Merge change 599 into donut
* changes: Add call to (new) Canvas.freeCaches() in response to low-memory
This commit is contained in:
@@ -3497,6 +3497,9 @@ public final class ActivityThread {
|
|||||||
EventLog.writeEvent(SQLITE_MEM_RELEASED_EVENT_LOG_TAG, sqliteReleased);
|
EventLog.writeEvent(SQLITE_MEM_RELEASED_EVENT_LOG_TAG, sqliteReleased);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ask graphics to free up as much as possible (font/image caches)
|
||||||
|
Canvas.freeCaches();
|
||||||
|
|
||||||
BinderInternal.forceGc("mem");
|
BinderInternal.forceGc("mem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "SkCanvas.h"
|
#include "SkCanvas.h"
|
||||||
#include "SkDevice.h"
|
#include "SkDevice.h"
|
||||||
#include "SkGLCanvas.h"
|
#include "SkGLCanvas.h"
|
||||||
|
#include "SkGraphics.h"
|
||||||
|
#include "SkImageRef_GlobalPool.h"
|
||||||
#include "SkShader.h"
|
#include "SkShader.h"
|
||||||
#include "SkTemplates.h"
|
#include "SkTemplates.h"
|
||||||
|
|
||||||
@@ -58,8 +60,11 @@ public:
|
|||||||
return new SkGLCanvas;
|
return new SkGLCanvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void freeGlCaches(JNIEnv* env, jobject) {
|
static void freeCaches(JNIEnv* env, jobject) {
|
||||||
|
// these are called in no particular order
|
||||||
SkGLCanvas::DeleteAllTextures();
|
SkGLCanvas::DeleteAllTextures();
|
||||||
|
SkImageRef_GlobalPool::SetRAMUsed(0);
|
||||||
|
SkGraphics::SetFontCacheUsed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean isOpaque(JNIEnv* env, jobject jcanvas) {
|
static jboolean isOpaque(JNIEnv* env, jobject jcanvas) {
|
||||||
@@ -933,7 +938,7 @@ static JNINativeMethod gCanvasMethods[] = {
|
|||||||
(void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint},
|
(void*) SkCanvasGlue::drawTextOnPath__StringPathFFPaint},
|
||||||
{"native_drawPicture", "(II)V", (void*) SkCanvasGlue::drawPicture},
|
{"native_drawPicture", "(II)V", (void*) SkCanvasGlue::drawPicture},
|
||||||
|
|
||||||
{"freeGlCaches", "()V", (void*) SkCanvasGlue::freeGlCaches}
|
{"freeCaches", "()V", (void*) SkCanvasGlue::freeCaches}
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <android_runtime/AndroidRuntime.h>
|
#include <android_runtime/AndroidRuntime.h>
|
||||||
|
|||||||
@@ -112,7 +112,9 @@ public class Canvas {
|
|||||||
* on behalf of the Canvas. Any subsequent drawing with a GL-backed Canvas
|
* on behalf of the Canvas. Any subsequent drawing with a GL-backed Canvas
|
||||||
* will have to recreate those resources.
|
* will have to recreate those resources.
|
||||||
*/
|
*/
|
||||||
public static native void freeGlCaches();
|
public static void freeGlCaches() {
|
||||||
|
freeCaches();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a bitmap for the canvas to draw into.
|
* Specify a bitmap for the canvas to draw into.
|
||||||
@@ -1405,6 +1407,14 @@ public class Canvas {
|
|||||||
finalizer(mNativeCanvas);
|
finalizer(mNativeCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free up as much memory as possible from private caches (e.g. fonts,
|
||||||
|
* images)
|
||||||
|
*
|
||||||
|
* @hide - for now
|
||||||
|
*/
|
||||||
|
public static native void freeCaches();
|
||||||
|
|
||||||
private static native int initRaster(int nativeBitmapOrZero);
|
private static native int initRaster(int nativeBitmapOrZero);
|
||||||
private static native int initGL();
|
private static native int initGL();
|
||||||
private static native void native_setBitmap(int nativeCanvas, int bitmap);
|
private static native void native_setBitmap(int nativeCanvas, int bitmap);
|
||||||
|
|||||||
Reference in New Issue
Block a user