| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar_layer.h" | 5 #include "chrome/browser/android/compositor/layer/toolbar_layer.h" |
| 6 | 6 |
| 7 #include "cc/layers/nine_patch_layer.h" | 7 #include "cc/layers/nine_patch_layer.h" |
| 8 #include "cc/layers/solid_color_layer.h" | 8 #include "cc/layers/solid_color_layer.h" |
| 9 #include "cc/layers/ui_resource_layer.h" | 9 #include "cc/layers/ui_resource_layer.h" |
| 10 #include "cc/resources/scoped_ui_resource.h" | 10 #include "cc/resources/scoped_ui_resource.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ToolbarLayer::PushResource( | 28 void ToolbarLayer::PushResource( |
| 29 int toolbar_resource_id, | 29 int toolbar_resource_id, |
| 30 int toolbar_background_color, | 30 int toolbar_background_color, |
| 31 bool anonymize, | 31 bool anonymize, |
| 32 int toolbar_textbox_background_color, | 32 int toolbar_textbox_background_color, |
| 33 int url_bar_background_resource_id, | 33 int url_bar_background_resource_id, |
| 34 float url_bar_alpha, | 34 float url_bar_alpha, |
| 35 bool show_debug, | 35 bool show_debug, |
| 36 float brightness, | |
| 37 bool clip_shadow) { | 36 bool clip_shadow) { |
| 38 ui::ResourceManager::Resource* resource = | 37 ui::ResourceManager::Resource* resource = |
| 39 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, | 38 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, |
| 40 toolbar_resource_id); | 39 toolbar_resource_id); |
| 41 | 40 |
| 42 // Ensure the toolbar resource is available before making the layer visible. | 41 // Ensure the toolbar resource is available before making the layer visible. |
| 43 layer_->SetHideLayerAndSubtree(!resource); | 42 layer_->SetHideLayerAndSubtree(!resource); |
| 44 if (!resource) | 43 if (!resource) |
| 45 return; | 44 return; |
| 46 | 45 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 anonymize_layer_->SetPosition(gfx::PointF(resource->aperture.origin())); | 94 anonymize_layer_->SetPosition(gfx::PointF(resource->aperture.origin())); |
| 96 anonymize_layer_->SetBounds(resource->aperture.size()); | 95 anonymize_layer_->SetBounds(resource->aperture.size()); |
| 97 anonymize_layer_->SetBackgroundColor(toolbar_textbox_background_color); | 96 anonymize_layer_->SetBackgroundColor(toolbar_textbox_background_color); |
| 98 } | 97 } |
| 99 | 98 |
| 100 debug_layer_->SetBounds(resource->size); | 99 debug_layer_->SetBounds(resource->size); |
| 101 if (show_debug && !debug_layer_->parent()) | 100 if (show_debug && !debug_layer_->parent()) |
| 102 layer_->AddChild(debug_layer_); | 101 layer_->AddChild(debug_layer_); |
| 103 else if (!show_debug && debug_layer_->parent()) | 102 else if (!show_debug && debug_layer_->parent()) |
| 104 debug_layer_->RemoveFromParent(); | 103 debug_layer_->RemoveFromParent(); |
| 105 | |
| 106 if (brightness != brightness_) { | |
| 107 brightness_ = brightness; | |
| 108 cc::FilterOperations filters; | |
| 109 if (brightness_ < 1.f) | |
| 110 filters.Append(cc::FilterOperation::CreateBrightnessFilter(brightness_)); | |
| 111 layer_->SetFilters(filters); | |
| 112 } | |
| 113 } | 104 } |
| 114 | 105 |
| 115 void ToolbarLayer::UpdateProgressBar(int progress_bar_x, | 106 void ToolbarLayer::UpdateProgressBar(int progress_bar_x, |
| 116 int progress_bar_y, | 107 int progress_bar_y, |
| 117 int progress_bar_width, | 108 int progress_bar_width, |
| 118 int progress_bar_height, | 109 int progress_bar_height, |
| 119 int progress_bar_color, | 110 int progress_bar_color, |
| 120 int progress_bar_background_x, | 111 int progress_bar_background_x, |
| 121 int progress_bar_background_y, | 112 int progress_bar_background_y, |
| 122 int progress_bar_background_width, | 113 int progress_bar_background_width, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 149 | 140 |
| 150 ToolbarLayer::ToolbarLayer(ui::ResourceManager* resource_manager) | 141 ToolbarLayer::ToolbarLayer(ui::ResourceManager* resource_manager) |
| 151 : resource_manager_(resource_manager), | 142 : resource_manager_(resource_manager), |
| 152 layer_(cc::Layer::Create()), | 143 layer_(cc::Layer::Create()), |
| 153 toolbar_background_layer_(cc::SolidColorLayer::Create()), | 144 toolbar_background_layer_(cc::SolidColorLayer::Create()), |
| 154 url_bar_background_layer_(cc::NinePatchLayer::Create()), | 145 url_bar_background_layer_(cc::NinePatchLayer::Create()), |
| 155 bitmap_layer_(cc::UIResourceLayer::Create()), | 146 bitmap_layer_(cc::UIResourceLayer::Create()), |
| 156 progress_bar_layer_(cc::SolidColorLayer::Create()), | 147 progress_bar_layer_(cc::SolidColorLayer::Create()), |
| 157 progress_bar_background_layer_(cc::SolidColorLayer::Create()), | 148 progress_bar_background_layer_(cc::SolidColorLayer::Create()), |
| 158 anonymize_layer_(cc::SolidColorLayer::Create()), | 149 anonymize_layer_(cc::SolidColorLayer::Create()), |
| 159 debug_layer_(cc::SolidColorLayer::Create()), | 150 debug_layer_(cc::SolidColorLayer::Create()) { |
| 160 brightness_(1.f) { | |
| 161 toolbar_background_layer_->SetIsDrawable(true); | 151 toolbar_background_layer_->SetIsDrawable(true); |
| 162 layer_->AddChild(toolbar_background_layer_); | 152 layer_->AddChild(toolbar_background_layer_); |
| 163 | 153 |
| 164 url_bar_background_layer_->SetIsDrawable(true); | 154 url_bar_background_layer_->SetIsDrawable(true); |
| 165 url_bar_background_layer_->SetFillCenter(true); | 155 url_bar_background_layer_->SetFillCenter(true); |
| 166 layer_->AddChild(url_bar_background_layer_); | 156 layer_->AddChild(url_bar_background_layer_); |
| 167 | 157 |
| 168 bitmap_layer_->SetIsDrawable(true); | 158 bitmap_layer_->SetIsDrawable(true); |
| 169 layer_->AddChild(bitmap_layer_); | 159 layer_->AddChild(bitmap_layer_); |
| 170 | 160 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 183 debug_layer_->SetIsDrawable(true); | 173 debug_layer_->SetIsDrawable(true); |
| 184 debug_layer_->SetBackgroundColor(SK_ColorGREEN); | 174 debug_layer_->SetBackgroundColor(SK_ColorGREEN); |
| 185 debug_layer_->SetOpacity(0.5f); | 175 debug_layer_->SetOpacity(0.5f); |
| 186 } | 176 } |
| 187 | 177 |
| 188 ToolbarLayer::~ToolbarLayer() { | 178 ToolbarLayer::~ToolbarLayer() { |
| 189 } | 179 } |
| 190 | 180 |
| 191 } // namespace android | 181 } // namespace android |
| 192 } // namespace chrome | 182 } // namespace chrome |
| OLD | NEW |