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
src/api-impl: use skia instead of cairo
Using the C API provided by SkiaSharp's skia fork instead of using cairo significantly improves performance. The API is also closer to the android Canvas API, which makes the implementation more straightforward.
This commit is contained in:
@@ -22,6 +22,9 @@ libart_dep = [
|
|||||||
libdl_bio_dep = [
|
libdl_bio_dep = [
|
||||||
cc.find_library('dl_bio')
|
cc.find_library('dl_bio')
|
||||||
]
|
]
|
||||||
|
libskia_dep = [
|
||||||
|
cc.find_library('SkiaSharp')
|
||||||
|
]
|
||||||
if fs.is_file('/usr' / get_option('libdir') / 'java/core-all_classes.jar')
|
if fs.is_file('/usr' / get_option('libdir') / 'java/core-all_classes.jar')
|
||||||
bootclasspath = '/usr' / get_option('libdir') / 'java/core-all_classes.jar'
|
bootclasspath = '/usr' / get_option('libdir') / 'java/core-all_classes.jar'
|
||||||
elif fs.is_file('/usr/local' / get_option('libdir') / 'java/core-all_classes.jar')
|
elif fs.is_file('/usr/local' / get_option('libdir') / 'java/core-all_classes.jar')
|
||||||
@@ -64,6 +67,7 @@ libtranslationlayer_so = shared_library('translation_layer_main', [
|
|||||||
'src/api-impl-jni/android_view_Window.c',
|
'src/api-impl-jni/android_view_Window.c',
|
||||||
'src/api-impl-jni/util.c',
|
'src/api-impl-jni/util.c',
|
||||||
'src/api-impl-jni/android_graphics_Canvas.c',
|
'src/api-impl-jni/android_graphics_Canvas.c',
|
||||||
|
'src/api-impl-jni/android_graphics_Paint.c',
|
||||||
'src/api-impl-jni/database/android_database_SQLiteCommon.c',
|
'src/api-impl-jni/database/android_database_SQLiteCommon.c',
|
||||||
'src/api-impl-jni/database/android_database_SQLiteConnection.c',
|
'src/api-impl-jni/database/android_database_SQLiteConnection.c',
|
||||||
'src/api-impl-jni/drawables/ninepatch.c',
|
'src/api-impl-jni/drawables/ninepatch.c',
|
||||||
@@ -91,11 +95,13 @@ libtranslationlayer_so = shared_library('translation_layer_main', [
|
|||||||
'src/api-impl-jni/app/android_app_Activity.c',
|
'src/api-impl-jni/app/android_app_Activity.c',
|
||||||
'src/api-impl-jni/app/android_app_AlertDialog.c',
|
'src/api-impl-jni/app/android_app_AlertDialog.c',
|
||||||
'src/api-impl-jni/app/android_app_Dialog.c',
|
'src/api-impl-jni/app/android_app_Dialog.c',
|
||||||
|
'src/sk_area/sk_area.c',
|
||||||
] + marshal_files,
|
] + marshal_files,
|
||||||
|
include_directories: ['src/sk_area/'],
|
||||||
install: true,
|
install: true,
|
||||||
install_dir : get_option('libdir') / 'java/dex/android_translation_layer/natives',
|
install_dir : get_option('libdir') / 'java/dex/android_translation_layer/natives',
|
||||||
dependencies: [
|
dependencies: [
|
||||||
dependency('gtk4'), dependency('gl'), dependency('egl'), dependency('wayland-client'), dependency('jni'), dependency('libportal'), dependency('sqlite3')
|
dependency('gtk4'), dependency('gl'), dependency('egl'), dependency('wayland-client'), dependency('jni'), dependency('libportal'), dependency('sqlite3'), libskia_dep
|
||||||
],
|
],
|
||||||
link_with: [ libandroid_so ],
|
link_with: [ libandroid_so ],
|
||||||
link_args: [
|
link_args: [
|
||||||
|
|||||||
@@ -3,12 +3,38 @@
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "../sk_area/include/c/sk_data.h"
|
||||||
|
#include "../sk_area/include/c/sk_image.h"
|
||||||
|
|
||||||
#include "generated_headers/android_graphics_Bitmap.h"
|
#include "generated_headers/android_graphics_Bitmap.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We use a GdkPixbuf as the backing for a bitmap.
|
||||||
|
* We additionally create a view into it as a skia image,
|
||||||
|
* so we can pass it to skia functions.
|
||||||
|
*/
|
||||||
JNIEXPORT jlong JNICALL Java_android_graphics_Bitmap_native_1bitmap_1from_1path(JNIEnv *env, jobject this, jobject path)
|
JNIEXPORT jlong JNICALL Java_android_graphics_Bitmap_native_1bitmap_1from_1path(JNIEnv *env, jobject this, jobject path)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(_CSTRING(path), NULL);
|
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(_CSTRING(path), NULL);
|
||||||
printf(">>> made pixbuf from path: >%s<, >%p<\n", _CSTRING(path), pixbuf);
|
printf(">>> made pixbuf from path: >%s<, >%p<\n", _CSTRING(path), pixbuf);
|
||||||
|
|
||||||
|
sk_imageinfo_t info = {
|
||||||
|
.width = gdk_pixbuf_get_width(pixbuf),
|
||||||
|
.height = gdk_pixbuf_get_height(pixbuf),
|
||||||
|
.colorType = RGBA_8888_SK_COLORTYPE, // is this correct?
|
||||||
|
.alphaType = PREMUL_SK_ALPHATYPE,
|
||||||
|
};
|
||||||
|
|
||||||
|
void *pixbuf_pixels = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
|
int rowstride = gdk_pixbuf_get_rowstride(pixbuf);
|
||||||
|
size_t pixbuf_size = rowstride * (info.height - 1)
|
||||||
|
+ /* last row: */ info.width * ((gdk_pixbuf_get_n_channels(pixbuf) * gdk_pixbuf_get_bits_per_sample(pixbuf) + 7) / 8);
|
||||||
|
/* use the data as-is, and don't ever free it because the pixbuf owns it */
|
||||||
|
sk_data_t *pixels = sk_data_new_with_proc(pixbuf_pixels, pixbuf_size, NULL, NULL);
|
||||||
|
|
||||||
|
sk_image_t *image = sk_image_new_raster_data(&info, pixels, rowstride);
|
||||||
|
g_object_set_data(G_OBJECT(pixbuf), "sk_image", image);
|
||||||
|
|
||||||
g_object_ref(pixbuf);
|
g_object_ref(pixbuf);
|
||||||
return _INTPTR(pixbuf);
|
return _INTPTR(pixbuf);
|
||||||
}
|
}
|
||||||
@@ -49,6 +75,13 @@ JNIEXPORT void JNICALL Java_android_graphics_Bitmap_nativeGetPixels(JNIEnv *env,
|
|||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_android_graphics_Bitmap_nativeRecycle(JNIEnv *env, jclass, jlong bitmapHandle) {
|
JNIEXPORT jboolean JNICALL Java_android_graphics_Bitmap_nativeRecycle(JNIEnv *env, jclass, jlong bitmapHandle) {
|
||||||
GdkPixbuf *pixbuf = _PTR(bitmapHandle);
|
GdkPixbuf *pixbuf = _PTR(bitmapHandle);
|
||||||
|
sk_image_t *image = g_object_get_data(G_OBJECT(pixbuf), "sk_image");
|
||||||
|
if(!image) {
|
||||||
|
fprintf(stderr, "pixbuf doesn't have a skia image associated: %p\n", pixbuf);
|
||||||
|
g_object_unref(pixbuf);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sk_image_unref(image);
|
||||||
g_object_unref(pixbuf);
|
g_object_unref(pixbuf);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,67 +3,68 @@
|
|||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "../sk_area/include/c/sk_canvas.h"
|
||||||
|
#include "../sk_area/include/c/sk_image.h"
|
||||||
#include "generated_headers/android_graphics_Canvas.h"
|
#include "generated_headers/android_graphics_Canvas.h"
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1save(JNIEnv *env, jclass this, jlong cairo_context, jlong widget)
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1save(JNIEnv *env, jclass this, jlong skia_canvas, jlong widget)
|
||||||
{
|
{
|
||||||
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
|
|
||||||
cairo_save(cr);
|
sk_canvas_save(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1restore(JNIEnv *env, jclass this, jlong cairo_context, jlong widget)
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1restore(JNIEnv *env, jclass this, jlong skia_canvas, jlong widget)
|
||||||
{
|
{
|
||||||
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
|
|
||||||
cairo_restore(cr);
|
sk_canvas_restore(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawLine(JNIEnv *env, jclass this_class, jlong cairo_context, jlong widget, jfloat start_x, jfloat start_y, jfloat stop_x, jfloat stop_y, jint paint_color)
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawLine(JNIEnv *env, jclass this_class, jlong skia_canvas, jlong widget, jfloat start_x, jfloat start_y, jfloat stop_x, jfloat stop_y, jlong skia_paint)
|
||||||
{
|
{
|
||||||
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
|
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||||
|
|
||||||
// TODO: cairo is not stateless, so we should probably check that the state is not already what we want it to be before we tell cairo to change it
|
sk_canvas_draw_line(canvas, start_x, start_y, stop_x, stop_y, paint);
|
||||||
// NOTE: we should make sure that cairo doesn't do this microoptimization internally before we implement it here
|
|
||||||
|
|
||||||
char buf[10]; //#rrggbbaa\0
|
|
||||||
snprintf(buf, 10, "#%06x%02x", paint_color & 0x00FFFFFF, paint_color>>24);
|
|
||||||
GdkRGBA color;
|
|
||||||
gdk_rgba_parse(&color, buf);
|
|
||||||
|
|
||||||
gdk_cairo_set_source_rgba(cr, &color);
|
|
||||||
|
|
||||||
cairo_move_to(cr, start_x, start_y);
|
|
||||||
cairo_line_to(cr, stop_x, stop_y);
|
|
||||||
cairo_stroke(cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawBitmap(JNIEnv *env , jclass this_class, jlong cairo_context, jlong widget, jlong _pixbuf, jfloat src_x, jfloat src_y, jfloat dest_x , jfloat dest_y, jfloat dest_w , jfloat dest_h, jobject paint)
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawBitmap(JNIEnv *env , jclass this_class, jlong skia_canvas, jlong widget, jlong _pixbuf, jfloat src_x, jfloat src_y, jfloat dest_x , jfloat dest_y, jfloat dest_w , jfloat dest_h, jlong skia_paint)
|
||||||
{
|
{
|
||||||
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
GdkPixbuf *pixbuf = (GdkPixbuf *)_PTR(_pixbuf);
|
GdkPixbuf *pixbuf = (GdkPixbuf *)_PTR(_pixbuf);
|
||||||
|
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||||
|
|
||||||
cairo_translate(cr, dest_x, dest_y);
|
sk_image_t *image = g_object_get_data(G_OBJECT(pixbuf), "sk_image");
|
||||||
cairo_scale(cr, dest_w / gdk_pixbuf_get_width(pixbuf), dest_h / gdk_pixbuf_get_height(pixbuf));
|
if(!image) {
|
||||||
gdk_cairo_set_source_pixbuf(cr, pixbuf, src_x, src_y);
|
fprintf(stderr, "pixbuf doesn't have a skia image associated: %p\n", pixbuf);
|
||||||
cairo_paint(cr);
|
return;
|
||||||
cairo_translate(cr, -dest_x, -dest_y);
|
}
|
||||||
|
sk_canvas_draw_image(canvas, image, dest_x, dest_y, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: if we switched to using the snapshot mechanic directly instead of having a DrawingArea, these two could possibly (maybe it clips or something?) be replaced with hw-accelerated Gsk functions
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawRect(JNIEnv *env, jclass this, jlong skia_canvas, jfloat left, jfloat top, jfloat right, jfloat bottom, jlong skia_paint)
|
||||||
// NOTE: it's unclear whether using the snapshot mechanic would still give us the same cairo context each time, and getting the same cairo context each time sure is convenient
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1rotate(JNIEnv *env, jclass this, jlong cairo_context, jlong widget, jfloat angle)
|
|
||||||
{
|
{
|
||||||
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
|
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||||
|
|
||||||
cairo_rotate(cr, DEG2RAD(angle));
|
// FIXME: this doesn't work great with dark mode, since the text stays light even if the game draws white background
|
||||||
|
// sk_canvas_draw_rect(canvas, &(sk_rect_t){left, top, right, bottom}, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1rotate_1and_1translate(JNIEnv *env, jclass this, jlong cairo_context, jlong widget, jfloat angle, jfloat tx, jfloat ty)
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1rotate(JNIEnv *env, jclass this, jlong skia_canvas, jlong widget, jfloat angle)
|
||||||
{
|
{
|
||||||
cairo_t *cr = (cairo_t *)_PTR(cairo_context);
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
|
|
||||||
|
sk_canvas_rotate_degrees(canvas, angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1rotate_1and_1translate(JNIEnv *env, jclass this, jlong skia_canvas, jlong widget, jfloat angle, jfloat tx, jfloat ty)
|
||||||
|
{
|
||||||
|
sk_canvas_t *canvas = (sk_canvas_t *)_PTR(skia_canvas);
|
||||||
|
|
||||||
|
sk_canvas_translate(canvas, tx, ty);
|
||||||
|
sk_canvas_rotate_degrees(canvas, angle);
|
||||||
|
sk_canvas_translate(canvas, -tx, -ty);
|
||||||
|
|
||||||
cairo_translate(cr, tx, ty);
|
|
||||||
cairo_rotate(cr, DEG2RAD(angle));
|
|
||||||
cairo_translate(cr, -tx, -ty);
|
|
||||||
}
|
}
|
||||||
|
|||||||
27
src/api-impl-jni/android_graphics_Paint.c
Normal file
27
src/api-impl-jni/android_graphics_Paint.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "defines.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#include "../sk_area/include/c/sk_paint.h"
|
||||||
|
#include "generated_headers/android_graphics_Paint.h"
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_android_graphics_Paint_native_1constructor(JNIEnv *env, jobject this)
|
||||||
|
{
|
||||||
|
return _INTPTR(sk_paint_new());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* NOTE: sk_color_t seems to have the same internal representation as android uses for color, so we just pass that directly */
|
||||||
|
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1color(JNIEnv *env, jobject this, jlong skia_paint, jint color)
|
||||||
|
{
|
||||||
|
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||||
|
|
||||||
|
sk_paint_set_color(paint, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_android_graphics_Paint_native_1get_1color(JNIEnv *env, jobject this, jlong skia_paint)
|
||||||
|
{
|
||||||
|
sk_paint_t *paint = (sk_paint_t *)_PTR(skia_paint);
|
||||||
|
|
||||||
|
return sk_paint_get_color(paint);
|
||||||
|
}
|
||||||
@@ -23,21 +23,29 @@ JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1save
|
|||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1restore
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1restore
|
||||||
(JNIEnv *, jclass, jlong, jlong);
|
(JNIEnv *, jclass, jlong, jlong);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_graphics_Canvas
|
||||||
|
* Method: native_drawRect
|
||||||
|
* Signature: (JFFFFJ)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawRect
|
||||||
|
(JNIEnv *, jclass, jlong, jfloat, jfloat, jfloat, jfloat, jlong);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_graphics_Canvas
|
* Class: android_graphics_Canvas
|
||||||
* Method: native_drawLine
|
* Method: native_drawLine
|
||||||
* Signature: (JJFFFFI)V
|
* Signature: (JJFFFFJ)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawLine
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawLine
|
||||||
(JNIEnv *, jclass, jlong, jlong, jfloat, jfloat, jfloat, jfloat, jint);
|
(JNIEnv *, jclass, jlong, jlong, jfloat, jfloat, jfloat, jfloat, jlong);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_graphics_Canvas
|
* Class: android_graphics_Canvas
|
||||||
* Method: native_drawBitmap
|
* Method: native_drawBitmap
|
||||||
* Signature: (JJJFFFFFFLandroid/graphics/Paint;)V
|
* Signature: (JJJFFFFFFJ)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawBitmap
|
JNIEXPORT void JNICALL Java_android_graphics_Canvas_native_1drawBitmap
|
||||||
(JNIEnv *, jclass, jlong, jlong, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jobject);
|
(JNIEnv *, jclass, jlong, jlong, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jlong);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_graphics_Canvas
|
* Class: android_graphics_Canvas
|
||||||
|
|||||||
37
src/api-impl-jni/generated_headers/android_graphics_Paint.h
Normal file
37
src/api-impl-jni/generated_headers/android_graphics_Paint.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class android_graphics_Paint */
|
||||||
|
|
||||||
|
#ifndef _Included_android_graphics_Paint
|
||||||
|
#define _Included_android_graphics_Paint
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: android_graphics_Paint
|
||||||
|
* Method: native_constructor
|
||||||
|
* Signature: ()J
|
||||||
|
*/
|
||||||
|
JNIEXPORT jlong JNICALL Java_android_graphics_Paint_native_1constructor
|
||||||
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_graphics_Paint
|
||||||
|
* Method: native_set_color
|
||||||
|
* Signature: (JI)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_graphics_Paint_native_1set_1color
|
||||||
|
(JNIEnv *, jobject, jlong, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_graphics_Paint
|
||||||
|
* Method: native_get_color
|
||||||
|
* Signature: (J)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_android_graphics_Paint_native_1get_1color
|
||||||
|
(JNIEnv *, jobject, jlong);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@@ -195,14 +195,6 @@ JNIEXPORT void JNICALL Java_android_view_View_setVisibility(JNIEnv *env, jobject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this is used in one other place as well, should probably go in util.c or gtk_util.c?
|
|
||||||
gboolean tick_callback(GtkWidget* widget, GdkFrameClock* frame_clock, gpointer user_data)
|
|
||||||
{
|
|
||||||
gtk_widget_queue_draw(widget);
|
|
||||||
gtk_widget_queue_draw(gtk_widget_get_parent(widget));
|
|
||||||
return G_SOURCE_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_android_view_View_native_1constructor(JNIEnv *env, jobject this, jobject context, jobject attrs)
|
JNIEXPORT jlong JNICALL Java_android_view_View_native_1constructor(JNIEnv *env, jobject this, jobject context, jobject attrs)
|
||||||
{
|
{
|
||||||
GtkWidget *wrapper = g_object_ref(wrapper_widget_new());
|
GtkWidget *wrapper = g_object_ref(wrapper_widget_new());
|
||||||
@@ -210,8 +202,6 @@ JNIEXPORT jlong JNICALL Java_android_view_View_native_1constructor(JNIEnv *env,
|
|||||||
wrapper_widget_set_child(WRAPPER_WIDGET(wrapper), area);
|
wrapper_widget_set_child(WRAPPER_WIDGET(wrapper), area);
|
||||||
wrapper_widget_set_jobject(WRAPPER_WIDGET(wrapper), env, this);
|
wrapper_widget_set_jobject(WRAPPER_WIDGET(wrapper), env, this);
|
||||||
|
|
||||||
gtk_widget_add_tick_callback(area, tick_callback, NULL, NULL);
|
|
||||||
|
|
||||||
return _INTPTR(area);
|
return _INTPTR(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,46 +4,10 @@
|
|||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
#include "../drawables/ninepatch.h"
|
#include "../drawables/ninepatch.h"
|
||||||
|
|
||||||
|
#include "../sk_area/sk_area.h"
|
||||||
|
|
||||||
#include "WrapperWidget.h"
|
#include "WrapperWidget.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* gdk_texture_new_for_surface:
|
|
||||||
* @surface: a cairo image surface
|
|
||||||
*
|
|
||||||
* Creates a new texture object representing the surface.
|
|
||||||
*
|
|
||||||
* @surface must be an image surface with format CAIRO_FORMAT_ARGB32.
|
|
||||||
*
|
|
||||||
* Returns: a new `GdkTexture`
|
|
||||||
*/
|
|
||||||
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface)
|
|
||||||
{
|
|
||||||
GdkTexture *texture;
|
|
||||||
GBytes *bytes;
|
|
||||||
|
|
||||||
g_return_val_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE, NULL);
|
|
||||||
g_return_val_if_fail (cairo_image_surface_get_width (surface) > 0, NULL);
|
|
||||||
g_return_val_if_fail (cairo_image_surface_get_height (surface) > 0, NULL);
|
|
||||||
|
|
||||||
bytes = g_bytes_new_with_free_func (cairo_image_surface_get_data (surface),
|
|
||||||
cairo_image_surface_get_height (surface)
|
|
||||||
* cairo_image_surface_get_stride (surface),
|
|
||||||
(GDestroyNotify) cairo_surface_destroy,
|
|
||||||
cairo_surface_reference (surface));
|
|
||||||
|
|
||||||
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
|
|
||||||
cairo_image_surface_get_height (surface),
|
|
||||||
GDK_MEMORY_DEFAULT,
|
|
||||||
bytes,
|
|
||||||
cairo_image_surface_get_stride (surface));
|
|
||||||
|
|
||||||
g_bytes_unref (bytes);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---
|
|
||||||
|
|
||||||
G_DEFINE_TYPE(WrapperWidget, wrapper_widget, GTK_TYPE_WIDGET)
|
G_DEFINE_TYPE(WrapperWidget, wrapper_widget, GTK_TYPE_WIDGET)
|
||||||
|
|
||||||
static void wrapper_widget_init (WrapperWidget *wrapper_widget)
|
static void wrapper_widget_init (WrapperWidget *wrapper_widget)
|
||||||
@@ -66,54 +30,27 @@ static void wrapper_widget_dispose(GObject *wrapper_widget)
|
|||||||
G_OBJECT_CLASS (wrapper_widget_parent_class)->dispose (wrapper_widget);
|
G_OBJECT_CLASS (wrapper_widget_parent_class)->dispose (wrapper_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wrapper_snapshot(GtkWidget* widget, GtkSnapshot* snapshot)
|
void skia_draw_func(SKArea *sk_area, sk_canvas_t *canvas, WrapperWidget *wrapper_widget)
|
||||||
{
|
{
|
||||||
struct ninepatch_t *ninepatch = g_object_get_data(G_OBJECT(widget), "background_ninepatch");
|
JNIEnv *env;
|
||||||
|
(*wrapper_widget->jvm)->GetEnv(wrapper_widget->jvm, (void**)&env, JNI_VERSION_1_6);
|
||||||
if(ninepatch && 0) {
|
if(wrapper_widget->canvas == NULL) {
|
||||||
GtkAllocation alloc;
|
wrapper_widget->canvas = _REF((*env)->NewObject(env, handle_cache.canvas.class, handle_cache.canvas.constructor, _INTPTR(canvas), 0));
|
||||||
gtk_widget_get_allocation(widget, &alloc);
|
} else {
|
||||||
|
_SET_LONG_FIELD(wrapper_widget->canvas, "skia_canvas", _INTPTR(canvas));
|
||||||
ninepatch_stretch(ninepatch, alloc.width, alloc.height);
|
|
||||||
|
|
||||||
cairo_surface_t *surface = ninepatch_to_surface(ninepatch);
|
|
||||||
|
|
||||||
// GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, ninepatch->__w, ninepatch->__h);
|
|
||||||
// GdkTexture *texture = gdk_texture_new_for_pixbuf(pixbuf);
|
|
||||||
GdkTexture *texture = gdk_texture_new_for_surface(surface);
|
|
||||||
|
|
||||||
gtk_snapshot_append_texture(snapshot, texture, &GRAPHENE_RECT_INIT(0, 0, ninepatch->__w, ninepatch->__h));
|
|
||||||
|
|
||||||
cairo_surface_destroy(surface);
|
|
||||||
// g_object_unref(pixbuf);
|
|
||||||
g_object_unref(texture);
|
|
||||||
}
|
}
|
||||||
gtk_widget_snapshot_child(widget, gtk_widget_get_first_child(widget), snapshot);
|
|
||||||
|
|
||||||
// if onDraw method is overwritten call it now
|
(*env)->CallVoidMethod(env, wrapper_widget->jobj, wrapper_widget->draw_method, wrapper_widget->canvas);
|
||||||
WrapperWidget *wrapper_widget = WRAPPER_WIDGET(widget);
|
|
||||||
GtkAllocation alloc;
|
|
||||||
gtk_widget_get_allocation(widget, &alloc);
|
|
||||||
if (wrapper_widget->draw_method) {
|
|
||||||
cairo_t *cr = gtk_snapshot_append_cairo (snapshot, &GRAPHENE_RECT_INIT(0, 0, alloc.width, alloc.height));
|
|
||||||
|
|
||||||
JNIEnv *env;
|
if((*env)->ExceptionCheck(env))
|
||||||
(*wrapper_widget->jvm)->GetEnv(wrapper_widget->jvm, (void**)&env, JNI_VERSION_1_6);
|
(*env)->ExceptionDescribe(env);
|
||||||
if(wrapper_widget->canvas == NULL) {
|
|
||||||
wrapper_widget->canvas = _REF((*env)->NewObject(env, handle_cache.canvas.class, handle_cache.canvas.constructor, _INTPTR(cr), 0));
|
|
||||||
} else {
|
|
||||||
_SET_LONG_FIELD(wrapper_widget->canvas, "cairo_context", _INTPTR(cr));
|
|
||||||
}
|
|
||||||
|
|
||||||
(*env)->CallVoidMethod(env, wrapper_widget->jobj, wrapper_widget->draw_method, wrapper_widget->canvas);
|
|
||||||
|
|
||||||
if((*env)->ExceptionCheck(env))
|
|
||||||
(*env)->ExceptionDescribe(env);
|
|
||||||
|
|
||||||
cairo_destroy (cr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void wrapper_snapshot(GtkWidget* widget, GtkSnapshot* snapshot)
|
||||||
|
{
|
||||||
|
gtk_widget_snapshot_child(widget, gtk_widget_get_first_child(widget), snapshot);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
static void wrapper_widget_class_init(WrapperWidgetClass *class)
|
static void wrapper_widget_class_init(WrapperWidgetClass *class)
|
||||||
{
|
{
|
||||||
@@ -122,7 +59,7 @@ static void wrapper_widget_class_init(WrapperWidgetClass *class)
|
|||||||
|
|
||||||
object_class->dispose = wrapper_widget_dispose;
|
object_class->dispose = wrapper_widget_dispose;
|
||||||
|
|
||||||
widget_class->snapshot = wrapper_snapshot;
|
// widget_class->snapshot = wrapper_snapshot;
|
||||||
|
|
||||||
gtk_widget_class_set_layout_manager_type(widget_class, GTK_TYPE_BIN_LAYOUT);
|
gtk_widget_class_set_layout_manager_type(widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||||
}
|
}
|
||||||
@@ -156,6 +93,14 @@ static void on_mapped(GtkWidget* self, gpointer data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: this is used in one other place as well, should probably go in util.c or gtk_util.c?
|
||||||
|
gboolean tick_callback(GtkWidget* widget, GdkFrameClock* frame_clock, gpointer user_data)
|
||||||
|
{
|
||||||
|
gtk_widget_queue_draw(widget);
|
||||||
|
gtk_widget_queue_draw(gtk_widget_get_parent(widget));
|
||||||
|
return G_SOURCE_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject jobj)
|
void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject jobj)
|
||||||
{
|
{
|
||||||
JavaVM *jvm;
|
JavaVM *jvm;
|
||||||
@@ -163,9 +108,15 @@ void wrapper_widget_set_jobject(WrapperWidget *wrapper, JNIEnv *env, jobject job
|
|||||||
wrapper->jvm = jvm;
|
wrapper->jvm = jvm;
|
||||||
wrapper->jobj = _REF(jobj);
|
wrapper->jobj = _REF(jobj);
|
||||||
jmethodID draw_method = _METHOD(_CLASS(jobj), "onDraw", "(Landroid/graphics/Canvas;)V");
|
jmethodID draw_method = _METHOD(_CLASS(jobj), "onDraw", "(Landroid/graphics/Canvas;)V");
|
||||||
if (draw_method != handle_cache.view.onDraw)
|
if (draw_method != handle_cache.view.onDraw) {
|
||||||
wrapper->draw_method = draw_method;
|
wrapper->draw_method = draw_method;
|
||||||
|
|
||||||
|
GtkWidget *sk_area = sk_area_new();
|
||||||
|
sk_area_set_draw_func(SK_AREA_WIDGET(sk_area), skia_draw_func, wrapper);
|
||||||
|
gtk_widget_insert_before(sk_area, GTK_WIDGET(wrapper), NULL);
|
||||||
|
gtk_widget_add_tick_callback(sk_area, tick_callback, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
jmethodID measure_method = _METHOD(_CLASS(jobj), "onMeasure", "(II)V");
|
jmethodID measure_method = _METHOD(_CLASS(jobj), "onMeasure", "(II)V");
|
||||||
if (measure_method != handle_cache.view.onMeasure) {
|
if (measure_method != handle_cache.view.onMeasure) {
|
||||||
wrapper->measure_method = measure_method;
|
wrapper->measure_method = measure_method;
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
package android.graphics;
|
package android.graphics;
|
||||||
|
|
||||||
public class Canvas {
|
public class Canvas {
|
||||||
public long cairo_context;
|
public long skia_canvas;
|
||||||
public long widget;
|
public long widget;
|
||||||
|
|
||||||
public Canvas() {}
|
public Canvas() {}
|
||||||
|
|
||||||
public Canvas(Bitmap bmp) {}
|
public Canvas(Bitmap bmp) {}
|
||||||
|
|
||||||
public Canvas(long cairo_context, long widget) {
|
public Canvas(long skia_canvas, long widget) {
|
||||||
this.cairo_context = cairo_context;
|
this.skia_canvas = skia_canvas;
|
||||||
this.widget = widget;
|
this.widget = widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: are these _needed_ ?
|
// FIXME: are these _needed_ ?
|
||||||
|
|
||||||
public int save() {
|
public int save() {
|
||||||
native_save(cairo_context, widget);
|
native_save(skia_canvas, widget);
|
||||||
return -1; // FIXME: wtf should we return
|
return -1; // FIXME: wtf should we return
|
||||||
}
|
}
|
||||||
public void restore() {
|
public void restore() {
|
||||||
native_restore(cairo_context, widget);
|
native_restore(skia_canvas, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native void native_save(long cairo_context, long widget);
|
private static native void native_save(long skia_canvas, long widget);
|
||||||
private static native void native_restore(long cairo_context, long widget);
|
private static native void native_restore(long skia_canvas, long widget);
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ public class Canvas {
|
|||||||
* @param rect The rect to be drawn
|
* @param rect The rect to be drawn
|
||||||
* @param paint The paint used to draw the rect
|
* @param paint The paint used to draw the rect
|
||||||
*/
|
*/
|
||||||
public void drawRect(RectF rect, Paint paint) {
|
public void drawRect(RectF r, Paint paint) {
|
||||||
// native_drawRect(mNativeCanvas, rect, paint.mNativePaint);
|
drawRect(r.left, r.top, r.right, r.bottom, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +61,7 @@ public class Canvas {
|
|||||||
* @param paint The paint used to draw the rect
|
* @param paint The paint used to draw the rect
|
||||||
*/
|
*/
|
||||||
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
|
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
|
||||||
// native_drawRect(mNativeCanvas, left, top, right, bottom, paint.mNativePaint);
|
native_drawRect(skia_canvas, left, top, right, bottom, paint.skia_paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
@@ -71,7 +71,7 @@ public class Canvas {
|
|||||||
* @param degrees The amount to rotate, in degrees
|
* @param degrees The amount to rotate, in degrees
|
||||||
*/
|
*/
|
||||||
public void rotate(float degrees) {
|
public void rotate(float degrees) {
|
||||||
native_rotate(cairo_context, widget, degrees);
|
native_rotate(skia_canvas, widget, degrees);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,7 +82,7 @@ public class Canvas {
|
|||||||
* @param py The y-coord for the pivot point (unchanged by the rotation)
|
* @param py The y-coord for the pivot point (unchanged by the rotation)
|
||||||
*/
|
*/
|
||||||
public final void rotate(float degrees, float px, float py) {
|
public final void rotate(float degrees, float px, float py) {
|
||||||
native_rotate_and_translate(cairo_context, widget, degrees, px, py);
|
native_rotate_and_translate(skia_canvas, widget, degrees, px, py);
|
||||||
}
|
}
|
||||||
// ---
|
// ---
|
||||||
/**
|
/**
|
||||||
@@ -186,7 +186,7 @@ public class Canvas {
|
|||||||
* @param sx The amount to scale in X
|
* @param sx The amount to scale in X
|
||||||
* @param sy The amount to scale in Y
|
* @param sy The amount to scale in Y
|
||||||
*/
|
*/
|
||||||
public /*native*/ void scale(float sx, float sy) {}
|
public /*native*/ void scale(float sx, float sy) {/*used by gd*/}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preconcat the current matrix with the specified scale.
|
* Preconcat the current matrix with the specified scale.
|
||||||
@@ -197,6 +197,7 @@ public class Canvas {
|
|||||||
* @param py The y-coord for the pivot point (unchanged by the scale)
|
* @param py The y-coord for the pivot point (unchanged by the scale)
|
||||||
*/
|
*/
|
||||||
public final void scale(float sx, float sy, float px, float py) {
|
public final void scale(float sx, float sy, float px, float py) {
|
||||||
|
System.out.println("XXXXXXX scale(sx, sy, px, py)");
|
||||||
/*translate(px, py);
|
/*translate(px, py);
|
||||||
scale(sx, sy);
|
scale(sx, sy);
|
||||||
translate(-px, -py);*/
|
translate(-px, -py);*/
|
||||||
@@ -221,7 +222,9 @@ public class Canvas {
|
|||||||
* @param top The position of the top side of the bitmap being drawn
|
* @param top The position of the top side of the bitmap being drawn
|
||||||
* @param paint The paint used to draw the bitmap (may be null)
|
* @param paint The paint used to draw the bitmap (may be null)
|
||||||
*/
|
*/
|
||||||
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) { /*
|
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
|
||||||
|
System.out.println("XXXXXXX bitmap(bitmap, left, top, paint)");
|
||||||
|
/*
|
||||||
native_drawBitmap(mNativeCanvas, bitmap.ni(), left, top, paint != null ? paint.mNativePaint : 0, mDensity, mScreenDensity, bitmap.mDensity);
|
native_drawBitmap(mNativeCanvas, bitmap.ni(), left, top, paint != null ? paint.mNativePaint : 0, mDensity, mScreenDensity, bitmap.mDensity);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@@ -252,7 +255,7 @@ public class Canvas {
|
|||||||
if (dst == null) {
|
if (dst == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
native_drawBitmap(cairo_context, widget, bitmap.pixbuf, src.left, src.top, dst.left, dst.top, dst.width(), dst.height(), paint); // FIXME - ignores width/height of source
|
native_drawBitmap(skia_canvas, widget, bitmap.pixbuf, src.left, src.top, dst.left, dst.top, dst.width(), dst.height(), (paint != null) ? paint.skia_paint : 0); // FIXME - ignores width/height of source
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -277,7 +280,9 @@ public class Canvas {
|
|||||||
* to fit into
|
* to fit into
|
||||||
* @param paint May be null. The paint used to draw the bitmap
|
* @param paint May be null. The paint used to draw the bitmap
|
||||||
*/
|
*/
|
||||||
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) { /*
|
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
|
||||||
|
System.out.println("XXXXXXX bitmap(bitmap, src, dst, paint)");
|
||||||
|
/*
|
||||||
if (dst == null) {
|
if (dst == null) {
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
}
|
}
|
||||||
@@ -306,6 +311,7 @@ public class Canvas {
|
|||||||
*/
|
*/
|
||||||
public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
|
public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
|
||||||
int width, int height, boolean hasAlpha, Paint paint) {
|
int width, int height, boolean hasAlpha, Paint paint) {
|
||||||
|
System.out.println("XXXXXXX bitmap(colors, offset, ...)");
|
||||||
/* // check for valid input
|
/* // check for valid input
|
||||||
if (width < 0) {
|
if (width < 0) {
|
||||||
throw new IllegalArgumentException("width must be >= 0");
|
throw new IllegalArgumentException("width must be >= 0");
|
||||||
@@ -349,6 +355,7 @@ public class Canvas {
|
|||||||
* @param paint May be null. The paint used to draw the bitmap
|
* @param paint May be null. The paint used to draw the bitmap
|
||||||
*/
|
*/
|
||||||
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
|
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
|
||||||
|
System.out.println("XXXXXXX bitmap(bitmap, matrix, paint)");
|
||||||
/* nativeDrawBitmapMatrix(mNativeCanvas, bitmap.ni(), matrix.ni(),
|
/* nativeDrawBitmapMatrix(mNativeCanvas, bitmap.ni(), matrix.ni(),
|
||||||
paint != null ? paint.mNativePaint : 0);*/
|
paint != null ? paint.mNativePaint : 0);*/
|
||||||
}
|
}
|
||||||
@@ -366,13 +373,14 @@ public class Canvas {
|
|||||||
* @param paint The paint used to draw the line
|
* @param paint The paint used to draw the line
|
||||||
*/
|
*/
|
||||||
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
|
||||||
native_drawLine(cairo_context, widget, startX, startY, stopX, stopY, paint.getColor());
|
native_drawLine(skia_canvas, widget, startX, startY, stopX, stopY, paint.skia_paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBitmap(Bitmap bitmap) {}
|
public void setBitmap(Bitmap bitmap) {}
|
||||||
|
|
||||||
private static native void native_drawLine(long cairo_context, long widget, float startX, float startY, float stopX, float stopY, int paint_color); // TODO: pass all the other relevant parameters extracted from paint
|
private static native void native_drawRect(long skia_canvas, float left, float top, float right, float bottom, long skia_paint);
|
||||||
private static native void native_drawBitmap(long cairo_context, long widget, long pixbuf, float src_x, float src_y, float dest_x, float dest_y, float dest_w, float dest_h, Paint paint); // TODO: make use of "paint"?
|
private static native void native_drawLine(long skia_canvas, long widget, float startX, float startY, float stopX, float stopY, long skia_paint);
|
||||||
private static native void native_rotate(long cairo_context, long widget, float angle);
|
private static native void native_drawBitmap(long skia_canvas, long widget, long pixbuf, float src_x, float src_y, float dest_x, float dest_y, float dest_w, float dest_h, long skia_paint);
|
||||||
private static native void native_rotate_and_translate(long cairo_context, long widget, float angle, float tx, float ty);
|
private static native void native_rotate(long skia_canvas, long widget, float angle);
|
||||||
|
private static native void native_rotate_and_translate(long skia_canvas, long widget, float angle, float tx, float ty);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
package android.graphics;
|
package android.graphics;
|
||||||
|
|
||||||
public class Paint {
|
public class Paint {
|
||||||
private int color = 0xFF000000;
|
public long skia_paint = 0; // should probably be private, but then we'd need to get it from C
|
||||||
|
|
||||||
|
private native long native_constructor();
|
||||||
|
private native void native_set_color(long skia_paint, int color);
|
||||||
|
private native int native_get_color(long skia_paint);
|
||||||
|
|
||||||
public Paint() {
|
public Paint() {
|
||||||
|
skia_paint = native_constructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Paint (int flags) {
|
public Paint (int flags) {
|
||||||
@@ -12,15 +17,17 @@ public class Paint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Paint(Paint paint) {
|
public Paint(Paint paint) {
|
||||||
|
/* TODO: use sk_paint_clone */
|
||||||
|
this();
|
||||||
setColor(paint.getColor());
|
setColor(paint.getColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(int color) {
|
public void setColor(int color) {
|
||||||
this.color = color;
|
native_set_color(skia_paint, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
return color;
|
return native_get_color(skia_paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAntiAlias(boolean aa) {}
|
public void setAntiAlias(boolean aa) {}
|
||||||
|
|||||||
107
src/sk_area/include/c/gr_context.h
Normal file
107
src/sk_area/include/c/gr_context.h
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef gr_context_DEFINED
|
||||||
|
#define gr_context_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
// GrRecordingContext
|
||||||
|
|
||||||
|
SK_C_API void gr_recording_context_unref(gr_recording_context_t* context);
|
||||||
|
SK_C_API int gr_recording_context_get_max_surface_sample_count_for_color_type(gr_recording_context_t* context, sk_colortype_t colorType);
|
||||||
|
SK_C_API gr_backend_t gr_recording_context_get_backend(gr_recording_context_t* context);
|
||||||
|
SK_C_API bool gr_recording_context_is_abandoned(gr_recording_context_t* context);
|
||||||
|
SK_C_API int gr_recording_context_max_texture_size(gr_recording_context_t* context);
|
||||||
|
SK_C_API int gr_recording_context_max_render_target_size(gr_recording_context_t* context);
|
||||||
|
|
||||||
|
// GrDirectContext
|
||||||
|
|
||||||
|
SK_C_API gr_direct_context_t* gr_direct_context_make_gl(const gr_glinterface_t* glInterface);
|
||||||
|
SK_C_API gr_direct_context_t* gr_direct_context_make_gl_with_options(const gr_glinterface_t* glInterface, const gr_context_options_t* options);
|
||||||
|
SK_C_API gr_direct_context_t* gr_direct_context_make_vulkan(const gr_vk_backendcontext_t vkBackendContext);
|
||||||
|
SK_C_API gr_direct_context_t* gr_direct_context_make_vulkan_with_options(const gr_vk_backendcontext_t vkBackendContext, const gr_context_options_t* options);
|
||||||
|
SK_C_API gr_direct_context_t* gr_direct_context_make_metal(void* device, void* queue);
|
||||||
|
SK_C_API gr_direct_context_t* gr_direct_context_make_metal_with_options(void* device, void* queue, const gr_context_options_t* options);
|
||||||
|
|
||||||
|
// TODO: the overloads with GrContextOptions
|
||||||
|
|
||||||
|
SK_C_API bool gr_direct_context_is_abandoned(gr_direct_context_t* context);
|
||||||
|
SK_C_API void gr_direct_context_abandon_context(gr_direct_context_t* context);
|
||||||
|
SK_C_API void gr_direct_context_release_resources_and_abandon_context(gr_direct_context_t* context);
|
||||||
|
SK_C_API size_t gr_direct_context_get_resource_cache_limit(gr_direct_context_t* context);
|
||||||
|
SK_C_API void gr_direct_context_set_resource_cache_limit(gr_direct_context_t* context, size_t maxResourceBytes);
|
||||||
|
SK_C_API void gr_direct_context_get_resource_cache_usage(gr_direct_context_t* context, int* maxResources, size_t* maxResourceBytes);
|
||||||
|
SK_C_API void gr_direct_context_flush(gr_direct_context_t* context);
|
||||||
|
SK_C_API bool gr_direct_context_submit(gr_direct_context_t* context, bool syncCpu);
|
||||||
|
SK_C_API void gr_direct_context_flush_and_submit(gr_direct_context_t* context, bool syncCpu);
|
||||||
|
SK_C_API void gr_direct_context_reset_context(gr_direct_context_t* context, uint32_t state);
|
||||||
|
SK_C_API void gr_direct_context_dump_memory_statistics(const gr_direct_context_t* context, sk_tracememorydump_t* dump);
|
||||||
|
SK_C_API void gr_direct_context_free_gpu_resources(gr_direct_context_t* context);
|
||||||
|
SK_C_API void gr_direct_context_perform_deferred_cleanup(gr_direct_context_t* context, long long ms);
|
||||||
|
SK_C_API void gr_direct_context_purge_unlocked_resources_bytes(gr_direct_context_t* context, size_t bytesToPurge, bool preferScratchResources);
|
||||||
|
SK_C_API void gr_direct_context_purge_unlocked_resources(gr_direct_context_t* context, bool scratchResourcesOnly);
|
||||||
|
|
||||||
|
|
||||||
|
// GrGLInterface
|
||||||
|
|
||||||
|
SK_C_API const gr_glinterface_t* gr_glinterface_create_native_interface(void);
|
||||||
|
SK_C_API const gr_glinterface_t* gr_glinterface_assemble_interface(void* ctx, gr_gl_get_proc get);
|
||||||
|
SK_C_API const gr_glinterface_t* gr_glinterface_assemble_gl_interface(void* ctx, gr_gl_get_proc get);
|
||||||
|
SK_C_API const gr_glinterface_t* gr_glinterface_assemble_gles_interface(void* ctx, gr_gl_get_proc get);
|
||||||
|
SK_C_API const gr_glinterface_t* gr_glinterface_assemble_webgl_interface(void* ctx, gr_gl_get_proc get);
|
||||||
|
|
||||||
|
SK_C_API void gr_glinterface_unref(const gr_glinterface_t* glInterface);
|
||||||
|
SK_C_API bool gr_glinterface_validate(const gr_glinterface_t* glInterface);
|
||||||
|
SK_C_API bool gr_glinterface_has_extension(const gr_glinterface_t* glInterface, const char* extension);
|
||||||
|
|
||||||
|
// GrVkExtensions
|
||||||
|
|
||||||
|
SK_C_API gr_vk_extensions_t* gr_vk_extensions_new(void);
|
||||||
|
SK_C_API void gr_vk_extensions_delete(gr_vk_extensions_t* extensions);
|
||||||
|
SK_C_API void gr_vk_extensions_init(gr_vk_extensions_t* extensions, gr_vk_get_proc getProc, void* userData, vk_instance_t* instance, vk_physical_device_t* physDev, uint32_t instanceExtensionCount, const char** instanceExtensions, uint32_t deviceExtensionCount, const char** deviceExtensions);
|
||||||
|
SK_C_API bool gr_vk_extensions_has_extension(gr_vk_extensions_t* extensions, const char* ext, uint32_t minVersion);
|
||||||
|
|
||||||
|
// GrBackendTexture
|
||||||
|
|
||||||
|
SK_C_API gr_backendtexture_t* gr_backendtexture_new_gl(int width, int height, bool mipmapped, const gr_gl_textureinfo_t* glInfo);
|
||||||
|
SK_C_API gr_backendtexture_t* gr_backendtexture_new_vulkan(int width, int height, const gr_vk_imageinfo_t* vkInfo);
|
||||||
|
SK_C_API gr_backendtexture_t* gr_backendtexture_new_metal(int width, int height, bool mipmapped, const gr_mtl_textureinfo_t* mtlInfo);
|
||||||
|
SK_C_API void gr_backendtexture_delete(gr_backendtexture_t* texture);
|
||||||
|
|
||||||
|
SK_C_API bool gr_backendtexture_is_valid(const gr_backendtexture_t* texture);
|
||||||
|
SK_C_API int gr_backendtexture_get_width(const gr_backendtexture_t* texture);
|
||||||
|
SK_C_API int gr_backendtexture_get_height(const gr_backendtexture_t* texture);
|
||||||
|
SK_C_API bool gr_backendtexture_has_mipmaps(const gr_backendtexture_t* texture);
|
||||||
|
SK_C_API gr_backend_t gr_backendtexture_get_backend(const gr_backendtexture_t* texture);
|
||||||
|
SK_C_API bool gr_backendtexture_get_gl_textureinfo(const gr_backendtexture_t* texture, gr_gl_textureinfo_t* glInfo);
|
||||||
|
|
||||||
|
|
||||||
|
// GrBackendRenderTarget
|
||||||
|
|
||||||
|
SK_C_API gr_backendrendertarget_t* gr_backendrendertarget_new_gl(int width, int height, int samples, int stencils, const gr_gl_framebufferinfo_t* glInfo);
|
||||||
|
SK_C_API gr_backendrendertarget_t* gr_backendrendertarget_new_vulkan(int width, int height, int samples, const gr_vk_imageinfo_t* vkImageInfo);
|
||||||
|
SK_C_API gr_backendrendertarget_t* gr_backendrendertarget_new_metal(int width, int height, int samples, const gr_mtl_textureinfo_t* mtlInfo);
|
||||||
|
|
||||||
|
SK_C_API void gr_backendrendertarget_delete(gr_backendrendertarget_t* rendertarget);
|
||||||
|
|
||||||
|
SK_C_API bool gr_backendrendertarget_is_valid(const gr_backendrendertarget_t* rendertarget);
|
||||||
|
SK_C_API int gr_backendrendertarget_get_width(const gr_backendrendertarget_t* rendertarget);
|
||||||
|
SK_C_API int gr_backendrendertarget_get_height(const gr_backendrendertarget_t* rendertarget);
|
||||||
|
SK_C_API int gr_backendrendertarget_get_samples(const gr_backendrendertarget_t* rendertarget);
|
||||||
|
SK_C_API int gr_backendrendertarget_get_stencils(const gr_backendrendertarget_t* rendertarget);
|
||||||
|
SK_C_API gr_backend_t gr_backendrendertarget_get_backend(const gr_backendrendertarget_t* rendertarget);
|
||||||
|
SK_C_API bool gr_backendrendertarget_get_gl_framebufferinfo(const gr_backendrendertarget_t* rendertarget, gr_gl_framebufferinfo_t* glInfo);
|
||||||
|
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
51
src/sk_area/include/c/sk_bitmap.h
Normal file
51
src/sk_area/include/c/sk_bitmap.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_bitmap_DEFINED
|
||||||
|
#define sk_bitmap_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
SK_C_API void sk_bitmap_destructor(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API sk_bitmap_t* sk_bitmap_new(void);
|
||||||
|
SK_C_API void sk_bitmap_get_info(sk_bitmap_t* cbitmap, sk_imageinfo_t* info);
|
||||||
|
SK_C_API void* sk_bitmap_get_pixels(sk_bitmap_t* cbitmap, size_t* length);
|
||||||
|
SK_C_API size_t sk_bitmap_get_row_bytes(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API size_t sk_bitmap_get_byte_count(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API void sk_bitmap_reset(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API bool sk_bitmap_is_null(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API bool sk_bitmap_is_immutable(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API void sk_bitmap_set_immutable(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API void sk_bitmap_erase(sk_bitmap_t* cbitmap, sk_color_t color);
|
||||||
|
SK_C_API void sk_bitmap_erase_rect(sk_bitmap_t* cbitmap, sk_color_t color, sk_irect_t* rect);
|
||||||
|
SK_C_API uint8_t* sk_bitmap_get_addr_8(sk_bitmap_t* cbitmap, int x, int y);
|
||||||
|
SK_C_API uint16_t* sk_bitmap_get_addr_16(sk_bitmap_t* cbitmap, int x, int y);
|
||||||
|
SK_C_API uint32_t* sk_bitmap_get_addr_32(sk_bitmap_t* cbitmap, int x, int y);
|
||||||
|
SK_C_API void* sk_bitmap_get_addr(sk_bitmap_t* cbitmap, int x, int y);
|
||||||
|
SK_C_API sk_color_t sk_bitmap_get_pixel_color(sk_bitmap_t* cbitmap, int x, int y);
|
||||||
|
SK_C_API bool sk_bitmap_ready_to_draw(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API void sk_bitmap_get_pixel_colors(sk_bitmap_t* cbitmap, sk_color_t* colors);
|
||||||
|
SK_C_API bool sk_bitmap_install_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes, const sk_bitmap_release_proc releaseProc, void* context);
|
||||||
|
SK_C_API bool sk_bitmap_install_pixels_with_pixmap(sk_bitmap_t* cbitmap, const sk_pixmap_t* cpixmap);
|
||||||
|
SK_C_API bool sk_bitmap_try_alloc_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, size_t rowBytes);
|
||||||
|
SK_C_API bool sk_bitmap_try_alloc_pixels_with_flags(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, uint32_t flags);
|
||||||
|
SK_C_API void sk_bitmap_set_pixels(sk_bitmap_t* cbitmap, void* pixels);
|
||||||
|
SK_C_API bool sk_bitmap_peek_pixels(sk_bitmap_t* cbitmap, sk_pixmap_t* cpixmap);
|
||||||
|
SK_C_API bool sk_bitmap_extract_subset(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, sk_irect_t* subset);
|
||||||
|
SK_C_API bool sk_bitmap_extract_alpha(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, const sk_paint_t* paint, sk_ipoint_t* offset);
|
||||||
|
SK_C_API void sk_bitmap_notify_pixels_changed(sk_bitmap_t* cbitmap);
|
||||||
|
SK_C_API void sk_bitmap_swap(sk_bitmap_t* cbitmap, sk_bitmap_t* cother);
|
||||||
|
SK_C_API sk_shader_t* sk_bitmap_make_shader(sk_bitmap_t* cbitmap, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* cmatrix);
|
||||||
|
SK_C_API sk_shader_t* sk_bitmap_make_shader_v2(sk_bitmap_t* cbitmap, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, sk_sampling_options_t* sampling, const sk_matrix_t* cmatrix);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
92
src/sk_area/include/c/sk_canvas.h
Normal file
92
src/sk_area/include/c/sk_canvas.h
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_canvas_DEFINED
|
||||||
|
#define sk_canvas_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
SK_C_API void sk_canvas_destroy(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API void sk_canvas_clear(sk_canvas_t* ccanvas, sk_color_t color);
|
||||||
|
SK_C_API void sk_canvas_clear_color4f(sk_canvas_t* ccanvas, sk_color4f_t color);
|
||||||
|
SK_C_API void sk_canvas_discard(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API int sk_canvas_get_save_count(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API void sk_canvas_restore_to_count(sk_canvas_t* ccanvas, int saveCount);
|
||||||
|
SK_C_API void sk_canvas_draw_color(sk_canvas_t* ccanvas, sk_color_t color, sk_blendmode_t cmode);
|
||||||
|
SK_C_API void sk_canvas_draw_color4f(sk_canvas_t* ccanvas, sk_color4f_t color, sk_blendmode_t cmode);
|
||||||
|
SK_C_API void sk_canvas_draw_points(sk_canvas_t* ccanvas, sk_point_mode_t pointMode, size_t count, const sk_point_t points [], const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_point(sk_canvas_t* ccanvas, float x, float y, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_line(sk_canvas_t* ccanvas, float x0, float y0, float x1, float y1, sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_simple_text(sk_canvas_t* ccanvas, const void* text, size_t byte_length, sk_text_encoding_t encoding, float x, float y, const sk_font_t* cfont, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_text_blob (sk_canvas_t* ccanvas, sk_textblob_t* text, float x, float y, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_reset_matrix(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API void sk_canvas_set_matrix(sk_canvas_t* ccanvas, const sk_matrix44_t* cmatrix);
|
||||||
|
SK_C_API void sk_canvas_get_matrix(sk_canvas_t* ccanvas, sk_matrix44_t* cmatrix);
|
||||||
|
SK_C_API void sk_canvas_draw_round_rect(sk_canvas_t* ccanvas, const sk_rect_t* crect, float rx, float ry, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_clip_rect_with_operation(sk_canvas_t* ccanvas, const sk_rect_t* crect, sk_clipop_t op, bool doAA);
|
||||||
|
SK_C_API void sk_canvas_clip_path_with_operation(sk_canvas_t* ccanvas, const sk_path_t* cpath, sk_clipop_t op, bool doAA);
|
||||||
|
SK_C_API void sk_canvas_clip_rrect_with_operation(sk_canvas_t* ccanvas, const sk_rrect_t* crect, sk_clipop_t op, bool doAA);
|
||||||
|
SK_C_API bool sk_canvas_get_local_clip_bounds(sk_canvas_t* ccanvas, sk_rect_t* cbounds);
|
||||||
|
SK_C_API bool sk_canvas_get_device_clip_bounds(sk_canvas_t* ccanvas, sk_irect_t* cbounds);
|
||||||
|
SK_C_API int sk_canvas_save(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API int sk_canvas_save_layer(sk_canvas_t* ccanvas, const sk_rect_t* crect, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_restore(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API void sk_canvas_translate(sk_canvas_t* ccanvas, float dx, float dy);
|
||||||
|
SK_C_API void sk_canvas_scale(sk_canvas_t* ccanvas, float sx, float sy);
|
||||||
|
SK_C_API void sk_canvas_rotate_degrees(sk_canvas_t* ccanvas, float degrees);
|
||||||
|
SK_C_API void sk_canvas_rotate_radians(sk_canvas_t* ccanvas, float radians);
|
||||||
|
SK_C_API void sk_canvas_skew(sk_canvas_t* ccanvas, float sx, float sy);
|
||||||
|
SK_C_API void sk_canvas_concat(sk_canvas_t* ccanvas, const sk_matrix44_t* cmatrix);
|
||||||
|
SK_C_API bool sk_canvas_quick_reject(sk_canvas_t* ccanvas, const sk_rect_t* crect);
|
||||||
|
SK_C_API void sk_canvas_clip_region(sk_canvas_t* ccanvas, const sk_region_t* region, sk_clipop_t op);
|
||||||
|
SK_C_API void sk_canvas_draw_paint(sk_canvas_t* ccanvas, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_region(sk_canvas_t* ccanvas, const sk_region_t* cregion, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_rect(sk_canvas_t* ccanvas, const sk_rect_t* crect, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_rrect(sk_canvas_t* ccanvas, const sk_rrect_t* crect, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_circle(sk_canvas_t* ccanvas, float cx, float cy, float rad, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_oval(sk_canvas_t* ccanvas, const sk_rect_t* crect, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_path(sk_canvas_t* ccanvas, const sk_path_t* cpath, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_image(sk_canvas_t* ccanvas, const sk_image_t* cimage, float x, float y, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_image_v2(sk_canvas_t* ccanvas, const sk_image_t* cimage, float x, float y, const sk_sampling_options_t* sampling, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_image_rect(sk_canvas_t* ccanvas, const sk_image_t* cimage, const sk_rect_t* csrcR, const sk_rect_t* cdstR, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_image_rect_v2(sk_canvas_t* ccanvas, const sk_image_t* cimage, const sk_rect_t* csrcR, const sk_rect_t* cdstR, const sk_sampling_options_t* sampling, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_picture(sk_canvas_t* ccanvas, const sk_picture_t* cpicture, const sk_matrix_t* cmatrix, const sk_paint_t* cpaint);
|
||||||
|
SK_C_API void sk_canvas_draw_drawable(sk_canvas_t* ccanvas, sk_drawable_t* cdrawable, const sk_matrix_t* cmatrix);
|
||||||
|
SK_C_API void sk_canvas_flush(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API sk_canvas_t* sk_canvas_new_from_bitmap(const sk_bitmap_t* bitmap);
|
||||||
|
SK_C_API sk_canvas_t* sk_canvas_new_from_raster(const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes, const sk_surfaceprops_t* props);
|
||||||
|
SK_C_API void sk_canvas_draw_annotation(sk_canvas_t* t, const sk_rect_t* rect, const char* key, sk_data_t* value);
|
||||||
|
SK_C_API void sk_canvas_draw_url_annotation(sk_canvas_t* t, const sk_rect_t* rect, sk_data_t* value);
|
||||||
|
SK_C_API void sk_canvas_draw_named_destination_annotation(sk_canvas_t* t, const sk_point_t* point, sk_data_t* value);
|
||||||
|
SK_C_API void sk_canvas_draw_link_destination_annotation(sk_canvas_t* t, const sk_rect_t* rect, sk_data_t* value);
|
||||||
|
SK_C_API void sk_canvas_draw_image_lattice(sk_canvas_t* ccanvas, const sk_image_t* image, const sk_lattice_t* lattice, const sk_rect_t* dst, sk_filter_mode_t mode, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_image_nine(sk_canvas_t* ccanvas, const sk_image_t* image, const sk_irect_t* center, const sk_rect_t* dst, sk_filter_mode_t mode, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_vertices(sk_canvas_t* ccanvas, const sk_vertices_t* vertices, sk_blendmode_t mode, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_arc(sk_canvas_t* ccanvas, const sk_rect_t* oval, float startAngle, float sweepAngle, bool useCenter, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_drrect(sk_canvas_t* ccanvas, const sk_rrect_t* outer, const sk_rrect_t* inner, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_atlas(sk_canvas_t* ccanvas, const sk_image_t* atlas, const sk_rsxform_t* xform, const sk_rect_t* tex, const sk_color_t* colors, int count, sk_blendmode_t mode, const sk_rect_t* cullRect, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_atlas_v2(sk_canvas_t* ccanvas, const sk_image_t* atlas, const sk_rsxform_t* xform, const sk_rect_t* tex, const sk_color_t* colors, int count, sk_blendmode_t mode, const sk_sampling_options_t* sampling, const sk_rect_t* cullRect, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_canvas_draw_patch(sk_canvas_t* ccanvas, const sk_point_t* cubics, const sk_color_t* colors, const sk_point_t* texCoords, sk_blendmode_t mode, const sk_paint_t* paint);
|
||||||
|
SK_C_API bool sk_canvas_is_clip_empty(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API bool sk_canvas_is_clip_rect(sk_canvas_t* ccanvas);
|
||||||
|
SK_C_API sk_nodraw_canvas_t* sk_nodraw_canvas_new(int width, int height);
|
||||||
|
SK_C_API void sk_nodraw_canvas_destroy(sk_nodraw_canvas_t* t);
|
||||||
|
SK_C_API sk_nway_canvas_t* sk_nway_canvas_new(int width, int height);
|
||||||
|
SK_C_API void sk_nway_canvas_destroy(sk_nway_canvas_t* t);
|
||||||
|
SK_C_API void sk_nway_canvas_add_canvas(sk_nway_canvas_t* t, sk_canvas_t* canvas);
|
||||||
|
SK_C_API void sk_nway_canvas_remove_canvas(sk_nway_canvas_t* t, sk_canvas_t* canvas);
|
||||||
|
SK_C_API void sk_nway_canvas_remove_all(sk_nway_canvas_t* t);
|
||||||
|
SK_C_API sk_overdraw_canvas_t* sk_overdraw_canvas_new(sk_canvas_t* canvas);
|
||||||
|
SK_C_API void sk_overdraw_canvas_destroy(sk_overdraw_canvas_t* canvas);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
43
src/sk_area/include/c/sk_codec.h
Normal file
43
src/sk_area/include/c/sk_codec.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_codec_DEFINED
|
||||||
|
#define sk_codec_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
SK_C_API size_t sk_codec_min_buffered_bytes_needed(void);
|
||||||
|
|
||||||
|
SK_C_API sk_codec_t* sk_codec_new_from_stream(sk_stream_t* stream, sk_codec_result_t* result);
|
||||||
|
SK_C_API sk_codec_t* sk_codec_new_from_data(sk_data_t* data);
|
||||||
|
SK_C_API void sk_codec_destroy(sk_codec_t* codec);
|
||||||
|
SK_C_API void sk_codec_get_info(sk_codec_t* codec, sk_imageinfo_t* info);
|
||||||
|
SK_C_API sk_encodedorigin_t sk_codec_get_origin(sk_codec_t* codec);
|
||||||
|
SK_C_API void sk_codec_get_scaled_dimensions(sk_codec_t* codec, float desiredScale, sk_isize_t* dimensions);
|
||||||
|
SK_C_API bool sk_codec_get_valid_subset(sk_codec_t* codec, sk_irect_t* desiredSubset);
|
||||||
|
SK_C_API sk_encoded_image_format_t sk_codec_get_encoded_format(sk_codec_t* codec);
|
||||||
|
SK_C_API sk_codec_result_t sk_codec_get_pixels(sk_codec_t* codec, const sk_imageinfo_t* info, void* pixels, size_t rowBytes, const sk_codec_options_t* options);
|
||||||
|
SK_C_API sk_codec_result_t sk_codec_start_incremental_decode(sk_codec_t* codec, const sk_imageinfo_t* info, void* pixels, size_t rowBytes, const sk_codec_options_t* options);
|
||||||
|
SK_C_API sk_codec_result_t sk_codec_incremental_decode(sk_codec_t* codec, int* rowsDecoded);
|
||||||
|
SK_C_API sk_codec_result_t sk_codec_start_scanline_decode(sk_codec_t* codec, const sk_imageinfo_t* info, const sk_codec_options_t* options);
|
||||||
|
SK_C_API int sk_codec_get_scanlines(sk_codec_t* codec, void* dst, int countLines, size_t rowBytes);
|
||||||
|
SK_C_API bool sk_codec_skip_scanlines(sk_codec_t* codec, int countLines);
|
||||||
|
SK_C_API sk_codec_scanline_order_t sk_codec_get_scanline_order(sk_codec_t* codec);
|
||||||
|
SK_C_API int sk_codec_next_scanline(sk_codec_t* codec);
|
||||||
|
SK_C_API int sk_codec_output_scanline(sk_codec_t* codec, int inputScanline);
|
||||||
|
SK_C_API int sk_codec_get_frame_count(sk_codec_t* codec);
|
||||||
|
SK_C_API void sk_codec_get_frame_info(sk_codec_t* codec, sk_codec_frameinfo_t* frameInfo);
|
||||||
|
SK_C_API bool sk_codec_get_frame_info_for_index(sk_codec_t* codec, int index, sk_codec_frameinfo_t* frameInfo);
|
||||||
|
SK_C_API int sk_codec_get_repetition_count(sk_codec_t* codec);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
29
src/sk_area/include/c/sk_colorfilter.h
Normal file
29
src/sk_area/include/c/sk_colorfilter.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_colorfilter_DEFINED
|
||||||
|
#define sk_colorfilter_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
SK_C_API void sk_colorfilter_unref(sk_colorfilter_t* filter);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_mode(sk_color_t c, sk_blendmode_t mode);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_lighting(sk_color_t mul, sk_color_t add);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_compose(sk_colorfilter_t* outer, sk_colorfilter_t* inner);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_color_matrix(const float array[20]);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_luma_color(void);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_high_contrast(const sk_highcontrastconfig_t* config);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_table(const uint8_t table[256]);
|
||||||
|
SK_C_API sk_colorfilter_t* sk_colorfilter_new_table_argb(const uint8_t tableA[256], const uint8_t tableR[256], const uint8_t tableG[256], const uint8_t tableB[256]);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
77
src/sk_area/include/c/sk_colorspace.h
Normal file
77
src/sk_area/include/c/sk_colorspace.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_colorspace_DEFINED
|
||||||
|
#define sk_colorspace_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
// TODO: skcms.h has things that may be useful
|
||||||
|
|
||||||
|
// sk_colorspace_t
|
||||||
|
|
||||||
|
SK_C_API void sk_colorspace_ref(sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API void sk_colorspace_unref(sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API sk_colorspace_t* sk_colorspace_new_srgb(void);
|
||||||
|
SK_C_API sk_colorspace_t* sk_colorspace_new_srgb_linear(void);
|
||||||
|
SK_C_API sk_colorspace_t* sk_colorspace_new_rgb(const sk_colorspace_transfer_fn_t* transferFn, const sk_colorspace_xyz_t* toXYZD50);
|
||||||
|
SK_C_API sk_colorspace_t* sk_colorspace_new_icc(const sk_colorspace_icc_profile_t* profile);
|
||||||
|
SK_C_API void sk_colorspace_to_profile(const sk_colorspace_t* colorspace, sk_colorspace_icc_profile_t* profile);
|
||||||
|
SK_C_API bool sk_colorspace_gamma_close_to_srgb(const sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API bool sk_colorspace_gamma_is_linear(const sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API bool sk_colorspace_is_numerical_transfer_fn(const sk_colorspace_t* colorspace, sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API bool sk_colorspace_to_xyzd50(const sk_colorspace_t* colorspace, sk_colorspace_xyz_t* toXYZD50);
|
||||||
|
SK_C_API sk_colorspace_t* sk_colorspace_make_linear_gamma(const sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API sk_colorspace_t* sk_colorspace_make_srgb_gamma(const sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API bool sk_colorspace_is_srgb(const sk_colorspace_t* colorspace);
|
||||||
|
SK_C_API bool sk_colorspace_equals(const sk_colorspace_t* src, const sk_colorspace_t* dst);
|
||||||
|
|
||||||
|
// sk_colorspace_transfer_fn_t
|
||||||
|
|
||||||
|
SK_C_API void sk_colorspace_transfer_fn_named_srgb(sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API void sk_colorspace_transfer_fn_named_2dot2(sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API void sk_colorspace_transfer_fn_named_linear(sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API void sk_colorspace_transfer_fn_named_rec2020(sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API void sk_colorspace_transfer_fn_named_pq(sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API void sk_colorspace_transfer_fn_named_hlg(sk_colorspace_transfer_fn_t* transferFn);
|
||||||
|
SK_C_API float sk_colorspace_transfer_fn_eval(const sk_colorspace_transfer_fn_t* transferFn, float x);
|
||||||
|
SK_C_API bool sk_colorspace_transfer_fn_invert(const sk_colorspace_transfer_fn_t* src, sk_colorspace_transfer_fn_t* dst);
|
||||||
|
|
||||||
|
// sk_colorspace_primaries_t
|
||||||
|
|
||||||
|
SK_C_API bool sk_colorspace_primaries_to_xyzd50(const sk_colorspace_primaries_t* primaries, sk_colorspace_xyz_t* toXYZD50);
|
||||||
|
|
||||||
|
// sk_colorspace_xyz_t
|
||||||
|
|
||||||
|
SK_C_API void sk_colorspace_xyz_named_srgb(sk_colorspace_xyz_t* xyz);
|
||||||
|
SK_C_API void sk_colorspace_xyz_named_adobe_rgb(sk_colorspace_xyz_t* xyz);
|
||||||
|
SK_C_API void sk_colorspace_xyz_named_display_p3(sk_colorspace_xyz_t* xyz);
|
||||||
|
SK_C_API void sk_colorspace_xyz_named_rec2020(sk_colorspace_xyz_t* xyz);
|
||||||
|
SK_C_API void sk_colorspace_xyz_named_xyz(sk_colorspace_xyz_t* xyz);
|
||||||
|
SK_C_API bool sk_colorspace_xyz_invert(const sk_colorspace_xyz_t* src, sk_colorspace_xyz_t* dst);
|
||||||
|
SK_C_API void sk_colorspace_xyz_concat(const sk_colorspace_xyz_t* a, const sk_colorspace_xyz_t* b, sk_colorspace_xyz_t* result);
|
||||||
|
|
||||||
|
// sk_colorspace_icc_profile_t
|
||||||
|
|
||||||
|
SK_C_API void sk_colorspace_icc_profile_delete(sk_colorspace_icc_profile_t* profile);
|
||||||
|
SK_C_API sk_colorspace_icc_profile_t* sk_colorspace_icc_profile_new(void);
|
||||||
|
SK_C_API bool sk_colorspace_icc_profile_parse(const void* buffer, size_t length, sk_colorspace_icc_profile_t* profile);
|
||||||
|
SK_C_API const uint8_t* sk_colorspace_icc_profile_get_buffer(const sk_colorspace_icc_profile_t* profile, uint32_t* size);
|
||||||
|
SK_C_API bool sk_colorspace_icc_profile_get_to_xyzd50(const sk_colorspace_icc_profile_t* profile, sk_colorspace_xyz_t* toXYZD50);
|
||||||
|
|
||||||
|
// sk_color4f_t
|
||||||
|
|
||||||
|
SK_C_API sk_color_t sk_color4f_to_color(const sk_color4f_t* color4f);
|
||||||
|
SK_C_API void sk_color4f_from_color(sk_color_t color, sk_color4f_t* color4f);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
32
src/sk_area/include/c/sk_data.h
Normal file
32
src/sk_area/include/c/sk_data.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_data_DEFINED
|
||||||
|
#define sk_data_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
SK_C_API sk_data_t* sk_data_new_empty(void);
|
||||||
|
SK_C_API sk_data_t* sk_data_new_with_copy(const void* src, size_t length);
|
||||||
|
SK_C_API sk_data_t* sk_data_new_subset(const sk_data_t* src, size_t offset, size_t length);
|
||||||
|
SK_C_API void sk_data_ref(const sk_data_t*);
|
||||||
|
SK_C_API void sk_data_unref(const sk_data_t*);
|
||||||
|
SK_C_API size_t sk_data_get_size(const sk_data_t*);
|
||||||
|
SK_C_API const void* sk_data_get_data(const sk_data_t*);
|
||||||
|
SK_C_API sk_data_t* sk_data_new_from_file(const char* path);
|
||||||
|
SK_C_API sk_data_t* sk_data_new_from_stream(sk_stream_t* stream, size_t length);
|
||||||
|
SK_C_API const uint8_t* sk_data_get_bytes(const sk_data_t*);
|
||||||
|
SK_C_API sk_data_t* sk_data_new_with_proc(const void* ptr, size_t length, sk_data_release_proc proc, void* ctx);
|
||||||
|
SK_C_API sk_data_t* sk_data_new_uninitialized(size_t size);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
31
src/sk_area/include/c/sk_document.h
Normal file
31
src/sk_area/include/c/sk_document.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_document_DEFINED
|
||||||
|
#define sk_document_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
SK_C_API void sk_document_unref(sk_document_t* document);
|
||||||
|
|
||||||
|
SK_C_API sk_document_t* sk_document_create_pdf_from_stream(sk_wstream_t* stream);
|
||||||
|
SK_C_API sk_document_t* sk_document_create_pdf_from_stream_with_metadata(sk_wstream_t* stream, const sk_document_pdf_metadata_t* metadata);
|
||||||
|
|
||||||
|
SK_C_API sk_document_t* sk_document_create_xps_from_stream(sk_wstream_t* stream, float dpi);
|
||||||
|
|
||||||
|
SK_C_API sk_canvas_t* sk_document_begin_page(sk_document_t* document, float width, float height, const sk_rect_t* content);
|
||||||
|
SK_C_API void sk_document_end_page(sk_document_t* document);
|
||||||
|
SK_C_API void sk_document_close(sk_document_t* document);
|
||||||
|
SK_C_API void sk_document_abort(sk_document_t* document);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
27
src/sk_area/include/c/sk_drawable.h
Normal file
27
src/sk_area/include/c/sk_drawable.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_drawable_DEFINED
|
||||||
|
#define sk_drawable_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
typedef struct sk_drawable_t sk_drawable_t;
|
||||||
|
|
||||||
|
SK_C_API void sk_drawable_unref (sk_drawable_t*);
|
||||||
|
SK_C_API uint32_t sk_drawable_get_generation_id (sk_drawable_t*);
|
||||||
|
SK_C_API void sk_drawable_get_bounds (sk_drawable_t*, sk_rect_t*);
|
||||||
|
SK_C_API void sk_drawable_draw (sk_drawable_t*, sk_canvas_t*, const sk_matrix_t*);
|
||||||
|
SK_C_API sk_picture_t* sk_drawable_new_picture_snapshot(sk_drawable_t*);
|
||||||
|
SK_C_API void sk_drawable_notify_drawing_changed (sk_drawable_t*);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
68
src/sk_area/include/c/sk_font.h
Normal file
68
src/sk_area/include/c/sk_font.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
* Copyright 2015 Xamarin Inc.
|
||||||
|
* Copyright 2017 Microsoft Corporation. All rights reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license that can be
|
||||||
|
* found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef sk_font_DEFINED
|
||||||
|
#define sk_font_DEFINED
|
||||||
|
|
||||||
|
#include "include/c/sk_types.h"
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_BEGIN_GUARD
|
||||||
|
|
||||||
|
// sk_font_t
|
||||||
|
|
||||||
|
SK_C_API sk_font_t* sk_font_new(void);
|
||||||
|
SK_C_API sk_font_t* sk_font_new_with_values(sk_typeface_t* typeface, float size, float scaleX, float skewX);
|
||||||
|
SK_C_API void sk_font_delete(sk_font_t* font);
|
||||||
|
SK_C_API bool sk_font_is_force_auto_hinting(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_force_auto_hinting(sk_font_t* font, bool value);
|
||||||
|
SK_C_API bool sk_font_is_embedded_bitmaps(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_embedded_bitmaps(sk_font_t* font, bool value);
|
||||||
|
SK_C_API bool sk_font_is_subpixel(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_subpixel(sk_font_t* font, bool value);
|
||||||
|
SK_C_API bool sk_font_is_linear_metrics(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_linear_metrics(sk_font_t* font, bool value);
|
||||||
|
SK_C_API bool sk_font_is_embolden(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_embolden(sk_font_t* font, bool value);
|
||||||
|
SK_C_API bool sk_font_is_baseline_snap(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_baseline_snap(sk_font_t* font, bool value);
|
||||||
|
SK_C_API sk_font_edging_t sk_font_get_edging(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_edging(sk_font_t* font, sk_font_edging_t value);
|
||||||
|
SK_C_API sk_font_hinting_t sk_font_get_hinting(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_hinting(sk_font_t* font, sk_font_hinting_t value);
|
||||||
|
SK_C_API sk_typeface_t* sk_font_get_typeface(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_typeface(sk_font_t* font, sk_typeface_t* value);
|
||||||
|
SK_C_API float sk_font_get_size(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_size(sk_font_t* font, float value);
|
||||||
|
SK_C_API float sk_font_get_scale_x(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_scale_x(sk_font_t* font, float value);
|
||||||
|
SK_C_API float sk_font_get_skew_x(const sk_font_t* font);
|
||||||
|
SK_C_API void sk_font_set_skew_x(sk_font_t* font, float value);
|
||||||
|
SK_C_API int sk_font_text_to_glyphs(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, uint16_t glyphs[], int maxGlyphCount);
|
||||||
|
SK_C_API uint16_t sk_font_unichar_to_glyph(const sk_font_t* font, int32_t uni);
|
||||||
|
SK_C_API void sk_font_unichars_to_glyphs(const sk_font_t* font, const int32_t uni[], int count, uint16_t glyphs[]);
|
||||||
|
SK_C_API float sk_font_measure_text(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, sk_rect_t* bounds, const sk_paint_t* paint);
|
||||||
|
// NOTE: it appears that .NET Framework 4.7 has an issue with returning float?
|
||||||
|
// https://github.com/mono/SkiaSharp/issues/1409
|
||||||
|
SK_C_API void sk_font_measure_text_no_return(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, sk_rect_t* bounds, const sk_paint_t* paint, float* measuredWidth);
|
||||||
|
SK_C_API size_t sk_font_break_text(const sk_font_t* font, const void* text, size_t byteLength, sk_text_encoding_t encoding, float maxWidth, float* measuredWidth, const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_font_get_widths_bounds(const sk_font_t* font, const uint16_t glyphs[], int count, float widths[], sk_rect_t bounds[], const sk_paint_t* paint);
|
||||||
|
SK_C_API void sk_font_get_pos(const sk_font_t* font, const uint16_t glyphs[], int count, sk_point_t pos[], sk_point_t* origin);
|
||||||
|
SK_C_API void sk_font_get_xpos(const sk_font_t* font, const uint16_t glyphs[], int count, float xpos[], float origin);
|
||||||
|
SK_C_API bool sk_font_get_path(const sk_font_t* font, uint16_t glyph, sk_path_t* path);
|
||||||
|
SK_C_API void sk_font_get_paths(const sk_font_t* font, uint16_t glyphs[], int count, const sk_glyph_path_proc glyphPathProc, void* context);
|
||||||
|
SK_C_API float sk_font_get_metrics(const sk_font_t* font, sk_fontmetrics_t* metrics);
|
||||||
|
|
||||||
|
// sk_text_utils
|
||||||
|
|
||||||
|
SK_C_API void sk_text_utils_get_path(const void* text, size_t length, sk_text_encoding_t encoding, float x, float y, const sk_font_t* font, sk_path_t* path);
|
||||||
|
SK_C_API void sk_text_utils_get_pos_path(const void* text, size_t length, sk_text_encoding_t encoding, const sk_point_t pos[], const sk_font_t* font, sk_path_t* path);
|
||||||
|
|
||||||
|
SK_C_PLUS_PLUS_END_GUARD
|
||||||
|
|
||||||
|
#endif
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user