| 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( |
| 14 OverlayCandidateValidator* capability_checker) |
| 15 : capability_checker_(capability_checker) { |
| 16 DCHECK(capability_checker); |
| 17 } |
| 18 |
| 13 OverlayStrategyUnderlay::~OverlayStrategyUnderlay() {} | 19 OverlayStrategyUnderlay::~OverlayStrategyUnderlay() {} |
| 14 | 20 |
| 15 OverlayResult OverlayStrategyUnderlay::TryOverlay( | 21 bool OverlayStrategyUnderlay::Attempt(RenderPassList* render_passes, |
| 16 OverlayCandidateValidator* capability_checker, | 22 OverlayCandidateList* candidate_list) { |
| 17 RenderPassList* render_passes_in_draw_order, | 23 QuadList& quad_list = render_passes->back()->quad_list; |
| 18 OverlayCandidateList* candidate_list, | 24 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { |
| 19 const OverlayCandidate& candidate, | 25 OverlayCandidate candidate; |
| 20 QuadList::Iterator* candidate_iterator, | 26 if (!OverlayCandidate::FromDrawQuad(*it, &candidate)) |
| 21 float device_scale_factor) { | 27 continue; |
| 22 RenderPass* root_render_pass = render_passes_in_draw_order->back(); | |
| 23 QuadList& quad_list = root_render_pass->quad_list; | |
| 24 | 28 |
| 25 // Add the overlay. | 29 // Add the overlay. |
| 26 OverlayCandidateList new_candidate_list = *candidate_list; | 30 OverlayCandidateList new_candidate_list = *candidate_list; |
| 27 new_candidate_list.push_back(candidate); | 31 new_candidate_list.push_back(candidate); |
| 28 new_candidate_list.back().plane_z_order = -1; | 32 new_candidate_list.back().plane_z_order = -1; |
| 29 | 33 |
| 30 // Check for support. | 34 // Check for support. |
| 31 capability_checker->CheckOverlaySupport(&new_candidate_list); | 35 capability_checker_->CheckOverlaySupport(&new_candidate_list); |
| 32 | 36 |
| 33 // If the candidate can be handled by an overlay, create a pass for it. We | 37 // If the candidate can be handled by an overlay, create a pass for it. We |
| 34 // need to switch out the video quad with a black transparent one. | 38 // need to switch out the video quad with a black transparent one. |
| 35 if (new_candidate_list.back().overlay_handled) { | 39 if (new_candidate_list.back().overlay_handled) { |
| 36 const SharedQuadState* shared_quad_state = | 40 const SharedQuadState* shared_quad_state = it->shared_quad_state; |
| 37 (*candidate_iterator)->shared_quad_state; | 41 gfx::Rect rect = it->visible_rect; |
| 38 gfx::Rect rect = (*candidate_iterator)->visible_rect; | 42 SolidColorDrawQuad* replacement = |
| 39 SolidColorDrawQuad* replacement = | 43 quad_list.ReplaceExistingElement<SolidColorDrawQuad>(it); |
| 40 quad_list.ReplaceExistingElement<SolidColorDrawQuad>( | 44 replacement->SetAll(shared_quad_state, rect, rect, rect, false, |
| 41 *candidate_iterator); | 45 SK_ColorTRANSPARENT, true); |
| 42 replacement->SetAll(shared_quad_state, rect, rect, rect, false, | 46 candidate_list->swap(new_candidate_list); |
| 43 SK_ColorTRANSPARENT, true); | 47 return true; |
| 44 candidate_list->swap(new_candidate_list); | 48 } |
| 45 return CREATED_OVERLAY_STOP_LOOKING; | |
| 46 } | 49 } |
| 47 | 50 |
| 48 return DID_NOT_CREATE_OVERLAY; | 51 return false; |
| 49 } | 52 } |
| 50 | 53 |
| 51 } // namespace cc | 54 } // namespace cc |
| OLD | NEW |