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

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

Issue 2749783006: cc: Enable non-opaque harware overlays. (Closed)
Patch Set: Blank lines! 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 {
14 namespace {
15
16 const gfx::BufferFormat kOverlayFormatsWithAlpha[] = {
17 gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::BGRA_8888};
18 }
13 19
14 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop( 20 OverlayStrategySingleOnTop::OverlayStrategySingleOnTop(
15 OverlayCandidateValidator* capability_checker) 21 OverlayCandidateValidator* capability_checker)
16 : capability_checker_(capability_checker) { 22 : capability_checker_(capability_checker) {
17 DCHECK(capability_checker); 23 DCHECK(capability_checker);
18 } 24 }
19 25
20 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {} 26 OverlayStrategySingleOnTop::~OverlayStrategySingleOnTop() {}
21 27
22 bool OverlayStrategySingleOnTop::Attempt( 28 bool OverlayStrategySingleOnTop::Attempt(
23 ResourceProvider* resource_provider, 29 ResourceProvider* resource_provider,
24 RenderPass* render_pass, 30 RenderPass* render_pass,
25 OverlayCandidateList* candidate_list, 31 OverlayCandidateList* candidate_list,
26 std::vector<gfx::Rect>* content_bounds) { 32 std::vector<gfx::Rect>* content_bounds) {
27 QuadList* quad_list = &render_pass->quad_list; 33 QuadList* quad_list = &render_pass->quad_list;
28 // Build a list of candidates with the associated quad. 34 // Build a list of candidates with the associated quad.
29 OverlayCandidate best_candidate; 35 OverlayCandidate best_candidate;
30 QuadList::Iterator best_quad_it = quad_list->end(); 36 QuadList::Iterator best_quad_it = quad_list->end();
31 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) { 37 for (auto it = quad_list->begin(); it != quad_list->end(); ++it) {
32 OverlayCandidate candidate; 38 OverlayCandidate candidate;
33 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate) && 39 if (OverlayCandidate::FromDrawQuad(resource_provider, *it, &candidate) &&
34 // TODO(dcastagna): Remove this once drm platform supports transforms. 40 // TODO(dcastagna): Remove this once drm platform supports transforms.
35 candidate.transform == gfx::OVERLAY_TRANSFORM_NONE && 41 candidate.transform == gfx::OVERLAY_TRANSFORM_NONE &&
36 !OverlayCandidate::IsOccluded(candidate, quad_list->cbegin(), it)) { 42 !OverlayCandidate::IsOccluded(candidate, quad_list->cbegin(), it)) {
43 // We currently reject quads with alpha that do not request alpha blending
44 // since the alpha channel might not be set to 1 and we're not disabling
45 // blending when scanning out.
46 // TODO(dcastagna): We should support alpha formats without blending using
47 // the opaque FB at scanout.
48 if (std::find(std::begin(kOverlayFormatsWithAlpha),
49 std::end(kOverlayFormatsWithAlpha),
50 candidate.format) != std::end(kOverlayFormatsWithAlpha) &&
51 it->shared_quad_state->blend_mode == SkBlendMode::kSrc)
52 continue;
53
37 if (candidate.display_rect.size().GetArea() > 54 if (candidate.display_rect.size().GetArea() >
38 best_candidate.display_rect.size().GetArea()) { 55 best_candidate.display_rect.size().GetArea()) {
39 best_candidate = candidate; 56 best_candidate = candidate;
40 best_quad_it = it; 57 best_quad_it = it;
41 } 58 }
42 } 59 }
43 } 60 }
44 if (best_quad_it == quad_list->end()) 61 if (best_quad_it == quad_list->end())
45 return false; 62 return false;
46 63
(...skipping 21 matching lines...) Expand all
68 if (overlay_candidate.overlay_handled) { 85 if (overlay_candidate.overlay_handled) {
69 quad_list->EraseAndInvalidateAllPointers(candidate_iterator); 86 quad_list->EraseAndInvalidateAllPointers(candidate_iterator);
70 candidate_list->swap(new_candidate_list); 87 candidate_list->swap(new_candidate_list);
71 return true; 88 return true;
72 } 89 }
73 90
74 return false; 91 return false;
75 } 92 }
76 93
77 } // namespace cc 94 } // 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