hwc/copybit: Handle "R/B swap" for RGBA and RGBX color formats.
1.Framework notifies HAL with "HWC_FORMAT_RB_SWAP" layer flag to handle
a limitation where R and B components were swapped in Rendering phase.
2.Add "R/B swap" in hwc query to enable framework to query for support
in display HAL, at run-time.
Change-Id: I3b44d15b51b4f24939048fee9d1bac2b9009c97c
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 47afa85..e5c5a41 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -1385,6 +1385,14 @@
Whf whf(hnd->width, hnd->height,
getMdpFormat(hnd->format), hnd->size);
+ // Handle R/B swap
+ if (layer->flags & HWC_FORMAT_RB_SWAP) {
+ if (hnd->format == HAL_PIXEL_FORMAT_RGBA_8888)
+ whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRA_8888);
+ else if (hnd->format == HAL_PIXEL_FORMAT_RGBX_8888)
+ whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRX_8888);
+ }
+
if(dpy && isYuvBuffer(hnd)) {
if(!ctx->listStats[dpy].isDisplayAnimating) {
ctx->mPrevCropVideo = crop;
@@ -1508,6 +1516,14 @@
Whf whf(hnd->width, hnd->height,
getMdpFormat(hnd->format), hnd->size);
+ // Handle R/B swap
+ if (layer->flags & HWC_FORMAT_RB_SWAP) {
+ if (hnd->format == HAL_PIXEL_FORMAT_RGBA_8888)
+ whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRA_8888);
+ else if (hnd->format == HAL_PIXEL_FORMAT_RGBX_8888)
+ whf.format = getMdpFormat(HAL_PIXEL_FORMAT_BGRX_8888);
+ }
+
if(dpy && isYuvBuffer(hnd)) {
if(!ctx->listStats[dpy].isDisplayAnimating) {
ctx->mPrevCropVideo = crop;