blob: 230f89d1cdace0612ea4e279509fe58f52fe79ce [file] [log] [blame]
[email protected]cd57cc5a2012-10-12 22:43:411// Copyright 2010 The Chromium Authors. All rights reserved.
[email protected]0fb25002012-10-12 07:20:022// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]cd57cc5a2012-10-12 22:43:414
5
[email protected]8fcbaa372012-11-05 04:12:416#ifndef CC_RENDER_SURFACE_H_
7#define CC_RENDER_SURFACE_H_
[email protected]cd57cc5a2012-10-12 22:43:418
[email protected]cd57cc5a2012-10-12 22:43:419#include "base/basictypes.h"
10#include "base/memory/ref_counted.h"
[email protected]aad0a0072012-11-01 18:15:5811#include "ui/gfx/rect.h"
12#include "ui/gfx/rect_f.h"
[email protected]cd57cc5a2012-10-12 22:43:4113#include <public/WebTransformationMatrix.h>
14#include <vector>
[email protected]52347c842012-11-02 21:06:2015#include "cc/cc_export.h"
[email protected]cd57cc5a2012-10-12 22:43:4116
17namespace cc {
18
[email protected]96baf3e2012-10-22 23:09:5519class Layer;
[email protected]cd57cc5a2012-10-12 22:43:4120
[email protected]52347c842012-11-02 21:06:2021class CC_EXPORT RenderSurface {
[email protected]cd57cc5a2012-10-12 22:43:4122public:
[email protected]96baf3e2012-10-22 23:09:5523 explicit RenderSurface(Layer*);
24 ~RenderSurface();
[email protected]cd57cc5a2012-10-12 22:43:4125
[email protected]96baf3e2012-10-22 23:09:5526 // Returns the rect that encloses the RenderSurfaceImpl including any reflection.
[email protected]aad0a0072012-11-01 18:15:5827 gfx::RectF drawableContentRect() const;
[email protected]cd57cc5a2012-10-12 22:43:4128
[email protected]aad0a0072012-11-01 18:15:5829 const gfx::Rect& contentRect() const { return m_contentRect; }
30 void setContentRect(const gfx::Rect& contentRect) { m_contentRect = contentRect; }
[email protected]cd57cc5a2012-10-12 22:43:4131
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]dc462d782012-11-21 21:43:0157 bool isClipped() const { return m_isClipped; }
58 void setIsClipped(bool isClipped) { m_isClipped = isClipped; }
59
[email protected]aad0a0072012-11-01 18:15:5860 const gfx::Rect& clipRect() const { return m_clipRect; }
61 void setClipRect(const gfx::Rect& clipRect) { m_clipRect = clipRect; }
[email protected]cd57cc5a2012-10-12 22:43:4162
[email protected]96baf3e2012-10-22 23:09:5563 typedef std::vector<scoped_refptr<Layer> > LayerList;
[email protected]cd57cc5a2012-10-12 22:43:4164 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]96baf3e2012-10-22 23:09:5567 void addContributingDelegatedRenderPassLayer(Layer*) { }
[email protected]cd57cc5a2012-10-12 22:43:4168 void clearLayerLists() { m_layerList.clear(); }
69
[email protected]96baf3e2012-10-22 23:09:5570 void setNearestAncestorThatMovesPixels(RenderSurface* surface) { m_nearestAncestorThatMovesPixels = surface; }
71 const RenderSurface* nearestAncestorThatMovesPixels() const { return m_nearestAncestorThatMovesPixels; }
[email protected]cd57cc5a2012-10-12 22:43:4172
73private:
[email protected]96baf3e2012-10-22 23:09:5574 friend struct LayerIteratorActions;
[email protected]cd57cc5a2012-10-12 22:43:4175
[email protected]96baf3e2012-10-22 23:09:5576 Layer* m_owningLayer;
[email protected]cd57cc5a2012-10-12 22:43:4177
78 // Uses this surface's space.
[email protected]aad0a0072012-11-01 18:15:5879 gfx::Rect m_contentRect;
[email protected]cd57cc5a2012-10-12 22:43:4180
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]dc462d782012-11-21 21:43:0190 bool m_isClipped;
91
[email protected]cd57cc5a2012-10-12 22:43:4192 // Uses the space of the surface's target surface.
[email protected]aad0a0072012-11-01 18:15:5893 gfx::Rect m_clipRect;
[email protected]cd57cc5a2012-10-12 22:43:4194
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]96baf3e2012-10-22 23:09:5599 RenderSurface* m_nearestAncestorThatMovesPixels;
[email protected]cd57cc5a2012-10-12 22:43:41100
[email protected]96baf3e2012-10-22 23:09:55101 // For LayerIteratorActions
[email protected]cd57cc5a2012-10-12 22:43:41102 int m_targetRenderSurfaceLayerIndexHistory;
103 int m_currentLayerIndexHistory;
104
[email protected]96baf3e2012-10-22 23:09:55105 DISALLOW_COPY_AND_ASSIGN(RenderSurface);
[email protected]cd57cc5a2012-10-12 22:43:41106};
107
108}
[email protected]8fcbaa372012-11-05 04:12:41109#endif // CC_RENDER_SURFACE_H_