Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / cc / output / overlay_strategy_underlay.cc
bloba88997a06fdcc8c602f0a610644a12201ca83fc8
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"
11 namespace cc {
13 OverlayStrategyUnderlay::OverlayStrategyUnderlay(
14 OverlayCandidateValidator* capability_checker,
15 ResourceProvider* resource_provider)
16 : OverlayStrategyCommon(capability_checker, resource_provider) {
19 bool OverlayStrategyUnderlay::Attempt(
20 RenderPassList* render_passes_in_draw_order,
21 OverlayCandidateList* candidate_list) {
22 if (!capability_checker_)
23 return false;
25 RenderPass* root_render_pass = render_passes_in_draw_order->back();
26 DCHECK(root_render_pass);
28 OverlayCandidate candidate;
29 QuadList& quad_list = root_render_pass->quad_list;
30 auto candidate_iterator = quad_list.end();
31 for (auto it = quad_list.begin(); it != quad_list.end(); ++it) {
32 if (IsOverlayQuad(*it) && GetCandidateQuadInfo(**it, &candidate)) {
33 candidate_iterator = it;
34 break;
37 if (candidate_iterator == quad_list.end())
38 return false;
40 // Add our primary surface.
41 OverlayCandidateList candidates;
42 OverlayCandidate main_image;
43 main_image.display_rect = root_render_pass->output_rect;
44 candidates.push_back(main_image);
46 // Add the overlay.
47 candidate.plane_z_order = -1;
48 candidates.push_back(candidate);
50 // Check for support.
51 capability_checker_->CheckOverlaySupport(&candidates);
53 // If the candidate can be handled by an overlay, create a pass for it. We
54 // need to switch out the video quad with a black transparent one.
55 if (candidates[1].overlay_handled) {
56 const SharedQuadState* shared_quad_state =
57 candidate_iterator->shared_quad_state;
58 gfx::Rect rect = candidate_iterator->visible_rect;
59 SolidColorDrawQuad* replacement =
60 quad_list.ReplaceExistingElement<SolidColorDrawQuad>(
61 candidate_iterator);
62 replacement->SetAll(shared_quad_state, rect, rect, rect, false,
63 SK_ColorTRANSPARENT, true);
64 candidate_list->swap(candidates);
65 return true;
67 return false;
70 } // namespace cc