| 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_underlay.h" | 5 #include "cc/output/overlay_strategy_underlay.h" |
| 6 | 6 |
| 7 #include "cc/output/overlay_candidate_validator.h" | 7 #include "cc/output/overlay_candidate_validator.h" |
| 8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
| 9 #include "cc/quads/solid_color_draw_quad.h" | 9 #include "cc/quads/solid_color_draw_quad.h" |
| 10 | 10 |
| 11 namespace cc { | 11 namespace cc { |
| 12 | 12 |
| 13 OverlayStrategyUnderlay::~OverlayStrategyUnderlay() {} | 13 OverlayStrategyUnderlay::~OverlayStrategyUnderlay() {} |
| 14 | 14 |
| 15 bool OverlayStrategyUnderlay::TryOverlay( | 15 OverlayResult OverlayStrategyUnderlay::TryOverlay( |
| 16 OverlayCandidateValidator* capability_checker, | 16 OverlayCandidateValidator* capability_checker, |
| 17 RenderPassList* render_passes_in_draw_order, | 17 RenderPassList* render_passes_in_draw_order, |
| 18 OverlayCandidateList* candidate_list, | 18 OverlayCandidateList* candidate_list, |
| 19 const OverlayCandidate& candidate, | 19 const OverlayCandidate& candidate, |
| 20 QuadList::Iterator candidate_iterator, | 20 QuadList::Iterator* candidate_iterator, |
| 21 float device_scale_factor) { | 21 float device_scale_factor) { |
| 22 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | 22 RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
| 23 QuadList& quad_list = root_render_pass->quad_list; | 23 QuadList& quad_list = root_render_pass->quad_list; |
| 24 | 24 |
| 25 // Add our primary surface. | |
| 26 OverlayCandidateList candidates; | |
| 27 OverlayCandidate main_image; | |
| 28 main_image.display_rect = root_render_pass->output_rect; | |
| 29 candidates.push_back(main_image); | |
| 30 | |
| 31 // Add the overlay. | 25 // Add the overlay. |
| 32 candidates.push_back(candidate); | 26 OverlayCandidateList new_candidate_list = *candidate_list; |
| 33 candidates.back().plane_z_order = -1; | 27 new_candidate_list.push_back(candidate); |
| 28 new_candidate_list.back().plane_z_order = -1; |
| 34 | 29 |
| 35 // Check for support. | 30 // Check for support. |
| 36 capability_checker->CheckOverlaySupport(&candidates); | 31 capability_checker->CheckOverlaySupport(&new_candidate_list); |
| 37 | 32 |
| 38 // If the candidate can be handled by an overlay, create a pass for it. We | 33 // If the candidate can be handled by an overlay, create a pass for it. We |
| 39 // need to switch out the video quad with a black transparent one. | 34 // need to switch out the video quad with a black transparent one. |
| 40 if (candidates[1].overlay_handled) { | 35 if (new_candidate_list.back().overlay_handled) { |
| 41 const SharedQuadState* shared_quad_state = | 36 const SharedQuadState* shared_quad_state = |
| 42 candidate_iterator->shared_quad_state; | 37 (*candidate_iterator)->shared_quad_state; |
| 43 gfx::Rect rect = candidate_iterator->visible_rect; | 38 gfx::Rect rect = (*candidate_iterator)->visible_rect; |
| 44 SolidColorDrawQuad* replacement = | 39 SolidColorDrawQuad* replacement = |
| 45 quad_list.ReplaceExistingElement<SolidColorDrawQuad>( | 40 quad_list.ReplaceExistingElement<SolidColorDrawQuad>( |
| 46 candidate_iterator); | 41 *candidate_iterator); |
| 47 replacement->SetAll(shared_quad_state, rect, rect, rect, false, | 42 replacement->SetAll(shared_quad_state, rect, rect, rect, false, |
| 48 SK_ColorTRANSPARENT, true); | 43 SK_ColorTRANSPARENT, true); |
| 49 candidate_list->swap(candidates); | 44 candidate_list->swap(new_candidate_list); |
| 50 return true; | 45 return CREATED_OVERLAY_STOP_LOOKING; |
| 51 } | 46 } |
| 52 return false; | 47 |
| 48 return DID_NOT_CREATE_OVERLAY; |
| 53 } | 49 } |
| 54 | 50 |
| 55 } // namespace cc | 51 } // namespace cc |
| OLD | NEW |