Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / cc / layers / render_surface_impl.h
blob2035e28b1278a458c5314ffc44efe3a5a7b26e9e
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 template <typename LayerType>
31 class LayerIterator;
33 struct AppendQuadsData;
35 class CC_EXPORT RenderSurfaceImpl {
36 public:
37 explicit RenderSurfaceImpl(LayerImpl* owning_layer);
38 virtual ~RenderSurfaceImpl();
40 gfx::PointF ContentRectCenter() const {
41 return gfx::RectF(content_rect_).CenterPoint();
44 // Returns the rect that encloses the RenderSurfaceImpl including any
45 // reflection.
46 gfx::RectF DrawableContentRect() const;
48 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; }
49 float draw_opacity() const { return draw_opacity_; }
51 void SetNearestOcclusionImmuneAncestor(RenderSurfaceImpl* surface) {
52 nearest_occlusion_immune_ancestor_ = surface;
54 const RenderSurfaceImpl* nearest_occlusion_immune_ancestor() const {
55 return nearest_occlusion_immune_ancestor_;
58 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) {
59 draw_opacity_is_animating_ = draw_opacity_is_animating;
61 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; }
63 SkColor GetDebugBorderColor() const;
64 SkColor GetReplicaDebugBorderColor() const;
66 float GetDebugBorderWidth() const;
67 float GetReplicaDebugBorderWidth() const;
69 void SetDrawTransform(const gfx::Transform& draw_transform) {
70 draw_transform_ = draw_transform;
72 const gfx::Transform& draw_transform() const { return draw_transform_; }
74 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) {
75 screen_space_transform_ = screen_space_transform;
77 const gfx::Transform& screen_space_transform() const {
78 return screen_space_transform_;
81 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) {
82 replica_draw_transform_ = replica_draw_transform;
84 const gfx::Transform& replica_draw_transform() const {
85 return replica_draw_transform_;
88 void SetReplicaScreenSpaceTransform(
89 const gfx::Transform& replica_screen_space_transform) {
90 replica_screen_space_transform_ = replica_screen_space_transform;
92 const gfx::Transform& replica_screen_space_transform() const {
93 return replica_screen_space_transform_;
96 void SetTargetSurfaceTransformsAreAnimating(bool animating) {
97 target_surface_transforms_are_animating_ = animating;
99 bool target_surface_transforms_are_animating() const {
100 return target_surface_transforms_are_animating_;
102 void SetScreenSpaceTransformsAreAnimating(bool animating) {
103 screen_space_transforms_are_animating_ = animating;
105 bool screen_space_transforms_are_animating() const {
106 return screen_space_transforms_are_animating_;
109 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; }
110 bool is_clipped() const { return is_clipped_; }
112 void SetClipRect(const gfx::Rect& clip_rect);
113 gfx::Rect clip_rect() const { return clip_rect_; }
115 // When false, the RenderSurface does not contribute to another target
116 // RenderSurface that is being drawn for the current frame. It could still be
117 // drawn to as a target, but its output will not be a part of any other
118 // surface.
119 bool contributes_to_drawn_surface() const {
120 return contributes_to_drawn_surface_;
122 void set_contributes_to_drawn_surface(bool contributes_to_drawn_surface) {
123 contributes_to_drawn_surface_ = contributes_to_drawn_surface;
126 void SetContentRect(const gfx::Rect& content_rect);
127 gfx::Rect content_rect() const { return content_rect_; }
129 const Occlusion& occlusion_in_content_space() const {
130 return occlusion_in_content_space_;
132 void set_occlusion_in_content_space(const Occlusion& occlusion) {
133 occlusion_in_content_space_ = occlusion;
136 LayerImplList& layer_list() { return layer_list_; }
137 void AddContributingDelegatedRenderPassLayer(LayerImpl* layer);
138 void ClearLayerLists();
140 int OwningLayerId() const;
142 void ResetPropertyChangedFlag() { surface_property_changed_ = false; }
143 bool SurfacePropertyChanged() const;
144 bool SurfacePropertyChangedOnlyFromDescendant() const;
146 DamageTracker* damage_tracker() const { return damage_tracker_.get(); }
148 RenderPassId GetRenderPassId();
150 void AppendRenderPasses(RenderPassSink* pass_sink);
151 void AppendQuads(RenderPass* render_pass,
152 const gfx::Transform& draw_transform,
153 const Occlusion& occlusion_in_content_space,
154 SkColor debug_border_color,
155 float debug_border_width,
156 LayerImpl* mask_layer,
157 AppendQuadsData* append_quads_data,
158 RenderPassId render_pass_id);
160 private:
161 LayerImpl* owning_layer_;
163 // Uses this surface's space.
164 gfx::Rect content_rect_;
165 bool surface_property_changed_ : 1;
166 bool draw_opacity_is_animating_ : 1;
167 bool target_surface_transforms_are_animating_ : 1;
168 bool screen_space_transforms_are_animating_ : 1;
170 bool is_clipped_ : 1;
171 bool contributes_to_drawn_surface_ : 1;
173 float draw_opacity_;
174 gfx::Transform draw_transform_;
175 gfx::Transform screen_space_transform_;
176 gfx::Transform replica_draw_transform_;
177 gfx::Transform replica_screen_space_transform_;
179 // Uses the space of the surface's target surface.
180 gfx::Rect clip_rect_;
182 LayerImplList layer_list_;
183 std::vector<DelegatedRendererLayerImpl*>
184 contributing_delegated_render_pass_layer_list_;
185 Occlusion occlusion_in_content_space_;
187 // The nearest ancestor target surface that will contain the contents of this
188 // surface, and that ignores outside occlusion. This can point to itself.
189 RenderSurfaceImpl* nearest_occlusion_immune_ancestor_;
191 scoped_ptr<DamageTracker> damage_tracker_;
193 // For LayerIteratorActions
194 int target_render_surface_layer_index_history_;
195 int current_layer_index_history_;
197 friend class LayerIterator<LayerImpl>;
199 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceImpl);
202 } // namespace cc
203 #endif // CC_LAYERS_RENDER_SURFACE_IMPL_H_