Skip to content

Commit

Permalink
hwc: Return failure code if hwc_set fails to draw
Browse files Browse the repository at this point in the history
Check for errors while drawing the layers in hwc_set.

Return -1 in the error case so that framework doesn't wait on fences.

Bug: 7284105
Change-Id: I024f9ca07faf64d6b90d4f483164dc15c0d7992c
Signed-off-by: Iliyan Malchev <[email protected]>
  • Loading branch information
Saurabh Shah authored and Iliyan Malchev committed Oct 15, 2012
1 parent 40a1cc5 commit eaf6791
Showing 1 changed file with 29 additions and 9 deletions.
38 changes: 29 additions & 9 deletions libhwcomposer/hwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,27 +254,38 @@ static int hwc_query(struct hwc_composer_device_1* dev,
}

static int hwc_set_primary(hwc_context_t *ctx, hwc_display_contents_1_t* list) {
int ret = 0;

if (LIKELY(list && list->numHwLayers > 1) &&
ctx->dpyAttr[HWC_DISPLAY_PRIMARY].isActive) {
uint32_t last = list->numHwLayers - 1;
hwc_layer_1_t *fbLayer = &list->hwLayers[last];

hwc_sync(ctx, list, HWC_DISPLAY_PRIMARY);

VideoOverlay::draw(ctx, list, HWC_DISPLAY_PRIMARY);
MDPComp::draw(ctx, list);

if (!VideoOverlay::draw(ctx, list, HWC_DISPLAY_PRIMARY)) {
ALOGE("%s: VideoOverlay::draw fail!", __FUNCTION__);
ret = -1;
}
if (MDPComp::draw(ctx, list)) {
ALOGE("%s: MDPComp::draw fail!", __FUNCTION__);
ret = -1;
}
//TODO We dont check for SKIP flag on this layer because we need PAN
//always. Last layer is always FB
if(list->hwLayers[last].compositionType == HWC_FRAMEBUFFER_TARGET) {
ctx->mFbDev->post(ctx->mFbDev, fbLayer->handle);
if (ctx->mFbDev->post(ctx->mFbDev, fbLayer->handle)) {
ALOGE("%s: ctx->mFbDev->post fail!", __FUNCTION__);
return -1;
}
}
}
return 0;
return ret;
}

static int hwc_set_external(hwc_context_t *ctx,
hwc_display_contents_1_t* list) {
int ret = 0;
Locker::Autolock _l(ctx->mExtSetLock);

if (LIKELY(list && list->numHwLayers > 1) &&
Expand All @@ -285,16 +296,25 @@ static int hwc_set_external(hwc_context_t *ctx,

hwc_sync(ctx, list, HWC_DISPLAY_EXTERNAL);

VideoOverlay::draw(ctx, list, HWC_DISPLAY_EXTERNAL);
if (!VideoOverlay::draw(ctx, list, HWC_DISPLAY_EXTERNAL)) {
ALOGE("%s: VideoOverlay::draw fail!", __FUNCTION__);
ret = -1;
}

private_handle_t *hnd = (private_handle_t *)fbLayer->handle;
if(fbLayer->compositionType == HWC_FRAMEBUFFER_TARGET &&
!(fbLayer->flags & HWC_SKIP_LAYER) && hnd) {
UIMirrorOverlay::draw(ctx, fbLayer);
if (!UIMirrorOverlay::draw(ctx, fbLayer)) {
ALOGE("%s: UIMirrorOverlay::draw fail!", __FUNCTION__);
ret = -1;
}
}
if (!ctx->mExtDisplay->post()) {
ALOGE("%s: ctx->mExtDisplay->post fail!", __FUNCTION__);
return -1;
}
ctx->mExtDisplay->post();
}
return 0;
return ret;
}

static int hwc_set(hwc_composer_device_1 *dev,
Expand Down

0 comments on commit eaf6791

Please sign in to comment.