diff options
author | Andreas Gampe <agampe@google.com> | 2014-11-21 10:36:14 -0800 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-11-21 10:36:14 -0800 |
commit | 7d13d9db1ef90063cb542ccd6554042a6a3263b7 (patch) | |
tree | 087eaefffcd35f9c4968408ea80080cda39e22ac /core/jni/android | |
parent | 935fd8d0b1c7953e6e6610aea0c2d09d0fa8ba97 (diff) | |
parent | 3fc5e3cabfd9787e722b7720eabbcbba49984a94 (diff) | |
download | frameworks_base-7d13d9db1ef90063cb542ccd6554042a6a3263b7.zip frameworks_base-7d13d9db1ef90063cb542ccd6554042a6a3263b7.tar.gz frameworks_base-7d13d9db1ef90063cb542ccd6554042a6a3263b7.tar.bz2 |
resolved conflicts for merge of 3fc5e3ca to lmp-mr1-dev-plus-aosp
Change-Id: Id8286e5a4381315a6060251a8055b0f1d1a96019
Diffstat (limited to 'core/jni/android')
47 files changed, 314 insertions, 430 deletions
diff --git a/core/jni/android/graphics/AutoDecodeCancel.h b/core/jni/android/graphics/AutoDecodeCancel.h index 37b86f9..dd6a0d4 100644 --- a/core/jni/android/graphics/AutoDecodeCancel.h +++ b/core/jni/android/graphics/AutoDecodeCancel.h @@ -1,5 +1,5 @@ -#ifndef AutoDecodeCancel_DEFINED -#define AutoDecodeCancel_DEFINED +#ifndef _ANDROID_GRAPHICS_AUTO_DECODE_CANCEL_H_ +#define _ANDROID_GRAPHICS_AUTO_DECODE_CANCEL_H_ #include <jni.h> #include "SkImageDecoder.h" @@ -24,4 +24,4 @@ private: #endif }; -#endif +#endif // _ANDROID_GRAPHICS_AUTO_DECODE_CANCEL_H_ diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp index 61a34e5..ceec0e3 100755 --- a/core/jni/android/graphics/Bitmap.cpp +++ b/core/jni/android/graphics/Bitmap.cpp @@ -15,16 +15,12 @@ #include "android_nio_utils.h" #include "CreateJavaOutputStreamAdaptor.h" +#include "core_jni_helpers.h" + #include <jni.h> #include <ResourceCache.h> -#if 0 - #define TRACE_BITMAP(code) code -#else - #define TRACE_BITMAP(code) -#endif - /////////////////////////////////////////////////////////////////////////////// // Conversions to/from SkColor, for get/setPixels, and the create method, which // is basically like setPixels @@ -876,8 +872,6 @@ static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapHandle) { /////////////////////////////////////////////////////////////////////////////// -#include <android_runtime/AndroidRuntime.h> - static JNINativeMethod gBitmapMethods[] = { { "nativeCreate", "([IIIIIIZ)Landroid/graphics/Bitmap;", (void*)Bitmap_creator }, @@ -917,10 +911,8 @@ static JNINativeMethod gBitmapMethods[] = { { "nativePrepareToDraw", "(J)V", (void*)Bitmap_prepareToDraw }, }; -#define kClassPathName "android/graphics/Bitmap" - int register_android_graphics_Bitmap(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, kClassPathName, - gBitmapMethods, SK_ARRAY_COUNT(gBitmapMethods)); + return android::RegisterMethodsOrDie(env, "android/graphics/Bitmap", gBitmapMethods, + NELEM(gBitmapMethods)); } diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp index 0e08a8d..099f1b0 100644 --- a/core/jni/android/graphics/BitmapFactory.cpp +++ b/core/jni/android/graphics/BitmapFactory.cpp @@ -15,7 +15,7 @@ #include "JNIHelp.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include <androidfw/Asset.h> #include <androidfw/ResourceTypes.h> #include <cutils/compiler.h> @@ -574,52 +574,40 @@ static JNINativeMethod gOptionsMethods[] = { { "requestCancel", "()V", (void*)nativeRequestCancel } }; -static jfieldID getFieldIDCheck(JNIEnv* env, jclass clazz, - const char fieldname[], const char type[]) { - jfieldID id = env->GetFieldID(clazz, fieldname, type); - SkASSERT(id); - return id; -} - int register_android_graphics_BitmapFactory(JNIEnv* env) { - jclass options_class = env->FindClass("android/graphics/BitmapFactory$Options"); - SkASSERT(options_class); - gOptions_bitmapFieldID = getFieldIDCheck(env, options_class, "inBitmap", + jclass options_class = FindClassOrDie(env, "android/graphics/BitmapFactory$Options"); + gOptions_bitmapFieldID = GetFieldIDOrDie(env, options_class, "inBitmap", "Landroid/graphics/Bitmap;"); - gOptions_justBoundsFieldID = getFieldIDCheck(env, options_class, "inJustDecodeBounds", "Z"); - gOptions_sampleSizeFieldID = getFieldIDCheck(env, options_class, "inSampleSize", "I"); - gOptions_configFieldID = getFieldIDCheck(env, options_class, "inPreferredConfig", + gOptions_justBoundsFieldID = GetFieldIDOrDie(env, options_class, "inJustDecodeBounds", "Z"); + gOptions_sampleSizeFieldID = GetFieldIDOrDie(env, options_class, "inSampleSize", "I"); + gOptions_configFieldID = GetFieldIDOrDie(env, options_class, "inPreferredConfig", "Landroid/graphics/Bitmap$Config;"); - gOptions_premultipliedFieldID = getFieldIDCheck(env, options_class, "inPremultiplied", "Z"); - gOptions_mutableFieldID = getFieldIDCheck(env, options_class, "inMutable", "Z"); - gOptions_ditherFieldID = getFieldIDCheck(env, options_class, "inDither", "Z"); - gOptions_preferQualityOverSpeedFieldID = getFieldIDCheck(env, options_class, + gOptions_premultipliedFieldID = GetFieldIDOrDie(env, options_class, "inPremultiplied", "Z"); + gOptions_mutableFieldID = GetFieldIDOrDie(env, options_class, "inMutable", "Z"); + gOptions_ditherFieldID = GetFieldIDOrDie(env, options_class, "inDither", "Z"); + gOptions_preferQualityOverSpeedFieldID = GetFieldIDOrDie(env, options_class, "inPreferQualityOverSpeed", "Z"); - gOptions_scaledFieldID = getFieldIDCheck(env, options_class, "inScaled", "Z"); - gOptions_densityFieldID = getFieldIDCheck(env, options_class, "inDensity", "I"); - gOptions_screenDensityFieldID = getFieldIDCheck(env, options_class, "inScreenDensity", "I"); - gOptions_targetDensityFieldID = getFieldIDCheck(env, options_class, "inTargetDensity", "I"); - gOptions_widthFieldID = getFieldIDCheck(env, options_class, "outWidth", "I"); - gOptions_heightFieldID = getFieldIDCheck(env, options_class, "outHeight", "I"); - gOptions_mimeFieldID = getFieldIDCheck(env, options_class, "outMimeType", "Ljava/lang/String;"); - gOptions_mCancelID = getFieldIDCheck(env, options_class, "mCancel", "Z"); - - jclass bitmap_class = env->FindClass("android/graphics/Bitmap"); - SkASSERT(bitmap_class); - gBitmap_nativeBitmapFieldID = getFieldIDCheck(env, bitmap_class, "mNativeBitmap", "J"); - gBitmap_ninePatchInsetsFieldID = getFieldIDCheck(env, bitmap_class, "mNinePatchInsets", + gOptions_scaledFieldID = GetFieldIDOrDie(env, options_class, "inScaled", "Z"); + gOptions_densityFieldID = GetFieldIDOrDie(env, options_class, "inDensity", "I"); + gOptions_screenDensityFieldID = GetFieldIDOrDie(env, options_class, "inScreenDensity", "I"); + gOptions_targetDensityFieldID = GetFieldIDOrDie(env, options_class, "inTargetDensity", "I"); + gOptions_widthFieldID = GetFieldIDOrDie(env, options_class, "outWidth", "I"); + gOptions_heightFieldID = GetFieldIDOrDie(env, options_class, "outHeight", "I"); + gOptions_mimeFieldID = GetFieldIDOrDie(env, options_class, "outMimeType", "Ljava/lang/String;"); + gOptions_mCancelID = GetFieldIDOrDie(env, options_class, "mCancel", "Z"); + + jclass bitmap_class = FindClassOrDie(env, "android/graphics/Bitmap"); + gBitmap_nativeBitmapFieldID = GetFieldIDOrDie(env, bitmap_class, "mNativeBitmap", "J"); + gBitmap_ninePatchInsetsFieldID = GetFieldIDOrDie(env, bitmap_class, "mNinePatchInsets", "Landroid/graphics/NinePatch$InsetStruct;"); - gInsetStruct_class = (jclass) env->NewGlobalRef(env->FindClass("android/graphics/NinePatch$InsetStruct")); - gInsetStruct_constructorMethodID = env->GetMethodID(gInsetStruct_class, "<init>", "(IIIIIIIIFIF)V"); + gInsetStruct_class = MakeGlobalRefOrDie(env, FindClassOrDie(env, + "android/graphics/NinePatch$InsetStruct")); + gInsetStruct_constructorMethodID = GetMethodIDOrDie(env, gInsetStruct_class, "<init>", + "(IIIIIIIIFIF)V"); - int ret = AndroidRuntime::registerNativeMethods(env, - "android/graphics/BitmapFactory$Options", - gOptionsMethods, - SK_ARRAY_COUNT(gOptionsMethods)); - if (ret) { - return ret; - } - return android::AndroidRuntime::registerNativeMethods(env, "android/graphics/BitmapFactory", - gMethods, SK_ARRAY_COUNT(gMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/BitmapFactory$Options", + gOptionsMethods, NELEM(gOptionsMethods)); + return android::RegisterMethodsOrDie(env, "android/graphics/BitmapFactory", + gMethods, NELEM(gMethods)); } diff --git a/core/jni/android/graphics/BitmapFactory.h b/core/jni/android/graphics/BitmapFactory.h index 97dcc6d..a54da43 100644 --- a/core/jni/android/graphics/BitmapFactory.h +++ b/core/jni/android/graphics/BitmapFactory.h @@ -1,5 +1,5 @@ -#ifndef BitmapFactory_DEFINE -#define BitmapFactory_DEFINE +#ifndef _ANDROID_GRAPHICS_BITMAP_FACTORY_H_ +#define _ANDROID_GRAPHICS_BITMAP_FACTORY_H_ #include "GraphicsJNI.h" @@ -21,4 +21,4 @@ extern jfieldID gOptions_bitmapFieldID; jstring getMimeTypeString(JNIEnv* env, SkImageDecoder::Format format); -#endif +#endif // _ANDROID_GRAPHICS_BITMAP_FACTORY_H_ diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp index 91efc8c..3537bcb 100644 --- a/core/jni/android/graphics/BitmapRegionDecoder.cpp +++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp @@ -30,7 +30,7 @@ #include "Utils.h" #include "JNIHelp.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "android_util_Binder.h" #include "android_nio_utils.h" #include "CreateJavaOutputStreamAdaptor.h" @@ -40,12 +40,6 @@ #include <androidfw/Asset.h> #include <sys/stat.h> -#if 0 - #define TRACE_BITMAP(code) code -#else - #define TRACE_BITMAP(code) -#endif - using namespace android; class SkBitmapRegionDecoder { @@ -273,8 +267,6 @@ static void nativeClean(JNIEnv* env, jobject, jlong brdHandle) { /////////////////////////////////////////////////////////////////////////////// -#include <android_runtime/AndroidRuntime.h> - static JNINativeMethod gBitmapRegionDecoderMethods[] = { { "nativeDecodeRegion", "(JIIIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;", @@ -307,10 +299,8 @@ static JNINativeMethod gBitmapRegionDecoderMethods[] = { }, }; -#define kClassPathName "android/graphics/BitmapRegionDecoder" - int register_android_graphics_BitmapRegionDecoder(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, kClassPathName, - gBitmapRegionDecoderMethods, SK_ARRAY_COUNT(gBitmapRegionDecoderMethods)); + return android::RegisterMethodsOrDie(env, "android/graphics/BitmapRegionDecoder", + gBitmapRegionDecoderMethods, NELEM(gBitmapRegionDecoderMethods)); } diff --git a/core/jni/android/graphics/Camera.cpp b/core/jni/android/graphics/Camera.cpp index 9f832b0..b572604 100644 --- a/core/jni/android/graphics/Camera.cpp +++ b/core/jni/android/graphics/Camera.cpp @@ -1,5 +1,5 @@ #include "jni.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "SkCamera.h" @@ -137,16 +137,8 @@ static JNINativeMethod gCameraMethods[] = { }; int register_android_graphics_Camera(JNIEnv* env) { - jclass clazz = env->FindClass("android/graphics/Camera"); - if (clazz == 0) { - return -1; - } - gNativeInstanceFieldID = env->GetFieldID(clazz, "native_instance", "J"); - if (gNativeInstanceFieldID == 0) { - return -1; - } - return android::AndroidRuntime::registerNativeMethods(env, - "android/graphics/Camera", - gCameraMethods, - SK_ARRAY_COUNT(gCameraMethods)); + jclass clazz = android::FindClassOrDie(env, "android/graphics/Camera"); + gNativeInstanceFieldID = android::GetFieldIDOrDie(env, clazz, "native_instance", "J"); + return android::RegisterMethodsOrDie(env, "android/graphics/Camera", gCameraMethods, + NELEM(gCameraMethods)); } diff --git a/core/jni/android/graphics/CanvasProperty.cpp b/core/jni/android/graphics/CanvasProperty.cpp index e63c5fa..a69a457 100644 --- a/core/jni/android/graphics/CanvasProperty.cpp +++ b/core/jni/android/graphics/CanvasProperty.cpp @@ -17,16 +17,20 @@ #include "jni.h" #include "GraphicsJNI.h" #include "Paint.h" -#include <android_runtime/AndroidRuntime.h> +#include <core_jni_helpers.h> #include <utils/RefBase.h> #include <CanvasProperty.h> namespace android { -using namespace uirenderer; - #ifdef USE_OPENGL_RENDERER +static const bool kUseOpenGLRenderer = true; +#else +static const bool kUseOpenGLRenderer = false; +#endif + +using namespace uirenderer; static jlong createFloat(JNIEnv* env, jobject clazz, jfloat initialValue) { return reinterpret_cast<jlong>(new CanvasPropertyPrimitive(initialValue)); @@ -37,23 +41,21 @@ static jlong createPaint(JNIEnv* env, jobject clazz, jlong paintPtr) { return reinterpret_cast<jlong>(new CanvasPropertyPaint(*paint)); } -#endif - // ---------------------------------------------------------------------------- // JNI Glue // ---------------------------------------------------------------------------- -const char* const kClassPathName = "android/graphics/CanvasProperty"; - static JNINativeMethod gMethods[] = { -#ifdef USE_OPENGL_RENDERER { "nCreateFloat", "(F)J", (void*) createFloat }, { "nCreatePaint", "(J)J", (void*) createPaint }, -#endif }; int register_android_graphics_CanvasProperty(JNIEnv* env) { - return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); + if (kUseOpenGLRenderer) { + return RegisterMethodsOrDie(env, "android/graphics/CanvasProperty", gMethods, + NELEM(gMethods)); + } + return 0; } }; // namespace android diff --git a/core/jni/android/graphics/ColorFilter.cpp b/core/jni/android/graphics/ColorFilter.cpp index c66c844..026cbee 100644 --- a/core/jni/android/graphics/ColorFilter.cpp +++ b/core/jni/android/graphics/ColorFilter.cpp @@ -17,7 +17,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "SkColorFilter.h" #include "SkColorMatrixFilter.h" @@ -74,18 +74,15 @@ static JNINativeMethod colormatrix_methods[] = { { "nativeColorMatrixFilter", "([F)J", (void*) SkColorFilterGlue::CreateColorMatrixFilter }, }; -#define REG(env, name, array) \ - result = android::AndroidRuntime::registerNativeMethods(env, name, array, \ - SK_ARRAY_COUNT(array)); \ - if (result < 0) return result - int register_android_graphics_ColorFilter(JNIEnv* env) { - int result; - - REG(env, "android/graphics/ColorFilter", colorfilter_methods); - REG(env, "android/graphics/PorterDuffColorFilter", porterduff_methods); - REG(env, "android/graphics/LightingColorFilter", lighting_methods); - REG(env, "android/graphics/ColorMatrixColorFilter", colormatrix_methods); + android::RegisterMethodsOrDie(env, "android/graphics/ColorFilter", colorfilter_methods, + NELEM(colorfilter_methods)); + android::RegisterMethodsOrDie(env, "android/graphics/PorterDuffColorFilter", porterduff_methods, + NELEM(porterduff_methods)); + android::RegisterMethodsOrDie(env, "android/graphics/LightingColorFilter", lighting_methods, + NELEM(lighting_methods)); + android::RegisterMethodsOrDie(env, "android/graphics/ColorMatrixColorFilter", + colormatrix_methods, NELEM(colormatrix_methods)); return 0; } diff --git a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h index ecd270f..56cba51 100644 --- a/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h +++ b/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h @@ -1,5 +1,5 @@ -#ifndef CreateJavaOutputStream_DEFINED -#define CreateJavaOutputStream_DEFINED +#ifndef _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ +#define _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ //#include <android_runtime/AndroidRuntime.h> #include "jni.h" @@ -38,4 +38,5 @@ SkStreamRewindable* CopyJavaInputStream(JNIEnv* env, jobject stream, SkWStream* CreateJavaOutputStreamAdaptor(JNIEnv* env, jobject stream, jbyteArray storage); -#endif + +#endif // _ANDROID_GRAPHICS_CREATE_JAVA_OUTPUT_STREAM_ADAPTOR_H_ diff --git a/core/jni/android/graphics/DrawFilter.cpp b/core/jni/android/graphics/DrawFilter.cpp index 3275875..bac124f 100644 --- a/core/jni/android/graphics/DrawFilter.cpp +++ b/core/jni/android/graphics/DrawFilter.cpp @@ -24,6 +24,8 @@ #include "GraphicsJNI.h" #include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" + #include "SkDrawFilter.h" #include "SkPaintFlagsDrawFilter.h" #include "SkPaint.h" @@ -103,16 +105,11 @@ static JNINativeMethod paintflags_methods[] = { {"nativeConstructor","(II)J", (void*) SkDrawFilterGlue::CreatePaintFlagsDF} }; -#define REG(env, name, array) \ - result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \ - if (result < 0) return result - - int register_android_graphics_DrawFilter(JNIEnv* env) { - int result; - - REG(env, "android/graphics/DrawFilter", drawfilter_methods); - REG(env, "android/graphics/PaintFlagsDrawFilter", paintflags_methods); + int result = RegisterMethodsOrDie(env, "android/graphics/DrawFilter", drawfilter_methods, + NELEM(drawfilter_methods)); + result |= RegisterMethodsOrDie(env, "android/graphics/PaintFlagsDrawFilter", paintflags_methods, + NELEM(paintflags_methods)); return 0; } diff --git a/core/jni/android/graphics/FontFamily.cpp b/core/jni/android/graphics/FontFamily.cpp index bfb30b7..8a85d62 100644 --- a/core/jni/android/graphics/FontFamily.cpp +++ b/core/jni/android/graphics/FontFamily.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "Minikin" #include "JNIHelp.h" -#include <android_runtime/AndroidRuntime.h> +#include <core_jni_helpers.h> #include "SkTypeface.h" #include "GraphicsJNI.h" @@ -125,9 +125,8 @@ static JNINativeMethod gFontFamilyMethods[] = { int register_android_graphics_FontFamily(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, - "android/graphics/FontFamily", - gFontFamilyMethods, NELEM(gFontFamilyMethods)); + return RegisterMethodsOrDie(env, "android/graphics/FontFamily", gFontFamilyMethods, + NELEM(gFontFamilyMethods)); } } diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h index 8ef56cf..45b31c0 100644 --- a/core/jni/android/graphics/GraphicsJNI.h +++ b/core/jni/android/graphics/GraphicsJNI.h @@ -1,5 +1,5 @@ -#ifndef GraphicsJNI_DEFINED -#define GraphicsJNI_DEFINED +#ifndef _ANDROID_GRAPHICS_GRAPHICS_JNI_H_ +#define _ANDROID_GRAPHICS_GRAPHICS_JNI_H_ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -292,4 +292,4 @@ void doThrowIOE(JNIEnv* env, const char* msg = NULL); // IO Exception #define NPE_CHECK_RETURN_VOID(env, object) \ do { if (NULL == (object)) { doThrowNPE(env); return; } } while (0) -#endif +#endif // _ANDROID_GRAPHICS_GRAPHICS_JNI_H_ diff --git a/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp b/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp index a75efcf..ca3a42f 100644 --- a/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp +++ b/core/jni/android/graphics/HarfBuzzNGFaceSkia.cpp @@ -44,6 +44,8 @@ namespace android { +static const bool kDebugGlyphs = false; + // Our implementation of the callbacks which Harfbuzz requires by using Skia // calls. See the Harfbuzz source for references about what these callbacks do. @@ -62,9 +64,9 @@ static void SkiaGetGlyphWidthAndExtents(SkPaint* paint, hb_codepoint_t codepoint uint16_t glyph = codepoint; paint->getTextWidths(&glyph, sizeof(glyph), &skWidth, &skBounds); -#if DEBUG_GLYPHS - ALOGD("returned glyph for %i: width = %f", codepoint, skWidth); -#endif + if (kDebugGlyphs) { + ALOGD("returned glyph for %i: width = %f", codepoint, skWidth); + } if (width) *width = SkScalarToHBFixed(skWidth); if (extents) { diff --git a/core/jni/android/graphics/HarfBuzzNGFaceSkia.h b/core/jni/android/graphics/HarfBuzzNGFaceSkia.h index 7b71ecc..3308d5d 100644 --- a/core/jni/android/graphics/HarfBuzzNGFaceSkia.h +++ b/core/jni/android/graphics/HarfBuzzNGFaceSkia.h @@ -24,8 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HarfBuzzNGFaceSkia_h -#define HarfBuzzNGFaceSkia_h +#ifndef _ANDROID_GRAPHICS_HARF_BUZZ_NG_FACE_SKIA_H_ +#define _ANDROID_GRAPHICS_HARF_BUZZ_NG_FACE_SKIA_H_ #include <SkScalar.h> #include <SkPaint.h> @@ -56,4 +56,4 @@ hb_font_t* createFont(hb_face_t* face, SkPaint* paint, float sizeX, float sizeY) } // namespace android -#endif +#endif // _ANDROID_GRAPHICS_HARF_BUZZ_NG_FACE_SKIA_H_ diff --git a/core/jni/android/graphics/Interpolator.cpp b/core/jni/android/graphics/Interpolator.cpp index 455f867..f7f3511 100644 --- a/core/jni/android/graphics/Interpolator.cpp +++ b/core/jni/android/graphics/Interpolator.cpp @@ -1,5 +1,5 @@ #include "jni.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "GraphicsJNI.h" #include "SkInterpolator.h" @@ -83,8 +83,6 @@ static JNINativeMethod gInterpolatorMethods[] = { int register_android_graphics_Interpolator(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, - "android/graphics/Interpolator", - gInterpolatorMethods, - SK_ARRAY_COUNT(gInterpolatorMethods)); + return android::RegisterMethodsOrDie(env, "android/graphics/Interpolator", + gInterpolatorMethods, NELEM(gInterpolatorMethods)); } diff --git a/core/jni/android/graphics/MaskFilter.cpp b/core/jni/android/graphics/MaskFilter.cpp index b394905..d658643 100644 --- a/core/jni/android/graphics/MaskFilter.cpp +++ b/core/jni/android/graphics/MaskFilter.cpp @@ -4,6 +4,8 @@ #include "SkBlurMaskFilter.h" #include "SkTableMaskFilter.h" +#include "core_jni_helpers.h" + #include <jni.h> static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) { @@ -77,20 +79,16 @@ static JNINativeMethod gTableMaskFilterMethods[] = { { "nativeNewGamma", "(F)J", (void*)SkMaskFilterGlue::createGammaTable } }; -#include <android_runtime/AndroidRuntime.h> - -#define REG(env, name, array) \ - result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \ - if (result < 0) return result - int register_android_graphics_MaskFilter(JNIEnv* env) { - int result; - - REG(env, "android/graphics/MaskFilter", gMaskFilterMethods); - REG(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods); - REG(env, "android/graphics/EmbossMaskFilter", gEmbossMaskFilterMethods); - REG(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods); + android::RegisterMethodsOrDie(env, "android/graphics/MaskFilter", gMaskFilterMethods, + NELEM(gMaskFilterMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/BlurMaskFilter", gBlurMaskFilterMethods, + NELEM(gBlurMaskFilterMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/EmbossMaskFilter", + gEmbossMaskFilterMethods, NELEM(gEmbossMaskFilterMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/TableMaskFilter", gTableMaskFilterMethods, + NELEM(gTableMaskFilterMethods)); return 0; } diff --git a/core/jni/android/graphics/Matrix.cpp b/core/jni/android/graphics/Matrix.cpp index 01ab699..0ff7c78 100644 --- a/core/jni/android/graphics/Matrix.cpp +++ b/core/jni/android/graphics/Matrix.cpp @@ -17,7 +17,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include <core_jni_helpers.h> #include "SkMatrix.h" #include "SkTemplates.h" @@ -354,11 +354,10 @@ static JNINativeMethod methods[] = { static jfieldID sNativeInstanceField; int register_android_graphics_Matrix(JNIEnv* env) { - int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Matrix", methods, - sizeof(methods) / sizeof(methods[0])); + int result = RegisterMethodsOrDie(env, "android/graphics/Matrix", methods, NELEM(methods)); - jclass clazz = env->FindClass("android/graphics/Matrix"); - sNativeInstanceField = env->GetFieldID(clazz, "native_instance", "J"); + jclass clazz = FindClassOrDie(env, "android/graphics/Matrix"); + sNativeInstanceField = GetFieldIDOrDie(env, clazz, "native_instance", "J"); return result; } diff --git a/core/jni/android/graphics/Matrix.h b/core/jni/android/graphics/Matrix.h index 31edf88..11c9e72 100644 --- a/core/jni/android/graphics/Matrix.h +++ b/core/jni/android/graphics/Matrix.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef _ANDROID_GRAPHICS_MATRIX_H -#define _ANDROID_GRAPHICS_MATRIX_H +#ifndef _ANDROID_GRAPHICS_MATRIX_H_ +#define _ANDROID_GRAPHICS_MATRIX_H_ #include "jni.h" #include "SkMatrix.h" @@ -27,4 +27,4 @@ extern SkMatrix* android_graphics_Matrix_getSkMatrix(JNIEnv* env, jobject matrix } // namespace android -#endif // _ANDROID_GRAPHICS_MATRIX_H +#endif // _ANDROID_GRAPHICS_MATRIX_H_ diff --git a/core/jni/android/graphics/MinikinSkia.h b/core/jni/android/graphics/MinikinSkia.h index 255617e..a06428d 100644 --- a/core/jni/android/graphics/MinikinSkia.h +++ b/core/jni/android/graphics/MinikinSkia.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_MINIKIN_SKIA_H -#define ANDROID_MINIKIN_SKIA_H +#ifndef _ANDROID_GRAPHICS_MINIKIN_SKIA_H_ +#define _ANDROID_GRAPHICS_MINIKIN_SKIA_H_ #include <minikin/MinikinFont.h> @@ -54,4 +54,4 @@ private: } // namespace android -#endif // ANDROID_MINIKIN_SKIA_H
\ No newline at end of file +#endif // _ANDROID_GRAPHICS_MINIKIN_SKIA_H_
\ No newline at end of file diff --git a/core/jni/android/graphics/MinikinUtils.h b/core/jni/android/graphics/MinikinUtils.h index 3646c1a..236f1fd 100644 --- a/core/jni/android/graphics/MinikinUtils.h +++ b/core/jni/android/graphics/MinikinUtils.h @@ -21,8 +21,8 @@ // TODO: does this really need to be separate from MinikinSkia? -#ifndef ANDROID_MINIKIN_UTILS_H -#define ANDROID_MINIKIN_UTILS_H +#ifndef _ANDROID_GRAPHICS_MINIKIN_UTILS_H_ +#define _ANDROID_GRAPHICS_MINIKIN_UTILS_H_ #include <minikin/Layout.h> #include "Paint.h" @@ -81,4 +81,4 @@ public: } // namespace android -#endif // ANDROID_MINIKIN_UTILS_H +#endif // _ANDROID_GRAPHICS_MINIKIN_UTILS_H_ diff --git a/core/jni/android/graphics/Movie.cpp b/core/jni/android/graphics/Movie.cpp index 226f83e..b25fa84 100644 --- a/core/jni/android/graphics/Movie.cpp +++ b/core/jni/android/graphics/Movie.cpp @@ -13,11 +13,7 @@ #include <androidfw/ResourceTypes.h> #include <netinet/in.h> -#if 0 - #define TRACE_BITMAP(code) code -#else - #define TRACE_BITMAP(code) -#endif +#include "core_jni_helpers.h" static jclass gMovie_class; static jmethodID gMovie_constructorMethodID; @@ -138,8 +134,6 @@ static void movie_destructor(JNIEnv* env, jobject, jlong movieHandle) { ////////////////////////////////////////////////////////////////////////////////////////////// -#include <android_runtime/AndroidRuntime.h> - static JNINativeMethod gMethods[] = { { "width", "()I", (void*)movie_width }, { "height", "()I", (void*)movie_height }, @@ -157,22 +151,14 @@ static JNINativeMethod gMethods[] = { (void*)movie_decodeByteArray }, }; -#define kClassPathName "android/graphics/Movie" - -#define RETURN_ERR_IF_NULL(value) do { if (!(value)) { assert(0); return -1; } } while (false) - int register_android_graphics_Movie(JNIEnv* env) { - gMovie_class = env->FindClass(kClassPathName); - RETURN_ERR_IF_NULL(gMovie_class); - gMovie_class = (jclass)env->NewGlobalRef(gMovie_class); + gMovie_class = android::FindClassOrDie(env, "android/graphics/Movie"); + gMovie_class = android::MakeGlobalRefOrDie(env, gMovie_class); - gMovie_constructorMethodID = env->GetMethodID(gMovie_class, "<init>", "(J)V"); - RETURN_ERR_IF_NULL(gMovie_constructorMethodID); + gMovie_constructorMethodID = android::GetMethodIDOrDie(env, gMovie_class, "<init>", "(J)V"); - gMovie_nativeInstanceID = env->GetFieldID(gMovie_class, "mNativeMovie", "J"); - RETURN_ERR_IF_NULL(gMovie_nativeInstanceID); + gMovie_nativeInstanceID = android::GetFieldIDOrDie(env, gMovie_class, "mNativeMovie", "J"); - return android::AndroidRuntime::registerNativeMethods(env, kClassPathName, - gMethods, SK_ARRAY_COUNT(gMethods)); + return android::RegisterMethodsOrDie(env, "android/graphics/Movie", gMethods, NELEM(gMethods)); } diff --git a/core/jni/android/graphics/NinePatch.cpp b/core/jni/android/graphics/NinePatch.cpp index be62fdd..d868f28 100644 --- a/core/jni/android/graphics/NinePatch.cpp +++ b/core/jni/android/graphics/NinePatch.cpp @@ -30,6 +30,7 @@ #include "GraphicsJNI.h" #include "JNIHelp.h" +#include "core_jni_helpers.h" extern void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, const SkBitmap& bitmap, const android::Res_png_9patch& chunk, const SkPaint* paint, SkRegion** outRegion); @@ -176,8 +177,6 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// -#include <android_runtime/AndroidRuntime.h> - static JNINativeMethod gNinePatchMethods[] = { { "isNinePatchChunk", "([B)Z", (void*) SkNinePatchGlue::isNinePatchChunk }, { "validateNinePatchChunk", "(J[B)J", (void*) SkNinePatchGlue::validateNinePatchChunk }, @@ -189,6 +188,6 @@ static JNINativeMethod gNinePatchMethods[] = { }; int register_android_graphics_NinePatch(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, - "android/graphics/NinePatch", gNinePatchMethods, SK_ARRAY_COUNT(gNinePatchMethods)); + return android::RegisterMethodsOrDie(env, + "android/graphics/NinePatch", gNinePatchMethods, NELEM(gNinePatchMethods)); } diff --git a/core/jni/android/graphics/NinePatchImpl.cpp b/core/jni/android/graphics/NinePatchImpl.cpp index 39a9554..4c589b7 100644 --- a/core/jni/android/graphics/NinePatchImpl.cpp +++ b/core/jni/android/graphics/NinePatchImpl.cpp @@ -23,20 +23,16 @@ #include "SkBitmap.h" #include "SkCanvas.h" +#include "SkColorPriv.h" #include "SkNinePatch.h" #include "SkPaint.h" #include "SkUnPreMultiply.h" -#define USE_TRACE - -#ifdef USE_TRACE - static bool gTrace; -#endif - -#include "SkColorPriv.h" - #include <utils/Log.h> +static const bool kUseTrace = true; +static bool gTrace = false; + static bool getColor(const SkBitmap& bitmap, int x, int y, SkColor* c) { switch (bitmap.colorType()) { case kN32_SkColorType: @@ -128,37 +124,34 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, return; } -#ifdef USE_TRACE - gTrace = true; -#endif + if (kUseTrace) { + gTrace = true; + } SkASSERT(canvas || outRegion); -#ifdef USE_TRACE - if (canvas) { - const SkMatrix& m = canvas->getTotalMatrix(); - ALOGV("ninepatch [%g %g %g] [%g %g %g]\n", - SkScalarToFloat(m[0]), SkScalarToFloat(m[1]), SkScalarToFloat(m[2]), - SkScalarToFloat(m[3]), SkScalarToFloat(m[4]), SkScalarToFloat(m[5])); - } -#endif + if (kUseTrace) { + if (canvas) { + const SkMatrix& m = canvas->getTotalMatrix(); + ALOGV("ninepatch [%g %g %g] [%g %g %g]\n", + SkScalarToFloat(m[0]), SkScalarToFloat(m[1]), SkScalarToFloat(m[2]), + SkScalarToFloat(m[3]), SkScalarToFloat(m[4]), SkScalarToFloat(m[5])); + } -#ifdef USE_TRACE - if (gTrace) { - ALOGV("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height())); + ALOGV("======== ninepatch bounds [%g %g]\n", SkScalarToFloat(bounds.width()), + SkScalarToFloat(bounds.height())); ALOGV("======== ninepatch paint bm [%d,%d]\n", bitmap.width(), bitmap.height()); ALOGV("======== ninepatch xDivs [%d,%d]\n", xDivs[0], xDivs[1]); ALOGV("======== ninepatch yDivs [%d,%d]\n", yDivs[0], yDivs[1]); } -#endif if (bounds.isEmpty() || bitmap.width() == 0 || bitmap.height() == 0 || (paint && paint->getXfermode() == NULL && paint->getAlpha() == 0)) { -#ifdef USE_TRACE - if (gTrace) ALOGV("======== abort ninepatch draw\n"); -#endif + if (kUseTrace) { + ALOGV("======== abort ninepatch draw\n"); + } return; } @@ -202,13 +195,13 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, } int numFixedYPixelsRemaining = bitmapHeight - numStretchyYPixelsRemaining; -#ifdef USE_TRACE - ALOGV("NinePatch [%d %d] bounds [%g %g %g %g] divs [%d %d]\n", - bitmap.width(), bitmap.height(), - SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop), - SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()), - numXDivs, numYDivs); -#endif + if (kUseTrace) { + ALOGV("NinePatch [%d %d] bounds [%g %g %g %g] divs [%d %d]\n", + bitmap.width(), bitmap.height(), + SkScalarToFloat(bounds.fLeft), SkScalarToFloat(bounds.fTop), + SkScalarToFloat(bounds.width()), SkScalarToFloat(bounds.height()), + numXDivs, numYDivs); + } src.fTop = 0; dst.fTop = bounds.fTop; @@ -307,15 +300,15 @@ void NinePatch_Draw(SkCanvas* canvas, const SkRect& bounds, goto nextDiv; } if (canvas) { -#ifdef USE_TRACE - ALOGV("-- src [%d %d %d %d] dst [%g %g %g %g]\n", - src.fLeft, src.fTop, src.width(), src.height(), - SkScalarToFloat(dst.fLeft), SkScalarToFloat(dst.fTop), - SkScalarToFloat(dst.width()), SkScalarToFloat(dst.height())); - if (2 == src.width() && SkIntToScalar(5) == dst.width()) { - ALOGV("--- skip patch\n"); + if (kUseTrace) { + ALOGV("-- src [%d %d %d %d] dst [%g %g %g %g]\n", + src.fLeft, src.fTop, src.width(), src.height(), + SkScalarToFloat(dst.fLeft), SkScalarToFloat(dst.fTop), + SkScalarToFloat(dst.width()), SkScalarToFloat(dst.height())); + if (2 == src.width() && SkIntToScalar(5) == dst.width()) { + ALOGV("--- skip patch\n"); + } } -#endif drawStretchyPatch(canvas, src, dst, bitmap, *paint, initColor, color, hasXfer); } diff --git a/core/jni/android/graphics/NinePatchPeeker.h b/core/jni/android/graphics/NinePatchPeeker.h index 7c18b2d..2d49b38 100644 --- a/core/jni/android/graphics/NinePatchPeeker.h +++ b/core/jni/android/graphics/NinePatchPeeker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef NinePatchPeeker_h -#define NinePatchPeeker_h +#ifndef _ANDROID_GRAPHICS_NINE_PATCH_PEEKER_H_ +#define _ANDROID_GRAPHICS_NINE_PATCH_PEEKER_H_ #include "SkImageDecoder.h" #include <androidfw/ResourceTypes.h> @@ -53,4 +53,4 @@ public: uint8_t mOutlineAlpha; }; -#endif // NinePatchPeeker_h +#endif // _ANDROID_GRAPHICS_NINE_PATCH_PEEKER_H_ diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index 6b02326..2cd2db7 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -21,7 +21,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include <ScopedUtfChars.h> #include "SkBlurDrawLooper.h" @@ -1021,35 +1021,26 @@ static JNINativeMethod methods[] = { {"native_hasShadowLayer", "!(J)Z", (void*)PaintGlue::hasShadowLayer} }; -static jfieldID req_fieldID(jfieldID id) { - SkASSERT(id); - return id; -} - int register_android_graphics_Paint(JNIEnv* env) { - gFontMetrics_class = env->FindClass("android/graphics/Paint$FontMetrics"); - SkASSERT(gFontMetrics_class); - gFontMetrics_class = (jclass)env->NewGlobalRef(gFontMetrics_class); - - gFontMetrics_fieldID.top = req_fieldID(env->GetFieldID(gFontMetrics_class, "top", "F")); - gFontMetrics_fieldID.ascent = req_fieldID(env->GetFieldID(gFontMetrics_class, "ascent", "F")); - gFontMetrics_fieldID.descent = req_fieldID(env->GetFieldID(gFontMetrics_class, "descent", "F")); - gFontMetrics_fieldID.bottom = req_fieldID(env->GetFieldID(gFontMetrics_class, "bottom", "F")); - gFontMetrics_fieldID.leading = req_fieldID(env->GetFieldID(gFontMetrics_class, "leading", "F")); - - gFontMetricsInt_class = env->FindClass("android/graphics/Paint$FontMetricsInt"); - SkASSERT(gFontMetricsInt_class); - gFontMetricsInt_class = (jclass)env->NewGlobalRef(gFontMetricsInt_class); - - gFontMetricsInt_fieldID.top = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "top", "I")); - gFontMetricsInt_fieldID.ascent = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "ascent", "I")); - gFontMetricsInt_fieldID.descent = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "descent", "I")); - gFontMetricsInt_fieldID.bottom = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "bottom", "I")); - gFontMetricsInt_fieldID.leading = req_fieldID(env->GetFieldID(gFontMetricsInt_class, "leading", "I")); - - int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Paint", methods, - sizeof(methods) / sizeof(methods[0])); - return result; + gFontMetrics_class = FindClassOrDie(env, "android/graphics/Paint$FontMetrics"); + gFontMetrics_class = MakeGlobalRefOrDie(env, gFontMetrics_class); + + gFontMetrics_fieldID.top = GetFieldIDOrDie(env, gFontMetrics_class, "top", "F"); + gFontMetrics_fieldID.ascent = GetFieldIDOrDie(env, gFontMetrics_class, "ascent", "F"); + gFontMetrics_fieldID.descent = GetFieldIDOrDie(env, gFontMetrics_class, "descent", "F"); + gFontMetrics_fieldID.bottom = GetFieldIDOrDie(env, gFontMetrics_class, "bottom", "F"); + gFontMetrics_fieldID.leading = GetFieldIDOrDie(env, gFontMetrics_class, "leading", "F"); + + gFontMetricsInt_class = FindClassOrDie(env, "android/graphics/Paint$FontMetricsInt"); + gFontMetricsInt_class = MakeGlobalRefOrDie(env, gFontMetricsInt_class); + + gFontMetricsInt_fieldID.top = GetFieldIDOrDie(env, gFontMetricsInt_class, "top", "I"); + gFontMetricsInt_fieldID.ascent = GetFieldIDOrDie(env, gFontMetricsInt_class, "ascent", "I"); + gFontMetricsInt_fieldID.descent = GetFieldIDOrDie(env, gFontMetricsInt_class, "descent", "I"); + gFontMetricsInt_fieldID.bottom = GetFieldIDOrDie(env, gFontMetricsInt_class, "bottom", "I"); + gFontMetricsInt_fieldID.leading = GetFieldIDOrDie(env, gFontMetricsInt_class, "leading", "I"); + + return RegisterMethodsOrDie(env, "android/graphics/Paint", methods, NELEM(methods)); } } diff --git a/core/jni/android/graphics/Paint.h b/core/jni/android/graphics/Paint.h index a20bb4b..fa539f5 100644 --- a/core/jni/android/graphics/Paint.h +++ b/core/jni/android/graphics/Paint.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_GRAPHICS_PAINT_H -#define ANDROID_GRAPHICS_PAINT_H +#ifndef ANDROID_GRAPHICS_PAINT_H_ +#define ANDROID_GRAPHICS_PAINT_H_ #include <SkPaint.h> #include <string> @@ -78,4 +78,4 @@ private: } // namespace android -#endif // ANDROID_GRAPHICS_PAINT_H +#endif // ANDROID_GRAPHICS_PAINT_H_ diff --git a/core/jni/android/graphics/Path.cpp b/core/jni/android/graphics/Path.cpp index 30ce58d..1e4eb75 100644 --- a/core/jni/android/graphics/Path.cpp +++ b/core/jni/android/graphics/Path.cpp @@ -22,7 +22,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "SkPath.h" #include "SkPathOps.h" @@ -520,9 +520,7 @@ static JNINativeMethod methods[] = { }; int register_android_graphics_Path(JNIEnv* env) { - int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Path", methods, - sizeof(methods) / sizeof(methods[0])); - return result; + return RegisterMethodsOrDie(env, "android/graphics/Path", methods, NELEM(methods)); } } diff --git a/core/jni/android/graphics/PathEffect.cpp b/core/jni/android/graphics/PathEffect.cpp index 28d881d..9d0f0ad 100644 --- a/core/jni/android/graphics/PathEffect.cpp +++ b/core/jni/android/graphics/PathEffect.cpp @@ -1,6 +1,8 @@ #include <jni.h> #include "GraphicsJNI.h" +#include "core_jni_helpers.h" + #include "SkPathEffect.h" #include "SkCornerPathEffect.h" #include "SkDashPathEffect.h" @@ -97,24 +99,22 @@ static JNINativeMethod gDiscretePathEffectMethods[] = { { "nativeCreate", "(FF)J", (void*)SkPathEffectGlue::Discrete_constructor } }; -#include <android_runtime/AndroidRuntime.h> - -#define REG(env, name, array) \ - result = android::AndroidRuntime::registerNativeMethods(env, name, array, \ - SK_ARRAY_COUNT(array)); \ - if (result < 0) return result - int register_android_graphics_PathEffect(JNIEnv* env) { - int result; - - REG(env, "android/graphics/PathEffect", gPathEffectMethods); - REG(env, "android/graphics/ComposePathEffect", gComposePathEffectMethods); - REG(env, "android/graphics/SumPathEffect", gSumPathEffectMethods); - REG(env, "android/graphics/DashPathEffect", gDashPathEffectMethods); - REG(env, "android/graphics/PathDashPathEffect", gPathDashPathEffectMethods); - REG(env, "android/graphics/CornerPathEffect", gCornerPathEffectMethods); - REG(env, "android/graphics/DiscretePathEffect", gDiscretePathEffectMethods); + android::RegisterMethodsOrDie(env, "android/graphics/PathEffect", gPathEffectMethods, + NELEM(gPathEffectMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/ComposePathEffect", + gComposePathEffectMethods, NELEM(gComposePathEffectMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/SumPathEffect", gSumPathEffectMethods, + NELEM(gSumPathEffectMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/DashPathEffect", gDashPathEffectMethods, + NELEM(gDashPathEffectMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/PathDashPathEffect", + gPathDashPathEffectMethods, NELEM(gPathDashPathEffectMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/CornerPathEffect", + gCornerPathEffectMethods, NELEM(gCornerPathEffectMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/DiscretePathEffect", + gDiscretePathEffectMethods, NELEM(gDiscretePathEffectMethods)); return 0; } diff --git a/core/jni/android/graphics/PathMeasure.cpp b/core/jni/android/graphics/PathMeasure.cpp index 13f68a9..fec5d9d 100644 --- a/core/jni/android/graphics/PathMeasure.cpp +++ b/core/jni/android/graphics/PathMeasure.cpp @@ -17,7 +17,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include <core_jni_helpers.h> #include "SkPathMeasure.h" @@ -156,9 +156,7 @@ static JNINativeMethod methods[] = { }; int register_android_graphics_PathMeasure(JNIEnv* env) { - int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/PathMeasure", methods, - sizeof(methods) / sizeof(methods[0])); - return result; + return RegisterMethodsOrDie(env, "android/graphics/PathMeasure", methods, NELEM(methods)); } } diff --git a/core/jni/android/graphics/Picture.h b/core/jni/android/graphics/Picture.h index a2e5d4a..4db923d 100644 --- a/core/jni/android/graphics/Picture.h +++ b/core/jni/android/graphics/Picture.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_GRAPHICS_PICTURE_H -#define ANDROID_GRAPHICS_PICTURE_H +#ifndef ANDROID_GRAPHICS_PICTURE_H_ +#define ANDROID_GRAPHICS_PICTURE_H_ #include "SkPicture.h" #include "SkPictureRecorder.h" @@ -63,4 +63,4 @@ private: }; }; // namespace android -#endif // ANDROID_GRAPHICS_PICTURE_H +#endif // ANDROID_GRAPHICS_PICTURE_H_ diff --git a/core/jni/android/graphics/PorterDuff.cpp b/core/jni/android/graphics/PorterDuff.cpp index 8a49eb5..73b1691 100644 --- a/core/jni/android/graphics/PorterDuff.cpp +++ b/core/jni/android/graphics/PorterDuff.cpp @@ -22,7 +22,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "SkPorterDuff.h" @@ -43,10 +43,7 @@ static JNINativeMethod methods[] = { }; int register_android_graphics_PorterDuff(JNIEnv* env) { - int result = AndroidRuntime::registerNativeMethods(env, - "android/graphics/PorterDuffXfermode", methods, - sizeof(methods) / sizeof(methods[0])); - return result; + return RegisterMethodsOrDie(env, "android/graphics/PorterDuffXfermode", methods, NELEM(methods)); } } diff --git a/core/jni/android/graphics/Rasterizer.cpp b/core/jni/android/graphics/Rasterizer.cpp index 2b1aca1..cfc23ac8 100644 --- a/core/jni/android/graphics/Rasterizer.cpp +++ b/core/jni/android/graphics/Rasterizer.cpp @@ -24,7 +24,7 @@ #include "GraphicsJNI.h" #include "Paint.h" #include "SkLayerRasterizer.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" // Rasterizer.java holds a pointer (jlong) to this guy class NativeRasterizer { @@ -59,7 +59,6 @@ public: static void finalizer(JNIEnv* env, jobject clazz, jlong objHandle) { delete reinterpret_cast<NativeRasterizer *>(objHandle); } - }; static JNINativeMethod gRasterizerMethods[] = { @@ -67,9 +66,8 @@ static JNINativeMethod gRasterizerMethods[] = { }; int register_android_graphics_Rasterizer(JNIEnv* env) { - int result = AndroidRuntime::registerNativeMethods(env, "android/graphics/Rasterizer", gRasterizerMethods, - sizeof(gRasterizerMethods) / sizeof(gRasterizerMethods[0])); - return result; + return RegisterMethodsOrDie(env, "android/graphics/Rasterizer", gRasterizerMethods, + NELEM(gRasterizerMethods)); } class SkLayerRasterizerGlue { @@ -94,10 +92,8 @@ static JNINativeMethod gLayerRasterizerMethods[] = { int register_android_graphics_LayerRasterizer(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, - "android/graphics/LayerRasterizer", - gLayerRasterizerMethods, - SK_ARRAY_COUNT(gLayerRasterizerMethods)); + return RegisterMethodsOrDie(env, "android/graphics/LayerRasterizer", + gLayerRasterizerMethods, NELEM(gLayerRasterizerMethods)); } } diff --git a/core/jni/android/graphics/Region.cpp b/core/jni/android/graphics/Region.cpp index 912968a..90a020e 100644 --- a/core/jni/android/graphics/Region.cpp +++ b/core/jni/android/graphics/Region.cpp @@ -23,7 +23,7 @@ #include "android_util_Binder.h" #include <jni.h> -#include <android_runtime/AndroidRuntime.h> +#include <core_jni_helpers.h> namespace android { @@ -325,19 +325,13 @@ static JNINativeMethod gRegionMethods[] = { int register_android_graphics_Region(JNIEnv* env) { - jclass clazz = env->FindClass("android/graphics/Region"); - SkASSERT(clazz); + jclass clazz = FindClassOrDie(env, "android/graphics/Region"); - gRegion_nativeInstanceFieldID = env->GetFieldID(clazz, "mNativeRegion", "J"); - SkASSERT(gRegion_nativeInstanceFieldID); + gRegion_nativeInstanceFieldID = GetFieldIDOrDie(env, clazz, "mNativeRegion", "J"); - int result = android::AndroidRuntime::registerNativeMethods(env, "android/graphics/Region", - gRegionMethods, SK_ARRAY_COUNT(gRegionMethods)); - if (result < 0) - return result; - - return android::AndroidRuntime::registerNativeMethods(env, "android/graphics/RegionIterator", - gRegionIterMethods, SK_ARRAY_COUNT(gRegionIterMethods)); + RegisterMethodsOrDie(env, "android/graphics/Region", gRegionMethods, NELEM(gRegionMethods)); + return RegisterMethodsOrDie(env, "android/graphics/RegionIterator", gRegionIterMethods, + NELEM(gRegionIterMethods)); } SkRegion* android_graphics_Region_getSkRegion(JNIEnv* env, jobject regionObj) { diff --git a/core/jni/android/graphics/Region.h b/core/jni/android/graphics/Region.h index c15f06e..2e8e109 100644 --- a/core/jni/android/graphics/Region.h +++ b/core/jni/android/graphics/Region.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef _ANDROID_GRAPHICS_REGION_H -#define _ANDROID_GRAPHICS_REGION_H +#ifndef _ANDROID_GRAPHICS_REGION_H_ +#define _ANDROID_GRAPHICS_REGION_H_ #include "jni.h" #include "SkRegion.h" @@ -27,4 +27,4 @@ extern SkRegion* android_graphics_Region_getSkRegion(JNIEnv* env, jobject region } // namespace android -#endif // _ANDROID_GRAPHICS_REGION_H +#endif // _ANDROID_GRAPHICS_REGION_H_ diff --git a/core/jni/android/graphics/RtlProperties.h b/core/jni/android/graphics/RtlProperties.h index d43745f..907dd59 100644 --- a/core/jni/android/graphics/RtlProperties.h +++ b/core/jni/android/graphics/RtlProperties.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_RTL_PROPERTIES_H -#define ANDROID_RTL_PROPERTIES_H +#ifndef _ANDROID_GRAPHICS_RTL_PROPERTIES_H_ +#define _ANDROID_GRAPHICS_RTL_PROPERTIES_H_ #include <cutils/properties.h> #include <stdlib.h> @@ -45,11 +45,5 @@ static RtlDebugLevel readRtlDebugLevel() { return kRtlDebugDisabled; } -// Define if we want (1) to have Advances debug values or not (0) -#define DEBUG_ADVANCES 0 - -// Define if we want (1) to have Glyphs debug values or not (0) -#define DEBUG_GLYPHS 0 - } // namespace android -#endif // ANDROID_RTL_PROPERTIES_H +#endif // _ANDROID_GRAPHICS_RTL_PROPERTIES_H_ diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp index 70a2fe5..9ec9c58 100644 --- a/core/jni/android/graphics/Shader.cpp +++ b/core/jni/android/graphics/Shader.cpp @@ -11,6 +11,8 @@ #include <SkiaShader.h> #include <Caches.h> +#include "core_jni_helpers.h" + using namespace android::uirenderer; static void ThrowIAE_IfNull(JNIEnv* env, void* ptr) { @@ -260,23 +262,22 @@ static JNINativeMethod gComposeShaderMethods[] = { { "nativeCreate2", "(JJI)J", (void*)ComposeShader_create2 }, }; -#include <android_runtime/AndroidRuntime.h> - -#define REG(env, name, array) \ - result = android::AndroidRuntime::registerNativeMethods(env, name, array, SK_ARRAY_COUNT(array)); \ - if (result < 0) return result - int register_android_graphics_Shader(JNIEnv* env) { - int result; - - REG(env, "android/graphics/Color", gColorMethods); - REG(env, "android/graphics/Shader", gShaderMethods); - REG(env, "android/graphics/BitmapShader", gBitmapShaderMethods); - REG(env, "android/graphics/LinearGradient", gLinearGradientMethods); - REG(env, "android/graphics/RadialGradient", gRadialGradientMethods); - REG(env, "android/graphics/SweepGradient", gSweepGradientMethods); - REG(env, "android/graphics/ComposeShader", gComposeShaderMethods); - - return result; + android::RegisterMethodsOrDie(env, "android/graphics/Color", gColorMethods, + NELEM(gColorMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/Shader", gShaderMethods, + NELEM(gShaderMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/BitmapShader", gBitmapShaderMethods, + NELEM(gBitmapShaderMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/LinearGradient", gLinearGradientMethods, + NELEM(gLinearGradientMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/RadialGradient", gRadialGradientMethods, + NELEM(gRadialGradientMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/SweepGradient", gSweepGradientMethods, + NELEM(gSweepGradientMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/ComposeShader", gComposeShaderMethods, + NELEM(gComposeShaderMethods)); + + return 0; } diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp index eaca6d2..35d69fe 100644 --- a/core/jni/android/graphics/SurfaceTexture.cpp +++ b/core/jni/android/graphics/SurfaceTexture.cpp @@ -24,7 +24,7 @@ #include <gui/GLConsumer.h> #include <gui/Surface.h> -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include <utils/Log.h> #include <utils/misc.h> @@ -359,10 +359,8 @@ static JNINativeMethod gSurfaceTextureMethods[] = { int register_android_graphics_SurfaceTexture(JNIEnv* env) { - int err = 0; - err = AndroidRuntime::registerNativeMethods(env, kSurfaceTextureClassPathName, - gSurfaceTextureMethods, NELEM(gSurfaceTextureMethods)); - return err; + return RegisterMethodsOrDie(env, kSurfaceTextureClassPathName, gSurfaceTextureMethods, + NELEM(gSurfaceTextureMethods)); } } // namespace android diff --git a/core/jni/android/graphics/Typeface.cpp b/core/jni/android/graphics/Typeface.cpp index 2029658..808ae2c 100644 --- a/core/jni/android/graphics/Typeface.cpp +++ b/core/jni/android/graphics/Typeface.cpp @@ -15,7 +15,7 @@ */ #include "jni.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "GraphicsJNI.h" #include <ScopedPrimitiveArray.h> @@ -81,8 +81,6 @@ static JNINativeMethod gTypefaceMethods[] = { int register_android_graphics_Typeface(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, - "android/graphics/Typeface", - gTypefaceMethods, - SK_ARRAY_COUNT(gTypefaceMethods)); + return RegisterMethodsOrDie(env, "android/graphics/Typeface", gTypefaceMethods, + NELEM(gTypefaceMethods)); } diff --git a/core/jni/android/graphics/TypefaceImpl.h b/core/jni/android/graphics/TypefaceImpl.h index d129f62..d36f83a 100644 --- a/core/jni/android/graphics/TypefaceImpl.h +++ b/core/jni/android/graphics/TypefaceImpl.h @@ -15,8 +15,8 @@ */ -#ifndef ANDROID_TYPEFACE_IMPL_H -#define ANDROID_TYPEFACE_IMPL_H +#ifndef _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_ +#define _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_ #include "jni.h" // for jlong, eventually remove #include "SkTypeface.h" @@ -62,4 +62,4 @@ void TypefaceImpl_setDefault(TypefaceImpl* face); } -#endif // ANDROID_TYPEFACE_IMPL_H
\ No newline at end of file +#endif // _ANDROID_GRAPHICS_TYPEFACE_IMPL_H_
\ No newline at end of file diff --git a/core/jni/android/graphics/Utils.h b/core/jni/android/graphics/Utils.h index b90593c..bde87f0 100644 --- a/core/jni/android/graphics/Utils.h +++ b/core/jni/android/graphics/Utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef UTILS_DEFINED -#define UTILS_DEFINED +#ifndef _ANDROID_GRAPHICS_UTILS_H_ +#define _ANDROID_GRAPHICS_UTILS_H_ #include "SkStream.h" @@ -89,4 +89,4 @@ jobject nullObjectReturn(const char msg[]); }; // namespace android -#endif +#endif // _ANDROID_GRAPHICS_UTILS_H_ diff --git a/core/jni/android/graphics/Xfermode.cpp b/core/jni/android/graphics/Xfermode.cpp index 6bf6f8a..5a3883a 100644 --- a/core/jni/android/graphics/Xfermode.cpp +++ b/core/jni/android/graphics/Xfermode.cpp @@ -16,7 +16,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include "SkAvoidXfermode.h" #include "SkPixelXorXfermode.h" @@ -59,19 +59,15 @@ static JNINativeMethod gPixelXorMethods[] = { {"nativeCreate", "(I)J", (void*) SkXfermodeGlue::pixelxor_create} }; -#include <android_runtime/AndroidRuntime.h> - -#define REG(env, name, array) \ - result = android::AndroidRuntime::registerNativeMethods(env, name, array, \ - SK_ARRAY_COUNT(array)); \ - if (result < 0) return result - int register_android_graphics_Xfermode(JNIEnv* env) { - int result; - - REG(env, "android/graphics/Xfermode", gXfermodeMethods); - REG(env, "android/graphics/AvoidXfermode", gAvoidMethods); - REG(env, "android/graphics/PixelXorXfermode", gPixelXorMethods); + android::RegisterMethodsOrDie(env, "android/graphics/Xfermode", gXfermodeMethods, + NELEM(gXfermodeMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/Xfermode", gXfermodeMethods, + NELEM(gXfermodeMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/AvoidXfermode", gAvoidMethods, + NELEM(gAvoidMethods)); + android::RegisterMethodsOrDie(env, "android/graphics/PixelXorXfermode", gPixelXorMethods, + NELEM(gPixelXorMethods)); return 0; } diff --git a/core/jni/android/graphics/YuvToJpegEncoder.cpp b/core/jni/android/graphics/YuvToJpegEncoder.cpp index 9b2e4b5..5eede2a 100644 --- a/core/jni/android/graphics/YuvToJpegEncoder.cpp +++ b/core/jni/android/graphics/YuvToJpegEncoder.cpp @@ -4,6 +4,8 @@ #include <ui/PixelFormat.h> #include <hardware/hardware.h> +#include "core_jni_helpers.h" + #include <jni.h> YuvToJpegEncoder* YuvToJpegEncoder::create(int format, int* strides) { @@ -241,17 +243,13 @@ static jboolean YuvImage_compressToJpeg(JNIEnv* env, jobject, jbyteArray inYuv, } /////////////////////////////////////////////////////////////////////////////// -#include <android_runtime/AndroidRuntime.h> - static JNINativeMethod gYuvImageMethods[] = { { "nativeCompressToJpeg", "([BIII[I[IILjava/io/OutputStream;[B)Z", (void*)YuvImage_compressToJpeg } }; -#define kClassPathName "android/graphics/YuvImage" - int register_android_graphics_YuvImage(JNIEnv* env) { - return android::AndroidRuntime::registerNativeMethods(env, kClassPathName, - gYuvImageMethods, SK_ARRAY_COUNT(gYuvImageMethods)); + return android::RegisterMethodsOrDie(env, "android/graphics/YuvImage", gYuvImageMethods, + NELEM(gYuvImageMethods)); } diff --git a/core/jni/android/graphics/YuvToJpegEncoder.h b/core/jni/android/graphics/YuvToJpegEncoder.h index 0d418ed..1ea844a 100644 --- a/core/jni/android/graphics/YuvToJpegEncoder.h +++ b/core/jni/android/graphics/YuvToJpegEncoder.h @@ -1,5 +1,5 @@ -#ifndef YuvToJpegEncoder_DEFINED -#define YuvToJpegEncoder_DEFINED +#ifndef _ANDROID_GRAPHICS_YUV_TO_JPEG_ENCODER_H_ +#define _ANDROID_GRAPHICS_YUV_TO_JPEG_ENCODER_H_ #include "SkTypes.h" #include "SkStream.h" @@ -47,16 +47,16 @@ protected: class Yuv420SpToJpegEncoder : public YuvToJpegEncoder { public: - Yuv420SpToJpegEncoder(int* strides); - virtual ~Yuv420SpToJpegEncoder() {} + Yuv420SpToJpegEncoder(int* strides); + virtual ~Yuv420SpToJpegEncoder() {} private: - void configSamplingFactors(jpeg_compress_struct* cinfo); - void deinterleaveYuv(uint8_t* yuv, int width, int height, + void configSamplingFactors(jpeg_compress_struct* cinfo); + void deinterleaveYuv(uint8_t* yuv, int width, int height, uint8_t*& yPlanar, uint8_t*& uPlanar, uint8_t*& vPlanar); - void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, - int rowIndex, int width, int height); - void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets); + void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, + int rowIndex, int width, int height); + void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets); }; class Yuv422IToJpegEncoder : public YuvToJpegEncoder { @@ -71,4 +71,4 @@ private: uint8_t* vRows, int rowIndex, int width, int height); }; -#endif +#endif // _ANDROID_GRAPHICS_YUV_TO_JPEG_ENCODER_H_ diff --git a/core/jni/android/graphics/pdf/PdfDocument.cpp b/core/jni/android/graphics/pdf/PdfDocument.cpp index 9436a47..be90612 100644 --- a/core/jni/android/graphics/pdf/PdfDocument.cpp +++ b/core/jni/android/graphics/pdf/PdfDocument.cpp @@ -16,7 +16,7 @@ #include "jni.h" #include "GraphicsJNI.h" -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include <vector> #include "Canvas.h" @@ -164,10 +164,9 @@ static JNINativeMethod gPdfDocument_Methods[] = { }; int register_android_graphics_pdf_PdfDocument(JNIEnv* env) { - int result = android::AndroidRuntime::registerNativeMethods( + return RegisterMethodsOrDie( env, "android/graphics/pdf/PdfDocument", gPdfDocument_Methods, NELEM(gPdfDocument_Methods)); - return result; } }; diff --git a/core/jni/android/graphics/pdf/PdfEditor.cpp b/core/jni/android/graphics/pdf/PdfEditor.cpp index 17090b7..cb228f2 100644 --- a/core/jni/android/graphics/pdf/PdfEditor.cpp +++ b/core/jni/android/graphics/pdf/PdfEditor.cpp @@ -28,7 +28,7 @@ #include "SkMatrix.h" -#include <android_runtime/AndroidRuntime.h> +#include <core_jni_helpers.h> #include <vector> #include <utils/Log.h> #include <unistd.h> @@ -355,19 +355,19 @@ static JNINativeMethod gPdfEditor_Methods[] = { }; int register_android_graphics_pdf_PdfEditor(JNIEnv* env) { - const int result = android::AndroidRuntime::registerNativeMethods( + const int result = RegisterMethodsOrDie( env, "android/graphics/pdf/PdfEditor", gPdfEditor_Methods, NELEM(gPdfEditor_Methods)); - jclass pointClass = env->FindClass("android/graphics/Point"); - gPointClassInfo.x = env->GetFieldID(pointClass, "x", "I"); - gPointClassInfo.y = env->GetFieldID(pointClass, "y", "I"); + jclass pointClass = FindClassOrDie(env, "android/graphics/Point"); + gPointClassInfo.x = GetFieldIDOrDie(env, pointClass, "x", "I"); + gPointClassInfo.y = GetFieldIDOrDie(env, pointClass, "y", "I"); - jclass rectClass = env->FindClass("android/graphics/Rect"); - gRectClassInfo.left = env->GetFieldID(rectClass, "left", "I"); - gRectClassInfo.top = env->GetFieldID(rectClass, "top", "I"); - gRectClassInfo.right = env->GetFieldID(rectClass, "right", "I"); - gRectClassInfo.bottom = env->GetFieldID(rectClass, "bottom", "I"); + jclass rectClass = FindClassOrDie(env, "android/graphics/Rect"); + gRectClassInfo.left = GetFieldIDOrDie(env, rectClass, "left", "I"); + gRectClassInfo.top = GetFieldIDOrDie(env, rectClass, "top", "I"); + gRectClassInfo.right = GetFieldIDOrDie(env, rectClass, "right", "I"); + gRectClassInfo.bottom = GetFieldIDOrDie(env, rectClass, "bottom", "I"); return result; }; diff --git a/core/jni/android/graphics/pdf/PdfRenderer.cpp b/core/jni/android/graphics/pdf/PdfRenderer.cpp index 3319578..ae23cb4 100644 --- a/core/jni/android/graphics/pdf/PdfRenderer.cpp +++ b/core/jni/android/graphics/pdf/PdfRenderer.cpp @@ -26,7 +26,7 @@ #include "fsdk_rendercontext.h" #pragma GCC diagnostic pop -#include <android_runtime/AndroidRuntime.h> +#include "core_jni_helpers.h" #include <vector> #include <utils/Log.h> #include <unistd.h> @@ -282,13 +282,13 @@ static JNINativeMethod gPdfRenderer_Methods[] = { }; int register_android_graphics_pdf_PdfRenderer(JNIEnv* env) { - int result = android::AndroidRuntime::registerNativeMethods( + int result = RegisterMethodsOrDie( env, "android/graphics/pdf/PdfRenderer", gPdfRenderer_Methods, NELEM(gPdfRenderer_Methods)); - jclass clazz = env->FindClass("android/graphics/Point"); - gPointClassInfo.x = env->GetFieldID(clazz, "x", "I"); - gPointClassInfo.y = env->GetFieldID(clazz, "y", "I"); + jclass clazz = FindClassOrDie(env, "android/graphics/Point"); + gPointClassInfo.x = GetFieldIDOrDie(env, clazz, "x", "I"); + gPointClassInfo.y = GetFieldIDOrDie(env, clazz, "y", "I"); return result; }; diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp index f60a154..da30044 100644 --- a/core/jni/android/opengl/util.cpp +++ b/core/jni/android/opengl/util.cpp @@ -29,7 +29,7 @@ #include <SkBitmap.h> -#include "android_runtime/AndroidRuntime.h" +#include "core_jni_helpers.h" #undef LOG_TAG #define LOG_TAG "OpenGLUtil" @@ -732,24 +732,22 @@ static jfieldID elementSizeShiftID; /* Cache method IDs each time the class is loaded. */ static void -nativeClassInitBuffer(JNIEnv *_env) +nativeClassInitBuffer(JNIEnv *env) { - jclass nioAccessClassLocal = _env->FindClass("java/nio/NIOAccess"); - nioAccessClass = (jclass) _env->NewGlobalRef(nioAccessClassLocal); - - jclass bufferClassLocal = _env->FindClass("java/nio/Buffer"); - bufferClass = (jclass) _env->NewGlobalRef(bufferClassLocal); - - getBasePointerID = _env->GetStaticMethodID(nioAccessClass, + jclass nioAccessClassLocal = FindClassOrDie(env, "java/nio/NIOAccess"); + nioAccessClass = MakeGlobalRefOrDie(env, nioAccessClassLocal); + getBasePointerID = GetStaticMethodIDOrDie(env, nioAccessClass, "getBasePointer", "(Ljava/nio/Buffer;)J"); - getBaseArrayID = _env->GetStaticMethodID(nioAccessClass, + getBaseArrayID = GetStaticMethodIDOrDie(env, nioAccessClass, "getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;"); - getBaseArrayOffsetID = _env->GetStaticMethodID(nioAccessClass, + getBaseArrayOffsetID = GetStaticMethodIDOrDie(env, nioAccessClass, "getBaseArrayOffset", "(Ljava/nio/Buffer;)I"); - positionID = _env->GetFieldID(bufferClass, "position", "I"); - limitID = _env->GetFieldID(bufferClass, "limit", "I"); - elementSizeShiftID = - _env->GetFieldID(bufferClass, "_elementSizeShift", "I"); + + jclass bufferClassLocal = FindClassOrDie(env, "java/nio/Buffer"); + bufferClass = MakeGlobalRefOrDie(env, bufferClassLocal); + positionID = GetFieldIDOrDie(env, bufferClass, "position", "I"); + limitID = GetFieldIDOrDie(env, bufferClass, "limit", "I"); + elementSizeShiftID = GetFieldIDOrDie(env, bufferClass, "_elementSizeShift", "I"); } static void * @@ -1056,12 +1054,7 @@ int register_android_opengl_classes(JNIEnv* env) int result = 0; for (int i = 0; i < NELEM(gClasses); i++) { ClassRegistrationInfo* cri = &gClasses[i]; - result = AndroidRuntime::registerNativeMethods(env, - cri->classPath, cri->methods, cri->methodCount); - if (result < 0) { - ALOGE("Failed to register %s: %d", cri->classPath, result); - break; - } + result = RegisterMethodsOrDie(env, cri->classPath, cri->methods, cri->methodCount); } return result; } |