OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surfaces/surface_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (!frame_data) | 169 if (!frame_data) |
170 return; | 170 return; |
171 | 171 |
172 RenderPassList render_pass_list; | 172 RenderPassList render_pass_list; |
173 bool invalid_frame = TakeResources(surface, frame_data, &render_pass_list); | 173 bool invalid_frame = TakeResources(surface, frame_data, &render_pass_list); |
174 if (invalid_frame) | 174 if (invalid_frame) |
175 return; | 175 return; |
176 | 176 |
177 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 177 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
178 | 178 |
| 179 ScopedPtrVector<CopyOutputRequest> copy_requests; |
| 180 surface->TakeCopyOutputRequests(©_requests); |
| 181 |
| 182 bool merge_pass = copy_requests.empty(); |
| 183 |
179 const RenderPassList& referenced_passes = render_pass_list; | 184 const RenderPassList& referenced_passes = render_pass_list; |
180 for (size_t j = 0; j + 1 < referenced_passes.size(); ++j) { | 185 size_t passes_to_copy = |
| 186 merge_pass ? referenced_passes.size() - 1 : referenced_passes.size(); |
| 187 for (size_t j = 0; j < passes_to_copy; ++j) { |
181 const RenderPass& source = *referenced_passes[j]; | 188 const RenderPass& source = *referenced_passes[j]; |
182 | 189 |
183 scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); | 190 scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); |
184 | 191 |
185 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); | 192 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); |
186 | 193 |
187 copy_pass->SetAll(remapped_pass_id, | 194 copy_pass->SetAll(remapped_pass_id, |
188 source.output_rect, | 195 source.output_rect, |
189 source.damage_rect, | 196 source.damage_rect, |
190 source.transform_to_root_target, | 197 source.transform_to_root_target, |
191 source.has_transparent_background); | 198 source.has_transparent_background); |
192 | 199 |
193 // Contributing passes aggregated in to the pass list need to take the | 200 // Contributing passes aggregated in to the pass list need to take the |
194 // transform of the surface quad into account to update their transform to | 201 // transform of the surface quad into account to update their transform to |
195 // the root surface. | 202 // the root surface. |
196 // TODO(jamesr): Make sure this is sufficient for surfaces nested several | 203 // TODO(jamesr): Make sure this is sufficient for surfaces nested several |
197 // levels deep and add tests. | 204 // levels deep and add tests. |
198 copy_pass->transform_to_root_target.ConcatTransform( | 205 copy_pass->transform_to_root_target.ConcatTransform( |
199 surface_quad->quadTransform()); | 206 surface_quad->quadTransform()); |
200 | 207 |
201 CopyQuadsToPass(source.quad_list, | 208 CopyQuadsToPass(source.quad_list, |
202 source.shared_quad_state_list, | 209 source.shared_quad_state_list, |
203 gfx::Transform(), | 210 gfx::Transform(), |
204 copy_pass.get(), | 211 copy_pass.get(), |
205 surface_id); | 212 surface_id); |
206 | 213 |
207 dest_pass_list_->push_back(copy_pass.Pass()); | 214 dest_pass_list_->push_back(copy_pass.Pass()); |
208 } | 215 } |
209 | 216 |
210 // TODO(jamesr): Clean up last pass special casing. | |
211 const RenderPass& last_pass = *render_pass_list.back(); | 217 const RenderPass& last_pass = *render_pass_list.back(); |
212 const QuadList& quads = last_pass.quad_list; | 218 if (merge_pass) { |
| 219 // TODO(jamesr): Clean up last pass special casing. |
| 220 const QuadList& quads = last_pass.quad_list; |
213 | 221 |
214 // TODO(jamesr): Make sure clipping is enforced. | 222 // TODO(jamesr): Make sure clipping is enforced. |
215 CopyQuadsToPass(quads, | 223 CopyQuadsToPass(quads, |
216 last_pass.shared_quad_state_list, | 224 last_pass.shared_quad_state_list, |
217 surface_quad->quadTransform(), | 225 surface_quad->quadTransform(), |
218 dest_pass, | 226 dest_pass, |
219 surface_id); | 227 surface_id); |
| 228 } else { |
| 229 RenderPassId remapped_pass_id = RemapPassId(last_pass.id, surface_id); |
| 230 |
| 231 dest_pass_list_->back()->copy_requests.swap(copy_requests); |
| 232 |
| 233 SharedQuadState* shared_quad_state = |
| 234 dest_pass->CreateAndAppendSharedQuadState(); |
| 235 shared_quad_state->CopyFrom(surface_quad->shared_quad_state); |
| 236 scoped_ptr<RenderPassDrawQuad> quad(new RenderPassDrawQuad); |
| 237 quad->SetNew(shared_quad_state, |
| 238 surface_quad->rect, |
| 239 surface_quad->visible_rect, |
| 240 remapped_pass_id, |
| 241 0, |
| 242 gfx::RectF(), |
| 243 FilterOperations(), |
| 244 gfx::Vector2dF(), |
| 245 FilterOperations()); |
| 246 dest_pass->quad_list.push_back(quad.PassAs<DrawQuad>()); |
| 247 } |
220 dest_pass->damage_rect = | 248 dest_pass->damage_rect = |
221 gfx::UnionRects(dest_pass->damage_rect, | 249 gfx::UnionRects(dest_pass->damage_rect, |
222 MathUtil::MapEnclosingClippedRect( | 250 MathUtil::MapEnclosingClippedRect( |
223 surface_quad->quadTransform(), | 251 surface_quad->quadTransform(), |
224 DamageRectForSurface(surface, last_pass))); | 252 DamageRectForSurface(surface, last_pass))); |
225 | 253 |
226 referenced_surfaces_.erase(it); | 254 referenced_surfaces_.erase(it); |
227 } | 255 } |
228 | 256 |
229 void SurfaceAggregator::CopySharedQuadState( | 257 void SurfaceAggregator::CopySharedQuadState( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 surface->TakeLatencyInfo(&frame->metadata.latency_info); | 389 surface->TakeLatencyInfo(&frame->metadata.latency_info); |
362 } | 390 } |
363 | 391 |
364 // TODO(jamesr): Aggregate all resource references into the returned frame's | 392 // TODO(jamesr): Aggregate all resource references into the returned frame's |
365 // resource list. | 393 // resource list. |
366 | 394 |
367 return frame.Pass(); | 395 return frame.Pass(); |
368 } | 396 } |
369 | 397 |
370 } // namespace cc | 398 } // namespace cc |
OLD | NEW |