OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.compositor; | 5 package org.chromium.chrome.browser.compositor; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.graphics.Color; | 9 import android.graphics.Color; |
10 import android.graphics.PixelFormat; | 10 import android.graphics.PixelFormat; |
11 import android.graphics.Rect; | 11 import android.graphics.Rect; |
12 import android.graphics.drawable.Drawable; | |
12 import android.os.Build; | 13 import android.os.Build; |
13 import android.view.Display; | 14 import android.view.Display; |
14 import android.view.MotionEvent; | 15 import android.view.MotionEvent; |
15 import android.view.Surface; | 16 import android.view.Surface; |
16 import android.view.SurfaceHolder; | 17 import android.view.SurfaceHolder; |
17 import android.view.SurfaceView; | 18 import android.view.SurfaceView; |
18 import android.view.View; | 19 import android.view.View; |
19 import android.view.WindowManager; | 20 import android.view.WindowManager; |
21 import android.widget.FrameLayout; | |
20 | 22 |
21 import org.chromium.base.CommandLine; | 23 import org.chromium.base.CommandLine; |
22 import org.chromium.base.Log; | |
23 import org.chromium.base.TraceEvent; | 24 import org.chromium.base.TraceEvent; |
24 import org.chromium.base.annotations.CalledByNative; | 25 import org.chromium.base.annotations.CalledByNative; |
25 import org.chromium.base.annotations.JNINamespace; | 26 import org.chromium.base.annotations.JNINamespace; |
26 import org.chromium.chrome.browser.ChromeSwitches; | 27 import org.chromium.chrome.browser.ChromeSwitches; |
27 import org.chromium.chrome.browser.compositor.layouts.Layout; | 28 import org.chromium.chrome.browser.compositor.layouts.Layout; |
28 import org.chromium.chrome.browser.compositor.layouts.LayoutProvider; | 29 import org.chromium.chrome.browser.compositor.layouts.LayoutProvider; |
29 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; | 30 import org.chromium.chrome.browser.compositor.layouts.LayoutRenderHost; |
30 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; | 31 import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
31 import org.chromium.chrome.browser.compositor.resources.StaticResourcePreloads; | 32 import org.chromium.chrome.browser.compositor.resources.StaticResourcePreloads; |
32 import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer; | 33 import org.chromium.chrome.browser.compositor.scene_layer.SceneLayer; |
33 import org.chromium.chrome.browser.externalnav.IntentWithGesturesHandler; | 34 import org.chromium.chrome.browser.externalnav.IntentWithGesturesHandler; |
34 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; | 35 import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
35 import org.chromium.chrome.browser.tabmodel.TabModelImpl; | 36 import org.chromium.chrome.browser.tabmodel.TabModelImpl; |
36 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo; | 37 import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo; |
37 import org.chromium.ui.base.DeviceFormFactor; | 38 import org.chromium.ui.base.DeviceFormFactor; |
38 import org.chromium.ui.base.WindowAndroid; | 39 import org.chromium.ui.base.WindowAndroid; |
39 import org.chromium.ui.resources.AndroidResourceType; | 40 import org.chromium.ui.resources.AndroidResourceType; |
40 import org.chromium.ui.resources.ResourceManager; | 41 import org.chromium.ui.resources.ResourceManager; |
41 | 42 |
42 /** | 43 /** |
43 * The is the {@link View} displaying the ui compositor results; including webpa ges and tabswitcher. | 44 * The is the {@link View} displaying the ui compositor results; including webpa ges and tabswitcher. |
44 */ | 45 */ |
45 @JNINamespace("android") | 46 @JNINamespace("android") |
46 public class CompositorView | 47 public class CompositorView extends FrameLayout implements SurfaceHolder.Callbac k { |
47 extends SurfaceView implements SurfaceHolder.Callback { | |
48 private static final String TAG = "CompositorView"; | 48 private static final String TAG = "CompositorView"; |
49 private static final long NANOSECONDS_PER_MILLISECOND = 1000000; | 49 private static final long NANOSECONDS_PER_MILLISECOND = 1000000; |
50 | 50 |
51 // Cache objects that should not be created every frame | 51 // Cache objects that should not be created every frame |
52 private final Rect mCacheAppRect = new Rect(); | 52 private final Rect mCacheAppRect = new Rect(); |
53 private final int[] mCacheViewPosition = new int[2]; | 53 private final int[] mCacheViewPosition = new int[2]; |
54 | 54 |
55 private CompositorSurfaceManager mCompositorSurfaceManager; | |
56 private boolean mOverlayVideoEnabled; | |
57 private boolean mAlwaysTranslucent; | |
58 | |
59 // Are we waiting to hide the outgoing surface until the foreground has some thing to display? | |
60 // If == 0, then no. If > 0, then yes. We'll hide when it transitions from one to zero. | |
61 private int mFramesUntilHideBackground; | |
62 | |
63 // Cache of setWillNotDraw, which we keep up to date if we switch SVs. | |
64 private boolean mWillNotDraw; | |
65 | |
55 private long mNativeCompositorView; | 66 private long mNativeCompositorView; |
56 private final LayoutRenderHost mRenderHost; | 67 private final LayoutRenderHost mRenderHost; |
57 private boolean mEnableTabletTabStack; | 68 private boolean mEnableTabletTabStack; |
58 private int mPreviousWindowTop = -1; | 69 private int mPreviousWindowTop = -1; |
59 | 70 |
60 // A conservative estimate of when a frame is guaranteed to be presented aft er being submitted. | 71 // A conservative estimate of when a frame is guaranteed to be presented aft er being submitted. |
61 private long mFramePresentationDelay; | 72 private long mFramePresentationDelay; |
62 | 73 |
63 // Resource Management | 74 // Resource Management |
64 private ResourceManager mResourceManager; | 75 private ResourceManager mResourceManager; |
65 | 76 |
66 // Lazily populated as it is needed. | 77 // Lazily populated as it is needed. |
67 private View mRootActivityView; | 78 private View mRootActivityView; |
68 private WindowAndroid mWindowAndroid; | 79 private WindowAndroid mWindowAndroid; |
69 private LayerTitleCache mLayerTitleCache; | 80 private LayerTitleCache mLayerTitleCache; |
70 private TabContentManager mTabContentManager; | 81 private TabContentManager mTabContentManager; |
71 | 82 |
72 private View mRootView; | 83 private View mRootView; |
73 private int mSurfaceWidth; | |
74 private int mSurfaceHeight; | |
75 private boolean mPreloadedResources; | 84 private boolean mPreloadedResources; |
76 | 85 |
77 // The current SurfaceView pixel format. Defaults to OPAQUE. | |
78 private int mCurrentPixelFormat = PixelFormat.OPAQUE; | |
79 | |
80 /** | 86 /** |
81 * Creates a {@link CompositorView}. This can be called only after the nativ e library is | 87 * Creates a {@link CompositorView}. This can be called only after the |
82 * properly loaded. | 88 * native library is properly loaded. |
David Trainor- moved to gerrit
2017/02/07 19:36:16
Move back up? 100 columns for Java.
liberato (no reviews please)
2017/02/14 17:22:24
Done.
| |
83 * @param c The Context to create this {@link CompositorView} in. | 89 * @param c The Context to create this {@link CompositorView} in. |
84 * @param host The renderer host owning this view. | 90 * @param host The renderer host owning this view. |
85 */ | 91 */ |
86 public CompositorView(Context c, LayoutRenderHost host) { | 92 public CompositorView(Context c, LayoutRenderHost host) { |
87 super(c); | 93 super(c); |
88 mRenderHost = host; | 94 mRenderHost = host; |
89 resetFlags(); | 95 resetFlags(); |
96 | |
90 setVisibility(View.INVISIBLE); | 97 setVisibility(View.INVISIBLE); |
91 setZOrderMediaOverlay(true); | |
92 } | 98 } |
93 | 99 |
94 /** | 100 /** |
95 * @param view The root view of the hierarchy. | 101 * @param view The root view of the hierarchy. |
96 */ | 102 */ |
97 public void setRootView(View view) { | 103 public void setRootView(View view) { |
98 mRootView = view; | 104 mRootView = view; |
99 } | 105 } |
100 | 106 |
101 /** | 107 /** |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 * @return The ResourceManager. | 156 * @return The ResourceManager. |
151 */ | 157 */ |
152 public ResourceManager getResourceManager() { | 158 public ResourceManager getResourceManager() { |
153 return mResourceManager; | 159 return mResourceManager; |
154 } | 160 } |
155 | 161 |
156 /** | 162 /** |
157 * Should be called for cleanup when the CompositorView instance is no longe r used. | 163 * Should be called for cleanup when the CompositorView instance is no longe r used. |
158 */ | 164 */ |
159 public void shutDown() { | 165 public void shutDown() { |
160 getHolder().removeCallback(this); | 166 mCompositorSurfaceManager.shutDown(); |
161 if (mNativeCompositorView != 0) nativeDestroy(mNativeCompositorView); | 167 if (mNativeCompositorView != 0) nativeDestroy(mNativeCompositorView); |
162 mNativeCompositorView = 0; | 168 mNativeCompositorView = 0; |
163 } | 169 } |
164 | 170 |
165 /** | 171 /** |
166 * Initializes the {@link CompositorView}'s native parts (e.g. the rendering parts). | 172 * Initializes the {@link CompositorView}'s native parts (e.g. the rendering parts). |
167 * @param lowMemDevice If this is a low memory device. | 173 * @param lowMemDevice If this is a low memory device. |
168 * @param windowAndroid A {@link WindowAndroid} instance. | 174 * @param windowAndroid A {@link WindowAndroid} instance. |
169 * @param layerTitleCache A {@link LayerTitleCache} instance. | 175 * @param layerTitleCache A {@link LayerTitleCache} instance. |
170 * @param tabContentManager A {@link TabContentManager} instance. | 176 * @param tabContentManager A {@link TabContentManager} instance. |
171 */ | 177 */ |
172 public void initNativeCompositor(boolean lowMemDevice, WindowAndroid windowA ndroid, | 178 public void initNativeCompositor(boolean lowMemDevice, WindowAndroid windowA ndroid, |
173 LayerTitleCache layerTitleCache, TabContentManager tabContentManager ) { | 179 LayerTitleCache layerTitleCache, TabContentManager tabContentManager ) { |
174 mWindowAndroid = windowAndroid; | 180 mWindowAndroid = windowAndroid; |
175 mLayerTitleCache = layerTitleCache; | 181 mLayerTitleCache = layerTitleCache; |
176 mTabContentManager = tabContentManager; | 182 mTabContentManager = tabContentManager; |
177 | 183 |
178 mNativeCompositorView = nativeInit(lowMemDevice, | 184 mNativeCompositorView = nativeInit(lowMemDevice, |
179 windowAndroid.getNativePointer(), layerTitleCache, tabContentMan ager); | 185 windowAndroid.getNativePointer(), layerTitleCache, tabContentMan ager); |
180 | 186 |
181 assert !getHolder().getSurface().isValid() | 187 // compositor_impl_android.cc will use 565 EGL surfaces if and only if we're using a low |
David Trainor- moved to gerrit
2017/02/07 19:36:16
Remove extra space after "only if"
liberato (no reviews please)
2017/02/14 17:22:24
Done.
| |
182 : "Surface created before native library loaded."; | 188 // memory device, and no alpha channel is desired. Otherwise, it will u se 8888. Since |
183 getHolder().addCallback(this); | 189 // SurfaceFlinger doesn't need the eOpaque flag to optimize out alpha bl ending during |
190 // composition if the buffer has no alpha channel, we can avoid using th e extra background | |
191 // surface (and the memory it requires) in the low memory case. The out put buffer will | |
192 // either have an alpha channel or not, depending on whether the composi tor needs it. We | |
193 // can keep the surface translucent all the times without worrying about the impact on power | |
194 // usage during SurfaceFlinger composition. We might also want to set |m AlwaysTranslucent| | |
195 // on non-low memory devices , if we are running on hardware that implem ents efficient alpha | |
David Trainor- moved to gerrit
2017/02/07 19:36:16
Remove extra space before ","
liberato (no reviews please)
2017/02/14 17:22:24
Done.
| |
196 // blending. | |
197 mAlwaysTranslucent = lowMemDevice; | |
198 | |
199 mCompositorSurfaceManager = new CompositorSurfaceManager(this, this); | |
200 // In case the background drawable was set before now, update it. | |
201 mCompositorSurfaceManager.setBackgroundDrawable(getBackground()); | |
202 mCompositorSurfaceManager.setWillNotDraw(mWillNotDraw); | |
203 mCompositorSurfaceManager.requestSurface(getSurfacePixelFormat()); | |
184 | 204 |
185 // Cover the black surface before it has valid content. | 205 // Cover the black surface before it has valid content. |
186 setBackgroundColor(Color.WHITE); | 206 setBackgroundColor(Color.WHITE); |
187 setVisibility(View.VISIBLE); | 207 setVisibility(View.VISIBLE); |
188 | 208 |
189 mFramePresentationDelay = 0; | 209 mFramePresentationDelay = 0; |
190 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { | 210 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) { |
191 Display display = | 211 Display display = |
192 ((WindowManager) getContext().getSystemService(Context.WINDO W_SERVICE)) | 212 ((WindowManager) getContext().getSystemService(Context.WINDO W_SERVICE)) |
193 .getDefaultDisplay(); | 213 .getDefaultDisplay(); |
194 long presentationDeadline = display.getPresentationDeadlineNanos() | 214 long presentationDeadline = display.getPresentationDeadlineNanos() |
195 / NANOSECONDS_PER_MILLISECOND; | 215 / NANOSECONDS_PER_MILLISECOND; |
196 long vsyncPeriod = mWindowAndroid.getVsyncPeriodInMillis(); | 216 long vsyncPeriod = mWindowAndroid.getVsyncPeriodInMillis(); |
197 mFramePresentationDelay = Math.min(3 * vsyncPeriod, | 217 mFramePresentationDelay = Math.min(3 * vsyncPeriod, |
198 ((presentationDeadline + vsyncPeriod - 1) / vsyncPeriod) * v syncPeriod); | 218 ((presentationDeadline + vsyncPeriod - 1) / vsyncPeriod) * v syncPeriod); |
199 } | 219 } |
200 | 220 |
201 // Grab the Resource Manager | 221 // Grab the Resource Manager |
202 mResourceManager = nativeGetResourceManager(mNativeCompositorView); | 222 mResourceManager = nativeGetResourceManager(mNativeCompositorView); |
203 } | 223 } |
204 | 224 |
205 @Override | 225 @Override |
206 public boolean onTouchEvent(MotionEvent e) { | 226 public boolean onTouchEvent(MotionEvent e) { |
207 return super.onTouchEvent(e); | 227 return super.onTouchEvent(e); |
208 } | 228 } |
209 | 229 |
210 /** | 230 /** |
231 * @see SurfaceView#getHolder | |
232 */ | |
233 SurfaceHolder getHolder() { | |
234 return mCompositorSurfaceManager.getHolder(); | |
235 } | |
236 | |
237 /** | |
211 * Enables/disables overlay video mode. Affects alpha blending on this view. | 238 * Enables/disables overlay video mode. Affects alpha blending on this view. |
212 * @param enabled Whether to enter or leave overlay video mode. | 239 * @param enabled Whether to enter or leave overlay video mode. |
213 */ | 240 */ |
214 public void setOverlayVideoMode(boolean enabled) { | 241 public void setOverlayVideoMode(boolean enabled) { |
215 mCurrentPixelFormat = enabled ? PixelFormat.TRANSLUCENT : PixelFormat.OP AQUE; | |
216 getHolder().setFormat(mCurrentPixelFormat); | |
217 nativeSetOverlayVideoMode(mNativeCompositorView, enabled); | 242 nativeSetOverlayVideoMode(mNativeCompositorView, enabled); |
243 | |
244 mOverlayVideoEnabled = enabled; | |
245 // Request the new surface, even if it's the same as the old one. We'll get a synthetic | |
246 // destroy / create / changed callback in that case, possibly before thi s returns. | |
247 mCompositorSurfaceManager.requestSurface(getSurfacePixelFormat()); | |
248 // Note that we don't know if we'll get a surfaceCreated / surfaceDestoy ed for this surface. | |
249 // We do know that if we do get one, then it will be for the surface tha t we just requested. | |
250 } | |
251 | |
252 private int getSurfacePixelFormat() { | |
253 return (mOverlayVideoEnabled || mAlwaysTranslucent) ? PixelFormat.TRANSL UCENT | |
254 : PixelFormat.OPAQUE ; | |
218 } | 255 } |
219 | 256 |
220 @Override | 257 @Override |
221 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { | 258 public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
222 if (mNativeCompositorView == 0) return; | 259 if (mNativeCompositorView == 0) return; |
260 | |
223 nativeSurfaceChanged(mNativeCompositorView, format, width, height, holde r.getSurface()); | 261 nativeSurfaceChanged(mNativeCompositorView, format, width, height, holde r.getSurface()); |
224 mRenderHost.onPhysicalBackingSizeChanged(width, height); | 262 mRenderHost.onPhysicalBackingSizeChanged(width, height); |
225 mSurfaceWidth = width; | |
226 mSurfaceHeight = height; | |
227 } | 263 } |
228 | 264 |
229 @Override | 265 @Override |
230 public void surfaceCreated(SurfaceHolder holder) { | 266 public void surfaceCreated(SurfaceHolder holder) { |
231 if (mNativeCompositorView == 0) return; | 267 if (mNativeCompositorView == 0) return; |
268 | |
232 nativeSurfaceCreated(mNativeCompositorView); | 269 nativeSurfaceCreated(mNativeCompositorView); |
270 mFramesUntilHideBackground = 2; | |
233 mRenderHost.onSurfaceCreated(); | 271 mRenderHost.onSurfaceCreated(); |
234 } | 272 } |
235 | 273 |
236 @Override | 274 @Override |
237 public void surfaceDestroyed(SurfaceHolder holder) { | 275 public void surfaceDestroyed(SurfaceHolder holder) { |
238 if (mNativeCompositorView == 0) return; | 276 if (mNativeCompositorView == 0) return; |
277 | |
239 nativeSurfaceDestroyed(mNativeCompositorView); | 278 nativeSurfaceDestroyed(mNativeCompositorView); |
240 } | 279 } |
241 | 280 |
242 @Override | 281 @Override |
243 public void onWindowVisibilityChanged(int visibility) { | 282 public void onWindowVisibilityChanged(int visibility) { |
244 super.onWindowVisibilityChanged(visibility); | 283 super.onWindowVisibilityChanged(visibility); |
245 if (mWindowAndroid == null) return; | 284 if (mWindowAndroid == null) return; |
246 if (visibility == View.GONE) { | 285 if (visibility == View.GONE) { |
247 mWindowAndroid.onVisibilityChanged(false); | 286 mWindowAndroid.onVisibilityChanged(false); |
248 } else if (visibility == View.VISIBLE) { | 287 } else if (visibility == View.VISIBLE) { |
249 mWindowAndroid.onVisibilityChanged(true); | 288 mWindowAndroid.onVisibilityChanged(true); |
250 } | 289 } |
251 IntentWithGesturesHandler.getInstance().clear(); | 290 IntentWithGesturesHandler.getInstance().clear(); |
252 } | 291 } |
253 | 292 |
254 @CalledByNative | 293 @CalledByNative |
255 private void onCompositorLayout() { | 294 private void onCompositorLayout() { |
256 mRenderHost.onCompositorLayout(); | 295 mRenderHost.onCompositorLayout(); |
257 } | 296 } |
258 | 297 |
259 /* | 298 /* |
260 * On JellyBean there is a known bug where a crashed producer process | 299 * On JellyBean there is a known bug where a crashed producer process |
261 * (i.e. GPU process) does not properly disconnect from the BufferQueue, | 300 * (i.e. GPU process) does not properly disconnect from the BufferQueue, |
262 * which means we won't be able to reconnect to it ever again. | 301 * which means we won't be able to reconnect to it ever again. |
263 * This workaround forces the creation of a new Surface. | 302 * This workaround forces the creation of a new Surface. |
264 */ | 303 */ |
265 @CalledByNative | 304 @CalledByNative |
266 private void onJellyBeanSurfaceDisconnectWorkaround(boolean inOverlayMode) { | 305 private void onJellyBeanSurfaceDisconnectWorkaround(boolean inOverlayMode) { |
267 // There is a bug in JellyBean because of which we will not be able to | 306 mCompositorSurfaceManager.recreateSurfaceForJellyBean(); |
268 // reconnect to the existing Surface after we launch a new GPU process. | |
269 // We simply trick the JB Android code to allocate a new Surface. | |
270 // It does a strict comparison between the current format and the reques ted | |
271 // one, even if they are the same in practice. Furthermore, the format | |
272 // does not matter here since the producer-side EGL config overwrites it | |
273 // (but transparency might matter). | |
274 switch (mCurrentPixelFormat) { | |
275 case PixelFormat.OPAQUE: | |
276 mCurrentPixelFormat = PixelFormat.RGBA_8888; | |
277 break; | |
278 case PixelFormat.RGBA_8888: | |
279 mCurrentPixelFormat = inOverlayMode | |
280 ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE; | |
281 break; | |
282 case PixelFormat.TRANSLUCENT: | |
283 mCurrentPixelFormat = PixelFormat.RGBA_8888; | |
284 break; | |
285 default: | |
286 assert false; | |
287 Log.e(TAG, "Unknown current pixel format."); | |
288 } | |
289 getHolder().setFormat(mCurrentPixelFormat); | |
290 } | 307 } |
291 | 308 |
292 /** | 309 /** |
293 * Request compositor view to render a frame. | 310 * Request compositor view to render a frame. |
294 */ | 311 */ |
295 public void requestRender() { | 312 public void requestRender() { |
296 if (mNativeCompositorView != 0) nativeSetNeedsComposite(mNativeComposito rView); | 313 if (mNativeCompositorView != 0) nativeSetNeedsComposite(mNativeComposito rView); |
297 } | 314 } |
298 | 315 |
299 @CalledByNative | 316 @CalledByNative |
300 private void onSwapBuffersCompleted(int pendingSwapBuffersCount) { | 317 private void onSwapBuffersCompleted(int pendingSwapBuffersCount) { |
301 // Clear the color used to cover the uninitialized surface. | 318 // Clear the color used to cover the uninitialized surface. |
302 if (getBackground() != null) { | 319 if (getBackground() != null) { |
303 postDelayed(new Runnable() { | 320 postDelayed(new Runnable() { |
304 @Override | 321 @Override |
305 public void run() { | 322 public void run() { |
306 setBackgroundResource(0); | 323 setBackgroundResource(0); |
307 } | 324 } |
308 }, mFramePresentationDelay); | 325 }, mFramePresentationDelay); |
309 } | 326 } |
310 | 327 |
328 // If we're in the middle of a surface swap, then see if we've received a new frame yet for | |
329 // the new surface before hiding the outgoing surface. | |
330 if (mFramesUntilHideBackground > 1) { | |
331 // We need at least one more frame before we hide the outgoing surfa ce. Make sure that | |
332 // there will be a frame. | |
333 mFramesUntilHideBackground--; | |
334 requestRender(); | |
335 } else if (mFramesUntilHideBackground == 1) { | |
336 // We can hide the outgoing surface, since the incoming one has a fr ame. It's okay if | |
337 // we've don't have an unowned surface. | |
338 mFramesUntilHideBackground = 0; | |
339 mCompositorSurfaceManager.doneWithUnownedSurface(); | |
Ted C
2017/02/06 18:44:17
Looking at the code in doneWithUnownedSurface, it
liberato (no reviews please)
2017/02/14 17:22:24
it will doneWithUnowned -> detachSurfaceLater a fe
| |
340 } | |
341 | |
311 mRenderHost.onSwapBuffersCompleted(pendingSwapBuffersCount); | 342 mRenderHost.onSwapBuffersCompleted(pendingSwapBuffersCount); |
312 } | 343 } |
313 | 344 |
314 /** | 345 /** |
315 * Converts the layout into compositor layers. This is to be called on every frame the layout | 346 * Converts the layout into compositor layers. This is to be called on every frame the layout |
316 * is changing. | 347 * is changing. |
317 * @param provider Provides the layout to be rendered. | 348 * @param provider Provides the layout to be rendered. |
318 * @param forRotation Whether or not this is a special draw durin g a rotation. | 349 * @param forRotation Whether or not this is a special draw durin g a rotation. |
319 */ | 350 */ |
320 public void finalizeLayers(final LayoutProvider provider, boolean forRotatio n, | 351 public void finalizeLayers(final LayoutProvider provider, boolean forRotatio n, |
(...skipping 23 matching lines...) Expand all Loading... | |
344 provider.getUpdatedActiveSceneLayer(mLayerTitleCache, mTabConten tManager, | 375 provider.getUpdatedActiveSceneLayer(mLayerTitleCache, mTabConten tManager, |
345 mResourceManager, provider.getFullscreenManager()); | 376 mResourceManager, provider.getFullscreenManager()); |
346 | 377 |
347 nativeSetSceneLayer(mNativeCompositorView, sceneLayer); | 378 nativeSetSceneLayer(mNativeCompositorView, sceneLayer); |
348 | 379 |
349 TabModelImpl.flushActualTabSwitchLatencyMetric(); | 380 TabModelImpl.flushActualTabSwitchLatencyMetric(); |
350 nativeFinalizeLayers(mNativeCompositorView); | 381 nativeFinalizeLayers(mNativeCompositorView); |
351 TraceEvent.end("CompositorView:finalizeLayers"); | 382 TraceEvent.end("CompositorView:finalizeLayers"); |
352 } | 383 } |
353 | 384 |
385 @Override | |
386 public void setWillNotDraw(boolean willNotDraw) { | |
387 mWillNotDraw = willNotDraw; | |
388 if (mCompositorSurfaceManager != null) { | |
389 mCompositorSurfaceManager.setWillNotDraw(mWillNotDraw); | |
390 } | |
391 } | |
392 | |
393 @Override | |
394 public void setBackgroundDrawable(Drawable background) { | |
395 // We override setBackgroundDrawable since that's the common entry point from all the | |
396 // setBackground* calls in View. We still call to setBackground on the SurfaceView because | |
397 // SetBackgroundDrawable is depricated, and the semantics are the same I think. | |
Ted C
2017/02/06 18:44:17
depr[e]cated
liberato (no reviews please)
2017/02/14 17:22:24
Done.
| |
398 super.setBackgroundDrawable(background); | |
Ted C
2017/02/06 18:44:17
should we actually set the drawable in both places
liberato (no reviews please)
2017/02/14 17:22:24
i think that we should. i tried with / without bo
| |
399 if (mCompositorSurfaceManager != null) { | |
400 mCompositorSurfaceManager.setBackgroundDrawable(background); | |
401 } | |
402 } | |
403 | |
354 // Implemented in native | 404 // Implemented in native |
355 private native long nativeInit(boolean lowMemDevice, long nativeWindowAndroi d, | 405 private native long nativeInit(boolean lowMemDevice, long nativeWindowAndroi d, |
356 LayerTitleCache layerTitleCache, TabContentManager tabContentManager ); | 406 LayerTitleCache layerTitleCache, TabContentManager tabContentManager ); |
357 private native void nativeDestroy(long nativeCompositorView); | 407 private native void nativeDestroy(long nativeCompositorView); |
358 private native ResourceManager nativeGetResourceManager(long nativeComposito rView); | 408 private native ResourceManager nativeGetResourceManager(long nativeComposito rView); |
359 private native void nativeSurfaceCreated(long nativeCompositorView); | 409 private native void nativeSurfaceCreated(long nativeCompositorView); |
360 private native void nativeSurfaceDestroyed(long nativeCompositorView); | 410 private native void nativeSurfaceDestroyed(long nativeCompositorView); |
361 private native void nativeSurfaceChanged( | 411 private native void nativeSurfaceChanged( |
362 long nativeCompositorView, int format, int width, int height, Surfac e surface); | 412 long nativeCompositorView, int format, int width, int height, Surfac e surface); |
363 private native void nativeFinalizeLayers(long nativeCompositorView); | 413 private native void nativeFinalizeLayers(long nativeCompositorView); |
364 private native void nativeSetNeedsComposite(long nativeCompositorView); | 414 private native void nativeSetNeedsComposite(long nativeCompositorView); |
365 private native void nativeSetLayoutBounds(long nativeCompositorView); | 415 private native void nativeSetLayoutBounds(long nativeCompositorView); |
366 private native void nativeSetOverlayVideoMode(long nativeCompositorView, boo lean enabled); | 416 private native void nativeSetOverlayVideoMode(long nativeCompositorView, boo lean enabled); |
367 private native void nativeSetSceneLayer(long nativeCompositorView, SceneLaye r sceneLayer); | 417 private native void nativeSetSceneLayer(long nativeCompositorView, SceneLaye r sceneLayer); |
368 } | 418 } |
OLD | NEW |