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
3 // found in the LICENSE file.
6 #ifndef CC_RENDER_SURFACE_H_
7 #define CC_RENDER_SURFACE_H_
9 #include "base/basictypes.h"
10 #include "base/memory/ref_counted.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/gfx/rect_f.h"
13 #include <public/WebTransformationMatrix.h>
15 #include "cc/cc_export.h"
21 class CC_EXPORT RenderSurface
{
23 explicit RenderSurface(Layer
*);
26 // Returns the rect that encloses the RenderSurfaceImpl including any reflection.
27 gfx::RectF
drawableContentRect() const;
29 const gfx::Rect
& contentRect() const { return m_contentRect
; }
30 void setContentRect(const gfx::Rect
& contentRect
) { m_contentRect
= contentRect
; }
32 float drawOpacity() const { return m_drawOpacity
; }
33 void setDrawOpacity(float drawOpacity
) { m_drawOpacity
= drawOpacity
; }
35 bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating
; }
36 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating
) { m_drawOpacityIsAnimating
= drawOpacityIsAnimating
; }
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
; }
43 const WebKit::WebTransformationMatrix
& screenSpaceTransform() const { return m_screenSpaceTransform
; }
44 void setScreenSpaceTransform(const WebKit::WebTransformationMatrix
& screenSpaceTransform
) { m_screenSpaceTransform
= screenSpaceTransform
; }
46 const WebKit::WebTransformationMatrix
& replicaDrawTransform() const { return m_replicaDrawTransform
; }
47 void setReplicaDrawTransform(const WebKit::WebTransformationMatrix
& replicaDrawTransform
) { m_replicaDrawTransform
= replicaDrawTransform
; }
49 const WebKit::WebTransformationMatrix
& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform
; }
50 void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix
& replicaScreenSpaceTransform
) { m_replicaScreenSpaceTransform
= replicaScreenSpaceTransform
; }
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
; }
57 const gfx::Rect
& clipRect() const { return m_clipRect
; }
58 void setClipRect(const gfx::Rect
& clipRect
) { m_clipRect
= clipRect
; }
60 typedef std::vector
<scoped_refptr
<Layer
> > LayerList
;
61 LayerList
& layerList() { return m_layerList
; }
62 // A no-op since DelegatedRendererLayers on the main thread don't have any
63 // RenderPasses so they can't contribute to a surface.
64 void addContributingDelegatedRenderPassLayer(Layer
*) { }
65 void clearLayerLists() { m_layerList
.clear(); }
67 void setNearestAncestorThatMovesPixels(RenderSurface
* surface
) { m_nearestAncestorThatMovesPixels
= surface
; }
68 const RenderSurface
* nearestAncestorThatMovesPixels() const { return m_nearestAncestorThatMovesPixels
; }
71 friend struct LayerIteratorActions
;
75 // Uses this surface's space.
76 gfx::Rect m_contentRect
;
79 bool m_drawOpacityIsAnimating
;
80 WebKit::WebTransformationMatrix m_drawTransform
;
81 WebKit::WebTransformationMatrix m_screenSpaceTransform
;
82 WebKit::WebTransformationMatrix m_replicaDrawTransform
;
83 WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform
;
84 bool m_targetSurfaceTransformsAreAnimating
;
85 bool m_screenSpaceTransformsAreAnimating
;
87 // Uses the space of the surface's target surface.
90 LayerList m_layerList
;
92 // The nearest ancestor target surface that will contain the contents of this surface, and that is going
93 // to move pixels within the surface (such as with a blur). This can point to itself.
94 RenderSurface
* m_nearestAncestorThatMovesPixels
;
96 // For LayerIteratorActions
97 int m_targetRenderSurfaceLayerIndexHistory
;
98 int m_currentLayerIndexHistory
;
100 DISALLOW_COPY_AND_ASSIGN(RenderSurface
);
104 #endif // CC_RENDER_SURFACE_H_