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

Side by Side Diff: components/display_compositor/compositor_overlay_candidate_validator_android.cc

Issue 2508203004: Add hints for potential overlay promotion on android. (Closed)
Patch Set: Created 4 years, 1 month 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h" 5 #include "components/display_compositor/compositor_overlay_candidate_validator_a ndroid.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "cc/base/resource_id.h"
10 #include "cc/output/overlay_processor.h" 11 #include "cc/output/overlay_processor.h"
11 #include "cc/output/overlay_strategy_underlay.h" 12 #include "cc/output/overlay_strategy_underlay.h"
13 #include "gpu/command_buffer/client/gles2_interface.h"
12 #include "ui/gfx/geometry/rect_conversions.h" 14 #include "ui/gfx/geometry/rect_conversions.h"
13 15
14 namespace display_compositor { 16 namespace display_compositor {
15 17
16 CompositorOverlayCandidateValidatorAndroid:: 18 CompositorOverlayCandidateValidatorAndroid::
17 CompositorOverlayCandidateValidatorAndroid() {} 19 CompositorOverlayCandidateValidatorAndroid() {}
18 20
19 CompositorOverlayCandidateValidatorAndroid:: 21 CompositorOverlayCandidateValidatorAndroid::
20 ~CompositorOverlayCandidateValidatorAndroid() {} 22 ~CompositorOverlayCandidateValidatorAndroid() {}
21 23
22 void CompositorOverlayCandidateValidatorAndroid::GetStrategies( 24 void CompositorOverlayCandidateValidatorAndroid::GetStrategies(
23 cc::OverlayProcessor::StrategyList* strategies) { 25 cc::OverlayProcessor::StrategyList* strategies) {
24 strategies->push_back(base::MakeUnique<cc::OverlayStrategyUnderlay>(this)); 26 strategies->push_back(base::MakeUnique<cc::OverlayStrategyUnderlay>(this));
25 } 27 }
26 28
27 void CompositorOverlayCandidateValidatorAndroid::CheckOverlaySupport( 29 void CompositorOverlayCandidateValidatorAndroid::CheckOverlaySupport(
28 cc::OverlayCandidateList* candidates) { 30 cc::OverlayCandidateList* candidates) {
29 // There should only be at most a single overlay candidate: the video quad. 31 // There should only be at most a single overlay candidate: the video quad.
30 // There's no check that the presented candidate is really a video frame for 32 // There's no check that the presented candidate is really a video frame for
31 // a fullscreen video. Instead it's assumed that if a quad is marked as 33 // a fullscreen video. Instead it's assumed that if a quad is marked as
32 // overlayable, it's a fullscreen video quad. 34 // overlayable, it's a fullscreen video quad.
33 DCHECK_LE(candidates->size(), 1u); 35 DCHECK_LE(candidates->size(), 1u);
34 36
35 if (!candidates->empty()) { 37 if (!candidates->empty()) {
36 cc::OverlayCandidate& candidate = candidates->front(); 38 cc::OverlayCandidate& candidate = candidates->front();
39
40 // TODO(liberato): maybe we should notify by resource, not by quad. while
liberato (no reviews please) 2016/11/19 18:25:52 this comment block is a little stale, sorry. we n
piman 2016/11/23 00:37:25 As long as we gracefully handle the case, it's ok
liberato (no reviews please) 2016/12/01 20:59:11 Acknowledged.
41 // multiple quads could share a resource, i think that would just make them
42 // all not overlayable. we don't currently check for this, but we could.
43 // maybe 'is_backed_by_surface_texture' should move to the resource.
44 // TODO: should we send in a ResourceProvider here, so that it can ask if
45 // the resource is backed by a surface texture or not, rather than store it
46 // in the candidate?
47 if (candidate.is_backed_by_surface_texture) {
48 // This quad would be promoted if it were backed by a SurfaceView. Since
49 // it isn't, we can't promote it.
50 promotable_resources_.insert(candidate.resource_id);
51 return;
52 }
53
54 // This quad will be promoted. We clear the promotable set here, since we
55 // can only promote a single quad. Otherwise, somebody might try to back
56 // one of the promotable quads with a SurfaceView, and either it or |quad|
57 // would have to fall back to a texture.
58 // We could re-insert |candidate.resource_id| back into the set, but the
59 // quad that refers to it won't be in the list anyway after promotion.
60 promotable_resources_.clear();
61
37 candidate.display_rect = 62 candidate.display_rect =
38 gfx::RectF(gfx::ToEnclosingRect(candidate.display_rect)); 63 gfx::RectF(gfx::ToEnclosingRect(candidate.display_rect));
39 candidate.overlay_handled = true; 64 candidate.overlay_handled = true;
40 candidate.plane_z_order = -1; 65 candidate.plane_z_order = -1;
41 } 66 }
42 } 67 }
43 68
44 bool CompositorOverlayCandidateValidatorAndroid::AllowCALayerOverlays() { 69 bool CompositorOverlayCandidateValidatorAndroid::AllowCALayerOverlays() {
45 return false; 70 return false;
46 } 71 }
47 72
48 // Overlays will still be allowed when software mirroring is enabled, even 73 // Overlays will still be allowed when software mirroring is enabled, even
49 // though they won't appear in the mirror. 74 // though they won't appear in the mirror.
50 void CompositorOverlayCandidateValidatorAndroid::SetSoftwareMirrorMode( 75 void CompositorOverlayCandidateValidatorAndroid::SetSoftwareMirrorMode(
51 bool enabled) {} 76 bool enabled) {}
52 77
78 void CompositorOverlayCandidateValidatorAndroid::ClearPromotableResources() {
79 promotable_resources_.clear();
80 }
81
82 bool CompositorOverlayCandidateValidatorAndroid::IsResourcePromotable(
83 cc::ResourceId resource_id) {
84 return promotable_resources_.count(resource_id) > 0;
85 }
86
53 } // namespace display_compositor 87 } // namespace display_compositor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698