OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.compositor.scene_layer; |
| 6 |
| 7 import com.google.android.apps.chrome.R; |
| 8 |
| 9 import org.chromium.base.JNINamespace; |
| 10 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context
ualSearchPanel; |
| 11 import org.chromium.content.browser.ContentViewCore; |
| 12 import org.chromium.ui.resources.ResourceManager; |
| 13 |
| 14 import javax.annotation.Nullable; |
| 15 |
| 16 /** |
| 17 * A SceneLayer to render layers for ContextualSearchLayout. |
| 18 */ |
| 19 @JNINamespace("chrome::android") |
| 20 public class ContextualSearchSceneLayer extends SceneLayer { |
| 21 // NOTE: If you use SceneLayer's native pointer here, the JNI generator will
try to |
| 22 // downcast using reinterpret_cast<>. We keep a separate pointer to avoid it
. |
| 23 private long mNativePtr; |
| 24 |
| 25 private final float mDpToPx; |
| 26 private final ContextualSearchPanel mSearchPanel; |
| 27 |
| 28 public ContextualSearchSceneLayer(float dpToPx, ContextualSearchPanel search
Panel) { |
| 29 mDpToPx = dpToPx; |
| 30 mSearchPanel = searchPanel; |
| 31 } |
| 32 |
| 33 /** |
| 34 * Update contextual search's layer tree using the parameters. |
| 35 * |
| 36 * @param contentViewCore The CVC, may be null if only updating the bar. |
| 37 * @param resourceManager |
| 38 */ |
| 39 public void update(@Nullable ContentViewCore contentViewCore, ResourceManage
r resourceManager) { |
| 40 boolean searchPromoVisible = mSearchPanel.getPromoVisible(); |
| 41 float searchPromoHeightPx = mSearchPanel.getPromoHeightPx(); |
| 42 float searchPromoOpacity = mSearchPanel.getPromoOpacity(); |
| 43 |
| 44 float searchPanelY = mSearchPanel.getContextualSearchPanelY(); |
| 45 float searchPanelWidth = mSearchPanel.getWidth(); |
| 46 float searchBarMarginTop = mSearchPanel.getSearchBarMarginTop(); |
| 47 float searchBarHeight = mSearchPanel.getSearchBarHeight(); |
| 48 float searchBarTextOpacity = mSearchPanel.getSearchBarTextOpacity(); |
| 49 |
| 50 boolean searchBarBorderVisible = mSearchPanel.isSearchBarBorderVisible()
; |
| 51 float searchBarBorderY = mSearchPanel.getSearchBarBorderY(); |
| 52 float searchBarBorderHeight = mSearchPanel.getSearchBarBorderHeight(); |
| 53 |
| 54 boolean searchBarShadowVisible = mSearchPanel.getSearchBarShadowVisible(
); |
| 55 float searchBarShadowOpacity = mSearchPanel.getSearchBarShadowOpacity(); |
| 56 |
| 57 float searchProviderIconOpacity = mSearchPanel.getSearchProviderIconOpac
ity(); |
| 58 float searchIconPaddingLeft = mSearchPanel.getSearchIconPaddingLeft(); |
| 59 float searchIconOpacity = mSearchPanel.getSearchIconOpacity(); |
| 60 |
| 61 boolean isProgressBarVisible = mSearchPanel.isProgressBarVisible(); |
| 62 float progressBarY = mSearchPanel.getProgressBarY(); |
| 63 float progressBarHeight = mSearchPanel.getProgressBarHeight(); |
| 64 float progressBarOpacity = mSearchPanel.getProgressBarOpacity(); |
| 65 int progressBarCompletion = mSearchPanel.getProgressBarCompletion(); |
| 66 |
| 67 nativeUpdateContextualSearchLayer(mNativePtr, |
| 68 R.drawable.contextual_search_bar_background, |
| 69 R.id.contextual_search_view, |
| 70 R.drawable.contextual_search_bar_shadow, |
| 71 R.drawable.blue_google_icon, |
| 72 R.drawable.ic_search, |
| 73 R.drawable.progress_bar_background, |
| 74 R.drawable.progress_bar_foreground, |
| 75 R.id.contextual_search_opt_out_promo, |
| 76 contentViewCore, |
| 77 searchPromoVisible, |
| 78 searchPromoHeightPx, |
| 79 searchPromoOpacity, |
| 80 searchPanelY * mDpToPx, |
| 81 searchPanelWidth * mDpToPx, |
| 82 searchBarMarginTop * mDpToPx, |
| 83 searchBarHeight * mDpToPx, |
| 84 searchBarTextOpacity, |
| 85 searchBarBorderVisible, |
| 86 searchBarBorderY * mDpToPx, |
| 87 searchBarBorderHeight * mDpToPx, |
| 88 searchBarShadowVisible, |
| 89 searchBarShadowOpacity, |
| 90 searchProviderIconOpacity, |
| 91 searchIconPaddingLeft * mDpToPx, |
| 92 searchIconOpacity, |
| 93 isProgressBarVisible, |
| 94 progressBarY * mDpToPx, |
| 95 progressBarHeight * mDpToPx, |
| 96 progressBarOpacity, |
| 97 progressBarCompletion, |
| 98 resourceManager); |
| 99 } |
| 100 |
| 101 @Override |
| 102 protected void initializeNative() { |
| 103 if (mNativePtr == 0) { |
| 104 mNativePtr = nativeInit(); |
| 105 } |
| 106 assert mNativePtr != 0; |
| 107 } |
| 108 |
| 109 /** |
| 110 * Destroys this object and the corresponding native component. |
| 111 */ |
| 112 @Override |
| 113 public void destroy() { |
| 114 super.destroy(); |
| 115 mNativePtr = 0; |
| 116 } |
| 117 |
| 118 private native long nativeInit(); |
| 119 private native void nativeUpdateContextualSearchLayer( |
| 120 long nativeContextualSearchSceneLayer, |
| 121 int searchBarBackgroundResourceId, |
| 122 int searchBarTextResourceId, |
| 123 int searchBarShadowResourceId, |
| 124 int searchProviderIconResourceId, |
| 125 int searchIconResourceId, |
| 126 int progressBarBackgroundResourceId, |
| 127 int progressBarResourceId, |
| 128 int searchPromoResourceId, |
| 129 ContentViewCore contentViewCore, |
| 130 boolean searchPromoVisible, |
| 131 float searchPromoHeight, |
| 132 float searchPromoOpacity, |
| 133 float searchPanelY, |
| 134 float searchPanelWidth, |
| 135 float searchBarMarginTop, |
| 136 float searchBarHeight, |
| 137 float searchBarTextOpacity, |
| 138 boolean searchBarBorderVisible, |
| 139 float searchBarBorderY, |
| 140 float searchBarBorderHeight, |
| 141 boolean searchBarShadowVisible, |
| 142 float searchBarShadowOpacity, |
| 143 float searchProviderIconOpacity, |
| 144 float searchIconPaddingLeft, |
| 145 float searchIconOpacity, |
| 146 boolean isProgressBarVisible, |
| 147 float progressBarY, |
| 148 float progressBarHeight, |
| 149 float progressBarOpacity, |
| 150 int progressBarCompletion, |
| 151 ResourceManager resourceManager); |
| 152 } |
OLD | NEW |