Index: components/display_compositor/compositor_overlay_candidate_validator_android.cc |
diff --git a/components/display_compositor/compositor_overlay_candidate_validator_android.cc b/components/display_compositor/compositor_overlay_candidate_validator_android.cc |
index 805dae3b917d7147b70e749309e068ab3518483e..3a58a1cb4001efb0c4f956ab0e1251a2edbf4bd5 100644 |
--- a/components/display_compositor/compositor_overlay_candidate_validator_android.cc |
+++ b/components/display_compositor/compositor_overlay_candidate_validator_android.cc |
@@ -7,8 +7,10 @@ |
#include <memory> |
#include "base/memory/ptr_util.h" |
+#include "cc/base/resource_id.h" |
#include "cc/output/overlay_processor.h" |
#include "cc/output/overlay_strategy_underlay.h" |
+#include "gpu/command_buffer/client/gles2_interface.h" |
#include "ui/gfx/geometry/rect_conversions.h" |
namespace display_compositor { |
@@ -34,6 +36,29 @@ void CompositorOverlayCandidateValidatorAndroid::CheckOverlaySupport( |
if (!candidates->empty()) { |
cc::OverlayCandidate& candidate = candidates->front(); |
+ |
+ // 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.
|
+ // multiple quads could share a resource, i think that would just make them |
+ // all not overlayable. we don't currently check for this, but we could. |
+ // maybe 'is_backed_by_surface_texture' should move to the resource. |
+ // TODO: should we send in a ResourceProvider here, so that it can ask if |
+ // the resource is backed by a surface texture or not, rather than store it |
+ // in the candidate? |
+ if (candidate.is_backed_by_surface_texture) { |
+ // This quad would be promoted if it were backed by a SurfaceView. Since |
+ // it isn't, we can't promote it. |
+ promotable_resources_.insert(candidate.resource_id); |
+ return; |
+ } |
+ |
+ // This quad will be promoted. We clear the promotable set here, since we |
+ // can only promote a single quad. Otherwise, somebody might try to back |
+ // one of the promotable quads with a SurfaceView, and either it or |quad| |
+ // would have to fall back to a texture. |
+ // We could re-insert |candidate.resource_id| back into the set, but the |
+ // quad that refers to it won't be in the list anyway after promotion. |
+ promotable_resources_.clear(); |
+ |
candidate.display_rect = |
gfx::RectF(gfx::ToEnclosingRect(candidate.display_rect)); |
candidate.overlay_handled = true; |
@@ -50,4 +75,13 @@ bool CompositorOverlayCandidateValidatorAndroid::AllowCALayerOverlays() { |
void CompositorOverlayCandidateValidatorAndroid::SetSoftwareMirrorMode( |
bool enabled) {} |
+void CompositorOverlayCandidateValidatorAndroid::ClearPromotableResources() { |
+ promotable_resources_.clear(); |
+} |
+ |
+bool CompositorOverlayCandidateValidatorAndroid::IsResourcePromotable( |
+ cc::ResourceId resource_id) { |
+ return promotable_resources_.count(resource_id) > 0; |
+} |
+ |
} // namespace display_compositor |