ThreadedRenderer.java revision 19b6bcfd83eb7fb92ebd06d2fec89e308311f1d0
1cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck/* 2cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Copyright (C) 2013 The Android Open Source Project 3cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 4cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Licensed under the Apache License, Version 2.0 (the "License"); 5cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * you may not use this file except in compliance with the License. 6cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * You may obtain a copy of the License at 7cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 8cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * http://www.apache.org/licenses/LICENSE-2.0 9cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 10cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Unless required by applicable law or agreed to in writing, software 11cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * distributed under the License is distributed on an "AS IS" BASIS, 12cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * See the License for the specific language governing permissions and 14cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * limitations under the License. 15cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck */ 16cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 17cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckpackage android.view; 18cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 1904fc583c3dd3144bc6b718fcac4b3e1afdfdb067John Reckimport android.graphics.Bitmap; 20cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.graphics.Rect; 21cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.graphics.SurfaceTexture; 22cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.os.SystemClock; 23cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.os.Trace; 24cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.view.Surface.OutOfResourcesException; 25cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.view.View.AttachInfo; 26cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 27cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport java.io.PrintWriter; 28cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 29cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck/** 30cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Hardware renderer that proxies the rendering to a render thread. Most calls 314f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * are currently synchronous. 324f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * TODO: Make draw() async. 334f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * TODO: Figure out how to share the DisplayList between two threads (global lock?) 34cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 35cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * The UI thread can block on the RenderThread, but RenderThread must never 36cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * block on the UI thread. 37cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 384f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * ThreadedRenderer creates an instance of RenderProxy. RenderProxy in turn creates 394f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * and manages a CanvasContext on the RenderThread. The CanvasContext is fully managed 404f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * by the lifecycle of the RenderProxy. 414f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * 42cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Note that although currently the EGL context & surfaces are created & managed 43cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * by the render thread, the goal is to move that into a shared structure that can 44cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * be managed by both threads. EGLSurface creation & deletion should ideally be 45cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * done on the UI thread and not the RenderThread to avoid stalling the 46cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * RenderThread with surface buffer allocation. 47cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 48cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * @hide 49cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck */ 50cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckpublic class ThreadedRenderer extends HardwareRenderer { 51cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck private static final String LOGTAG = "ThreadedRenderer"; 52cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 534f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static final Rect NULL_RECT = new Rect(-1, -1, -1, -1); 54cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 55cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck private int mWidth, mHeight; 564f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private long mNativeProxy; 57cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 583dfe19f72cbd95b201e89376ae1810c5c9229b00John Reck ThreadedRenderer(boolean translucent) { 594f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck mNativeProxy = nCreateProxy(translucent); 604f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck setEnabled(mNativeProxy != 0); 61cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 62cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 63cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 64cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void destroy(boolean full) { 654f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck nDestroyCanvas(mNativeProxy); 66cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 67cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 68cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 69cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck boolean initialize(Surface surface) throws OutOfResourcesException { 704f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck return nInitialize(mNativeProxy, surface); 71cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 72cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 73cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 74cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void updateSurface(Surface surface) throws OutOfResourcesException { 754f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck nUpdateSurface(mNativeProxy, surface); 76cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 77cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 78cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 79cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void destroyHardwareResources(View view) { 804f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck destroyResources(view); 814f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck // TODO: GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_LAYERS); 824f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck } 834f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck 844f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static void destroyResources(View view) { 854f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck view.destroyHardwareResources(); 864f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck 874f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck if (view instanceof ViewGroup) { 884f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck ViewGroup group = (ViewGroup) view; 894f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck 904f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck int count = group.getChildCount(); 914f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck for (int i = 0; i < count; i++) { 924f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck destroyResources(group.getChildAt(i)); 934f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck } 944f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck } 95cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 96cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 97cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 98cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void invalidate(Surface surface) { 994f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck updateSurface(surface); 100cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 101cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 102cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 103cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck boolean safelyRun(Runnable action) { 104fc53ef27793a39e9effd829e9cae02a9ca14147eJohn Reck nRunWithGlContext(mNativeProxy, action); 105fc53ef27793a39e9effd829e9cae02a9ca14147eJohn Reck return true; 106cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 107cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 108cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 109cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void setup(int width, int height) { 110cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck mWidth = width; 111cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck mHeight = height; 1124f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck nSetup(mNativeProxy, width, height); 113cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 114cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 115cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 116cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck int getWidth() { 117cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck return mWidth; 118cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 119cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 120cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 121cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck int getHeight() { 122cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck return mHeight; 123cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 124cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 125cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 126cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void dumpGfxInfo(PrintWriter pw) { 127cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck // TODO Auto-generated method stub 128cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 129cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 130cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 131cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck long getFrameCount() { 132cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck // TODO Auto-generated method stub 133cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck return 0; 134cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 135cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 136cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 137cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck boolean loadSystemProperties() { 1384f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck return false; 139cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 140cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 141cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck /** 142cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * TODO: Remove 143cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Temporary hack to allow RenderThreadTest prototype app to trigger 144cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * replaying a DisplayList after modifying the displaylist properties 145cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 146cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * @hide */ 147cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck public void repeatLastDraw() { 148cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 149cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 150cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 151cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks, Rect dirty) { 152cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck attachInfo.mIgnoreDirtyState = true; 153cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck attachInfo.mDrawingTime = SystemClock.uptimeMillis(); 154cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck view.mPrivateFlags |= View.PFLAG_DRAWN; 155cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 156cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED) 157cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck == View.PFLAG_INVALIDATED; 158cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck view.mPrivateFlags &= ~View.PFLAG_INVALIDATED; 159cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 160cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList"); 161cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck DisplayList displayList = view.getDisplayList(); 162cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck Trace.traceEnd(Trace.TRACE_TAG_VIEW); 163cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 164cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck view.mRecreateDisplayList = false; 165cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 1664f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck if (dirty == null) { 1674f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck dirty = NULL_RECT; 1684f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck } 1694f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck nDrawDisplayList(mNativeProxy, displayList.getNativeDisplayList(), 1704f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck dirty.left, dirty.top, dirty.right, dirty.bottom); 171cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 172cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 173cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 17419b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck void detachFunctor(long functor) { 17519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck nDetachFunctor(mNativeProxy, functor); 17619b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck } 17719b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck 17819b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck @Override 17919b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck void attachFunctor(AttachInfo attachInfo, long functor) { 18019b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck nAttachFunctor(mNativeProxy, functor); 181cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 182cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 183cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 18404fc583c3dd3144bc6b718fcac4b3e1afdfdb067John Reck HardwareLayer createDisplayListLayer(int width, int height) { 18519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck long layer = nCreateDisplayListLayer(mNativeProxy, width, height); 18619b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck return HardwareLayer.adoptDisplayListLayer(this, layer); 187cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 188cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 189cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 19019b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck HardwareLayer createTextureLayer() { 19119b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck long layer = nCreateTextureLayer(mNativeProxy); 19219b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck return HardwareLayer.adoptTextureLayer(this, layer); 193cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 194cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 195cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 19619b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck SurfaceTexture createSurfaceTexture(final HardwareLayer layer) { 19719b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck final SurfaceTexture[] ret = new SurfaceTexture[1]; 19819b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck nRunWithGlContext(mNativeProxy, new Runnable() { 19919b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck @Override 20019b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck public void run() { 20119b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck ret[0] = layer.createSurfaceTexture(); 20219b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck } 20319b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck }); 20419b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck return ret[0]; 205cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 206cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 207cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 20819b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) { 20919b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck return nCopyLayerInto(mNativeProxy, 21019b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck layer.getDeferredLayerUpdater(), bitmap.mNativeBitmap); 211cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 212cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 213cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 21419b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck void pushLayerUpdate(HardwareLayer layer) { 21519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck // TODO: Remove this, it's not needed outside of GLRenderer 21619b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck } 21719b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck 21819b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck @Override 21919b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck void onLayerCreated(HardwareLayer layer) { 22019b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck // TODO: Is this actually useful? 22119b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck } 22219b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck 22319b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck @Override 22419b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck void flushLayerUpdates() { 22519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck // TODO: Figure out what this should do or remove it 22619b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck } 22719b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck 22819b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck @Override 22919b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck void onLayerDestroyed(HardwareLayer layer) { 23019b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck nDestroyLayer(mNativeProxy, layer.getDeferredLayerUpdater()); 231cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 232cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 233cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck @Override 234cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck void setName(String name) { 235cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 236cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 2374f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck @Override 2384f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck protected void finalize() throws Throwable { 2394f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck try { 2404f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck nDeleteProxy(mNativeProxy); 2414f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck } finally { 2424f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck super.finalize(); 243cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 244cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 245cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 2464f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck /** @hide */ 2474f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck public static native void postToRenderThread(Runnable runnable); 248cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 2494f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native long nCreateProxy(boolean translucent); 2504f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nDeleteProxy(long nativeProxy); 251cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 2524f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native boolean nInitialize(long nativeProxy, Surface window); 2534f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nUpdateSurface(long nativeProxy, Surface window); 2544f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nSetup(long nativeProxy, int width, int height); 2554f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nDrawDisplayList(long nativeProxy, long displayList, 2564f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom); 257fc53ef27793a39e9effd829e9cae02a9ca14147eJohn Reck private static native void nRunWithGlContext(long nativeProxy, Runnable runnable); 2584f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nDestroyCanvas(long nativeProxy); 259cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 2604f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nAttachFunctor(long nativeProxy, long functor); 2614f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck private static native void nDetachFunctor(long nativeProxy, long functor); 26219b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck 26319b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck private static native long nCreateDisplayListLayer(long nativeProxy, int width, int height); 26419b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck private static native long nCreateTextureLayer(long nativeProxy); 26519b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck private static native boolean nCopyLayerInto(long nativeProxy, long layer, long bitmap); 26619b6bcfd83eb7fb92ebd06d2fec89e308311f1d0John Reck private static native void nDestroyLayer(long nativeProxy, long layer); 267cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck} 268