blob: 3af214db0ad938d81f3f64840e5e80690aca7f77 [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 Viverette57774a82014-07-15 15:49:55 -070084 // Whether the surface has insets. Used to protect opacity.
85 private boolean mHasInsets;
86
Alan Viverette58c42c32014-07-12 20:33:45 -070087 // Light and shadow properties specified by the theme.
88 private final float mLightY;
89 private final float mLightZ;
90 private final float mLightRadius;
Chris Craik058fc642014-07-23 18:19:28 -070091 private final int mAmbientShadowAlpha;
92 private final int mSpotShadowAlpha;
Alan Viverette58c42c32014-07-12 20:33:45 -070093
John Reck4f02bf42014-01-03 18:09:17 -080094 private long mNativeProxy;
John Reckf7d9c1d2014-04-09 10:01:03 -070095 private boolean mInitialized = false;
John Reckbc0cc022014-04-11 16:08:14 -070096 private RenderNode mRootNode;
John Reck18f16e62014-05-02 16:46:41 -070097 private Choreographer mChoreographer;
John Reckfe5e7b72014-05-23 17:42:28 -070098 private boolean mProfilingEnabled;
John Reck0a973302014-07-16 13:29:45 -070099 private boolean mRootNodeNeedsUpdate;
John Reckcec24ae2013-11-05 13:27:50 -0800100
John Reckb8802b12014-06-16 15:28:50 -0700101 ThreadedRenderer(Context context, boolean translucent) {
Alan Viveretteed6f14a2014-08-26 14:53:28 -0700102 final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Lighting, 0, 0);
Alan Viverette58c42c32014-07-12 20:33:45 -0700103 mLightY = a.getDimension(R.styleable.Lighting_lightY, 0);
104 mLightZ = a.getDimension(R.styleable.Lighting_lightZ, 0);
105 mLightRadius = a.getDimension(R.styleable.Lighting_lightRadius, 0);
Alan Viveretteed6f14a2014-08-26 14:53:28 -0700106 mAmbientShadowAlpha =
107 (int) (255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0) + 0.5f);
108 mSpotShadowAlpha = (int) (255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0) + 0.5f);
Alan Viverette58c42c32014-07-12 20:33:45 -0700109 a.recycle();
110
John Recke45b1fd2014-04-15 09:50:16 -0700111 long rootNodePtr = nCreateRootRenderNode();
112 mRootNode = RenderNode.adopt(rootNodePtr);
John Reckbc0cc022014-04-11 16:08:14 -0700113 mRootNode.setClipToBounds(false);
John Recke45b1fd2014-04-15 09:50:16 -0700114 mNativeProxy = nCreateProxy(translucent, rootNodePtr);
John Reck18f16e62014-05-02 16:46:41 -0700115
John Reck3b202512014-06-23 13:13:08 -0700116 AtlasInitializer.sInstance.init(context, mNativeProxy);
117
John Reck18f16e62014-05-02 16:46:41 -0700118 // Setup timing
119 mChoreographer = Choreographer.getInstance();
120 nSetFrameInterval(mNativeProxy, mChoreographer.getFrameIntervalNanos());
John Reckfe5e7b72014-05-23 17:42:28 -0700121
122 loadSystemProperties();
John Reckcec24ae2013-11-05 13:27:50 -0800123 }
124
125 @Override
John Reckf47a5942014-06-30 16:20:04 -0700126 void destroy() {
John Reckf7d9c1d2014-04-09 10:01:03 -0700127 mInitialized = false;
128 updateEnabledState(null);
John Reckfae904d2014-04-14 11:01:57 -0700129 nDestroyCanvasAndSurface(mNativeProxy);
John Reckcec24ae2013-11-05 13:27:50 -0800130 }
131
John Reckf7d9c1d2014-04-09 10:01:03 -0700132 private void updateEnabledState(Surface surface) {
133 if (surface == null || !surface.isValid()) {
134 setEnabled(false);
135 } else {
136 setEnabled(mInitialized);
137 }
138 }
139
John Reckcec24ae2013-11-05 13:27:50 -0800140 @Override
141 boolean initialize(Surface surface) throws OutOfResourcesException {
John Reckf7d9c1d2014-04-09 10:01:03 -0700142 mInitialized = true;
143 updateEnabledState(surface);
Dan Stoza5795d642014-06-20 13:01:36 -0700144 boolean status = nInitialize(mNativeProxy, surface);
145 surface.allocateBuffers();
146 return status;
John Reckcec24ae2013-11-05 13:27:50 -0800147 }
148
149 @Override
150 void updateSurface(Surface surface) throws OutOfResourcesException {
John Reckf7d9c1d2014-04-09 10:01:03 -0700151 updateEnabledState(surface);
John Reck4f02bf42014-01-03 18:09:17 -0800152 nUpdateSurface(mNativeProxy, surface);
John Reckcec24ae2013-11-05 13:27:50 -0800153 }
154
155 @Override
John Reckf7d9c1d2014-04-09 10:01:03 -0700156 void pauseSurface(Surface surface) {
157 nPauseSurface(mNativeProxy, surface);
158 }
159
160 @Override
John Reckcec24ae2013-11-05 13:27:50 -0800161 void destroyHardwareResources(View view) {
John Reck4f02bf42014-01-03 18:09:17 -0800162 destroyResources(view);
John Reckf47a5942014-06-30 16:20:04 -0700163 nDestroyHardwareResources(mNativeProxy);
John Reck4f02bf42014-01-03 18:09:17 -0800164 }
165
166 private static void destroyResources(View view) {
167 view.destroyHardwareResources();
168
169 if (view instanceof ViewGroup) {
170 ViewGroup group = (ViewGroup) view;
171
172 int count = group.getChildCount();
173 for (int i = 0; i < count; i++) {
174 destroyResources(group.getChildAt(i));
175 }
176 }
John Reckcec24ae2013-11-05 13:27:50 -0800177 }
178
179 @Override
180 void invalidate(Surface surface) {
John Reck4f02bf42014-01-03 18:09:17 -0800181 updateSurface(surface);
John Reckcec24ae2013-11-05 13:27:50 -0800182 }
183
184 @Override
John Reck918ad522014-06-27 14:45:25 -0700185 void detachSurfaceTexture(long hardwareLayer) {
186 nDetachSurfaceTexture(mNativeProxy, hardwareLayer);
John Reckcec24ae2013-11-05 13:27:50 -0800187 }
188
189 @Override
Alan Viverette58c42c32014-07-12 20:33:45 -0700190 void setup(int width, int height, Rect surfaceInsets) {
191 final float lightX = width / 2.0f;
John Reckcec24ae2013-11-05 13:27:50 -0800192 mWidth = width;
193 mHeight = height;
Alan Viverette57774a82014-07-15 15:49:55 -0700194 if (surfaceInsets != null && !surfaceInsets.isEmpty()) {
195 mHasInsets = true;
Alan Viveretteccb11e12014-07-08 16:04:02 -0700196 mInsetLeft = surfaceInsets.left;
197 mInsetTop = surfaceInsets.top;
198 mSurfaceWidth = width + mInsetLeft + surfaceInsets.right;
199 mSurfaceHeight = height + mInsetTop + surfaceInsets.bottom;
Alan Viverette57774a82014-07-15 15:49:55 -0700200
201 // If the surface has insets, it can't be opaque.
202 setOpaque(false);
Alan Viveretteccb11e12014-07-08 16:04:02 -0700203 } else {
Alan Viverette57774a82014-07-15 15:49:55 -0700204 mHasInsets = false;
Alan Viveretteccb11e12014-07-08 16:04:02 -0700205 mInsetLeft = 0;
206 mInsetTop = 0;
207 mSurfaceWidth = width;
208 mSurfaceHeight = height;
209 }
210 mRootNode.setLeftTopRightBottom(-mInsetLeft, -mInsetTop, mSurfaceWidth, mSurfaceHeight);
Chris Craik058fc642014-07-23 18:19:28 -0700211 nSetup(mNativeProxy, mSurfaceWidth, mSurfaceHeight,
212 lightX, mLightY, mLightZ, mLightRadius,
213 mAmbientShadowAlpha, mSpotShadowAlpha);
John Reckcec24ae2013-11-05 13:27:50 -0800214 }
215
216 @Override
John Reck63a06672014-05-07 13:45:54 -0700217 void setOpaque(boolean opaque) {
Alan Viverette57774a82014-07-15 15:49:55 -0700218 nSetOpaque(mNativeProxy, opaque && !mHasInsets);
John Reck63a06672014-05-07 13:45:54 -0700219 }
220
221 @Override
John Reckcec24ae2013-11-05 13:27:50 -0800222 int getWidth() {
223 return mWidth;
224 }
225
226 @Override
227 int getHeight() {
228 return mHeight;
229 }
230
231 @Override
John Reckfe5e7b72014-05-23 17:42:28 -0700232 void dumpGfxInfo(PrintWriter pw, FileDescriptor fd) {
233 pw.flush();
234 nDumpProfileInfo(mNativeProxy, fd);
John Reckcec24ae2013-11-05 13:27:50 -0800235 }
236
John Reckfe5e7b72014-05-23 17:42:28 -0700237 private static int search(String[] values, String value) {
238 for (int i = 0; i < values.length; i++) {
239 if (values[i].equals(value)) return i;
240 }
241 return -1;
242 }
243
244 private static boolean checkIfProfilingRequested() {
245 String profiling = SystemProperties.get(HardwareRenderer.PROFILE_PROPERTY);
246 int graphType = search(VISUALIZERS, profiling);
247 return (graphType >= 0) || Boolean.parseBoolean(profiling);
John Reckcec24ae2013-11-05 13:27:50 -0800248 }
249
250 @Override
251 boolean loadSystemProperties() {
John Reckfe5e7b72014-05-23 17:42:28 -0700252 boolean changed = nLoadSystemProperties(mNativeProxy);
253 boolean wantProfiling = checkIfProfilingRequested();
254 if (wantProfiling != mProfilingEnabled) {
255 mProfilingEnabled = wantProfiling;
256 changed = true;
257 }
258 return changed;
John Reckcec24ae2013-11-05 13:27:50 -0800259 }
260
John Reck0a973302014-07-16 13:29:45 -0700261 private void updateViewTreeDisplayList(View view) {
John Reckcec24ae2013-11-05 13:27:50 -0800262 view.mPrivateFlags |= View.PFLAG_DRAWN;
John Reckcec24ae2013-11-05 13:27:50 -0800263 view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED)
264 == View.PFLAG_INVALIDATED;
265 view.mPrivateFlags &= ~View.PFLAG_INVALIDATED;
John Reck0a973302014-07-16 13:29:45 -0700266 view.getDisplayList();
John Reckcec24ae2013-11-05 13:27:50 -0800267 view.mRecreateDisplayList = false;
John Reckbc0cc022014-04-11 16:08:14 -0700268 }
269
John Reck0a973302014-07-16 13:29:45 -0700270 private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks) {
271 Trace.traceBegin(Trace.TRACE_TAG_VIEW, "getDisplayList");
272 updateViewTreeDisplayList(view);
273
274 if (mRootNodeNeedsUpdate || !mRootNode.isValid()) {
275 HardwareCanvas canvas = mRootNode.start(mSurfaceWidth, mSurfaceHeight);
276 try {
Alan Viverettedbed8932014-08-06 17:54:52 -0700277 final int saveCount = canvas.save();
John Reck0a973302014-07-16 13:29:45 -0700278 canvas.translate(mInsetLeft, mInsetTop);
279 callbacks.onHardwarePreDraw(canvas);
280 canvas.drawRenderNode(view.getDisplayList());
281 callbacks.onHardwarePostDraw(canvas);
Alan Viverettedbed8932014-08-06 17:54:52 -0700282 canvas.restoreToCount(saveCount);
John Reck0a973302014-07-16 13:29:45 -0700283 mRootNodeNeedsUpdate = false;
284 } finally {
285 mRootNode.end(canvas);
286 }
287 }
288 Trace.traceEnd(Trace.TRACE_TAG_VIEW);
289 }
290
291 @Override
292 void invalidateRoot() {
293 mRootNodeNeedsUpdate = true;
294 }
295
John Reckbc0cc022014-04-11 16:08:14 -0700296 @Override
John Recke4267ea2014-06-03 15:53:15 -0700297 void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks) {
John Reckbc0cc022014-04-11 16:08:14 -0700298 attachInfo.mIgnoreDirtyState = true;
John Reck18f16e62014-05-02 16:46:41 -0700299 long frameTimeNanos = mChoreographer.getFrameTimeNanos();
John Reck315c3292014-05-09 19:21:04 -0700300 attachInfo.mDrawingTime = frameTimeNanos / TimeUtils.NANOS_PER_MS;
John Reckbc0cc022014-04-11 16:08:14 -0700301
John Reckfe5e7b72014-05-23 17:42:28 -0700302 long recordDuration = 0;
303 if (mProfilingEnabled) {
304 recordDuration = System.nanoTime();
305 }
306
John Reckbc0cc022014-04-11 16:08:14 -0700307 updateRootDisplayList(view, callbacks);
John Reckcec24ae2013-11-05 13:27:50 -0800308
John Reckfe5e7b72014-05-23 17:42:28 -0700309 if (mProfilingEnabled) {
310 recordDuration = System.nanoTime() - recordDuration;
311 }
312
John Reck6313b922014-04-16 18:59:21 -0700313 attachInfo.mIgnoreDirtyState = false;
314
John Reckf9be7792014-05-02 18:21:16 -0700315 int syncResult = nSyncAndDrawFrame(mNativeProxy, frameTimeNanos,
John Recke4267ea2014-06-03 15:53:15 -0700316 recordDuration, view.getResources().getDisplayMetrics().density);
John Reckf9be7792014-05-02 18:21:16 -0700317 if ((syncResult & SYNC_INVALIDATE_REQUIRED) != 0) {
318 attachInfo.mViewRootImpl.invalidate();
319 }
John Reckcec24ae2013-11-05 13:27:50 -0800320 }
321
John Reck3b202512014-06-23 13:13:08 -0700322 static void invokeFunctor(long functor, boolean waitForCompletion) {
323 nInvokeFunctor(functor, waitForCompletion);
John Reck0d1f6342014-03-28 20:30:27 -0700324 }
325
326 @Override
John Reck19b6bcf2014-02-14 20:03:38 -0800327 HardwareLayer createTextureLayer() {
328 long layer = nCreateTextureLayer(mNativeProxy);
329 return HardwareLayer.adoptTextureLayer(this, layer);
330 }
331
332 @Override
John Reck3e824952014-08-20 10:08:39 -0700333 void buildLayer(RenderNode node) {
334 nBuildLayer(mNativeProxy, node.getNativeDisplayList());
335 }
336
337 @Override
John Reck19b6bcf2014-02-14 20:03:38 -0800338 boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) {
339 return nCopyLayerInto(mNativeProxy,
340 layer.getDeferredLayerUpdater(), bitmap.mNativeBitmap);
341 }
342
343 @Override
344 void pushLayerUpdate(HardwareLayer layer) {
John Reckd72e0a32014-05-29 18:56:11 -0700345 nPushLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater());
John Reck19b6bcf2014-02-14 20:03:38 -0800346 }
347
348 @Override
John Reck19b6bcf2014-02-14 20:03:38 -0800349 void onLayerDestroyed(HardwareLayer layer) {
John Reckd72e0a32014-05-29 18:56:11 -0700350 nCancelLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater());
John Reck19b6bcf2014-02-14 20:03:38 -0800351 }
352
353 @Override
John Reckcec24ae2013-11-05 13:27:50 -0800354 void setName(String name) {
John Reckcec24ae2013-11-05 13:27:50 -0800355 }
356
John Reck4f02bf42014-01-03 18:09:17 -0800357 @Override
John Reck28ad7b52014-04-07 16:59:25 -0700358 void fence() {
359 nFence(mNativeProxy);
360 }
361
362 @Override
John Reckf47a5942014-06-30 16:20:04 -0700363 void stopDrawing() {
364 nStopDrawing(mNativeProxy);
365 }
366
367 @Override
John Recka5dda642014-05-22 15:43:54 -0700368 public void notifyFramePending() {
369 nNotifyFramePending(mNativeProxy);
370 }
371
372 @Override
John Reck4f02bf42014-01-03 18:09:17 -0800373 protected void finalize() throws Throwable {
374 try {
375 nDeleteProxy(mNativeProxy);
John Reck0ed751d2014-04-08 14:10:17 -0700376 mNativeProxy = 0;
John Reck4f02bf42014-01-03 18:09:17 -0800377 } finally {
378 super.finalize();
John Reckcec24ae2013-11-05 13:27:50 -0800379 }
380 }
381
John Reckf47a5942014-06-30 16:20:04 -0700382 static void trimMemory(int level) {
383 nTrimMemory(level);
John Reck84a4c882014-05-30 14:34:03 -0700384 }
385
John Reck66f0be62014-05-13 13:39:31 -0700386 private static class AtlasInitializer {
387 static AtlasInitializer sInstance = new AtlasInitializer();
388
389 private boolean mInitialized = false;
390
391 private AtlasInitializer() {}
392
John Reck3b202512014-06-23 13:13:08 -0700393 synchronized void init(Context context, long renderProxy) {
John Reck66f0be62014-05-13 13:39:31 -0700394 if (mInitialized) return;
395 IBinder binder = ServiceManager.getService("assetatlas");
396 if (binder == null) return;
397
398 IAssetAtlas atlas = IAssetAtlas.Stub.asInterface(binder);
399 try {
400 if (atlas.isCompatible(android.os.Process.myPpid())) {
401 GraphicBuffer buffer = atlas.getBuffer();
402 if (buffer != null) {
403 long[] map = atlas.getMap();
404 if (map != null) {
John Reckb8802b12014-06-16 15:28:50 -0700405 // TODO Remove after fixing b/15425820
406 validateMap(context, map);
John Reck3b202512014-06-23 13:13:08 -0700407 nSetAtlas(renderProxy, buffer, map);
John Reck66f0be62014-05-13 13:39:31 -0700408 mInitialized = true;
409 }
410 // If IAssetAtlas is not the same class as the IBinder
411 // we are using a remote service and we can safely
412 // destroy the graphic buffer
413 if (atlas.getClass() != binder.getClass()) {
414 buffer.destroy();
415 }
416 }
417 }
418 } catch (RemoteException e) {
419 Log.w(LOG_TAG, "Could not acquire atlas", e);
420 }
421 }
John Reckb8802b12014-06-16 15:28:50 -0700422
423 private static void validateMap(Context context, long[] map) {
424 Log.d("Atlas", "Validating map...");
425 HashSet<Long> preloadedPointers = new HashSet<Long>();
426
427 // We only care about drawables that hold bitmaps
428 final Resources resources = context.getResources();
429 final LongSparseArray<Drawable.ConstantState> drawables = resources.getPreloadedDrawables();
430
431 final int count = drawables.size();
432 for (int i = 0; i < count; i++) {
433 final Bitmap bitmap = drawables.valueAt(i).getBitmap();
434 if (bitmap != null && bitmap.getConfig() == Bitmap.Config.ARGB_8888) {
435 preloadedPointers.add(bitmap.mNativeBitmap);
436 }
437 }
438
439 for (int i = 0; i < map.length; i += 4) {
440 if (!preloadedPointers.contains(map[i])) {
441 Log.w("Atlas", String.format("Pointer 0x%X, not in getPreloadedDrawables?", map[i]));
442 map[i] = 0;
443 }
444 }
445 }
John Reck66f0be62014-05-13 13:39:31 -0700446 }
447
John Reck84a4c882014-05-30 14:34:03 -0700448 static native void setupShadersDiskCache(String cacheFile);
449
John Reck3b202512014-06-23 13:13:08 -0700450 private static native void nSetAtlas(long nativeProxy, GraphicBuffer buffer, long[] map);
John Reck4f02bf42014-01-03 18:09:17 -0800451
John Recke45b1fd2014-04-15 09:50:16 -0700452 private static native long nCreateRootRenderNode();
453 private static native long nCreateProxy(boolean translucent, long rootRenderNode);
John Reck4f02bf42014-01-03 18:09:17 -0800454 private static native void nDeleteProxy(long nativeProxy);
455
John Reck18f16e62014-05-02 16:46:41 -0700456 private static native void nSetFrameInterval(long nativeProxy, long frameIntervalNanos);
John Recke4280ba2014-05-05 16:39:37 -0700457 private static native boolean nLoadSystemProperties(long nativeProxy);
John Reck18f16e62014-05-02 16:46:41 -0700458
John Reck4f02bf42014-01-03 18:09:17 -0800459 private static native boolean nInitialize(long nativeProxy, Surface window);
460 private static native void nUpdateSurface(long nativeProxy, Surface window);
John Reckf7d9c1d2014-04-09 10:01:03 -0700461 private static native void nPauseSurface(long nativeProxy, Surface window);
Chris Craik797b95b2014-05-20 18:10:25 -0700462 private static native void nSetup(long nativeProxy, int width, int height,
Chris Craik058fc642014-07-23 18:19:28 -0700463 float lightX, float lightY, float lightZ, float lightRadius,
464 int ambientShadowAlpha, int spotShadowAlpha);
John Reck63a06672014-05-07 13:45:54 -0700465 private static native void nSetOpaque(long nativeProxy, boolean opaque);
John Reckfe5e7b72014-05-23 17:42:28 -0700466 private static native int nSyncAndDrawFrame(long nativeProxy,
John Recke4267ea2014-06-03 15:53:15 -0700467 long frameTimeNanos, long recordDuration, float density);
John Reckfae904d2014-04-14 11:01:57 -0700468 private static native void nDestroyCanvasAndSurface(long nativeProxy);
John Reck4f02bf42014-01-03 18:09:17 -0800469
John Reck3b202512014-06-23 13:13:08 -0700470 private static native void nInvokeFunctor(long functor, boolean waitForCompletion);
John Reck19b6bcf2014-02-14 20:03:38 -0800471
472 private static native long nCreateDisplayListLayer(long nativeProxy, int width, int height);
473 private static native long nCreateTextureLayer(long nativeProxy);
John Reck3e824952014-08-20 10:08:39 -0700474 private static native void nBuildLayer(long nativeProxy, long node);
John Reck19b6bcf2014-02-14 20:03:38 -0800475 private static native boolean nCopyLayerInto(long nativeProxy, long layer, long bitmap);
John Reckd72e0a32014-05-29 18:56:11 -0700476 private static native void nPushLayerUpdate(long nativeProxy, long layer);
477 private static native void nCancelLayerUpdate(long nativeProxy, long layer);
John Reck918ad522014-06-27 14:45:25 -0700478 private static native void nDetachSurfaceTexture(long nativeProxy, long layer);
John Reck28ad7b52014-04-07 16:59:25 -0700479
John Reckf47a5942014-06-30 16:20:04 -0700480 private static native void nDestroyHardwareResources(long nativeProxy);
481 private static native void nTrimMemory(int level);
John Recke1628b72014-05-23 15:11:19 -0700482
John Reck28ad7b52014-04-07 16:59:25 -0700483 private static native void nFence(long nativeProxy);
John Reckf47a5942014-06-30 16:20:04 -0700484 private static native void nStopDrawing(long nativeProxy);
John Recka5dda642014-05-22 15:43:54 -0700485 private static native void nNotifyFramePending(long nativeProxy);
John Reckfe5e7b72014-05-23 17:42:28 -0700486
487 private static native void nDumpProfileInfo(long nativeProxy, FileDescriptor fd);
John Reckcec24ae2013-11-05 13:27:50 -0800488}