diff options
author | Chris Craik <ccraik@google.com> | 2015-03-06 18:42:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-06 18:42:30 +0000 |
commit | 2d08eaf0341df5d22236baadbcc4341f0e2e7f5e (patch) | |
tree | 96789154ea6e71825059cb35a5cabd133647bd01 /core/jni/android | |
parent | fdbf68ff6c5e45da4971352775d614e6790cc991 (diff) | |
parent | 1526a458a30184609f19b05e7334da3cbde81dd1 (diff) | |
download | frameworks_base-2d08eaf0341df5d22236baadbcc4341f0e2e7f5e.zip frameworks_base-2d08eaf0341df5d22236baadbcc4341f0e2e7f5e.tar.gz frameworks_base-2d08eaf0341df5d22236baadbcc4341f0e2e7f5e.tar.bz2 |
Merge "Revert "Revert "Remove references to SkPorterDuff as it is deprecated."""
Diffstat (limited to 'core/jni/android')
-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 |
3 files changed, 31 insertions, 14 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); } |