MCPcopy Create free account
hub / github.com/GNOME/gjs / getDeviceOffset_func

Function getDeviceOffset_func

modules/cairo-surface.cpp:150–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150GJS_JSAPI_RETURN_CONVENTION
151static bool getDeviceOffset_func(JSContext* cx, unsigned argc, JS::Value* vp) {
152 GJS_GET_THIS(cx, argc, vp, args, obj);
153
154 if (argc > 0) {
155 gjs_throw(cx, "Surface.getDeviceOffset() takes no arguments");
156 return false;
157 }
158
159 cairo_surface_t* surface = CairoSurface::for_js(cx, obj);
160 if (!surface)
161 return false;
162
163 double x_offset, y_offset;
164 cairo_surface_get_device_offset(surface, &x_offset, &y_offset);
165 // cannot error
166
167 JS::RootedValueArray<2> elements(cx);
168 elements[0].setNumber(JS::CanonicalizeNaN(x_offset));
169 elements[1].setNumber(JS::CanonicalizeNaN(y_offset));
170 JS::RootedObject retval(cx, JS::NewArrayObject(cx, elements));
171 if (!retval)
172 return false;
173
174 args.rval().setObject(*retval);
175 return true;
176}
177
178GJS_JSAPI_RETURN_CONVENTION
179static bool setDeviceScale_func(JSContext* cx, unsigned argc, JS::Value* vp) {

Callers

nothing calls this directly

Calls 1

gjs_throwFunction · 0.85

Tested by

no test coverage detected