OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/output/overlay_strategy_underlay.h" |
| 6 |
| 7 #include "cc/quads/draw_quad.h" |
| 8 #include "cc/quads/solid_color_draw_quad.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 OverlayStrategyUnderlay::OverlayStrategyUnderlay( |
| 13 OverlayCandidateValidator* capability_checker, |
| 14 ResourceProvider* resource_provider) |
| 15 : OverlayStrategyCommon(capability_checker, resource_provider) { |
| 16 } |
| 17 |
| 18 bool OverlayStrategyUnderlay::Attempt( |
| 19 RenderPassList* render_passes_in_draw_order, |
| 20 OverlayCandidateList* candidate_list) { |
| 21 if (!capability_checker_) |
| 22 return false; |
| 23 |
| 24 RenderPass* root_render_pass = render_passes_in_draw_order->back(); |
| 25 DCHECK(root_render_pass); |
| 26 |
| 27 OverlayCandidate candidate; |
| 28 QuadList& quad_list = root_render_pass->quad_list; |
| 29 auto candidate_iterator = quad_list.end(); |
| 30 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) { |
| 31 if (IsOverlayQuad(*it) && GetCandidateQuadInfo(**it, &candidate)) { |
| 32 candidate_iterator = it; |
| 33 break; |
| 34 } |
| 35 } |
| 36 if (candidate_iterator == quad_list.end()) |
| 37 return false; |
| 38 |
| 39 // Add our primary surface. |
| 40 OverlayCandidateList candidates; |
| 41 OverlayCandidate main_image; |
| 42 main_image.display_rect = root_render_pass->output_rect; |
| 43 candidates.push_back(main_image); |
| 44 |
| 45 // Add the overlay. |
| 46 candidate.plane_z_order = -1; |
| 47 candidates.push_back(candidate); |
| 48 |
| 49 // Check for support. |
| 50 capability_checker_->CheckOverlaySupport(&candidates); |
| 51 |
| 52 // If the candidate can be handled by an overlay, create a pass for it. We |
| 53 // need to switch out the video quad with a black transparent one. |
| 54 if (candidates[1].overlay_handled) { |
| 55 const SharedQuadState* shared_quad_state = |
| 56 candidate_iterator->shared_quad_state; |
| 57 gfx::Rect rect = candidate_iterator->visible_rect; |
| 58 SolidColorDrawQuad* replacement = |
| 59 quad_list.ReplaceExistingElement<SolidColorDrawQuad>( |
| 60 candidate_iterator); |
| 61 replacement->SetAll(shared_quad_state, rect, rect, rect, false, |
| 62 SK_ColorTRANSPARENT, true); |
| 63 candidate_list->swap(candidates); |
| 64 return true; |
| 65 } |
| 66 return false; |
| 67 } |
| 68 |
| 69 } // namespace cc |
OLD | NEW |