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
3 // found in the LICENSE file.
5 #include "chrome/browser/android/compositor/layer/toolbar_layer.h"
7 #include "cc/layers/solid_color_layer.h"
8 #include "cc/layers/ui_resource_layer.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/android/resources/resource_manager.h"
11 #include "ui/android/resources/ui_resource_android.h"
13 const SkColor kNormalAnonymizeContentColor
= SK_ColorWHITE
;
14 const SkColor kIncognitoAnonymizeContentColor
= 0xFF737373;
20 scoped_refptr
<ToolbarLayer
> ToolbarLayer::Create() {
21 return make_scoped_refptr(new ToolbarLayer());
24 scoped_refptr
<cc::Layer
> ToolbarLayer::layer() {
28 void ToolbarLayer::PushResource(ui::ResourceManager::Resource
* resource
,
30 bool anonymize_component_is_incognito
,
34 // 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.
36 layer_
->SetBounds(resource
->padding
.size());
38 bitmap_layer_
->SetUIResourceId(resource
->ui_resource
->id());
39 bitmap_layer_
->SetBounds(resource
->size
);
41 anonymize_layer_
->SetHideLayerAndSubtree(!anonymize
);
43 anonymize_layer_
->SetPosition(resource
->aperture
.origin());
44 anonymize_layer_
->SetBounds(resource
->aperture
.size());
45 anonymize_layer_
->SetBackgroundColor(anonymize_component_is_incognito
46 ? kIncognitoAnonymizeContentColor
47 : kNormalAnonymizeContentColor
);
50 debug_layer_
->SetBounds(resource
->size
);
51 if (show_debug
&& !debug_layer_
->parent())
52 layer_
->AddChild(debug_layer_
);
53 else if (!show_debug
&& debug_layer_
->parent())
54 debug_layer_
->RemoveFromParent();
57 ToolbarLayer::ToolbarLayer()
58 : layer_(cc::Layer::Create()),
59 bitmap_layer_(cc::UIResourceLayer::Create()),
60 anonymize_layer_(cc::SolidColorLayer::Create()),
61 debug_layer_(cc::SolidColorLayer::Create()) {
62 bitmap_layer_
->SetIsDrawable(true);
63 layer_
->AddChild(bitmap_layer_
);
65 anonymize_layer_
->SetHideLayerAndSubtree(true);
66 anonymize_layer_
->SetIsDrawable(true);
67 anonymize_layer_
->SetBackgroundColor(kNormalAnonymizeContentColor
);
68 layer_
->AddChild(anonymize_layer_
);
70 debug_layer_
->SetIsDrawable(true);
71 debug_layer_
->SetBackgroundColor(SK_ColorGREEN
);
72 debug_layer_
->SetOpacity(0.5f
);
75 ToolbarLayer::~ToolbarLayer() {
78 } // namespace android