WebKit Roll 139512:139548
[chromium-blink-merge.git] / cc / render_surface.h
blobc1c0b06f2a847a0dade2997af91dd586eef32bc5
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 <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "cc/cc_export.h"
14 #include "ui/gfx/rect.h"
15 #include "ui/gfx/rect_f.h"
16 #include "ui/gfx/transform.h"
18 namespace cc {
20 class Layer;
22 class CC_EXPORT RenderSurface {
23 public:
24 explicit RenderSurface(Layer*);
25 ~RenderSurface();
27 // Returns the rect that encloses the RenderSurfaceImpl including any reflection.
28 gfx::RectF drawableContentRect() const;
30 const gfx::Rect& contentRect() const { return m_contentRect; }
31 void setContentRect(const gfx::Rect& 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 gfx::Transform& drawTransform() const { return m_drawTransform; }
42 void setDrawTransform(const gfx::Transform& drawTransform) { m_drawTransform = drawTransform; }
44 const gfx::Transform& screenSpaceTransform() const { return m_screenSpaceTransform; }
45 void setScreenSpaceTransform(const gfx::Transform& screenSpaceTransform) { m_screenSpaceTransform = screenSpaceTransform; }
47 const gfx::Transform& replicaDrawTransform() const { return m_replicaDrawTransform; }
48 void setReplicaDrawTransform(const gfx::Transform& replicaDrawTransform) { m_replicaDrawTransform = replicaDrawTransform; }
50 const gfx::Transform& replicaScreenSpaceTransform() const { return m_replicaScreenSpaceTransform; }
51 void setReplicaScreenSpaceTransform(const gfx::Transform& 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 bool isClipped() const { return m_isClipped; }
59 void setIsClipped(bool isClipped) { m_isClipped = isClipped; }
61 const gfx::Rect& clipRect() const { return m_clipRect; }
62 void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; }
64 typedef std::vector<scoped_refptr<Layer> > LayerList;
65 LayerList& layerList() { return m_layerList; }
66 // A no-op since DelegatedRendererLayers on the main thread don't have any
67 // RenderPasses so they can't contribute to a surface.
68 void addContributingDelegatedRenderPassLayer(Layer*) { }
69 void clearLayerLists() { m_layerList.clear(); }
71 void setNearestAncestorThatMovesPixels(RenderSurface* surface) { m_nearestAncestorThatMovesPixels = surface; }
72 const RenderSurface* nearestAncestorThatMovesPixels() const { return m_nearestAncestorThatMovesPixels; }
74 private:
75 friend struct LayerIteratorActions;
77 Layer* m_owningLayer;
79 // Uses this surface's space.
80 gfx::Rect m_contentRect;
82 float m_drawOpacity;
83 bool m_drawOpacityIsAnimating;
84 gfx::Transform m_drawTransform;
85 gfx::Transform m_screenSpaceTransform;
86 gfx::Transform m_replicaDrawTransform;
87 gfx::Transform m_replicaScreenSpaceTransform;
88 bool m_targetSurfaceTransformsAreAnimating;
89 bool m_screenSpaceTransformsAreAnimating;
91 bool m_isClipped;
93 // Uses the space of the surface's target surface.
94 gfx::Rect m_clipRect;
96 LayerList m_layerList;
98 // The nearest ancestor target surface that will contain the contents of this surface, and that is going
99 // to move pixels within the surface (such as with a blur). This can point to itself.
100 RenderSurface* m_nearestAncestorThatMovesPixels;
102 // For LayerIteratorActions
103 int m_targetRenderSurfaceLayerIndexHistory;
104 int m_currentLayerIndexHistory;
106 DISALLOW_COPY_AND_ASSIGN(RenderSurface);
110 #endif // CC_RENDER_SURFACE_H_