Skip to content
Snippets Groups Projects
Commit 53e522c4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Add ColorLayer support to hardware/qcom/display on ICS chocolate"

parents 1be4b38f d7b5decf
No related branches found
No related tags found
No related merge requests found
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp
index 6b91711..1787c57 100644
--- a/libcopybit/copybit.cpp
+++ b/libcopybit/copybit.cpp
@@ -479,6 +479,49 @@ static int blit_copybit(
return stretch_copybit(dev, dst, src, &dr, &sr, region);
}
+/** Fill the rect on dst with rgba color **/
+static int fill_color(struct copybit_device_t *dev,
+ struct copybit_image_t const *dst,
+ struct copybit_rect_t const *rect,
+ uint32_t color)
+{
+ struct copybit_context_t* ctx = (struct copybit_context_t*)dev;
+ if (!ctx) {
+ LOGE ("%s: Invalid copybit context", __FUNCTION__);
+ return -EINVAL;
+ }
+
+ if (dst->w > MAX_DIMENSION || dst->h > MAX_DIMENSION) {
+ LOGE ("fill_color: Invalid DST w=%d h=%d", dst->w, dst->h);
+ return -EINVAL;
+ }
+
+ struct {
+ uint32_t count;
+ struct mdp_blit_req req[1];
+ } list;
+
+ list.count = 1;
+ mdp_blit_req* req = &list.req[0];
+ set_image(&req->dst, dst);
+ req->dst_rect.x = rect->l;
+ req->dst_rect.y = rect->t;
+ req->dst_rect.w = rect->r - rect->l;
+ req->dst_rect.h = rect->b - rect->t;
+ req->const_color.alpha = (uint32_t)((color >> 24) & 0xff);
+ if (req->const_color.alpha == 0)
+ return -EINVAL;
+ req->const_color.b = (uint32_t)((color >> 16) & 0xff);
+ req->const_color.g = (uint32_t)((color >> 8) & 0xff);
+ req->const_color.r = (uint32_t)((color >> 0) & 0xff);
+ req->alpha = MDP_ALPHA_NOP;
+ req->transp_mask = MDP_TRANSP_NOP;
+ req->flags = CONST_COLOR;
+
+ int status = msm_copybit(ctx, &list);
+ return status;
+}
+
/*****************************************************************************/
/** Close the copybit device */
@@ -509,6 +552,7 @@ static int open_copybit(const struct hw_module_t* module, const char* name,
ctx->device.get = get;
ctx->device.blit = blit_copybit;
ctx->device.stretch = stretch_copybit;
+ ctx->device.fill = fill_color;
ctx->mAlpha = MDP_ALPHA_NOP;
ctx->mFlags = 0;
ctx->mFD = open("/dev/graphics/fb0", O_RDWR, 0);
diff --git a/libcopybit/copybit.h b/libcopybit/copybit.h
index e6c55e0..7f9b8ef 100644
--- a/libcopybit/copybit.h
+++ b/libcopybit/copybit.h
@@ -209,8 +209,22 @@ struct copybit_device_t {
struct copybit_rect_t const *dst_rect,
struct copybit_rect_t const *src_rect,
struct copybit_region_t const *region);
-};
+ /**
+ * Fill the rect on dst with rgba color
+ *
+ * @param dev from open
+ * @param dst is destination image
+ * @param rect is destination rectangle
+ * @param color is the color to fill
+ *
+ * @return 0 if successful
+ */
+ int (*fill)(struct copybit_device_t *dev,
+ struct copybit_image_t const *dst,
+ struct copybit_rect_t const *rect,
+ uint32_t color);
+};
/** convenience API for opening and closing a device */
diff --git a/libcopybit/copybit_c2d.cpp b/libcopybit/copybit_c2d.cpp
index 1d43554..420a730 100644
--- a/libcopybit/copybit_c2d.cpp
+++ b/libcopybit/copybit_c2d.cpp
@@ -1292,6 +1292,16 @@ static int blit_copybit(
return stretch_copybit_internal(dev, dst, src, &dr, &sr, region, false);
}
+/** Fill the rect on dst with rgba color **/
+static int fill_color(struct copybit_device_t *dev,
+ struct copybit_image_t const *dst,
+ struct copybit_rect_t const *rect,
+ uint32_t color)
+{
+ // TODO: Impl. once c2d driver supports color fill.
+ return -EINVAL;
+}
+
/*****************************************************************************/
/** Close the copybit device */
diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp
index 11397d4..1d4a92c 100755
--- a/libhwcomposer/hwcomposer.cpp
+++ b/libhwcomposer/hwcomposer.cpp
@@ -1234,6 +1234,38 @@ private:
mutable range r;
};
+static int fillColorUsingCopybit(copybit_device_t *copybit, hwc_layer_t *layer,
+ EGLDisplay dpy, EGLSurface surface)
+{
+ android_native_buffer_t *renderBuffer =
+ (android_native_buffer_t *)eglGetRenderBufferANDROID(dpy, surface);
+ if (!renderBuffer) {
+ LOGE("%s: eglGetRenderBufferANDROID returned NULL buffer", __FUNCTION__);
+ return -1;
+ }
+
+ private_handle_t *fbHandle = (private_handle_t *)renderBuffer->handle;
+ if(!fbHandle) {
+ LOGE("%s: Framebuffer handle is NULL", __FUNCTION__);
+ return -1;
+ }
+
+ uint32_t color = layer->transform;
+ hwc_rect_t displayFrame = layer->displayFrame;
+ copybit_rect_t dstRect = {displayFrame.left, displayFrame.top,
+ displayFrame.right, displayFrame.bottom};
+
+ copybit_image_t dst;
+ dst.w = ALIGN(fbHandle->width,32);
+ dst.h = fbHandle->height;
+ dst.format = fbHandle->format;
+ dst.base = (void *)fbHandle->base;
+ dst.handle = (native_handle_t *)renderBuffer->handle;
+
+ int res = copybit->fill(copybit, &dst, &dstRect, color);
+ return res;
+}
+
static int drawLayerUsingCopybit(hwc_composer_device_t *dev, hwc_layer_t *layer, EGLDisplay dpy,
EGLSurface surface)
{
@@ -1251,6 +1283,11 @@ static int drawLayerUsingCopybit(hwc_composer_device_t *dev, hwc_layer_t *layer,
private_handle_t *hnd = (private_handle_t *)layer->handle;
if(!hnd) {
+ if (layer->flags & HWC_COLOR_FILL) {
+ copybit_device_t *copybit = hwcModule->copybitEngine;
+ int res = fillColorUsingCopybit(copybit, layer, dpy, surface);
+ return res;
+ }
LOGE("drawLayerUsingCopybit invalid handle");
return -1;
}
diff --git a/libqcomui/qcom_ui.h b/libqcomui/qcom_ui.h
index b1ad528..2dbe156 100755
--- a/libqcomui/qcom_ui.h
+++ b/libqcomui/qcom_ui.h
@@ -85,6 +85,7 @@ enum {
enum {
HWC_LAYER_NOT_UPDATING = 0x00000002,
HWC_LAYER_ASYNCHRONOUS = 0x00000004,
+ HWC_COLOR_FILL = 0x00000008, //RGBA color-fill using copybit
HWC_USE_ORIGINAL_RESOLUTION = 0x10000000,
HWC_DO_NOT_USE_OVERLAY = 0x20000000,
HWC_COMP_BYPASS = 0x40000000,
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment