OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_IMPL_H_ | 5 #ifndef CC_LAYER_IMPL_H_ |
6 #define CC_LAYER_IMPL_H_ | 6 #define CC_LAYER_IMPL_H_ |
7 | 7 |
8 #include <public/WebFilterOperations.h> | 8 #include <public/WebFilterOperations.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 class LayerSorter; | 29 class LayerSorter; |
30 class LayerTreeHostImpl; | 30 class LayerTreeHostImpl; |
31 class QuadSink; | 31 class QuadSink; |
32 class Renderer; | 32 class Renderer; |
33 class ScrollbarAnimationController; | 33 class ScrollbarAnimationController; |
34 class ScrollbarLayerImpl; | 34 class ScrollbarLayerImpl; |
35 class Layer; | 35 class Layer; |
36 | 36 |
37 struct AppendQuadsData; | 37 struct AppendQuadsData; |
38 | 38 |
39 // Container for properties that layers need to compute before they can be drawn . | |
40 struct DrawProperties { | |
danakj
2012/12/01 03:51:40
If the struct has all the same things on both thre
| |
41 DrawProperties() | |
42 : drawOpacity(0) | |
43 , drawOpacityIsAnimating(false) | |
44 , drawTransformIsAnimating(false) | |
45 , screenSpaceTransformIsAnimating(false) | |
46 , isClipped(false) | |
47 , renderTarget(0) | |
48 { | |
49 } | |
50 | |
51 // Transforms objects from content space to target surface space, where | |
52 // this layer would be drawn. | |
53 gfx::Transform drawTransform; | |
54 | |
55 // Transforms objects from content space to screen space (viewport space). | |
56 gfx::Transform screenSpaceTransform; | |
57 | |
58 // drawOpacity may be different than layer's opacity, particularly in the | |
59 // case where a renderSurface re-parents the layer's opacity. | |
60 float drawOpacity; | |
61 | |
62 // XXXIsAnimating flags are used to indicate whether the drawProperties | |
63 // are actually meaningful on the main thread. When the properties are | |
64 // animating, the main thread may not have the same values that are used | |
65 // to draw. | |
66 bool drawOpacityIsAnimating; | |
67 bool drawTransformIsAnimating; | |
68 bool screenSpaceTransformIsAnimating; | |
69 | |
70 // True if the layer needs to be clipped by clipRect. | |
71 bool isClipped; | |
72 | |
73 // The layer whose coordinate space this layer draws into. This can be | |
74 // either the same layer (m_drawProperties.renderTarget == this) or an | |
75 // ancestor of this layer. | |
76 LayerImpl* renderTarget; | |
77 | |
78 // Uses layer's content space. | |
79 gfx::Rect visibleContentRect; | |
80 | |
81 // In target surface space, the rect that encloses the clipped, drawable | |
82 // content of the layer. | |
83 gfx::Rect drawableContentRect; | |
84 | |
85 // In target surface space, the original rect that clipped this | |
86 // layer. This value is used to avoid unnecessarily changing GL scissor | |
87 // state. | |
88 gfx::Rect clipRect; | |
89 }; | |
90 | |
39 class CC_EXPORT LayerImpl : public LayerAnimationControllerClient { | 91 class CC_EXPORT LayerImpl : public LayerAnimationControllerClient { |
40 public: | 92 public: |
41 typedef ScopedPtrVector<LayerImpl> LayerList; | 93 typedef ScopedPtrVector<LayerImpl> LayerList; |
42 | 94 |
43 static scoped_ptr<LayerImpl> create(int id) | 95 static scoped_ptr<LayerImpl> create(int id) |
44 { | 96 { |
45 return make_scoped_ptr(new LayerImpl(id)); | 97 return make_scoped_ptr(new LayerImpl(id)); |
46 } | 98 } |
47 | 99 |
48 virtual ~LayerImpl(); | 100 virtual ~LayerImpl(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 // Debug layer name. | 207 // Debug layer name. |
156 void setDebugName(const std::string& debugName) { m_debugName = debugName; } | 208 void setDebugName(const std::string& debugName) { m_debugName = debugName; } |
157 std::string debugName() const { return m_debugName; } | 209 std::string debugName() const { return m_debugName; } |
158 | 210 |
159 bool showDebugBorders() const; | 211 bool showDebugBorders() const; |
160 | 212 |
161 RenderSurfaceImpl* renderSurface() const { return m_renderSurface.get(); } | 213 RenderSurfaceImpl* renderSurface() const { return m_renderSurface.get(); } |
162 void createRenderSurface(); | 214 void createRenderSurface(); |
163 void clearRenderSurface() { m_renderSurface.reset(); } | 215 void clearRenderSurface() { m_renderSurface.reset(); } |
164 | 216 |
165 float drawOpacity() const { return m_drawOpacity; } | 217 float drawOpacity() const { return m_drawProperties.drawOpacity; } |
danakj
2012/12/01 03:51:40
I guess the plan is for these accessors to go away
| |
166 void setDrawOpacity(float opacity) { m_drawOpacity = opacity; } | 218 void setDrawOpacity(float opacity) { m_drawProperties.drawOpacity = opacity; } |
167 | 219 |
168 bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; } | 220 bool drawOpacityIsAnimating() const { return m_drawProperties.drawOpacityIsA nimating; } |
169 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityI sAnimating = drawOpacityIsAnimating; } | 221 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawProperti es.drawOpacityIsAnimating = drawOpacityIsAnimating; } |
170 | 222 |
171 void setRenderTarget(LayerImpl* target) { m_renderTarget = target; } | 223 void setRenderTarget(LayerImpl* target) { m_drawProperties.renderTarget = ta rget; } |
172 LayerImpl* renderTarget() { DCHECK(!m_renderTarget || m_renderTarget->render Surface()); return m_renderTarget; } | 224 LayerImpl* renderTarget() { DCHECK(!m_drawProperties.renderTarget || m_drawP roperties.renderTarget->renderSurface()); return m_drawProperties.renderTarget; } |
173 const LayerImpl* renderTarget() const { DCHECK(!m_renderTarget || m_renderTa rget->renderSurface()); return m_renderTarget; } | 225 const LayerImpl* renderTarget() const { DCHECK(!m_drawProperties.renderTarge t || m_drawProperties.renderTarget->renderSurface()); return m_drawProperties.re nderTarget; } |
174 | 226 |
175 // The client should be responsible for setting bounds, contentBounds and | 227 // The client should be responsible for setting bounds, contentBounds and |
176 // contentsScale to appropriate values. LayerImpl doesn't calculate any of | 228 // contentsScale to appropriate values. LayerImpl doesn't calculate any of |
177 // them from the other values. | 229 // them from the other values. |
178 | 230 |
179 void setBounds(const gfx::Size&); | 231 void setBounds(const gfx::Size&); |
180 const gfx::Size& bounds() const { return m_bounds; } | 232 const gfx::Size& bounds() const { return m_bounds; } |
181 | 233 |
182 // ContentBounds may be [0, 1) pixels larger than bounds * contentsScale. | 234 // ContentBounds may be [0, 1) pixels larger than bounds * contentsScale. |
183 // Don't calculate scale from it. Use contentsScale instead for accuracy. | 235 // Don't calculate scale from it. Use contentsScale instead for accuracy. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR egion = region; } | 271 void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableR egion = region; } |
220 | 272 |
221 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe gion; } | 273 const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRe gion; } |
222 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR egion = region; } | 274 void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerR egion = region; } |
223 | 275 |
224 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo ardForMissingTiles = checkerboard; } | 276 void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerbo ardForMissingTiles = checkerboard; } |
225 bool drawCheckerboardForMissingTiles() const; | 277 bool drawCheckerboardForMissingTiles() const; |
226 | 278 |
227 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi nt, InputHandlerClient::ScrollInputType) const; | 279 InputHandlerClient::ScrollStatus tryScroll(const gfx::PointF& screenSpacePoi nt, InputHandlerClient::ScrollInputType) const; |
228 | 280 |
229 const gfx::Rect& visibleContentRect() const { return m_visibleContentRect; } | 281 const gfx::Rect& visibleContentRect() const { return m_drawProperties.visibl eContentRect; } |
230 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_visibleC ontentRect = visibleContentRect; } | 282 void setVisibleContentRect(const gfx::Rect& visibleContentRect) { m_drawProp erties.visibleContentRect = visibleContentRect; } |
231 | 283 |
232 bool doubleSided() const { return m_doubleSided; } | 284 bool doubleSided() const { return m_doubleSided; } |
233 void setDoubleSided(bool); | 285 void setDoubleSided(bool); |
234 | 286 |
235 void setTransform(const gfx::Transform&); | 287 void setTransform(const gfx::Transform&); |
236 bool transformIsAnimating() const; | 288 bool transformIsAnimating() const; |
237 | 289 |
238 const gfx::Transform& drawTransform() const { return m_drawTransform; } | 290 const gfx::Transform& drawTransform() const { return m_drawProperties.drawTr ansform; } |
239 void setDrawTransform(const gfx::Transform& matrix) { m_drawTransform = matr ix; } | 291 void setDrawTransform(const gfx::Transform& matrix) { m_drawProperties.drawT ransform = matrix; } |
240 const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTra nsform; } | 292 const gfx::Transform& screenSpaceTransform() const { return m_drawProperties .screenSpaceTransform; } |
241 void setScreenSpaceTransform(const gfx::Transform& matrix) { m_screenSpaceTr ansform = matrix; } | 293 void setScreenSpaceTransform(const gfx::Transform& matrix) { m_drawPropertie s.screenSpaceTransform = matrix; } |
242 | 294 |
243 bool drawTransformIsAnimating() const { return m_drawTransformIsAnimating; } | 295 bool drawTransformIsAnimating() const { return m_drawProperties.drawTransfor mIsAnimating; } |
244 void setDrawTransformIsAnimating(bool animating) { m_drawTransformIsAnimatin g = animating; } | 296 void setDrawTransformIsAnimating(bool animating) { m_drawProperties.drawTran sformIsAnimating = animating; } |
245 bool screenSpaceTransformIsAnimating() const { return m_screenSpaceTransform IsAnimating; } | 297 bool screenSpaceTransformIsAnimating() const { return m_drawProperties.scree nSpaceTransformIsAnimating; } |
246 void setScreenSpaceTransformIsAnimating(bool animating) { m_screenSpaceTrans formIsAnimating = animating; } | 298 void setScreenSpaceTransformIsAnimating(bool animating) { m_drawProperties.s creenSpaceTransformIsAnimating = animating; } |
247 | 299 |
248 bool isClipped() const { return m_isClipped; } | 300 bool isClipped() const { return m_drawProperties.isClipped; } |
249 void setIsClipped(bool isClipped) { m_isClipped = isClipped; } | 301 void setIsClipped(bool isClipped) { m_drawProperties.isClipped = isClipped; } |
250 | 302 |
251 const gfx::Rect& clipRect() const { return m_clipRect; } | 303 const gfx::Rect& clipRect() const { return m_drawProperties.clipRect; } |
252 void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; } | 304 void setClipRect(const gfx::Rect& clipRect) { m_drawProperties.clipRect = cl ipRect; } |
253 | 305 |
254 const gfx::Rect& drawableContentRect() const { return m_drawableContentRect; } | 306 const gfx::Rect& drawableContentRect() const { return m_drawProperties.drawa bleContentRect; } |
255 void setDrawableContentRect(const gfx::Rect& rect) { m_drawableContentRect = rect; } | 307 void setDrawableContentRect(const gfx::Rect& rect) { m_drawProperties.drawab leContentRect = rect; } |
256 | 308 |
257 const gfx::RectF& updateRect() const { return m_updateRect; } | 309 const gfx::RectF& updateRect() const { return m_updateRect; } |
258 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect ; } | 310 void setUpdateRect(const gfx::RectF& updateRect) { m_updateRect = updateRect ; } |
259 | 311 |
260 std::string layerTreeAsText() const; | 312 std::string layerTreeAsText() const; |
261 | 313 |
262 void setStackingOrderChanged(bool); | 314 void setStackingOrderChanged(bool); |
263 | 315 |
264 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs AlwaysDamaged(); } | 316 bool layerPropertyChanged() const { return m_layerPropertyChanged || layerIs AlwaysDamaged(); } |
265 bool layerSurfacePropertyChanged() const; | 317 bool layerSurfacePropertyChanged() const; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 | 399 |
348 // Tracks if drawing-related properties have changed since last redraw. | 400 // Tracks if drawing-related properties have changed since last redraw. |
349 bool m_layerPropertyChanged; | 401 bool m_layerPropertyChanged; |
350 | 402 |
351 // Indicates that a property has changed on this layer that would not | 403 // Indicates that a property has changed on this layer that would not |
352 // affect the pixels on its target surface, but would require redrawing | 404 // affect the pixels on its target surface, but would require redrawing |
353 // but would require redrawing the targetSurface onto its ancestor targetSur face. | 405 // but would require redrawing the targetSurface onto its ancestor targetSur face. |
354 // For layers that do not own a surface this flag acts as m_layerPropertyCha nged. | 406 // For layers that do not own a surface this flag acts as m_layerPropertyCha nged. |
355 bool m_layerSurfacePropertyChanged; | 407 bool m_layerSurfacePropertyChanged; |
356 | 408 |
357 // Uses layer's content space. | |
358 gfx::Rect m_visibleContentRect; | |
359 bool m_masksToBounds; | 409 bool m_masksToBounds; |
360 bool m_contentsOpaque; | 410 bool m_contentsOpaque; |
361 float m_opacity; | 411 float m_opacity; |
362 gfx::PointF m_position; | 412 gfx::PointF m_position; |
363 bool m_preserves3D; | 413 bool m_preserves3D; |
364 bool m_useParentBackfaceVisibility; | 414 bool m_useParentBackfaceVisibility; |
365 bool m_drawCheckerboardForMissingTiles; | 415 bool m_drawCheckerboardForMissingTiles; |
366 gfx::Transform m_sublayerTransform; | 416 gfx::Transform m_sublayerTransform; |
367 gfx::Transform m_transform; | 417 gfx::Transform m_transform; |
368 bool m_useLCDText; | 418 bool m_useLCDText; |
369 | 419 |
370 bool m_drawsContent; | 420 bool m_drawsContent; |
371 bool m_forceRenderSurface; | 421 bool m_forceRenderSurface; |
372 | 422 |
373 // Set for the layer that other layers are fixed to. | 423 // Set for the layer that other layers are fixed to. |
374 bool m_isContainerForFixedPositionLayers; | 424 bool m_isContainerForFixedPositionLayers; |
375 // This is true if the layer should be fixed to the closest ancestor contain er. | 425 // This is true if the layer should be fixed to the closest ancestor contain er. |
376 bool m_fixedToContainerLayer; | 426 bool m_fixedToContainerLayer; |
377 | 427 |
378 gfx::Vector2dF m_scrollDelta; | 428 gfx::Vector2dF m_scrollDelta; |
379 gfx::Vector2d m_sentScrollDelta; | 429 gfx::Vector2d m_sentScrollDelta; |
380 gfx::Vector2d m_maxScrollOffset; | 430 gfx::Vector2d m_maxScrollOffset; |
381 gfx::Transform m_implTransform; | 431 gfx::Transform m_implTransform; |
382 | 432 |
383 // The layer whose coordinate space this layer draws into. This can be | |
384 // either the same layer (m_renderTarget == this) or an ancestor of this | |
385 // layer. | |
386 LayerImpl* m_renderTarget; | |
387 | |
388 // The global depth value of the center of the layer. This value is used | 433 // The global depth value of the center of the layer. This value is used |
389 // to sort layers from back to front. | 434 // to sort layers from back to front. |
390 float m_drawDepth; | 435 float m_drawDepth; |
391 float m_drawOpacity; | |
392 bool m_drawOpacityIsAnimating; | |
393 | 436 |
394 // Debug layer name. | 437 // Debug layer name. |
395 std::string m_debugName; | 438 std::string m_debugName; |
396 | 439 |
397 WebKit::WebFilterOperations m_filters; | 440 WebKit::WebFilterOperations m_filters; |
398 WebKit::WebFilterOperations m_backgroundFilters; | 441 WebKit::WebFilterOperations m_backgroundFilters; |
399 SkImageFilter* m_filter; | 442 SkImageFilter* m_filter; |
400 | 443 |
401 gfx::Transform m_drawTransform; | |
402 gfx::Transform m_screenSpaceTransform; | |
403 bool m_drawTransformIsAnimating; | |
404 bool m_screenSpaceTransformIsAnimating; | |
405 | |
406 #ifndef NDEBUG | 444 #ifndef NDEBUG |
407 bool m_betweenWillDrawAndDidDraw; | 445 bool m_betweenWillDrawAndDidDraw; |
408 #endif | 446 #endif |
409 | 447 |
410 // Render surface associated with this layer. The layer and its descendants | 448 // Render surface associated with this layer. The layer and its descendants |
411 // will render to this surface. | 449 // will render to this surface. |
412 scoped_ptr<RenderSurfaceImpl> m_renderSurface; | 450 scoped_ptr<RenderSurfaceImpl> m_renderSurface; |
413 | 451 |
414 // Uses target surface's space. | |
415 gfx::Rect m_drawableContentRect; | |
416 gfx::Rect m_clipRect; | |
417 | |
418 // True if the layer is clipped by m_clipRect. | |
419 bool m_isClipped; | |
420 | |
421 // Rect indicating what was repainted/updated during update. | 452 // Rect indicating what was repainted/updated during update. |
422 // Note that plugin layers bypass this and leave it empty. | 453 // Note that plugin layers bypass this and leave it empty. |
423 // Uses layer's content space. | 454 // Uses layer's content space. |
424 gfx::RectF m_updateRect; | 455 gfx::RectF m_updateRect; |
425 | 456 |
426 // Manages animations for this layer. | 457 // Manages animations for this layer. |
427 scoped_ptr<LayerAnimationController> m_layerAnimationController; | 458 scoped_ptr<LayerAnimationController> m_layerAnimationController; |
428 | 459 |
429 // Manages scrollbars for this layer | 460 // Manages scrollbars for this layer |
430 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; | 461 scoped_ptr<ScrollbarAnimationController> m_scrollbarAnimationController; |
431 | 462 |
463 // Group of properties that need to be computed based on the layer tree | |
464 // hierarchy before layers can be drawn. | |
465 DrawProperties m_drawProperties; | |
466 | |
432 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 467 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
433 }; | 468 }; |
434 | 469 |
435 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*> ::iterator end, LayerSorter*); | 470 void sortLayers(std::vector<LayerImpl*>::iterator first, std::vector<LayerImpl*> ::iterator end, LayerSorter*); |
436 | 471 |
437 } | 472 } |
438 | 473 |
439 #endif // CC_LAYER_IMPL_H_ | 474 #endif // CC_LAYER_IMPL_H_ |
OLD | NEW |