ThreadedRenderer.java revision 4f02bf4eef6af47f35c70c4dda5b7b9523d89ca0
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
19cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.graphics.Rect;
20cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.graphics.SurfaceTexture;
21cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.os.SystemClock;
22cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.os.Trace;
23cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.view.Surface.OutOfResourcesException;
24cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.view.View.AttachInfo;
25cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
26cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport java.io.PrintWriter;
27cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
28cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck/**
29cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Hardware renderer that proxies the rendering to a render thread. Most calls
304f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * are currently synchronous.
314f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * TODO: Make draw() async.
324f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * TODO: Figure out how to share the DisplayList between two threads (global lock?)
33cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck *
34cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * The UI thread can block on the RenderThread, but RenderThread must never
35cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * block on the UI thread.
36cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck *
374f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * ThreadedRenderer creates an instance of RenderProxy. RenderProxy in turn creates
384f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * and manages a CanvasContext on the RenderThread. The CanvasContext is fully managed
394f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck * by the lifecycle of the RenderProxy.
404f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck *
41cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Note that although currently the EGL context & surfaces are created & managed
42cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * by the render thread, the goal is to move that into a shared structure that can
43cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * be managed by both threads. EGLSurface creation & deletion should ideally be
44cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * done on the UI thread and not the RenderThread to avoid stalling the
45cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * RenderThread with surface buffer allocation.
46cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck *
47cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * @hide
48cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck */
49cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckpublic class ThreadedRenderer extends HardwareRenderer {
50cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    private static final String LOGTAG = "ThreadedRenderer";
51cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
524f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static final Rect NULL_RECT = new Rect(-1, -1, -1, -1);
53cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
54cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    private int mWidth, mHeight;
554f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private long mNativeProxy;
56cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
573dfe19f72cbd95b201e89376ae1810c5c9229b00John Reck    ThreadedRenderer(boolean translucent) {
584f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        mNativeProxy = nCreateProxy(translucent);
594f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        setEnabled(mNativeProxy != 0);
60cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
61cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
62cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
63cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void destroy(boolean full) {
644f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        nDestroyCanvas(mNativeProxy);
65cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
66cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
67cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
68cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    boolean initialize(Surface surface) throws OutOfResourcesException {
694f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        return nInitialize(mNativeProxy, surface);
70cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
71cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
72cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
73cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void updateSurface(Surface surface) throws OutOfResourcesException {
744f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        nUpdateSurface(mNativeProxy, surface);
75cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
76cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
77cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
78cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void destroyLayers(View view) {
79cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
80cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
81cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
82cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
83cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void destroyHardwareResources(View view) {
844f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        // TODO: canvas.clearLayerUpdates()
854f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        destroyResources(view);
864f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        // TODO: GLES20Canvas.flushCaches(GLES20Canvas.FLUSH_CACHES_LAYERS);
874f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    }
884f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
894f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static void destroyResources(View view) {
904f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        view.destroyHardwareResources();
914f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
924f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        if (view instanceof ViewGroup) {
934f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            ViewGroup group = (ViewGroup) view;
944f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck
954f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            int count = group.getChildCount();
964f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            for (int i = 0; i < count; i++) {
974f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck                destroyResources(group.getChildAt(i));
984f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            }
994f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        }
100cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
101cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
102cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
103cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void invalidate(Surface surface) {
1044f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        updateSurface(surface);
105cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
106cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
107cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
108cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    boolean validate() {
109cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        // TODO Remove users of this API
110cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        return false;
111cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
112cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
113cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
114cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    boolean safelyRun(Runnable action) {
1154f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        // TODO:
1164f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        return false;
117cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
118cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
119cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
120cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void setup(int width, int height) {
121cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        mWidth = width;
122cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        mHeight = height;
1234f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        nSetup(mNativeProxy, width, height);
124cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
125cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
126cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
127cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    int getWidth() {
128cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        return mWidth;
129cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
130cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
131cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
132cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    int getHeight() {
133cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        return mHeight;
134cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
135cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
136cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
137cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void dumpGfxInfo(PrintWriter pw) {
138cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        // TODO Auto-generated method stub
139cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
140cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
141cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
142cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    long getFrameCount() {
143cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        // TODO Auto-generated method stub
144cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        return 0;
145cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
146cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
147cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
148cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    boolean loadSystemProperties() {
1494f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        return false;
150cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
151cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
152cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
153cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void pushLayerUpdate(HardwareLayer layer) {
154cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
155cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
156cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
157cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
158cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void cancelLayerUpdate(HardwareLayer layer) {
159cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
160cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
161cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
162cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
163cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void flushLayerUpdates() {
164cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
165cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
166cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
167cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    /**
168cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck     * TODO: Remove
169cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck     * Temporary hack to allow RenderThreadTest prototype app to trigger
170cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck     * replaying a DisplayList after modifying the displaylist properties
171cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck     *
172cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck     *  @hide */
173cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    public void repeatLastDraw() {
174cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
175cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
176cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
177cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks, Rect dirty) {
178cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        attachInfo.mIgnoreDirtyState = true;
179cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        attachInfo.mDrawingTime = SystemClock.uptimeMillis();
180cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        view.mPrivateFlags |= View.PFLAG_DRAWN;
181cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
182cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
183cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck                == View.PFLAG_INVALIDATED;
184cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        view.mPrivateFlags &= ~View.PFLAG_INVALIDATED;
185cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
186cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
187cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        DisplayList displayList = view.getDisplayList();
188cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        Trace.traceEnd(Trace.TRACE_TAG_VIEW);
189cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
190cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        view.mRecreateDisplayList = false;
191cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
1924f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        if (dirty == null) {
1934f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            dirty = NULL_RECT;
1944f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        }
1954f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        nDrawDisplayList(mNativeProxy, displayList.getNativeDisplayList(),
1964f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck                dirty.left, dirty.top, dirty.right, dirty.bottom);
197cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
198cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
199cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
200cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    HardwareLayer createHardwareLayer(boolean isOpaque) {
201cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
202cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
203cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
204cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
205cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    HardwareLayer createHardwareLayer(int width, int height, boolean isOpaque) {
206cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
207cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
208cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
209cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
210cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    SurfaceTexture createSurfaceTexture(HardwareLayer layer) {
211cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
212cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
213cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
214cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
215cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void setSurfaceTexture(HardwareLayer layer, SurfaceTexture surfaceTexture) {
216cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        throw new NoSuchMethodError();
217cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
218cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
219cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
220cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void detachFunctor(int functor) {
2214f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        nDetachFunctor(mNativeProxy, functor);
222cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
223cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
224cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
2254f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    void attachFunctor(AttachInfo attachInfo, int functor) {
2264f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        nAttachFunctor(mNativeProxy, functor);
227cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
228cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
229cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    @Override
230cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    void setName(String name) {
231cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
232cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
2334f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    @Override
2344f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    protected void finalize() throws Throwable {
2354f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        try {
2364f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            nDeleteProxy(mNativeProxy);
2374f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck        } finally {
2384f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            super.finalize();
239cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck        }
240cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck    }
241cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
2424f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    /** @hide */
2434f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    public static native void postToRenderThread(Runnable runnable);
244cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
2454f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native long nCreateProxy(boolean translucent);
2464f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nDeleteProxy(long nativeProxy);
247cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
2484f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native boolean nInitialize(long nativeProxy, Surface window);
2494f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nUpdateSurface(long nativeProxy, Surface window);
2504f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nSetup(long nativeProxy, int width, int height);
2514f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nDrawDisplayList(long nativeProxy, long displayList,
2524f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck            int dirtyLeft, int dirtyTop, int dirtyRight, int dirtyBottom);
2534f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nDestroyCanvas(long nativeProxy);
254cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck
2554f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nAttachFunctor(long nativeProxy, long functor);
2564f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck    private static native void nDetachFunctor(long nativeProxy, long functor);
257cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck}
258