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

Side by Side Diff: cc/layer.cc

Issue 11503005: cc: Refactor content scale/bounds into draw properties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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 "cc/layer.h" 5 #include "cc/layer.h"
6 6
7 #include "cc/active_animation.h" 7 #include "cc/active_animation.h"
8 #include "cc/animation_events.h" 8 #include "cc/animation_events.h"
9 #include "cc/layer_animation_controller.h" 9 #include "cc/layer_animation_controller.h"
10 #include "cc/layer_impl.h" 10 #include "cc/layer_impl.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 void Layer::setBounds(const gfx::Size& size) 216 void Layer::setBounds(const gfx::Size& size)
217 { 217 {
218 if (bounds() == size) 218 if (bounds() == size)
219 return; 219 return;
220 220
221 bool firstResize = bounds().IsEmpty() && !size.IsEmpty(); 221 bool firstResize = bounds().IsEmpty() && !size.IsEmpty();
222 222
223 m_bounds = size; 223 m_bounds = size;
224 224
225 didUpdateBounds();
226
225 if (firstResize) 227 if (firstResize)
226 setNeedsDisplay(); 228 setNeedsDisplay();
227 else 229 else
228 setNeedsCommit(); 230 setNeedsCommit();
229 } 231 }
230 232
233 void Layer::didUpdateBounds()
234 {
235 m_drawProperties.content_bounds = bounds();
236 }
237
231 Layer* Layer::rootLayer() 238 Layer* Layer::rootLayer()
232 { 239 {
233 Layer* layer = this; 240 Layer* layer = this;
234 while (layer->parent()) 241 while (layer->parent())
235 layer = layer->parent(); 242 layer = layer->parent();
236 return layer; 243 return layer;
237 } 244 }
238 245
239 void Layer::removeAllChildren() 246 void Layer::removeAllChildren()
240 { 247 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } 280 }
274 281
275 void Layer::setBackgroundColor(SkColor backgroundColor) 282 void Layer::setBackgroundColor(SkColor backgroundColor)
276 { 283 {
277 if (m_backgroundColor == backgroundColor) 284 if (m_backgroundColor == backgroundColor)
278 return; 285 return;
279 m_backgroundColor = backgroundColor; 286 m_backgroundColor = backgroundColor;
280 setNeedsCommit(); 287 setNeedsCommit();
281 } 288 }
282 289
283 gfx::Size Layer::contentBounds() const 290 void Layer::setIdealContentsScale(float ideal_contents_scale)
284 { 291 {
285 return bounds(); 292 m_drawProperties.ideal_contents_scale = ideal_contents_scale;
293 m_drawProperties.contents_scale_x = 1;
294 m_drawProperties.contents_scale_y = 1;
295 m_drawProperties.content_bounds = bounds();
286 } 296 }
287 297
288 void Layer::setMasksToBounds(bool masksToBounds) 298 void Layer::setMasksToBounds(bool masksToBounds)
289 { 299 {
290 if (m_masksToBounds == masksToBounds) 300 if (m_masksToBounds == masksToBounds)
291 return; 301 return;
292 m_masksToBounds = masksToBounds; 302 m_masksToBounds = masksToBounds;
293 setNeedsCommit(); 303 setNeedsCommit();
294 } 304 }
295 305
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 { 643 {
634 return false; 644 return false;
635 } 645 }
636 646
637 void Layer::setDebugName(const std::string& debugName) 647 void Layer::setDebugName(const std::string& debugName)
638 { 648 {
639 m_debugName = debugName; 649 m_debugName = debugName;
640 setNeedsCommit(); 650 setNeedsCommit();
641 } 651 }
642 652
643 float Layer::contentsScaleX() const
644 {
645 return 1.0;
646 }
647
648 float Layer::contentsScaleY() const
649 {
650 return 1.0;
651 }
652
653 void Layer::setRasterScale(float scale) 653 void Layer::setRasterScale(float scale)
654 { 654 {
655 if (m_rasterScale == scale) 655 if (m_rasterScale == scale)
656 return; 656 return;
657 m_rasterScale = scale; 657 m_rasterScale = scale;
658 658
659 if (!m_automaticallyComputeRasterScale) 659 if (!m_automaticallyComputeRasterScale)
660 return; 660 return;
661 setNeedsDisplay(); 661 setNeedsDisplay();
662 } 662 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 { 840 {
841 return 0; 841 return 0;
842 } 842 }
843 843
844 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) 844 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
845 { 845 {
846 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. 846 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
847 } 847 }
848 848
849 } // namespace cc 849 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698