OLD | NEW |
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/output/overlay_processor.h" | 10 #include "cc/output/overlay_processor.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 void CompositorOverlayCandidateValidatorAndroid::CheckOverlaySupport( | 27 void CompositorOverlayCandidateValidatorAndroid::CheckOverlaySupport( |
28 cc::OverlayCandidateList* candidates) { | 28 cc::OverlayCandidateList* candidates) { |
29 // There should only be at most a single overlay candidate: the video quad. | 29 // 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 | 30 // 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 | 31 // a fullscreen video. Instead it's assumed that if a quad is marked as |
32 // overlayable, it's a fullscreen video quad. | 32 // overlayable, it's a fullscreen video quad. |
33 DCHECK_LE(candidates->size(), 1u); | 33 DCHECK_LE(candidates->size(), 1u); |
34 | 34 |
35 if (!candidates->empty()) { | 35 if (!candidates->empty()) { |
36 cc::OverlayCandidate& candidate = candidates->front(); | 36 cc::OverlayCandidate& candidate = candidates->front(); |
| 37 |
| 38 if (candidate.is_backed_by_surface_texture) { |
| 39 // This quad would be promoted if it were backed by a SurfaceView. Since |
| 40 // it isn't, we can't promote it. We do want to mark it as promotable, |
| 41 // since the whole point of signalling this is to help whoever creates |
| 42 // the resource to decide whether a SurfaceTexture or SurfaceView is more |
| 43 // appropriate to use. |
| 44 promotable_resources_.insert(candidate.resource_id); |
| 45 return; |
| 46 } |
| 47 |
| 48 // This quad will be promoted. We clear the promotable set here, since we |
| 49 // can only promote a single quad. Otherwise, somebody might try to back |
| 50 // one of the promotable quads with a SurfaceView, and either it or |quad| |
| 51 // would have to fall back to a texture. |
| 52 // We could re-insert |candidate.resource_id| back into the set, but the |
| 53 // quad that refers to it won't be in the list anyway after promotion. |
| 54 promotable_resources_.clear(); |
| 55 |
37 candidate.display_rect = | 56 candidate.display_rect = |
38 gfx::RectF(gfx::ToEnclosingRect(candidate.display_rect)); | 57 gfx::RectF(gfx::ToEnclosingRect(candidate.display_rect)); |
39 candidate.overlay_handled = true; | 58 candidate.overlay_handled = true; |
40 candidate.plane_z_order = -1; | 59 candidate.plane_z_order = -1; |
41 } | 60 } |
42 } | 61 } |
43 | 62 |
44 bool CompositorOverlayCandidateValidatorAndroid::AllowCALayerOverlays() { | 63 bool CompositorOverlayCandidateValidatorAndroid::AllowCALayerOverlays() { |
45 return false; | 64 return false; |
46 } | 65 } |
47 | 66 |
48 // Overlays will still be allowed when software mirroring is enabled, even | 67 // Overlays will still be allowed when software mirroring is enabled, even |
49 // though they won't appear in the mirror. | 68 // though they won't appear in the mirror. |
50 void CompositorOverlayCandidateValidatorAndroid::SetSoftwareMirrorMode( | 69 void CompositorOverlayCandidateValidatorAndroid::SetSoftwareMirrorMode( |
51 bool enabled) {} | 70 bool enabled) {} |
52 | 71 |
| 72 void CompositorOverlayCandidateValidatorAndroid::ClearPromotableResources() { |
| 73 promotable_resources_.clear(); |
| 74 } |
| 75 |
| 76 bool CompositorOverlayCandidateValidatorAndroid::IsResourcePromotable( |
| 77 cc::ResourceId resource_id) { |
| 78 return promotable_resources_.count(resource_id) > 0; |
| 79 } |
| 80 |
53 } // namespace display_compositor | 81 } // namespace display_compositor |
OLD | NEW |