Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java |
| index c470e0445e435ea4ea10d0481fb6b49879c3a88b..36441a05fc96c00042e9db751e1c7db6c6194bdc 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java |
| @@ -4,13 +4,22 @@ |
| package org.chromium.chrome.browser.compositor.scene_layer; |
| +import android.content.Context; |
| import android.graphics.Rect; |
| import org.chromium.base.annotations.JNINamespace; |
| +import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.compositor.LayerTitleCache; |
| +import org.chromium.chrome.browser.compositor.layouts.Layout; |
| +import org.chromium.chrome.browser.compositor.layouts.Layout.SizingFlags; |
| import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab; |
| import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; |
| +import org.chromium.chrome.browser.device.DeviceClassManager; |
| import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; |
| +import org.chromium.chrome.browser.widget.ClipDrawableProgressBar.DrawingInfo; |
| +import org.chromium.chrome.browser.widget.ControlContainer; |
| +import org.chromium.ui.base.DeviceFormFactor; |
| +import org.chromium.ui.resources.ResourceManager; |
| /** |
| * A SceneLayer to render a static tab. |
| @@ -21,10 +30,17 @@ public class StaticTabSceneLayer extends SceneLayer { |
| // downcast using reinterpret_cast<>. We keep a separate pointer to avoid it. |
| private long mNativePtr; |
| + private Context mContext; |
|
David Trainor- moved to gerrit
2016/02/24 17:06:10
final?
mdjones
2016/02/25 21:38:01
Done.
|
| + |
| private final int mResToolbarControlContainer; |
| - public StaticTabSceneLayer(int resToolbarControlContainer) { |
| + private DrawingInfo mProgressBarDrawingInfo; |
| + private boolean mIsTablet; |
|
David Trainor- moved to gerrit
2016/02/24 17:06:10
final?
mdjones
2016/02/25 21:38:01
Done.
|
| + |
| + public StaticTabSceneLayer(Context context, int resToolbarControlContainer) { |
| + mContext = context; |
| mResToolbarControlContainer = resToolbarControlContainer; |
| + mIsTablet = DeviceFormFactor.isTablet(mContext); |
| } |
| /** |
| @@ -59,6 +75,72 @@ public class StaticTabSceneLayer extends SceneLayer { |
| } |
| /** |
| + * Update the toolbar and progress bar layers. |
| + * |
| + * @param dpToPx The conversion factor of dp to px. |
| + * @param topControlsBackgroundColor The background color of the top controls. |
| + * @param topControlsUrlBarAlpha The alpha of the URL bar. |
| + * @param fullscreenManager A ChromeFullscreenManager instance. |
| + * @param resourceManager A ResourceManager for loading static resources. |
| + * @param layout The layout being rendered to. |
| + */ |
| + public void updateToolbarLayer(float dpToPx, int topControlsBackgroundColor, |
|
David Trainor- moved to gerrit
2016/02/24 17:06:10
I'm assuming most of this logic is a copy from Com
mdjones
2016/02/25 21:38:01
That is correct. Some things have been removed sin
|
| + float topControlsUrlBarAlpha, ChromeFullscreenManager fullscreenManager, |
| + ResourceManager resourceManager, Layout layout) { |
|
David Trainor- moved to gerrit
2016/02/24 17:06:10
It seems like there are 4 things we need Layout fo
mdjones
2016/02/25 21:38:00
1 and 4 need to stick around, I removed 2 and 3 an
|
| + if (!DeviceClassManager.enableFullscreen()) return; |
| + |
| + ControlContainer toolbarContainer = fullscreenManager.getControlContainer(); |
| + if (!mIsTablet && toolbarContainer != null) { |
| + if (mProgressBarDrawingInfo == null) mProgressBarDrawingInfo = new DrawingInfo(); |
| + toolbarContainer.getProgressBarDrawingInfo(mProgressBarDrawingInfo); |
| + } else { |
| + assert mProgressBarDrawingInfo == null; |
| + } |
| + |
| + if (fullscreenManager == null) return; |
|
David Trainor- moved to gerrit
2016/02/24 17:06:10
Should we check this before dereferencing it on li
mdjones
2016/02/25 21:38:00
Yes
|
| + |
| + float offset = fullscreenManager.getControlOffset(); |
| + boolean forceHideTopControlsAndroidView = layout.forceHideTopControlsAndroidView(); |
| + boolean useTexture = fullscreenManager.drawControlsAsTexture() || offset == 0 |
| + || forceHideTopControlsAndroidView; |
| + |
| + float layoutOffsetDp = layout.getTopControlsOffset(offset / dpToPx); |
| + boolean validLayoutOffset = !Float.isNaN(layoutOffsetDp); |
| + |
| + if (validLayoutOffset) { |
| + offset = layoutOffsetDp * dpToPx; |
| + useTexture = true; |
| + } |
| + |
| + fullscreenManager.setHideTopControlsAndroidView(forceHideTopControlsAndroidView |
| + || (validLayoutOffset && layoutOffsetDp != 0.f)); |
| + |
| + int flags = layout.getSizingFlags(); |
| + if ((flags & SizingFlags.REQUIRE_FULLSCREEN_SIZE) != 0 |
| + && (flags & SizingFlags.ALLOW_TOOLBAR_HIDE) == 0 |
| + && (flags & SizingFlags.ALLOW_TOOLBAR_ANIMATE) == 0) { |
| + useTexture = false; |
| + } |
| + |
| + nativeUpdateToolbarLayer(mNativePtr, resourceManager, R.id.control_container, |
| + topControlsBackgroundColor, R.drawable.textbox, topControlsUrlBarAlpha, offset, |
| + layout.getToolbarBrightness(), useTexture, forceHideTopControlsAndroidView); |
| + |
| + if (mProgressBarDrawingInfo == null) return; |
| + nativeUpdateProgressBar(mNativePtr, |
| + mProgressBarDrawingInfo.progressBarRect.left, |
| + mProgressBarDrawingInfo.progressBarRect.top, |
| + mProgressBarDrawingInfo.progressBarRect.width(), |
| + mProgressBarDrawingInfo.progressBarRect.height(), |
| + mProgressBarDrawingInfo.progressBarColor, |
| + mProgressBarDrawingInfo.progressBarBackgroundRect.left, |
| + mProgressBarDrawingInfo.progressBarBackgroundRect.top, |
| + mProgressBarDrawingInfo.progressBarBackgroundRect.width(), |
| + mProgressBarDrawingInfo.progressBarBackgroundRect.height(), |
| + mProgressBarDrawingInfo.progressBarBackgroundColor); |
| + } |
| + |
| + /** |
| * Set the given sceneLayer as content along with {@link StaticTabSceneLayer}'s own. |
| * |
| * @param sceneLayer |
| @@ -89,6 +171,15 @@ public class StaticTabSceneLayer extends SceneLayer { |
| boolean canUseLiveLayer, int backgroundColor, float x, float y, float width, |
| float height, float contentOffsetY, float staticToViewBlend, float saturation, |
| float brightness); |
| + private native void nativeUpdateToolbarLayer(long nativeStaticTabSceneLayer, |
| + ResourceManager resourceManager, int resourceId, int toolbarBackgroundColor, |
| + int urlBarResourceId, float urlBarAlpha, float topOffset, float brightness, |
| + boolean visible, boolean showShadow); |
| + private native void nativeUpdateProgressBar( |
| + long nativeStaticTabSceneLayer, int progressBarX, int progressBarY, |
| + int progressBarWidth, int progressBarHeight, int progressBarColor, |
| + int progressBarBackgroundX, int progressBarBackgroundY, int progressBarBackgroundWidth, |
| + int progressBarBackgroundHeight, int progressBarBackgroundColor); |
| private native void nativeSetContentSceneLayer( |
| long nativeStaticTabSceneLayer, SceneLayer sceneLayer); |
| } |