summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android/graphics/Bitmap.cpp11
-rw-r--r--core/jni/android/graphics/Matrix.cpp13
-rw-r--r--core/jni/android/graphics/Paint.cpp12
-rw-r--r--core/jni/android/graphics/Shader.cpp6
-rw-r--r--core/jni/android_view_GLES20Canvas.cpp4
5 files changed, 29 insertions, 17 deletions
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 880fb6e..f8a80b0 100644
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -255,14 +255,21 @@ static jobject Bitmap_copy(JNIEnv* env, jobject, const SkBitmap* src,
static void Bitmap_destructor(JNIEnv* env, jobject, SkBitmap* bitmap) {
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
- android::uirenderer::Caches::getInstance().textureCache.remove(bitmap);
+ android::uirenderer::Caches::getInstance().resourceCache.destructor(bitmap);
}
-#endif
+#else // !USE_OPENGL_RENDERER
delete bitmap;
+#endif
}
static void Bitmap_recycle(JNIEnv* env, jobject, SkBitmap* bitmap) {
+#ifdef USE_OPENGL_RENDERER
+ if (android::uirenderer::Caches::hasInstance()) {
+ android::uirenderer::Caches::getInstance().resourceCache.recycle(bitmap);
+ }
+#else // !USE_OPENGL_RENDERER
bitmap->setPixels(NULL, NULL);
+#endif // USE_OPENGL_RENDERER
}
// These must match the int values in Bitmap.java
diff --git a/core/jni/android/graphics/Matrix.cpp b/core/jni/android/graphics/Matrix.cpp
index cafceab..6667756 100644
--- a/core/jni/android/graphics/Matrix.cpp
+++ b/core/jni/android/graphics/Matrix.cpp
@@ -15,11 +15,6 @@
** limitations under the License.
*/
-// This file was generated from the C++ include file: SkMatrix.h
-// Any changes made to this file will be discarded by the build.
-// To change this file, either edit the include, or device/tools/gluemaker/main.cpp,
-// or one of the auxilary file specifications in device/tools/gluemaker.
-
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
@@ -29,13 +24,21 @@
#include "Matrix.h"
+#include <Caches.h>
+
namespace android {
class SkMatrixGlue {
public:
static void finalizer(JNIEnv* env, jobject clazz, SkMatrix* obj) {
+#ifdef USE_OPENGL_RENDERER
+ if (android::uirenderer::Caches::hasInstance()) {
+ android::uirenderer::Caches::getInstance().resourceCache.destructor(obj);
+ }
+#else // !USE_OPENGL_RENDERER
delete obj;
+#endif
}
static SkMatrix* create(JNIEnv* env, jobject clazz, const SkMatrix* src) {
diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp
index ca9f371..339c1a4 100644
--- a/core/jni/android/graphics/Paint.cpp
+++ b/core/jni/android/graphics/Paint.cpp
@@ -15,11 +15,6 @@
** limitations under the License.
*/
-// This file was generated from the C++ include file: SkPaint.h
-// Any changes made to this file will be discarded by the build.
-// To change this file, either edit the include, or device/tools/gluemaker/main.cpp,
-// or one of the auxilary file specifications in device/tools/gluemaker.
-
#include "jni.h"
#include "GraphicsJNI.h"
#include <android_runtime/AndroidRuntime.h>
@@ -35,6 +30,7 @@
#include "TextLayout.h"
// temporary for debugging
+#include <Caches.h>
#include <utils/Log.h>
namespace android {
@@ -67,7 +63,13 @@ public:
};
static void finalizer(JNIEnv* env, jobject clazz, SkPaint* obj) {
+#ifdef USE_OPENGL_RENDERER
+ if (android::uirenderer::Caches::hasInstance()) {
+ android::uirenderer::Caches::getInstance().resourceCache.destructor(obj);
+ }
+#else // !USE_OPENGL_RENDERER
delete obj;
+#endif
}
static SkPaint* init(JNIEnv* env, jobject clazz) {
diff --git a/core/jni/android/graphics/Shader.cpp b/core/jni/android/graphics/Shader.cpp
index ee44747..79051c2 100644
--- a/core/jni/android/graphics/Shader.cpp
+++ b/core/jni/android/graphics/Shader.cpp
@@ -53,13 +53,13 @@ static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArra
static void Shader_destructor(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader)
{
+ shader->safeUnref();
+ // skiaShader == NULL when not !USE_OPENGL_RENDERER, so no need to delete it outside the ifdef
#ifdef USE_OPENGL_RENDERER
if (android::uirenderer::Caches::hasInstance()) {
- android::uirenderer::Caches::getInstance().gradientCache.remove(shader);
+ android::uirenderer::Caches::getInstance().resourceCache.destructor(skiaShader);
}
#endif
- delete skiaShader;
- shader->safeUnref();
}
static bool Shader_getLocalMatrix(JNIEnv* env, jobject, const SkShader* shader, SkMatrix* matrix)
diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp
index cfa9a27..6d848a4 100644
--- a/core/jni/android_view_GLES20Canvas.cpp
+++ b/core/jni/android_view_GLES20Canvas.cpp
@@ -87,7 +87,7 @@ static OpenGLRenderer* android_view_GLES20Canvas_createRenderer(JNIEnv* env, job
#endif
}
-static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject canvas,
+static void android_view_GLES20Canvas_destroyRenderer(JNIEnv* env, jobject clazz,
OpenGLRenderer* renderer) {
RENDERER_LOGD("Destroy OpenGLRenderer");
delete renderer;
@@ -415,7 +415,7 @@ static DisplayList* android_view_GLES20Canvas_createDisplayList(JNIEnv* env,
}
static void android_view_GLES20Canvas_destroyDisplayList(JNIEnv* env,
- jobject canvas, DisplayList* displayList) {
+ jobject clazz, DisplayList* displayList) {
delete displayList;
}