diff options
author | Chris Craik <ccraik@google.com> | 2015-03-06 18:15:39 +0000 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-03-06 18:15:39 +0000 |
commit | 26b4f598c8b1e99b43261614a6861785638c8c00 (patch) | |
tree | bc6e64c7dc08fcbda6e1d65c7423d003426f6d6c | |
parent | a9aded1f6253afbea7906509992a8a3721f731ab (diff) | |
download | frameworks_base-26b4f598c8b1e99b43261614a6861785638c8c00.zip frameworks_base-26b4f598c8b1e99b43261614a6861785638c8c00.tar.gz frameworks_base-26b4f598c8b1e99b43261614a6861785638c8c00.tar.bz2 |
Revert "Remove references to SkPorterDuff as it is deprecated."
bug:19627342
This reverts commit a9aded1f6253afbea7906509992a8a3721f731ab.
Change-Id: Ic865edfbd31c9e24d18a1397a1d346633376e20a
-rw-r--r-- | core/jni/android/graphics/ColorFilter.cpp | 9 | ||||
-rw-r--r-- | core/jni/android/graphics/PorterDuff.cpp | 26 | ||||
-rw-r--r-- | core/jni/android/graphics/Shader.cpp | 10 | ||||
-rw-r--r-- | core/jni/android_graphics_Canvas.cpp | 4 | ||||
-rw-r--r-- | graphics/java/android/graphics/PorterDuff.java | 14 |
5 files changed, 23 insertions, 40 deletions
diff --git a/core/jni/android/graphics/ColorFilter.cpp b/core/jni/android/graphics/ColorFilter.cpp index d03bcf0..026cbee 100644 --- a/core/jni/android/graphics/ColorFilter.cpp +++ b/core/jni/android/graphics/ColorFilter.cpp @@ -21,7 +21,7 @@ #include "SkColorFilter.h" #include "SkColorMatrixFilter.h" -#include "SkXfermode.h" +#include "SkPorterDuff.h" #include <Caches.h> @@ -36,9 +36,10 @@ public: if (filter) SkSafeUnref(filter); } - static jlong CreatePorterDuffFilter(JNIEnv* env, jobject, jint srcColor, jint modeHandle) { - SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(modeHandle); - return reinterpret_cast<jlong>(SkColorFilter::CreateModeFilter(srcColor, mode)); + static jlong CreatePorterDuffFilter(JNIEnv* env, jobject, jint srcColor, + jint modeHandle) { + SkPorterDuff::Mode mode = (SkPorterDuff::Mode) modeHandle; + return reinterpret_cast<jlong>(SkColorFilter::CreateModeFilter(srcColor, SkPorterDuff::ToXfermodeMode(mode))); } static jlong CreateLightingFilter(JNIEnv* env, jobject, jint mul, jint add) { diff --git a/core/jni/android/graphics/PorterDuff.cpp b/core/jni/android/graphics/PorterDuff.cpp index d65864d..73b1691 100644 --- a/core/jni/android/graphics/PorterDuff.cpp +++ b/core/jni/android/graphics/PorterDuff.cpp @@ -24,7 +24,7 @@ #include "GraphicsJNI.h" #include "core_jni_helpers.h" -#include "SkXfermode.h" +#include "SkPorterDuff.h" namespace android { @@ -32,28 +32,8 @@ class SkPorterDuffGlue { public: static jlong CreateXfermode(JNIEnv* env, jobject, jint modeHandle) { - // validate that the Java enum values match our expectations - SK_COMPILE_ASSERT(0 == SkXfermode::kClear_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(1 == SkXfermode::kSrc_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(2 == SkXfermode::kDst_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(3 == SkXfermode::kSrcOver_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(4 == SkXfermode::kDstOver_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(5 == SkXfermode::kSrcIn_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(6 == SkXfermode::kDstIn_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(7 == SkXfermode::kSrcOut_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(8 == SkXfermode::kDstOut_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(9 == SkXfermode::kSrcATop_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(10 == SkXfermode::kDstATop_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(11 == SkXfermode::kXor_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(16 == SkXfermode::kDarken_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(17 == SkXfermode::kLighten_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(13 == SkXfermode::kModulate_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(14 == SkXfermode::kScreen_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(12 == SkXfermode::kPlus_Mode, xfermode_mismatch); - SK_COMPILE_ASSERT(15 == SkXfermode::kOverlay_Mode, xfermode_mismatch); - - SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(modeHandle); - return reinterpret_cast<jlong>(SkXfermode::Create(mode)); + SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); + return reinterpret_cast<jlong>(SkPorterDuff::CreateXfermode(mode)); } }; diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 6591d29..3f47a72 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -3,6 +3,7 @@ #include "SkShader.h" #include "SkGradientShader.h" +#include "SkPorterDuff.h" #include "SkComposeShader.h" #include "SkTemplates.h" #include "SkXfermode.h" @@ -226,13 +227,14 @@ static jlong ComposeShader_create1(JNIEnv* env, jobject o, } static jlong ComposeShader_create2(JNIEnv* env, jobject o, - jlong shaderAHandle, jlong shaderBHandle, jint xfermodeHandle) + jlong shaderAHandle, jlong shaderBHandle, jint porterDuffModeHandle) { SkShader* shaderA = reinterpret_cast<SkShader *>(shaderAHandle); SkShader* shaderB = reinterpret_cast<SkShader *>(shaderBHandle); - SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(xfermodeHandle); - SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(mode)); - SkShader* shader = new SkComposeShader(shaderA, shaderB, xfermode.get()); + SkPorterDuff::Mode porterDuffMode = static_cast<SkPorterDuff::Mode>(porterDuffModeHandle); + SkAutoUnref au(SkPorterDuff::CreateXfermode(porterDuffMode)); + SkXfermode* mode = (SkXfermode*) au.get(); + SkShader* shader = new SkComposeShader(shaderA, shaderB, mode); return reinterpret_cast<jlong>(shader); } diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp index f14e89e..7d5ca8d 100644 --- a/core/jni/android_graphics_Canvas.cpp +++ b/core/jni/android_graphics_Canvas.cpp @@ -186,8 +186,8 @@ static jboolean clipRegion(JNIEnv* env, jobject, jlong canvasHandle, jlong devic } static void drawColor(JNIEnv* env, jobject, jlong canvasHandle, jint color, jint modeHandle) { - SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(modeHandle); - get_canvas(canvasHandle)->drawColor(color, mode); + SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); + get_canvas(canvasHandle)->drawColor(color, SkPorterDuff::ToXfermodeMode(mode)); } static void drawPaint(JNIEnv* env, jobject, jlong canvasHandle, jlong paintHandle) { diff --git a/graphics/java/android/graphics/PorterDuff.java b/graphics/java/android/graphics/PorterDuff.java index f5fbe70..2ef1662 100644 --- a/graphics/java/android/graphics/PorterDuff.java +++ b/graphics/java/android/graphics/PorterDuff.java @@ -18,7 +18,7 @@ package android.graphics; public class PorterDuff { - // these value must match their native equivalents. See SkXfermode.h + // these value must match their native equivalents. See SkPorterDuff.h public enum Mode { /** [0, 0] */ CLEAR (0), @@ -46,17 +46,17 @@ public class PorterDuff { XOR (11), /** [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + min(Sc, Dc)] */ - DARKEN (16), + DARKEN (12), /** [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] */ - LIGHTEN (17), + LIGHTEN (13), /** [Sa * Da, Sc * Dc] */ - MULTIPLY (24), + MULTIPLY (14), /** [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] */ - SCREEN (14), + SCREEN (15), /** Saturate(S + D) */ - ADD (12), - OVERLAY (15); + ADD (16), + OVERLAY (17); Mode(int nativeInt) { this.nativeInt = nativeInt; |