| 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/decoration_title.h" | 5 #include "chrome/browser/android/compositor/decoration_title.h" |
| 6 | 6 |
| 7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 favicon_start_padding_ = favicon_start_padding; | 74 favicon_start_padding_ = favicon_start_padding; |
| 75 favicon_end_padding_ = favicon_end_padding; | 75 favicon_end_padding_ = favicon_end_padding; |
| 76 fade_width_ = fade_width; | 76 fade_width_ = fade_width; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void DecorationTitle::SetFaviconResourceId(int favicon_resource_id) { | 79 void DecorationTitle::SetFaviconResourceId(int favicon_resource_id) { |
| 80 favicon_resource_id_ = favicon_resource_id; | 80 favicon_resource_id_ = favicon_resource_id; |
| 81 } | 81 } |
| 82 | 82 |
| 83 void DecorationTitle::SetUIResourceIds() { | 83 void DecorationTitle::SetUIResourceIds() { |
| 84 ui::ResourceManager::Resource* title_resource = | 84 ui::Resource* title_resource = resource_manager_->GetResource( |
| 85 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, | 85 ui::ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, title_resource_id_); |
| 86 title_resource_id_); | |
| 87 if (title_resource) { | 86 if (title_resource) { |
| 88 layer_opaque_->SetUIResourceId(title_resource->ui_resource->id()); | 87 layer_opaque_->SetUIResourceId(title_resource->ui_resource()->id()); |
| 89 layer_fade_->SetUIResourceId(title_resource->ui_resource->id()); | 88 layer_fade_->SetUIResourceId(title_resource->ui_resource()->id()); |
| 90 title_size_ = title_resource->size; | 89 title_size_ = title_resource->size(); |
| 91 } | 90 } |
| 92 | 91 |
| 93 if (!is_loading_) { | 92 if (!is_loading_) { |
| 94 ui::ResourceManager::Resource* favicon_resource = | 93 ui::Resource* favicon_resource = resource_manager_->GetResource( |
| 95 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, | 94 ui::ANDROID_RESOURCE_TYPE_DYNAMIC_BITMAP, favicon_resource_id_); |
| 96 favicon_resource_id_); | |
| 97 if (favicon_resource) { | 95 if (favicon_resource) { |
| 98 layer_favicon_->SetUIResourceId(favicon_resource->ui_resource->id()); | 96 layer_favicon_->SetUIResourceId(favicon_resource->ui_resource()->id()); |
| 99 favicon_size_ = favicon_resource->size; | 97 favicon_size_ = favicon_resource->size(); |
| 100 } else { | 98 } else { |
| 101 layer_favicon_->SetUIResourceId(0); | 99 layer_favicon_->SetUIResourceId(0); |
| 102 } | 100 } |
| 103 layer_favicon_->SetTransform(gfx::Transform()); | 101 layer_favicon_->SetTransform(gfx::Transform()); |
| 104 } else { | 102 } else { |
| 105 int resource_id = | 103 int resource_id = |
| 106 is_incognito_ ? spinner_incognito_resource_id_ : spinner_resource_id_; | 104 is_incognito_ ? spinner_incognito_resource_id_ : spinner_resource_id_; |
| 107 | 105 |
| 108 ui::ResourceManager::Resource* spinner_resource = | 106 ui::Resource* spinner_resource = resource_manager_->GetResource( |
| 109 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 107 ui::ANDROID_RESOURCE_TYPE_STATIC, resource_id); |
| 110 resource_id); | |
| 111 | 108 |
| 112 if (spinner_resource) | 109 if (spinner_resource) |
| 113 layer_favicon_->SetUIResourceId(spinner_resource->ui_resource->id()); | 110 layer_favicon_->SetUIResourceId(spinner_resource->ui_resource()->id()); |
| 114 | 111 |
| 115 // Rotate about the center of the layer. | 112 // Rotate about the center of the layer. |
| 116 layer_favicon_->SetTransformOrigin( | 113 layer_favicon_->SetTransformOrigin( |
| 117 gfx::Point3F(favicon_size_.width() / 2, favicon_size_.height() / 2, 0)); | 114 gfx::Point3F(favicon_size_.width() / 2, favicon_size_.height() / 2, 0)); |
| 118 } | 115 } |
| 119 | 116 |
| 120 size_ = gfx::Size(title_size_.width() + favicon_size_.width(), | 117 size_ = gfx::Size(title_size_.width() + favicon_size_.width(), |
| 121 title_size_.height()); | 118 title_size_.height()); |
| 122 } | 119 } |
| 123 | 120 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 layer_fade_->SetIsDrawable(false); | 230 layer_fade_->SetIsDrawable(false); |
| 234 } | 231 } |
| 235 } | 232 } |
| 236 | 233 |
| 237 scoped_refptr<cc::Layer> DecorationTitle::layer() { | 234 scoped_refptr<cc::Layer> DecorationTitle::layer() { |
| 238 DCHECK(layer_.get()); | 235 DCHECK(layer_.get()); |
| 239 return layer_; | 236 return layer_; |
| 240 } | 237 } |
| 241 | 238 |
| 242 } // namespace android | 239 } // namespace android |
| OLD | NEW |