diff options
| author | 2009-10-29 17:20:49 -0400 | |
|---|---|---|
| committer | 2009-10-30 08:11:58 -0400 | |
| commit | 0e1e62301112a51d9b91ac4ac31c406d726f93ab (patch) | |
| tree | dce2e89b4c8eba09f15de26587cc0b087ce29cd0 | |
| parent | ec1f1e3df1ca5e73e262df479bf91a92f3ccafde (diff) | |
add table maskfilter
hidden for now, since it need only be seen by Launcher2
http://b/issue?id=2210685
| -rw-r--r-- | core/jni/android/graphics/MaskFilter.cpp | 21 | ||||
| -rw-r--r-- | graphics/java/android/graphics/TableMaskFilter.java | 46 |
2 files changed, 67 insertions, 0 deletions
diff --git a/core/jni/android/graphics/MaskFilter.cpp b/core/jni/android/graphics/MaskFilter.cpp index 0f8dff121055..455449e5349d 100644 --- a/core/jni/android/graphics/MaskFilter.cpp +++ b/core/jni/android/graphics/MaskFilter.cpp @@ -1,6 +1,7 @@ #include "GraphicsJNI.h" #include "SkMaskFilter.h" #include "SkBlurMaskFilter.h" +#include "SkTableMaskFilter.h" #include <jni.h> @@ -39,6 +40,19 @@ public: ThrowIAE_IfNull(env, filter); return filter; } + + static SkMaskFilter* createTable(JNIEnv* env, jobject, jbyteArray jtable) { + AutoJavaByteArray autoTable(env, jtable, 256); + return new SkTableMaskFilter((const uint8_t*)autoTable.ptr()); + } + + static SkMaskFilter* createClipTable(JNIEnv* env, jobject, int min, int max) { + return SkTableMaskFilter::CreateClip(min, max); + } + + static SkMaskFilter* createGammaTable(JNIEnv* env, jobject, float gamma) { + return SkTableMaskFilter::CreateGamma(gamma); + } }; static JNINativeMethod gMaskFilterMethods[] = { @@ -53,6 +67,12 @@ static JNINativeMethod gEmbossMaskFilterMethods[] = { { "nativeConstructor", "([FFFF)I", (void*)SkMaskFilterGlue::createEmboss } }; +static JNINativeMethod gTableMaskFilterMethods[] = { + { "nativeNewTable", "([B)I", (void*)SkMaskFilterGlue::createTable }, + { "nativeNewClip", "(II)I", (void*)SkMaskFilterGlue::createClipTable }, + { "nativeNewGamma", "(F)I", (void*)SkMaskFilterGlue::createGammaTable } +}; + #include <android_runtime/AndroidRuntime.h> #define REG(env, name, array) \ @@ -67,6 +87,7 @@ int register_android_graphics_MaskFilter(JNIEnv* env) REG(env, "android/graphics/MaskFilter", gMaskFilterMethods); REG(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods); REG(env, "android/graphics/EmbossMaskFilter", gEmbossMaskFilterMethods); + REG(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods); return 0; } diff --git a/graphics/java/android/graphics/TableMaskFilter.java b/graphics/java/android/graphics/TableMaskFilter.java new file mode 100644 index 000000000000..a8a7ff0528e1 --- /dev/null +++ b/graphics/java/android/graphics/TableMaskFilter.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.graphics; + +/** + * @hide + */ +public class TableMaskFilter extends MaskFilter { + + public TableMaskFilter(byte[] table) { + if (table.length < 256) { + throw new RuntimeException("table.length must be >= 256"); + } + native_instance = nativeNewTable(table); + } + + private TableMaskFilter(int ni) { + native_instance = ni; + } + + public static TableMaskFilter CreateClipTable(int min, int max) { + return new TableMaskFilter(nativeNewClip(min, max)); + } + + public static TableMaskFilter CreateGammaTable(float gamma) { + return new TableMaskFilter(nativeNewGamma(gamma)); + } + + private static native int nativeNewTable(byte[] table); + private static native int nativeNewClip(int min, int max); + private static native int nativeNewGamma(float gamma); +} |