Add RGBA8888 format support for EGL tizen sfc ext 30/89730/1 accepted/tizen/3.0/ivi/20161011.044041 accepted/tizen/3.0/mobile/20161015.033105 accepted/tizen/3.0/tv/20161016.004518 accepted/tizen/3.0/wearable/20161015.082722 accepted/tizen/common/20160928.164441 accepted/tizen/ivi/20160929.002229 accepted/tizen/mobile/20160929.002032 accepted/tizen/tv/20160929.002155 accepted/tizen/wearable/20160929.002318 submit/tizen/20160928.075844 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000002 submit/tizen_3.0_mobile/20161015.000002 submit/tizen_3.0_tv/20161015.000002 submit/tizen_3.0_wearable/20161015.000002
authorVasiliy Ulyanov <v.ulyanov@samsung.com>
Mon, 26 Sep 2016 13:04:15 +0000 (16:04 +0300)
committerVasiliy Ulyanov <v.ulyanov@samsung.com>
Mon, 26 Sep 2016 13:04:15 +0000 (16:04 +0300)
This format requires convertion to ARGB.

Change-Id: Ia9ade3d84b3d061c5f713457e6ac0e2cbae31418
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
EGL/yagl_onscreen_image_tizen_sfc.c
EGL/yagl_onscreen_image_tizen_sfc.h

index 925d14ecfa688902b848329c8762b8290baced0b..b30bdf1125446435617fdadc6a01c17130e1c412 100644 (file)
 #include <tbm_surface_internal.h>
 #include <string.h>
 
+static inline uint32_t rgba2argb(uint32_t rgba)
+{
+    return ((rgba & 0xff) << 24) | (rgba >> 8);
+}
+
 static inline uint32_t yuv2argb(float y, float u, float v)
 {
     int32_t r, g, b;
@@ -74,7 +79,7 @@ static bool yagl_onscreen_image_tizen_sfc_convert(struct yagl_onscreen_image_tiz
 
     YAGL_LOG_FUNC_SET(yagl_onscreen_image_tizen_sfc_convert);
 
-    if (!image->planar) {
+    if (!image->need_convert) {
         return true;
     }
 
@@ -97,6 +102,15 @@ static bool yagl_onscreen_image_tizen_sfc_convert(struct yagl_onscreen_image_tiz
     dst += info.width * info.height - info.width;
 
     switch (info.format) {
+    case TBM_FORMAT_RGBA8888:
+        for (i = 0; i < info.height; i++) {
+            for (j = 0; j < info.width; j++) {
+                uint32_t rgba = ((uint32_t *)info.planes[0].ptr)[i * info.width + j];
+
+                *(dst - i * info.width + j) = rgba2argb(rgba);
+            }
+        }
+        break;
     case TBM_FORMAT_NV21:
         for (i = 0; i < info.height; i++) {
             for (j = 0; j < info.width; j++) {
@@ -166,7 +180,7 @@ struct yagl_onscreen_image_tizen_sfc
     tbm_surface_h sfc;
     tbm_bo bo;
     tbm_surface_info_s info;
-    bool planar;
+    bool need_convert;
     int ret;
 
     YAGL_LOG_FUNC_SET(yagl_onscreen_image_tizen_sfc_create);
@@ -187,11 +201,12 @@ struct yagl_onscreen_image_tizen_sfc
         case TBM_FORMAT_RGB888:
         case TBM_FORMAT_ARGB8888:
         case TBM_FORMAT_XRGB8888:
-            planar = false;
+            need_convert = false;
             break;
+        case TBM_FORMAT_RGBA8888:
         case TBM_FORMAT_NV21:
         case TBM_FORMAT_YUV420:
-            planar = true;
+            need_convert = true;
             break;
         default:
             YAGL_LOG_ERROR("bad format: 0x%X", info.format);
@@ -199,7 +214,7 @@ struct yagl_onscreen_image_tizen_sfc
             goto fail;
     }
 
-    if (planar) {
+    if (need_convert) {
         ret = vigs_drm_surface_create(dpy->native_dpy->drm_dev,
                                       info.width,
                                       info.height,
@@ -271,15 +286,15 @@ struct yagl_onscreen_image_tizen_sfc
 
     image->base.update = &yagl_onscreen_image_tizen_sfc_update;
     image->sfc = sfc;
-    image->planar = planar;
+    image->need_convert = need_convert;
     image->drm_sfc = drm_sfc;
 
-    YAGL_LOG_DEBUG("%ux%u/%u, sfc_id = %u, planar = %d (0x%X), num_planes = %u, size = %u",
+    YAGL_LOG_DEBUG("%ux%u/%u, sfc_id = %u, need_convert = %d (0x%X), num_planes = %u, size = %u",
                    info.width,
                    info.height,
                    info.bpp,
                    drm_sfc->id,
-                   planar,
+                   need_convert,
                    info.format,
                    info.num_planes,
                    info.size);
index ccd3a3985ad2e0badd0a9cdd0bfd4c664424aa47..7da39fe757a56a54b4237c19ff244d2a3713a0d5 100644 (file)
@@ -47,7 +47,7 @@ struct yagl_onscreen_image_tizen_sfc
 
     tbm_surface_h sfc;
 
-    bool planar;
+    bool need_convert;
 
     struct vigs_drm_surface *drm_sfc;
 };