summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorChad Jones <chadj@google.com>2015-03-05 19:35:14 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-03-05 19:35:15 +0000
commitb9a468eb193a374bf82279817aa592b3f5901c98 (patch)
treedda18c7faed40caca2b90bd6019a7595be417990 /core/jni
parent54b804fa742e44a0bc7dccc2784b3322c7b92f19 (diff)
parentc02977e3bbfaaedcb1b1d67e1692becc7dddd59b (diff)
downloadframeworks_base-b9a468eb193a374bf82279817aa592b3f5901c98.zip
frameworks_base-b9a468eb193a374bf82279817aa592b3f5901c98.tar.gz
frameworks_base-b9a468eb193a374bf82279817aa592b3f5901c98.tar.bz2
Merge "Revert "Cleanup Bitmap JNI""
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/Android.mk2
-rw-r--r--core/jni/android/graphics/BitmapFactory.cpp4
-rw-r--r--core/jni/android/graphics/BitmapRegionDecoder.cpp2
-rw-r--r--core/jni/android/graphics/Graphics.cpp8
-rw-r--r--core/jni/android/graphics/GraphicsJNI.h2
-rw-r--r--core/jni/android/opengl/util.cpp26
-rw-r--r--core/jni/android_view_PointerIcon.cpp2
-rw-r--r--core/jni/com_google_android_gles_jni_EGLImpl.cpp9
8 files changed, 39 insertions, 16 deletions
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 97744ea..28f1a3a 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -147,7 +147,7 @@ LOCAL_SRC_FILES:= \
android_hardware_location_ActivityRecognitionHardware.cpp \
android_util_FileObserver.cpp \
android/opengl/poly_clip.cpp.arm \
- android/opengl/util.cpp \
+ android/opengl/util.cpp.arm \
android_server_FingerprintManager.cpp \
android_server_NetworkManagementSocketTagger.cpp \
android_server_Watchdog.cpp \
diff --git a/core/jni/android/graphics/BitmapFactory.cpp b/core/jni/android/graphics/BitmapFactory.cpp
index 6a50b52..672008d 100644
--- a/core/jni/android/graphics/BitmapFactory.cpp
+++ b/core/jni/android/graphics/BitmapFactory.cpp
@@ -41,6 +41,7 @@ jfieldID gOptions_mimeFieldID;
jfieldID gOptions_mCancelID;
jfieldID gOptions_bitmapFieldID;
+jfieldID gBitmap_nativeBitmapFieldID;
jfieldID gBitmap_ninePatchInsetsFieldID;
jclass gInsetStruct_class;
@@ -261,7 +262,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
SkBitmap* outputBitmap = NULL;
unsigned int existingBufferSize = 0;
if (javaBitmap != NULL) {
- outputBitmap = GraphicsJNI::getSkBitmap(env, javaBitmap);
+ outputBitmap = (SkBitmap*) env->GetLongField(javaBitmap, gBitmap_nativeBitmapFieldID);
if (outputBitmap->isImmutable()) {
ALOGW("Unable to reuse an immutable bitmap as an image decoder target.");
javaBitmap = NULL;
@@ -600,6 +601,7 @@ int register_android_graphics_BitmapFactory(JNIEnv* env) {
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;");
diff --git a/core/jni/android/graphics/BitmapRegionDecoder.cpp b/core/jni/android/graphics/BitmapRegionDecoder.cpp
index 04afe3e..90a7f69 100644
--- a/core/jni/android/graphics/BitmapRegionDecoder.cpp
+++ b/core/jni/android/graphics/BitmapRegionDecoder.cpp
@@ -213,7 +213,7 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle,
if (tileBitmap != NULL) {
// Re-use bitmap.
- bitmap = GraphicsJNI::getSkBitmap(env, tileBitmap);
+ bitmap = GraphicsJNI::getNativeBitmap(env, tileBitmap);
}
if (bitmap == NULL) {
bitmap = new SkBitmap;
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 0747969..dde1393 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -154,7 +154,7 @@ static jfieldID gPointF_xFieldID;
static jfieldID gPointF_yFieldID;
static jclass gBitmap_class;
-static jfieldID gBitmap_skBitmapPtr;
+static jfieldID gBitmap_nativeInstanceID;
static jmethodID gBitmap_constructorMethodID;
static jmethodID gBitmap_reinitMethodID;
static jmethodID gBitmap_getAllocationByteCountMethodID;
@@ -338,11 +338,11 @@ SkColorType GraphicsJNI::legacyBitmapConfigToColorType(jint legacyConfig) {
return static_cast<SkColorType>(gConfig2ColorType[legacyConfig]);
}
-SkBitmap* GraphicsJNI::getSkBitmap(JNIEnv* env, jobject bitmap) {
+SkBitmap* GraphicsJNI::getNativeBitmap(JNIEnv* env, jobject bitmap) {
SkASSERT(env);
SkASSERT(bitmap);
SkASSERT(env->IsInstanceOf(bitmap, gBitmap_class));
- jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_skBitmapPtr);
+ jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_nativeInstanceID);
SkBitmap* b = reinterpret_cast<SkBitmap*>(bitmapHandle);
SkASSERT(b);
return b;
@@ -676,7 +676,7 @@ int register_android_graphics_Graphics(JNIEnv* env)
gPointF_yFieldID = getFieldIDCheck(env, gPointF_class, "y", "F");
gBitmap_class = make_globalref(env, "android/graphics/Bitmap");
- gBitmap_skBitmapPtr = getFieldIDCheck(env, gBitmap_class, "mSkBitmapPtr", "J");
+ gBitmap_nativeInstanceID = getFieldIDCheck(env, gBitmap_class, "mNativeBitmap", "J");
gBitmap_constructorMethodID = env->GetMethodID(gBitmap_class, "<init>", "(J[BIIIZZ[BLandroid/graphics/NinePatch$InsetStruct;)V");
gBitmap_reinitMethodID = env->GetMethodID(gBitmap_class, "reinit", "(IIZ)V");
gBitmap_getAllocationByteCountMethodID = env->GetMethodID(gBitmap_class, "getAllocationByteCount", "()I");
diff --git a/core/jni/android/graphics/GraphicsJNI.h b/core/jni/android/graphics/GraphicsJNI.h
index 422d3f1..a202c38 100644
--- a/core/jni/android/graphics/GraphicsJNI.h
+++ b/core/jni/android/graphics/GraphicsJNI.h
@@ -48,7 +48,7 @@ public:
static void point_to_jpointf(const SkPoint& point, JNIEnv*, jobject jpointf);
static SkCanvas* getNativeCanvas(JNIEnv*, jobject canvas);
- static SkBitmap* getSkBitmap(JNIEnv*, jobject bitmap);
+ static SkBitmap* getNativeBitmap(JNIEnv*, jobject bitmap);
static SkRegion* getNativeRegion(JNIEnv*, jobject region);
// Given the 'native' long held by the Rasterizer.java object, return a
diff --git a/core/jni/android/opengl/util.cpp b/core/jni/android/opengl/util.cpp
index 5c2d0d0..461507f 100644
--- a/core/jni/android/opengl/util.cpp
+++ b/core/jni/android/opengl/util.cpp
@@ -16,7 +16,6 @@
#include "jni.h"
#include "JNIHelp.h"
-#include "GraphicsJNI.h"
#include <math.h>
#include <stdio.h>
@@ -150,6 +149,10 @@ int visibilityTest(float* pWS, float* pPositions, int positionsLength,
return result;
}
+static void doThrowIAE(JNIEnv* env, const char* msg) {
+ jniThrowException(env, "java/lang/IllegalArgumentException", msg);
+}
+
template<class JArray, class T>
class ArrayHelper {
public:
@@ -545,6 +548,14 @@ void util_multiplyMV(JNIEnv *env, jclass clazz,
// ---------------------------------------------------------------------------
+static jfieldID nativeBitmapID = 0;
+
+void nativeUtilsClassInit(JNIEnv *env, jclass clazz)
+{
+ jclass bitmapClass = env->FindClass("android/graphics/Bitmap");
+ nativeBitmapID = env->GetFieldID(bitmapClass, "mNativeBitmap", "J");
+}
+
extern void setGLDebugLevel(int level);
void setTracingLevel(JNIEnv *env, jclass clazz, jint level)
{
@@ -618,14 +629,16 @@ static int getType(SkColorType colorType)
static jint util_getInternalFormat(JNIEnv *env, jclass clazz,
jobject jbitmap)
{
- SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
return getInternalFormat(nativeBitmap->colorType());
}
static jint util_getType(JNIEnv *env, jclass clazz,
jobject jbitmap)
{
- SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
return getType(nativeBitmap->colorType());
}
@@ -633,7 +646,8 @@ static jint util_texImage2D(JNIEnv *env, jclass clazz,
jint target, jint level, jint internalformat,
jobject jbitmap, jint type, jint border)
{
- SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
const SkBitmap& bitmap(*nativeBitmap);
SkColorType colorType = bitmap.colorType();
if (internalformat < 0) {
@@ -680,7 +694,8 @@ static jint util_texSubImage2D(JNIEnv *env, jclass clazz,
jint target, jint level, jint xoffset, jint yoffset,
jobject jbitmap, jint format, jint type)
{
- SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(env, jbitmap);
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)env->GetLongField(jbitmap, nativeBitmapID);
const SkBitmap& bitmap(*nativeBitmap);
SkColorType colorType = bitmap.colorType();
if (format < 0) {
@@ -999,6 +1014,7 @@ static JNINativeMethod gVisibilityMethods[] = {
};
static JNINativeMethod gUtilsMethods[] = {
+ {"nativeClassInit", "()V", (void*)nativeUtilsClassInit },
{ "native_getInternalFormat", "(Landroid/graphics/Bitmap;)I", (void*) util_getInternalFormat },
{ "native_getType", "(Landroid/graphics/Bitmap;)I", (void*) util_getType },
{ "native_texImage2D", "(IIILandroid/graphics/Bitmap;II)I", (void*)util_texImage2D },
diff --git a/core/jni/android_view_PointerIcon.cpp b/core/jni/android_view_PointerIcon.cpp
index f6d9a1a..bbd031e 100644
--- a/core/jni/android_view_PointerIcon.cpp
+++ b/core/jni/android_view_PointerIcon.cpp
@@ -80,7 +80,7 @@ status_t android_view_PointerIcon_load(JNIEnv* env, jobject pointerIconObj, jobj
jobject bitmapObj = env->GetObjectField(loadedPointerIconObj, gPointerIconClassInfo.mBitmap);
if (bitmapObj) {
- SkBitmap* bitmap = GraphicsJNI::getSkBitmap(env, bitmapObj);
+ SkBitmap* bitmap = GraphicsJNI::getNativeBitmap(env, bitmapObj);
if (bitmap) {
outPointerIcon->bitmap = *bitmap; // use a shared pixel ref
}
diff --git a/core/jni/com_google_android_gles_jni_EGLImpl.cpp b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
index 7080e2a..6c21bab 100644
--- a/core/jni/com_google_android_gles_jni_EGLImpl.cpp
+++ b/core/jni/com_google_android_gles_jni_EGLImpl.cpp
@@ -30,7 +30,6 @@
#include <gui/GLConsumer.h>
#include <gui/Surface.h>
-#include <GraphicsJNI.h>
#include <SkBitmap.h>
#include <SkPixelRef.h>
@@ -47,6 +46,7 @@ static jfieldID gContext_EGLContextFieldID;
static jfieldID gSurface_EGLSurfaceFieldID;
static jfieldID gSurface_NativePixelRefFieldID;
static jfieldID gConfig_EGLConfigFieldID;
+static jfieldID gBitmap_NativeBitmapFieldID;
static inline EGLDisplay getDisplay(JNIEnv* env, jobject o) {
if (!o) return EGL_NO_DISPLAY;
@@ -85,6 +85,9 @@ static void nativeClassInit(JNIEnv *_env, jclass eglImplClass)
jclass surface_class = _env->FindClass("com/google/android/gles_jni/EGLSurfaceImpl");
gSurface_EGLSurfaceFieldID = _env->GetFieldID(surface_class, "mEGLSurface", "J");
gSurface_NativePixelRefFieldID = _env->GetFieldID(surface_class, "mNativePixelRef", "J");
+
+ jclass bitmap_class = _env->FindClass("android/graphics/Bitmap");
+ gBitmap_NativeBitmapFieldID = _env->GetFieldID(bitmap_class, "mNativeBitmap", "J");
}
static const jint gNull_attrib_base[] = {EGL_NONE};
@@ -277,7 +280,9 @@ static void jni_eglCreatePixmapSurface(JNIEnv *_env, jobject _this, jobject out_
EGLConfig cnf = getConfig(_env, config);
jint* base = 0;
- SkBitmap const * nativeBitmap = GraphicsJNI::getSkBitmap(_env, native_pixmap);
+ SkBitmap const * nativeBitmap =
+ (SkBitmap const *)_env->GetLongField(native_pixmap,
+ gBitmap_NativeBitmapFieldID);
SkPixelRef* ref = nativeBitmap ? nativeBitmap->pixelRef() : 0;
if (ref == NULL) {
jniThrowException(_env, "java/lang/IllegalArgumentException", "Bitmap has no PixelRef");