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

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: rebase 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
« no previous file with comments | « cc/layer.h ('k') | cc/layer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 void Layer::setBounds(const gfx::Size& size) 210 void Layer::setBounds(const gfx::Size& size)
211 { 211 {
212 if (bounds() == size) 212 if (bounds() == size)
213 return; 213 return;
214 214
215 bool firstResize = bounds().IsEmpty() && !size.IsEmpty(); 215 bool firstResize = bounds().IsEmpty() && !size.IsEmpty();
216 216
217 m_bounds = size; 217 m_bounds = size;
218 218
219 didUpdateBounds();
220
219 if (firstResize) 221 if (firstResize)
220 setNeedsDisplay(); 222 setNeedsDisplay();
221 else 223 else
222 setNeedsCommit(); 224 setNeedsCommit();
223 } 225 }
224 226
227 void Layer::didUpdateBounds()
228 {
229 m_drawProperties.content_bounds = bounds();
230 }
231
225 Layer* Layer::rootLayer() 232 Layer* Layer::rootLayer()
226 { 233 {
227 Layer* layer = this; 234 Layer* layer = this;
228 while (layer->parent()) 235 while (layer->parent())
229 layer = layer->parent(); 236 layer = layer->parent();
230 return layer; 237 return layer;
231 } 238 }
232 239
233 void Layer::removeAllChildren() 240 void Layer::removeAllChildren()
234 { 241 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 274 }
268 275
269 void Layer::setBackgroundColor(SkColor backgroundColor) 276 void Layer::setBackgroundColor(SkColor backgroundColor)
270 { 277 {
271 if (m_backgroundColor == backgroundColor) 278 if (m_backgroundColor == backgroundColor)
272 return; 279 return;
273 m_backgroundColor = backgroundColor; 280 m_backgroundColor = backgroundColor;
274 setNeedsCommit(); 281 setNeedsCommit();
275 } 282 }
276 283
277 gfx::Size Layer::contentBounds() const 284 void Layer::calculateContentsScale(
285 float idealContentsScale,
286 float* contentsScaleX,
287 float* contentsScaleY,
288 gfx::Size* contentBounds)
278 { 289 {
279 return bounds(); 290 *contentsScaleX = 1;
291 *contentsScaleY = 1;
292 *contentBounds = bounds();
280 } 293 }
281 294
282 void Layer::setMasksToBounds(bool masksToBounds) 295 void Layer::setMasksToBounds(bool masksToBounds)
283 { 296 {
284 if (m_masksToBounds == masksToBounds) 297 if (m_masksToBounds == masksToBounds)
285 return; 298 return;
286 m_masksToBounds = masksToBounds; 299 m_masksToBounds = masksToBounds;
287 setNeedsCommit(); 300 setNeedsCommit();
288 } 301 }
289 302
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 { 639 {
627 return false; 640 return false;
628 } 641 }
629 642
630 void Layer::setDebugName(const std::string& debugName) 643 void Layer::setDebugName(const std::string& debugName)
631 { 644 {
632 m_debugName = debugName; 645 m_debugName = debugName;
633 setNeedsCommit(); 646 setNeedsCommit();
634 } 647 }
635 648
636 float Layer::contentsScaleX() const
637 {
638 return 1.0;
639 }
640
641 float Layer::contentsScaleY() const
642 {
643 return 1.0;
644 }
645
646 void Layer::setRasterScale(float scale) 649 void Layer::setRasterScale(float scale)
647 { 650 {
648 if (m_rasterScale == scale) 651 if (m_rasterScale == scale)
649 return; 652 return;
650 m_rasterScale = scale; 653 m_rasterScale = scale;
651 654
652 if (!m_automaticallyComputeRasterScale) 655 if (!m_automaticallyComputeRasterScale)
653 return; 656 return;
654 setNeedsDisplay(); 657 setNeedsDisplay();
655 } 658 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 { 823 {
821 return 0; 824 return 0;
822 } 825 }
823 826
824 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*) 827 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*)
825 { 828 {
826 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers. 829 // Currently we don't use z-order to decide what to paint, so there's no nee d to actually sort Layers.
827 } 830 }
828 831
829 } // namespace cc 832 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer.h ('k') | cc/layer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698