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 "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "cc/layers/layer_lists.h" | 8 #include "cc/layers/layer_lists.h" |
9 #include "chrome/browser/android/compositor/layer/thumbnail_layer.h" | 9 #include "chrome/browser/android/compositor/layer/thumbnail_layer.h" |
10 #include "chrome/browser/android/compositor/tab_content_manager.h" | 10 #include "chrome/browser/android/compositor/tab_content_manager.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 SetOpacityOnLeaf(layer_->children()[i], content_alpha_override); | 124 SetOpacityOnLeaf(layer_->children()[i], content_alpha_override); |
125 } | 125 } |
126 | 126 |
127 if (!content_layer_draws && !static_attached_) | 127 if (!content_layer_draws && !static_attached_) |
128 content_bounds = gfx::Size(0, 0); | 128 content_bounds = gfx::Size(0, 0); |
129 | 129 |
130 layer_->SetBounds(content_bounds); | 130 layer_->SetBounds(content_bounds); |
131 | 131 |
132 // Only worry about saturation on the static layer. | 132 // Only worry about saturation on the static layer. |
133 if (static_layer.get()) { | 133 if (static_layer.get()) { |
134 if (saturation != saturation_) { | 134 static_filter_operations_.Clear(); |
135 saturation_ = saturation; | 135 if (saturation < 1.0f) { |
136 cc::FilterOperations filters; | 136 static_filter_operations_.Append( |
137 if (saturation_ < 1.0f) | 137 cc::FilterOperation::CreateSaturateFilter(saturation)); |
138 filters.Append(cc::FilterOperation::CreateSaturateFilter(saturation_)); | |
139 static_layer->layer()->SetFilters(filters); | |
140 } | 138 } |
| 139 static_layer->layer()->SetFilters(static_filter_operations_); |
141 } | 140 } |
142 | 141 |
143 // Only worry about brightness on the content layer. | 142 // Only worry about brightness on the content layer. |
144 if (content_layer.get()) { | 143 if (content_layer.get()) { |
145 if (brightness != brightness_) { | 144 content_filter_operations_.Clear(); |
146 brightness_ = brightness; | 145 if (brightness < 1.0f) { |
147 cc::FilterOperations filters; | 146 content_filter_operations_.Append( |
148 if (brightness_ < 1.f) { | 147 cc::FilterOperation::CreateBrightnessFilter(brightness)); |
149 filters.Append( | |
150 cc::FilterOperation::CreateBrightnessFilter(brightness_)); | |
151 } | |
152 content_layer->SetFilters(filters); | |
153 } | 148 } |
| 149 content_layer->SetFilters(content_filter_operations_); |
154 } | 150 } |
155 } | 151 } |
156 | 152 |
157 gfx::Size ContentLayer::GetContentSize() { | 153 gfx::Size ContentLayer::GetContentSize() { |
158 if (content_attached_ && DoesLeafDrawContents(layer()->children()[0])) | 154 if (content_attached_ && DoesLeafDrawContents(layer()->children()[0])) |
159 return layer_->children()[0]->bounds(); | 155 return layer_->children()[0]->bounds(); |
160 return gfx::Size(0, 0); | 156 return gfx::Size(0, 0); |
161 } | 157 } |
162 | 158 |
163 scoped_refptr<cc::Layer> ContentLayer::layer() { | 159 scoped_refptr<cc::Layer> ContentLayer::layer() { |
164 return layer_; | 160 return layer_; |
165 } | 161 } |
166 | 162 |
167 ContentLayer::ContentLayer(TabContentManager* tab_content_manager) | 163 ContentLayer::ContentLayer(TabContentManager* tab_content_manager) |
168 : layer_(cc::Layer::Create()), | 164 : layer_(cc::Layer::Create()), |
169 content_attached_(false), | 165 content_attached_(false), |
170 static_attached_(false), | 166 static_attached_(false), |
171 saturation_(1.0f), | |
172 brightness_(1.0f), | |
173 tab_content_manager_(tab_content_manager) { | 167 tab_content_manager_(tab_content_manager) { |
174 } | 168 } |
175 | 169 |
176 ContentLayer::~ContentLayer() { | 170 ContentLayer::~ContentLayer() { |
177 } | 171 } |
178 | 172 |
179 void ContentLayer::SetContentLayer(scoped_refptr<cc::Layer> layer) { | 173 void ContentLayer::SetContentLayer(scoped_refptr<cc::Layer> layer) { |
180 // Check indices | 174 // Check indices |
181 // content_attached_, expect at least 1 child. | 175 // content_attached_, expect at least 1 child. |
182 DCHECK(!content_attached_ || layer_->children().size() > 0); | 176 DCHECK(!content_attached_ || layer_->children().size() > 0); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (!new_static_layer.get()) { | 213 if (!new_static_layer.get()) { |
220 if (static_layer_.get()) { | 214 if (static_layer_.get()) { |
221 static_layer_->layer()->RemoveFromParent(); | 215 static_layer_->layer()->RemoveFromParent(); |
222 static_layer_ = nullptr; | 216 static_layer_ = nullptr; |
223 } | 217 } |
224 static_attached_ = false; | 218 static_attached_ = false; |
225 return; | 219 return; |
226 } | 220 } |
227 static_layer_ = new_static_layer; | 221 static_layer_ = new_static_layer; |
228 static_layer_->AddSelfToParentOrReplaceAt(layer_, content_attached_ ? 1 : 0); | 222 static_layer_->AddSelfToParentOrReplaceAt(layer_, content_attached_ ? 1 : 0); |
229 saturation_ = -1.0f; | |
230 static_layer_->layer()->SetIsDrawable(true); | 223 static_layer_->layer()->SetIsDrawable(true); |
231 static_attached_ = true; | 224 static_attached_ = true; |
232 } | 225 } |
233 | 226 |
234 void ContentLayer::ClipContentLayer(scoped_refptr<cc::Layer> content_layer, | 227 void ContentLayer::ClipContentLayer(scoped_refptr<cc::Layer> content_layer, |
235 gfx::Rect clipping, | 228 gfx::Rect clipping, |
236 gfx::Size content_size) { | 229 gfx::Size content_size) { |
237 if (!content_layer.get()) | 230 if (!content_layer.get()) |
238 return; | 231 return; |
239 | 232 |
(...skipping 13 matching lines...) Expand all Loading... |
253 | 246 |
254 void ContentLayer::ClipStaticLayer(scoped_refptr<ThumbnailLayer> static_layer, | 247 void ContentLayer::ClipStaticLayer(scoped_refptr<ThumbnailLayer> static_layer, |
255 gfx::Rect clipping) { | 248 gfx::Rect clipping) { |
256 if (!static_layer.get()) | 249 if (!static_layer.get()) |
257 return; | 250 return; |
258 static_layer->Clip(clipping); | 251 static_layer->Clip(clipping); |
259 } | 252 } |
260 | 253 |
261 } // namespace android | 254 } // namespace android |
262 } // namespace chrome | 255 } // namespace chrome |
OLD | NEW |