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