diff options
author | Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp> | 2014-07-28 17:57:16 +0900 |
---|---|---|
committer | Nobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp> | 2014-08-21 13:34:55 +0900 |
commit | e881b106681c6e45257579024e524ee3f6d8a928 (patch) | |
tree | 12bbe8eec98ea6d959b59c2f96747d1a70cad9b5 | |
parent | cf8530166be34ebc6a8ad22abee55122af013975 (diff) | |
download | weston-e881b106681c6e45257579024e524ee3f6d8a928.tar.gz |
ivi-shell: Add IVI layout APIs
- ivi_layout_surfaceGetWestonSurface
- ivi_layout_surfaceGetSize
These are used by screenshot APIs.
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
-rw-r--r-- | ivi-shell/ivi-layout-export.h | 6 | ||||
-rw-r--r-- | ivi-shell/ivi-layout.c | 80 |
2 files changed, 86 insertions, 0 deletions
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 5e9c1d72..0244072f 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -2663,6 +2663,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) { |