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

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

Issue 2749783006: cc: Enable non-opaque harware overlays. (Closed)
Patch Set: Fix comments. Created 3 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
« no previous file with comments | « cc/output/overlay_strategy_fullscreen.cc ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/overlay_strategy_single_on_top.h" 5 #include "cc/output/overlay_strategy_single_on_top.h"
6 6
7 #include "cc/base/math_util.h" 7 #include "cc/base/math_util.h"
8 #include "cc/output/overlay_candidate_validator.h" 8 #include "cc/output/overlay_candidate_validator.h"
9 #include "cc/quads/draw_quad.h" 9 #include "cc/quads/draw_quad.h"
10 #include "ui/gfx/buffer_types.h"
10 #include "ui/gfx/geometry/rect_conversions.h" 11 #include "ui/gfx/geometry/rect_conversions.h"
11 12
12 namespace cc { 13 namespace cc {
13 14
reveman 2017/03/16 04:57:34 nit: remove blank line
Daniele Castagna 2017/03/16 05:04:20 Done.
15 namespace {
16 const gfx::BufferFormat kOverlayFormatsWithAlpha[] = {
reveman 2017/03/16 04:57:34 nit: add blank line before this
Daniele Castagna 2017/03/16 05:04:20 Done.
17 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888};
18 }
reveman 2017/03/16 04:57:34 nit: add blank line after this :)
Daniele Castagna 2017/03/16 05:04:20 Done.
14 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop( 19 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop(
15 OverlayCandidateValidator* capability_checker) 20 OverlayCandidateValidator* capability_checker)
16 : capability_checker_(capability_checker) { 21 : capability_checker_(capability_checker) {
17 DCHECK(capability_checker); 22 DCHECK(capability_checker);
18 } 23 }
19 24
20 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {} 25 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {}
21 26
22 bool OverlayStrategySingleOnTop::Attempt( 27 bool OverlayStrategySingleOnTop::Attempt(
23 ResourceProvider* resource_provider, 28 ResourceProvider* resource_provider,
24 RenderPass* render_pass, 29 RenderPass* render_pass,
25 OverlayCandidateList* candidate_list, 30 OverlayCandidateList* candidate_list,
26 std::vector<gfx::Rect>* content_bounds) { 31 std::vector<gfx::Rect>* content_bounds) {
27 QuadList* quad_list = &render_pass->quad_list; 32 QuadList* quad_list = &render_pass->quad_list;
28 // Build a list of candidates with the associated quad. 33 // Build a list of candidates with the associated quad.
29 OverlayCandidate best_candidate; 34 OverlayCandidate best_candidate;
30 QuadList::Iterator best_quad_it = quad_list->end(); 35 QuadList::Iterator best_quad_it = quad_list->end();
31 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { 36 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) {
32 OverlayCandidate candidate; 37 OverlayCandidate candidate;
33 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate) && 38 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate) &&
34 // TODO(dcastagna): Remove this once drm platform supports transforms. 39 // TODO(dcastagna): Remove this once drm platform supports transforms.
35 candidate.transform == gfx::OVERLAY_TRANSFORM_NONE && 40 candidate.transform == gfx::OVERLAY_TRANSFORM_NONE &&
36 !OverlayCandidate::IsOccluded(candidate, quad_list->cbegin(), it)) { 41 !OverlayCandidate::IsOccluded(candidate, quad_list->cbegin(), it)) {
42 // We currently reject quads with alpha that do not request alpha blending
43 // since the alpha channel might not be set to 1 and we're not disabling
44 // blending when scanning out.
45 // TODO(dcastagna): We should support alpha formats without blending using
46 // the opaque FB at scanout.
47 if (std::find(std::begin(kOverlayFormatsWithAlpha),
48 std::end(kOverlayFormatsWithAlpha),
49 candidate.format) != std::end(kOverlayFormatsWithAlpha) &&
50 it->shared_quad_state->blend_mode == SkBlendMode::kSrc)
51 continue;
52
37 if (candidate.display_rect.size().GetArea() > 53 if (candidate.display_rect.size().GetArea() >
38 best_candidate.display_rect.size().GetArea()) { 54 best_candidate.display_rect.size().GetArea()) {
39 best_candidate = candidate; 55 best_candidate = candidate;
40 best_quad_it = it; 56 best_quad_it = it;
41 } 57 }
42 } 58 }
43 } 59 }
44 if (best_quad_it == quad_list->end()) 60 if (best_quad_it == quad_list->end())
45 return false; 61 return false;
46 62
(...skipping 21 matching lines...) Expand all
68 if (overlay_candidate.overlay_handled) { 84 if (overlay_candidate.overlay_handled) {
69 quad_list->EraseAndInvalidateAllPointers(candidate_iterator); 85 quad_list->EraseAndInvalidateAllPointers(candidate_iterator);
70 candidate_list->swap(new_candidate_list); 86 candidate_list->swap(new_candidate_list);
71 return true; 87 return true;
72 } 88 }
73 89
74 return false; 90 return false;
75 } 91 }
76 92
77 } // namespace cc 93 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/overlay_strategy_fullscreen.cc ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698