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

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

Issue 1101823002: CC Animations: Make LayerAnimationController creation optional (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Plumb LayerSettings parameter for cc::Layer construction. Created 5 years, 7 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/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"
11 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 12
13 namespace chrome { 13 namespace chrome {
14 namespace android { 14 namespace android {
15 15
16 cc::LayerSettings g_content_layer_settings;
piman 2015/05/11 21:31:24 Same here wrt static non-POD.
17
16 // static 18 // static
17 scoped_refptr<ContentLayer> ContentLayer::Create( 19 scoped_refptr<ContentLayer> ContentLayer::Create(
18 TabContentManager* tab_content_manager) { 20 TabContentManager* tab_content_manager) {
19 return make_scoped_refptr(new ContentLayer(tab_content_manager)); 21 return make_scoped_refptr(new ContentLayer(tab_content_manager));
20 } 22 }
21 23
22 static void SetOpacityOnLeaf(scoped_refptr<cc::Layer> layer, float alpha) { 24 static void SetOpacityOnLeaf(scoped_refptr<cc::Layer> layer, float alpha) {
23 const cc::LayerList& children = layer->children(); 25 const cc::LayerList& children = layer->children();
24 if (children.size() > 0) { 26 if (children.size() > 0) {
25 layer->SetOpacity(1.0f); 27 layer->SetOpacity(1.0f);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 if (content_attached_ && DoesLeafDrawContents(layer()->children()[0])) 156 if (content_attached_ && DoesLeafDrawContents(layer()->children()[0]))
155 return layer_->children()[0]->bounds(); 157 return layer_->children()[0]->bounds();
156 return gfx::Size(0, 0); 158 return gfx::Size(0, 0);
157 } 159 }
158 160
159 scoped_refptr<cc::Layer> ContentLayer::layer() { 161 scoped_refptr<cc::Layer> ContentLayer::layer() {
160 return layer_; 162 return layer_;
161 } 163 }
162 164
163 ContentLayer::ContentLayer(TabContentManager* tab_content_manager) 165 ContentLayer::ContentLayer(TabContentManager* tab_content_manager)
164 : layer_(cc::Layer::Create()), 166 : layer_(cc::Layer::Create(ContentLayerSettings())),
165 content_attached_(false), 167 content_attached_(false),
166 static_attached_(false), 168 static_attached_(false),
167 tab_content_manager_(tab_content_manager) { 169 tab_content_manager_(tab_content_manager) {
168 } 170 }
169 171
170 ContentLayer::~ContentLayer() { 172 ContentLayer::~ContentLayer() {
171 } 173 }
172 174
175 // static
176 const cc::LayerSettings& ContentLayer::ContentLayerSettings() {
177 return g_content_layer_settings;
178 }
179
180 // static
181 void ContentLayer::SetContentLayerSettings(const cc::LayerSettings& settings) {
182 g_content_layer_settings = settings;
183 }
184
173 void ContentLayer::SetContentLayer(scoped_refptr<cc::Layer> layer) { 185 void ContentLayer::SetContentLayer(scoped_refptr<cc::Layer> layer) {
174 // Check indices 186 // Check indices
175 // content_attached_, expect at least 1 child. 187 // content_attached_, expect at least 1 child.
176 DCHECK(!content_attached_ || layer_->children().size() > 0); 188 DCHECK(!content_attached_ || layer_->children().size() > 0);
177 189
178 if (!layer.get()) { 190 if (!layer.get()) {
179 if (content_attached_) 191 if (content_attached_)
180 layer_->child_at(0)->RemoveFromParent(); 192 layer_->child_at(0)->RemoveFromParent();
181 content_attached_ = false; 193 content_attached_ = false;
182 return; 194 return;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 258
247 void ContentLayer::ClipStaticLayer(scoped_refptr<ThumbnailLayer> static_layer, 259 void ContentLayer::ClipStaticLayer(scoped_refptr<ThumbnailLayer> static_layer,
248 gfx::Rect clipping) { 260 gfx::Rect clipping) {
249 if (!static_layer.get()) 261 if (!static_layer.get())
250 return; 262 return;
251 static_layer->Clip(clipping); 263 static_layer->Clip(clipping);
252 } 264 }
253 265
254 } // namespace android 266 } // namespace android
255 } // namespace chrome 267 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698