OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 heightMeasureSpec = | 140 heightMeasureSpec = |
141 MeasureSpec.makeMeasureSpec(getMeasuredHeight(), Measure
Spec.EXACTLY); | 141 MeasureSpec.makeMeasureSpec(getMeasuredHeight(), Measure
Spec.EXACTLY); |
142 } | 142 } |
143 } | 143 } |
144 super.onMeasure(widthMeasureSpec, heightMeasureSpec); | 144 super.onMeasure(widthMeasureSpec, heightMeasureSpec); |
145 } | 145 } |
146 | 146 |
147 @Override | 147 @Override |
148 protected void onLayout(boolean changed, int left, int top, int right, int b
ottom) { | 148 protected void onLayout(boolean changed, int left, int top, int right, int b
ottom) { |
149 super.onLayout(changed, left, top, right, bottom); | 149 super.onLayout(changed, left, top, right, bottom); |
150 mRenderHost.onOverdrawBottomHeightChanged(getOverdrawBottomHeight()); | |
151 } | 150 } |
152 | 151 |
153 @Override | 152 @Override |
154 protected void onDetachedFromWindow() { | 153 protected void onDetachedFromWindow() { |
155 super.onDetachedFromWindow(); | 154 super.onDetachedFromWindow(); |
156 mPreviousWindowTop = -1; | 155 mPreviousWindowTop = -1; |
157 } | 156 } |
158 | 157 |
159 /** | 158 /** |
160 * @return The ResourceManager. | 159 * @return The ResourceManager. |
161 */ | 160 */ |
162 public ResourceManager getResourceManager() { | 161 public ResourceManager getResourceManager() { |
163 return mResourceManager; | 162 return mResourceManager; |
164 } | 163 } |
165 | 164 |
166 /** | 165 /** |
167 * @return The amount the surface view is overdrawing the window bounds. | |
168 */ | |
169 public int getOverdrawBottomHeight() { | |
170 if (mRootActivityView == null) { | |
171 mRootActivityView = mRootView.findViewById(android.R.id.content); | |
172 } | |
173 if (mRootActivityView != null) { | |
174 int compositorHeight = getHeight(); | |
175 int rootViewHeight = mRootActivityView.getHeight(); | |
176 return Math.max(0, compositorHeight - rootViewHeight); | |
177 } | |
178 return 0; | |
179 } | |
180 | |
181 /** | |
182 * Should be called for cleanup when the CompositorView instance is no longe
r used. | 166 * Should be called for cleanup when the CompositorView instance is no longe
r used. |
183 */ | 167 */ |
184 public void shutDown() { | 168 public void shutDown() { |
185 getHolder().removeCallback(this); | 169 getHolder().removeCallback(this); |
186 if (mNativeCompositorView != 0) nativeDestroy(mNativeCompositorView); | 170 if (mNativeCompositorView != 0) nativeDestroy(mNativeCompositorView); |
187 mNativeCompositorView = 0; | 171 mNativeCompositorView = 0; |
188 } | 172 } |
189 | 173 |
190 /** | 174 /** |
191 * Initializes the {@link CompositorView}'s native parts (e.g. the rendering
parts). | 175 * Initializes the {@link CompositorView}'s native parts (e.g. the rendering
parts). |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 389 |
406 // IMPORTANT: Do not do anything that impacts the compositor layer tree
before this line. | 390 // IMPORTANT: Do not do anything that impacts the compositor layer tree
before this line. |
407 // If you do, you could inadvertently trigger follow up renders. For fu
rther information | 391 // If you do, you could inadvertently trigger follow up renders. For fu
rther information |
408 // see dtrainor@, tedchoc@, or klobag@. | 392 // see dtrainor@, tedchoc@, or klobag@. |
409 | 393 |
410 // TODO(jscholler): change 1.0f to dpToPx once the native part is fully
supporting dp. | 394 // TODO(jscholler): change 1.0f to dpToPx once the native part is fully
supporting dp. |
411 mRenderHost.getVisibleViewport(mCacheVisibleViewport); | 395 mRenderHost.getVisibleViewport(mCacheVisibleViewport); |
412 provider.getViewportPixel(mCacheViewport); | 396 provider.getViewportPixel(mCacheViewport); |
413 nativeSetLayoutViewport(mNativeCompositorView, mCacheViewport.left, mCac
heViewport.top, | 397 nativeSetLayoutViewport(mNativeCompositorView, mCacheViewport.left, mCac
heViewport.top, |
414 mCacheViewport.width(), mCacheViewport.height(), mCacheVisibleVi
ewport.left, | 398 mCacheViewport.width(), mCacheViewport.height(), mCacheVisibleVi
ewport.left, |
415 mCacheVisibleViewport.top, mRenderHost.getCurrentOverdrawBottomH
eight(), 1.0f); | 399 mCacheVisibleViewport.top, 1.0f); |
416 | |
417 mCacheVisibleViewport.right = mCacheVisibleViewport.left + mSurfaceWidth
; | |
418 mCacheVisibleViewport.bottom = mCacheVisibleViewport.top | |
419 + Math.max(mSurfaceHeight - mRenderHost.getCurrentOverdrawBottom
Height(), 0); | |
420 | 400 |
421 // TODO(changwan): move to treeprovider. | 401 // TODO(changwan): move to treeprovider. |
422 updateToolbarLayer(provider, forRotation, progressBarDrawingInfo); | 402 updateToolbarLayer(provider, forRotation, progressBarDrawingInfo); |
423 | 403 |
424 SceneLayer sceneLayer = | 404 SceneLayer sceneLayer = |
425 provider.getUpdatedActiveSceneLayer(mCacheViewport, mCacheVisibl
eViewport, | 405 provider.getUpdatedActiveSceneLayer(mCacheViewport, mCacheVisibl
eViewport, |
426 mLayerTitleCache, mTabContentManager, mResourceManager, | 406 mLayerTitleCache, mTabContentManager, mResourceManager, |
427 provider.getFullscreenManager()); | 407 provider.getFullscreenManager()); |
428 | 408 |
429 nativeSetSceneLayer(mNativeCompositorView, sceneLayer); | 409 nativeSetSceneLayer(mNativeCompositorView, sceneLayer); |
(...skipping 27 matching lines...) Expand all Loading... |
457 private native void nativeDestroy(long nativeCompositorView); | 437 private native void nativeDestroy(long nativeCompositorView); |
458 private native ResourceManager nativeGetResourceManager(long nativeComposito
rView); | 438 private native ResourceManager nativeGetResourceManager(long nativeComposito
rView); |
459 private native void nativeSurfaceCreated(long nativeCompositorView); | 439 private native void nativeSurfaceCreated(long nativeCompositorView); |
460 private native void nativeSurfaceDestroyed(long nativeCompositorView); | 440 private native void nativeSurfaceDestroyed(long nativeCompositorView); |
461 private native void nativeSurfaceChanged( | 441 private native void nativeSurfaceChanged( |
462 long nativeCompositorView, int format, int width, int height, Surfac
e surface); | 442 long nativeCompositorView, int format, int width, int height, Surfac
e surface); |
463 private native void nativeFinalizeLayers(long nativeCompositorView); | 443 private native void nativeFinalizeLayers(long nativeCompositorView); |
464 private native void nativeSetNeedsComposite(long nativeCompositorView); | 444 private native void nativeSetNeedsComposite(long nativeCompositorView); |
465 private native void nativeSetLayoutViewport(long nativeCompositorView, float
x, float y, | 445 private native void nativeSetLayoutViewport(long nativeCompositorView, float
x, float y, |
466 float width, float height, float visibleXOffset, float visibleYOffse
t, | 446 float width, float height, float visibleXOffset, float visibleYOffse
t, |
467 float overdrawBottomHeight, float dpToPixel); | 447 float dpToPixel); |
468 private native void nativeUpdateToolbarLayer(long nativeCompositorView, int
resourceId, | 448 private native void nativeUpdateToolbarLayer(long nativeCompositorView, int
resourceId, |
469 int toolbarBackgroundColor, int urlBarResourceId, float urlBarAlpha,
float topOffset, | 449 int toolbarBackgroundColor, int urlBarResourceId, float urlBarAlpha,
float topOffset, |
470 float brightness, boolean visible, boolean showShadow); | 450 float brightness, boolean visible, boolean showShadow); |
471 private native void nativeUpdateProgressBar( | 451 private native void nativeUpdateProgressBar( |
472 long nativeCompositorView, | 452 long nativeCompositorView, |
473 int progressBarX, | 453 int progressBarX, |
474 int progressBarY, | 454 int progressBarY, |
475 int progressBarWidth, | 455 int progressBarWidth, |
476 int progressBarHeight, | 456 int progressBarHeight, |
477 int progressBarColor, | 457 int progressBarColor, |
478 int progressBarBackgroundX, | 458 int progressBarBackgroundX, |
479 int progressBarBackgroundY, | 459 int progressBarBackgroundY, |
480 int progressBarBackgroundWidth, | 460 int progressBarBackgroundWidth, |
481 int progressBarBackgroundHeight, | 461 int progressBarBackgroundHeight, |
482 int progressBarBackgroundColor); | 462 int progressBarBackgroundColor); |
483 private native void nativeSetOverlayVideoMode(long nativeCompositorView, boo
lean enabled); | 463 private native void nativeSetOverlayVideoMode(long nativeCompositorView, boo
lean enabled); |
484 private native void nativeSetSceneLayer(long nativeCompositorView, SceneLaye
r sceneLayer); | 464 private native void nativeSetSceneLayer(long nativeCompositorView, SceneLaye
r sceneLayer); |
485 } | 465 } |
OLD | NEW |