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/output/overlay_strategy_single_on_top.h" | 5 #include "cc/output/overlay_strategy_single_on_top.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/output/overlay_candidate_validator.h" | 10 #include "cc/output/overlay_candidate_validator.h" |
11 #include "cc/quads/draw_quad.h" | 11 #include "cc/quads/draw_quad.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 | 14 |
15 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {} | 15 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {} |
16 | 16 |
17 bool OverlayStrategySingleOnTop::TryOverlay( | 17 OverlayResult OverlayStrategySingleOnTop::TryOverlay( |
18 OverlayCandidateValidator* capability_checker, | 18 OverlayCandidateValidator* capability_checker, |
19 RenderPassList* render_passes_in_draw_order, | 19 RenderPassList* render_passes_in_draw_order, |
20 OverlayCandidateList* candidate_list, | 20 OverlayCandidateList* candidate_list, |
21 const OverlayCandidate& candidate, | 21 const OverlayCandidate& candidate, |
22 QuadList::Iterator candidate_iterator, | 22 QuadList::Iterator* candidate_iterator, |
23 float device_scale_factor) { | 23 float device_scale_factor) { |
24 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | 24 RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
25 QuadList& quad_list = root_render_pass->quad_list; | 25 QuadList& quad_list = root_render_pass->quad_list; |
26 const DrawQuad* draw_quad = *candidate_iterator; | |
27 gfx::RectF rect = MathUtil::MapClippedRect( | |
28 draw_quad->shared_quad_state->quad_to_target_transform, | |
29 gfx::RectF(draw_quad->rect)); | |
30 | |
31 // Check that no prior quads overlap it. | 26 // Check that no prior quads overlap it. |
32 for (auto overlap_iter = quad_list.cbegin(); | 27 for (auto overlap_iter = quad_list.cbegin(); |
33 overlap_iter != candidate_iterator; ++overlap_iter) { | 28 overlap_iter != *candidate_iterator; ++overlap_iter) { |
34 gfx::RectF overlap_rect = MathUtil::MapClippedRect( | 29 gfx::RectF overlap_rect = MathUtil::MapClippedRect( |
35 overlap_iter->shared_quad_state->quad_to_target_transform, | 30 overlap_iter->shared_quad_state->quad_to_target_transform, |
36 gfx::RectF(overlap_iter->rect)); | 31 gfx::RectF(overlap_iter->rect)); |
37 if (rect.Intersects(overlap_rect) && | 32 if (candidate.display_rect.Intersects(overlap_rect) && |
38 !OverlayStrategyCommon::IsInvisibleQuad(*overlap_iter)) | 33 !OverlayStrategyCommon::IsInvisibleQuad(*overlap_iter)) |
39 return false; | 34 return DID_NOT_CREATE_OVERLAY; |
40 } | 35 } |
41 | 36 |
42 // Add our primary surface. | |
43 OverlayCandidateList candidates; | |
44 OverlayCandidate main_image; | |
45 main_image.display_rect = gfx::RectF(root_render_pass->output_rect); | |
46 candidates.push_back(main_image); | |
47 | |
48 // Add the overlay. | 37 // Add the overlay. |
49 candidates.push_back(candidate); | 38 OverlayCandidateList new_candidate_list = *candidate_list; |
50 candidates.back().plane_z_order = 1; | 39 new_candidate_list.push_back(candidate); |
| 40 new_candidate_list.back().plane_z_order = 1; |
51 | 41 |
52 // Check for support. | 42 // Check for support. |
53 capability_checker->CheckOverlaySupport(&candidates); | 43 capability_checker->CheckOverlaySupport(&new_candidate_list); |
54 | 44 |
55 // If the candidate can be handled by an overlay, create a pass for it. | 45 // If the candidate can be handled by an overlay, create a pass for it. |
56 if (candidates[1].overlay_handled) { | 46 if (new_candidate_list.back().overlay_handled) { |
57 quad_list.EraseAndInvalidateAllPointers(candidate_iterator); | 47 quad_list.EraseAndInvalidateAllPointers(*candidate_iterator); |
58 candidate_list->swap(candidates); | 48 candidate_list->swap(new_candidate_list); |
59 return true; | 49 return CREATED_OVERLAY_STOP_LOOKING; |
60 } | 50 } |
61 return false; | 51 |
| 52 return DID_NOT_CREATE_OVERLAY; |
62 } | 53 } |
63 | 54 |
64 } // namespace cc | 55 } // namespace cc |
OLD | NEW |