diff options
author | Chris Craik <ccraik@google.com> | 2015-03-06 18:16:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-06 18:16:45 +0000 |
commit | fdbf68ff6c5e45da4971352775d614e6790cc991 (patch) | |
tree | 7a4dcec6b82eaac58019865153c579304cccca6c /core/jni/android | |
parent | f045198fb3b008e0341f0b9761e4ef96310e7333 (diff) | |
parent | 26b4f598c8b1e99b43261614a6861785638c8c00 (diff) | |
download | frameworks_base-fdbf68ff6c5e45da4971352775d614e6790cc991.zip frameworks_base-fdbf68ff6c5e45da4971352775d614e6790cc991.tar.gz frameworks_base-fdbf68ff6c5e45da4971352775d614e6790cc991.tar.bz2 |
Merge "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, 14 insertions, 31 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); } |