| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 size_t sqs_size = source.shared_quad_state_list.size(); | 242 size_t sqs_size = source.shared_quad_state_list.size(); |
| 243 size_t dq_size = source.quad_list.size(); | 243 size_t dq_size = source.quad_list.size(); |
| 244 std::unique_ptr<RenderPass> copy_pass( | 244 std::unique_ptr<RenderPass> copy_pass( |
| 245 RenderPass::Create(sqs_size, dq_size)); | 245 RenderPass::Create(sqs_size, dq_size)); |
| 246 | 246 |
| 247 int remapped_pass_id = RemapPassId(source.id, surface_id); | 247 int remapped_pass_id = RemapPassId(source.id, surface_id); |
| 248 | 248 |
| 249 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, | 249 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, |
| 250 source.transform_to_root_target, source.filters, | 250 source.transform_to_root_target, source.filters, |
| 251 source.background_filters, output_color_space_, | 251 source.background_filters, blending_color_space_, |
| 252 source.has_transparent_background); | 252 source.has_transparent_background); |
| 253 | 253 |
| 254 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 254 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
| 255 | 255 |
| 256 // Contributing passes aggregated in to the pass list need to take the | 256 // Contributing passes aggregated in to the pass list need to take the |
| 257 // transform of the surface quad into account to update their transform to | 257 // transform of the surface quad into account to update their transform to |
| 258 // the root surface. | 258 // the root surface. |
| 259 copy_pass->transform_to_root_target.ConcatTransform( | 259 copy_pass->transform_to_root_target.ConcatTransform( |
| 260 surface_quad->shared_quad_state->quad_to_target_transform); | 260 surface_quad->shared_quad_state->quad_to_target_transform); |
| 261 copy_pass->transform_to_root_target.ConcatTransform(target_transform); | 261 copy_pass->transform_to_root_target.ConcatTransform(target_transform); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 RenderPassDrawQuad* quad = | 316 RenderPassDrawQuad* quad = |
| 317 dest_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); | 317 dest_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 318 quad->SetNew(shared_quad_state, surface_quad->rect, | 318 quad->SetNew(shared_quad_state, surface_quad->rect, |
| 319 surface_quad->visible_rect, remapped_pass_id, 0, gfx::RectF(), | 319 surface_quad->visible_rect, remapped_pass_id, 0, gfx::RectF(), |
| 320 gfx::Size(), gfx::Vector2dF(), gfx::PointF(), gfx::RectF()); | 320 gfx::Size(), gfx::Vector2dF(), gfx::PointF(), gfx::RectF()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 referenced_surfaces_.erase(it); | 323 referenced_surfaces_.erase(it); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void SurfaceAggregator::AddColorConversionPass() { |
| 327 if (dest_pass_list_->empty()) |
| 328 return; |
| 329 |
| 330 RenderPass* root_render_pass = dest_pass_list_->back().get(); |
| 331 if (root_render_pass->color_space == output_color_space_) |
| 332 return; |
| 333 |
| 334 gfx::Rect output_rect = root_render_pass->output_rect; |
| 335 CHECK(root_render_pass->transform_to_root_target == gfx::Transform()); |
| 336 |
| 337 if (!color_conversion_render_pass_id_) |
| 338 color_conversion_render_pass_id_ = next_render_pass_id_++; |
| 339 |
| 340 std::unique_ptr<RenderPass> color_conversion_pass(RenderPass::Create(1, 1)); |
| 341 color_conversion_pass->SetNew(color_conversion_render_pass_id_, output_rect, |
| 342 root_render_pass->damage_rect, |
| 343 root_render_pass->transform_to_root_target); |
| 344 color_conversion_pass->color_space = output_color_space_; |
| 345 |
| 346 SharedQuadState* shared_quad_state = |
| 347 color_conversion_pass->CreateAndAppendSharedQuadState(); |
| 348 shared_quad_state->quad_layer_bounds = output_rect.size(); |
| 349 shared_quad_state->visible_quad_layer_rect = output_rect; |
| 350 shared_quad_state->opacity = 1.f; |
| 351 |
| 352 RenderPassDrawQuad* quad = |
| 353 color_conversion_pass->CreateAndAppendDrawQuad<RenderPassDrawQuad>(); |
| 354 quad->SetNew(shared_quad_state, output_rect, output_rect, |
| 355 root_render_pass->id, 0, gfx::RectF(), gfx::Size(), |
| 356 gfx::Vector2dF(), gfx::PointF(), gfx::RectF()); |
| 357 dest_pass_list_->push_back(std::move(color_conversion_pass)); |
| 358 } |
| 359 |
| 326 SharedQuadState* SurfaceAggregator::CopySharedQuadState( | 360 SharedQuadState* SurfaceAggregator::CopySharedQuadState( |
| 327 const SharedQuadState* source_sqs, | 361 const SharedQuadState* source_sqs, |
| 328 const gfx::Transform& target_transform, | 362 const gfx::Transform& target_transform, |
| 329 const ClipData& clip_rect, | 363 const ClipData& clip_rect, |
| 330 RenderPass* dest_render_pass) { | 364 RenderPass* dest_render_pass) { |
| 331 SharedQuadState* copy_shared_quad_state = | 365 SharedQuadState* copy_shared_quad_state = |
| 332 dest_render_pass->CreateAndAppendSharedQuadState(); | 366 dest_render_pass->CreateAndAppendSharedQuadState(); |
| 333 *copy_shared_quad_state = *source_sqs; | 367 *copy_shared_quad_state = *source_sqs; |
| 334 // target_transform contains any transformation that may exist | 368 // target_transform contains any transformation that may exist |
| 335 // between the context that these quads are being copied from (i.e. the | 369 // between the context that these quads are being copied from (i.e. the |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 size_t dq_size = source.quad_list.size(); | 519 size_t dq_size = source.quad_list.size(); |
| 486 std::unique_ptr<RenderPass> copy_pass( | 520 std::unique_ptr<RenderPass> copy_pass( |
| 487 RenderPass::Create(sqs_size, dq_size)); | 521 RenderPass::Create(sqs_size, dq_size)); |
| 488 | 522 |
| 489 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); | 523 MoveMatchingRequests(source.id, ©_requests, ©_pass->copy_requests); |
| 490 | 524 |
| 491 int remapped_pass_id = RemapPassId(source.id, surface->surface_id()); | 525 int remapped_pass_id = RemapPassId(source.id, surface->surface_id()); |
| 492 | 526 |
| 493 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, | 527 copy_pass->SetAll(remapped_pass_id, source.output_rect, source.output_rect, |
| 494 source.transform_to_root_target, source.filters, | 528 source.transform_to_root_target, source.filters, |
| 495 source.background_filters, output_color_space_, | 529 source.background_filters, blending_color_space_, |
| 496 source.has_transparent_background); | 530 source.has_transparent_background); |
| 497 | 531 |
| 498 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, | 532 CopyQuadsToPass(source.quad_list, source.shared_quad_state_list, |
| 499 child_to_parent_map, gfx::Transform(), ClipData(), | 533 child_to_parent_map, gfx::Transform(), ClipData(), |
| 500 copy_pass.get(), surface->surface_id()); | 534 copy_pass.get(), surface->surface_id()); |
| 501 if (!copy_request_passes_.count(remapped_pass_id) && | 535 if (!copy_request_passes_.count(remapped_pass_id) && |
| 502 !moved_pixel_passes_.count(remapped_pass_id)) { | 536 !moved_pixel_passes_.count(remapped_pass_id)) { |
| 503 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); | 537 gfx::Transform inverse_transform(gfx::Transform::kSkipInitialization); |
| 504 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { | 538 if (copy_pass->transform_to_root_target.GetInverse(&inverse_transform)) { |
| 505 gfx::Rect damage_rect_in_render_pass_space = | 539 gfx::Rect damage_rect_in_render_pass_space = |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 PrewalkResult prewalk_result; | 835 PrewalkResult prewalk_result; |
| 802 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result); | 836 root_damage_rect_ = PrewalkTree(surface_id, false, 0, &prewalk_result); |
| 803 PropagateCopyRequestPasses(); | 837 PropagateCopyRequestPasses(); |
| 804 has_copy_requests_ = !copy_request_passes_.empty(); | 838 has_copy_requests_ = !copy_request_passes_.empty(); |
| 805 frame.metadata.may_contain_video = prewalk_result.may_contain_video; | 839 frame.metadata.may_contain_video = prewalk_result.may_contain_video; |
| 806 | 840 |
| 807 CopyUndrawnSurfaces(&prewalk_result); | 841 CopyUndrawnSurfaces(&prewalk_result); |
| 808 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 842 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
| 809 CopyPasses(root_surface_frame, surface); | 843 CopyPasses(root_surface_frame, surface); |
| 810 referenced_surfaces_.erase(it); | 844 referenced_surfaces_.erase(it); |
| 845 AddColorConversionPass(); |
| 811 | 846 |
| 812 moved_pixel_passes_.clear(); | 847 moved_pixel_passes_.clear(); |
| 813 copy_request_passes_.clear(); | 848 copy_request_passes_.clear(); |
| 814 render_pass_dependencies_.clear(); | 849 render_pass_dependencies_.clear(); |
| 815 | 850 |
| 816 // Remove all render pass mappings that weren't used in the current frame. | 851 // Remove all render pass mappings that weren't used in the current frame. |
| 817 for (auto it = render_pass_allocator_map_.begin(); | 852 for (auto it = render_pass_allocator_map_.begin(); |
| 818 it != render_pass_allocator_map_.end();) { | 853 it != render_pass_allocator_map_.end();) { |
| 819 if (it->second.in_use) { | 854 if (it->second.in_use) { |
| 820 it->second.in_use = false; | 855 it->second.in_use = false; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 | 894 |
| 860 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { | 895 void SurfaceAggregator::SetFullDamageForSurface(const SurfaceId& surface_id) { |
| 861 auto it = previous_contained_surfaces_.find(surface_id); | 896 auto it = previous_contained_surfaces_.find(surface_id); |
| 862 if (it == previous_contained_surfaces_.end()) | 897 if (it == previous_contained_surfaces_.end()) |
| 863 return; | 898 return; |
| 864 // Set the last drawn index as 0 to ensure full damage next time it's drawn. | 899 // Set the last drawn index as 0 to ensure full damage next time it's drawn. |
| 865 it->second = 0; | 900 it->second = 0; |
| 866 } | 901 } |
| 867 | 902 |
| 868 void SurfaceAggregator::SetOutputColorSpace( | 903 void SurfaceAggregator::SetOutputColorSpace( |
| 904 const gfx::ColorSpace& blending_color_space, |
| 869 const gfx::ColorSpace& output_color_space) { | 905 const gfx::ColorSpace& output_color_space) { |
| 906 blending_color_space_ = blending_color_space; |
| 870 output_color_space_ = output_color_space; | 907 output_color_space_ = output_color_space; |
| 871 } | 908 } |
| 872 | 909 |
| 873 } // namespace cc | 910 } // namespace cc |
| OLD | NEW |