summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Ulyanov <v.ulyanov@samsung.com>2016-09-26 16:04:15 +0300
committerVasiliy Ulyanov <v.ulyanov@samsung.com>2016-09-26 16:04:15 +0300
commit4ecc2a1f8364bc7becbeea7d9b4812975de6b64d (patch)
tree9a20b816479d202393d95aca219ff2ff70eb54e7
parentff9555ba17932b7f24f6eae8fa412640c7702167 (diff)
downloademulator-yagl-4ecc2a1f8364bc7becbeea7d9b4812975de6b64d.tar.gz
emulator-yagl-4ecc2a1f8364bc7becbeea7d9b4812975de6b64d.tar.bz2
emulator-yagl-4ecc2a1f8364bc7becbeea7d9b4812975de6b64d.zip
This format requires convertion to ARGB. Change-Id: Ia9ade3d84b3d061c5f713457e6ac0e2cbae31418 Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
-rw-r--r--EGL/yagl_onscreen_image_tizen_sfc.c31
-rw-r--r--EGL/yagl_onscreen_image_tizen_sfc.h2
2 files changed, 24 insertions, 9 deletions
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.c b/EGL/yagl_onscreen_image_tizen_sfc.c
index 925d14e..b30bdf1 100644
--- a/EGL/yagl_onscreen_image_tizen_sfc.c
+++ b/EGL/yagl_onscreen_image_tizen_sfc.c
@@ -48,6 +48,11 @@
#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);
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.h b/EGL/yagl_onscreen_image_tizen_sfc.h
index ccd3a39..7da39fe 100644
--- a/EGL/yagl_onscreen_image_tizen_sfc.h
+++ b/EGL/yagl_onscreen_image_tizen_sfc.h
@@ -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;
};