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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java

Issue 852433002: [Android] Upstream scene layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Jaekyun's comments Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..2cbdeb0ddef80733353c091616637cee613dac11
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/scene_layer/StaticTabSceneLayer.java
@@ -0,0 +1,91 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.compositor.scene_layer;
+
+import android.graphics.Rect;
+
+import org.chromium.base.JNINamespace;
+import org.chromium.chrome.browser.compositor.LayerTitleCache;
+import org.chromium.chrome.browser.compositor.layouts.components.LayoutTab;
+import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
+import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
+
+/**
+ * A SceneLayer to render a static tab.
+ */
+@JNINamespace("chrome::android")
+public class StaticTabSceneLayer extends SceneLayer {
+
+ // NOTE: If you use SceneLayer's native pointer here, the JNI generator will try to
+ // downcast using reinterpret_cast<>. We keep a separate pointer to avoid it.
+ private long mNativePtr;
+
+ private final int mResToolbarControlContainer;
+
+ public StaticTabSceneLayer(int resToolbarControlContainer) {
+ mResToolbarControlContainer = resToolbarControlContainer;
+ }
+
+ /**
+ * Update {@link StaticTabSceneLayer} with the given parameters.
+ *
+ * @param dpToPx The ratio of dp to px.
+ * @param contentViewport The viewport of the content.
+ * @param layerTitleCache The LayerTitleCache.
+ * @param tabContentManager The TabContentManager.
+ * @param fullscreenManager The FullscreenManager.
+ * @param layoutTab The LayoutTab.
+ */
+ public void update(float dpToPx, Rect contentViewport, LayerTitleCache layerTitleCache,
+ TabContentManager tabContentManager, ChromeFullscreenManager fullscreenManager,
+ LayoutTab layoutTab) {
+ if (layoutTab == null) {
+ return;
+ }
+
+ // TODO(dtrainor, clholgat): remove "* dpToPx" once the native part is fully supporting dp.
+ nativeUpdateTabLayer(mNativePtr, contentViewport.left, contentViewport.top,
+ contentViewport.width(), contentViewport.height(), tabContentManager,
+ layoutTab.getId(), mResToolbarControlContainer, layoutTab.canUseLiveTexture(),
+ false, layoutTab.getBackgroundColor(), layoutTab.getRenderX() * dpToPx,
+ layoutTab.getRenderY() * dpToPx, layoutTab.getScaledContentWidth() * dpToPx,
+ layoutTab.getScaledContentHeight() * dpToPx, fullscreenManager.getContentOffset(),
+ layoutTab.getStaticToViewBlend(), layoutTab.getSaturation());
+ }
+
+ /**
+ * Set the given sceneLayer as content along with {@link StaticTabSceneLayer}'s own.
+ *
+ * @param sceneLayer
+ */
+ // TODO(pedrosimonetti): Remove this once contextual search is moved into an overlay.
+ public void setContentSceneLayer(SceneLayer sceneLayer) {
+ nativeSetContentSceneLayer(mNativePtr, sceneLayer);
+ }
+
+ @Override
+ protected void initializeNative() {
+ if (mNativePtr == 0) {
+ mNativePtr = nativeInit();
+ }
+ assert mNativePtr != 0;
+ }
+
+ @Override
+ public void destroy() {
+ super.destroy();
+ mNativePtr = 0;
+ }
+
+ private native long nativeInit();
+ private native void nativeUpdateTabLayer(long nativeStaticTabSceneLayer, float contentViewportX,
+ float contentViewportY, float contentViewportWidth, float contentViewportHeight,
+ TabContentManager tabContentManager, int id, int toolbarResourceId,
+ boolean canUseLiveLayer, boolean canUseNtpFallback, int backgroundColor, float x,
+ float y, float width, float height, float contentOffsetY, float staticToViewBlend,
+ float saturation);
+ private native void nativeSetContentSceneLayer(
+ long nativeStaticTabSceneLayer, SceneLayer sceneLayer);
+}

Powered by Google App Engine
This is Rietveld 408576698