OLD | NEW |
| (Empty) |
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_RENDER_SURFACE_IMPL_H_ | |
6 #define CC_RENDER_SURFACE_IMPL_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "cc/base/cc_export.h" | |
11 #include "cc/quads/render_pass.h" | |
12 #include "cc/quads/shared_quad_state.h" | |
13 #include "ui/gfx/rect.h" | |
14 #include "ui/gfx/rect_f.h" | |
15 #include "ui/gfx/transform.h" | |
16 | |
17 namespace cc { | |
18 | |
19 class DamageTracker; | |
20 class DelegatedRendererLayerImpl; | |
21 class QuadSink; | |
22 class RenderPassSink; | |
23 class LayerImpl; | |
24 | |
25 struct AppendQuadsData; | |
26 | |
27 class CC_EXPORT RenderSurfaceImpl { | |
28 public: | |
29 explicit RenderSurfaceImpl(LayerImpl* owning_layer); | |
30 virtual ~RenderSurfaceImpl(); | |
31 | |
32 std::string Name() const; | |
33 void DumpSurface(std::string* str, int indent) const; | |
34 | |
35 gfx::PointF ContentRectCenter() const { | |
36 return gfx::RectF(content_rect_).CenterPoint(); | |
37 } | |
38 | |
39 // Returns the rect that encloses the RenderSurfaceImpl including any | |
40 // reflection. | |
41 gfx::RectF DrawableContentRect() const; | |
42 | |
43 void SetDrawOpacity(float opacity) { draw_opacity_ = opacity; } | |
44 float draw_opacity() const { return draw_opacity_; } | |
45 | |
46 void SetNearestAncestorThatMovesPixels(RenderSurfaceImpl* surface) { | |
47 nearest_ancestor_that_moves_pixels_ = surface; | |
48 } | |
49 const RenderSurfaceImpl* nearest_ancestor_that_moves_pixels() const { | |
50 return nearest_ancestor_that_moves_pixels_; | |
51 } | |
52 | |
53 void SetDrawOpacityIsAnimating(bool draw_opacity_is_animating) { | |
54 draw_opacity_is_animating_ = draw_opacity_is_animating; | |
55 } | |
56 bool draw_opacity_is_animating() const { return draw_opacity_is_animating_; } | |
57 | |
58 void SetDrawTransform(const gfx::Transform& draw_transform) { | |
59 draw_transform_ = draw_transform; | |
60 } | |
61 const gfx::Transform& draw_transform() const { return draw_transform_; } | |
62 | |
63 void SetScreenSpaceTransform(const gfx::Transform& screen_space_transform) { | |
64 screen_space_transform_ = screen_space_transform; | |
65 } | |
66 const gfx::Transform& screen_space_transform() const { | |
67 return screen_space_transform_; | |
68 } | |
69 | |
70 void SetReplicaDrawTransform(const gfx::Transform& replica_draw_transform) { | |
71 replica_draw_transform_ = replica_draw_transform; | |
72 } | |
73 const gfx::Transform& replica_draw_transform() const { | |
74 return replica_draw_transform_; | |
75 } | |
76 | |
77 void SetReplicaScreenSpaceTransform( | |
78 const gfx::Transform& replica_screen_space_transform) { | |
79 replica_screen_space_transform_ = replica_screen_space_transform; | |
80 } | |
81 const gfx::Transform& replica_screen_space_transform() const { | |
82 return replica_screen_space_transform_; | |
83 } | |
84 | |
85 void SetTargetSurfaceTransformsAreAnimating(bool animating) { | |
86 target_surface_transforms_are_animating_ = animating; | |
87 } | |
88 bool target_surface_transforms_are_animating() const { | |
89 return target_surface_transforms_are_animating_; | |
90 } | |
91 void SetScreenSpaceTransformsAreAnimating(bool animating) { | |
92 screen_space_transforms_are_animating_ = animating; | |
93 } | |
94 bool screen_space_transforms_are_animating() const { | |
95 return screen_space_transforms_are_animating_; | |
96 } | |
97 | |
98 void SetIsClipped(bool is_clipped) { is_clipped_ = is_clipped; } | |
99 bool is_clipped() const { return is_clipped_; } | |
100 | |
101 void SetClipRect(gfx::Rect clip_rect); | |
102 gfx::Rect clip_rect() const { return clip_rect_; } | |
103 | |
104 bool ContentsChanged() const; | |
105 | |
106 void SetContentRect(gfx::Rect content_rect); | |
107 gfx::Rect content_rect() const { return content_rect_; } | |
108 | |
109 std::vector<LayerImpl*>& layer_list() { return layer_list_; } | |
110 void AddContributingDelegatedRenderPassLayer(LayerImpl* layer); | |
111 void ClearLayerLists(); | |
112 | |
113 int OwningLayerId() const; | |
114 | |
115 void ResetPropertyChangedFlag() { surface_property_changed_ = false; } | |
116 bool SurfacePropertyChanged() const; | |
117 bool SurfacePropertyChangedOnlyFromDescendant() const; | |
118 | |
119 DamageTracker* damage_tracker() const { return damage_tracker_.get(); } | |
120 | |
121 RenderPass::Id RenderPassId(); | |
122 | |
123 void AppendRenderPasses(RenderPassSink* pass_sink); | |
124 void AppendQuads(QuadSink* quad_sink, | |
125 AppendQuadsData* append_quads_data, | |
126 bool for_replica, | |
127 RenderPass::Id render_pass_id); | |
128 | |
129 private: | |
130 LayerImpl* owning_layer_; | |
131 | |
132 // Uses this surface's space. | |
133 gfx::Rect content_rect_; | |
134 bool surface_property_changed_; | |
135 | |
136 float draw_opacity_; | |
137 bool draw_opacity_is_animating_; | |
138 gfx::Transform draw_transform_; | |
139 gfx::Transform screen_space_transform_; | |
140 gfx::Transform replica_draw_transform_; | |
141 gfx::Transform replica_screen_space_transform_; | |
142 bool target_surface_transforms_are_animating_; | |
143 bool screen_space_transforms_are_animating_; | |
144 | |
145 bool is_clipped_; | |
146 | |
147 // Uses the space of the surface's target surface. | |
148 gfx::Rect clip_rect_; | |
149 | |
150 std::vector<LayerImpl*> layer_list_; | |
151 std::vector<DelegatedRendererLayerImpl*> | |
152 contributing_delegated_render_pass_layer_list_; | |
153 | |
154 // The nearest ancestor target surface that will contain the contents of this | |
155 // surface, and that is going to move pixels within the surface (such as with | |
156 // a blur). This can point to itself. | |
157 RenderSurfaceImpl* nearest_ancestor_that_moves_pixels_; | |
158 | |
159 scoped_ptr<DamageTracker> damage_tracker_; | |
160 | |
161 // For LayerIteratorActions | |
162 int target_render_surface_layer_index_history_; | |
163 int current_layer_index_history_; | |
164 | |
165 friend struct LayerIteratorActions; | |
166 | |
167 DISALLOW_COPY_AND_ASSIGN(RenderSurfaceImpl); | |
168 }; | |
169 | |
170 } | |
171 #endif // CC_RENDER_SURFACE_IMPL_H_ | |
OLD | NEW |