| 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 bool 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. | 25 // Add our primary surface. |
| 26 OverlayCandidateList candidates; | 26 OverlayCandidateList candidates; |
| 27 OverlayCandidate main_image; | 27 OverlayCandidate main_image; |
| 28 main_image.display_rect = root_render_pass->output_rect; | 28 main_image.display_rect = gfx::RectF(root_render_pass->output_rect); |
| 29 candidates.push_back(main_image); | 29 candidates.push_back(main_image); |
| 30 | 30 |
| 31 // Add the overlay. | 31 // Add the overlay. |
| 32 candidates.push_back(candidate); | 32 candidates.push_back(candidate); |
| 33 candidates.back().plane_z_order = -1; | 33 candidates.back().plane_z_order = -1; |
| 34 | 34 |
| 35 // Check for support. | 35 // Check for support. |
| 36 capability_checker->CheckOverlaySupport(&candidates); | 36 capability_checker->CheckOverlaySupport(&candidates); |
| 37 | 37 |
| 38 // If the candidate can be handled by an overlay, create a pass for it. We | 38 // 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. | 39 // need to switch out the video quad with a black transparent one. |
| 40 if (candidates[1].overlay_handled) { | 40 if (candidates[1].overlay_handled) { |
| 41 const SharedQuadState* shared_quad_state = | 41 const SharedQuadState* shared_quad_state = |
| 42 candidate_iterator->shared_quad_state; | 42 candidate_iterator->shared_quad_state; |
| 43 gfx::Rect rect = candidate_iterator->visible_rect; | 43 gfx::Rect rect = candidate_iterator->visible_rect; |
| 44 SolidColorDrawQuad* replacement = | 44 SolidColorDrawQuad* replacement = |
| 45 quad_list.ReplaceExistingElement<SolidColorDrawQuad>( | 45 quad_list.ReplaceExistingElement<SolidColorDrawQuad>( |
| 46 candidate_iterator); | 46 candidate_iterator); |
| 47 replacement->SetAll(shared_quad_state, rect, rect, rect, false, | 47 replacement->SetAll(shared_quad_state, rect, rect, rect, false, |
| 48 SK_ColorTRANSPARENT, true); | 48 SK_ColorTRANSPARENT, true); |
| 49 candidate_list->swap(candidates); | 49 candidate_list->swap(candidates); |
| 50 return true; | 50 return true; |
| 51 } | 51 } |
| 52 return false; | 52 return false; |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace cc | 55 } // namespace cc |
| OLD | NEW |