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 RenderSurfaceChromium_h
7 #define RenderSurfaceChromium_h
9 #if USE(ACCELERATED_COMPOSITING)
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "FloatRect.h"
15 #include <public/WebTransformationMatrix.h>
22 class RenderSurfaceChromium
{
24 explicit RenderSurfaceChromium(LayerChromium
*);
25 ~RenderSurfaceChromium();
27 // Returns the rect that encloses the RenderSurface including any reflection.
28 FloatRect
drawableContentRect() const;
30 const IntRect
& contentRect() const { return m_contentRect
; }
31 void setContentRect(const IntRect
& contentRect
) { m_contentRect
= contentRect
; }
33 float drawOpacity() const { return m_drawOpacity
; }
34 void setDrawOpacity(float drawOpacity
) { m_drawOpacity
= drawOpacity
; }
36 bool drawOpacityIsAnimating() const { return m_drawOpacityIsAnimating
; }
37 void setDrawOpacityIsAnimating(bool drawOpacityIsAnimating
) { m_drawOpacityIsAnimating
= drawOpacityIsAnimating
; }
39 // 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
40 // rect being transformed. Position the rect so that the origin is in the center of it before applying this transform.
41 const WebKit::WebTransformationMatrix
& drawTransform() const { return m_drawTransform
; }
42 void setDrawTransform(const WebKit::WebTransformationMatrix
& drawTransform
) { m_drawTransform
= drawTransform
; }
44 const WebKit::WebTransformationMatrix
& screenSpaceTransform() const { return m_screenSpaceTransform
; }
45 void setScreenSpaceTransform(const WebKit::WebTransformationMatrix
& screenSpaceTransform
) { m_screenSpaceTransform
= screenSpaceTransform
; }
47 const WebKit::WebTransformationMatrix
& replicaDrawTransform() const { return m_replicaDrawTransform
; }
48 void setReplicaDrawTransform(const WebKit::WebTransformationMatrix
& replicaDrawTransform
) { m_replicaDrawTransform
= replicaDrawTransform
; }
50 const WebKit::WebTransformationMatrix
& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform
; }
51 void setReplicaScreenSpaceTransform(const WebKit::WebTransformationMatrix
& replicaScreenSpaceTransform
) { m_replicaScreenSpaceTransform
= replicaScreenSpaceTransform
; }
53 bool targetSurfaceTransformsAreAnimating() const { return m_targetSurfaceTransformsAreAnimating
; }
54 void setTargetSurfaceTransformsAreAnimating(bool animating
) { m_targetSurfaceTransformsAreAnimating
= animating
; }
55 bool screenSpaceTransformsAreAnimating() const { return m_screenSpaceTransformsAreAnimating
; }
56 void setScreenSpaceTransformsAreAnimating(bool animating
) { m_screenSpaceTransformsAreAnimating
= animating
; }
58 const IntRect
& clipRect() const { return m_clipRect
; }
59 void setClipRect(const IntRect
& clipRect
) { m_clipRect
= clipRect
; }
61 typedef std::vector
<scoped_refptr
<LayerChromium
> > LayerList
;
62 LayerList
& layerList() { return m_layerList
; }
63 // A no-op since DelegatedRendererLayers on the main thread don't have any
64 // RenderPasses so they can't contribute to a surface.
65 void addContributingDelegatedRenderPassLayer(LayerChromium
*) { }
66 void clearLayerLists() { m_layerList
.clear(); }
68 void setNearestAncestorThatMovesPixels(RenderSurfaceChromium
* surface
) { m_nearestAncestorThatMovesPixels
= surface
; }
69 const RenderSurfaceChromium
* nearestAncestorThatMovesPixels() const { return m_nearestAncestorThatMovesPixels
; }
72 friend struct CCLayerIteratorActions
;
74 LayerChromium
* m_owningLayer
;
76 // Uses this surface's space.
77 IntRect m_contentRect
;
80 bool m_drawOpacityIsAnimating
;
81 WebKit::WebTransformationMatrix m_drawTransform
;
82 WebKit::WebTransformationMatrix m_screenSpaceTransform
;
83 WebKit::WebTransformationMatrix m_replicaDrawTransform
;
84 WebKit::WebTransformationMatrix m_replicaScreenSpaceTransform
;
85 bool m_targetSurfaceTransformsAreAnimating
;
86 bool m_screenSpaceTransformsAreAnimating
;
88 // Uses the space of the surface's target surface.
91 LayerList m_layerList
;
93 // The nearest ancestor target surface that will contain the contents of this surface, and that is going
94 // to move pixels within the surface (such as with a blur). This can point to itself.
95 RenderSurfaceChromium
* m_nearestAncestorThatMovesPixels
;
97 // For CCLayerIteratorActions
98 int m_targetRenderSurfaceLayerIndexHistory
;
99 int m_currentLayerIndexHistory
;
101 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceChromium
);
105 #endif // USE(ACCELERATED_COMPOSITING)