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

Side by Side Diff: cc/layer.h

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 #ifndef CC_LAYER_H_ 5 #ifndef CC_LAYER_H_
6 #define CC_LAYER_H_ 6 #define CC_LAYER_H_
7 7
8 #include <public/WebFilterOperations.h> 8 #include <public/WebFilterOperations.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 void setAnchorPointZ(float); 78 void setAnchorPointZ(float);
79 float anchorPointZ() const { return m_anchorPointZ; } 79 float anchorPointZ() const { return m_anchorPointZ; }
80 80
81 virtual void setBackgroundColor(SkColor); 81 virtual void setBackgroundColor(SkColor);
82 SkColor backgroundColor() const { return m_backgroundColor; } 82 SkColor backgroundColor() const { return m_backgroundColor; }
83 83
84 // A layer's bounds are in logical, non-page-scaled pixels (however, the 84 // A layer's bounds are in logical, non-page-scaled pixels (however, the
85 // root layer's bounds are in physical pixels). 85 // root layer's bounds are in physical pixels).
86 void setBounds(const gfx::Size&); 86 void setBounds(const gfx::Size&);
87 virtual void didUpdateBounds();
shawnsingh 2012/12/11 21:54:05 I think we can do without this. Instead, I think
enne (OOO) 2012/12/11 23:23:44 Sadly, no. Unfortunately, we do so much in conten
87 const gfx::Size& bounds() const { return m_bounds; } 88 const gfx::Size& bounds() const { return m_bounds; }
88 virtual gfx::Size contentBounds() const;
89 89
90 void setMasksToBounds(bool); 90 void setMasksToBounds(bool);
91 bool masksToBounds() const { return m_masksToBounds; } 91 bool masksToBounds() const { return m_masksToBounds; }
92 92
93 void setMaskLayer(Layer*); 93 void setMaskLayer(Layer*);
94 Layer* maskLayer() { return m_maskLayer.get(); } 94 Layer* maskLayer() { return m_maskLayer.get(); }
95 const Layer* maskLayer() const { return m_maskLayer.get(); } 95 const Layer* maskLayer() const { return m_maskLayer.get(); }
96 96
97 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect); 97 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect);
98 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound s())); } 98 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound s())); }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 void setDebugName(const std::string&); 220 void setDebugName(const std::string&);
221 221
222 virtual void pushPropertiesTo(LayerImpl*); 222 virtual void pushPropertiesTo(LayerImpl*);
223 223
224 void clearRenderSurface() { m_drawProperties.render_surface.reset(); } 224 void clearRenderSurface() { m_drawProperties.render_surface.reset(); }
225 void createRenderSurface(); 225 void createRenderSurface();
226 226
227 // The contentsScale converts from logical, non-page-scaled pixels to target pixels. 227 // The contentsScale converts from logical, non-page-scaled pixels to target pixels.
228 // The contentsScale is 1 for the root layer as it is already in physical pi xels. 228 // The contentsScale is 1 for the root layer as it is already in physical pi xels.
229 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer. 229 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer.
230 virtual float contentsScaleX() const; 230 float contentsScaleX() const { return m_drawProperties.contents_scale_x; }
231 virtual float contentsScaleY() const; 231 float contentsScaleY() const { return m_drawProperties.contents_scale_y; }
shawnsingh 2012/12/11 21:54:05 maybe to avoid confusion with the previous state o
enne (OOO) 2012/12/11 23:23:44 I think that's just an issue with ImageLayer shado
232 virtual void setContentsScale(float contentsScale) { } 232 gfx::Size contentBounds() const { return m_drawProperties.content_bounds; }
233 virtual void setIdealContentsScale(float ideal_contents_scale);
shawnsingh 2012/12/11 21:54:05 instead of "set" which makes it feel like it's par
enne (OOO) 2012/12/11 23:23:44 Sure. I can rename this for clarity.
233 234
234 // The scale at which contents should be rastered, to match the scale at 235 // The scale at which contents should be rastered, to match the scale at
235 // which they will drawn to the screen. This scale is a component of the 236 // which they will drawn to the screen. This scale is a component of the
236 // contentsScale() but does not include page/device scale factors. 237 // contentsScale() but does not include page/device scale factors.
237 float rasterScale() const { return m_rasterScale; } 238 float rasterScale() const { return m_rasterScale; }
238 void setRasterScale(float scale); 239 void setRasterScale(float scale);
239 240
240 // When true, the rasterScale() will be set by the compositor. If false, it 241 // When true, the rasterScale() will be set by the compositor. If false, it
241 // will use whatever value is given to it by the embedder. 242 // will use whatever value is given to it by the embedder.
242 bool automaticallyComputeRasterScale() { return m_automaticallyComputeRaster Scale; } 243 bool automaticallyComputeRasterScale() { return m_automaticallyComputeRaster Scale; }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // is not available and the update rect will remain empty. 310 // is not available and the update rect will remain empty.
310 // Note this rect is in layer space (not content space). 311 // Note this rect is in layer space (not content space).
311 gfx::RectF m_updateRect; 312 gfx::RectF m_updateRect;
312 313
313 scoped_refptr<Layer> m_maskLayer; 314 scoped_refptr<Layer> m_maskLayer;
314 315
315 // Constructs a LayerImpl of the correct runtime type for this Layer type. 316 // Constructs a LayerImpl of the correct runtime type for this Layer type.
316 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeHostImpl* hostImpl); 317 virtual scoped_ptr<LayerImpl> createLayerImpl(LayerTreeHostImpl* hostImpl);
317 int m_layerId; 318 int m_layerId;
318 319
320 DrawProperties<Layer, RenderSurface> m_drawProperties;
321
319 private: 322 private:
320 friend class base::RefCounted<Layer>; 323 friend class base::RefCounted<Layer>;
321 324
322 void setParent(Layer*); 325 void setParent(Layer*);
323 bool hasAncestor(Layer*) const; 326 bool hasAncestor(Layer*) const;
324 bool descendantIsFixedToContainerLayer() const; 327 bool descendantIsFixedToContainerLayer() const;
325 328
326 size_t numChildren() const { return m_children.size(); } 329 size_t numChildren() const { return m_children.size(); }
327 330
328 // Returns the index of the child or -1 if not found. 331 // Returns the index of the child or -1 if not found.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 385
383 // Transient properties. 386 // Transient properties.
384 float m_rasterScale; 387 float m_rasterScale;
385 bool m_automaticallyComputeRasterScale; 388 bool m_automaticallyComputeRasterScale;
386 bool m_boundsContainPageScale; 389 bool m_boundsContainPageScale;
387 390
388 gfx::Transform m_implTransform; 391 gfx::Transform m_implTransform;
389 392
390 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; 393 WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
391 WebKit::WebLayerScrollClient* m_layerScrollClient; 394 WebKit::WebLayerScrollClient* m_layerScrollClient;
392
393 DrawProperties<Layer, RenderSurface> m_drawProperties;
394 }; 395 };
395 396
396 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*); 397 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*);
397 398
398 } // namespace cc 399 } // namespace cc
399 400
400 #endif // CC_LAYER_H_ 401 #endif // CC_LAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698