[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 1 | // Copyright 2010 The Chromium Authors. All rights reserved. |
[email protected] | 0fb2500 | 2012-10-12 07:20:02 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 4 | |
5 | |||||
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 6 | #ifndef CC_RENDER_SURFACE_H_ |
7 | #define CC_RENDER_SURFACE_H_ | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 8 | |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 9 | #include "base/basictypes.h" |
10 | #include "base/memory/ref_counted.h" | ||||
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 11 | #include "ui/gfx/rect.h" |
12 | #include "ui/gfx/rect_f.h" | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 13 | #include <public/WebTransformationMatrix.h> |
14 | #include <vector> | ||||
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 15 | #include "cc/cc_export.h" |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 16 | |
17 | namespace cc { | ||||
18 | |||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 19 | class Layer; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 20 | |
[email protected] | 52347c84 | 2012-11-02 21:06:20 | [diff] [blame] | 21 | class CC_EXPORT RenderSurface { |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 22 | public: |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 23 | explicit RenderSurface(Layer*); |
24 | ~RenderSurface(); | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 25 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 26 | // Returns the rect that encloses the RenderSurfaceImpl including any reflection. |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 27 | gfx::RectF drawableContentRect() const; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 28 | |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 29 | const gfx::Rect& contentRect() const { return m_contentRect; } |
30 | void setContentRect(const gfx::Rect& contentRect) { m_contentRect = contentRect; } | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 31 | |
32 | float drawOpacity() const { return m_drawOpacity; } | ||||
33 | void setDrawOpacity(float drawOpacity) { m_drawOpacity = drawOpacity; } | ||||
34 | |||||
35 | bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating; } | ||||
36 | void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating) { m_drawOpacityIsAnimating = drawOpacityIsAnimating; } | ||||
37 | |||||
38 | // This goes from content space with the origin in the center of the rect being transformed to the target space with the origin in the top left of the | ||||
39 | // rect being transformed. Position the rect so that the origin is in the center of it before applying this transform. | ||||
40 | const WebKit::WebTransformationMatrix& drawTransform() const { return m_drawTransform; } | ||||
41 | void setDrawTransform(const WebKit::WebTransformationMatrix& drawTransform) { m_drawTransform = drawTransform; } | ||||
42 | |||||
43 | const WebKit::WebTransformationMatrix& screenSpaceTransform() const { return m_screenSpaceTransform; } | ||||
44 | void setScreenSpaceTransform(const WebKit::WebTransformationMatrix& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; } | ||||
45 | |||||
46 | const WebKit::WebTransformationMatrix& replicaDrawTransform() const { return m_replicaDrawTransform; } | ||||
47 | void setReplicaDrawTransform(const WebKit::WebTransformationMatrix& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; } | ||||
48 | |||||
49 | const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; } | ||||
50 | void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix& replicaScreenSpaceTransform) { m_replicaScreenSpaceTransform = replicaScreenSpaceTransform; } | ||||
51 | |||||
52 | bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating; } | ||||
53 | void setTargetSurfaceTransformsAreAnimating(bool animating) { m_targetSurfaceTransformsAreAnimating = animating; } | ||||
54 | bool screenSpaceTransformsAreAnimating() const { return m_screenSpaceTransformsAreAnimating; } | ||||
55 | void setScreenSpaceTransformsAreAnimating(bool animating) { m_screenSpaceTransformsAreAnimating = animating; } | ||||
56 | |||||
[email protected] | dc462d78 | 2012-11-21 21:43:01 | [diff] [blame] | 57 | bool isClipped() const { return m_isClipped; } |
58 | void setIsClipped(bool isClipped) { m_isClipped = isClipped; } | ||||
59 | |||||
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 60 | const gfx::Rect& clipRect() const { return m_clipRect; } |
61 | void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; } | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 62 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 63 | typedef std::vector<scoped_refptr<Layer> > LayerList; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 64 | LayerList& layerList() { return m_layerList; } |
65 | // A no-op since DelegatedRendererLayers on the main thread don't have any | ||||
66 | // RenderPasses so they can't contribute to a surface. | ||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 67 | void addContributingDelegatedRenderPassLayer(Layer*) { } |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 68 | void clearLayerLists() { m_layerList.clear(); } |
69 | |||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 70 | void setNearestAncestorThatMovesPixels(RenderSurface* surface) { m_nearestAncestorThatMovesPixels = surface; } |
71 | const RenderSurface* nearestAncestorThatMovesPixels() const { return m_nearestAncestorThatMovesPixels; } | ||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 72 | |
73 | private: | ||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 74 | friend struct LayerIteratorActions; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 75 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 76 | Layer* m_owningLayer; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 77 | |
78 | // Uses this surface's space. | ||||
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 79 | gfx::Rect m_contentRect; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 80 | |
81 | float m_drawOpacity; | ||||
82 | bool m_drawOpacityIsAnimating; | ||||
83 | WebKit::WebTransformationMatrix m_drawTransform; | ||||
84 | WebKit::WebTransformationMatrix m_screenSpaceTransform; | ||||
85 | WebKit::WebTransformationMatrix m_replicaDrawTransform; | ||||
86 | WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform; | ||||
87 | bool m_targetSurfaceTransformsAreAnimating; | ||||
88 | bool m_screenSpaceTransformsAreAnimating; | ||||
89 | |||||
[email protected] | dc462d78 | 2012-11-21 21:43:01 | [diff] [blame] | 90 | bool m_isClipped; |
91 | |||||
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 92 | // Uses the space of the surface's target surface. |
[email protected] | aad0a007 | 2012-11-01 18:15:58 | [diff] [blame] | 93 | gfx::Rect m_clipRect; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 94 | |
95 | LayerList m_layerList; | ||||
96 | |||||
97 | // The nearest ancestor target surface that will contain the contents of this surface, and that is going | ||||
98 | // to move pixels within the surface (such as with a blur). This can point to itself. | ||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 99 | RenderSurface* m_nearestAncestorThatMovesPixels; |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 100 | |
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 101 | // For LayerIteratorActions |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 102 | int m_targetRenderSurfaceLayerIndexHistory; |
103 | int m_currentLayerIndexHistory; | ||||
104 | |||||
[email protected] | 96baf3e | 2012-10-22 23:09:55 | [diff] [blame] | 105 | DISALLOW_COPY_AND_ASSIGN(RenderSurface); |
[email protected] | cd57cc5a | 2012-10-12 22:43:41 | [diff] [blame] | 106 | }; |
107 | |||||
108 | } | ||||
[email protected] | 8fcbaa37 | 2012-11-05 04:12:41 | [diff] [blame] | 109 | #endif // CC_RENDER_SURFACE_H_ |