summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2015-11-24 16:52:37 (GMT)
committerSean Paul <seanpaul@google.com>2015-11-24 18:09:26 (GMT)
commitb1008373244ff109cadb8b5d443e95d98d034124 (patch)
tree1a8b44afb3b5bafbe8a992fe81435c29760d7ffc
parent4fdafe6d988b5cac91b5448e197891508b5e6e2d (diff)
downloaddrm_hwcomposer-b1008373244ff109cadb8b5d443e95d98d034124.tar.gz
drm_hwcomposer-b1008373244ff109cadb8b5d443e95d98d034124.tar.xz
drm_hwcomposer: Skip layers which aren't on-screen
Don't composite layers whose bounds are entirely off screen, or which have width or height of 0. Bug: chrome-os-partner:47938 Test: Swipe between videos in Google Photos Change-Id: I29671db6763caf3cb764b06d1ff955276ebecd80 Signed-off-by: Sean Paul <seanpaul@chromium.org>
-rw-r--r--hwcomposer.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/hwcomposer.cpp b/hwcomposer.cpp
index c6f636b..3d39f6e 100644
--- a/hwcomposer.cpp
+++ b/hwcomposer.cpp
@@ -328,14 +328,16 @@ static int hwc_prepare(hwc_composer_device_1_t *dev, size_t num_displays,
continue;
bool use_framebuffer_target = false;
+ DrmMode mode;
if (i == HWC_DISPLAY_VIRTUAL) {
use_framebuffer_target = true;
} else {
- DrmCrtc *crtc = ctx->drm.GetCrtcForDisplay(i);
- if (!crtc) {
- ALOGE("No crtc for display %d", i);
+ DrmConnector *c = ctx->drm.GetConnectorForDisplay(i);
+ if (!c) {
+ ALOGE("Failed to get DrmConnector for display %d", i);
return -ENODEV;
}
+ mode = c->active_mode();
}
// Since we can't composite HWC_SKIP_LAYERs by ourselves, we'll let SF
@@ -358,6 +360,16 @@ static int hwc_prepare(hwc_composer_device_1_t *dev, size_t num_displays,
hwc_layer_1_t *layer = &display_contents[i]->hwLayers[j];
if (!use_framebuffer_target && !hwc_skip_layer(skip_layer_indices, j)) {
+ // If the layer is off the screen, don't earmark it for an overlay.
+ // We'll leave it as-is, which effectively just drops it from the frame
+ const hwc_rect_t *frame = &layer->displayFrame;
+ if ((frame->right - frame->left) <= 0 ||
+ (frame->bottom - frame->top) <= 0 ||
+ frame->right <= 0 || frame->bottom <= 0 ||
+ frame->left >= (int)mode.h_display() ||
+ frame->top >= (int)mode.v_display())
+ continue;
+
if (layer->compositionType == HWC_FRAMEBUFFER)
layer->compositionType = HWC_OVERLAY;
} else {