summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-02-13 14:37:42 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-02-13 14:45:02 +0100
commit36cfeaf99bbf6f9431cb55ab9f04a67a491299c1 (patch)
tree0536b88644bc5caf4dcb413428ae7322053a7164 /source
parent60aa2d2f7109bc8e975f949d88729f1f3e4e7ac3 (diff)
downloadmupdf-36cfeaf99bbf6f9431cb55ab9f04a67a491299c1.tar.xz
Add JNI and JS bindings to layer device calls.
Diffstat (limited to 'source')
-rw-r--r--source/tools/murun.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 93e04b3e..4f535670 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1146,6 +1146,35 @@ js_dev_end_tile(fz_context *ctx, fz_device *dev)
js_endtry(J);
}
+static void
+js_dev_begin_layer(fz_context *ctx, fz_device *dev, const char *name)
+{
+ js_State *J = ((js_device*)dev)->J;
+ if (js_try(J))
+ rethrow_as_fz(J);
+ if (js_hasproperty(J, -1, "beginLayer")) {
+ js_copy(J, -2);
+ js_pushstring(J, name);
+ js_call(J, 1);
+ js_pop(J, 1);
+ }
+ js_endtry(J);
+}
+
+static void
+js_dev_end_layer(fz_context *ctx, fz_device *dev)
+{
+ js_State *J = ((js_device*)dev)->J;
+ if (js_try(J))
+ rethrow_as_fz(J);
+ if (js_hasproperty(J, -1, "endLayer")) {
+ js_copy(J, -2);
+ js_call(J, 0);
+ js_pop(J, 1);
+ }
+ js_endtry(J);
+}
+
static fz_device *new_js_device(fz_context *ctx, js_State *J)
{
js_device *dev = fz_new_derived_device(ctx, js_device);
@@ -1176,6 +1205,9 @@ static fz_device *new_js_device(fz_context *ctx, js_State *J)
dev->super.begin_tile = js_dev_begin_tile;
dev->super.end_tile = js_dev_end_tile;
+ dev->super.begin_layer = js_dev_begin_layer;
+ dev->super.end_layer = js_dev_end_layer;
+
dev->J = J;
return (fz_device*)dev;
}
@@ -1455,6 +1487,27 @@ static void ffi_Device_endTile(js_State *J)
rethrow(J);
}
+static void ffi_Device_beginLayer(js_State *J)
+{
+ fz_context *ctx = js_getcontext(J);
+ fz_device *dev = js_touserdata(J, 0, "fz_device");
+ const char *name = js_tostring(J, 1);
+ fz_try(ctx)
+ fz_begin_layer(ctx, dev, name);
+ fz_catch(ctx)
+ rethrow(J);
+}
+
+static void ffi_Device_endLayer(js_State *J)
+{
+ fz_context *ctx = js_getcontext(J);
+ fz_device *dev = js_touserdata(J, 0, "fz_device");
+ fz_try(ctx)
+ fz_end_layer(ctx, dev);
+ fz_catch(ctx)
+ rethrow(J);
+}
+
/* mupdf module */
static void ffi_readFile(js_State *J)
@@ -4469,6 +4522,9 @@ int murun_main(int argc, char **argv)
jsB_propfun(J, "Device.endGroup", ffi_Device_endGroup, 0);
jsB_propfun(J, "Device.beginTile", ffi_Device_beginTile, 6);
jsB_propfun(J, "Device.endTile", ffi_Device_endTile, 0);
+
+ jsB_propfun(J, "Device.beginLayer", ffi_Device_beginLayer, 1);
+ jsB_propfun(J, "Device.endLayer", ffi_Device_endLayer, 0);
}
js_setregistry(J, "fz_device");