Loading core/java/android/view/HardwareRenderer.java +34 −20 Original line number Diff line number Diff line Loading @@ -283,7 +283,7 @@ public abstract class HardwareRenderer { * see {@link android.content.ComponentCallbacks} */ static void trimMemory(int level) { Gl20Renderer.flushCaches(level); Gl20Renderer.trimMemory(level); } /** Loading Loading @@ -677,19 +677,10 @@ public abstract class HardwareRenderer { } EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) { int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; int[] attribs = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; return egl.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, mGlVersion != 0 ? attrib_list : null); } @Override void initializeIfNeeded(int width, int height, View.AttachInfo attachInfo, SurfaceHolder holder) throws Surface.OutOfResourcesException { if (isRequested()) { checkEglErrors(); super.initializeIfNeeded(width, height, attachInfo, holder); } mGlVersion != 0 ? attribs : null); } @Override Loading Loading @@ -726,6 +717,7 @@ public abstract class HardwareRenderer { @Override void setup(int width, int height) { checkCurrent(); mCanvas.setViewport(width, height); } Loading Loading @@ -819,7 +811,7 @@ public abstract class HardwareRenderer { * {@link #SURFACE_STATE_UPDATED} if the EGL context was changed or * {@link #SURFACE_STATE_SUCCESS} if the EGL context was the correct one */ private int checkCurrent() { int checkCurrent() { if (mEglThread != Thread.currentThread()) { throw new IllegalStateException("Hardware acceleration can only be used with a " + "single UI thread.\nOriginal thread: " + mEglThread + "\n" + Loading Loading @@ -847,6 +839,9 @@ public abstract class HardwareRenderer { static class Gl20Renderer extends GlRenderer { private GLES20Canvas mGlCanvas; private static EGLSurface sPbuffer; private static final Object[] sPbufferLock = new Object[0]; Gl20Renderer(boolean translucent) { super(2, translucent); } Loading Loading @@ -926,14 +921,26 @@ public abstract class HardwareRenderer { return ((GLES20TextureLayer) layer).getSurfaceTexture(); } static HardwareRenderer create(boolean translucent) { if (GLES20Canvas.isAvailable()) { return new Gl20Renderer(translucent); static void trimMemory(int level) { if (sEgl == null || sEglConfig == null) return; EGLContext eglContext = sEglContextStorage.get(); // We do not have OpenGL objects if (eglContext == null) { return; } else { synchronized (sPbufferLock) { // Create a temporary 1x1 pbuffer so we have a context // to clear our OpenGL objects if (sPbuffer == null) { sPbuffer = sEgl.eglCreatePbufferSurface(sEglDisplay, sEglConfig, new int[] { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }); } return null; } sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); } static void flushCaches(int level) { switch (level) { case ComponentCallbacks.TRIM_MEMORY_MODERATE: GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_MODERATE); Loading @@ -943,5 +950,12 @@ public abstract class HardwareRenderer { break; } } static HardwareRenderer create(boolean translucent) { if (GLES20Canvas.isAvailable()) { return new Gl20Renderer(translucent); } return null; } } } core/java/android/view/ViewRootImpl.java +1 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, final Configuration mLastConfiguration = new Configuration(); final Configuration mPendingConfiguration = new Configuration(); class ResizedInfo { Rect coveredInsets; Rect visibleInsets; Loading libs/hwui/Layer.h +4 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,10 @@ struct Layer { if (texture.id) glDeleteTextures(1, &texture.id); } inline void deleteFbo() { if (fbo) glDeleteFramebuffers(1, &fbo); } inline void allocateTexture(GLenum format, GLenum storage) { glTexImage2D(renderTarget, 0, format, getWidth(), getHeight(), 0, format, storage, NULL); } Loading libs/hwui/LayerCache.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ void LayerCache::setMaxSize(uint32_t maxSize) { void LayerCache::deleteLayer(Layer* layer) { if (layer) { mSize -= layer->getWidth() * layer->getHeight() * 4; layer->deleteFbo(); layer->deleteTexture(); delete layer; } Loading libs/hwui/TextureCache.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ void TextureCache::clearGarbage() { void TextureCache::clear() { mCache.clear(); TEXTURE_LOGD("TextureCache:clear(), miSize = %d", mSize); TEXTURE_LOGD("TextureCache:clear(), mSize = %d", mSize); } void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) { Loading Loading
core/java/android/view/HardwareRenderer.java +34 −20 Original line number Diff line number Diff line Loading @@ -283,7 +283,7 @@ public abstract class HardwareRenderer { * see {@link android.content.ComponentCallbacks} */ static void trimMemory(int level) { Gl20Renderer.flushCaches(level); Gl20Renderer.trimMemory(level); } /** Loading Loading @@ -677,19 +677,10 @@ public abstract class HardwareRenderer { } EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) { int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; int[] attribs = { EGL_CONTEXT_CLIENT_VERSION, mGlVersion, EGL_NONE }; return egl.eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, mGlVersion != 0 ? attrib_list : null); } @Override void initializeIfNeeded(int width, int height, View.AttachInfo attachInfo, SurfaceHolder holder) throws Surface.OutOfResourcesException { if (isRequested()) { checkEglErrors(); super.initializeIfNeeded(width, height, attachInfo, holder); } mGlVersion != 0 ? attribs : null); } @Override Loading Loading @@ -726,6 +717,7 @@ public abstract class HardwareRenderer { @Override void setup(int width, int height) { checkCurrent(); mCanvas.setViewport(width, height); } Loading Loading @@ -819,7 +811,7 @@ public abstract class HardwareRenderer { * {@link #SURFACE_STATE_UPDATED} if the EGL context was changed or * {@link #SURFACE_STATE_SUCCESS} if the EGL context was the correct one */ private int checkCurrent() { int checkCurrent() { if (mEglThread != Thread.currentThread()) { throw new IllegalStateException("Hardware acceleration can only be used with a " + "single UI thread.\nOriginal thread: " + mEglThread + "\n" + Loading Loading @@ -847,6 +839,9 @@ public abstract class HardwareRenderer { static class Gl20Renderer extends GlRenderer { private GLES20Canvas mGlCanvas; private static EGLSurface sPbuffer; private static final Object[] sPbufferLock = new Object[0]; Gl20Renderer(boolean translucent) { super(2, translucent); } Loading Loading @@ -926,14 +921,26 @@ public abstract class HardwareRenderer { return ((GLES20TextureLayer) layer).getSurfaceTexture(); } static HardwareRenderer create(boolean translucent) { if (GLES20Canvas.isAvailable()) { return new Gl20Renderer(translucent); static void trimMemory(int level) { if (sEgl == null || sEglConfig == null) return; EGLContext eglContext = sEglContextStorage.get(); // We do not have OpenGL objects if (eglContext == null) { return; } else { synchronized (sPbufferLock) { // Create a temporary 1x1 pbuffer so we have a context // to clear our OpenGL objects if (sPbuffer == null) { sPbuffer = sEgl.eglCreatePbufferSurface(sEglDisplay, sEglConfig, new int[] { EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE }); } return null; } sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); } static void flushCaches(int level) { switch (level) { case ComponentCallbacks.TRIM_MEMORY_MODERATE: GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_MODERATE); Loading @@ -943,5 +950,12 @@ public abstract class HardwareRenderer { break; } } static HardwareRenderer create(boolean translucent) { if (GLES20Canvas.isAvailable()) { return new Gl20Renderer(translucent); } return null; } } }
core/java/android/view/ViewRootImpl.java +1 −0 Original line number Diff line number Diff line Loading @@ -235,6 +235,7 @@ public final class ViewRootImpl extends Handler implements ViewParent, final Configuration mLastConfiguration = new Configuration(); final Configuration mPendingConfiguration = new Configuration(); class ResizedInfo { Rect coveredInsets; Rect visibleInsets; Loading
libs/hwui/Layer.h +4 −0 Original line number Diff line number Diff line Loading @@ -191,6 +191,10 @@ struct Layer { if (texture.id) glDeleteTextures(1, &texture.id); } inline void deleteFbo() { if (fbo) glDeleteFramebuffers(1, &fbo); } inline void allocateTexture(GLenum format, GLenum storage) { glTexImage2D(renderTarget, 0, format, getWidth(), getHeight(), 0, format, storage, NULL); } Loading
libs/hwui/LayerCache.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ void LayerCache::setMaxSize(uint32_t maxSize) { void LayerCache::deleteLayer(Layer* layer) { if (layer) { mSize -= layer->getWidth() * layer->getHeight() * 4; layer->deleteFbo(); layer->deleteTexture(); delete layer; } Loading
libs/hwui/TextureCache.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -165,7 +165,7 @@ void TextureCache::clearGarbage() { void TextureCache::clear() { mCache.clear(); TEXTURE_LOGD("TextureCache:clear(), miSize = %d", mSize); TEXTURE_LOGD("TextureCache:clear(), mSize = %d", mSize); } void TextureCache::generateTexture(SkBitmap* bitmap, Texture* texture, bool regenerate) { Loading