[gjs] cairo: bind image_surface_get_{format,width,height,stride}
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] cairo: bind image_surface_get_{format,width,height,stride}
- Date: Sat, 6 Aug 2011 14:40:18 +0000 (UTC)
commit 0fe711d20ff9a24087480a170f4fdde43adfcb75
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Wed Jul 27 20:21:08 2011 +0200
cairo: bind image_surface_get_{format,width,height,stride}
Add some missing cairo_image_surface getters bindings.
https://bugzilla.gnome.org/show_bug.cgi?id=655447
modules/cairo-image-surface.c | 104 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 100 insertions(+), 4 deletions(-)
---
diff --git a/modules/cairo-image-surface.c b/modules/cairo-image-surface.c
index d8d2f70..d1525a7 100644
--- a/modules/cairo-image-surface.c
+++ b/modules/cairo-image-surface.c
@@ -99,13 +99,109 @@ createFromPNG_func(JSContext *context,
return JS_TRUE;
}
+static JSBool
+getFormat_func(JSContext *context,
+ uintN argc,
+ jsval *vp)
+{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
+ cairo_surface_t *surface;
+ cairo_format_t format;
+
+ if (argc > 1) {
+ gjs_throw(context, "ImageSurface.getFormat() takes no arguments");
+ return JS_FALSE;
+ }
+
+ surface = gjs_cairo_surface_get_surface(context, obj);
+ format = cairo_image_surface_get_format(surface);
+
+ if (!gjs_cairo_check_status(context, cairo_surface_status(surface), "surface"))
+ return JS_FALSE;
+
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(format));
+ return JS_TRUE;
+}
+
+static JSBool
+getWidth_func(JSContext *context,
+ uintN argc,
+ jsval *vp)
+{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
+ cairo_surface_t *surface;
+ int width;
+
+ if (argc > 1) {
+ gjs_throw(context, "ImageSurface.getWidth() takes no arguments");
+ return JS_FALSE;
+ }
+
+ surface = gjs_cairo_surface_get_surface(context, obj);
+ width = cairo_image_surface_get_width(surface);
+
+ if (!gjs_cairo_check_status(context, cairo_surface_status(surface), "surface"))
+ return JS_FALSE;
+
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(width));
+ return JS_TRUE;
+}
+
+static JSBool
+getHeight_func(JSContext *context,
+ uintN argc,
+ jsval *vp)
+{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
+ cairo_surface_t *surface;
+ int height;
+
+ if (argc > 1) {
+ gjs_throw(context, "ImageSurface.getHeight() takes no arguments");
+ return JS_FALSE;
+ }
+
+ surface = gjs_cairo_surface_get_surface(context, obj);
+ height = cairo_image_surface_get_height(surface);
+
+ if (!gjs_cairo_check_status(context, cairo_surface_status(surface), "surface"))
+ return JS_FALSE;
+
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(height));
+ return JS_TRUE;
+}
+
+static JSBool
+getStride_func(JSContext *context,
+ uintN argc,
+ jsval *vp)
+{
+ JSObject *obj = JS_THIS_OBJECT(context, vp);
+ cairo_surface_t *surface;
+ int stride;
+
+ if (argc > 1) {
+ gjs_throw(context, "ImageSurface.getStride() takes no arguments");
+ return JS_FALSE;
+ }
+
+ surface = gjs_cairo_surface_get_surface(context, obj);
+ stride = cairo_image_surface_get_stride(surface);
+
+ if (!gjs_cairo_check_status(context, cairo_surface_status(surface), "surface"))
+ return JS_FALSE;
+
+ JS_SET_RVAL(context, vp, INT_TO_JSVAL(stride));
+ return JS_TRUE;
+}
+
static JSFunctionSpec gjs_cairo_image_surface_proto_funcs[] = {
{ "createFromPNG", (JSNative)createFromPNG_func, 0, JSFUN_FAST_NATIVE},
// getData
- // getFormat
- // getWidth
- // getHeight
- // getStride
+ { "getFormat", (JSNative)getFormat_func, 0, JSFUN_FAST_NATIVE },
+ { "getWidth", (JSNative)getWidth_func, 0, JSFUN_FAST_NATIVE },
+ { "getHeight", (JSNative)getHeight_func, 0, JSFUN_FAST_NATIVE },
+ { "getStride", (JSNative)getStride_func, 0, JSFUN_FAST_NATIVE },
{ NULL }
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]