From d5cda531d239b1311c3c4eed3abf7b21da15e650 Mon Sep 17 00:00:00 2001 From: Nobuhiko Tanibata Date: Mon, 28 Jul 2014 17:57:16 +0900 Subject: ivi-shell: Add IVI layout APIs - ivi_layout_surfaceGetWestonSurface - ivi_layout_surfaceGetSize These are used by screenshot APIs. Signed-off-by: Nobuhiko Tanibata --- ivi-shell/ivi-layout-export.h | 6 ++++ ivi-shell/ivi-layout.c | 80 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/ivi-shell/ivi-layout-export.h b/ivi-shell/ivi-layout-export.h index ea1adea2..f0654f1f 100644 --- a/ivi-shell/ivi-layout-export.h +++ b/ivi-shell/ivi-layout-export.h @@ -908,6 +908,12 @@ ivi_layout_surfaceSetSourceRectangle(struct ivi_layout_surface *ivisurf, struct weston_output * ivi_layout_screenGetOutput(struct ivi_layout_screen *); +struct weston_surface * +ivi_layout_surfaceGetWestonSurface(struct ivi_layout_surface *ivisurf); + +int32_t +ivi_layout_surfaceGetSize(struct ivi_layout_surface *ivisurf, int32_t *width, int32_t *height, int32_t *stride); + int32_t ivi_layout_layerSetTransition(struct ivi_layout_layer *ivilayer, enum ivi_layout_transition_type type, diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index d8aa2e6f..e2a3f082 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -2658,6 +2658,86 @@ ivi_layout_screenGetOutput(struct ivi_layout_screen *iviscrn) return iviscrn->output; } +WL_EXPORT struct weston_surface * +ivi_layout_surfaceGetWestonSurface(struct ivi_layout_surface *ivisurf) +{ + return ivisurf != NULL ? ivisurf->surface : NULL; +} + +static int32_t +surfaceGetBitPerPixel(struct ivi_layout_surface *ivisurf) +{ + int32_t bpp = 0; + + if (ivisurf == NULL) { + return bpp; + } + + switch (ivisurf->pixelformat) { + case IVI_LAYOUT_SURFACE_PIXELFORMAT_R_8: + bpp = 8; + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_RGB_888: + bpp = 24; + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_RGBA_8888: + bpp = 32; + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_RGB_565: + bpp = 16; + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_RGBA_5551: + bpp = 16; + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_RGBA_6661: + bpp = 0; // 19 + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_RGBA_4444: + bpp = 16; + break; + + case IVI_LAYOUT_SURFACE_PIXELFORMAT_UNKNOWN: + default: + bpp = 0; + break; + } + + return bpp; +} + +WL_EXPORT int32_t +ivi_layout_surfaceGetSize(struct ivi_layout_surface *ivisurf, int32_t *width, int32_t *height, int32_t *stride) +{ + if (ivisurf == NULL) { + return -1; + } + + if (width != NULL) { + *width = ivisurf->prop.sourceWidth; + } + + if (height != NULL) { + *height = ivisurf->prop.sourceHeight; + } + + if (stride != NULL) { + int32_t bpp = surfaceGetBitPerPixel(ivisurf); + if ((bpp == 0) ||(bpp % 8 != 0)) { + return -1; + } + + *stride = ivisurf->prop.sourceWidth * (bpp / 8); + } + + return 0; +} + WL_EXPORT int32_t ivi_layout_SetOptimizationMode(uint32_t id, int32_t mode) { -- cgit v1.2.1