19jint Canvas_GetWidth(JNIEnv*
env, jobject, jlong native_instance) {
20 const auto* canvas =
reinterpret_cast<const SkCanvas*
>(native_instance);
24jint Canvas_GetHeight(JNIEnv*
env, jobject, jlong native_instance) {
25 const auto* canvas =
reinterpret_cast<const SkCanvas*
>(native_instance);
29jint Canvas_Save(JNIEnv*
env, jobject, jlong native_instance) {
30 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
31 return canvas->save();
36void Canvas_Restore(JNIEnv*
env, jobject, jlong native_instance) {
37 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
42void Canvas_RestoreToCount(JNIEnv*
env, jobject, jlong native_instance, jint
count) {
43 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
44 canvas->restoreToCount(
count);
48jint Canvas_SaveLayer(JNIEnv*
env, jobject, jlong native_instance, jlong native_paint) {
50 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
51 return canvas->saveLayer(
nullptr,
paint);
56jlong Canvas_LocalToDevice(JNIEnv*
env, jobject, jlong native_instance) {
57 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
59 return reinterpret_cast<jlong
>(
m);
64void Canvas_Concat(JNIEnv*
env, jobject, jlong native_instance, jlong native_matrix) {
65 auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance);
66 auto*
matrix =
reinterpret_cast<SkM44*
>(native_matrix);
73void Canvas_Concat16f(JNIEnv*
env, jobject, jlong native_instance, jfloatArray jmatrix) {
76 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
77 auto*
m =
env->GetFloatArrayElements(jmatrix,
nullptr);
79 env->ReleaseFloatArrayElements(jmatrix,
m, 0);
83void Canvas_Translate(JNIEnv*
env, jobject, jlong native_instance,
84 jfloat tx, jfloat ty, jfloat tz) {
85 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
90void Canvas_Scale(JNIEnv*
env, jobject, jlong native_instance, jfloat sx, jfloat sy, jfloat sz) {
91 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
96void Canvas_ClipPath(JNIEnv*
env, jobject, jlong native_instance, jlong native_path,
97 jint native_clipOp, jboolean doAA) {
98 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
99 if (
auto*
path =
reinterpret_cast<SkPath*
>(native_path)) {
100 canvas->clipPath(*
path,
static_cast<SkClipOp>(native_clipOp), doAA);
105void Canvas_ClipRect(JNIEnv*
env, jobject, jlong native_instance, jfloat l, jfloat t, jfloat r, jfloat
b,
106 jint native_clipOp, jboolean doAA) {
107 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
112void Canvas_ClipRRect(JNIEnv*
env, jobject, jlong native_instance, jfloat l, jfloat t, jfloat r, jfloat
b,
113 jfloat xRad, jfloat yRad,
114 jint native_clipOp, jboolean doAA) {
115 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
117 static_cast<SkClipOp>(native_clipOp), doAA);
121void Canvas_ClipShader(JNIEnv*
env, jobject, jlong native_instance, jlong native_shader, jint native_clipOp) {
122 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
123 if (
auto* shader =
reinterpret_cast<SkShader*
>(native_shader)) {
129void Canvas_DrawColor(JNIEnv*
env, jobject, jlong native_instance,
130 float r,
float g,
float b,
float a) {
131 if (
auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance)) {
136void Canvas_DrawRect(JNIEnv*
env, jobject, jlong native_instance,
137 jfloat
left, jfloat top, jfloat
right, jfloat bottom,
138 jlong native_paint) {
139 auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance);
140 auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint);
141 if (canvas &&
paint) {
146void Canvas_DrawImage(JNIEnv*
env, jobject, jlong native_instance, jlong native_image,
148 jint sampling_desc, jfloat sampling_b, jfloat sampling_c) {
149 auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance);
150 auto*
image =
reinterpret_cast<SkImage *
>(native_image);
152 if (canvas &&
image) {
158void Canvas_DrawPath(JNIEnv*
env, jobject, jlong native_instance, jlong native_path,
159 jlong native_paint) {
160 auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance);
161 auto*
path =
reinterpret_cast<SkPath*
>(native_path);
162 auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint);
170void Canvas_DrawGlyphs(JNIEnv*
env, jobject, jlong native_instance, jcharArray jglyphs,
171 jfloatArray jPos, jfloat xOrigin, jfloat yOrigin,
172 jlong native_font, jlong native_paint) {
173 auto* canvas =
reinterpret_cast<SkCanvas*
>(native_instance);
174 auto*
font =
reinterpret_cast<SkFont*
>(native_font);
175 auto*
paint =
reinterpret_cast<SkPaint*
>(native_paint);
177 int count =
env->GetArrayLength(jglyphs);
178 auto* compositePositions =
env->GetFloatArrayElements(jPos,
nullptr);
179 auto* positions =
reinterpret_cast<SkPoint*
>(compositePositions);
180 auto*
glyphs =
env->GetCharArrayElements(jglyphs,
nullptr);
183 env->ReleaseCharArrayElements(jglyphs,
glyphs, 0);
184 env->ReleaseFloatArrayElements(jPos, compositePositions, 0);
191 static const JNINativeMethod methods[] = {
192 {
"nGetWidth" ,
"(J)I" ,
reinterpret_cast<void*
>(Canvas_GetWidth) },
193 {
"nGetHeight" ,
"(J)I" ,
reinterpret_cast<void*
>(Canvas_GetHeight) },
194 {
"nSave" ,
"(J)I" ,
reinterpret_cast<void*
>(Canvas_Save) },
195 {
"nSaveLayer" ,
"(JJ)I" ,
reinterpret_cast<void*
>(Canvas_SaveLayer) },
196 {
"nRestore" ,
"(J)V" ,
reinterpret_cast<void*
>(Canvas_Restore) },
197 {
"nRestoreToCount" ,
"(JI)V" ,
reinterpret_cast<void*
>(Canvas_RestoreToCount)},
198 {
"nGetLocalToDevice",
"(J)J" ,
reinterpret_cast<void*
>(Canvas_LocalToDevice) },
199 {
"nConcat" ,
"(JJ)V" ,
reinterpret_cast<void*
>(Canvas_Concat) },
200 {
"nConcat16f" ,
"(J[F)V" ,
reinterpret_cast<void*
>(Canvas_Concat16f) },
201 {
"nTranslate" ,
"(JFFF)V" ,
reinterpret_cast<void*
>(Canvas_Translate) },
202 {
"nScale" ,
"(JFFF)V" ,
reinterpret_cast<void*
>(Canvas_Scale) },
203 {
"nClipPath" ,
"(JJIZ)V" ,
reinterpret_cast<void*
>(Canvas_ClipPath) },
204 {
"nClipRect" ,
"(JFFFFIZ)V" ,
reinterpret_cast<void*
>(Canvas_ClipRect) },
205 {
"nClipRRect" ,
"(JFFFFFFIZ)V" ,
reinterpret_cast<void*
>(Canvas_ClipRRect) },
206 {
"nClipShader" ,
"(JJI)V" ,
reinterpret_cast<void*
>(Canvas_ClipShader) },
207 {
"nDrawColor" ,
"(JFFFF)V" ,
reinterpret_cast<void*
>(Canvas_DrawColor) },
208 {
"nDrawRect" ,
"(JFFFFJ)V" ,
reinterpret_cast<void*
>(Canvas_DrawRect) },
209 {
"nDrawImage" ,
"(JJFFIFF)V" ,
reinterpret_cast<void*
>(Canvas_DrawImage) },
210 {
"nDrawPath" ,
"(JJJ)V" ,
reinterpret_cast<void*
>(Canvas_DrawPath) },
211 {
"nDrawGlyphs" ,
"(J[C[FFFJJ)V",
reinterpret_cast<void*
>(Canvas_DrawGlyphs) },
215 const auto clazz =
env->FindClass(
"org/skia/jetski/Canvas");
217 ?
env->RegisterNatives(clazz, methods,
std::size(methods))
int register_jetski_Canvas(JNIEnv *env)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
sk_sp< T > sk_ref_sp(T *obj)
SkImageInfo imageInfo() const
static SkM44 RowMajor(const SkScalar r[16])
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
font
Font Metadata and Metrics.
SkSamplingOptions SamplingOptions(jint desc, jfloat coeffB, jfloat coeffC)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)