Merge changes I241824bf,I9021864f
* changes: Convert ColorLong in native code in Paint Restore Paint#nSetColor(@ColorInt)
This commit is contained in:
committed by
Android (Google) Code Review
commit
c052fa2032
@@ -723,13 +723,17 @@ namespace PaintGlue {
|
||||
obj->setStyle(style);
|
||||
}
|
||||
|
||||
static void setColor(jlong paintHandle, jlong colorSpaceHandle,
|
||||
jfloat r, jfloat g, jfloat b, jfloat a) {
|
||||
static void setColorLong(jlong paintHandle, jlong colorSpaceHandle,
|
||||
jlong colorLong) {
|
||||
SkColor4f color = GraphicsJNI::convertColorLong(colorLong);
|
||||
sk_sp<SkColorSpace> cs = GraphicsJNI::getNativeColorSpace(colorSpaceHandle);
|
||||
SkColor4f color = SkColor4f{r, g, b, a};
|
||||
reinterpret_cast<Paint*>(paintHandle)->setColor4f(color, cs.get());
|
||||
}
|
||||
|
||||
static void setColor(jlong paintHandle, jint color) {
|
||||
reinterpret_cast<Paint*>(paintHandle)->setColor(color);
|
||||
}
|
||||
|
||||
static void setAlpha(jlong paintHandle, jint a) {
|
||||
reinterpret_cast<Paint*>(paintHandle)->setAlpha(a);
|
||||
}
|
||||
@@ -991,9 +995,9 @@ namespace PaintGlue {
|
||||
|
||||
static void setShadowLayer(jlong paintHandle, jfloat radius,
|
||||
jfloat dx, jfloat dy, jlong colorSpaceHandle,
|
||||
jfloat r, jfloat g, jfloat b, jfloat a) {
|
||||
jlong colorLong) {
|
||||
SkColor4f color = GraphicsJNI::convertColorLong(colorLong);
|
||||
sk_sp<SkColorSpace> cs = GraphicsJNI::getNativeColorSpace(colorSpaceHandle);
|
||||
SkColor4f color = SkColor4f{r, g, b, a};
|
||||
|
||||
Paint* paint = reinterpret_cast<Paint*>(paintHandle);
|
||||
if (radius <= 0) {
|
||||
@@ -1082,7 +1086,8 @@ static const JNINativeMethod methods[] = {
|
||||
{"nSetDither","(JZ)V", (void*) PaintGlue::setDither},
|
||||
{"nGetStyle","(J)I", (void*) PaintGlue::getStyle},
|
||||
{"nSetStyle","(JI)V", (void*) PaintGlue::setStyle},
|
||||
{"nSetColor","(JJFFFF)V", (void*) PaintGlue::setColor},
|
||||
{"nSetColor","(JI)V", (void*) PaintGlue::setColor},
|
||||
{"nSetColor","(JJJ)V", (void*) PaintGlue::setColorLong},
|
||||
{"nSetAlpha","(JI)V", (void*) PaintGlue::setAlpha},
|
||||
{"nGetStrokeWidth","(J)F", (void*) PaintGlue::getStrokeWidth},
|
||||
{"nSetStrokeWidth","(JF)V", (void*) PaintGlue::setStrokeWidth},
|
||||
@@ -1125,7 +1130,7 @@ static const JNINativeMethod methods[] = {
|
||||
{"nGetUnderlineThickness","(J)F", (void*) PaintGlue::getUnderlineThickness},
|
||||
{"nGetStrikeThruPosition","(J)F", (void*) PaintGlue::getStrikeThruPosition},
|
||||
{"nGetStrikeThruThickness","(J)F", (void*) PaintGlue::getStrikeThruThickness},
|
||||
{"nSetShadowLayer", "(JFFFJFFFF)V", (void*)PaintGlue::setShadowLayer},
|
||||
{"nSetShadowLayer", "(JFFFJJ)V", (void*)PaintGlue::setShadowLayer},
|
||||
{"nHasShadowLayer", "(J)Z", (void*)PaintGlue::hasShadowLayer},
|
||||
{"nEqualsForTextMeasurement", "(JJ)Z", (void*)PaintGlue::equalsForTextMeasurement},
|
||||
};
|
||||
|
||||
@@ -1046,7 +1046,8 @@ public class Paint {
|
||||
* @param color The new color (including alpha) to set in the paint.
|
||||
*/
|
||||
public void setColor(@ColorInt int color) {
|
||||
setColor(Color.pack(color));
|
||||
nSetColor(mNativePaint, color);
|
||||
mColor = Color.pack(color);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1063,12 +1064,8 @@ public class Paint {
|
||||
*/
|
||||
public void setColor(@ColorLong long color) {
|
||||
ColorSpace cs = Color.colorSpace(color);
|
||||
float r = Color.red(color);
|
||||
float g = Color.green(color);
|
||||
float b = Color.blue(color);
|
||||
float a = Color.alpha(color);
|
||||
|
||||
nSetColor(mNativePaint, cs.getNativeInstance(), r, g, b, a);
|
||||
nSetColor(mNativePaint, cs.getNativeInstance(), color);
|
||||
mColor = color;
|
||||
}
|
||||
|
||||
@@ -1498,11 +1495,7 @@ public class Paint {
|
||||
*/
|
||||
public void setShadowLayer(float radius, float dx, float dy, @ColorLong long shadowColor) {
|
||||
ColorSpace cs = Color.colorSpace(shadowColor);
|
||||
float r = Color.red(shadowColor);
|
||||
float g = Color.green(shadowColor);
|
||||
float b = Color.blue(shadowColor);
|
||||
float a = Color.alpha(shadowColor);
|
||||
nSetShadowLayer(mNativePaint, radius, dx, dy, cs.getNativeInstance(), r, g, b, a);
|
||||
nSetShadowLayer(mNativePaint, radius, dx, dy, cs.getNativeInstance(), shadowColor);
|
||||
|
||||
mShadowLayerRadius = radius;
|
||||
mShadowLayerDx = dx;
|
||||
@@ -1530,6 +1523,7 @@ public class Paint {
|
||||
/**
|
||||
* Returns the blur radius of the shadow layer.
|
||||
* @see #setShadowLayer(float,float,float,int)
|
||||
* @see #setShadowLayer(float,float,float,long)
|
||||
*/
|
||||
public float getShadowLayerRadius() {
|
||||
return mShadowLayerRadius;
|
||||
@@ -1538,6 +1532,7 @@ public class Paint {
|
||||
/**
|
||||
* Returns the x offset of the shadow layer.
|
||||
* @see #setShadowLayer(float,float,float,int)
|
||||
* @see #setShadowLayer(float,float,float,long)
|
||||
*/
|
||||
public float getShadowLayerDx() {
|
||||
return mShadowLayerDx;
|
||||
@@ -1546,6 +1541,7 @@ public class Paint {
|
||||
/**
|
||||
* Returns the y offset of the shadow layer.
|
||||
* @see #setShadowLayer(float,float,float,int)
|
||||
* @see #setShadowLayer(float,float,float,long)
|
||||
*/
|
||||
public float getShadowLayerDy() {
|
||||
return mShadowLayerDy;
|
||||
@@ -3135,7 +3131,7 @@ public class Paint {
|
||||
@CriticalNative
|
||||
private static native void nSetShadowLayer(long paintPtr,
|
||||
float radius, float dx, float dy, long colorSpaceHandle,
|
||||
float r, float g, float b, float a);
|
||||
@ColorLong long shadowColor);
|
||||
@CriticalNative
|
||||
private static native boolean nHasShadowLayer(long paintPtr);
|
||||
@CriticalNative
|
||||
@@ -3188,7 +3184,9 @@ public class Paint {
|
||||
private static native void nSetFilterBitmap(long paintPtr, boolean filter);
|
||||
@CriticalNative
|
||||
private static native void nSetColor(long paintPtr, long colorSpaceHandle,
|
||||
float r, float g, float b, float a);
|
||||
@ColorLong long color);
|
||||
@CriticalNative
|
||||
private static native void nSetColor(long paintPtr, @ColorInt int color);
|
||||
@CriticalNative
|
||||
private static native void nSetStrikeThruText(long paintPtr, boolean strikeThruText);
|
||||
@CriticalNative
|
||||
|
||||
Reference in New Issue
Block a user