20 GradientData(JNIEnv*
env,
const jfloatArray& jcolors,
const jfloatArray& jpos,
21 jint jtm, jlong native_lm)
25 , fColors(
env->GetFloatArrayElements(jcolors, nullptr))
26 , fPos(
env->GetFloatArrayElements(jpos, nullptr))
29 , fLocalMatrix(native_lm ? reinterpret_cast<const
SkM44*>(native_lm)->asM33() :
SkMatrix())
35 fEnv->ReleaseFloatArrayElements(fJPos, fPos, 0);
36 fEnv->ReleaseFloatArrayElements(fJColors, fColors, 0);
42 const float*
pos()
const {
return fPos; }
43 const SkTileMode& tileMode()
const {
return fTileMode; }
44 const SkMatrix& localMatrix()
const {
return fLocalMatrix; }
48 const jfloatArray& fJColors;
49 const jfloatArray& fJPos;
57static jlong
MakeLinear(JNIEnv*
env, jobject, jfloat x0, jfloat y0, jfloat x1, jfloat y1,
58 jfloatArray jcolors, jfloatArray jpos, jint jtm, jlong native_lm) {
59 const GradientData gdata(
env, jcolors, jpos, jtm, native_lm);
60 const SkPoint pts[] = {{x0, y0}, {x1, y1}};
69 &gdata.localMatrix());
71 return reinterpret_cast<jlong
>(shader.release());
74static jlong
MakeRadial(JNIEnv*
env, jobject, jfloat
x, jfloat
y, jfloat r,
75 jfloatArray jcolors, jfloatArray jpos, jint jtm, jlong native_lm) {
76 const GradientData gdata(
env, jcolors, jpos, jtm, native_lm);
85 &gdata.localMatrix());
87 return reinterpret_cast<jlong
>(shader.release());
90static jlong MakeTwoPointConical(JNIEnv*
env, jobject,
91 jfloat x0, jfloat y0, jfloat r0,
92 jfloat x1, jfloat y1, jfloat r1,
93 jfloatArray jcolors, jfloatArray jpos, jint jtm, jlong native_lm) {
94 const GradientData gdata(
env, jcolors, jpos, jtm, native_lm);
104 &gdata.localMatrix());
106 return reinterpret_cast<jlong
>(shader.release());
109static jlong
MakeSweep(JNIEnv*
env, jobject, jfloat
x, jfloat
y, jfloat sa, jfloat ea,
110 jfloatArray jcolors, jfloatArray jpos, jint jtm, jlong native_lm) {
111 const GradientData gdata(
env, jcolors, jpos, jtm, native_lm);
121 &gdata.localMatrix());
123 return reinterpret_cast<jlong
>(shader.release());
129 static const JNINativeMethod methods[] = {
130 {
"nMakeLinear",
"(FFFF[F[FIJ)J",
reinterpret_cast<void*
>(
MakeLinear)},
133 const auto clazz =
env->FindClass(
"org/skia/jetski/LinearGradient");
135 ?
env->RegisterNatives(clazz, methods, std::size(methods))
140 static const JNINativeMethod methods[] = {
141 {
"nMakeRadial",
"(FFF[F[FIJ)J",
reinterpret_cast<void*
>(
MakeRadial)},
144 const auto clazz =
env->FindClass(
"org/skia/jetski/RadialGradient");
146 ?
env->RegisterNatives(clazz, methods, std::size(methods))
151 static const JNINativeMethod methods[] = {
152 {
"nMakeTwoPointConical",
"(FFFFFF[F[FIJ)J",
reinterpret_cast<void*
>(MakeTwoPointConical)},
155 const auto clazz =
env->FindClass(
"org/skia/jetski/TwoPointConicalGradient");
157 ?
env->RegisterNatives(clazz, methods, std::size(methods))
162 static const JNINativeMethod methods[] = {
163 {
"nMakeSweep",
"(FFFF[F[FIJ)J",
reinterpret_cast<void*
>(
MakeSweep)},
166 const auto clazz =
env->FindClass(
"org/skia/jetski/SweepGradient");
168 ?
env->RegisterNatives(clazz, methods, std::size(methods))
static sk_sp< SkShader > MakeSweep(const SkPoint pts[2], const GradData &data, SkTileMode tm, float scale)
Ignores scale.
int register_jetski_RadialGradient(JNIEnv *env)
int register_jetski_TwoPointConicalGradient(JNIEnv *env)
int register_jetski_LinearGradient(JNIEnv *env)
int register_jetski_SweepGradient(JNIEnv *env)
static sk_sp< SkShader > MakeRadial()
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)
static sk_sp< SkShader > MakeRadial(const SkPoint ¢er, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static sk_sp< SkShader > MakeLinear()
PODArray< SkColor > colors
SkTileMode TileMode(jint tm)