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/tab_layer.h" | 5 #include "chrome/browser/android/compositor/layer/tab_layer.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "cc/layers/layer.h" | 8 #include "cc/layers/layer.h" |
9 #include "cc/layers/layer_lists.h" | 9 #include "cc/layers/layer_lists.h" |
10 #include "cc/layers/nine_patch_layer.h" | 10 #include "cc/layers/nine_patch_layer.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 float brightness, | 89 float brightness, |
90 float close_btn_width, | 90 float close_btn_width, |
91 float static_to_view_blend, | 91 float static_to_view_blend, |
92 float content_width, | 92 float content_width, |
93 float content_height, | 93 float content_height, |
94 float view_width, | 94 float view_width, |
95 float view_height, | 95 float view_height, |
96 bool show_toolbar, | 96 bool show_toolbar, |
97 int toolbar_background_color, | 97 int toolbar_background_color, |
98 bool anonymize_toolbar, | 98 bool anonymize_toolbar, |
| 99 int toolbar_textbox_resource_id, |
99 int toolbar_textbox_background_color, | 100 int toolbar_textbox_background_color, |
| 101 float toolbar_textbox_alpha, |
100 float toolbar_alpha, | 102 float toolbar_alpha, |
101 float toolbar_y_offset, | 103 float toolbar_y_offset, |
102 float side_border_scale, | 104 float side_border_scale, |
103 bool attach_content, | 105 bool attach_content, |
104 bool inset_border) { | 106 bool inset_border) { |
105 if (alpha <= 0) { | 107 if (alpha <= 0) { |
106 layer_->SetHideLayerAndSubtree(true); | 108 layer_->SetHideLayerAndSubtree(true); |
107 return; | 109 return; |
108 } | 110 } |
109 | 111 |
110 layer_->SetHideLayerAndSubtree(false); | 112 layer_->SetHideLayerAndSubtree(false); |
111 | 113 |
112 // Grab required resources | 114 // Grab required resources |
113 ui::ResourceManager::Resource* border_resource = | 115 ui::ResourceManager::Resource* border_resource = |
114 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 116 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
115 border_resource_id); | 117 border_resource_id); |
116 ui::ResourceManager::Resource* shadow_resource = | 118 ui::ResourceManager::Resource* shadow_resource = |
117 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 119 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
118 shadow_resource_id); | 120 shadow_resource_id); |
119 ui::ResourceManager::Resource* contour_resource = | 121 ui::ResourceManager::Resource* contour_resource = |
120 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 122 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
121 contour_resource_id); | 123 contour_resource_id); |
122 ui::ResourceManager::Resource* toolbar_resource = | |
123 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, | |
124 toolbar_resource_id); | |
125 ui::ResourceManager::Resource* close_btn_resource = | 124 ui::ResourceManager::Resource* close_btn_resource = |
126 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 125 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
127 close_button_resource_id); | 126 close_button_resource_id); |
128 ui::ResourceManager::Resource* back_logo_resource = nullptr; | 127 ui::ResourceManager::Resource* back_logo_resource = nullptr; |
129 | 128 |
130 DecorationTitle* title_layer = nullptr; | 129 DecorationTitle* title_layer = nullptr; |
131 | 130 |
132 //---------------------------------------------------------------------------- | 131 //---------------------------------------------------------------------------- |
133 // Handle Border Scaling (Upscale/Downscale everything until final scaling) | 132 // Handle Border Scaling (Upscale/Downscale everything until final scaling) |
134 //---------------------------------------------------------------------------- | 133 //---------------------------------------------------------------------------- |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 shadow_resource->size.height() - shadow_padding.height()); | 167 shadow_resource->size.height() - shadow_padding.height()); |
169 const gfx::Size border_padding_size( | 168 const gfx::Size border_padding_size( |
170 border_resource->size.width() - border_padding.width(), | 169 border_resource->size.width() - border_padding.width(), |
171 border_resource->size.height() - border_padding.height()); | 170 border_resource->size.height() - border_padding.height()); |
172 const gfx::Size contour_padding_size( | 171 const gfx::Size contour_padding_size( |
173 contour_resource->size.width() - contour_padding.width(), | 172 contour_resource->size.width() - contour_padding.width(), |
174 contour_resource->size.height() - contour_padding.height()); | 173 contour_resource->size.height() - contour_padding.height()); |
175 | 174 |
176 const float close_btn_effective_width = close_btn_width * close_alpha; | 175 const float close_btn_effective_width = close_btn_width * close_alpha; |
177 | 176 |
| 177 //-------------------------------------------------------------------------- |
| 178 // Update Resource Ids For Layers That Impact Layout |
| 179 //-------------------------------------------------------------------------- |
| 180 |
| 181 // TODO(kkimlabs): Tab switcher doesn't show the progress bar. |
| 182 toolbar_layer_->PushResource(toolbar_resource_id, |
| 183 toolbar_background_color, |
| 184 anonymize_toolbar, |
| 185 toolbar_textbox_background_color, |
| 186 toolbar_textbox_resource_id, |
| 187 toolbar_textbox_alpha, |
| 188 false, |
| 189 1.f, |
| 190 false); |
| 191 toolbar_layer_->UpdateProgressBar(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
| 192 |
178 float toolbar_impact_height = 0; | 193 float toolbar_impact_height = 0; |
179 if (toolbar_resource) { | 194 if (show_toolbar && !back_visible) |
180 //-------------------------------------------------------------------------- | 195 toolbar_impact_height = toolbar_layer_->layer()->bounds().height(); |
181 // Update Resource Ids For Layers That Impact Layout | |
182 //-------------------------------------------------------------------------- | |
183 | |
184 // TODO(kkimlabs): Tab switcher doesn't show the progress bar. | |
185 toolbar_layer_->PushResource(toolbar_resource, | |
186 toolbar_background_color, | |
187 anonymize_toolbar, | |
188 toolbar_textbox_background_color, | |
189 false, | |
190 1.f); | |
191 toolbar_layer_->UpdateProgressBar(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
192 | |
193 if (show_toolbar && !back_visible) | |
194 toolbar_impact_height = toolbar_resource->padding.height(); | |
195 } | |
196 | 196 |
197 //---------------------------------------------------------------------------- | 197 //---------------------------------------------------------------------------- |
198 // Compute Alpha and Visibility | 198 // Compute Alpha and Visibility |
199 //---------------------------------------------------------------------------- | 199 //---------------------------------------------------------------------------- |
200 border_alpha *= alpha; | 200 border_alpha *= alpha; |
201 contour_alpha *= alpha; | 201 contour_alpha *= alpha; |
202 shadow_alpha *= alpha; | 202 shadow_alpha *= alpha; |
203 close_alpha *= alpha; | 203 close_alpha *= alpha; |
204 toolbar_alpha *= alpha; | 204 toolbar_alpha *= alpha; |
205 | 205 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 } | 536 } |
537 | 537 |
538 TabLayer::TabLayer(bool incognito, | 538 TabLayer::TabLayer(bool incognito, |
539 ui::ResourceManager* resource_manager, | 539 ui::ResourceManager* resource_manager, |
540 LayerTitleCache* layer_title_cache, | 540 LayerTitleCache* layer_title_cache, |
541 TabContentManager* tab_content_manager) | 541 TabContentManager* tab_content_manager) |
542 : incognito_(incognito), | 542 : incognito_(incognito), |
543 resource_manager_(resource_manager), | 543 resource_manager_(resource_manager), |
544 layer_title_cache_(layer_title_cache), | 544 layer_title_cache_(layer_title_cache), |
545 layer_(cc::Layer::Create(content::Compositor::LayerSettings())), | 545 layer_(cc::Layer::Create(content::Compositor::LayerSettings())), |
546 toolbar_layer_(ToolbarLayer::Create()), | 546 toolbar_layer_(ToolbarLayer::Create(resource_manager)), |
547 title_(cc::Layer::Create(content::Compositor::LayerSettings())), | 547 title_(cc::Layer::Create(content::Compositor::LayerSettings())), |
548 content_(ContentLayer::Create(tab_content_manager)), | 548 content_(ContentLayer::Create(tab_content_manager)), |
549 padding_( | 549 padding_( |
550 cc::SolidColorLayer::Create(content::Compositor::LayerSettings())), | 550 cc::SolidColorLayer::Create(content::Compositor::LayerSettings())), |
551 close_button_( | 551 close_button_( |
552 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), | 552 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), |
553 front_border_( | 553 front_border_( |
554 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())), | 554 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())), |
555 contour_shadow_( | 555 contour_shadow_( |
556 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())), | 556 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 title_->AddChild(layer); | 591 title_->AddChild(layer); |
592 } | 592 } |
593 } | 593 } |
594 | 594 |
595 if (title) | 595 if (title) |
596 title->SetUIResourceIds(); | 596 title->SetUIResourceIds(); |
597 } | 597 } |
598 | 598 |
599 } // namespace android | 599 } // namespace android |
600 } // namespace chrome | 600 } // namespace chrome |
OLD | NEW |