1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
|
/* libs/android_runtime/android/graphics/Paint.cpp
**
** Copyright 2006, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
// This file was generated from the C++ include file: SkPaint.h
// Any changes made to this file will be discarded by the build.
// To change this file, either edit the include, or device/tools/gluemaker/main.cpp,
// or one of the auxilary file specifications in device/tools/gluemaker.
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
#include "SkBlurDrawLooper.h"
#include "SkColorFilter.h"
#include "SkMaskFilter.h"
#include "SkRasterizer.h"
#include "SkShader.h"
#include "SkTypeface.h"
#include "SkXfermode.h"
namespace android {
struct JMetricsID {
jfieldID top;
jfieldID ascent;
jfieldID descent;
jfieldID bottom;
jfieldID leading;
};
static jclass gFontMetrics_class;
static JMetricsID gFontMetrics_fieldID;
static jclass gFontMetricsInt_class;
static JMetricsID gFontMetricsInt_fieldID;
class SkPaintGlue {
public:
static void finalizer(JNIEnv* env, jobject clazz, SkPaint* obj) {
delete obj;
}
static SkPaint* init(JNIEnv* env, jobject clazz) {
SkPaint* obj = new SkPaint();
// utf16 is required for java
obj->setTextEncoding(SkPaint::kUTF16_TextEncoding);
return obj;
}
static SkPaint* intiWithPaint(JNIEnv* env, jobject clazz, SkPaint* paint) {
SkPaint* obj = new SkPaint(*paint);
return obj;
}
static void reset(JNIEnv* env, jobject clazz, SkPaint* obj) {
obj->reset();
}
static void assign(JNIEnv* env, jobject clazz, SkPaint* dst, const SkPaint* src) {
*dst = *src;
}
static jint getFlags(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return GraphicsJNI::getNativePaint(env, paint)->getFlags();
}
static void setFlags(JNIEnv* env, jobject paint, jint flags) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setFlags(flags);
}
static void setAntiAlias(JNIEnv* env, jobject paint, jboolean aa) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setAntiAlias(aa);
}
static void setLinearText(JNIEnv* env, jobject paint, jboolean linearText) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setLinearText(linearText);
}
static void setSubpixelText(JNIEnv* env, jobject paint, jboolean subpixelText) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setSubpixelText(subpixelText);
}
static void setUnderlineText(JNIEnv* env, jobject paint, jboolean underlineText) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setUnderlineText(underlineText);
}
static void setStrikeThruText(JNIEnv* env, jobject paint, jboolean strikeThruText) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setStrikeThruText(strikeThruText);
}
static void setFakeBoldText(JNIEnv* env, jobject paint, jboolean fakeBoldText) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setFakeBoldText(fakeBoldText);
}
static void setFilterBitmap(JNIEnv* env, jobject paint, jboolean filterBitmap) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setFilterBitmap(filterBitmap);
}
static void setDither(JNIEnv* env, jobject paint, jboolean dither) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setDither(dither);
}
static jint getStyle(JNIEnv* env, jobject clazz, SkPaint* obj) {
return obj->getStyle();
}
static void setStyle(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Style style) {
obj->setStyle(style);
}
static jint getColor(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return GraphicsJNI::getNativePaint(env, paint)->getColor();
}
static jint getAlpha(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return GraphicsJNI::getNativePaint(env, paint)->getAlpha();
}
static void setColor(JNIEnv* env, jobject paint, jint color) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setColor(color);
}
static void setAlpha(JNIEnv* env, jobject paint, jint a) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setAlpha(a);
}
static jfloat getStrokeWidth(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return SkScalarToFloat(GraphicsJNI::getNativePaint(env, paint)->getStrokeWidth());
}
static void setStrokeWidth(JNIEnv* env, jobject paint, jfloat width) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setStrokeWidth(SkFloatToScalar(width));
}
static jfloat getStrokeMiter(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return SkScalarToFloat(GraphicsJNI::getNativePaint(env, paint)->getStrokeMiter());
}
static void setStrokeMiter(JNIEnv* env, jobject paint, jfloat miter) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setStrokeMiter(SkFloatToScalar(miter));
}
static jint getStrokeCap(JNIEnv* env, jobject clazz, SkPaint* obj) {
return obj->getStrokeCap();
}
static void setStrokeCap(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Cap cap) {
obj->setStrokeCap(cap);
}
static jint getStrokeJoin(JNIEnv* env, jobject clazz, SkPaint* obj) {
return obj->getStrokeJoin();
}
static void setStrokeJoin(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Join join) {
obj->setStrokeJoin(join);
}
static jboolean getFillPath(JNIEnv* env, jobject clazz, SkPaint* obj, SkPath* src, SkPath* dst) {
return obj->getFillPath(*src, dst);
}
static SkShader* setShader(JNIEnv* env, jobject clazz, SkPaint* obj, SkShader* shader) {
return obj->setShader(shader);
}
static SkColorFilter* setColorFilter(JNIEnv* env, jobject clazz, SkPaint* obj, SkColorFilter* filter) {
return obj->setColorFilter(filter);
}
static SkXfermode* setXfermode(JNIEnv* env, jobject clazz, SkPaint* obj, SkXfermode* xfermode) {
return obj->setXfermode(xfermode);
}
static SkPathEffect* setPathEffect(JNIEnv* env, jobject clazz, SkPaint* obj, SkPathEffect* effect) {
return obj->setPathEffect(effect);
}
static SkMaskFilter* setMaskFilter(JNIEnv* env, jobject clazz, SkPaint* obj, SkMaskFilter* maskfilter) {
return obj->setMaskFilter(maskfilter);
}
static SkTypeface* setTypeface(JNIEnv* env, jobject clazz, SkPaint* obj, SkTypeface* typeface) {
return obj->setTypeface(typeface);
}
static SkRasterizer* setRasterizer(JNIEnv* env, jobject clazz, SkPaint* obj, SkRasterizer* rasterizer) {
return obj->setRasterizer(rasterizer);
}
static jint getTextAlign(JNIEnv* env, jobject clazz, SkPaint* obj) {
return obj->getTextAlign();
}
static void setTextAlign(JNIEnv* env, jobject clazz, SkPaint* obj, SkPaint::Align align) {
obj->setTextAlign(align);
}
static jfloat getTextSize(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return SkScalarToFloat(GraphicsJNI::getNativePaint(env, paint)->getTextSize());
}
static void setTextSize(JNIEnv* env, jobject paint, jfloat textSize) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setTextSize(SkFloatToScalar(textSize));
}
static jfloat getTextScaleX(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return SkScalarToFloat(GraphicsJNI::getNativePaint(env, paint)->getTextScaleX());
}
static void setTextScaleX(JNIEnv* env, jobject paint, jfloat scaleX) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setTextScaleX(SkFloatToScalar(scaleX));
}
static jfloat getTextSkewX(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
return SkScalarToFloat(GraphicsJNI::getNativePaint(env, paint)->getTextSkewX());
}
static void setTextSkewX(JNIEnv* env, jobject paint, jfloat skewX) {
NPE_CHECK_RETURN_VOID(env, paint);
GraphicsJNI::getNativePaint(env, paint)->setTextSkewX(SkFloatToScalar(skewX));
}
static jfloat ascent(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
SkPaint::FontMetrics metrics;
(void)GraphicsJNI::getNativePaint(env, paint)->getFontMetrics(&metrics);
return SkScalarToFloat(metrics.fAscent);
}
static jfloat descent(JNIEnv* env, jobject paint) {
NPE_CHECK_RETURN_ZERO(env, paint);
SkPaint::FontMetrics metrics;
(void)GraphicsJNI::getNativePaint(env, paint)->getFontMetrics(&metrics);
return SkScalarToFloat(metrics.fDescent);
}
static jfloat getFontMetrics(JNIEnv* env, jobject paint, jobject metricsObj) {
NPE_CHECK_RETURN_ZERO(env, paint);
SkPaint::FontMetrics metrics;
SkScalar spacing = GraphicsJNI::getNativePaint(env, paint)->getFontMetrics(&metrics);
if (metricsObj) {
SkASSERT(env->IsInstanceOf(metricsObj, gFontMetrics_class));
env->SetFloatField(metricsObj, gFontMetrics_fieldID.top, SkScalarToFloat(metrics.fTop));
env->SetFloatField(metricsObj, gFontMetrics_fieldID.ascent, SkScalarToFloat(metrics.fAscent));
env->SetFloatField(metricsObj, gFontMetrics_fieldID.descent, SkScalarToFloat(metrics.fDescent));
env->SetFloatField(metricsObj, gFontMetrics_fieldID.bottom, SkScalarToFloat(metrics.fBottom));
env->SetFloatField(metricsObj, gFontMetrics_fieldID.leading, SkScalarToFloat(metrics.fLeading));
}
return SkScalarToFloat(spacing);
}
static jint getFontMetricsInt(JNIEnv* env, jobject paint, jobject metricsObj) {
NPE_CHECK_RETURN_ZERO(env, paint);
SkPaint::FontMetrics metrics;
GraphicsJNI::getNativePaint(env, paint)->getFontMetrics(&metrics);
int ascent = SkScalarRound(metrics.fAscent);
int descent = SkScalarRound(metrics.fDescent);
int leading = SkScalarRound(metrics.fLeading);
if (metricsObj) {
SkASSERT(env->IsInstanceOf(metricsObj, gFontMetricsInt_class));
env->SetIntField(metricsObj, gFontMetricsInt_fieldID.top, SkScalarFloor(metrics.fTop));
env->SetIntField(metricsObj, gFontMetricsInt_fieldID.ascent, ascent);
env->SetIntField(metricsObj, gFontMetricsInt_fieldID.descent, descent);
env->SetIntField(metricsObj, gFontMetricsInt_fieldID.bottom, SkScalarCeil(metrics.fBottom));
env->SetIntField(metricsObj, gFontMetricsInt_fieldID.leading, leading);
}
return descent - ascent + leading;
}
static jfloat measureText_CII(JNIEnv* env, jobject jpaint, jcharArray text, int index, int count) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
size_t textLength = env->GetArrayLength(text);
if ((index | count) < 0 || (size_t)(index + count) > textLength) {
doThrow(env, "java/lang/ArrayIndexOutOfBoundsException");
return 0;
}
const SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
const jchar* textArray = env->GetCharArrayElements(text, NULL);
// we double count, since measureText wants a byteLength
SkScalar width = paint->measureText(textArray + index, count << 1);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray),
JNI_ABORT);
return SkScalarToFloat(width);
}
static jfloat measureText_StringII(JNIEnv* env, jobject jpaint, jstring text, int start, int end) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
const jchar* textArray = env->GetStringChars(text, NULL);
size_t textLength = env->GetStringLength(text);
int count = end - start;
if ((start | count) < 0 || (size_t)count > textLength) {
doThrow(env, "java/lang/IndexOutOfBoundsException");
return 0;
}
jfloat width = SkScalarToFloat(paint->measureText(textArray + start, count << 1));
env->ReleaseStringChars(text, textArray);
return width;
}
static jfloat measureText_String(JNIEnv* env, jobject jpaint, jstring text) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, text);
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
const jchar* textArray = env->GetStringChars(text, NULL);
size_t textLength = env->GetStringLength(text);
jfloat width = SkScalarToFloat(paint->measureText(textArray, textLength << 1));
env->ReleaseStringChars(text, textArray);
return width;
}
static int dotextwidths(JNIEnv* env, SkPaint* paint, const jchar text[], int count, jfloatArray widths) {
AutoJavaFloatArray autoWidths(env, widths, count);
jfloat* widthsArray = autoWidths.ptr();
SkScalar* scalarArray = (SkScalar*)widthsArray;
count = paint->getTextWidths(text, count << 1, scalarArray);
for (int i = 0; i < count; i++) {
widthsArray[i] = SkScalarToFloat(scalarArray[i]);
}
return count;
}
static int getTextWidths___CII_F(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, int index, int count, jfloatArray widths) {
const jchar* textArray = env->GetCharArrayElements(text, NULL);
count = dotextwidths(env, paint, textArray + index, count, widths);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray),
JNI_ABORT);
return count;
}
static int getTextWidths__StringII_F(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, int start, int end, jfloatArray widths) {
const jchar* textArray = env->GetStringChars(text, NULL);
int count = dotextwidths(env, paint, textArray + start, end - start, widths);
env->ReleaseStringChars(text, textArray);
return count;
}
static void getTextPath___CIIFFPath(JNIEnv* env, jobject clazz, SkPaint* paint, jcharArray text, int index, int count, jfloat x, jfloat y, SkPath* path) {
const jchar* textArray = env->GetCharArrayElements(text, NULL);
paint->getTextPath(textArray + index, count << 1, SkFloatToScalar(x), SkFloatToScalar(y), path);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray),
JNI_ABORT);
}
static void getTextPath__StringIIFFPath(JNIEnv* env, jobject clazz, SkPaint* paint, jstring text, int start, int end, jfloat x, jfloat y, SkPath* path) {
const jchar* textArray = env->GetStringChars(text, NULL);
paint->getTextPath(textArray + start, (end - start) << 1, SkFloatToScalar(x), SkFloatToScalar(y), path);
env->ReleaseStringChars(text, textArray);
}
static void setShadowLayer(JNIEnv* env, jobject jpaint, jfloat radius,
jfloat dx, jfloat dy, int color) {
NPE_CHECK_RETURN_VOID(env, jpaint);
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
if (radius <= 0) {
paint->setLooper(NULL);
}
else {
paint->setLooper(new SkBlurDrawLooper(SkFloatToScalar(radius),
SkFloatToScalar(dx),
SkFloatToScalar(dy),
(SkColor)color))->unref();
}
}
static int breakText(JNIEnv* env, const SkPaint& paint, const jchar text[],
int count, float maxWidth, jfloatArray jmeasured,
SkPaint::TextBufferDirection tbd) {
SkASSERT(paint.getTextEncoding() == SkPaint::kUTF16_TextEncoding);
SkScalar measured;
size_t bytes = paint.breakText(text, count << 1,
SkFloatToScalar(maxWidth), &measured, tbd);
SkASSERT((bytes & 1) == 0);
if (jmeasured && env->GetArrayLength(jmeasured) > 0) {
AutoJavaFloatArray autoMeasured(env, jmeasured, 1);
jfloat* array = autoMeasured.ptr();
array[0] = SkScalarToFloat(measured);
}
return bytes >> 1;
}
static int breakTextC(JNIEnv* env, jobject jpaint, jcharArray jtext,
int index, int count, float maxWidth, jfloatArray jmeasuredWidth) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, jtext);
SkPaint::TextBufferDirection tbd;
if (count < 0) {
tbd = SkPaint::kBackward_TextBufferDirection;
count = -count;
}
else {
tbd = SkPaint::kForward_TextBufferDirection;
}
if ((index < 0) || (index + count > env->GetArrayLength(jtext))) {
doThrow(env, "java/lang/ArrayIndexOutOfBoundsException");
return 0;
}
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
const jchar* text = env->GetCharArrayElements(jtext, NULL);
count = breakText(env, *paint, text + index, count, maxWidth,
jmeasuredWidth, tbd);
env->ReleaseCharArrayElements(jtext, const_cast<jchar*>(text),
JNI_ABORT);
return count;
}
static int breakTextS(JNIEnv* env, jobject jpaint, jstring jtext,
bool forwards, float maxWidth, jfloatArray jmeasuredWidth) {
NPE_CHECK_RETURN_ZERO(env, jpaint);
NPE_CHECK_RETURN_ZERO(env, jtext);
SkPaint::TextBufferDirection tbd = forwards ?
SkPaint::kForward_TextBufferDirection :
SkPaint::kBackward_TextBufferDirection;
SkPaint* paint = GraphicsJNI::getNativePaint(env, jpaint);
int count = env->GetStringLength(jtext);
const jchar* text = env->GetStringChars(jtext, NULL);
count = breakText(env, *paint, text, count, maxWidth,
jmeasuredWidth, tbd);
env->ReleaseStringChars(jtext, text);
return count;
}
static void doTextBounds(JNIEnv* env, const jchar* text, int count,
jobject bounds, const SkPaint& paint)
{
SkRect r;
SkIRect ir;
paint.measureText(text, count << 1, &r);
r.roundOut(&ir);
GraphicsJNI::irect_to_jrect(ir, env, bounds);
}
static void getStringBounds(JNIEnv* env, jobject, const SkPaint* paint,
jstring text, int start, int end, jobject bounds)
{
const jchar* textArray = env->GetStringChars(text, NULL);
doTextBounds(env, textArray + start, end - start, bounds, *paint);
env->ReleaseStringChars(text, textArray);
}
static void getCharArrayBounds(JNIEnv* env, jobject, const SkPaint* paint,
jcharArray text, int index, int count, jobject bounds)
{
const jchar* textArray = env->GetCharArrayElements(text, NULL);
doTextBounds(env, textArray + index, count, bounds, *paint);
env->ReleaseCharArrayElements(text, const_cast<jchar*>(textArray),
JNI_ABORT);
}
};
static JNINativeMethod methods[] = {
{"finalizer", "(I)V", (void*) SkPaintGlue::finalizer},
{"native_init","()I", (void*) SkPaintGlue::init},
{"native_initWithPaint","(I)I", (void*) SkPaintGlue::intiWithPaint},
{"native_reset","(I)V", (void*) SkPaintGlue::reset},
{"native_set","(II)V", (void*) SkPaintGlue::assign},
{"getFlags","()I", (void*) SkPaintGlue::getFlags},
{"setFlags","(I)V", (void*) SkPaintGlue::setFlags},
{"setAntiAlias","(Z)V", (void*) SkPaintGlue::setAntiAlias},
{"setSubpixelText","(Z)V", (void*) SkPaintGlue::setSubpixelText},
{"setLinearText","(Z)V", (void*) SkPaintGlue::setLinearText},
{"setUnderlineText","(Z)V", (void*) SkPaintGlue::setUnderlineText},
{"setStrikeThruText","(Z)V", (void*) SkPaintGlue::setStrikeThruText},
{"setFakeBoldText","(Z)V", (void*) SkPaintGlue::setFakeBoldText},
{"setFilterBitmap","(Z)V", (void*) SkPaintGlue::setFilterBitmap},
{"setDither","(Z)V", (void*) SkPaintGlue::setDither},
{"native_getStyle","(I)I", (void*) SkPaintGlue::getStyle},
{"native_setStyle","(II)V", (void*) SkPaintGlue::setStyle},
{"getColor","()I", (void*) SkPaintGlue::getColor},
{"setColor","(I)V", (void*) SkPaintGlue::setColor},
{"getAlpha","()I", (void*) SkPaintGlue::getAlpha},
{"setAlpha","(I)V", (void*) SkPaintGlue::setAlpha},
{"getStrokeWidth","()F", (void*) SkPaintGlue::getStrokeWidth},
{"setStrokeWidth","(F)V", (void*) SkPaintGlue::setStrokeWidth},
{"getStrokeMiter","()F", (void*) SkPaintGlue::getStrokeMiter},
{"setStrokeMiter","(F)V", (void*) SkPaintGlue::setStrokeMiter},
{"native_getStrokeCap","(I)I", (void*) SkPaintGlue::getStrokeCap},
{"native_setStrokeCap","(II)V", (void*) SkPaintGlue::setStrokeCap},
{"native_getStrokeJoin","(I)I", (void*) SkPaintGlue::getStrokeJoin},
{"native_setStrokeJoin","(II)V", (void*) SkPaintGlue::setStrokeJoin},
{"native_getFillPath","(III)Z", (void*) SkPaintGlue::getFillPath},
{"native_setShader","(II)I", (void*) SkPaintGlue::setShader},
{"native_setColorFilter","(II)I", (void*) SkPaintGlue::setColorFilter},
{"native_setXfermode","(II)I", (void*) SkPaintGlue::setXfermode},
{"native_setPathEffect","(II)I", (void*) SkPaintGlue::setPathEffect},
{"native_setMaskFilter","(II)I", (void*) SkPaintGlue::setMaskFilter},
{"native_setTypeface","(II)I", (void*) SkPaintGlue::setTypeface},
{"native_setRasterizer","(II)I", (void*) SkPaintGlue::setRasterizer},
{"native_getTextAlign","(I)I", (void*) SkPaintGlue::getTextAlign},
{"native_setTextAlign","(II)V", (void*) SkPaintGlue::setTextAlign},
{"getTextSize","()F", (void*) SkPaintGlue::getTextSize},
{"setTextSize","(F)V", (void*) SkPaintGlue::setTextSize},
{"getTextScaleX","()F", (void*) SkPaintGlue::getTextScaleX},
{"setTextScaleX","(F)V", (void*) SkPaintGlue::setTextScaleX},
{"getTextSkewX","()F", (void*) SkPaintGlue::getTextSkewX},
{"setTextSkewX","(F)V", (void*) SkPaintGlue::setTextSkewX},
{"ascent","()F", (void*) SkPaintGlue::ascent},
{"descent","()F", (void*) SkPaintGlue::descent},
{"getFontMetrics", "(Landroid/graphics/Paint$FontMetrics;)F", (void*)SkPaintGlue::getFontMetrics},
{"getFontMetricsInt", "(Landroid/graphics/Paint$FontMetricsInt;)I", (void*)SkPaintGlue::getFontMetricsInt},
{"measureText","([CII)F", (void*) SkPaintGlue::measureText_CII},
{"measureText","(Ljava/lang/String;)F", (void*) SkPaintGlue::measureText_String},
{"measureText","(Ljava/lang/String;II)F", (void*) SkPaintGlue::measureText_StringII},
{"breakText","([CIIF[F)I", (void*) SkPaintGlue::breakTextC},
{"breakText","(Ljava/lang/String;ZF[F)I", (void*) SkPaintGlue::breakTextS},
{"native_getTextWidths","(I[CII[F)I", (void*) SkPaintGlue::getTextWidths___CII_F},
{"native_getTextWidths","(ILjava/lang/String;II[F)I", (void*) SkPaintGlue::getTextWidths__StringII_F},
{"native_getTextPath","(I[CIIFFI)V", (void*) SkPaintGlue::getTextPath___CIIFFPath},
{"native_getTextPath","(ILjava/lang/String;IIFFI)V", (void*) SkPaintGlue::getTextPath__StringIIFFPath},
{"nativeGetStringBounds", "(ILjava/lang/String;IILandroid/graphics/Rect;)V",
(void*) SkPaintGlue::getStringBounds },
{"nativeGetCharArrayBounds", "(I[CIILandroid/graphics/Rect;)V",
(void*) SkPaintGlue::getCharArrayBounds },
{"setShadowLayer", "(FFFI)V", (void*)SkPaintGlue::setShadowLayer}
};
static jfieldID req_fieldID(jfieldID id) {
SkASSERT(id);
return id;
}
int register_android_graphics_Paint(JNIEnv* env) {
gFontMetrics_class = env->FindClass("android/graphics/Paint$FontMetrics");
SkASSERT(gFontMetrics_class);
gFontMetrics_class = (jclass)env->NewGlobalRef(gFontMetrics_class);
gFontMetrics_fieldID.top = req_fieldID(env->GetFieldID(gFontMetrics_class, "top", "F"));
gFontMetrics_fieldID.ascent = req_fieldID(env->GetFieldID(gFontMetrics_class, "ascent", "F"));
gFontMetrics_fieldID.descent = req_fieldID(env->GetFieldID(gFontMetrics_class, "descent", "F"));
gFontMetrics_fieldID.bottom = req_fieldID(env->GetFieldID(gFontMetrics_class, "bottom", "F"));
gFontMetrics_fieldID.leading = req_fieldID(env->GetFieldID(gFontMetrics_class, "leading", "F"));
gFontMetricsInt_class = env->FindClass("android/graphics/Paint$FontMetricsInt");
SkASSERT(gFontMetricsInt_class);
gFontMetricsInt_class = (jclass)env->NewGlobalRef(gFontMetricsInt_class);
gFontMetricsInt_fieldID.top = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "top", "I"));
gFontMetricsInt_fieldID.ascent = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "ascent", "I"));
gFontMetricsInt_fieldID.descent = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "descent", "I"));
gFontMetricsInt_fieldID.bottom = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "bottom", "I"));
gFontMetricsInt_fieldID.leading = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "leading", "I"));
int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Paint", methods,
sizeof(methods) / sizeof(methods[0]));
return result;
}
}
|