diff options
author | Chris Craik <ccraik@google.com> | 2015-03-06 18:42:15 +0000 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2015-03-06 18:42:15 +0000 |
commit | 1526a458a30184609f19b05e7334da3cbde81dd1 (patch) | |
tree | 1cc798a79f4df46890c18351413497478fd8f16a | |
parent | 26b4f598c8b1e99b43261614a6861785638c8c00 (diff) | |
download | frameworks_base-1526a458a30184609f19b05e7334da3cbde81dd1.zip frameworks_base-1526a458a30184609f19b05e7334da3cbde81dd1.tar.gz frameworks_base-1526a458a30184609f19b05e7334da3cbde81dd1.tar.bz2 |
Revert "Revert "Remove references to SkPorterDuff as it is deprecated.""
Fix build breakage.
This reverts commit 26b4f598c8b1e99b43261614a6861785638c8c00.
Change-Id: If39ce2a41d26a8520091f330234c3d35e413ee92
-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, 40 insertions, 23 deletions
diff --git a/core/jni/android/graphics/ColorFilter.cpp b/core/jni/android/graphics/ColorFilter.cpp index 026cbee..d03bcf0 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 "SkPorterDuff.h" +#include "SkXfermode.h" #include <Caches.h> @@ -36,10 +36,9 @@ public: if (filter) SkSafeUnref(filter); } - 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 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 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 73b1691..d65864d 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 "SkPorterDuff.h" +#include "SkXfermode.h" namespace android { @@ -32,8 +32,28 @@ class SkPorterDuffGlue { public: static jlong CreateXfermode(JNIEnv* env, jobject, jint modeHandle) { - SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); - return reinterpret_cast<jlong>(SkPorterDuff::CreateXfermode(mode)); + // 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)); } }; diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 3f47a72..6591d29 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -3,7 +3,6 @@ #include "SkShader.h" #include "SkGradientShader.h" -#include "SkPorterDuff.h" #include "SkComposeShader.h" #include "SkTemplates.h" #include "SkXfermode.h" @@ -227,14 +226,13 @@ static jlong ComposeShader_create1(JNIEnv* env, jobject o, } static jlong ComposeShader_create2(JNIEnv* env, jobject o, - jlong shaderAHandle, jlong shaderBHandle, jint porterDuffModeHandle) + jlong shaderAHandle, jlong shaderBHandle, jint xfermodeHandle) { SkShader* shaderA = reinterpret_cast<SkShader *>(shaderAHandle); SkShader* shaderB = reinterpret_cast<SkShader *>(shaderBHandle); - 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); + SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(xfermodeHandle); + SkAutoTUnref<SkXfermode> xfermode(SkXfermode::Create(mode)); + SkShader* shader = new SkComposeShader(shaderA, shaderB, xfermode.get()); return reinterpret_cast<jlong>(shader); } diff --git a/core/jni/android_graphics_Canvas.cpp b/core/jni/android_graphics_Canvas.cpp index 7d5ca8d..f14e89e 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) { - SkPorterDuff::Mode mode = static_cast<SkPorterDuff::Mode>(modeHandle); - get_canvas(canvasHandle)->drawColor(color, SkPorterDuff::ToXfermodeMode(mode)); + SkXfermode::Mode mode = static_cast<SkXfermode::Mode>(modeHandle); + get_canvas(canvasHandle)->drawColor(color, 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 2ef1662..f5fbe70 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 SkPorterDuff.h + // these value must match their native equivalents. See SkXfermode.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 (12), + DARKEN (16), /** [Sa + Da - Sa*Da, Sc*(1 - Da) + Dc*(1 - Sa) + max(Sc, Dc)] */ - LIGHTEN (13), + LIGHTEN (17), /** [Sa * Da, Sc * Dc] */ - MULTIPLY (14), + MULTIPLY (24), /** [Sa + Da - Sa * Da, Sc + Dc - Sc * Dc] */ - SCREEN (15), + SCREEN (14), /** Saturate(S + D) */ - ADD (16), - OVERLAY (17); + ADD (12), + OVERLAY (15); Mode(int nativeInt) { this.nativeInt = nativeInt; |