-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GTK] Move snapshot mechanism to Java layer
This exposes the GDK/Cairo methods to allow us to implement taking a screenshot of an SWT widget directly in Java. To improve readability, the C methods have been split into separate GDK, GTK and Cairo files. See #871
- Loading branch information
Showing
7 changed files
with
350 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Patrick Ziegler and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Patrick Ziegler - initial API and implementation | ||
******************************************************************************/ | ||
#include "wbp.h" | ||
#include <jni.h> | ||
|
||
JNIEXPORT jint JNICALL OS_NATIVE(_1CAIRO_1FORMAT_1ARGB32) | ||
(JNIEnv *envir, jobject that) { | ||
return (jint) CAIRO_FORMAT_ARGB32; | ||
} | ||
|
||
JNIEXPORT jint JNICALL OS_NATIVE(_1CAIRO_1OPERATOR_1SOURCE) | ||
(JNIEnv *envir, jobject that) { | ||
return (jint) CAIRO_OPERATOR_SOURCE; | ||
} | ||
|
||
JNIEXPORT JHANDLE JNICALL OS_NATIVE(_1cairo_1create) | ||
(JNIEnv *envir, jobject that, JHANDLE target) { | ||
return (JHANDLE) cairo_create((cairo_surface_t *)(CHANDLE) target); | ||
} | ||
|
||
JNIEXPORT JHANDLE JNICALL OS_NATIVE(_1cairo_1image_1surface_1create) | ||
(JNIEnv *envir, jobject that, jint format, jint width, jint height) { | ||
return (JHANDLE) cairo_image_surface_create((cairo_format_t)format, (int) width, (int) height); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1cairo_1clip) | ||
(JNIEnv *envir, jobject that, JHANDLE cr) { | ||
cairo_clip((cairo_t *)(CHANDLE) cr); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1cairo_1paint) | ||
(JNIEnv *envir, jobject that, JHANDLE cr) { | ||
cairo_paint((cairo_t *)(CHANDLE) cr); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1cairo_1set_1operator) | ||
(JNIEnv *envir, jobject that, JHANDLE cr, jint op) { | ||
cairo_set_operator((cairo_t *)(CHANDLE) cr, (cairo_operator_t) op); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1cairo_1destroy) | ||
(JNIEnv *envir, jobject that, JHANDLE cr) { | ||
cairo_destroy((cairo_t *)(CHANDLE) cr); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1cairo_1surface_1flush) | ||
(JNIEnv *envir, jobject that, JHANDLE surface) { | ||
cairo_surface_flush((cairo_surface_t *)(CHANDLE) surface); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1cairo_1region_1destroy) | ||
(JNIEnv *envir, jobject that, JHANDLE region) { | ||
cairo_region_destroy((cairo_region_t *)(CHANDLE) region); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Patrick Ziegler and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Patrick Ziegler - initial API and implementation | ||
******************************************************************************/ | ||
#include "wbp.h" | ||
#include <jni.h> | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// JNI | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
JNIEXPORT jboolean JNICALL OS_NATIVE(_1gdk_1window_1is_1visible) | ||
(JNIEnv *envir, jobject that, JHANDLE windowHandle) { | ||
return gdk_window_is_visible((GdkWindow*)(CHANDLE) windowHandle); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1get_1geometry) | ||
(JNIEnv *envir, jobject that, JHANDLE windowHandle, jintArray x, jintArray y, jintArray width, jintArray height) { | ||
jint x1; | ||
jint y1; | ||
jint width1; | ||
jint height1; | ||
gdk_window_get_geometry((GdkWindow*)(CHANDLE) windowHandle, &x1, &y1, &width1, &height1); | ||
if (x != NULL) { | ||
(*envir) -> SetIntArrayRegion(envir, x, 0, 1, &x1); | ||
} | ||
if (y != NULL) { | ||
(*envir) -> SetIntArrayRegion(envir, y, 0, 1, &y1); | ||
} | ||
if (width != NULL) { | ||
(*envir) -> SetIntArrayRegion(envir, width, 0, 1, &width1); | ||
} | ||
if (height != NULL) { | ||
(*envir) -> SetIntArrayRegion(envir, height, 0, 1, &height1); | ||
} | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1window_1process_1updates) | ||
(JNIEnv *envir, jobject that, JHANDLE widgetHandle, jboolean update_children) { | ||
gdk_window_process_updates((GdkWindow*)(CHANDLE) widgetHandle, (gboolean) update_children); | ||
} | ||
|
||
JNIEXPORT JHANDLE JNICALL OS_NATIVE(_1gdk_1window_1get_1visible_1region) | ||
(JNIEnv *envir, jobject that, JHANDLE window) { | ||
return (JHANDLE) gdk_window_get_visible_region((GdkWindow *)(CHANDLE) window); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1region) | ||
(JNIEnv *envir, jobject that, JHANDLE cr, JHANDLE region) { | ||
gdk_cairo_region((cairo_t *)(CHANDLE) cr, (cairo_region_t *)(CHANDLE) region); | ||
} | ||
|
||
JNIEXPORT void JNICALL OS_NATIVE(_1gdk_1cairo_1set_1source_1window) | ||
(JNIEnv *envir, jobject that, JHANDLE cr, JHANDLE window, jdouble x, jdouble y) { | ||
gdk_cairo_set_source_window((cairo_t *)(CHANDLE) cr, (GdkWindow *)(CHANDLE) window, (gdouble)x, (gdouble)y); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.