OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/android/compositor/layer/toolbar_layer.h" |
| 6 |
| 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" |
| 12 |
| 13 const SkColor kNormalAnonymizeContentColor = SK_ColorWHITE; |
| 14 const SkColor kIncognitoAnonymizeContentColor = 0xFF737373; |
| 15 |
| 16 namespace chrome { |
| 17 namespace android { |
| 18 |
| 19 // static |
| 20 scoped_refptr<ToolbarLayer> ToolbarLayer::Create() { |
| 21 return make_scoped_refptr(new ToolbarLayer()); |
| 22 } |
| 23 |
| 24 scoped_refptr<cc::Layer> ToolbarLayer::layer() { |
| 25 return layer_; |
| 26 } |
| 27 |
| 28 void ToolbarLayer::PushResource(ui::ResourceManager::Resource* resource, |
| 29 bool anonymize, |
| 30 bool anonymize_component_is_incognito, |
| 31 bool show_debug) { |
| 32 DCHECK(resource); |
| 33 |
| 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()); |
| 37 |
| 38 bitmap_layer_->SetUIResourceId(resource->ui_resource->id()); |
| 39 bitmap_layer_->SetBounds(resource->size); |
| 40 |
| 41 anonymize_layer_->SetHideLayerAndSubtree(!anonymize); |
| 42 if (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); |
| 48 } |
| 49 |
| 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(); |
| 55 } |
| 56 |
| 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_); |
| 64 |
| 65 anonymize_layer_->SetHideLayerAndSubtree(true); |
| 66 anonymize_layer_->SetIsDrawable(true); |
| 67 anonymize_layer_->SetBackgroundColor(kNormalAnonymizeContentColor); |
| 68 layer_->AddChild(anonymize_layer_); |
| 69 |
| 70 debug_layer_->SetIsDrawable(true); |
| 71 debug_layer_->SetBackgroundColor(SK_ColorGREEN); |
| 72 debug_layer_->SetOpacity(0.5f); |
| 73 } |
| 74 |
| 75 ToolbarLayer::~ToolbarLayer() { |
| 76 } |
| 77 |
| 78 } // namespace android |
| 79 } // namespace chrome |
OLD | NEW |