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

Unified Diff: chrome/browser/android/compositor/layer/toolbar_layer.cc

Issue 2228823003: When possible, draw the toolbar shadow with the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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/browser/android/compositor/layer/toolbar_layer.cc
diff --git a/chrome/browser/android/compositor/layer/toolbar_layer.cc b/chrome/browser/android/compositor/layer/toolbar_layer.cc
index a98ddbe59107ccfca56fcb40e6d2cfa9b5f45e77..1e4f411406200079206cd542e43c52746d2392b5 100644
--- a/chrome/browser/android/compositor/layer/toolbar_layer.cc
+++ b/chrome/browser/android/compositor/layer/toolbar_layer.cc
@@ -27,16 +27,20 @@ scoped_refptr<cc::Layer> ToolbarLayer::layer() {
void ToolbarLayer::PushResource(
int toolbar_resource_id,
+ int toolbar_shadow_resource_id,
int toolbar_background_color,
bool anonymize,
int toolbar_textbox_background_color,
int url_bar_background_resource_id,
float url_bar_alpha,
bool show_debug,
- bool clip_shadow) {
+ bool show_shadow) {
ui::ResourceManager::Resource* resource =
resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC,
toolbar_resource_id);
+ ui::ResourceManager::Resource* shadow_resource =
+ resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC,
+ toolbar_shadow_resource_id);
// Ensure the toolbar resource is available before making the layer visible.
layer_->SetHideLayerAndSubtree(!resource);
@@ -87,7 +91,14 @@ void ToolbarLayer::PushResource(
bitmap_layer_->SetUIResourceId(resource->ui_resource->id());
bitmap_layer_->SetBounds(resource->size);
- layer_->SetMasksToBounds(clip_shadow);
+ if (shadow_resource) {
+ toolbar_shadow_layer_->SetUIResourceId(shadow_resource->ui_resource->id());
+ toolbar_shadow_layer_->SetBounds(
+ gfx::Size(resource->size.width(), shadow_resource->size.height()));
+ toolbar_shadow_layer_->SetPosition(
+ gfx::PointF(0.0f, resource->padding.size().height()));
+ toolbar_shadow_layer_->SetHideLayerAndSubtree(!show_shadow);
+ }
anonymize_layer_->SetHideLayerAndSubtree(!anonymize);
if (anonymize) {
@@ -142,6 +153,7 @@ ToolbarLayer::ToolbarLayer(ui::ResourceManager* resource_manager)
: resource_manager_(resource_manager),
layer_(cc::Layer::Create()),
toolbar_background_layer_(cc::SolidColorLayer::Create()),
+ toolbar_shadow_layer_(cc::UIResourceLayer::Create()),
url_bar_background_layer_(cc::NinePatchLayer::Create()),
bitmap_layer_(cc::UIResourceLayer::Create()),
progress_bar_layer_(cc::SolidColorLayer::Create()),
@@ -151,6 +163,9 @@ ToolbarLayer::ToolbarLayer(ui::ResourceManager* resource_manager)
toolbar_background_layer_->SetIsDrawable(true);
layer_->AddChild(toolbar_background_layer_);
+ toolbar_shadow_layer_->SetIsDrawable(true);
+ layer_->AddChild(toolbar_shadow_layer_);
+
url_bar_background_layer_->SetIsDrawable(true);
url_bar_background_layer_->SetFillCenter(true);
layer_->AddChild(url_bar_background_layer_);

Powered by Google App Engine
This is Rietveld 408576698