Flutter Engine
The Flutter Engine
Paint.java
Go to the documentation of this file.
1/*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8package org.skia.jetski;
9
10import androidx.annotation.Nullable;
11
12public class Paint {
13 private long mNativeInstance;
14
15 public Paint() {
16 mNativeInstance = nCreate();
17 }
18
19 public Paint setColor(Color c) {
20 nSetColor(mNativeInstance, c.r(), c.g(), c.b(), c.a());
21 return this;
22 }
23
24 public Paint setColor(float r, float g, float b, float a) {
25 nSetColor(mNativeInstance, r, g, b, a);
26 return this;
27 }
28
29 public Paint setColorFilter(@Nullable ColorFilter filter) {
30 nSetColorFilter(mNativeInstance, filter != null ? filter.getNativeInstance() : 0);
31 return this;
32 }
33
34 public Paint setShader(@Nullable Shader shader) {
35 nSetShader(mNativeInstance, shader != null ? shader.getNativeInstance() : 0);
36 return this;
37 }
38
39 public Paint setImageFilter(@Nullable ImageFilter filter) {
40 nSetImageFilter(mNativeInstance, filter != null ? filter.getNativeInstance() : 0);
41 return this;
42 }
43
44 public Paint setStroke(boolean stroke) {
45 nSetStroke(mNativeInstance, stroke);
46 return this;
47 }
48
49 public Paint setStrokeWidth(float w) {
50 nSetStrokeWidth(mNativeInstance, w);
51 return this;
52 }
53
54 public enum Cap {
55 BUTT (0),
56 ROUND (1),
57 SQUARE (2);
58
59 private Cap(int nativeInt) {
60 this.nativeInt = nativeInt;
61 }
62 final int nativeInt;
63 }
64 public Paint setStrokeCap(Cap cap) {
65 nSetStrokeCap(mNativeInstance, cap.nativeInt);
66 return this;
67 }
68
69
70 public enum Join {
71 MITER (0),
72 ROUND (1),
73 BEVEL (2);
74
75 private Join(int nativeInt) {
76 this.nativeInt = nativeInt;
77 }
78 final int nativeInt;
79 }
81 nSetStrokeJoin(mNativeInstance, join.nativeInt);
82 return this;
83 }
84
85 public Paint setStrokeMiter(float limit) {
86 nSetStrokeMiter(mNativeInstance, limit);
87 return this;
88 }
89
90 /**
91 * Releases any resources associated with this Paint.
92 */
93 public void release() {
94 nRelease(mNativeInstance);
95 mNativeInstance = 0;
96 }
97
98 @Override
99 protected void finalize() throws Throwable {
100 release();
101 }
102
103 // package private
104 long getNativeInstance() { return mNativeInstance; }
105
106 private static native long nCreate();
107 private static native void nRelease(long nativeInstance);
108
109 private static native void nSetColor(long nativeInstance, float r, float g, float b, float a);
110 private static native void nSetStroke(long nativeInstance, boolean stroke);
111 private static native void nSetStrokeWidth(long nativeInstance, float w);
112 private static native void nSetStrokeCap(long nativeInstance, int native_cap);
113 private static native void nSetStrokeJoin(long nativeInstance, int native_join);
114 private static native void nSetStrokeMiter(long nativeInstance, float limit);
115 private static native void nSetColorFilter(long nativeInstance, long nativeCF);
116 private static native void nSetShader(long nativeInstance, long nativeShader);
117 private static native void nSetImageFilter(long nativeInstance, long nativeFilter);
118}
Paint setColor(Color c)
Definition: Paint.java:19
Paint setStrokeJoin(Join join)
Definition: Paint.java:80
Paint setColor(float r, float g, float b, float a)
Definition: Paint.java:24
Paint setColorFilter(@Nullable ColorFilter filter)
Definition: Paint.java:29
Paint setStrokeCap(Cap cap)
Definition: Paint.java:64
long getNativeInstance()
Definition: Paint.java:104
Paint setStrokeMiter(float limit)
Definition: Paint.java:85
Paint setShader(@Nullable Shader shader)
Definition: Paint.java:34
Paint setImageFilter(@Nullable ImageFilter filter)
Definition: Paint.java:39
Paint setStrokeWidth(float w)
Definition: Paint.java:49
Paint setStroke(boolean stroke)
Definition: Paint.java:44
static bool b
struct MyStruct a[10]
Join
Definition: path.h:24
Cap
Definition: path.h:18
SkScalar w
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741