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() {}
15 OverlayResult
OverlayStrategyUnderlay::TryOverlay(
16 OverlayCandidateValidator
* capability_checker
,
17 RenderPassList
* render_passes_in_draw_order
,
18 OverlayCandidateList
* candidate_list
,
19 const OverlayCandidate
& candidate
,
20 QuadList::Iterator
* candidate_iterator
,
21 float device_scale_factor
) {
22 RenderPass
* root_render_pass
= render_passes_in_draw_order
->back();
23 QuadList
& quad_list
= root_render_pass
->quad_list
;
26 OverlayCandidateList new_candidate_list
= *candidate_list
;
27 new_candidate_list
.push_back(candidate
);
28 new_candidate_list
.back().plane_z_order
= -1;
31 capability_checker
->CheckOverlaySupport(&new_candidate_list
);
33 // 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.
35 if (new_candidate_list
.back().overlay_handled
) {
36 const SharedQuadState
* shared_quad_state
=
37 (*candidate_iterator
)->shared_quad_state
;
38 gfx::Rect rect
= (*candidate_iterator
)->visible_rect
;
39 SolidColorDrawQuad
* replacement
=
40 quad_list
.ReplaceExistingElement
<SolidColorDrawQuad
>(
42 replacement
->SetAll(shared_quad_state
, rect
, rect
, rect
, false,
43 SK_ColorTRANSPARENT
, true);
44 candidate_list
->swap(new_candidate_list
);
45 return CREATED_OVERLAY_STOP_LOOKING
;
48 return DID_NOT_CREATE_OVERLAY
;