John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.view; |
| 18 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 20 | import android.annotation.NonNull; |
John Reck | b8802b1 | 2014-06-16 15:28:50 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Alan Viverette | 58c42c3 | 2014-07-12 20:33:45 -0700 | [diff] [blame] | 22 | import android.content.res.TypedArray; |
John Reck | 04fc583 | 2014-02-05 16:38:25 -0800 | [diff] [blame] | 23 | import android.graphics.Bitmap; |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 24 | import android.graphics.Point; |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 25 | import android.graphics.Rect; |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 26 | import android.os.Binder; |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 27 | import android.os.Handler; |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 28 | import android.os.IBinder; |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 29 | import android.os.Message; |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 30 | import android.os.ParcelFileDescriptor; |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 31 | import android.os.RemoteException; |
| 32 | import android.os.ServiceManager; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 33 | import android.os.Trace; |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 34 | import android.util.Log; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 35 | import android.view.Surface.OutOfResourcesException; |
| 36 | import android.view.View.AttachInfo; |
| 37 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 38 | import com.android.internal.R; |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 39 | import com.android.internal.util.VirtualRefBasePtr; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 40 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 41 | import java.io.File; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 42 | import java.io.FileDescriptor; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 43 | import java.io.PrintWriter; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 44 | import java.lang.annotation.Retention; |
| 45 | import java.lang.annotation.RetentionPolicy; |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 46 | import java.util.HashSet; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Hardware renderer that proxies the rendering to a render thread. Most calls |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 50 | * are currently synchronous. |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 51 | * |
| 52 | * The UI thread can block on the RenderThread, but RenderThread must never |
| 53 | * block on the UI thread. |
| 54 | * |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 55 | * ThreadedRenderer creates an instance of RenderProxy. RenderProxy in turn creates |
| 56 | * and manages a CanvasContext on the RenderThread. The CanvasContext is fully managed |
| 57 | * by the lifecycle of the RenderProxy. |
| 58 | * |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 59 | * Note that although currently the EGL context & surfaces are created & managed |
| 60 | * by the render thread, the goal is to move that into a shared structure that can |
| 61 | * be managed by both threads. EGLSurface creation & deletion should ideally be |
| 62 | * done on the UI thread and not the RenderThread to avoid stalling the |
| 63 | * RenderThread with surface buffer allocation. |
| 64 | * |
| 65 | * @hide |
| 66 | */ |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 67 | public final class ThreadedRenderer { |
| 68 | private static final String LOG_TAG = "ThreadedRenderer"; |
| 69 | |
| 70 | /** |
| 71 | * Name of the file that holds the shaders cache. |
| 72 | */ |
| 73 | private static final String CACHE_PATH_SHADERS = "com.android.opengl.shaders_cache"; |
| 74 | |
| 75 | /** |
| 76 | * System property used to enable or disable dirty regions invalidation. |
| 77 | * This property is only queried if {@link #RENDER_DIRTY_REGIONS} is true. |
| 78 | * The default value of this property is assumed to be true. |
| 79 | * |
| 80 | * Possible values: |
| 81 | * "true", to enable partial invalidates |
| 82 | * "false", to disable partial invalidates |
| 83 | */ |
| 84 | static final String RENDER_DIRTY_REGIONS_PROPERTY = "debug.hwui.render_dirty_regions"; |
| 85 | |
| 86 | /** |
| 87 | * System property used to enable or disable hardware rendering profiling. |
| 88 | * The default value of this property is assumed to be false. |
| 89 | * |
| 90 | * When profiling is enabled, the adb shell dumpsys gfxinfo command will |
| 91 | * output extra information about the time taken to execute by the last |
| 92 | * frames. |
| 93 | * |
| 94 | * Possible values: |
| 95 | * "true", to enable profiling |
| 96 | * "visual_bars", to enable profiling and visualize the results on screen |
| 97 | * "false", to disable profiling |
| 98 | * |
| 99 | * @see #PROFILE_PROPERTY_VISUALIZE_BARS |
| 100 | * |
| 101 | * @hide |
| 102 | */ |
| 103 | public static final String PROFILE_PROPERTY = "debug.hwui.profile"; |
| 104 | |
| 105 | /** |
| 106 | * Value for {@link #PROFILE_PROPERTY}. When the property is set to this |
| 107 | * value, profiling data will be visualized on screen as a bar chart. |
| 108 | * |
| 109 | * @hide |
| 110 | */ |
| 111 | public static final String PROFILE_PROPERTY_VISUALIZE_BARS = "visual_bars"; |
| 112 | |
| 113 | /** |
| 114 | * System property used to specify the number of frames to be used |
| 115 | * when doing hardware rendering profiling. |
| 116 | * The default value of this property is #PROFILE_MAX_FRAMES. |
| 117 | * |
| 118 | * When profiling is enabled, the adb shell dumpsys gfxinfo command will |
| 119 | * output extra information about the time taken to execute by the last |
| 120 | * frames. |
| 121 | * |
| 122 | * Possible values: |
| 123 | * "60", to set the limit of frames to 60 |
| 124 | */ |
| 125 | static final String PROFILE_MAXFRAMES_PROPERTY = "debug.hwui.profile.maxframes"; |
| 126 | |
| 127 | /** |
| 128 | * System property used to debug EGL configuration choice. |
| 129 | * |
| 130 | * Possible values: |
| 131 | * "choice", print the chosen configuration only |
| 132 | * "all", print all possible configurations |
| 133 | */ |
| 134 | static final String PRINT_CONFIG_PROPERTY = "debug.hwui.print_config"; |
| 135 | |
| 136 | /** |
| 137 | * Turn on to draw dirty regions every other frame. |
| 138 | * |
| 139 | * Possible values: |
| 140 | * "true", to enable dirty regions debugging |
| 141 | * "false", to disable dirty regions debugging |
| 142 | * |
| 143 | * @hide |
| 144 | */ |
| 145 | public static final String DEBUG_DIRTY_REGIONS_PROPERTY = "debug.hwui.show_dirty_regions"; |
| 146 | |
| 147 | /** |
| 148 | * Turn on to flash hardware layers when they update. |
| 149 | * |
| 150 | * Possible values: |
| 151 | * "true", to enable hardware layers updates debugging |
| 152 | * "false", to disable hardware layers updates debugging |
| 153 | * |
| 154 | * @hide |
| 155 | */ |
| 156 | public static final String DEBUG_SHOW_LAYERS_UPDATES_PROPERTY = |
| 157 | "debug.hwui.show_layers_updates"; |
| 158 | |
| 159 | /** |
| 160 | * Controls overdraw debugging. |
| 161 | * |
| 162 | * Possible values: |
| 163 | * "false", to disable overdraw debugging |
| 164 | * "show", to show overdraw areas on screen |
| 165 | * "count", to display an overdraw counter |
| 166 | * |
| 167 | * @hide |
| 168 | */ |
| 169 | public static final String DEBUG_OVERDRAW_PROPERTY = "debug.hwui.overdraw"; |
| 170 | |
| 171 | /** |
| 172 | * Value for {@link #DEBUG_OVERDRAW_PROPERTY}. When the property is set to this |
| 173 | * value, overdraw will be shown on screen by coloring pixels. |
| 174 | * |
| 175 | * @hide |
| 176 | */ |
| 177 | public static final String OVERDRAW_PROPERTY_SHOW = "show"; |
| 178 | |
| 179 | /** |
| 180 | * Turn on to debug non-rectangular clip operations. |
| 181 | * |
| 182 | * Possible values: |
| 183 | * "hide", to disable this debug mode |
| 184 | * "highlight", highlight drawing commands tested against a non-rectangular clip |
| 185 | * "stencil", renders the clip region on screen when set |
| 186 | * |
| 187 | * @hide |
| 188 | */ |
| 189 | public static final String DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY = |
| 190 | "debug.hwui.show_non_rect_clip"; |
| 191 | |
| 192 | /** |
| 193 | * A process can set this flag to false to prevent the use of hardware |
| 194 | * rendering. |
| 195 | * |
| 196 | * @hide |
| 197 | */ |
| 198 | public static boolean sRendererDisabled = false; |
| 199 | |
| 200 | /** |
| 201 | * Further hardware renderer disabling for the system process. |
| 202 | * |
| 203 | * @hide |
| 204 | */ |
| 205 | public static boolean sSystemRendererDisabled = false; |
| 206 | |
| 207 | /** |
| 208 | * Invoke this method to disable hardware rendering in the current process. |
| 209 | * |
| 210 | * @hide |
| 211 | */ |
| 212 | public static void disable(boolean system) { |
| 213 | sRendererDisabled = true; |
| 214 | if (system) { |
| 215 | sSystemRendererDisabled = true; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | public static boolean sTrimForeground = false; |
| 220 | |
| 221 | /** |
| 222 | * Controls whether or not the hardware renderer should aggressively |
| 223 | * trim memory. Note that this must not be set for any process that |
| 224 | * uses WebView! This should be only used by system_process or similar |
| 225 | * that do not go into the background. |
| 226 | */ |
| 227 | public static void enableForegroundTrimming() { |
| 228 | sTrimForeground = true; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Indicates whether hardware acceleration is available under any form for |
| 233 | * the view hierarchy. |
| 234 | * |
| 235 | * @return True if the view hierarchy can potentially be hardware accelerated, |
| 236 | * false otherwise |
| 237 | */ |
| 238 | public static boolean isAvailable() { |
| 239 | return DisplayListCanvas.isAvailable(); |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Sets the directory to use as a persistent storage for hardware rendering |
| 244 | * resources. |
| 245 | * |
| 246 | * @param cacheDir A directory the current process can write to |
| 247 | * |
| 248 | * @hide |
| 249 | */ |
| 250 | public static void setupDiskCache(File cacheDir) { |
| 251 | ThreadedRenderer.setupShadersDiskCache(new File(cacheDir, CACHE_PATH_SHADERS).getAbsolutePath()); |
| 252 | } |
| 253 | |
| 254 | /** |
Michael Lentine | 03d8f768 | 2016-01-31 15:37:11 -0600 | [diff] [blame] | 255 | * Sets the library directory to use as a search path for vulkan layers. |
| 256 | * |
| 257 | * @param libDir A directory that contains vulkan layers |
| 258 | * |
| 259 | * @hide |
| 260 | */ |
| 261 | public static void setLibDir(String libDir) { |
| 262 | ThreadedRenderer.setupVulkanLayerPath(libDir); |
| 263 | } |
| 264 | |
| 265 | /** |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 266 | * Creates a hardware renderer using OpenGL. |
| 267 | * |
| 268 | * @param translucent True if the surface is translucent, false otherwise |
| 269 | * |
| 270 | * @return A hardware renderer backed by OpenGL. |
| 271 | */ |
| 272 | public static ThreadedRenderer create(Context context, boolean translucent) { |
| 273 | ThreadedRenderer renderer = null; |
| 274 | if (DisplayListCanvas.isAvailable()) { |
| 275 | renderer = new ThreadedRenderer(context, translucent); |
| 276 | } |
| 277 | return renderer; |
| 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Invoke this method when the system is running out of memory. This |
| 282 | * method will attempt to recover as much memory as possible, based on |
| 283 | * the specified hint. |
| 284 | * |
| 285 | * @param level Hint about the amount of memory that should be trimmed, |
| 286 | * see {@link android.content.ComponentCallbacks} |
| 287 | */ |
| 288 | public static void trimMemory(int level) { |
| 289 | nTrimMemory(level); |
| 290 | } |
| 291 | |
| 292 | public static void overrideProperty(@NonNull String name, @NonNull String value) { |
| 293 | if (name == null || value == null) { |
| 294 | throw new IllegalArgumentException("name and value must be non-null"); |
| 295 | } |
| 296 | nOverrideProperty(name, value); |
| 297 | } |
| 298 | |
| 299 | public static void dumpProfileData(byte[] data, FileDescriptor fd) { |
| 300 | nDumpProfileData(data, fd); |
| 301 | } |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 302 | |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 303 | // Keep in sync with DrawFrameTask.h SYNC_* flags |
| 304 | // Nothing interesting to report |
John Reck | cd028f3 | 2014-06-24 08:44:29 -0700 | [diff] [blame] | 305 | private static final int SYNC_OK = 0; |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 306 | // Needs a ViewRoot invalidate |
John Reck | cd028f3 | 2014-06-24 08:44:29 -0700 | [diff] [blame] | 307 | private static final int SYNC_INVALIDATE_REQUIRED = 1 << 0; |
John Reck | aa95a88 | 2014-11-07 11:02:07 -0800 | [diff] [blame] | 308 | // Spoiler: the reward is GPU-accelerated drawing, better find that Surface! |
| 309 | private static final int SYNC_LOST_SURFACE_REWARD_IF_FOUND = 1 << 1; |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 310 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 311 | private static final String[] VISUALIZERS = { |
| 312 | PROFILE_PROPERTY_VISUALIZE_BARS, |
| 313 | }; |
| 314 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 315 | private static final int FLAG_DUMP_FRAMESTATS = 1 << 0; |
| 316 | private static final int FLAG_DUMP_RESET = 1 << 1; |
| 317 | |
| 318 | @IntDef(flag = true, value = { |
| 319 | FLAG_DUMP_FRAMESTATS, FLAG_DUMP_RESET }) |
| 320 | @Retention(RetentionPolicy.SOURCE) |
| 321 | public @interface DumpFlags {} |
| 322 | |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 323 | // Size of the rendered content. |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 324 | private int mWidth, mHeight; |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 325 | |
| 326 | // Actual size of the drawing surface. |
| 327 | private int mSurfaceWidth, mSurfaceHeight; |
| 328 | |
| 329 | // Insets between the drawing surface and rendered content. These are |
| 330 | // applied as translation when updating the root render node. |
| 331 | private int mInsetTop, mInsetLeft; |
| 332 | |
Alan Viverette | 57774a8 | 2014-07-15 15:49:55 -0700 | [diff] [blame] | 333 | // Whether the surface has insets. Used to protect opacity. |
| 334 | private boolean mHasInsets; |
| 335 | |
Alan Viverette | 58c42c3 | 2014-07-12 20:33:45 -0700 | [diff] [blame] | 336 | // Light and shadow properties specified by the theme. |
| 337 | private final float mLightY; |
| 338 | private final float mLightZ; |
| 339 | private final float mLightRadius; |
Chris Craik | 058fc64 | 2014-07-23 18:19:28 -0700 | [diff] [blame] | 340 | private final int mAmbientShadowAlpha; |
| 341 | private final int mSpotShadowAlpha; |
Alan Viverette | 58c42c3 | 2014-07-12 20:33:45 -0700 | [diff] [blame] | 342 | |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 343 | private long mNativeProxy; |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 344 | private boolean mInitialized = false; |
John Reck | bc0cc02 | 2014-04-11 16:08:14 -0700 | [diff] [blame] | 345 | private RenderNode mRootNode; |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 346 | private Choreographer mChoreographer; |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 347 | private boolean mRootNodeNeedsUpdate; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 348 | |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 349 | // In case of multi threaded render nodes, these bounds indicate the content bounds against |
| 350 | // which the backdrop needs to be cropped against. |
| 351 | private final Rect mCurrentContentBounds = new Rect(); |
| 352 | private final Rect mStagedContentBounds = new Rect(); |
| 353 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 354 | private boolean mEnabled; |
| 355 | private boolean mRequested = true; |
| 356 | |
John Reck | b8802b1 | 2014-06-16 15:28:50 -0700 | [diff] [blame] | 357 | ThreadedRenderer(Context context, boolean translucent) { |
Alan Viverette | ed6f14a | 2014-08-26 14:53:28 -0700 | [diff] [blame] | 358 | final TypedArray a = context.obtainStyledAttributes(null, R.styleable.Lighting, 0, 0); |
Alan Viverette | 58c42c3 | 2014-07-12 20:33:45 -0700 | [diff] [blame] | 359 | mLightY = a.getDimension(R.styleable.Lighting_lightY, 0); |
| 360 | mLightZ = a.getDimension(R.styleable.Lighting_lightZ, 0); |
| 361 | mLightRadius = a.getDimension(R.styleable.Lighting_lightRadius, 0); |
Alan Viverette | ed6f14a | 2014-08-26 14:53:28 -0700 | [diff] [blame] | 362 | mAmbientShadowAlpha = |
| 363 | (int) (255 * a.getFloat(R.styleable.Lighting_ambientShadowAlpha, 0) + 0.5f); |
| 364 | mSpotShadowAlpha = (int) (255 * a.getFloat(R.styleable.Lighting_spotShadowAlpha, 0) + 0.5f); |
Alan Viverette | 58c42c3 | 2014-07-12 20:33:45 -0700 | [diff] [blame] | 365 | a.recycle(); |
| 366 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 367 | long rootNodePtr = nCreateRootRenderNode(); |
| 368 | mRootNode = RenderNode.adopt(rootNodePtr); |
John Reck | bc0cc02 | 2014-04-11 16:08:14 -0700 | [diff] [blame] | 369 | mRootNode.setClipToBounds(false); |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 370 | mNativeProxy = nCreateProxy(translucent, rootNodePtr); |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 371 | |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 372 | ProcessInitializer.sInstance.init(context, mNativeProxy); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 373 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 374 | loadSystemProperties(); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 375 | } |
| 376 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 377 | /** |
| 378 | * Destroys the hardware rendering context. |
| 379 | */ |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 380 | void destroy() { |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 381 | mInitialized = false; |
| 382 | updateEnabledState(null); |
Doris Liu | 350e652 | 2016-02-19 14:20:37 -0800 | [diff] [blame] | 383 | nDestroy(mNativeProxy, mRootNode.mNativeRenderNode); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 384 | } |
| 385 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 386 | /** |
| 387 | * Indicates whether hardware acceleration is currently enabled. |
| 388 | * |
| 389 | * @return True if hardware acceleration is in use, false otherwise. |
| 390 | */ |
| 391 | boolean isEnabled() { |
| 392 | return mEnabled; |
| 393 | } |
| 394 | |
| 395 | /** |
| 396 | * Indicates whether hardware acceleration is currently enabled. |
| 397 | * |
| 398 | * @param enabled True if the hardware renderer is in use, false otherwise. |
| 399 | */ |
| 400 | void setEnabled(boolean enabled) { |
| 401 | mEnabled = enabled; |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * Indicates whether hardware acceleration is currently request but not |
| 406 | * necessarily enabled yet. |
| 407 | * |
| 408 | * @return True if requested, false otherwise. |
| 409 | */ |
| 410 | boolean isRequested() { |
| 411 | return mRequested; |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Indicates whether hardware acceleration is currently requested but not |
| 416 | * necessarily enabled yet. |
| 417 | * |
| 418 | * @return True to request hardware acceleration, false otherwise. |
| 419 | */ |
| 420 | void setRequested(boolean requested) { |
| 421 | mRequested = requested; |
| 422 | } |
| 423 | |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 424 | private void updateEnabledState(Surface surface) { |
| 425 | if (surface == null || !surface.isValid()) { |
| 426 | setEnabled(false); |
| 427 | } else { |
| 428 | setEnabled(mInitialized); |
| 429 | } |
| 430 | } |
| 431 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 432 | /** |
| 433 | * Initializes the hardware renderer for the specified surface. |
| 434 | * |
| 435 | * @param surface The surface to hardware accelerate |
| 436 | * |
| 437 | * @return True if the initialization was successful, false otherwise. |
| 438 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 439 | boolean initialize(Surface surface) throws OutOfResourcesException { |
Thomas Buhot | 0bcd0cb | 2015-12-04 12:18:03 +0100 | [diff] [blame] | 440 | boolean status = !mInitialized; |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 441 | mInitialized = true; |
| 442 | updateEnabledState(surface); |
Thomas Buhot | 0bcd0cb | 2015-12-04 12:18:03 +0100 | [diff] [blame] | 443 | nInitialize(mNativeProxy, surface); |
Dan Stoza | 5795d64 | 2014-06-20 13:01:36 -0700 | [diff] [blame] | 444 | return status; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 445 | } |
| 446 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 447 | /** |
| 448 | * Initializes the hardware renderer for the specified surface and setup the |
| 449 | * renderer for drawing, if needed. This is invoked when the ViewAncestor has |
| 450 | * potentially lost the hardware renderer. The hardware renderer should be |
| 451 | * reinitialized and setup when the render {@link #isRequested()} and |
| 452 | * {@link #isEnabled()}. |
| 453 | * |
| 454 | * @param width The width of the drawing surface. |
| 455 | * @param height The height of the drawing surface. |
| 456 | * @param attachInfo Information about the window. |
| 457 | * @param surface The surface to hardware accelerate |
| 458 | * @param surfaceInsets The drawing surface insets to apply |
| 459 | * |
| 460 | * @return true if the surface was initialized, false otherwise. Returning |
| 461 | * false might mean that the surface was already initialized. |
| 462 | */ |
| 463 | boolean initializeIfNeeded(int width, int height, View.AttachInfo attachInfo, |
| 464 | Surface surface, Rect surfaceInsets) throws OutOfResourcesException { |
| 465 | if (isRequested()) { |
| 466 | // We lost the gl context, so recreate it. |
| 467 | if (!isEnabled()) { |
| 468 | if (initialize(surface)) { |
| 469 | setup(width, height, attachInfo, surfaceInsets); |
| 470 | return true; |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | return false; |
| 475 | } |
| 476 | |
| 477 | /** |
| 478 | * Updates the hardware renderer for the specified surface. |
| 479 | * |
| 480 | * @param surface The surface to hardware accelerate |
| 481 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 482 | void updateSurface(Surface surface) throws OutOfResourcesException { |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 483 | updateEnabledState(surface); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 484 | nUpdateSurface(mNativeProxy, surface); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 485 | } |
| 486 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 487 | /** |
John Reck | 945961f | 2016-04-07 16:02:33 -0700 | [diff] [blame] | 488 | * Halts any current rendering into the surface. Use this if it is unclear whether |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 489 | * or not the surface used by the HardwareRenderer will be changing. It |
John Reck | 945961f | 2016-04-07 16:02:33 -0700 | [diff] [blame] | 490 | * Suspends any rendering into the surface, but will not do any destruction. |
| 491 | * |
| 492 | * Any subsequent draws will override the pause, resuming normal operation. |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 493 | */ |
John Reck | 01a5ea3 | 2014-12-03 13:01:07 -0800 | [diff] [blame] | 494 | boolean pauseSurface(Surface surface) { |
| 495 | return nPauseSurface(mNativeProxy, surface); |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 496 | } |
| 497 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 498 | /** |
John Reck | 945961f | 2016-04-07 16:02:33 -0700 | [diff] [blame] | 499 | * Hard stops or resumes rendering into the surface. This flag is used to |
| 500 | * determine whether or not it is safe to use the given surface *at all* |
| 501 | */ |
| 502 | void setStopped(boolean stopped) { |
| 503 | nSetStopped(mNativeProxy, stopped); |
| 504 | } |
| 505 | |
| 506 | /** |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 507 | * Destroys all hardware rendering resources associated with the specified |
| 508 | * view hierarchy. |
| 509 | * |
| 510 | * @param view The root of the view hierarchy |
| 511 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 512 | void destroyHardwareResources(View view) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 513 | destroyResources(view); |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 514 | nDestroyHardwareResources(mNativeProxy); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | private static void destroyResources(View view) { |
| 518 | view.destroyHardwareResources(); |
| 519 | |
| 520 | if (view instanceof ViewGroup) { |
| 521 | ViewGroup group = (ViewGroup) view; |
| 522 | |
| 523 | int count = group.getChildCount(); |
| 524 | for (int i = 0; i < count; i++) { |
| 525 | destroyResources(group.getChildAt(i)); |
| 526 | } |
| 527 | } |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 528 | } |
| 529 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 530 | /** |
| 531 | * This method should be invoked whenever the current hardware renderer |
| 532 | * context should be reset. |
| 533 | * |
| 534 | * @param surface The surface to hardware accelerate |
| 535 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 536 | void invalidate(Surface surface) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 537 | updateSurface(surface); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 538 | } |
| 539 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 540 | /** |
| 541 | * Detaches the layer's surface texture from the GL context and releases |
| 542 | * the texture id |
| 543 | */ |
John Reck | 918ad52 | 2014-06-27 14:45:25 -0700 | [diff] [blame] | 544 | void detachSurfaceTexture(long hardwareLayer) { |
| 545 | nDetachSurfaceTexture(mNativeProxy, hardwareLayer); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 546 | } |
| 547 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 548 | /** |
| 549 | * Sets up the renderer for drawing. |
| 550 | * |
| 551 | * @param width The width of the drawing surface. |
| 552 | * @param height The height of the drawing surface. |
| 553 | * @param attachInfo Information about the window. |
| 554 | * @param surfaceInsets The drawing surface insets to apply |
| 555 | */ |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 556 | void setup(int width, int height, AttachInfo attachInfo, Rect surfaceInsets) { |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 557 | mWidth = width; |
| 558 | mHeight = height; |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 559 | |
Alan Viverette | 3aa1ffb | 2014-10-30 12:22:08 -0700 | [diff] [blame] | 560 | if (surfaceInsets != null && (surfaceInsets.left != 0 || surfaceInsets.right != 0 |
| 561 | || surfaceInsets.top != 0 || surfaceInsets.bottom != 0)) { |
Alan Viverette | 57774a8 | 2014-07-15 15:49:55 -0700 | [diff] [blame] | 562 | mHasInsets = true; |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 563 | mInsetLeft = surfaceInsets.left; |
| 564 | mInsetTop = surfaceInsets.top; |
| 565 | mSurfaceWidth = width + mInsetLeft + surfaceInsets.right; |
| 566 | mSurfaceHeight = height + mInsetTop + surfaceInsets.bottom; |
Alan Viverette | 57774a8 | 2014-07-15 15:49:55 -0700 | [diff] [blame] | 567 | |
| 568 | // If the surface has insets, it can't be opaque. |
| 569 | setOpaque(false); |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 570 | } else { |
Alan Viverette | 57774a8 | 2014-07-15 15:49:55 -0700 | [diff] [blame] | 571 | mHasInsets = false; |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 572 | mInsetLeft = 0; |
| 573 | mInsetTop = 0; |
| 574 | mSurfaceWidth = width; |
| 575 | mSurfaceHeight = height; |
| 576 | } |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 577 | |
Alan Viverette | ccb11e1 | 2014-07-08 16:04:02 -0700 | [diff] [blame] | 578 | mRootNode.setLeftTopRightBottom(-mInsetLeft, -mInsetTop, mSurfaceWidth, mSurfaceHeight); |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 579 | nSetup(mNativeProxy, mSurfaceWidth, mSurfaceHeight, mLightRadius, |
John Reck | b36016c | 2015-03-11 08:50:53 -0700 | [diff] [blame] | 580 | mAmbientShadowAlpha, mSpotShadowAlpha); |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 581 | |
| 582 | setLightCenter(attachInfo); |
| 583 | } |
| 584 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 585 | /** |
| 586 | * Updates the light position based on the position of the window. |
| 587 | * |
| 588 | * @param attachInfo Information about the window. |
| 589 | */ |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 590 | void setLightCenter(AttachInfo attachInfo) { |
| 591 | // Adjust light position for window offsets. |
| 592 | final Point displaySize = attachInfo.mPoint; |
| 593 | attachInfo.mDisplay.getRealSize(displaySize); |
| 594 | final float lightX = displaySize.x / 2f - attachInfo.mWindowLeft; |
| 595 | final float lightY = mLightY - attachInfo.mWindowTop; |
| 596 | |
| 597 | nSetLightCenter(mNativeProxy, lightX, lightY, mLightZ); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 598 | } |
| 599 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 600 | /** |
| 601 | * Change the HardwareRenderer's opacity |
| 602 | */ |
John Reck | 63a0667 | 2014-05-07 13:45:54 -0700 | [diff] [blame] | 603 | void setOpaque(boolean opaque) { |
Alan Viverette | 57774a8 | 2014-07-15 15:49:55 -0700 | [diff] [blame] | 604 | nSetOpaque(mNativeProxy, opaque && !mHasInsets); |
John Reck | 63a0667 | 2014-05-07 13:45:54 -0700 | [diff] [blame] | 605 | } |
| 606 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 607 | /** |
| 608 | * Gets the current width of the surface. This is the width that the surface |
| 609 | * was last set to in a call to {@link #setup(int, int, View.AttachInfo, Rect)}. |
| 610 | * |
| 611 | * @return the current width of the surface |
| 612 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 613 | int getWidth() { |
| 614 | return mWidth; |
| 615 | } |
| 616 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 617 | /** |
| 618 | * Gets the current height of the surface. This is the height that the surface |
| 619 | * was last set to in a call to {@link #setup(int, int, View.AttachInfo, Rect)}. |
| 620 | * |
| 621 | * @return the current width of the surface |
| 622 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 623 | int getHeight() { |
| 624 | return mHeight; |
| 625 | } |
| 626 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 627 | /** |
| 628 | * Outputs extra debugging information in the specified file descriptor. |
| 629 | */ |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 630 | void dumpGfxInfo(PrintWriter pw, FileDescriptor fd, String[] args) { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 631 | pw.flush(); |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 632 | int flags = 0; |
| 633 | for (int i = 0; i < args.length; i++) { |
| 634 | switch (args[i]) { |
| 635 | case "framestats": |
| 636 | flags |= FLAG_DUMP_FRAMESTATS; |
| 637 | break; |
| 638 | case "reset": |
| 639 | flags |= FLAG_DUMP_RESET; |
| 640 | break; |
| 641 | } |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 642 | } |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 643 | nDumpProfileInfo(mNativeProxy, fd, flags); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 644 | } |
| 645 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 646 | /** |
| 647 | * Loads system properties used by the renderer. This method is invoked |
| 648 | * whenever system properties are modified. Implementations can use this |
| 649 | * to trigger live updates of the renderer based on properties. |
| 650 | * |
| 651 | * @return True if a property has changed. |
| 652 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 653 | boolean loadSystemProperties() { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 654 | boolean changed = nLoadSystemProperties(mNativeProxy); |
John Reck | 23d307c | 2014-10-27 12:38:48 -0700 | [diff] [blame] | 655 | if (changed) { |
| 656 | invalidateRoot(); |
| 657 | } |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 658 | return changed; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 659 | } |
| 660 | |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 661 | private void updateViewTreeDisplayList(View view) { |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 662 | view.mPrivateFlags |= View.PFLAG_DRAWN; |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 663 | view.mRecreateDisplayList = (view.mPrivateFlags & View.PFLAG_INVALIDATED) |
| 664 | == View.PFLAG_INVALIDATED; |
| 665 | view.mPrivateFlags &= ~View.PFLAG_INVALIDATED; |
Chris Craik | 31a2d06 | 2015-05-01 14:22:47 -0700 | [diff] [blame] | 666 | view.updateDisplayListIfDirty(); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 667 | view.mRecreateDisplayList = false; |
John Reck | bc0cc02 | 2014-04-11 16:08:14 -0700 | [diff] [blame] | 668 | } |
| 669 | |
John Reck | 61375a8 | 2014-09-18 19:27:48 +0000 | [diff] [blame] | 670 | private void updateRootDisplayList(View view, HardwareDrawCallbacks callbacks) { |
Chris Craik | 70850ea | 2014-11-18 10:49:23 -0800 | [diff] [blame] | 671 | Trace.traceBegin(Trace.TRACE_TAG_VIEW, "Record View#draw()"); |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 672 | updateViewTreeDisplayList(view); |
| 673 | |
| 674 | if (mRootNodeNeedsUpdate || !mRootNode.isValid()) { |
Chris Craik | f6829a0 | 2015-03-10 10:28:59 -0700 | [diff] [blame] | 675 | DisplayListCanvas canvas = mRootNode.start(mSurfaceWidth, mSurfaceHeight); |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 676 | try { |
Alan Viverette | dbed893 | 2014-08-06 17:54:52 -0700 | [diff] [blame] | 677 | final int saveCount = canvas.save(); |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 678 | canvas.translate(mInsetLeft, mInsetTop); |
| 679 | callbacks.onHardwarePreDraw(canvas); |
Chris Craik | abedca3 | 2014-08-28 15:03:55 -0700 | [diff] [blame] | 680 | |
| 681 | canvas.insertReorderBarrier(); |
Chris Craik | 31a2d06 | 2015-05-01 14:22:47 -0700 | [diff] [blame] | 682 | canvas.drawRenderNode(view.updateDisplayListIfDirty()); |
Chris Craik | abedca3 | 2014-08-28 15:03:55 -0700 | [diff] [blame] | 683 | canvas.insertInorderBarrier(); |
| 684 | |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 685 | callbacks.onHardwarePostDraw(canvas); |
Alan Viverette | dbed893 | 2014-08-06 17:54:52 -0700 | [diff] [blame] | 686 | canvas.restoreToCount(saveCount); |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 687 | mRootNodeNeedsUpdate = false; |
| 688 | } finally { |
| 689 | mRootNode.end(canvas); |
| 690 | } |
| 691 | } |
| 692 | Trace.traceEnd(Trace.TRACE_TAG_VIEW); |
| 693 | } |
| 694 | |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 695 | /** |
| 696 | * Adds a rendernode to the renderer which can be drawn and changed asynchronously to the |
| 697 | * rendernode of the UI thread. |
| 698 | * @param node The node to add. |
| 699 | * @param placeFront If true, the render node will be placed in front of the content node, |
| 700 | * otherwise behind the content node. |
| 701 | */ |
| 702 | public void addRenderNode(RenderNode node, boolean placeFront) { |
| 703 | nAddRenderNode(mNativeProxy, node.mNativeRenderNode, placeFront); |
| 704 | } |
| 705 | |
| 706 | /** |
| 707 | * Only especially added render nodes can be removed. |
| 708 | * @param node The node which was added via addRenderNode which should get removed again. |
| 709 | */ |
| 710 | public void removeRenderNode(RenderNode node) { |
| 711 | nRemoveRenderNode(mNativeProxy, node.mNativeRenderNode); |
| 712 | } |
| 713 | |
| 714 | /** |
| 715 | * Draws a particular render node. If the node is not the content node, only the additional |
| 716 | * nodes will get drawn and the content remains untouched. |
| 717 | * @param node The node to be drawn. |
| 718 | */ |
| 719 | public void drawRenderNode(RenderNode node) { |
| 720 | nDrawRenderNode(mNativeProxy, node.mNativeRenderNode); |
| 721 | } |
| 722 | |
| 723 | /** |
| 724 | * To avoid unnecessary overdrawing of the main content all additionally passed render nodes |
| 725 | * will be prevented to overdraw this area. It will be synchronized with the draw call. |
| 726 | * This should be updated in the content view's draw call. |
| 727 | * @param left The left side of the protected bounds. |
| 728 | * @param top The top side of the protected bounds. |
| 729 | * @param right The right side of the protected bounds. |
| 730 | * @param bottom The bottom side of the protected bounds. |
| 731 | */ |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 732 | public void setContentDrawBounds(int left, int top, int right, int bottom) { |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 733 | mStagedContentBounds.set(left, top, right, bottom); |
| 734 | } |
| 735 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 736 | /** |
| 737 | * Interface used to receive callbacks whenever a view is drawn by |
| 738 | * a hardware renderer instance. |
| 739 | */ |
| 740 | interface HardwareDrawCallbacks { |
| 741 | /** |
| 742 | * Invoked before a view is drawn by a hardware renderer. |
| 743 | * This method can be used to apply transformations to the |
| 744 | * canvas but no drawing command should be issued. |
| 745 | * |
| 746 | * @param canvas The Canvas used to render the view. |
| 747 | */ |
| 748 | void onHardwarePreDraw(DisplayListCanvas canvas); |
| 749 | |
| 750 | /** |
| 751 | * Invoked after a view is drawn by a hardware renderer. |
| 752 | * It is safe to invoke drawing commands from this method. |
| 753 | * |
| 754 | * @param canvas The Canvas used to render the view. |
| 755 | */ |
| 756 | void onHardwarePostDraw(DisplayListCanvas canvas); |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * Indicates that the content drawn by HardwareDrawCallbacks needs to |
| 761 | * be updated, which will be done by the next call to draw() |
| 762 | */ |
John Reck | 0a97330 | 2014-07-16 13:29:45 -0700 | [diff] [blame] | 763 | void invalidateRoot() { |
| 764 | mRootNodeNeedsUpdate = true; |
| 765 | } |
| 766 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 767 | /** |
| 768 | * Draws the specified view. |
| 769 | * |
| 770 | * @param view The view to draw. |
| 771 | * @param attachInfo AttachInfo tied to the specified view. |
| 772 | * @param callbacks Callbacks invoked when drawing happens. |
| 773 | */ |
John Reck | 61375a8 | 2014-09-18 19:27:48 +0000 | [diff] [blame] | 774 | void draw(View view, AttachInfo attachInfo, HardwareDrawCallbacks callbacks) { |
John Reck | bc0cc02 | 2014-04-11 16:08:14 -0700 | [diff] [blame] | 775 | attachInfo.mIgnoreDirtyState = true; |
John Reck | bc0cc02 | 2014-04-11 16:08:14 -0700 | [diff] [blame] | 776 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 777 | final Choreographer choreographer = attachInfo.mViewRootImpl.mChoreographer; |
| 778 | choreographer.mFrameInfo.markDrawStart(); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 779 | |
John Reck | 61375a8 | 2014-09-18 19:27:48 +0000 | [diff] [blame] | 780 | updateRootDisplayList(view, callbacks); |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 781 | // The main content view was updating the content bounds and we transfer them to the |
| 782 | // renderer. |
| 783 | if (!mCurrentContentBounds.equals(mStagedContentBounds)) { |
| 784 | mCurrentContentBounds.set(mStagedContentBounds); |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 785 | nSetContentDrawBounds(mNativeProxy, mCurrentContentBounds.left, |
| 786 | mCurrentContentBounds.top, mCurrentContentBounds.right, |
| 787 | mCurrentContentBounds.bottom); |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 788 | } |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 789 | |
John Reck | 6313b92 | 2014-04-16 18:59:21 -0700 | [diff] [blame] | 790 | attachInfo.mIgnoreDirtyState = false; |
| 791 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 792 | // register animating rendernodes which started animating prior to renderer |
| 793 | // creation, which is typical for animators started prior to first draw |
| 794 | if (attachInfo.mPendingAnimatingRenderNodes != null) { |
| 795 | final int count = attachInfo.mPendingAnimatingRenderNodes.size(); |
| 796 | for (int i = 0; i < count; i++) { |
| 797 | registerAnimatingRenderNode( |
| 798 | attachInfo.mPendingAnimatingRenderNodes.get(i)); |
| 799 | } |
| 800 | attachInfo.mPendingAnimatingRenderNodes.clear(); |
| 801 | // We don't need this anymore as subsequent calls to |
| 802 | // ViewRootImpl#attachRenderNodeAnimator will go directly to us. |
| 803 | attachInfo.mPendingAnimatingRenderNodes = null; |
| 804 | } |
| 805 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 806 | final long[] frameInfo = choreographer.mFrameInfo.mFrameInfo; |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame] | 807 | int syncResult = nSyncAndDrawFrame(mNativeProxy, frameInfo, frameInfo.length); |
John Reck | aa95a88 | 2014-11-07 11:02:07 -0800 | [diff] [blame] | 808 | if ((syncResult & SYNC_LOST_SURFACE_REWARD_IF_FOUND) != 0) { |
| 809 | setEnabled(false); |
John Reck | b13de07 | 2014-11-19 16:33:47 -0800 | [diff] [blame] | 810 | attachInfo.mViewRootImpl.mSurface.release(); |
John Reck | aa95a88 | 2014-11-07 11:02:07 -0800 | [diff] [blame] | 811 | // Invalidate since we failed to draw. This should fetch a Surface |
| 812 | // if it is still needed or do nothing if we are no longer drawing |
| 813 | attachInfo.mViewRootImpl.invalidate(); |
| 814 | } |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 815 | if ((syncResult & SYNC_INVALIDATE_REQUIRED) != 0) { |
| 816 | attachInfo.mViewRootImpl.invalidate(); |
| 817 | } |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 818 | } |
| 819 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 820 | static void invokeFunctor(long functor, boolean waitForCompletion) { |
| 821 | nInvokeFunctor(functor, waitForCompletion); |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 822 | } |
| 823 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 824 | /** |
| 825 | * Creates a new hardware layer. A hardware layer built by calling this |
| 826 | * method will be treated as a texture layer, instead of as a render target. |
| 827 | * |
| 828 | * @return A hardware layer |
| 829 | */ |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 830 | HardwareLayer createTextureLayer() { |
| 831 | long layer = nCreateTextureLayer(mNativeProxy); |
| 832 | return HardwareLayer.adoptTextureLayer(this, layer); |
| 833 | } |
| 834 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 835 | |
John Reck | 3e82495 | 2014-08-20 10:08:39 -0700 | [diff] [blame] | 836 | void buildLayer(RenderNode node) { |
| 837 | nBuildLayer(mNativeProxy, node.getNativeDisplayList()); |
| 838 | } |
| 839 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 840 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 841 | boolean copyLayerInto(final HardwareLayer layer, final Bitmap bitmap) { |
| 842 | return nCopyLayerInto(mNativeProxy, |
John Reck | 3731dc2 | 2015-04-13 15:20:29 -0700 | [diff] [blame] | 843 | layer.getDeferredLayerUpdater(), bitmap); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 844 | } |
| 845 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 846 | /** |
| 847 | * Indicates that the specified hardware layer needs to be updated |
| 848 | * as soon as possible. |
| 849 | * |
| 850 | * @param layer The hardware layer that needs an update |
| 851 | */ |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 852 | void pushLayerUpdate(HardwareLayer layer) { |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 853 | nPushLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater()); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 854 | } |
| 855 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 856 | /** |
| 857 | * Tells the HardwareRenderer that the layer is destroyed. The renderer |
| 858 | * should remove the layer from any update queues. |
| 859 | */ |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 860 | void onLayerDestroyed(HardwareLayer layer) { |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 861 | nCancelLayerUpdate(mNativeProxy, layer.getDeferredLayerUpdater()); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 862 | } |
| 863 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 864 | /** |
| 865 | * Optional, sets the name of the renderer. Useful for debugging purposes. |
| 866 | * |
| 867 | * @param name The name of this renderer, can be null |
| 868 | */ |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 869 | void setName(String name) { |
John Reck | b36016c | 2015-03-11 08:50:53 -0700 | [diff] [blame] | 870 | nSetName(mNativeProxy, name); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 871 | } |
| 872 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 873 | /** |
| 874 | * Blocks until all previously queued work has completed. |
| 875 | */ |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 876 | void fence() { |
| 877 | nFence(mNativeProxy); |
| 878 | } |
| 879 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 880 | /** |
| 881 | * Prevents any further drawing until draw() is called. This is a signal |
| 882 | * that the contents of the RenderNode tree are no longer safe to play back. |
| 883 | * In practice this usually means that there are Functor pointers in the |
| 884 | * display list that are no longer valid. |
| 885 | */ |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 886 | void stopDrawing() { |
| 887 | nStopDrawing(mNativeProxy); |
| 888 | } |
| 889 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 890 | /** |
| 891 | * Called by {@link ViewRootImpl} when a new performTraverals is scheduled. |
| 892 | */ |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 893 | public void notifyFramePending() { |
| 894 | nNotifyFramePending(mNativeProxy); |
| 895 | } |
| 896 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 897 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 898 | void registerAnimatingRenderNode(RenderNode animator) { |
| 899 | nRegisterAnimatingRenderNode(mRootNode.mNativeRenderNode, animator.mNativeRenderNode); |
| 900 | } |
| 901 | |
John Reck | e248bd1 | 2015-08-05 13:53:53 -0700 | [diff] [blame] | 902 | public void serializeDisplayListTree() { |
| 903 | nSerializeDisplayListTree(mNativeProxy); |
| 904 | } |
| 905 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 906 | @Override |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 907 | protected void finalize() throws Throwable { |
| 908 | try { |
| 909 | nDeleteProxy(mNativeProxy); |
John Reck | 0ed751d | 2014-04-08 14:10:17 -0700 | [diff] [blame] | 910 | mNativeProxy = 0; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 911 | } finally { |
| 912 | super.finalize(); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 913 | } |
| 914 | } |
| 915 | |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 916 | private static class ProcessInitializer { |
| 917 | static ProcessInitializer sInstance = new ProcessInitializer(); |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 918 | private static IBinder sProcToken; |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 919 | |
| 920 | private boolean mInitialized = false; |
| 921 | |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 922 | private ProcessInitializer() {} |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 923 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 924 | synchronized void init(Context context, long renderProxy) { |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 925 | if (mInitialized) return; |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 926 | mInitialized = true; |
| 927 | initGraphicsStats(context, renderProxy); |
| 928 | initAssetAtlas(context, renderProxy); |
| 929 | } |
| 930 | |
| 931 | private static void initGraphicsStats(Context context, long renderProxy) { |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 932 | try { |
John Reck | 828698b | 2015-06-30 12:56:03 -0700 | [diff] [blame] | 933 | IBinder binder = ServiceManager.getService("graphicsstats"); |
| 934 | if (binder == null) return; |
| 935 | IGraphicsStats graphicsStatsService = IGraphicsStats.Stub |
| 936 | .asInterface(binder); |
| 937 | sProcToken = new Binder(); |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 938 | final String pkg = context.getApplicationInfo().packageName; |
John Reck | 828698b | 2015-06-30 12:56:03 -0700 | [diff] [blame] | 939 | ParcelFileDescriptor pfd = graphicsStatsService. |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 940 | requestBufferForProcess(pkg, sProcToken); |
| 941 | nSetProcessStatsBuffer(renderProxy, pfd.getFd()); |
| 942 | pfd.close(); |
John Reck | 828698b | 2015-06-30 12:56:03 -0700 | [diff] [blame] | 943 | } catch (Throwable t) { |
| 944 | Log.w(LOG_TAG, "Could not acquire gfx stats buffer", t); |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 945 | } |
| 946 | } |
| 947 | |
| 948 | private static void initAssetAtlas(Context context, long renderProxy) { |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 949 | IBinder binder = ServiceManager.getService("assetatlas"); |
| 950 | if (binder == null) return; |
| 951 | |
| 952 | IAssetAtlas atlas = IAssetAtlas.Stub.asInterface(binder); |
| 953 | try { |
| 954 | if (atlas.isCompatible(android.os.Process.myPpid())) { |
| 955 | GraphicBuffer buffer = atlas.getBuffer(); |
| 956 | if (buffer != null) { |
| 957 | long[] map = atlas.getMap(); |
| 958 | if (map != null) { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 959 | nSetAtlas(renderProxy, buffer, map); |
John Reck | 66f0be6 | 2014-05-13 13:39:31 -0700 | [diff] [blame] | 960 | } |
| 961 | // If IAssetAtlas is not the same class as the IBinder |
| 962 | // we are using a remote service and we can safely |
| 963 | // destroy the graphic buffer |
| 964 | if (atlas.getClass() != binder.getClass()) { |
| 965 | buffer.destroy(); |
| 966 | } |
| 967 | } |
| 968 | } |
| 969 | } catch (RemoteException e) { |
| 970 | Log.w(LOG_TAG, "Could not acquire atlas", e); |
| 971 | } |
| 972 | } |
| 973 | } |
| 974 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 975 | void addFrameMetricsObserver(FrameMetricsObserver observer) { |
| 976 | long nativeObserver = nAddFrameMetricsObserver(mNativeProxy, observer); |
| 977 | observer.mNative = new VirtualRefBasePtr(nativeObserver); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 978 | } |
| 979 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 980 | void removeFrameMetricsObserver(FrameMetricsObserver observer) { |
| 981 | nRemoveFrameMetricsObserver(mNativeProxy, observer.mNative.get()); |
| 982 | observer.mNative = null; |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 983 | } |
| 984 | |
John Reck | 84a4c88 | 2014-05-30 14:34:03 -0700 | [diff] [blame] | 985 | static native void setupShadersDiskCache(String cacheFile); |
Michael Lentine | 03d8f768 | 2016-01-31 15:37:11 -0600 | [diff] [blame] | 986 | static native void setupVulkanLayerPath(String layerPath); |
John Reck | 84a4c88 | 2014-05-30 14:34:03 -0700 | [diff] [blame] | 987 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 988 | private static native void nSetAtlas(long nativeProxy, GraphicBuffer buffer, long[] map); |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 989 | private static native void nSetProcessStatsBuffer(long nativeProxy, int fd); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 990 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 991 | private static native long nCreateRootRenderNode(); |
| 992 | private static native long nCreateProxy(boolean translucent, long rootRenderNode); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 993 | private static native void nDeleteProxy(long nativeProxy); |
| 994 | |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 995 | private static native boolean nLoadSystemProperties(long nativeProxy); |
John Reck | b36016c | 2015-03-11 08:50:53 -0700 | [diff] [blame] | 996 | private static native void nSetName(long nativeProxy, String name); |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 997 | |
Thomas Buhot | 0bcd0cb | 2015-12-04 12:18:03 +0100 | [diff] [blame] | 998 | private static native void nInitialize(long nativeProxy, Surface window); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 999 | private static native void nUpdateSurface(long nativeProxy, Surface window); |
John Reck | 01a5ea3 | 2014-12-03 13:01:07 -0800 | [diff] [blame] | 1000 | private static native boolean nPauseSurface(long nativeProxy, Surface window); |
John Reck | 945961f | 2016-04-07 16:02:33 -0700 | [diff] [blame] | 1001 | private static native void nSetStopped(long nativeProxy, boolean stopped); |
Chris Craik | 797b95b | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 1002 | private static native void nSetup(long nativeProxy, int width, int height, |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 1003 | float lightRadius, int ambientShadowAlpha, int spotShadowAlpha); |
| 1004 | private static native void nSetLightCenter(long nativeProxy, |
| 1005 | float lightX, float lightY, float lightZ); |
John Reck | 63a0667 | 2014-05-07 13:45:54 -0700 | [diff] [blame] | 1006 | private static native void nSetOpaque(long nativeProxy, boolean opaque); |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame] | 1007 | private static native int nSyncAndDrawFrame(long nativeProxy, long[] frameInfo, int size); |
Doris Liu | 350e652 | 2016-02-19 14:20:37 -0800 | [diff] [blame] | 1008 | private static native void nDestroy(long nativeProxy, long rootRenderNode); |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 1009 | private static native void nRegisterAnimatingRenderNode(long rootRenderNode, long animatingNode); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 1010 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 1011 | private static native void nInvokeFunctor(long functor, boolean waitForCompletion); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 1012 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 1013 | private static native long nCreateTextureLayer(long nativeProxy); |
John Reck | 3e82495 | 2014-08-20 10:08:39 -0700 | [diff] [blame] | 1014 | private static native void nBuildLayer(long nativeProxy, long node); |
John Reck | 3731dc2 | 2015-04-13 15:20:29 -0700 | [diff] [blame] | 1015 | private static native boolean nCopyLayerInto(long nativeProxy, long layer, Bitmap bitmap); |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 1016 | private static native void nPushLayerUpdate(long nativeProxy, long layer); |
| 1017 | private static native void nCancelLayerUpdate(long nativeProxy, long layer); |
John Reck | 918ad52 | 2014-06-27 14:45:25 -0700 | [diff] [blame] | 1018 | private static native void nDetachSurfaceTexture(long nativeProxy, long layer); |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 1019 | |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 1020 | private static native void nDestroyHardwareResources(long nativeProxy); |
| 1021 | private static native void nTrimMemory(int level); |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 1022 | private static native void nOverrideProperty(String name, String value); |
John Reck | e1628b7 | 2014-05-23 15:11:19 -0700 | [diff] [blame] | 1023 | |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 1024 | private static native void nFence(long nativeProxy); |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 1025 | private static native void nStopDrawing(long nativeProxy); |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 1026 | private static native void nNotifyFramePending(long nativeProxy); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 1027 | |
John Reck | e248bd1 | 2015-08-05 13:53:53 -0700 | [diff] [blame] | 1028 | private static native void nSerializeDisplayListTree(long nativeProxy); |
| 1029 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 1030 | private static native void nDumpProfileInfo(long nativeProxy, FileDescriptor fd, |
| 1031 | @DumpFlags int dumpFlags); |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 1032 | private static native void nDumpProfileData(byte[] data, FileDescriptor fd); |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 1033 | |
| 1034 | private static native void nAddRenderNode(long nativeProxy, long rootRenderNode, |
| 1035 | boolean placeFront); |
| 1036 | private static native void nRemoveRenderNode(long nativeProxy, long rootRenderNode); |
| 1037 | private static native void nDrawRenderNode(long nativeProxy, long rootRenderNode); |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 1038 | private static native void nSetContentDrawBounds(long nativeProxy, int left, |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 1039 | int top, int right, int bottom); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 1040 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 1041 | private static native long nAddFrameMetricsObserver(long nativeProxy, FrameMetricsObserver observer); |
| 1042 | private static native void nRemoveFrameMetricsObserver(long nativeProxy, long nativeObserver); |
John Reck | cec24ae | 2013-11-05 13:27:50 -0800 | [diff] [blame] | 1043 | } |