Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / cc / layers / render_surface_impl.h
blob80a4f720b7be40f8d9206ba1c98093d0d9bd54cc
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_
8 #include <string>
9 #include <vector>
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 "cc/trees/occlusion.h"
18 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/rect_f.h"
20 #include "ui/gfx/transform.h"
22 namespace cc {
24 class DamageTracker;
25 class DelegatedRendererLayerImpl;
26 class Occlusion;
27 class RenderPassId;
28 class RenderPassSink;
29 class LayerImpl;
30 class LayerIterator;
32 struct AppendQuadsData;
34 class CC_EXPORT RenderSurfaceImpl {
35 public:
36 explicit RenderSurfaceImpl(LayerImpl* owning_layer);
37 virtual ~RenderSurfaceImpl();
39 gfx::PointF ContentRectCenter() const {
40 return gfx::RectF(content_rect_).CenterPoint();
43 // Returns the rect that encloses the RenderSurfaceImpl including any
44 // reflection.
45 gfx::RectF DrawableContentRect() const;
47 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; }
48 float draw_opacity() const { return draw_opacity_; }
50 void SetNearestOcclusionImmuneAncestor(RenderSurfaceImpl* surface) {
51 nearest_occlusion_immune_ancestor_ = surface;
53 const RenderSurfaceImpl* nearest_occlusion_immune_ancestor() const {
54 return nearest_occlusion_immune_ancestor_;
57 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) {
58 draw_opacity_is_animating_ = draw_opacity_is_animating;
60 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; }
62 SkColor GetDebugBorderColor() const;
63 SkColor GetReplicaDebugBorderColor() const;
65 float GetDebugBorderWidth() const;
66 float GetReplicaDebugBorderWidth() const;
68 void SetDrawTransform(const gfx::Transform& draw_transform) {
69 draw_transform_ = draw_transform;
71 const gfx::Transform& draw_transform() const { return draw_transform_; }
73 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) {
74 screen_space_transform_ = screen_space_transform;
76 const gfx::Transform& screen_space_transform() const {
77 return screen_space_transform_;
80 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) {
81 replica_draw_transform_ = replica_draw_transform;
83 const gfx::Transform& replica_draw_transform() const {
84 return replica_draw_transform_;
87 void SetReplicaScreenSpaceTransform(
88 const gfx::Transform& replica_screen_space_transform) {
89 replica_screen_space_transform_ = replica_screen_space_transform;
91 const gfx::Transform& replica_screen_space_transform() const {
92 return replica_screen_space_transform_;
95 void SetTargetSurfaceTransformsAreAnimating(bool animating) {
96 target_surface_transforms_are_animating_ = animating;
98 bool target_surface_transforms_are_animating() const {
99 return target_surface_transforms_are_animating_;
101 void SetScreenSpaceTransformsAreAnimating(bool animating) {
102 screen_space_transforms_are_animating_ = animating;
104 bool screen_space_transforms_are_animating() const {
105 return screen_space_transforms_are_animating_;
108 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; }
109 bool is_clipped() const { return is_clipped_; }
111 void SetClipRect(const gfx::Rect& clip_rect);
112 gfx::Rect clip_rect() const { return clip_rect_; }
114 // When false, the RenderSurface does not contribute to another target
115 // RenderSurface that is being drawn for the current frame. It could still be
116 // drawn to as a target, but its output will not be a part of any other
117 // surface.
118 bool contributes_to_drawn_surface() const {
119 return contributes_to_drawn_surface_;
121 void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface) {
122 contributes_to_drawn_surface_ = contributes_to_drawn_surface;
125 void SetContentRect(const gfx::Rect& content_rect);
126 gfx::Rect content_rect() const { return content_rect_; }
128 const Occlusion& occlusion_in_content_space() const {
129 return occlusion_in_content_space_;
131 void set_occlusion_in_content_space(const Occlusion& occlusion) {
132 occlusion_in_content_space_ = occlusion;
135 LayerImplList& layer_list() { return layer_list_; }
136 void AddContributingDelegatedRenderPassLayer(LayerImpl* layer);
137 void ClearLayerLists();
139 int OwningLayerId() const;
141 void ResetPropertyChangedFlag() { surface_property_changed_ = false; }
142 bool SurfacePropertyChanged() const;
143 bool SurfacePropertyChangedOnlyFromDescendant() const;
145 DamageTracker* damage_tracker() const { return damage_tracker_.get(); }
147 RenderPassId GetRenderPassId();
149 void AppendRenderPasses(RenderPassSink* pass_sink);
150 void AppendQuads(RenderPass* render_pass,
151 const gfx::Transform& draw_transform,
152 const Occlusion& occlusion_in_content_space,
153 SkColor debug_border_color,
154 float debug_border_width,
155 LayerImpl* mask_layer,
156 AppendQuadsData* append_quads_data,
157 RenderPassId render_pass_id);
159 private:
160 LayerImpl* owning_layer_;
162 // Uses this surface's space.
163 gfx::Rect content_rect_;
164 bool surface_property_changed_ : 1;
165 bool draw_opacity_is_animating_ : 1;
166 bool target_surface_transforms_are_animating_ : 1;
167 bool screen_space_transforms_are_animating_ : 1;
169 bool is_clipped_ : 1;
170 bool contributes_to_drawn_surface_ : 1;
172 float draw_opacity_;
173 gfx::Transform draw_transform_;
174 gfx::Transform screen_space_transform_;
175 gfx::Transform replica_draw_transform_;
176 gfx::Transform replica_screen_space_transform_;
178 // Uses the space of the surface's target surface.
179 gfx::Rect clip_rect_;
181 LayerImplList layer_list_;
182 std::vector<DelegatedRendererLayerImpl*>
183 contributing_delegated_render_pass_layer_list_;
184 Occlusion occlusion_in_content_space_;
186 // The nearest ancestor target surface that will contain the contents of this
187 // surface, and that ignores outside occlusion. This can point to itself.
188 RenderSurfaceImpl* nearest_occlusion_immune_ancestor_;
190 scoped_ptr<DamageTracker> damage_tracker_;
192 // For LayerIteratorActions
193 int target_render_surface_layer_index_history_;
194 size_t current_layer_index_history_;
196 friend class LayerIterator;
198 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceImpl);
201 } // namespace cc
202 #endif // CC_LAYERS_RENDER_SURFACE_IMPL_H_