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