| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 copy_pass->SetAll(remapped_pass_id, source.output_rect, gfx::Rect(), | 252 copy_pass->SetAll(remapped_pass_id, source.output_rect, gfx::Rect(), |
| 253 source.transform_to_root_target, | 253 source.transform_to_root_target, |
| 254 source.has_transparent_background); | 254 source.has_transparent_background); |
| 255 | 255 |
| 256 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 256 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
| 257 | 257 |
| 258 // Contributing passes aggregated in to the pass list need to take the | 258 // Contributing passes aggregated in to the pass list need to take the |
| 259 // transform of the surface quad into account to update their transform to | 259 // transform of the surface quad into account to update their transform to |
| 260 // the root surface. | 260 // the root surface. |
| 261 copy_pass->transform_to_root_target.ConcatTransform( | 261 copy_pass->transform_to_root_target.ConcatTransform( |
| 262 surface_quad->shared_quad_state->content_to_target_transform); | 262 surface_quad->shared_quad_state->quad_to_target_transform); |
| 263 copy_pass->transform_to_root_target.ConcatTransform(target_transform); | 263 copy_pass->transform_to_root_target.ConcatTransform(target_transform); |
| 264 copy_pass->transform_to_root_target.ConcatTransform( | 264 copy_pass->transform_to_root_target.ConcatTransform( |
| 265 dest_pass->transform_to_root_target); | 265 dest_pass->transform_to_root_target); |
| 266 | 266 |
| 267 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 267 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
| 268 child_to_parent_map, gfx::Transform(), ClipData(), | 268 child_to_parent_map, gfx::Transform(), ClipData(), |
| 269 copy_pass.get(), surface_id); | 269 copy_pass.get(), surface_id); |
| 270 | 270 |
| 271 if (j == referenced_passes.size() - 1) | 271 if (j == referenced_passes.size() - 1) |
| 272 surface_damage = gfx::UnionRects(surface_damage, copy_pass->damage_rect); | 272 surface_damage = gfx::UnionRects(surface_damage, copy_pass->damage_rect); |
| 273 | 273 |
| 274 dest_pass_list_->push_back(copy_pass.Pass()); | 274 dest_pass_list_->push_back(copy_pass.Pass()); |
| 275 } | 275 } |
| 276 | 276 |
| 277 const RenderPass& last_pass = *render_pass_list.back(); | 277 const RenderPass& last_pass = *render_pass_list.back(); |
| 278 if (merge_pass) { | 278 if (merge_pass) { |
| 279 // TODO(jamesr): Clean up last pass special casing. | 279 // TODO(jamesr): Clean up last pass special casing. |
| 280 const QuadList& quads = last_pass.quad_list; | 280 const QuadList& quads = last_pass.quad_list; |
| 281 | 281 |
| 282 gfx::Transform surface_transform = | 282 gfx::Transform surface_transform = |
| 283 surface_quad->shared_quad_state->content_to_target_transform; | 283 surface_quad->shared_quad_state->quad_to_target_transform; |
| 284 surface_transform.ConcatTransform(target_transform); | 284 surface_transform.ConcatTransform(target_transform); |
| 285 | 285 |
| 286 // Intersect the transformed visible rect and the clip rect to create a | 286 // Intersect the transformed visible rect and the clip rect to create a |
| 287 // smaller cliprect for the quad. | 287 // smaller cliprect for the quad. |
| 288 ClipData surface_quad_clip_rect( | 288 ClipData surface_quad_clip_rect( |
| 289 true, MathUtil::MapEnclosingClippedRect( | 289 true, MathUtil::MapEnclosingClippedRect( |
| 290 surface_quad->shared_quad_state->content_to_target_transform, | 290 surface_quad->shared_quad_state->quad_to_target_transform, |
| 291 surface_quad->visible_rect)); | 291 surface_quad->visible_rect)); |
| 292 if (surface_quad->shared_quad_state->is_clipped) { | 292 if (surface_quad->shared_quad_state->is_clipped) { |
| 293 surface_quad_clip_rect.rect.Intersect( | 293 surface_quad_clip_rect.rect.Intersect( |
| 294 surface_quad->shared_quad_state->clip_rect); | 294 surface_quad->shared_quad_state->clip_rect); |
| 295 } | 295 } |
| 296 | 296 |
| 297 ClipData quads_clip = | 297 ClipData quads_clip = |
| 298 CalculateClipRect(clip_rect, surface_quad_clip_rect, target_transform); | 298 CalculateClipRect(clip_rect, surface_quad_clip_rect, target_transform); |
| 299 | 299 |
| 300 CopyQuadsToPass(quads, last_pass.shared_quad_state_list, | 300 CopyQuadsToPass(quads, last_pass.shared_quad_state_list, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 317 0, | 317 0, |
| 318 gfx::Vector2dF(), | 318 gfx::Vector2dF(), |
| 319 gfx::Size(), | 319 gfx::Size(), |
| 320 FilterOperations(), | 320 FilterOperations(), |
| 321 gfx::Vector2dF(), | 321 gfx::Vector2dF(), |
| 322 FilterOperations()); | 322 FilterOperations()); |
| 323 } | 323 } |
| 324 dest_pass->damage_rect = gfx::UnionRects( | 324 dest_pass->damage_rect = gfx::UnionRects( |
| 325 dest_pass->damage_rect, | 325 dest_pass->damage_rect, |
| 326 MathUtil::MapEnclosingClippedRect( | 326 MathUtil::MapEnclosingClippedRect( |
| 327 surface_quad->shared_quad_state->content_to_target_transform, | 327 surface_quad->shared_quad_state->quad_to_target_transform, |
| 328 surface_damage)); | 328 surface_damage)); |
| 329 | 329 |
| 330 referenced_surfaces_.erase(it); | 330 referenced_surfaces_.erase(it); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void SurfaceAggregator::CopySharedQuadState( | 333 void SurfaceAggregator::CopySharedQuadState( |
| 334 const SharedQuadState* source_sqs, | 334 const SharedQuadState* source_sqs, |
| 335 const gfx::Transform& target_transform, | 335 const gfx::Transform& target_transform, |
| 336 const ClipData& clip_rect, | 336 const ClipData& clip_rect, |
| 337 RenderPass* dest_render_pass) { | 337 RenderPass* dest_render_pass) { |
| 338 SharedQuadState* copy_shared_quad_state = | 338 SharedQuadState* copy_shared_quad_state = |
| 339 dest_render_pass->CreateAndAppendSharedQuadState(); | 339 dest_render_pass->CreateAndAppendSharedQuadState(); |
| 340 copy_shared_quad_state->CopyFrom(source_sqs); | 340 copy_shared_quad_state->CopyFrom(source_sqs); |
| 341 // target_transform contains any transformation that may exist | 341 // target_transform contains any transformation that may exist |
| 342 // between the context that these quads are being copied from (i.e. the | 342 // between the context that these quads are being copied from (i.e. the |
| 343 // surface's draw transform when aggregated from within a surface) to the | 343 // surface's draw transform when aggregated from within a surface) to the |
| 344 // target space of the pass. This will be identity except when copying the | 344 // target space of the pass. This will be identity except when copying the |
| 345 // root draw pass from a surface into a pass when the surface draw quad's | 345 // root draw pass from a surface into a pass when the surface draw quad's |
| 346 // transform is not identity. | 346 // transform is not identity. |
| 347 copy_shared_quad_state->content_to_target_transform.ConcatTransform( | 347 copy_shared_quad_state->quad_to_target_transform.ConcatTransform( |
| 348 target_transform); | 348 target_transform); |
| 349 | 349 |
| 350 ClipData new_clip_rect = CalculateClipRect( | 350 ClipData new_clip_rect = CalculateClipRect( |
| 351 clip_rect, ClipData(source_sqs->is_clipped, source_sqs->clip_rect), | 351 clip_rect, ClipData(source_sqs->is_clipped, source_sqs->clip_rect), |
| 352 target_transform); | 352 target_transform); |
| 353 copy_shared_quad_state->is_clipped = new_clip_rect.is_clipped; | 353 copy_shared_quad_state->is_clipped = new_clip_rect.is_clipped; |
| 354 copy_shared_quad_state->clip_rect = new_clip_rect.rect; | 354 copy_shared_quad_state->clip_rect = new_clip_rect.rect; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void SurfaceAggregator::CopyQuadsToPass( | 357 void SurfaceAggregator::CopyQuadsToPass( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 break; | 397 break; |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 dest_quad = dest_pass->CopyFromAndAppendRenderPassDrawQuad( | 401 dest_quad = dest_pass->CopyFromAndAppendRenderPassDrawQuad( |
| 402 pass_quad, dest_pass->shared_quad_state_list.back(), | 402 pass_quad, dest_pass->shared_quad_state_list.back(), |
| 403 remapped_pass_id); | 403 remapped_pass_id); |
| 404 dest_pass->damage_rect = gfx::UnionRects( | 404 dest_pass->damage_rect = gfx::UnionRects( |
| 405 dest_pass->damage_rect, | 405 dest_pass->damage_rect, |
| 406 MathUtil::MapEnclosingClippedRect( | 406 MathUtil::MapEnclosingClippedRect( |
| 407 dest_quad->shared_quad_state->content_to_target_transform, | 407 dest_quad->shared_quad_state->quad_to_target_transform, |
| 408 pass_damage)); | 408 pass_damage)); |
| 409 } else { | 409 } else { |
| 410 dest_quad = dest_pass->CopyFromAndAppendDrawQuad( | 410 dest_quad = dest_pass->CopyFromAndAppendDrawQuad( |
| 411 quad, dest_pass->shared_quad_state_list.back()); | 411 quad, dest_pass->shared_quad_state_list.back()); |
| 412 } | 412 } |
| 413 if (!child_to_parent_map.empty()) { | 413 if (!child_to_parent_map.empty()) { |
| 414 for (ResourceId& resource_id : dest_quad->resources) { | 414 for (ResourceId& resource_id : dest_quad->resources) { |
| 415 ResourceProvider::ResourceIdMap::const_iterator it = | 415 ResourceProvider::ResourceIdMap::const_iterator it = |
| 416 child_to_parent_map.find(resource_id); | 416 child_to_parent_map.find(resource_id); |
| 417 DCHECK(it != child_to_parent_map.end()); | 417 DCHECK(it != child_to_parent_map.end()); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 546 |
| 547 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { | 547 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { |
| 548 auto it = previous_contained_surfaces_.find(surface_id); | 548 auto it = previous_contained_surfaces_.find(surface_id); |
| 549 if (it == previous_contained_surfaces_.end()) | 549 if (it == previous_contained_surfaces_.end()) |
| 550 return; | 550 return; |
| 551 // Set the last drawn index as 0 to ensure full damage next time it's drawn. | 551 // Set the last drawn index as 0 to ensure full damage next time it's drawn. |
| 552 it->second = 0; | 552 it->second = 0; |
| 553 } | 553 } |
| 554 | 554 |
| 555 } // namespace cc | 555 } // namespace cc |
| OLD | NEW |