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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/containers/adapters.h" | 12 #include "base/containers/adapters.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
19 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
20 #include "cc/output/compositor_frame.h" | 20 #include "cc/output/compositor_frame.h" |
21 #include "cc/quads/draw_quad.h" | 21 #include "cc/quads/draw_quad.h" |
22 #include "cc/quads/render_pass_draw_quad.h" | 22 #include "cc/quads/render_pass_draw_quad.h" |
23 #include "cc/quads/shared_quad_state.h" | 23 #include "cc/quads/shared_quad_state.h" |
24 #include "cc/quads/solid_color_draw_quad.h" | 24 #include "cc/quads/solid_color_draw_quad.h" |
25 #include "cc/quads/surface_draw_quad.h" | 25 #include "cc/quads/surface_draw_quad.h" |
26 #include "cc/quads/texture_draw_quad.h" | 26 #include "cc/quads/texture_draw_quad.h" |
27 #include "cc/resources/resource_provider.h" | 27 #include "cc/resources/resource_provider.h" |
28 #include "cc/surfaces/surface.h" | 28 #include "cc/surfaces/surface.h" |
29 #include "cc/surfaces/surface_factory.h" | |
30 #include "cc/surfaces/surface_manager.h" | 29 #include "cc/surfaces/surface_manager.h" |
31 #include "cc/trees/blocking_task_runner.h" | 30 #include "cc/trees/blocking_task_runner.h" |
32 | 31 |
33 namespace cc { | 32 namespace cc { |
34 namespace { | 33 namespace { |
35 | 34 |
36 // Maximum bucket size for the UMA stats. | 35 // Maximum bucket size for the UMA stats. |
37 constexpr int kUmaStatMaxSurfaces = 30; | 36 constexpr int kUmaStatMaxSurfaces = 30; |
38 | 37 |
39 const char kUmaValidSurface[] = | 38 const char kUmaValidSurface[] = |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 // Release resources of removed surface. | 569 // Release resources of removed surface. |
571 auto it = surface_id_to_resource_child_id_.find(surface.first); | 570 auto it = surface_id_to_resource_child_id_.find(surface.first); |
572 if (it != surface_id_to_resource_child_id_.end()) { | 571 if (it != surface_id_to_resource_child_id_.end()) { |
573 provider_->DestroyChild(it->second); | 572 provider_->DestroyChild(it->second); |
574 surface_id_to_resource_child_id_.erase(it); | 573 surface_id_to_resource_child_id_.erase(it); |
575 } | 574 } |
576 | 575 |
577 // Notify client of removed surface. | 576 // Notify client of removed surface. |
578 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first); | 577 Surface* surface_ptr = manager_->GetSurfaceForId(surface.first); |
579 if (surface_ptr) { | 578 if (surface_ptr) { |
580 surface_ptr->RunDrawCallbacks(); | 579 surface_ptr->RunDrawCallback(); |
581 } | 580 } |
582 } | 581 } |
583 } | 582 } |
584 } | 583 } |
585 | 584 |
586 // Walk the Surface tree from surface_id. Validate the resources of the current | 585 // Walk the Surface tree from surface_id. Validate the resources of the current |
587 // surface and its descendants, check if there are any copy requests, and | 586 // surface and its descendants, check if there are any copy requests, and |
588 // return the combined damage rect. | 587 // return the combined damage rect. |
589 gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id, | 588 gfx::Rect SurfaceAggregator::PrewalkTree(const SurfaceId& surface_id, |
590 bool in_moved_pixel_surface, | 589 bool in_moved_pixel_surface, |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 | 751 |
753 CHECK(debug_weak_this.get()); | 752 CHECK(debug_weak_this.get()); |
754 for (const auto& surface_id : frame.metadata.referenced_surfaces) { | 753 for (const auto& surface_id : frame.metadata.referenced_surfaces) { |
755 if (!contained_surfaces_.count(surface_id)) { | 754 if (!contained_surfaces_.count(surface_id)) { |
756 result->undrawn_surfaces.insert(surface_id); | 755 result->undrawn_surfaces.insert(surface_id); |
757 PrewalkTree(surface_id, false, 0, result); | 756 PrewalkTree(surface_id, false, 0, result); |
758 } | 757 } |
759 } | 758 } |
760 | 759 |
761 CHECK(debug_weak_this.get()); | 760 CHECK(debug_weak_this.get()); |
762 if (surface->factory()) { | 761 // TODO(staraz): It shouldn't need to call the callback when the damage is |
763 surface->factory()->WillDrawSurface( | 762 // from |surface| and not from |child_surfaces|. |
764 surface->surface_id().local_surface_id(), damage_rect); | 763 if (!damage_rect.IsEmpty()) |
765 } | 764 surface->RunWillDrawCallback(damage_rect); |
766 | 765 |
767 CHECK(debug_weak_this.get()); | 766 CHECK(debug_weak_this.get()); |
768 for (const auto& render_pass : frame.render_pass_list) { | 767 for (const auto& render_pass : frame.render_pass_list) { |
769 if (!render_pass->copy_requests.empty()) { | 768 if (!render_pass->copy_requests.empty()) { |
770 int remapped_pass_id = RemapPassId(render_pass->id, surface_id); | 769 int remapped_pass_id = RemapPassId(render_pass->id, surface_id); |
771 copy_request_passes_.insert(remapped_pass_id); | 770 copy_request_passes_.insert(remapped_pass_id); |
772 } | 771 } |
773 } | 772 } |
774 | 773 |
775 referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id())); | 774 referenced_surfaces_.erase(referenced_surfaces_.find(surface->surface_id())); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 } | 931 } |
933 | 932 |
934 void SurfaceAggregator::SetOutputColorSpace( | 933 void SurfaceAggregator::SetOutputColorSpace( |
935 const gfx::ColorSpace& blending_color_space, | 934 const gfx::ColorSpace& blending_color_space, |
936 const gfx::ColorSpace& output_color_space) { | 935 const gfx::ColorSpace& output_color_space) { |
937 blending_color_space_ = blending_color_space; | 936 blending_color_space_ = blending_color_space; |
938 output_color_space_ = output_color_space; | 937 output_color_space_ = output_color_space; |
939 } | 938 } |
940 | 939 |
941 } // namespace cc | 940 } // namespace cc |
OLD | NEW |