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

Side by Side Diff: cc/layer.h

Issue 11264056: cc: Use gfx:: Geometry types for positions, bounds, and related things. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RebaseAndSolveTODOs Created 8 years, 1 month 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 LayerChromium_h 5 #ifndef LayerChromium_h
6 #define LayerChromium_h 6 #define LayerChromium_h
7 7
8 #include "FloatPoint.h"
9 #include "Region.h" 8 #include "Region.h"
10 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
11 #include "cc/layer_animation_controller.h" 10 #include "cc/layer_animation_controller.h"
12 #include "cc/occlusion_tracker.h" 11 #include "cc/occlusion_tracker.h"
13 #include "cc/render_surface.h" 12 #include "cc/render_surface.h"
14 #include "third_party/skia/include/core/SkColor.h" 13 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/rect_f.h"
15 #include <public/WebFilterOperations.h> 16 #include <public/WebFilterOperations.h>
16 #include <public/WebTransformationMatrix.h> 17 #include <public/WebTransformationMatrix.h>
17 #include <string> 18 #include <string>
18 #include <vector> 19 #include <vector>
19 20
20 namespace WebKit { 21 namespace WebKit {
21 class WebAnimationDelegate; 22 class WebAnimationDelegate;
22 class WebLayerScrollClient; 23 class WebLayerScrollClient;
23 } 24 }
24 25
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 Layer* parent() const; 60 Layer* parent() const;
60 void addChild(scoped_refptr<Layer>); 61 void addChild(scoped_refptr<Layer>);
61 void insertChild(scoped_refptr<Layer>, size_t index); 62 void insertChild(scoped_refptr<Layer>, size_t index);
62 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer); 63 void replaceChild(Layer* reference, scoped_refptr<Layer> newLayer);
63 void removeFromParent(); 64 void removeFromParent();
64 void removeAllChildren(); 65 void removeAllChildren();
65 void setChildren(const LayerList&); 66 void setChildren(const LayerList&);
66 67
67 const LayerList& children() const { return m_children; } 68 const LayerList& children() const { return m_children; }
68 69
69 void setAnchorPoint(const FloatPoint&); 70 void setAnchorPoint(const gfx::PointF&);
70 FloatPoint anchorPoint() const { return m_anchorPoint; } 71 gfx::PointF anchorPoint() const { return m_anchorPoint; }
71 72
72 void setAnchorPointZ(float); 73 void setAnchorPointZ(float);
73 float anchorPointZ() const { return m_anchorPointZ; } 74 float anchorPointZ() const { return m_anchorPointZ; }
74 75
75 void setBackgroundColor(SkColor); 76 void setBackgroundColor(SkColor);
76 SkColor backgroundColor() const { return m_backgroundColor; } 77 SkColor backgroundColor() const { return m_backgroundColor; }
77 78
78 // A layer's bounds are in logical, non-page-scaled pixels (however, the 79 // A layer's bounds are in logical, non-page-scaled pixels (however, the
79 // root layer's bounds are in physical pixels). 80 // root layer's bounds are in physical pixels).
80 void setBounds(const IntSize&); 81 void setBounds(const gfx::Size&);
81 const IntSize& bounds() const { return m_bounds; } 82 const gfx::Size& bounds() const { return m_bounds; }
82 virtual IntSize contentBounds() const; 83 virtual gfx::Size contentBounds() const;
83 84
84 void setMasksToBounds(bool); 85 void setMasksToBounds(bool);
85 bool masksToBounds() const { return m_masksToBounds; } 86 bool masksToBounds() const { return m_masksToBounds; }
86 87
87 void setMaskLayer(Layer*); 88 void setMaskLayer(Layer*);
88 Layer* maskLayer() const { return m_maskLayer.get(); } 89 Layer* maskLayer() const { return m_maskLayer.get(); }
89 90
90 virtual void setNeedsDisplayRect(const FloatRect& dirtyRect); 91 virtual void setNeedsDisplayRect(const gfx::RectF& dirtyRect);
91 void setNeedsDisplay() { setNeedsDisplayRect(FloatRect(FloatPoint(), bounds( ))); } 92 void setNeedsDisplay() { setNeedsDisplayRect(gfx::RectF(gfx::PointF(), bound s())); }
92 virtual bool needsDisplay() const; 93 virtual bool needsDisplay() const;
93 94
94 void setOpacity(float); 95 void setOpacity(float);
95 bool opacityIsAnimating() const; 96 bool opacityIsAnimating() const;
96 97
97 void setFilters(const WebKit::WebFilterOperations&); 98 void setFilters(const WebKit::WebFilterOperations&);
98 const WebKit::WebFilterOperations& filters() const { return m_filters; } 99 const WebKit::WebFilterOperations& filters() const { return m_filters; }
99 100
100 void setFilter(SkImageFilter* filter); 101 void setFilter(SkImageFilter* filter);
101 SkImageFilter* filter() const { return m_filter; } 102 SkImageFilter* filter() const { return m_filter; }
102 103
103 // Background filters are filters applied to what is behind this layer, when they are viewed through non-opaque 104 // Background filters are filters applied to what is behind this layer, when they are viewed through non-opaque
104 // regions in this layer. They are used through the WebLayer interface, and are not exposed to HTML. 105 // regions in this layer. They are used through the WebLayer interface, and are not exposed to HTML.
105 void setBackgroundFilters(const WebKit::WebFilterOperations&); 106 void setBackgroundFilters(const WebKit::WebFilterOperations&);
106 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back groundFilters; } 107 const WebKit::WebFilterOperations& backgroundFilters() const { return m_back groundFilters; }
107 108
108 virtual void setContentsOpaque(bool); 109 virtual void setContentsOpaque(bool);
109 bool contentsOpaque() const { return m_contentsOpaque; } 110 bool contentsOpaque() const { return m_contentsOpaque; }
110 111
111 void setPosition(const FloatPoint&); 112 void setPosition(const gfx::PointF&);
112 FloatPoint position() const { return m_position; } 113 gfx::PointF position() const { return m_position; }
113 114
114 void setIsContainerForFixedPositionLayers(bool); 115 void setIsContainerForFixedPositionLayers(bool);
115 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe dPositionLayers; } 116 bool isContainerForFixedPositionLayers() const { return m_isContainerForFixe dPositionLayers; }
116 117
117 void setFixedToContainerLayer(bool); 118 void setFixedToContainerLayer(bool);
118 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; } 119 bool fixedToContainerLayer() const { return m_fixedToContainerLayer; }
119 120
120 void setSublayerTransform(const WebKit::WebTransformationMatrix&); 121 void setSublayerTransform(const WebKit::WebTransformationMatrix&);
121 const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_ sublayerTransform; } 122 const WebKit::WebTransformationMatrix& sublayerTransform() const { return m_ sublayerTransform; }
122 123
123 void setTransform(const WebKit::WebTransformationMatrix&); 124 void setTransform(const WebKit::WebTransformationMatrix&);
124 bool transformIsAnimating() const; 125 bool transformIsAnimating() const;
125 126
126 const IntRect& visibleContentRect() const { return m_visibleContentRect; } 127 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; }
127 void setVisibleContentRect(const IntRect& visibleContentRect) { m_visibleCon tentRect = visibleContentRect; } 128 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC ontentRect = visibleContentRect; }
128 129
129 void setScrollPosition(const IntPoint&); 130 void setScrollPosition(const IntPoint&);
130 const IntPoint& scrollPosition() const { return m_scrollPosition; } 131 const IntPoint& scrollPosition() const { return m_scrollPosition; }
131 132
132 void setMaxScrollPosition(const IntSize&); 133 void setMaxScrollPosition(const IntSize&);
133 const IntSize& maxScrollPosition() const { return m_maxScrollPosition; } 134 const IntSize& maxScrollPosition() const { return m_maxScrollPosition; }
134 135
135 void setScrollable(bool); 136 void setScrollable(bool);
136 bool scrollable() const { return m_scrollable; } 137 bool scrollable() const { return m_scrollable; }
137 138
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 217
217 // This moves from layer space, with origin in the center to target space wi th origin in the top left. 218 // This moves from layer space, with origin in the center to target space wi th origin in the top left.
218 // That is, it converts from logical, non-page-scaled, to target pixels (and if the target is the 219 // That is, it converts from logical, non-page-scaled, to target pixels (and if the target is the
219 // root render surface, then this converts to physical pixels). 220 // root render surface, then this converts to physical pixels).
220 const WebKit::WebTransformationMatrix& drawTransform() const { return m_draw Transform; } 221 const WebKit::WebTransformationMatrix& drawTransform() const { return m_draw Transform; }
221 void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_dra wTransform = matrix; } 222 void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_dra wTransform = matrix; }
222 // This moves from content space, with origin the top left to screen space w ith origin in the top left. 223 // This moves from content space, with origin the top left to screen space w ith origin in the top left.
223 // It converts logical, non-page-scaled pixels to physical pixels. 224 // It converts logical, non-page-scaled pixels to physical pixels.
224 const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } 225 const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; }
225 void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; } 226 void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix) { m_screenSpaceTransform = matrix; }
226 const IntRect& drawableContentRect() const { return m_drawableContentRect; } 227 const gfx::Rect& drawableContentRect() const { return m_drawableContentRect; }
227 void setDrawableContentRect(const IntRect& rect) { m_drawableContentRect = r ect; } 228 void setDrawableContentRect(const gfx::Rect& rect) { m_drawableContentRect = rect; }
228 229
229 // The contentsScale converts from logical, non-page-scaled pixels to target pixels. 230 // The contentsScale converts from logical, non-page-scaled pixels to target pixels.
230 // The contentsScale is 1 for the root layer as it is already in physical pi xels. 231 // The contentsScale is 1 for the root layer as it is already in physical pi xels.
231 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer. 232 // By default contentsScale is forced to be 1 except for subclasses of Conte ntsScalingLayer.
232 virtual float contentsScaleX() const; 233 virtual float contentsScaleX() const;
233 virtual float contentsScaleY() const; 234 virtual float contentsScaleY() const;
234 virtual void setContentsScale(float contentsScale) { } 235 virtual void setContentsScale(float contentsScale) { }
235 236
236 // The scale at which contents should be rastered, to match the scale at 237 // The scale at which contents should be rastered, to match the scale at
237 // which they will drawn to the screen. This scale is a component of the 238 // which they will drawn to the screen. This scale is a component of the
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 275
275 bool hasActiveAnimation() const; 276 bool hasActiveAnimation() const;
276 277
277 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT ime); 278 virtual void notifyAnimationStarted(const AnimationEvent&, double wallClockT ime);
278 virtual void notifyAnimationFinished(double wallClockTime); 279 virtual void notifyAnimationFinished(double wallClockTime);
279 280
280 virtual Region visibleContentOpaqueRegion() const; 281 virtual Region visibleContentOpaqueRegion() const;
281 282
282 virtual ScrollbarLayer* toScrollbarLayer(); 283 virtual ScrollbarLayer* toScrollbarLayer();
283 284
284 IntRect layerRectToContentRect(const FloatRect& layerRect) const; 285 gfx::Rect layerRectToContentRect(const gfx::RectF& layerRect) const;
285 286
286 protected: 287 protected:
287 friend class LayerImpl; 288 friend class LayerImpl;
288 friend class TreeSynchronizer; 289 friend class TreeSynchronizer;
289 virtual ~Layer(); 290 virtual ~Layer();
290 291
291 Layer(); 292 Layer();
292 293
293 void setNeedsCommit(); 294 void setNeedsCommit();
294 295
295 // This flag is set when layer need repainting/updating. 296 // This flag is set when layer need repainting/updating.
296 bool m_needsDisplay; 297 bool m_needsDisplay;
297 298
298 // Tracks whether this layer may have changed stacking order with its siblin gs. 299 // Tracks whether this layer may have changed stacking order with its siblin gs.
299 bool m_stackingOrderChanged; 300 bool m_stackingOrderChanged;
300 301
301 // The update rect is the region of the compositor resource that was actuall y updated by the compositor. 302 // The update rect is the region of the compositor resource that was actuall y updated by the compositor.
302 // For layers that may do updating outside the compositor's control (i.e. pl ugin layers), this information 303 // For layers that may do updating outside the compositor's control (i.e. pl ugin layers), this information
303 // is not available and the update rect will remain empty. 304 // is not available and the update rect will remain empty.
304 // Note this rect is in layer space (not content space). 305 // Note this rect is in layer space (not content space).
305 FloatRect m_updateRect; 306 gfx::RectF m_updateRect;
306 307
307 scoped_refptr<Layer> m_maskLayer; 308 scoped_refptr<Layer> m_maskLayer;
308 309
309 // Constructs a LayerImpl of the correct runtime type for this Layer type. 310 // Constructs a LayerImpl of the correct runtime type for this Layer type.
310 virtual scoped_ptr<LayerImpl> createLayerImpl(); 311 virtual scoped_ptr<LayerImpl> createLayerImpl();
311 int m_layerId; 312 int m_layerId;
312 313
313 private: 314 private:
314 friend class base::RefCounted<Layer>; 315 friend class base::RefCounted<Layer>;
315 316
(...skipping 13 matching lines...) Expand all
329 Layer* m_parent; 330 Layer* m_parent;
330 331
331 // Layer instances have a weak pointer to their LayerTreeHost. 332 // Layer instances have a weak pointer to their LayerTreeHost.
332 // This pointer value is nil when a Layer is not in a tree and is 333 // This pointer value is nil when a Layer is not in a tree and is
333 // updated via setLayerTreeHost() if a layer moves between trees. 334 // updated via setLayerTreeHost() if a layer moves between trees.
334 LayerTreeHost* m_layerTreeHost; 335 LayerTreeHost* m_layerTreeHost;
335 336
336 scoped_ptr<LayerAnimationController> m_layerAnimationController; 337 scoped_ptr<LayerAnimationController> m_layerAnimationController;
337 338
338 // Layer properties. 339 // Layer properties.
339 IntSize m_bounds; 340 gfx::Size m_bounds;
340 341
341 // Uses layer's content space. 342 // Uses layer's content space.
342 IntRect m_visibleContentRect; 343 gfx::Rect m_visibleContentRect;
343 344
344 IntPoint m_scrollPosition; 345 IntPoint m_scrollPosition;
345 IntSize m_maxScrollPosition; 346 IntSize m_maxScrollPosition;
346 bool m_scrollable; 347 bool m_scrollable;
347 bool m_shouldScrollOnMainThread; 348 bool m_shouldScrollOnMainThread;
348 bool m_haveWheelEventHandlers; 349 bool m_haveWheelEventHandlers;
349 Region m_nonFastScrollableRegion; 350 Region m_nonFastScrollableRegion;
350 bool m_nonFastScrollableRegionChanged; 351 bool m_nonFastScrollableRegionChanged;
351 FloatPoint m_position; 352 gfx::PointF m_position;
352 FloatPoint m_anchorPoint; 353 gfx::PointF m_anchorPoint;
353 SkColor m_backgroundColor; 354 SkColor m_backgroundColor;
354 SkColor m_debugBorderColor; 355 SkColor m_debugBorderColor;
355 float m_debugBorderWidth; 356 float m_debugBorderWidth;
356 std::string m_debugName; 357 std::string m_debugName;
357 float m_opacity; 358 float m_opacity;
358 SkImageFilter* m_filter; 359 SkImageFilter* m_filter;
359 WebKit::WebFilterOperations m_filters; 360 WebKit::WebFilterOperations m_filters;
360 WebKit::WebFilterOperations m_backgroundFilters; 361 WebKit::WebFilterOperations m_backgroundFilters;
361 float m_anchorPointZ; 362 float m_anchorPointZ;
362 bool m_isContainerForFixedPositionLayers; 363 bool m_isContainerForFixedPositionLayers;
(...skipping 20 matching lines...) Expand all
383 bool m_drawOpacityIsAnimating; 384 bool m_drawOpacityIsAnimating;
384 385
385 Layer* m_renderTarget; 386 Layer* m_renderTarget;
386 387
387 WebKit::WebTransformationMatrix m_drawTransform; 388 WebKit::WebTransformationMatrix m_drawTransform;
388 WebKit::WebTransformationMatrix m_screenSpaceTransform; 389 WebKit::WebTransformationMatrix m_screenSpaceTransform;
389 bool m_drawTransformIsAnimating; 390 bool m_drawTransformIsAnimating;
390 bool m_screenSpaceTransformIsAnimating; 391 bool m_screenSpaceTransformIsAnimating;
391 392
392 // Uses target surface space. 393 // Uses target surface space.
393 IntRect m_drawableContentRect; 394 gfx::Rect m_drawableContentRect;
394 float m_rasterScale; 395 float m_rasterScale;
395 bool m_automaticallyComputeRasterScale; 396 bool m_automaticallyComputeRasterScale;
396 bool m_boundsContainPageScale; 397 bool m_boundsContainPageScale;
397 398
398 WebKit::WebTransformationMatrix m_implTransform; 399 WebKit::WebTransformationMatrix m_implTransform;
399 400
400 WebKit::WebAnimationDelegate* m_layerAnimationDelegate; 401 WebKit::WebAnimationDelegate* m_layerAnimationDelegate;
401 WebKit::WebLayerScrollClient* m_layerScrollClient; 402 WebKit::WebLayerScrollClient* m_layerScrollClient;
402 }; 403 };
403 404
404 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*); 405 void sortLayers(std::vector<scoped_refptr<Layer> >::iterator, std::vector<scoped _refptr<Layer> >::iterator, void*);
405 406
406 } // namespace cc 407 } // namespace cc
407 408
408 #endif 409 #endif
OLDNEW
« no previous file with comments | « cc/io_surface_layer_impl.cc ('k') | cc/layer.cc » ('j') | cc/layer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698