Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewRenderView.java

Issue 201583004: Add layerTreeBuildHelper to control layer tree in ContentViewRenderView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Git add the new files Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Canvas; 9 import android.graphics.Canvas;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 25 matching lines...) Expand all
36 private long mNativeContentViewRenderView; 36 private long mNativeContentViewRenderView;
37 private final SurfaceHolder.Callback mSurfaceCallback; 37 private final SurfaceHolder.Callback mSurfaceCallback;
38 38
39 private final SurfaceView mSurfaceView; 39 private final SurfaceView mSurfaceView;
40 private final VSyncAdapter mVSyncAdapter; 40 private final VSyncAdapter mVSyncAdapter;
41 41
42 private int mPendingRenders; 42 private int mPendingRenders;
43 private int mPendingSwapBuffers; 43 private int mPendingSwapBuffers;
44 private boolean mNeedToRender; 44 private boolean mNeedToRender;
45 45
46 private ContentView mCurrentContentView; 46 protected ContentView mCurrentContentView;
Yaron 2014/04/23 20:57:46 Is this change still necessary? You haven't re-upl
Yusuf 2014/04/24 00:06:03 Yes. I will need this in extending classes to rout
47 47
48 private final Runnable mRenderRunnable = new Runnable() { 48 private final Runnable mRenderRunnable = new Runnable() {
49 @Override 49 @Override
50 public void run() { 50 public void run() {
51 render(); 51 render();
52 } 52 }
53 }; 53 };
54 54
55 /** 55 /**
56 * Constructs a new ContentViewRenderView that should be can to a view hiera rchy. 56 * Constructs a new ContentViewRenderView that should be can to a view hiera rchy.
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 /** 259 /**
260 * Enter or leave overlay video mode. 260 * Enter or leave overlay video mode.
261 * @param enabled Whether overlay mode is enabled. 261 * @param enabled Whether overlay mode is enabled.
262 */ 262 */
263 public void setOverlayVideoMode(boolean enabled) { 263 public void setOverlayVideoMode(boolean enabled) {
264 int format = enabled ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE; 264 int format = enabled ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE;
265 mSurfaceView.getHolder().setFormat(format); 265 mSurfaceView.getHolder().setFormat(format);
266 nativeSetOverlayVideoMode(mNativeContentViewRenderView, enabled); 266 nativeSetOverlayVideoMode(mNativeContentViewRenderView, enabled);
267 } 267 }
268 268
269 /**
270 *
Yaron 2014/04/23 20:57:46 Update
Yusuf 2014/04/24 00:06:03 Done.
271 */
272 public void setLayerTreeBuildHelper(long layerTreeBuildHelperNativePtr) {
273 nativeSetLayerTreeBuildHelper(mNativeContentViewRenderView, layerTreeBui ldHelperNativePtr);
274 }
275
269 @CalledByNative 276 @CalledByNative
270 private void requestRender() { 277 private void requestRender() {
271 ContentViewCore contentViewCore = mCurrentContentView != null ? 278 ContentViewCore contentViewCore = mCurrentContentView != null ?
272 mCurrentContentView.getContentViewCore() : null; 279 mCurrentContentView.getContentViewCore() : null;
273 280
274 boolean rendererHasFrame = 281 boolean rendererHasFrame =
275 contentViewCore != null && contentViewCore.consumePendingRendere rFrame(); 282 contentViewCore != null && contentViewCore.consumePendingRendere rFrame();
276 283
277 if (rendererHasFrame && mPendingSwapBuffers + mPendingRenders < MAX_SWAP _BUFFER_COUNT) { 284 if (rendererHasFrame && mPendingSwapBuffers + mPendingRenders < MAX_SWAP _BUFFER_COUNT) {
278 TraceEvent.instant("requestRender:now"); 285 TraceEvent.instant("requestRender:now");
(...skipping 19 matching lines...) Expand all
298 } 305 }
299 306
300 @CalledByNative 307 @CalledByNative
301 private void onSwapBuffersCompleted() { 308 private void onSwapBuffersCompleted() {
302 TraceEvent.instant("onSwapBuffersCompleted"); 309 TraceEvent.instant("onSwapBuffersCompleted");
303 310
304 if (mPendingSwapBuffers == MAX_SWAP_BUFFER_COUNT && mNeedToRender) reque stRender(); 311 if (mPendingSwapBuffers == MAX_SWAP_BUFFER_COUNT && mNeedToRender) reque stRender();
305 if (mPendingSwapBuffers > 0) mPendingSwapBuffers--; 312 if (mPendingSwapBuffers > 0) mPendingSwapBuffers--;
306 } 313 }
307 314
308 private void render() { 315 protected void render() {
309 if (mPendingRenders > 0) mPendingRenders--; 316 if (mPendingRenders > 0) mPendingRenders--;
310 317
311 // Waiting for the content view contents to be ready avoids compositing 318 // Waiting for the content view contents to be ready avoids compositing
312 // when the surface texture is still empty. 319 // when the surface texture is still empty.
313 if (mCurrentContentView == null) return; 320 if (mCurrentContentView == null) return;
314 ContentViewCore contentViewCore = mCurrentContentView.getContentViewCore (); 321 ContentViewCore contentViewCore = mCurrentContentView.getContentViewCore ();
315 if (contentViewCore == null || !contentViewCore.isReady()) { 322 if (contentViewCore == null || !contentViewCore.isReady()) {
316 return; 323 return;
317 } 324 }
318 325
319 boolean didDraw = nativeComposite(mNativeContentViewRenderView); 326 boolean didDraw = nativeComposite(mNativeContentViewRenderView);
320 if (didDraw) { 327 if (didDraw) {
321 mPendingSwapBuffers++; 328 mPendingSwapBuffers++;
322 if (mSurfaceView.getBackground() != null) { 329 if (mSurfaceView.getBackground() != null) {
323 post(new Runnable() { 330 post(new Runnable() {
324 @Override 331 @Override
325 public void run() { 332 public void run() {
326 mSurfaceView.setBackgroundResource(0); 333 mSurfaceView.setBackgroundResource(0);
327 } 334 }
328 }); 335 });
329 } 336 }
330 } 337 }
331 } 338 }
332 339
333 private native long nativeInit(long rootWindowNativePointer); 340 private native long nativeInit(long rootWindowNativePointer);
334 private native void nativeDestroy(long nativeContentViewRenderView); 341 private native void nativeDestroy(long nativeContentViewRenderView);
335 private native void nativeSetCurrentContentView(long nativeContentViewRender View, 342 private native void nativeSetCurrentContentView(long nativeContentViewRender View,
336 long nativeContentView); 343 long nativeContentView);
344 private native void nativeSetLayerTreeBuildHelper(long nativeContentViewRend erView,
345 long buildHelperNativePtr);
337 private native void nativeSurfaceCreated(long nativeContentViewRenderView); 346 private native void nativeSurfaceCreated(long nativeContentViewRenderView);
338 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView) ; 347 private native void nativeSurfaceDestroyed(long nativeContentViewRenderView) ;
339 private native void nativeSurfaceChanged(long nativeContentViewRenderView, 348 private native void nativeSurfaceChanged(long nativeContentViewRenderView,
340 int format, int width, int height, Surface surface); 349 int format, int width, int height, Surface surface);
341 private native boolean nativeComposite(long nativeContentViewRenderView); 350 private native boolean nativeComposite(long nativeContentViewRenderView);
342 private native boolean nativeCompositeToBitmap(long nativeContentViewRenderV iew, Bitmap bitmap); 351 private native boolean nativeCompositeToBitmap(long nativeContentViewRenderV iew, Bitmap bitmap);
343 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi ew, 352 private native void nativeSetOverlayVideoMode(long nativeContentViewRenderVi ew,
344 boolean enabled); 353 boolean enabled);
345 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698