Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: cc/output/overlay_strategy_underlay.cc

Issue 979693005: Add underlays and split off common overlay functionality (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 DrawQuad* candidate_quad = nullptr;
30 for (auto* draw_quad : quad_list) {
31 if (IsOverlayQuad(draw_quad) &&
32 GetCandidateQuadInfo(*draw_quad, &candidate)) {
33 candidate_quad = draw_quad;
34 break;
35 }
36 }
37 if (!candidate_quad)
38 return false;
39
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);
45
46 // Add the overlay.
47 candidate.plane_z_order = -1;
48 candidates.push_back(candidate);
49
50 // Check for support.
51 capability_checker_->CheckOverlaySupport(&candidates);
52
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_quad->shared_quad_state;
58 gfx::Rect rect = candidate_quad->visible_rect;
59 SolidColorDrawQuad* replacement = new (candidate_quad) SolidColorDrawQuad();
danakj 2015/03/18 21:30:14 I think we should do this by adding a replace type
achaulk 2015/03/23 19:16:03 Yeah, that's probably a good idea. It does depend
60 replacement->SetAll(shared_quad_state, rect, rect, rect, false,
61 SK_ColorTRANSPARENT, true);
62 candidate_list->swap(candidates);
63 return true;
64 }
65 return false;
66 }
67
68 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698