OLD | NEW |
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 Loading... |
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 218 |
218 // This moves from layer space, with origin in the center to target space wi
th origin in the top left. | 219 // This moves from layer space, with origin in the center to target space wi
th origin in the top left. |
219 // That is, it converts from logical, non-page-scaled, to target pixels (and
if the target is the | 220 // That is, it converts from logical, non-page-scaled, to target pixels (and
if the target is the |
220 // root render surface, then this converts to physical pixels). | 221 // root render surface, then this converts to physical pixels). |
221 const WebKit::WebTransformationMatrix& drawTransform() const { return m_draw
Transform; } | 222 const WebKit::WebTransformationMatrix& drawTransform() const { return m_draw
Transform; } |
222 void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_dra
wTransform = matrix; } | 223 void setDrawTransform(const WebKit::WebTransformationMatrix& matrix) { m_dra
wTransform = matrix; } |
223 // This moves from content space, with origin the top left to screen space w
ith origin in the top left. | 224 // This moves from content space, with origin the top left to screen space w
ith origin in the top left. |
224 // It converts logical, non-page-scaled pixels to physical pixels. | 225 // It converts logical, non-page-scaled pixels to physical pixels. |
225 const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return
m_screenSpaceTransform; } | 226 const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return
m_screenSpaceTransform; } |
226 void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix)
{ m_screenSpaceTransform = matrix; } | 227 void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& matrix)
{ m_screenSpaceTransform = matrix; } |
227 const IntRect& drawableContentRect() const { return m_drawableContentRect; } | 228 const gfx::Rect& drawableContentRect() const { return m_drawableContentRect;
} |
228 void setDrawableContentRect(const IntRect& rect) { m_drawableContentRect = r
ect; } | 229 void setDrawableContentRect(const gfx::Rect& rect) { m_drawableContentRect =
rect; } |
229 | 230 |
230 // The contentsScale converts from logical, non-page-scaled pixels to target
pixels. | 231 // The contentsScale converts from logical, non-page-scaled pixels to target
pixels. |
231 // The contentsScale is 1 for the root layer as it is already in physical pi
xels. | 232 // The contentsScale is 1 for the root layer as it is already in physical pi
xels. |
232 float contentsScale() const { return m_contentsScale; } | 233 float contentsScale() const { return m_contentsScale; } |
233 void setContentsScale(float); | 234 void setContentsScale(float); |
234 | 235 |
235 // The scale at which contents should be rastered, to match the scale at | 236 // The scale at which contents should be rastered, to match the scale at |
236 // which they will drawn to the screen. This scale is a component of the | 237 // which they will drawn to the screen. This scale is a component of the |
237 // contentsScale() but does not include page/device scale factors. | 238 // contentsScale() but does not include page/device scale factors. |
238 float rasterScale() const { return m_rasterScale; } | 239 float rasterScale() const { return m_rasterScale; } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 283 |
283 protected: | 284 protected: |
284 friend class LayerImpl; | 285 friend class LayerImpl; |
285 friend class TreeSynchronizer; | 286 friend class TreeSynchronizer; |
286 virtual ~Layer(); | 287 virtual ~Layer(); |
287 | 288 |
288 Layer(); | 289 Layer(); |
289 | 290 |
290 void setNeedsCommit(); | 291 void setNeedsCommit(); |
291 | 292 |
292 IntRect layerRectToContentRect(const WebKit::WebRect& layerRect); | 293 gfx::Rect layerRectToContentRect(const gfx::Rect& layerRect); |
293 | 294 |
294 // This flag is set when layer need repainting/updating. | 295 // This flag is set when layer need repainting/updating. |
295 bool m_needsDisplay; | 296 bool m_needsDisplay; |
296 | 297 |
297 // Tracks whether this layer may have changed stacking order with its siblin
gs. | 298 // Tracks whether this layer may have changed stacking order with its siblin
gs. |
298 bool m_stackingOrderChanged; | 299 bool m_stackingOrderChanged; |
299 | 300 |
300 // The update rect is the region of the compositor resource that was actuall
y updated by the compositor. | 301 // The update rect is the region of the compositor resource that was actuall
y updated by the compositor. |
301 // For layers that may do updating outside the compositor's control (i.e. pl
ugin layers), this information | 302 // For layers that may do updating outside the compositor's control (i.e. pl
ugin layers), this information |
302 // is not available and the update rect will remain empty. | 303 // is not available and the update rect will remain empty. |
303 // Note this rect is in layer space (not content space). | 304 // Note this rect is in layer space (not content space). |
304 FloatRect m_updateRect; | 305 gfx::RectF m_updateRect; |
305 | 306 |
306 scoped_refptr<Layer> m_maskLayer; | 307 scoped_refptr<Layer> m_maskLayer; |
307 | 308 |
308 // Constructs a LayerImpl of the correct runtime type for this Layer type. | 309 // Constructs a LayerImpl of the correct runtime type for this Layer type. |
309 virtual scoped_ptr<LayerImpl> createLayerImpl(); | 310 virtual scoped_ptr<LayerImpl> createLayerImpl(); |
310 int m_layerId; | 311 int m_layerId; |
311 | 312 |
312 private: | 313 private: |
313 friend class base::RefCounted<Layer>; | 314 friend class base::RefCounted<Layer>; |
314 | 315 |
(...skipping 13 matching lines...) Expand all Loading... |
328 Layer* m_parent; | 329 Layer* m_parent; |
329 | 330 |
330 // Layer instances have a weak pointer to their LayerTreeHost. | 331 // Layer instances have a weak pointer to their LayerTreeHost. |
331 // This pointer value is nil when a Layer is not in a tree and is | 332 // This pointer value is nil when a Layer is not in a tree and is |
332 // updated via setLayerTreeHost() if a layer moves between trees. | 333 // updated via setLayerTreeHost() if a layer moves between trees. |
333 LayerTreeHost* m_layerTreeHost; | 334 LayerTreeHost* m_layerTreeHost; |
334 | 335 |
335 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 336 scoped_ptr<LayerAnimationController> m_layerAnimationController; |
336 | 337 |
337 // Layer properties. | 338 // Layer properties. |
338 IntSize m_bounds; | 339 gfx::Size m_bounds; |
339 | 340 |
340 // Uses layer's content space. | 341 // Uses layer's content space. |
341 IntRect m_visibleContentRect; | 342 gfx::Rect m_visibleContentRect; |
342 | 343 |
343 IntPoint m_scrollPosition; | 344 IntPoint m_scrollPosition; |
344 IntSize m_maxScrollPosition; | 345 IntSize m_maxScrollPosition; |
345 bool m_scrollable; | 346 bool m_scrollable; |
346 bool m_shouldScrollOnMainThread; | 347 bool m_shouldScrollOnMainThread; |
347 bool m_haveWheelEventHandlers; | 348 bool m_haveWheelEventHandlers; |
348 Region m_nonFastScrollableRegion; | 349 Region m_nonFastScrollableRegion; |
349 bool m_nonFastScrollableRegionChanged; | 350 bool m_nonFastScrollableRegionChanged; |
350 FloatPoint m_position; | 351 gfx::PointF m_position; |
351 FloatPoint m_anchorPoint; | 352 gfx::PointF m_anchorPoint; |
352 SkColor m_backgroundColor; | 353 SkColor m_backgroundColor; |
353 SkColor m_debugBorderColor; | 354 SkColor m_debugBorderColor; |
354 float m_debugBorderWidth; | 355 float m_debugBorderWidth; |
355 std::string m_debugName; | 356 std::string m_debugName; |
356 float m_opacity; | 357 float m_opacity; |
357 SkImageFilter* m_filter; | 358 SkImageFilter* m_filter; |
358 WebKit::WebFilterOperations m_filters; | 359 WebKit::WebFilterOperations m_filters; |
359 WebKit::WebFilterOperations m_backgroundFilters; | 360 WebKit::WebFilterOperations m_backgroundFilters; |
360 float m_anchorPointZ; | 361 float m_anchorPointZ; |
361 bool m_isContainerForFixedPositionLayers; | 362 bool m_isContainerForFixedPositionLayers; |
(...skipping 20 matching lines...) Expand all Loading... |
382 bool m_drawOpacityIsAnimating; | 383 bool m_drawOpacityIsAnimating; |
383 | 384 |
384 Layer* m_renderTarget; | 385 Layer* m_renderTarget; |
385 | 386 |
386 WebKit::WebTransformationMatrix m_drawTransform; | 387 WebKit::WebTransformationMatrix m_drawTransform; |
387 WebKit::WebTransformationMatrix m_screenSpaceTransform; | 388 WebKit::WebTransformationMatrix m_screenSpaceTransform; |
388 bool m_drawTransformIsAnimating; | 389 bool m_drawTransformIsAnimating; |
389 bool m_screenSpaceTransformIsAnimating; | 390 bool m_screenSpaceTransformIsAnimating; |
390 | 391 |
391 // Uses target surface space. | 392 // Uses target surface space. |
392 IntRect m_drawableContentRect; | 393 gfx::Rect m_drawableContentRect; |
393 float m_contentsScale; | 394 float m_contentsScale; |
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 |
OLD | NEW |