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

Side by Side Diff: chrome/browser/android/compositor/layer/overlay_panel_layer.cc

Issue 2142263002: Remove ContentViewCore dependency from OverlayPanel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: var name Created 4 years, 5 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
OLDNEW
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 #include "chrome/browser/android/compositor/layer/overlay_panel_layer.h" 5 #include "chrome/browser/android/compositor/layer/overlay_panel_layer.h"
6 6
7 #include "cc/layers/layer.h" 7 #include "cc/layers/layer.h"
8 #include "cc/layers/nine_patch_layer.h" 8 #include "cc/layers/nine_patch_layer.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/layers/ui_resource_layer.h" 10 #include "cc/layers/ui_resource_layer.h"
11 #include "cc/resources/scoped_ui_resource.h" 11 #include "cc/resources/scoped_ui_resource.h"
12 #include "content/public/browser/android/compositor.h" 12 #include "content/public/browser/android/compositor.h"
13 #include "content/public/browser/android/content_view_core.h"
14 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/android/resources/crushed_sprite_resource.h" 14 #include "ui/android/resources/crushed_sprite_resource.h"
16 #include "ui/android/resources/resource_manager.h" 15 #include "ui/android/resources/resource_manager.h"
17 #include "ui/base/l10n/l10n_util_android.h" 16 #include "ui/base/l10n/l10n_util_android.h"
18 #include "ui/gfx/color_utils.h" 17 #include "ui/gfx/color_utils.h"
19 18
20 namespace { 19 namespace {
21 20
22 const SkColor kBarBackgroundColor = SkColorSetRGB(0xff, 0xff, 0xff); 21 const SkColor kBarBackgroundColor = SkColorSetRGB(0xff, 0xff, 0xff);
23 const SkColor kBarBorderColor = SkColorSetRGB(0xf1, 0xf1, 0xf1); 22 const SkColor kBarBorderColor = SkColorSetRGB(0xf1, 0xf1, 0xf1);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 int close_icon_resource_id) { 58 int close_icon_resource_id) {
60 bar_text_resource_id_ = bar_text_resource_id; 59 bar_text_resource_id_ = bar_text_resource_id;
61 panel_shadow_resource_id_ = panel_shadow_resource_id; 60 panel_shadow_resource_id_ = panel_shadow_resource_id;
62 bar_shadow_resource_id_ = bar_shadow_resource_id; 61 bar_shadow_resource_id_ = bar_shadow_resource_id;
63 panel_icon_resource_id_ = panel_icon_resource_id; 62 panel_icon_resource_id_ = panel_icon_resource_id;
64 close_icon_resource_id_ = close_icon_resource_id; 63 close_icon_resource_id_ = close_icon_resource_id;
65 } 64 }
66 65
67 void OverlayPanelLayer::SetProperties( 66 void OverlayPanelLayer::SetProperties(
68 float dp_to_px, 67 float dp_to_px,
69 content::ContentViewCore* content_view_core, 68 const scoped_refptr<cc::Layer>& content_layer,
70 float content_view_core_offset_y, 69 float content_offset_y,
71 float panel_x, 70 float panel_x,
72 float panel_y, 71 float panel_y,
73 float panel_width, 72 float panel_width,
74 float panel_height, 73 float panel_height,
75 float bar_margin_side, 74 float bar_margin_side,
76 float bar_height, 75 float bar_height,
77 float bar_offset_y, 76 float bar_offset_y,
78 float bar_text_opacity, 77 float bar_text_opacity,
79 bool bar_border_visible, 78 bool bar_border_visible,
80 float bar_border_height, 79 float bar_border_height,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bar_height / 2 - 189 bar_height / 2 -
191 close_icon_resource->size.height() / 2; 190 close_icon_resource->size.height() / 2;
192 191
193 close_icon_->SetUIResourceId(close_icon_resource->ui_resource->id()); 192 close_icon_->SetUIResourceId(close_icon_resource->ui_resource->id());
194 close_icon_->SetBounds(close_icon_resource->size); 193 close_icon_->SetBounds(close_icon_resource->size);
195 close_icon_->SetPosition( 194 close_icon_->SetPosition(
196 gfx::PointF(close_icon_left, close_icon_top)); 195 gfx::PointF(close_icon_left, close_icon_top));
197 close_icon_->SetOpacity(close_icon_opacity); 196 close_icon_->SetOpacity(close_icon_opacity);
198 197
199 // --------------------------------------------------------------------------- 198 // ---------------------------------------------------------------------------
200 // Content View 199 // Content
201 // --------------------------------------------------------------------------- 200 // ---------------------------------------------------------------------------
202 content_view_container_->SetPosition( 201 content_container_->SetPosition(
203 gfx::PointF(0.f, content_view_core_offset_y)); 202 gfx::PointF(0.f, content_offset_y));
204 content_view_container_->SetBounds(gfx::Size(panel_width, panel_height)); 203 content_container_->SetBounds(gfx::Size(panel_width, panel_height));
205 if (content_view_core && content_view_core->GetLayer()) { 204 if (content_layer) {
206 scoped_refptr<cc::Layer> content_view_layer = content_view_core->GetLayer(); 205 if (content_layer->parent() != content_container_)
207 if (content_view_layer->parent() != content_view_container_) 206 content_container_->AddChild(content_layer);
208 content_view_container_->AddChild(content_view_layer);
209 } else { 207 } else {
210 content_view_container_->RemoveAllChildren(); 208 content_container_->RemoveAllChildren();
211 } 209 }
212 210
213 // --------------------------------------------------------------------------- 211 // ---------------------------------------------------------------------------
214 // Bar Shadow 212 // Bar Shadow
215 // --------------------------------------------------------------------------- 213 // ---------------------------------------------------------------------------
216 if (bar_shadow_visible) { 214 if (bar_shadow_visible) {
217 ui::ResourceManager::Resource* bar_shadow_resource = 215 ui::ResourceManager::Resource* bar_shadow_resource =
218 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 216 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC,
219 bar_shadow_resource_id_); 217 bar_shadow_resource_id_);
220 218
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 257
260 OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager) 258 OverlayPanelLayer::OverlayPanelLayer(ui::ResourceManager* resource_manager)
261 : resource_manager_(resource_manager), 259 : resource_manager_(resource_manager),
262 layer_(cc::Layer::Create()), 260 layer_(cc::Layer::Create()),
263 panel_shadow_(cc::NinePatchLayer::Create()), 261 panel_shadow_(cc::NinePatchLayer::Create()),
264 bar_background_(cc::SolidColorLayer::Create()), 262 bar_background_(cc::SolidColorLayer::Create()),
265 bar_text_(cc::UIResourceLayer::Create()), 263 bar_text_(cc::UIResourceLayer::Create()),
266 bar_shadow_(cc::UIResourceLayer::Create()), 264 bar_shadow_(cc::UIResourceLayer::Create()),
267 panel_icon_(cc::UIResourceLayer::Create()), 265 panel_icon_(cc::UIResourceLayer::Create()),
268 close_icon_(cc::UIResourceLayer::Create()), 266 close_icon_(cc::UIResourceLayer::Create()),
269 content_view_container_(cc::SolidColorLayer::Create()), 267 content_container_(cc::SolidColorLayer::Create()),
270 text_container_(cc::Layer::Create()), 268 text_container_(cc::Layer::Create()),
271 bar_border_(cc::SolidColorLayer::Create()) { 269 bar_border_(cc::SolidColorLayer::Create()) {
272 layer_->SetMasksToBounds(false); 270 layer_->SetMasksToBounds(false);
273 layer_->SetIsDrawable(true); 271 layer_->SetIsDrawable(true);
274 272
275 // Panel Shadow 273 // Panel Shadow
276 panel_shadow_->SetIsDrawable(true); 274 panel_shadow_->SetIsDrawable(true);
277 panel_shadow_->SetFillCenter(false); 275 panel_shadow_->SetFillCenter(false);
278 layer_->AddChild(panel_shadow_); 276 layer_->AddChild(panel_shadow_);
279 277
(...skipping 10 matching lines...) Expand all
290 // Panel Icon 288 // Panel Icon
291 panel_icon_->SetIsDrawable(true); 289 panel_icon_->SetIsDrawable(true);
292 290
293 // The container that any text in the bar will be added to. 291 // The container that any text in the bar will be added to.
294 text_container_->SetIsDrawable(true); 292 text_container_->SetIsDrawable(true);
295 293
296 // Close Icon 294 // Close Icon
297 close_icon_->SetIsDrawable(true); 295 close_icon_->SetIsDrawable(true);
298 layer_->AddChild(close_icon_); 296 layer_->AddChild(close_icon_);
299 297
300 // Content View Container 298 // Content Container
301 content_view_container_->SetIsDrawable(true); 299 content_container_->SetIsDrawable(true);
302 content_view_container_->SetBackgroundColor(kBarBackgroundColor); 300 content_container_->SetBackgroundColor(kBarBackgroundColor);
303 layer_->AddChild(content_view_container_); 301 layer_->AddChild(content_container_);
304 302
305 // Bar Border 303 // Bar Border
306 bar_border_->SetIsDrawable(true); 304 bar_border_->SetIsDrawable(true);
307 bar_border_->SetBackgroundColor(kBarBorderColor); 305 bar_border_->SetBackgroundColor(kBarBorderColor);
308 306
309 // Bar Shadow 307 // Bar Shadow
310 bar_shadow_->SetIsDrawable(true); 308 bar_shadow_->SetIsDrawable(true);
311 } 309 }
312 310
313 OverlayPanelLayer::~OverlayPanelLayer() { 311 OverlayPanelLayer::~OverlayPanelLayer() {
314 } 312 }
315 313
316 scoped_refptr<cc::Layer> OverlayPanelLayer::layer() { 314 scoped_refptr<cc::Layer> OverlayPanelLayer::layer() {
317 return layer_; 315 return layer_;
318 } 316 }
319 317
320 } // namespace android 318 } // namespace android
321 } // namespace chrome 319 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698