Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2341a9f authored by Romain Guy's avatar Romain Guy
Browse files

Purge Skia objects from GL caches as needed.

Change-Id: I754c671cf790ad5ae8bf047ad328034217da4ecc
parent 9aaa8269
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -254,7 +254,9 @@ 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);
    }
#endif
    delete bitmap;
}
+7 −0
Original line number Diff line number Diff line
@@ -26,12 +26,19 @@

#include "SkPath.h"

#include <Caches.h>

namespace android {

class SkPathGlue {
public:

    static void finalizer(JNIEnv* env, jobject clazz, SkPath* obj) {
#ifdef USE_OPENGL_RENDERER
        if (android::uirenderer::Caches::hasInstance()) {
            android::uirenderer::Caches::getInstance().pathCache.remove(obj);
        }
#endif
        delete obj;
    }

+6 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "SkXfermode.h"

#include <SkiaShader.h>
#include <Caches.h>

using namespace android::uirenderer;

@@ -52,6 +53,11 @@ static int Color_HSVToColor(JNIEnv* env, jobject, int alpha, jfloatArray hsvArra

static void Shader_destructor(JNIEnv* env, jobject o, SkShader* shader, SkiaShader* skiaShader)
{
#ifdef USE_OPENGL_RENDERER
    if (android::uirenderer::Caches::hasInstance()) {
        android::uirenderer::Caches::getInstance().gradientCache.remove(shader);
    }
#endif
    delete skiaShader;
    shader->safeUnref();
}
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ public:
        return *instance;
    }

    static bool hasInstance() {
        Mutex::Autolock _l(sLock);
        return sInstance != 0;
    }
    
protected:
    ~Singleton() { };
    Singleton() { };
+3 −1
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@
#ifndef ANDROID_UI_CACHES_H
#define ANDROID_UI_CACHES_H

#ifndef LOG_TAG
    #define LOG_TAG "OpenGLRenderer"
#endif

#include <utils/Singleton.h>

Loading