summaryrefslogtreecommitdiffstats
path: root/rs/jni
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-03-04 08:36:12 -0800
committerJohn Reck <jreck@google.com>2015-03-05 09:55:02 -0800
commitb2915245b74b3b5541b123e38403f8e26426b4b7 (patch)
tree295bee60e89bba1ae2221bf40833a80e6d2c41ef /rs/jni
parentf855b0d2d0c0c157d657668fcb98097e2aca097e (diff)
downloadframeworks_base-b2915245b74b3b5541b123e38403f8e26426b4b7.zip
frameworks_base-b2915245b74b3b5541b123e38403f8e26426b4b7.tar.gz
frameworks_base-b2915245b74b3b5541b123e38403f8e26426b4b7.tar.bz2
Cleanup Bitmap JNI
Fix a bunch of places where mNativeBitmap was being poked at directly, switch them either to the NDK API or to GraphicsJNI where it made sense Change-Id: I6b3df3712d6497cba828c2d3012e725cb4ebb64d
Diffstat (limited to 'rs/jni')
-rw-r--r--rs/jni/Android.mk4
-rw-r--r--rs/jni/android_renderscript_RenderScript.cpp17
2 files changed, 9 insertions, 12 deletions
diff --git a/rs/jni/Android.mk b/rs/jni/Android.mk
index f1f0bfc..94f0859 100644
--- a/rs/jni/Android.mk
+++ b/rs/jni/Android.mk
@@ -14,7 +14,8 @@ LOCAL_SHARED_LIBRARIES := \
libskia \
libutils \
libui \
- libgui
+ libgui \
+ libjnigraphics
LOCAL_STATIC_LIBRARIES :=
@@ -23,6 +24,7 @@ rs_generated_include_dir := $(call intermediates-dir-for,SHARED_LIBRARIES,libRS,
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
frameworks/rs \
+ frameworks/base/core/jni \
$(rs_generated_include_dir)
LOCAL_CFLAGS += -Wno-unused-parameter -std=c++11
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index a145166..d8e1464 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -24,8 +24,6 @@
#include <utils/misc.h>
#include <inttypes.h>
-#include <SkBitmap.h>
-
#include <androidfw/Asset.h>
#include <androidfw/AssetManager.h>
#include <androidfw/ResourceTypes.h>
@@ -35,6 +33,7 @@
#include "android_runtime/AndroidRuntime.h"
#include "android_runtime/android_view_Surface.h"
#include "android_runtime/android_util_AssetManager.h"
+#include "android/graphics/GraphicsJNI.h"
#include <rs.h>
#include <rsEnv.h>
@@ -172,14 +171,10 @@ private:
// ---------------------------------------------------------------------------
static jfieldID gContextId = 0;
-static jfieldID gNativeBitmapID = 0;
static void _nInit(JNIEnv *_env, jclass _this)
{
gContextId = _env->GetFieldID(_this, "mContext", "J");
-
- jclass bitmapClass = _env->FindClass("android/graphics/Bitmap");
- gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "J");
}
// ---------------------------------------------------------------------------
@@ -934,7 +929,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type,
jobject jbitmap, jint usage)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ GraphicsJNI::getSkBitmap(_env, jbitmap);
const SkBitmap& bitmap(*nativeBitmap);
bitmap.lockPixels();
@@ -951,7 +946,7 @@ nAllocationCreateBitmapBackedAllocation(JNIEnv *_env, jobject _this, jlong con,
jint mip, jobject jbitmap, jint usage)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ GraphicsJNI::getSkBitmap(_env, jbitmap);
const SkBitmap& bitmap(*nativeBitmap);
bitmap.lockPixels();
@@ -968,7 +963,7 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong ty
jobject jbitmap, jint usage)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ GraphicsJNI::getSkBitmap(_env, jbitmap);
const SkBitmap& bitmap(*nativeBitmap);
bitmap.lockPixels();
@@ -984,7 +979,7 @@ static void
nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ GraphicsJNI::getSkBitmap(_env, jbitmap);
const SkBitmap& bitmap(*nativeBitmap);
int w = bitmap.width();
int h = bitmap.height();
@@ -1001,7 +996,7 @@ static void
nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobject jbitmap)
{
SkBitmap const * nativeBitmap =
- (SkBitmap const *)_env->GetLongField(jbitmap, gNativeBitmapID);
+ GraphicsJNI::getSkBitmap(_env, jbitmap);
const SkBitmap& bitmap(*nativeBitmap);
bitmap.lockPixels();