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 <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 request.second->SendEmptyResult(); | 221 request.second->SendEmptyResult(); |
222 delete request.second; | 222 delete request.second; |
223 } | 223 } |
224 return; | 224 return; |
225 } | 225 } |
226 | 226 |
227 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 227 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
228 | 228 |
229 bool merge_pass = surface_quad->opacity() == 1.f && copy_requests.empty(); | 229 bool merge_pass = surface_quad->opacity() == 1.f && copy_requests.empty(); |
230 | 230 |
| 231 gfx::Rect surface_damage = DamageRectForSurface( |
| 232 surface, *render_pass_list.back(), surface_quad->visible_rect); |
231 const RenderPassList& referenced_passes = render_pass_list; | 233 const RenderPassList& referenced_passes = render_pass_list; |
232 size_t passes_to_copy = | 234 size_t passes_to_copy = |
233 merge_pass ? referenced_passes.size() - 1 : referenced_passes.size(); | 235 merge_pass ? referenced_passes.size() - 1 : referenced_passes.size(); |
234 for (size_t j = 0; j < passes_to_copy; ++j) { | 236 for (size_t j = 0; j < passes_to_copy; ++j) { |
235 const RenderPass& source = *referenced_passes[j]; | 237 const RenderPass& source = *referenced_passes[j]; |
236 | 238 |
237 size_t sqs_size = source.shared_quad_state_list.size(); | 239 size_t sqs_size = source.shared_quad_state_list.size(); |
238 size_t dq_size = source.quad_list.size(); | 240 size_t dq_size = source.quad_list.size(); |
239 scoped_ptr<RenderPass> copy_pass(RenderPass::Create(sqs_size, dq_size)); | 241 scoped_ptr<RenderPass> copy_pass(RenderPass::Create(sqs_size, dq_size)); |
240 | 242 |
241 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); | 243 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); |
242 | 244 |
243 copy_pass->SetAll(remapped_pass_id, | 245 copy_pass->SetAll(remapped_pass_id, source.output_rect, gfx::Rect(), |
244 source.output_rect, | |
245 source.damage_rect, | |
246 source.transform_to_root_target, | 246 source.transform_to_root_target, |
247 source.has_transparent_background); | 247 source.has_transparent_background); |
248 | 248 |
249 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 249 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
250 | 250 |
251 // Contributing passes aggregated in to the pass list need to take the | 251 // Contributing passes aggregated in to the pass list need to take the |
252 // transform of the surface quad into account to update their transform to | 252 // transform of the surface quad into account to update their transform to |
253 // the root surface. | 253 // the root surface. |
254 copy_pass->transform_to_root_target.ConcatTransform( | 254 copy_pass->transform_to_root_target.ConcatTransform( |
255 surface_quad->quadTransform()); | 255 surface_quad->quadTransform()); |
256 copy_pass->transform_to_root_target.ConcatTransform( | 256 copy_pass->transform_to_root_target.ConcatTransform( |
257 content_to_target_transform); | 257 content_to_target_transform); |
258 copy_pass->transform_to_root_target.ConcatTransform( | 258 copy_pass->transform_to_root_target.ConcatTransform( |
259 dest_pass->transform_to_root_target); | 259 dest_pass->transform_to_root_target); |
260 | 260 |
261 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 261 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
262 gfx::Transform(), ClipData(), copy_pass.get(), surface_id); | 262 gfx::Transform(), ClipData(), copy_pass.get(), surface_id); |
263 | 263 |
| 264 if (j == referenced_passes.size() - 1) |
| 265 surface_damage = gfx::UnionRects(surface_damage, copy_pass->damage_rect); |
| 266 |
264 dest_pass_list_->push_back(copy_pass.Pass()); | 267 dest_pass_list_->push_back(copy_pass.Pass()); |
265 } | 268 } |
266 | 269 |
267 const RenderPass& last_pass = *render_pass_list.back(); | 270 const RenderPass& last_pass = *render_pass_list.back(); |
268 if (merge_pass) { | 271 if (merge_pass) { |
269 // TODO(jamesr): Clean up last pass special casing. | 272 // TODO(jamesr): Clean up last pass special casing. |
270 const QuadList& quads = last_pass.quad_list; | 273 const QuadList& quads = last_pass.quad_list; |
271 | 274 |
272 gfx::Transform surface_transform = surface_quad->quadTransform(); | 275 gfx::Transform surface_transform = surface_quad->quadTransform(); |
273 surface_transform.ConcatTransform(content_to_target_transform); | 276 surface_transform.ConcatTransform(content_to_target_transform); |
(...skipping 28 matching lines...) Expand all Loading... |
302 0, | 305 0, |
303 gfx::Vector2dF(), | 306 gfx::Vector2dF(), |
304 gfx::Size(), | 307 gfx::Size(), |
305 FilterOperations(), | 308 FilterOperations(), |
306 gfx::Vector2dF(), | 309 gfx::Vector2dF(), |
307 FilterOperations()); | 310 FilterOperations()); |
308 } | 311 } |
309 dest_pass->damage_rect = | 312 dest_pass->damage_rect = |
310 gfx::UnionRects(dest_pass->damage_rect, | 313 gfx::UnionRects(dest_pass->damage_rect, |
311 MathUtil::MapEnclosingClippedRect( | 314 MathUtil::MapEnclosingClippedRect( |
312 surface_quad->quadTransform(), | 315 surface_quad->quadTransform(), surface_damage)); |
313 DamageRectForSurface(surface, last_pass, | |
314 surface_quad->visible_rect))); | |
315 | 316 |
316 referenced_surfaces_.erase(it); | 317 referenced_surfaces_.erase(it); |
317 } | 318 } |
318 | 319 |
319 void SurfaceAggregator::CopySharedQuadState( | 320 void SurfaceAggregator::CopySharedQuadState( |
320 const SharedQuadState* source_sqs, | 321 const SharedQuadState* source_sqs, |
321 const gfx::Transform& content_to_target_transform, | 322 const gfx::Transform& content_to_target_transform, |
322 const ClipData& clip_rect, | 323 const ClipData& clip_rect, |
323 RenderPass* dest_render_pass) { | 324 RenderPass* dest_render_pass) { |
324 SharedQuadState* copy_shared_quad_state = | 325 SharedQuadState* copy_shared_quad_state = |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 content_to_target_transform, clip_rect, dest_pass); | 369 content_to_target_transform, clip_rect, dest_pass); |
369 last_copied_source_shared_quad_state = quad->shared_quad_state; | 370 last_copied_source_shared_quad_state = quad->shared_quad_state; |
370 } | 371 } |
371 if (quad->material == DrawQuad::RENDER_PASS) { | 372 if (quad->material == DrawQuad::RENDER_PASS) { |
372 const RenderPassDrawQuad* pass_quad = | 373 const RenderPassDrawQuad* pass_quad = |
373 RenderPassDrawQuad::MaterialCast(quad); | 374 RenderPassDrawQuad::MaterialCast(quad); |
374 RenderPassId original_pass_id = pass_quad->render_pass_id; | 375 RenderPassId original_pass_id = pass_quad->render_pass_id; |
375 RenderPassId remapped_pass_id = | 376 RenderPassId remapped_pass_id = |
376 RemapPassId(original_pass_id, surface_id); | 377 RemapPassId(original_pass_id, surface_id); |
377 | 378 |
378 dest_pass->CopyFromAndAppendRenderPassDrawQuad( | 379 gfx::Rect pass_damage; |
379 pass_quad, | 380 for (const auto* pass : *dest_pass_list_) { |
380 dest_pass->shared_quad_state_list.back(), | 381 if (pass->id == remapped_pass_id) { |
| 382 pass_damage = pass->damage_rect; |
| 383 break; |
| 384 } |
| 385 } |
| 386 |
| 387 DrawQuad* rpdq = dest_pass->CopyFromAndAppendRenderPassDrawQuad( |
| 388 pass_quad, dest_pass->shared_quad_state_list.back(), |
381 remapped_pass_id); | 389 remapped_pass_id); |
| 390 dest_pass->damage_rect = gfx::UnionRects( |
| 391 dest_pass->damage_rect, MathUtil::MapEnclosingClippedRect( |
| 392 rpdq->quadTransform(), pass_damage)); |
382 } else { | 393 } else { |
383 dest_pass->CopyFromAndAppendDrawQuad( | 394 dest_pass->CopyFromAndAppendDrawQuad( |
384 quad, dest_pass->shared_quad_state_list.back()); | 395 quad, dest_pass->shared_quad_state_list.back()); |
385 } | 396 } |
386 } | 397 } |
387 } | 398 } |
388 } | 399 } |
389 | 400 |
390 void SurfaceAggregator::CopyPasses(const DelegatedFrameData* frame_data, | 401 void SurfaceAggregator::CopyPasses(const DelegatedFrameData* frame_data, |
391 Surface* surface) { | 402 Surface* surface) { |
(...skipping 12 matching lines...) Expand all Loading... |
404 | 415 |
405 size_t sqs_size = source.shared_quad_state_list.size(); | 416 size_t sqs_size = source.shared_quad_state_list.size(); |
406 size_t dq_size = source.quad_list.size(); | 417 size_t dq_size = source.quad_list.size(); |
407 scoped_ptr<RenderPass> copy_pass(RenderPass::Create(sqs_size, dq_size)); | 418 scoped_ptr<RenderPass> copy_pass(RenderPass::Create(sqs_size, dq_size)); |
408 | 419 |
409 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 420 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
410 | 421 |
411 RenderPassId remapped_pass_id = | 422 RenderPassId remapped_pass_id = |
412 RemapPassId(source.id, surface->surface_id()); | 423 RemapPassId(source.id, surface->surface_id()); |
413 | 424 |
414 copy_pass->SetAll(remapped_pass_id, source.output_rect, | 425 gfx::Rect damage_rect = |
415 DamageRectForSurface(surface, source, source.output_rect), | 426 (i < source_pass_list.size() - 1) |
| 427 ? gfx::Rect() |
| 428 : DamageRectForSurface(surface, source, source.output_rect); |
| 429 copy_pass->SetAll(remapped_pass_id, source.output_rect, damage_rect, |
416 source.transform_to_root_target, | 430 source.transform_to_root_target, |
417 source.has_transparent_background); | 431 source.has_transparent_background); |
418 | 432 |
419 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 433 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
420 gfx::Transform(), ClipData(), copy_pass.get(), | 434 gfx::Transform(), ClipData(), copy_pass.get(), |
421 surface->surface_id()); | 435 surface->surface_id()); |
422 | 436 |
423 dest_pass_list_->push_back(copy_pass.Pass()); | 437 dest_pass_list_->push_back(copy_pass.Pass()); |
424 } | 438 } |
425 } | 439 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 void SurfaceAggregator::ReleaseResources(SurfaceId surface_id) { | 504 void SurfaceAggregator::ReleaseResources(SurfaceId surface_id) { |
491 SurfaceToResourceChildIdMap::iterator it = | 505 SurfaceToResourceChildIdMap::iterator it = |
492 surface_id_to_resource_child_id_.find(surface_id); | 506 surface_id_to_resource_child_id_.find(surface_id); |
493 if (it != surface_id_to_resource_child_id_.end()) { | 507 if (it != surface_id_to_resource_child_id_.end()) { |
494 provider_->DestroyChild(it->second); | 508 provider_->DestroyChild(it->second); |
495 surface_id_to_resource_child_id_.erase(it); | 509 surface_id_to_resource_child_id_.erase(it); |
496 } | 510 } |
497 } | 511 } |
498 | 512 |
499 } // namespace cc | 513 } // namespace cc |
OLD | NEW |