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

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

Issue 986683002: [Android] Allow specifying the progress component of the toolbar as a separate texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Javadoc fix Created 5 years, 9 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 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/solid_color_layer.h" 7 #include "cc/layers/solid_color_layer.h"
8 #include "cc/layers/ui_resource_layer.h" 8 #include "cc/layers/ui_resource_layer.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/android/resources/resource_manager.h" 10 #include "ui/android/resources/resource_manager.h"
11 #include "ui/android/resources/ui_resource_android.h" 11 #include "ui/android/resources/ui_resource_android.h"
12 12
13 const SkColor kNormalAnonymizeContentColor = SK_ColorWHITE; 13 const SkColor kNormalAnonymizeContentColor = SK_ColorWHITE;
14 const SkColor kIncognitoAnonymizeContentColor = 0xFF737373; 14 const SkColor kIncognitoAnonymizeContentColor = 0xFF737373;
15 15
16 namespace chrome { 16 namespace chrome {
17 namespace android { 17 namespace android {
18 18
19 // static 19 // static
20 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() { 20 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() {
21 return make_scoped_refptr(new ToolbarLayer()); 21 return make_scoped_refptr(new ToolbarLayer());
22 } 22 }
23 23
24 scoped_refptr<cc::Layer> ToolbarLayer::layer() { 24 scoped_refptr<cc::Layer> ToolbarLayer::layer() {
25 return layer_; 25 return layer_;
26 } 26 }
27 27
28 void ToolbarLayer::PushResource(ui::ResourceManager::Resource* resource, 28 void ToolbarLayer::PushResource(
29 bool anonymize, 29 ui::ResourceManager::Resource* resource,
30 bool anonymize_component_is_incognito, 30 ui::ResourceManager::Resource* progress_resource,
31 bool show_debug) { 31 bool anonymize,
32 bool anonymize_component_is_incognito,
33 bool show_debug) {
32 DCHECK(resource); 34 DCHECK(resource);
33 35
34 // This layer effectively draws over the space it takes for shadows. Set the 36 // This layer effectively draws over the space it takes for shadows. Set the
35 // bounds to the non-shadow size so that other things can properly line up. 37 // bounds to the non-shadow size so that other things can properly line up.
36 layer_->SetBounds(resource->padding.size()); 38 layer_->SetBounds(resource->padding.size());
37 39
38 bitmap_layer_->SetUIResourceId(resource->ui_resource->id()); 40 bitmap_layer_->SetUIResourceId(resource->ui_resource->id());
39 bitmap_layer_->SetBounds(resource->size); 41 bitmap_layer_->SetBounds(resource->size);
40 42
41 anonymize_layer_->SetHideLayerAndSubtree(!anonymize); 43 anonymize_layer_->SetHideLayerAndSubtree(!anonymize);
42 if (anonymize) { 44 if (anonymize) {
43 anonymize_layer_->SetPosition(resource->aperture.origin()); 45 anonymize_layer_->SetPosition(resource->aperture.origin());
44 anonymize_layer_->SetBounds(resource->aperture.size()); 46 anonymize_layer_->SetBounds(resource->aperture.size());
45 anonymize_layer_->SetBackgroundColor(anonymize_component_is_incognito 47 anonymize_layer_->SetBackgroundColor(anonymize_component_is_incognito
46 ? kIncognitoAnonymizeContentColor 48 ? kIncognitoAnonymizeContentColor
47 : kNormalAnonymizeContentColor); 49 : kNormalAnonymizeContentColor);
48 } 50 }
49 51
52 progress_layer_->SetHideLayerAndSubtree(!progress_resource);
53 if (progress_resource) {
54 progress_layer_->SetUIResourceId(progress_resource->ui_resource->id());
55 progress_layer_->SetBounds(progress_resource->size);
56 progress_layer_->SetPosition(progress_resource->padding.origin());
57 }
58
50 debug_layer_->SetBounds(resource->size); 59 debug_layer_->SetBounds(resource->size);
51 if (show_debug && !debug_layer_->parent()) 60 if (show_debug && !debug_layer_->parent())
52 layer_->AddChild(debug_layer_); 61 layer_->AddChild(debug_layer_);
53 else if (!show_debug && debug_layer_->parent()) 62 else if (!show_debug && debug_layer_->parent())
54 debug_layer_->RemoveFromParent(); 63 debug_layer_->RemoveFromParent();
55 } 64 }
56 65
66 void ToolbarLayer::PushResource(ui::ResourceManager::Resource* resource,
67 bool anonymize,
68 bool anonymize_component_is_incognito,
69 bool show_debug) {
70 PushResource(resource,
71 nullptr,
72 anonymize,
73 anonymize_component_is_incognito,
74 show_debug);
75 }
76
57 ToolbarLayer::ToolbarLayer() 77 ToolbarLayer::ToolbarLayer()
58 : layer_(cc::Layer::Create()), 78 : layer_(cc::Layer::Create()),
59 bitmap_layer_(cc::UIResourceLayer::Create()), 79 bitmap_layer_(cc::UIResourceLayer::Create()),
80 progress_layer_(cc::UIResourceLayer::Create()),
60 anonymize_layer_(cc::SolidColorLayer::Create()), 81 anonymize_layer_(cc::SolidColorLayer::Create()),
61 debug_layer_(cc::SolidColorLayer::Create()) { 82 debug_layer_(cc::SolidColorLayer::Create()) {
62 bitmap_layer_->SetIsDrawable(true); 83 bitmap_layer_->SetIsDrawable(true);
63 layer_->AddChild(bitmap_layer_); 84 layer_->AddChild(bitmap_layer_);
64 85
86 progress_layer_->SetIsDrawable(true);
87 progress_layer_->SetHideLayerAndSubtree(true);
88 layer_->AddChild(progress_layer_);
89
65 anonymize_layer_->SetHideLayerAndSubtree(true); 90 anonymize_layer_->SetHideLayerAndSubtree(true);
66 anonymize_layer_->SetIsDrawable(true); 91 anonymize_layer_->SetIsDrawable(true);
67 anonymize_layer_->SetBackgroundColor(kNormalAnonymizeContentColor); 92 anonymize_layer_->SetBackgroundColor(kNormalAnonymizeContentColor);
68 layer_->AddChild(anonymize_layer_); 93 layer_->AddChild(anonymize_layer_);
69 94
70 debug_layer_->SetIsDrawable(true); 95 debug_layer_->SetIsDrawable(true);
71 debug_layer_->SetBackgroundColor(SK_ColorGREEN); 96 debug_layer_->SetBackgroundColor(SK_ColorGREEN);
72 debug_layer_->SetOpacity(0.5f); 97 debug_layer_->SetOpacity(0.5f);
73 } 98 }
74 99
75 ToolbarLayer::~ToolbarLayer() { 100 ToolbarLayer::~ToolbarLayer() {
76 } 101 }
77 102
78 } // namespace android 103 } // namespace android
79 } // namespace chrome 104 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698