diff options
-rw-r--r-- | EGL/yagl_onscreen_image_tizen_sfc.c | 39 | ||||
-rw-r--r-- | EGL/yagl_onscreen_image_tizen_sfc.h | 2 |
2 files changed, 36 insertions, 5 deletions
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.c b/EGL/yagl_onscreen_image_tizen_sfc.c index 031d4a0..3a33a79 100644 --- a/EGL/yagl_onscreen_image_tizen_sfc.c +++ b/EGL/yagl_onscreen_image_tizen_sfc.c @@ -41,6 +41,7 @@ #include "yagl_state.h" #include "yagl_client_interface.h" #include "yagl_client_image.h" +#include "drm_fourcc.h" #include "vigs.h" #include <tbm_bufmgr.h> #include <tbm_bufmgr_backend.h> @@ -68,7 +69,6 @@ static inline uint32_t yuv2argb(float y, float u, float v) return (0xff000000 | (r << 16) | (g << 8) | b); } -/* TODO need to think about HW convertion */ static bool yagl_onscreen_image_tizen_sfc_convert(struct yagl_onscreen_image_tizen_sfc *image) { uint32_t *dst; @@ -79,10 +79,6 @@ 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->need_convert) { - return true; - } - ret = tbm_surface_map(image->sfc, TBM_SURF_OPTION_READ, &info); if (ret != TBM_SURFACE_ERROR_NONE) { @@ -160,6 +156,38 @@ static void yagl_onscreen_image_tizen_sfc_update(struct yagl_image *image) struct yagl_onscreen_image_tizen_sfc *tizen_sfc_image = (struct yagl_onscreen_image_tizen_sfc *)image; + YAGL_LOG_FUNC_SET(yagl_onscreen_image_tizen_sfc_update); + + if (!tizen_sfc_image->need_convert) { + return; + } + + if (tizen_sfc_image->format == TBM_FORMAT_ARGB8888) { + tbm_bo bo = tbm_surface_internal_get_bo(tizen_sfc_image->sfc, 0); + struct vigs_drm_surface *src = bo ? tbm_backend_get_bo_priv(bo) : NULL; + int ret; + + /* + * No actual format conversion in ARGB8888 case. We just need to + * y-invert the image. + */ + ret = vigs_drm_surface_convert(src, + DRM_FORMAT_ARGB8888, + tizen_sfc_image->drm_sfc, + DRM_FORMAT_ARGB8888, + true); + + if (ret == 0) { + return; + } + + YAGL_LOG_ERROR("vigs_drm_surface_convert failed %s\n", strerror(-ret)); + + /* + * Fallback to software converson in case of error. + */ + } + yagl_onscreen_image_tizen_sfc_convert(tizen_sfc_image); } @@ -297,6 +325,7 @@ struct yagl_onscreen_image_tizen_sfc image->sfc = sfc; image->need_convert = need_convert; image->drm_sfc = drm_sfc; + image->format = info.format; YAGL_LOG_DEBUG("%ux%u/%u, sfc_id = %u, need_convert = %d (0x%X), num_planes = %u, size = %u", info.width, diff --git a/EGL/yagl_onscreen_image_tizen_sfc.h b/EGL/yagl_onscreen_image_tizen_sfc.h index 7da39fe..e7af41b 100644 --- a/EGL/yagl_onscreen_image_tizen_sfc.h +++ b/EGL/yagl_onscreen_image_tizen_sfc.h @@ -50,6 +50,8 @@ struct yagl_onscreen_image_tizen_sfc bool need_convert; struct vigs_drm_surface *drm_sfc; + + uint32_t format; }; struct yagl_onscreen_image_tizen_sfc |