OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/render_surface_impl.h" | 5 #include "cc/layers/render_surface_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "cc/base/math_util.h" | 11 #include "cc/base/math_util.h" |
12 #include "cc/debug/debug_colors.h" | 12 #include "cc/debug/debug_colors.h" |
13 #include "cc/layers/delegated_renderer_layer_impl.h" | 13 #include "cc/layers/delegated_renderer_layer_impl.h" |
14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
15 #include "cc/layers/quad_sink.h" | |
16 #include "cc/layers/render_pass_sink.h" | 15 #include "cc/layers/render_pass_sink.h" |
17 #include "cc/quads/debug_border_draw_quad.h" | 16 #include "cc/quads/debug_border_draw_quad.h" |
18 #include "cc/quads/render_pass.h" | 17 #include "cc/quads/render_pass.h" |
19 #include "cc/quads/render_pass_draw_quad.h" | 18 #include "cc/quads/render_pass_draw_quad.h" |
20 #include "cc/quads/shared_quad_state.h" | 19 #include "cc/quads/shared_quad_state.h" |
21 #include "cc/trees/damage_tracker.h" | 20 #include "cc/trees/damage_tracker.h" |
| 21 #include "cc/trees/occlusion_tracker.h" |
22 #include "third_party/skia/include/core/SkImageFilter.h" | 22 #include "third_party/skia/include/core/SkImageFilter.h" |
23 #include "ui/gfx/rect_conversions.h" | 23 #include "ui/gfx/rect_conversions.h" |
24 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 | 27 |
28 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) | 28 RenderSurfaceImpl::RenderSurfaceImpl(LayerImpl* owning_layer) |
29 : owning_layer_(owning_layer), | 29 : owning_layer_(owning_layer), |
30 surface_property_changed_(false), | 30 surface_property_changed_(false), |
31 draw_opacity_is_animating_(false), | 31 draw_opacity_is_animating_(false), |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 129 |
130 scoped_ptr<RenderPass> pass = RenderPass::Create(layer_list_.size()); | 130 scoped_ptr<RenderPass> pass = RenderPass::Create(layer_list_.size()); |
131 pass->SetNew(RenderPassId(), | 131 pass->SetNew(RenderPassId(), |
132 content_rect_, | 132 content_rect_, |
133 gfx::IntersectRects(content_rect_, | 133 gfx::IntersectRects(content_rect_, |
134 damage_tracker_->current_damage_rect()), | 134 damage_tracker_->current_damage_rect()), |
135 screen_space_transform_); | 135 screen_space_transform_); |
136 pass_sink->AppendRenderPass(pass.Pass()); | 136 pass_sink->AppendRenderPass(pass.Pass()); |
137 } | 137 } |
138 | 138 |
139 void RenderSurfaceImpl::AppendQuads(QuadSink* quad_sink, | 139 void RenderSurfaceImpl::AppendQuads( |
140 AppendQuadsData* append_quads_data, | 140 RenderPass* render_pass, |
141 bool for_replica, | 141 const OcclusionTracker<LayerImpl>& occlusion_tracker, |
142 RenderPass::Id render_pass_id) { | 142 AppendQuadsData* append_quads_data, |
| 143 bool for_replica, |
| 144 RenderPass::Id render_pass_id) { |
143 DCHECK(!for_replica || owning_layer_->has_replica()); | 145 DCHECK(!for_replica || owning_layer_->has_replica()); |
144 | 146 |
145 const gfx::Transform& draw_transform = | 147 const gfx::Transform& draw_transform = |
146 for_replica ? replica_draw_transform_ : draw_transform_; | 148 for_replica ? replica_draw_transform_ : draw_transform_; |
147 gfx::Rect visible_content_rect = | 149 gfx::Rect visible_content_rect = |
148 quad_sink->UnoccludedContributingSurfaceContentRect(content_rect_, | 150 occlusion_tracker.UnoccludedContributingSurfaceContentRect( |
149 draw_transform); | 151 content_rect_, draw_transform); |
150 if (visible_content_rect.IsEmpty()) | 152 if (visible_content_rect.IsEmpty()) |
151 return; | 153 return; |
152 | 154 |
153 SharedQuadState* shared_quad_state = quad_sink->CreateSharedQuadState(); | 155 SharedQuadState* shared_quad_state = |
| 156 render_pass->CreateAndAppendSharedQuadState(); |
154 shared_quad_state->SetAll(draw_transform, | 157 shared_quad_state->SetAll(draw_transform, |
155 content_rect_.size(), | 158 content_rect_.size(), |
156 content_rect_, | 159 content_rect_, |
157 clip_rect_, | 160 clip_rect_, |
158 is_clipped_, | 161 is_clipped_, |
159 draw_opacity_, | 162 draw_opacity_, |
160 owning_layer_->blend_mode(), | 163 owning_layer_->blend_mode(), |
161 owning_layer_->sorting_context_id()); | 164 owning_layer_->sorting_context_id()); |
162 | 165 |
163 if (owning_layer_->ShowDebugBorders()) { | 166 if (owning_layer_->ShowDebugBorders()) { |
164 SkColor color = for_replica ? | 167 SkColor color = for_replica ? |
165 DebugColors::SurfaceReplicaBorderColor() : | 168 DebugColors::SurfaceReplicaBorderColor() : |
166 DebugColors::SurfaceBorderColor(); | 169 DebugColors::SurfaceBorderColor(); |
167 float width = for_replica ? | 170 float width = for_replica ? |
168 DebugColors::SurfaceReplicaBorderWidth( | 171 DebugColors::SurfaceReplicaBorderWidth( |
169 owning_layer_->layer_tree_impl()) : | 172 owning_layer_->layer_tree_impl()) : |
170 DebugColors::SurfaceBorderWidth( | 173 DebugColors::SurfaceBorderWidth( |
171 owning_layer_->layer_tree_impl()); | 174 owning_layer_->layer_tree_impl()); |
172 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = | 175 scoped_ptr<DebugBorderDrawQuad> debug_border_quad = |
173 DebugBorderDrawQuad::Create(); | 176 DebugBorderDrawQuad::Create(); |
174 debug_border_quad->SetNew( | 177 debug_border_quad->SetNew( |
175 shared_quad_state, content_rect_, visible_content_rect, color, width); | 178 shared_quad_state, content_rect_, visible_content_rect, color, width); |
176 quad_sink->Append(debug_border_quad.PassAs<DrawQuad>()); | 179 render_pass->AppendDrawQuad(debug_border_quad.PassAs<DrawQuad>()); |
177 } | 180 } |
178 | 181 |
179 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content | 182 // TODO(shawnsingh): By using the same RenderSurfaceImpl for both the content |
180 // and its reflection, it's currently not possible to apply a separate mask to | 183 // and its reflection, it's currently not possible to apply a separate mask to |
181 // the reflection layer or correctly handle opacity in reflections (opacity | 184 // the reflection layer or correctly handle opacity in reflections (opacity |
182 // must be applied after drawing both the layer and its reflection). The | 185 // must be applied after drawing both the layer and its reflection). The |
183 // solution is to introduce yet another RenderSurfaceImpl to draw the layer | 186 // solution is to introduce yet another RenderSurfaceImpl to draw the layer |
184 // and its reflection in. For now we only apply a separate reflection mask if | 187 // and its reflection in. For now we only apply a separate reflection mask if |
185 // the contents don't have a mask of their own. | 188 // the contents don't have a mask of their own. |
186 LayerImpl* mask_layer = owning_layer_->mask_layer(); | 189 LayerImpl* mask_layer = owning_layer_->mask_layer(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 quad->SetNew(shared_quad_state, | 229 quad->SetNew(shared_quad_state, |
227 content_rect_, | 230 content_rect_, |
228 visible_content_rect, | 231 visible_content_rect, |
229 render_pass_id, | 232 render_pass_id, |
230 for_replica, | 233 for_replica, |
231 mask_resource_id, | 234 mask_resource_id, |
232 contents_changed_since_last_frame, | 235 contents_changed_since_last_frame, |
233 mask_uv_rect, | 236 mask_uv_rect, |
234 owning_layer_->filters(), | 237 owning_layer_->filters(), |
235 owning_layer_->background_filters()); | 238 owning_layer_->background_filters()); |
236 quad_sink->Append(quad.PassAs<DrawQuad>()); | 239 render_pass->AppendDrawQuad(quad.PassAs<DrawQuad>()); |
237 } | 240 } |
238 | 241 |
239 } // namespace cc | 242 } // namespace cc |
OLD | NEW |