| 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/content_layer.h" | 5 #include "chrome/browser/android/compositor/layer/content_layer.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "cc/base/filter_operations.h" | 8 #include "cc/base/filter_operations.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/layers/layer_collections.h" | 10 #include "cc/layers/layer_collections.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 for (unsigned i = 0; i < children.size(); i++) { | 51 for (unsigned i = 0; i < children.size(); i++) { |
| 52 cc::Layer* leaf = GetDrawsContentLeaf(children[i]); | 52 cc::Layer* leaf = GetDrawsContentLeaf(children[i]); |
| 53 if (leaf) | 53 if (leaf) |
| 54 return leaf; | 54 return leaf; |
| 55 } | 55 } |
| 56 return nullptr; | 56 return nullptr; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ContentLayer::SetProperties(int id, | 59 void ContentLayer::SetProperties(int id, |
| 60 bool can_use_live_layer, | 60 bool can_use_live_layer, |
| 61 bool can_use_static_layer, |
| 61 float static_to_view_blend, | 62 float static_to_view_blend, |
| 62 bool should_override_content_alpha, | 63 bool should_override_content_alpha, |
| 63 float content_alpha_override, | 64 float content_alpha_override, |
| 64 float saturation, | 65 float saturation, |
| 65 bool should_clip, | 66 bool should_clip, |
| 66 const gfx::Rect& clip) { | 67 const gfx::Rect& clip) { |
| 67 scoped_refptr<cc::Layer> live_layer = tab_content_manager_->GetLiveLayer(id); | 68 scoped_refptr<cc::Layer> live_layer = tab_content_manager_->GetLiveLayer(id); |
| 68 if (live_layer) | 69 if (live_layer) |
| 69 live_layer->SetHideLayerAndSubtree(!can_use_live_layer); | 70 live_layer->SetHideLayerAndSubtree(!can_use_live_layer); |
| 70 bool live_layer_draws = GetDrawsContentLeaf(live_layer); | 71 bool live_layer_draws = GetDrawsContentLeaf(live_layer); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 83 for (unsigned i = 0; i < layer_children.size(); i++) | 84 for (unsigned i = 0; i < layer_children.size(); i++) |
| 84 layer_children[i]->RemoveFromParent(); | 85 layer_children[i]->RemoveFromParent(); |
| 85 | 86 |
| 86 if (live_layer.get()) { | 87 if (live_layer.get()) { |
| 87 live_layer->SetMasksToBounds(should_clip); | 88 live_layer->SetMasksToBounds(should_clip); |
| 88 live_layer->SetBounds(clip.size()); | 89 live_layer->SetBounds(clip.size()); |
| 89 SetOpacityOnLeaf(live_layer, content_opacity); | 90 SetOpacityOnLeaf(live_layer, content_opacity); |
| 90 | 91 |
| 91 layer_->AddChild(live_layer); | 92 layer_->AddChild(live_layer); |
| 92 } | 93 } |
| 93 if (static_layer.get()) { | 94 if (static_layer.get() && can_use_static_layer) { |
| 94 static_layer->layer()->SetIsDrawable(true); | 95 static_layer->layer()->SetIsDrawable(true); |
| 95 if (should_clip) | 96 if (should_clip) |
| 96 static_layer->Clip(clip); | 97 static_layer->Clip(clip); |
| 97 else | 98 else |
| 98 static_layer->ClearClip(); | 99 static_layer->ClearClip(); |
| 99 SetOpacityOnLeaf(static_layer->layer(), static_opacity); | 100 SetOpacityOnLeaf(static_layer->layer(), static_opacity); |
| 100 | 101 |
| 101 cc::FilterOperations static_filter_operations; | 102 cc::FilterOperations static_filter_operations; |
| 102 if (saturation < 1.0f) { | 103 if (saturation < 1.0f) { |
| 103 static_filter_operations.Append( | 104 static_filter_operations.Append( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 131 } | 132 } |
| 132 | 133 |
| 133 ContentLayer::ContentLayer(TabContentManager* tab_content_manager) | 134 ContentLayer::ContentLayer(TabContentManager* tab_content_manager) |
| 134 : layer_(cc::Layer::Create()), | 135 : layer_(cc::Layer::Create()), |
| 135 tab_content_manager_(tab_content_manager) {} | 136 tab_content_manager_(tab_content_manager) {} |
| 136 | 137 |
| 137 ContentLayer::~ContentLayer() { | 138 ContentLayer::~ContentLayer() { |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace android | 141 } // namespace android |
| OLD | NEW |