You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
add support for custom Java Drawables
This is made possible, by adding a second Canvas implementation which can be used to render directly to GdkSnapshot objects For now the only implemented method is drawBitmap(), this is already enough to make VectorDrawableCompat functional
This commit is contained in:
16
src/api-impl-jni/graphics/android_graphics_GskCanvas.c
Normal file
16
src/api-impl-jni/graphics/android_graphics_GskCanvas.c
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <graphene.h>
|
||||
|
||||
#include "../defines.h"
|
||||
#include "../util.h"
|
||||
|
||||
#include "../generated_headers/android_graphics_GskCanvas.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_android_graphics_GskCanvas_native_1drawBitmap(JNIEnv *env, jclass this_class, jlong snapshot_ptr, jlong pixbuf_ptr, jint x, jint y, jint width, jint height)
|
||||
{
|
||||
GdkSnapshot *snapshot = (GdkSnapshot *)_PTR(snapshot_ptr);
|
||||
GdkPixbuf *pixbuf = (GdkPixbuf *)_PTR(pixbuf_ptr);
|
||||
GdkTexture *texture = gdk_texture_new_for_pixbuf(pixbuf);
|
||||
gtk_snapshot_append_texture(snapshot, texture, &GRAPHENE_RECT_INIT(x, y, width, height));
|
||||
g_object_unref(texture);
|
||||
}
|
||||
Reference in New Issue
Block a user