Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / cc / layers / render_surface_impl.h
1 // Copyright 2011 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.
4
5 #ifndef CC_LAYERS_RENDER_SURFACE_IMPL_H_
6 #define CC_LAYERS_RENDER_SURFACE_IMPL_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "cc/base/cc_export.h"
14 #include "cc/layers/layer_lists.h"
15 #include "cc/quads/render_pass.h"
16 #include "cc/quads/shared_quad_state.h"
17 #include "ui/gfx/geometry/rect.h"
18 #include "ui/gfx/geometry/rect_f.h"
19 #include "ui/gfx/transform.h"
20
21 namespace cc {
22
23 class DamageTracker;
24 class DelegatedRendererLayerImpl;
25 template <typename LayerType>
26 class OcclusionTracker;
27 class RenderPassId;
28 class RenderPassSink;
29 class LayerImpl;
30 template <typename LayerType>
31 class LayerIterator;
32
33 struct AppendQuadsData;
34
35 class CC_EXPORT RenderSurfaceImpl {
36  public:
37   explicit RenderSurfaceImpl(LayerImpl* owning_layer);
38   virtual ~RenderSurfaceImpl();
39
40   gfx::PointF ContentRectCenter() const {
41     return gfx::RectF(content_rect_).CenterPoint();
42   }
43
44   // Returns the rect that encloses the RenderSurfaceImpl including any
45   // reflection.
46   gfx::RectF DrawableContentRect() const;
47
48   void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; }
49   float draw_opacity() const { return draw_opacity_; }
50
51   void SetNearestOcclusionImmuneAncestor(RenderSurfaceImpl* surface) {
52     nearest_occlusion_immune_ancestor_ = surface;
53   }
54   const RenderSurfaceImpl* nearest_occlusion_immune_ancestor() const {
55     return nearest_occlusion_immune_ancestor_;
56   }
57
58   void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) {
59     draw_opacity_is_animating_ = draw_opacity_is_animating;
60   }
61   bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; }
62
63   void SetDrawTransform(const gfx::Transform& draw_transform) {
64     draw_transform_ = draw_transform;
65   }
66   const gfx::Transform& draw_transform() const { return draw_transform_; }
67
68   void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) {
69     screen_space_transform_ = screen_space_transform;
70   }
71   const gfx::Transform& screen_space_transform() const {
72     return screen_space_transform_;
73   }
74
75   void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) {
76     replica_draw_transform_ = replica_draw_transform;
77   }
78   const gfx::Transform& replica_draw_transform() const {
79     return replica_draw_transform_;
80   }
81
82   void SetReplicaScreenSpaceTransform(
83       const gfx::Transform& replica_screen_space_transform) {
84     replica_screen_space_transform_ = replica_screen_space_transform;
85   }
86   const gfx::Transform& replica_screen_space_transform() const {
87     return replica_screen_space_transform_;
88   }
89
90   void SetTargetSurfaceTransformsAreAnimating(bool animating) {
91     target_surface_transforms_are_animating_ = animating;
92   }
93   bool target_surface_transforms_are_animating() const {
94     return target_surface_transforms_are_animating_;
95   }
96   void SetScreenSpaceTransformsAreAnimating(bool animating) {
97     screen_space_transforms_are_animating_ = animating;
98   }
99   bool screen_space_transforms_are_animating() const {
100     return screen_space_transforms_are_animating_;
101   }
102
103   void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; }
104   bool is_clipped() const { return is_clipped_; }
105
106   void SetClipRect(const gfx::Rect& clip_rect);
107   gfx::Rect clip_rect() const { return clip_rect_; }
108
109   // When false, the RenderSurface does not contribute to another target
110   // RenderSurface that is being drawn for the current frame. It could still be
111   // drawn to as a target, but its output will not be a part of any other
112   // surface.
113   bool contributes_to_drawn_surface() const {
114     return contributes_to_drawn_surface_;
115   }
116   void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface) {
117     contributes_to_drawn_surface_ = contributes_to_drawn_surface;
118   }
119
120   void SetContentRect(const gfx::Rect& content_rect);
121   gfx::Rect content_rect() const { return content_rect_; }
122
123   LayerImplList& layer_list() { return layer_list_; }
124   void AddContributingDelegatedRenderPassLayer(LayerImpl* layer);
125   void ClearLayerLists();
126
127   int OwningLayerId() const;
128
129   void ResetPropertyChangedFlag() { surface_property_changed_ = false; }
130   bool SurfacePropertyChanged() const;
131   bool SurfacePropertyChangedOnlyFromDescendant() const;
132
133   DamageTracker* damage_tracker() const { return damage_tracker_.get(); }
134
135   RenderPassId GetRenderPassId();
136
137   void AppendRenderPasses(RenderPassSink* pass_sink);
138   void AppendQuads(RenderPass* render_pass,
139                    const OcclusionTracker<LayerImpl>& occlusion_tracker,
140                    AppendQuadsData* append_quads_data,
141                    bool for_replica,
142                    RenderPassId render_pass_id);
143
144  private:
145   LayerImpl* owning_layer_;
146
147   // Uses this surface's space.
148   gfx::Rect content_rect_;
149   bool surface_property_changed_ : 1;
150   bool draw_opacity_is_animating_ : 1;
151   bool target_surface_transforms_are_animating_ : 1;
152   bool screen_space_transforms_are_animating_ : 1;
153
154   bool is_clipped_ : 1;
155   bool contributes_to_drawn_surface_ : 1;
156
157   float draw_opacity_;
158   gfx::Transform draw_transform_;
159   gfx::Transform screen_space_transform_;
160   gfx::Transform replica_draw_transform_;
161   gfx::Transform replica_screen_space_transform_;
162
163   // Uses the space of the surface's target surface.
164   gfx::Rect clip_rect_;
165
166   LayerImplList layer_list_;
167   std::vector<DelegatedRendererLayerImpl*>
168       contributing_delegated_render_pass_layer_list_;
169
170   // The nearest ancestor target surface that will contain the contents of this
171   // surface, and that ignores outside occlusion. This can point to itself.
172   RenderSurfaceImpl* nearest_occlusion_immune_ancestor_;
173
174   scoped_ptr<DamageTracker> damage_tracker_;
175
176   // For LayerIteratorActions
177   int target_render_surface_layer_index_history_;
178   int current_layer_index_history_;
179
180   friend class LayerIterator<LayerImpl>;
181
182   DISALLOW_COPY_AND_ASSIGN(RenderSurfaceImpl);
183 };
184
185 }  // namespace cc
186 #endif  // CC_LAYERS_RENDER_SURFACE_IMPL_H_