Merge change Iae849da2 into eclair

* changes:
  add table maskfilter
This commit is contained in:
Android (Google) Code Review
2009-10-30 17:03:18 -04:00
2 changed files with 67 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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);
}