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.
5 #ifndef CC_LAYERS_RENDER_SURFACE_IMPL_H_
6 #define CC_LAYERS_RENDER_SURFACE_IMPL_H_
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/rect.h"
18 #include "ui/gfx/rect_f.h"
19 #include "ui/gfx/transform.h"
24 class DelegatedRendererLayerImpl
;
29 struct AppendQuadsData
;
31 class CC_EXPORT RenderSurfaceImpl
{
33 explicit RenderSurfaceImpl(LayerImpl
* owning_layer
);
34 virtual ~RenderSurfaceImpl();
36 gfx::PointF
ContentRectCenter() const {
37 return gfx::RectF(content_rect_
).CenterPoint();
40 // Returns the rect that encloses the RenderSurfaceImpl including any
42 gfx::RectF
DrawableContentRect() const;
44 void SetDrawOpacity(float opacity
) { draw_opacity_
= opacity
; }
45 float draw_opacity() const { return draw_opacity_
; }
47 void SetNearestOcclusionImmuneAncestor(RenderSurfaceImpl
* surface
) {
48 nearest_occlusion_immune_ancestor_
= surface
;
50 const RenderSurfaceImpl
* nearest_occlusion_immune_ancestor() const {
51 return nearest_occlusion_immune_ancestor_
;
54 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating
) {
55 draw_opacity_is_animating_
= draw_opacity_is_animating
;
57 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_
; }
59 void SetDrawTransform(const gfx::Transform
& draw_transform
) {
60 draw_transform_
= draw_transform
;
62 const gfx::Transform
& draw_transform() const { return draw_transform_
; }
64 void SetScreenSpaceTransform(const gfx::Transform
& screen_space_transform
) {
65 screen_space_transform_
= screen_space_transform
;
67 const gfx::Transform
& screen_space_transform() const {
68 return screen_space_transform_
;
71 void SetReplicaDrawTransform(const gfx::Transform
& replica_draw_transform
) {
72 replica_draw_transform_
= replica_draw_transform
;
74 const gfx::Transform
& replica_draw_transform() const {
75 return replica_draw_transform_
;
78 void SetReplicaScreenSpaceTransform(
79 const gfx::Transform
& replica_screen_space_transform
) {
80 replica_screen_space_transform_
= replica_screen_space_transform
;
82 const gfx::Transform
& replica_screen_space_transform() const {
83 return replica_screen_space_transform_
;
86 void SetTargetSurfaceTransformsAreAnimating(bool animating
) {
87 target_surface_transforms_are_animating_
= animating
;
89 bool target_surface_transforms_are_animating() const {
90 return target_surface_transforms_are_animating_
;
92 void SetScreenSpaceTransformsAreAnimating(bool animating
) {
93 screen_space_transforms_are_animating_
= animating
;
95 bool screen_space_transforms_are_animating() const {
96 return screen_space_transforms_are_animating_
;
99 void SetIsClipped(bool is_clipped
) { is_clipped_
= is_clipped
; }
100 bool is_clipped() const { return is_clipped_
; }
102 void SetClipRect(const gfx::Rect
& clip_rect
);
103 gfx::Rect
clip_rect() const { return clip_rect_
; }
105 // When false, the RenderSurface does not contribute to another target
106 // RenderSurface that is being drawn for the current frame. It could still be
107 // drawn to as a target, but its output will not be a part of any other
109 bool contributes_to_drawn_surface() const {
110 return contributes_to_drawn_surface_
;
112 void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface
) {
113 contributes_to_drawn_surface_
= contributes_to_drawn_surface
;
116 bool ContentsChanged() const;
118 void SetContentRect(const gfx::Rect
& content_rect
);
119 gfx::Rect
content_rect() const { return content_rect_
; }
121 LayerImplList
& layer_list() { return layer_list_
; }
122 void AddContributingDelegatedRenderPassLayer(LayerImpl
* layer
);
123 void ClearLayerLists();
125 int OwningLayerId() const;
127 void ResetPropertyChangedFlag() { surface_property_changed_
= false; }
128 bool SurfacePropertyChanged() const;
129 bool SurfacePropertyChangedOnlyFromDescendant() const;
131 DamageTracker
* damage_tracker() const { return damage_tracker_
.get(); }
133 RenderPass::Id
RenderPassId();
135 void AppendRenderPasses(RenderPassSink
* pass_sink
);
136 void AppendQuads(QuadSink
* quad_sink
,
137 AppendQuadsData
* append_quads_data
,
139 RenderPass::Id render_pass_id
);
142 LayerImpl
* owning_layer_
;
144 // Uses this surface's space.
145 gfx::Rect content_rect_
;
146 bool surface_property_changed_
: 1;
147 bool draw_opacity_is_animating_
: 1;
148 bool target_surface_transforms_are_animating_
: 1;
149 bool screen_space_transforms_are_animating_
: 1;
151 bool is_clipped_
: 1;
152 bool contributes_to_drawn_surface_
: 1;
155 gfx::Transform draw_transform_
;
156 gfx::Transform screen_space_transform_
;
157 gfx::Transform replica_draw_transform_
;
158 gfx::Transform replica_screen_space_transform_
;
160 // Uses the space of the surface's target surface.
161 gfx::Rect clip_rect_
;
163 LayerImplList layer_list_
;
164 std::vector
<DelegatedRendererLayerImpl
*>
165 contributing_delegated_render_pass_layer_list_
;
167 // The nearest ancestor target surface that will contain the contents of this
168 // surface, and that ignores outside occlusion. This can point to itself.
169 RenderSurfaceImpl
* nearest_occlusion_immune_ancestor_
;
171 scoped_ptr
<DamageTracker
> damage_tracker_
;
173 // For LayerIteratorActions
174 int target_render_surface_layer_index_history_
;
175 int current_layer_index_history_
;
177 friend struct LayerIteratorActions
;
179 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceImpl
);
183 #endif // CC_LAYERS_RENDER_SURFACE_IMPL_H_