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