blob: 120c036e7b67bc56c09df7b2eee2561893c4e469 [file] [log] [blame]
John Reckcec24ae2013-11-05 13:27:50 -08001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.view;
18
Alan Viverette58c42c32014-07-12 20:33:45 -070019import com.android.internal.R;
20
John Reckb8802b12014-06-16 15:28:50 -070021import android.content.Context;
22import android.content.res.Resources;
Alan Viverette58c42c32014-07-12 20:33:45 -070023import android.content.res.TypedArray;
John Reck04fc5832014-02-05 16:38:25 -080024import android.graphics.Bitmap;
Alan Viveretteccb11e12014-07-08 16:04:02 -070025import android.graphics.Rect;
John Reckb8802b12014-06-16 15:28:50 -070026import android.graphics.drawable.Drawable;
John Reck66f0be62014-05-13 13:39:31 -070027import android.os.IBinder;
28import android.os.RemoteException;
29import android.os.ServiceManager;
John Reckfe5e7b72014-05-23 17:42:28 -070030import android.os.SystemProperties;
John Reckcec24ae2013-11-05 13:27:50 -080031import android.os.Trace;
John Reck66f0be62014-05-13 13:39:31 -070032import android.util.Log;
John Reckb8802b12014-06-16 15:28:50 -070033import android.util.LongSparseArray;
John Reck315c3292014-05-09 19:21:04 -070034import android.util.TimeUtils;
John Reckcec24ae2013-11-05 13:27:50 -080035import android.view.Surface.OutOfResourcesException;
36import android.view.View.AttachInfo;
37
John Reckfe5e7b72014-05-23 17:42:28 -070038import java.io.FileDescriptor;
John Reckcec24ae2013-11-05 13:27:50 -080039import java.io.PrintWriter;
John Reckb8802b12014-06-16 15:28:50 -070040import java.util.HashSet;
John Reckcec24ae2013-11-05 13:27:50 -080041
42/**
43 * Hardware renderer that proxies the rendering to a render thread. Most calls
John Reck4f02bf42014-01-03 18:09:17 -080044 * are currently synchronous.
John Reckcec24ae2013-11-05 13:27:50 -080045 *
46 * The UI thread can block on the RenderThread, but RenderThread must never
47 * block on the UI thread.
48 *
John Reck4f02bf42014-01-03 18:09:17 -080049 * ThreadedRenderer creates an instance of RenderProxy. RenderProxy in turn creates
50 * and manages a CanvasContext on the RenderThread. The CanvasContext is fully managed
51 * by the lifecycle of the RenderProxy.
52 *
John Reckcec24ae2013-11-05 13:27:50 -080053 * Note that although currently the EGL context & surfaces are created & managed
54 * by the render thread, the goal is to move that into a shared structure that can
55 * be managed by both threads. EGLSurface creation & deletion should ideally be
56 * done on the UI thread and not the RenderThread to avoid stalling the
57 * RenderThread with surface buffer allocation.
58 *
59 * @hide
60 */
61public class ThreadedRenderer extends HardwareRenderer {
62 private static final String LOGTAG = "ThreadedRenderer";
63
John Reckf9be7792014-05-02 18:21:16 -070064 // Keep in sync with DrawFrameTask.h SYNC_* flags
65 // Nothing interesting to report
John Reckcd028f32014-06-24 08:44:29 -070066 private static final int SYNC_OK = 0;
John Reckf9be7792014-05-02 18:21:16 -070067 // Needs a ViewRoot invalidate
John Reckcd028f32014-06-24 08:44:29 -070068 private static final int SYNC_INVALIDATE_REQUIRED = 1 << 0;
John Reckf9be7792014-05-02 18:21:16 -070069
John Reckfe5e7b72014-05-23 17:42:28 -070070 private static final String[] VISUALIZERS = {
71 PROFILE_PROPERTY_VISUALIZE_BARS,
72 };
73
Alan Viveretteccb11e12014-07-08 16:04:02 -070074 // Size of the rendered content.
John Reckcec24ae2013-11-05 13:27:50 -080075 private int mWidth, mHeight;
Alan Viveretteccb11e12014-07-08 16:04:02 -070076
77 // Actual size of the drawing surface.
78 private int mSurfaceWidth, mSurfaceHeight;
79
80 // Insets between the drawing surface and rendered content. These are
81 // applied as translation when updating the root render node.
82 private int mInsetTop, mInsetLeft;
83
Alan Viverette58c42c32014-07-12 20:33:45 -070084 // Light and shadow properties specified by the theme.
85 private final float mLightY;
86 private final float mLightZ;
87 private final float mLightRadius;
88 private final float mAmbientShadowAlpha;
89 private final float mSpotShadowAlpha;
90
John Reck4f02bf42014-01-03 18:09:17 -080091 private long mNativeProxy;
John Reckf7d9c1d2014-04-09 10:01:03 -070092 private boolean mInitialized = false;
John Reckbc0cc022014-04-11 16:08:14 -070093 private RenderNode mRootNode;
John Reck18f16e62014-05-02 16:46:41 -070094 private Choreographer mChoreographer;
John Reckfe5e7b72014-05-23 17:42:28 -070095 private boolean mProfilingEnabled;
John Reck0a973302014-07-16 13:29:45 -070096 private boolean mRootNodeNeedsUpdate;
John Reckcec24ae2013-11-05 13:27:50 -080097
John Reckb8802b12014-06-16 15:28:50 -070098 ThreadedRenderer(Context context, boolean translucent) {
Alan Viverette58c42c32014-07-12 20:33:45 -070099 final TypedArray a = context.obtainStyledAttributes(
100 null, R.styleable.Lighting, R.attr.lightingStyle, 0);
101 mLightY = a.getDimension(R.styleable.Lighting_lightY, 0);
102 mLightZ = a.getDimension(R.styleable.Lighting_lightZ, 0);
103 mLightRadius = a.getDimension(R.styleable.Lighting_lightRadius, 0);
104 mAmbientShadowAlpha = a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0);
105 mSpotShadowAlpha = a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0);
106 a.recycle();
107
John Recke45b1fd2014-04-15 09:50:16 -0700108 long rootNodePtr = nCreateRootRenderNode();
109 mRootNode = RenderNode.adopt(rootNodePtr);
John Reckbc0cc022014-04-11 16:08:14 -0700110 mRootNode.setClipToBounds(false);
John Recke45b1fd2014-04-15 09:50:16 -0700111 mNativeProxy = nCreateProxy(translucent, rootNodePtr);
John Reck18f16e62014-05-02 16:46:41 -0700112
John Reck3b202512014-06-23 13:13:08 -0700113 AtlasInitializer.sInstance.init(context, mNativeProxy);
114
John Reck18f16e62014-05-02 16:46:41 -0700115 // Setup timing
116 mChoreographer = Choreographer.getInstance();
117 nSetFrameInterval(mNativeProxy, mChoreographer.getFrameIntervalNanos());
John Reckfe5e7b72014-05-23 17:42:28 -0700118
119 loadSystemProperties();
John Reckcec24ae2013-11-05 13:27:50 -0800120 }
121
122 @Override
John Reckf47a5942014-06-30 16:20:04 -0700123 void destroy() {
John Reckf7d9c1d2014-04-09 10:01:03 -0700124 mInitialized = false;
125 updateEnabledState(null);
John Reckfae904d2014-04-14 11:01:57 -0700126 nDestroyCanvasAndSurface(mNativeProxy);
John Reckcec24ae2013-11-05 13:27:50 -0800127 }
128
John Reckf7d9c1d2014-04-09 10:01:03 -0700129 private void updateEnabledState(Surface surface) {
130 if (surface == null || !surface.isValid()) {
131 setEnabled(false);
132 } else {
133 setEnabled(mInitialized);
134 }
135 }
136
John Reckcec24ae2013-11-05 13:27:50 -0800137 @Override
138 boolean initialize(Surface surface) throws OutOfResourcesException {
John Reckf7d9c1d2014-04-09 10:01:03 -0700139 mInitialized = true;
140 updateEnabledState(surface);
Dan Stoza5795d642014-06-20 13:01:36 -0700141 boolean status = nInitialize(mNativeProxy, surface);
142 surface.allocateBuffers();
143 return status;
John Reckcec24ae2013-11-05 13:27:50 -0800144 }
145
146 @Override
147 void updateSurface(Surface surface) throws OutOfResourcesException {
John Reckf7d9c1d2014-04-09 10:01:03 -0700148 updateEnabledState(surface);
John Reck4f02bf42014-01-03 18:09:17 -0800149 nUpdateSurface(mNativeProxy, surface);
John Reckcec24ae2013-11-05 13:27:50 -0800150 }
151
152 @Override
John Reckf7d9c1d2014-04-09 10:01:03 -0700153 void pauseSurface(Surface surface) {
154 nPauseSurface(mNativeProxy, surface);
155 }
156
157 @Override
John Reckcec24ae2013-11-05 13:27:50 -0800158 void destroyHardwareResources(View view) {
John Reck4f02bf42014-01-03 18:09:17 -0800159 destroyResources(view);
John Reckf47a5942014-06-30 16:20:04 -0700160 nDestroyHardwareResources(mNativeProxy);
John Reck4f02bf42014-01-03 18:09:17 -0800161 }
162
163 private static void destroyResources(View view) {
164 view.destroyHardwareResources();
165
166 if (view instanceof ViewGroup) {
167 ViewGroup group = (ViewGroup) view;
168
169 int count = group.getChildCount();
170 for (int i = 0; i < count; i++) {
171 destroyResources(group.getChildAt(i));
172 }
173 }
John Reckcec24ae2013-11-05 13:27:50 -0800174 }
175
176 @Override
177 void invalidate(Surface surface) {
John Reck4f02bf42014-01-03 18:09:17 -0800178 updateSurface(surface);
John Reckcec24ae2013-11-05 13:27:50 -0800179 }
180
181 @Override
John Reck918ad522014-06-27 14:45:25 -0700182 void detachSurfaceTexture(long hardwareLayer) {
183 nDetachSurfaceTexture(mNativeProxy, hardwareLayer);
John Reckcec24ae2013-11-05 13:27:50 -0800184 }
185
186 @Override
Alan Viverette58c42c32014-07-12 20:33:45 -0700187 void setup(int width, int height, Rect surfaceInsets) {
188 final float lightX = width / 2.0f;
John Reckcec24ae2013-11-05 13:27:50 -0800189 mWidth = width;
190 mHeight = height;
Alan Viveretteccb11e12014-07-08 16:04:02 -0700191 if (surfaceInsets != null) {
192 mInsetLeft = surfaceInsets.left;
193 mInsetTop = surfaceInsets.top;
194 mSurfaceWidth = width + mInsetLeft + surfaceInsets.right;
195 mSurfaceHeight = height + mInsetTop + surfaceInsets.bottom;
196 } else {
197 mInsetLeft = 0;
198 mInsetTop = 0;
199 mSurfaceWidth = width;
200 mSurfaceHeight = height;
201 }
202 mRootNode.setLeftTopRightBottom(-mInsetLeft, -mInsetTop, mSurfaceWidth, mSurfaceHeight);
Alan Viverette58c42c32014-07-12 20:33:45 -0700203 nSetup(mNativeProxy, mSurfaceWidth, mSurfaceHeight, lightX, mLightY, mLightZ, mLightRadius);
John Reckcec24ae2013-11-05 13:27:50 -0800204 }
205
206 @Override
John Reck63a06672014-05-07 13:45:54 -0700207 void setOpaque(boolean opaque) {
208 nSetOpaque(mNativeProxy, opaque);
209 }
210
211 @Override
John Reckcec24ae2013-11-05 13:27:50 -0800212 int getWidth() {
213 return mWidth;
214 }
215
216 @Override
217 int getHeight() {
218 return mHeight;
219 }
220
221 @Override
John Reckfe5e7b72014-05-23 17:42:28 -0700222 void dumpGfxInfo(PrintWriter pw, FileDescriptor fd) {
223 pw.flush();
224 nDumpProfileInfo(mNativeProxy, fd);
John Reckcec24ae2013-11-05 13:27:50 -0800225 }
226
John Reckfe5e7b72014-05-23 17:42:28 -0700227 private static int search(String[] values, String value) {
228 for (int i = 0; i < values.length; i++) {
229 if (values[i].equals(value)) return i;
230 }
231 return -1;
232 }
233
234 private static boolean checkIfProfilingRequested() {
235 String profiling = SystemProperties.get(HardwareRenderer.PROFILE_PROPERTY);
236 int graphType = search(VISUALIZERS, profiling);
237 return (graphType >= 0) || Boolean.parseBoolean(profiling);
John Reckcec24ae2013-11-05 13:27:50 -0800238 }
239
240 @Override
241 boolean loadSystemProperties() {
John Reckfe5e7b72014-05-23 17:42:28 -0700242 boolean changed = nLoadSystemProperties(mNativeProxy);
243 boolean wantProfiling = checkIfProfilingRequested();
244 if (wantProfiling != mProfilingEnabled) {
245 mProfilingEnabled = wantProfiling;
246 changed = true;
247 }
248 return changed;
John Reckcec24ae2013-11-05 13:27:50 -0800249 }
250
John Reck0a973302014-07-16 13:29:45 -0700251 private void updateViewTreeDisplayList(View view) {
John Reckcec24ae2013-11-05 13:27:50 -0800252 view.mPrivateFlags |= View.PFLAG_DRAWN;
John Reckcec24ae2013-11-05 13:27:50 -0800253 view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
254 == View.PFLAG_INVALIDATED;
255 view.mPrivateFlags &= ~View.PFLAG_INVALIDATED;
John Reck0a973302014-07-16 13:29:45 -0700256 view.getDisplayList();
John Reckcec24ae2013-11-05 13:27:50 -0800257 view.mRecreateDisplayList = false;
John Reckbc0cc022014-04-11 16:08:14 -0700258 }
259
John Reck0a973302014-07-16 13:29:45 -0700260 private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks) {
261 Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
262 updateViewTreeDisplayList(view);
263
264 if (mRootNodeNeedsUpdate || !mRootNode.isValid()) {
265 HardwareCanvas canvas = mRootNode.start(mSurfaceWidth, mSurfaceHeight);
266 try {
267 canvas.save();
268 canvas.translate(mInsetLeft, mInsetTop);
269 callbacks.onHardwarePreDraw(canvas);
270 canvas.drawRenderNode(view.getDisplayList());
271 callbacks.onHardwarePostDraw(canvas);
272 canvas.restore();
273 mRootNodeNeedsUpdate = false;
274 } finally {
275 mRootNode.end(canvas);
276 }
277 }
278 Trace.traceEnd(Trace.TRACE_TAG_VIEW);
279 }
280
281 @Override
282 void invalidateRoot() {
283 mRootNodeNeedsUpdate = true;
284 }
285
John Reckbc0cc022014-04-11 16:08:14 -0700286 @Override
John Recke4267ea2014-06-03 15:53:15 -0700287 void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks) {
John Reckbc0cc022014-04-11 16:08:14 -0700288 attachInfo.mIgnoreDirtyState = true;
John Reck18f16e62014-05-02 16:46:41 -0700289 long frameTimeNanos = mChoreographer.getFrameTimeNanos();
John Reck315c3292014-05-09 19:21:04 -0700290 attachInfo.mDrawingTime = frameTimeNanos / TimeUtils.NANOS_PER_MS;
John Reckbc0cc022014-04-11 16:08:14 -0700291
John Reckfe5e7b72014-05-23 17:42:28 -0700292 long recordDuration = 0;
293 if (mProfilingEnabled) {
294 recordDuration = System.nanoTime();
295 }
296
John Reckbc0cc022014-04-11 16:08:14 -0700297 updateRootDisplayList(view, callbacks);
John Reckcec24ae2013-11-05 13:27:50 -0800298
John Reckfe5e7b72014-05-23 17:42:28 -0700299 if (mProfilingEnabled) {
300 recordDuration = System.nanoTime() - recordDuration;
301 }
302
John Reck6313b922014-04-16 18:59:21 -0700303 attachInfo.mIgnoreDirtyState = false;
304
John Reckf9be7792014-05-02 18:21:16 -0700305 int syncResult = nSyncAndDrawFrame(mNativeProxy, frameTimeNanos,
John Recke4267ea2014-06-03 15:53:15 -0700306 recordDuration, view.getResources().getDisplayMetrics().density);
John Reckf9be7792014-05-02 18:21:16 -0700307 if ((syncResult & SYNC_INVALIDATE_REQUIRED) != 0) {
308 attachInfo.mViewRootImpl.invalidate();
309 }
John Reckcec24ae2013-11-05 13:27:50 -0800310 }
311
John Reck3b202512014-06-23 13:13:08 -0700312 static void invokeFunctor(long functor, boolean waitForCompletion) {
313 nInvokeFunctor(functor, waitForCompletion);
John Reck0d1f6342014-03-28 20:30:27 -0700314 }
315
316 @Override
John Reck19b6bcf2014-02-14 20:03:38 -0800317 HardwareLayer createTextureLayer() {
318 long layer = nCreateTextureLayer(mNativeProxy);
319 return HardwareLayer.adoptTextureLayer(this, layer);
320 }
321
322 @Override
John Reck19b6bcf2014-02-14 20:03:38 -0800323 boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) {
324 return nCopyLayerInto(mNativeProxy,
325 layer.getDeferredLayerUpdater(), bitmap.mNativeBitmap);
326 }
327
328 @Override
329 void pushLayerUpdate(HardwareLayer layer) {
John Reckd72e0a32014-05-29 18:56:11 -0700330 nPushLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater());
John Reck19b6bcf2014-02-14 20:03:38 -0800331 }
332
333 @Override
John Reck19b6bcf2014-02-14 20:03:38 -0800334 void onLayerDestroyed(HardwareLayer layer) {
John Reckd72e0a32014-05-29 18:56:11 -0700335 nCancelLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater());
John Reck19b6bcf2014-02-14 20:03:38 -0800336 }
337
338 @Override
John Reckcec24ae2013-11-05 13:27:50 -0800339 void setName(String name) {
John Reckcec24ae2013-11-05 13:27:50 -0800340 }
341
John Reck4f02bf42014-01-03 18:09:17 -0800342 @Override
John Reck28ad7b52014-04-07 16:59:25 -0700343 void fence() {
344 nFence(mNativeProxy);
345 }
346
347 @Override
John Reckf47a5942014-06-30 16:20:04 -0700348 void stopDrawing() {
349 nStopDrawing(mNativeProxy);
350 }
351
352 @Override
John Recka5dda642014-05-22 15:43:54 -0700353 public void notifyFramePending() {
354 nNotifyFramePending(mNativeProxy);
355 }
356
357 @Override
John Reck4f02bf42014-01-03 18:09:17 -0800358 protected void finalize() throws Throwable {
359 try {
360 nDeleteProxy(mNativeProxy);
John Reck0ed751d2014-04-08 14:10:17 -0700361 mNativeProxy = 0;
John Reck4f02bf42014-01-03 18:09:17 -0800362 } finally {
363 super.finalize();
John Reckcec24ae2013-11-05 13:27:50 -0800364 }
365 }
366
John Reckf47a5942014-06-30 16:20:04 -0700367 static void trimMemory(int level) {
368 nTrimMemory(level);
John Reck84a4c882014-05-30 14:34:03 -0700369 }
370
John Reck66f0be62014-05-13 13:39:31 -0700371 private static class AtlasInitializer {
372 static AtlasInitializer sInstance = new AtlasInitializer();
373
374 private boolean mInitialized = false;
375
376 private AtlasInitializer() {}
377
John Reck3b202512014-06-23 13:13:08 -0700378 synchronized void init(Context context, long renderProxy) {
John Reck66f0be62014-05-13 13:39:31 -0700379 if (mInitialized) return;
380 IBinder binder = ServiceManager.getService("assetatlas");
381 if (binder == null) return;
382
383 IAssetAtlas atlas = IAssetAtlas.Stub.asInterface(binder);
384 try {
385 if (atlas.isCompatible(android.os.Process.myPpid())) {
386 GraphicBuffer buffer = atlas.getBuffer();
387 if (buffer != null) {
388 long[] map = atlas.getMap();
389 if (map != null) {
John Reckb8802b12014-06-16 15:28:50 -0700390 // TODO Remove after fixing b/15425820
391 validateMap(context, map);
John Reck3b202512014-06-23 13:13:08 -0700392 nSetAtlas(renderProxy, buffer, map);
John Reck66f0be62014-05-13 13:39:31 -0700393 mInitialized = true;
394 }
395 // If IAssetAtlas is not the same class as the IBinder
396 // we are using a remote service and we can safely
397 // destroy the graphic buffer
398 if (atlas.getClass() != binder.getClass()) {
399 buffer.destroy();
400 }
401 }
402 }
403 } catch (RemoteException e) {
404 Log.w(LOG_TAG, "Could not acquire atlas", e);
405 }
406 }
John Reckb8802b12014-06-16 15:28:50 -0700407
408 private static void validateMap(Context context, long[] map) {
409 Log.d("Atlas", "Validating map...");
410 HashSet<Long> preloadedPointers = new HashSet<Long>();
411
412 // We only care about drawables that hold bitmaps
413 final Resources resources = context.getResources();
414 final LongSparseArray<Drawable.ConstantState> drawables = resources.getPreloadedDrawables();
415
416 final int count = drawables.size();
417 for (int i = 0; i < count; i++) {
418 final Bitmap bitmap = drawables.valueAt(i).getBitmap();
419 if (bitmap != null && bitmap.getConfig() == Bitmap.Config.ARGB_8888) {
420 preloadedPointers.add(bitmap.mNativeBitmap);
421 }
422 }
423
424 for (int i = 0; i < map.length; i += 4) {
425 if (!preloadedPointers.contains(map[i])) {
426 Log.w("Atlas", String.format("Pointer 0x%X, not in getPreloadedDrawables?", map[i]));
427 map[i] = 0;
428 }
429 }
430 }
John Reck66f0be62014-05-13 13:39:31 -0700431 }
432
John Reck84a4c882014-05-30 14:34:03 -0700433 static native void setupShadersDiskCache(String cacheFile);
434
John Reck3b202512014-06-23 13:13:08 -0700435 private static native void nSetAtlas(long nativeProxy, GraphicBuffer buffer, long[] map);
John Reck4f02bf42014-01-03 18:09:17 -0800436
John Recke45b1fd2014-04-15 09:50:16 -0700437 private static native long nCreateRootRenderNode();
438 private static native long nCreateProxy(boolean translucent, long rootRenderNode);
John Reck4f02bf42014-01-03 18:09:17 -0800439 private static native void nDeleteProxy(long nativeProxy);
440
John Reck18f16e62014-05-02 16:46:41 -0700441 private static native void nSetFrameInterval(long nativeProxy, long frameIntervalNanos);
John Recke4280ba2014-05-05 16:39:37 -0700442 private static native boolean nLoadSystemProperties(long nativeProxy);
John Reck18f16e62014-05-02 16:46:41 -0700443
John Reck4f02bf42014-01-03 18:09:17 -0800444 private static native boolean nInitialize(long nativeProxy, Surface window);
445 private static native void nUpdateSurface(long nativeProxy, Surface window);
John Reckf7d9c1d2014-04-09 10:01:03 -0700446 private static native void nPauseSurface(long nativeProxy, Surface window);
Chris Craik797b95b2014-05-20 18:10:25 -0700447 private static native void nSetup(long nativeProxy, int width, int height,
448 float lightX, float lightY, float lightZ, float lightRadius);
John Reck63a06672014-05-07 13:45:54 -0700449 private static native void nSetOpaque(long nativeProxy, boolean opaque);
John Reckfe5e7b72014-05-23 17:42:28 -0700450 private static native int nSyncAndDrawFrame(long nativeProxy,
John Recke4267ea2014-06-03 15:53:15 -0700451 long frameTimeNanos, long recordDuration, float density);
John Reckfae904d2014-04-14 11:01:57 -0700452 private static native void nDestroyCanvasAndSurface(long nativeProxy);
John Reck4f02bf42014-01-03 18:09:17 -0800453
John Reck3b202512014-06-23 13:13:08 -0700454 private static native void nInvokeFunctor(long functor, boolean waitForCompletion);
John Reck19b6bcf2014-02-14 20:03:38 -0800455
456 private static native long nCreateDisplayListLayer(long nativeProxy, int width, int height);
457 private static native long nCreateTextureLayer(long nativeProxy);
458 private static native boolean nCopyLayerInto(long nativeProxy, long layer, long bitmap);
John Reckd72e0a32014-05-29 18:56:11 -0700459 private static native void nPushLayerUpdate(long nativeProxy, long layer);
460 private static native void nCancelLayerUpdate(long nativeProxy, long layer);
John Reck918ad522014-06-27 14:45:25 -0700461 private static native void nDetachSurfaceTexture(long nativeProxy, long layer);
John Reck28ad7b52014-04-07 16:59:25 -0700462
John Reckf47a5942014-06-30 16:20:04 -0700463 private static native void nDestroyHardwareResources(long nativeProxy);
464 private static native void nTrimMemory(int level);
John Recke1628b72014-05-23 15:11:19 -0700465
John Reck28ad7b52014-04-07 16:59:25 -0700466 private static native void nFence(long nativeProxy);
John Reckf47a5942014-06-30 16:20:04 -0700467 private static native void nStopDrawing(long nativeProxy);
John Recka5dda642014-05-22 15:43:54 -0700468 private static native void nNotifyFramePending(long nativeProxy);
John Reckfe5e7b72014-05-23 17:42:28 -0700469
470 private static native void nDumpProfileInfo(long nativeProxy, FileDescriptor fd);
John Reckcec24ae2013-11-05 13:27:50 -0800471}