summaryrefslogtreecommitdiffstats
path: root/libs/ui/PixelFormat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ui/PixelFormat.cpp')
-rw-r--r--libs/ui/PixelFormat.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/libs/ui/PixelFormat.cpp b/libs/ui/PixelFormat.cpp
index 605c8ae..b65ed97 100644
--- a/libs/ui/PixelFormat.cpp
+++ b/libs/ui/PixelFormat.cpp
@@ -19,6 +19,18 @@
namespace android {
+size_t PixelFormatInfo::getScanlineSize(unsigned int width) const
+{
+ size_t size;
+ if ((components >= 6) && (components <= 8)) {
+ // YCbCr formats are differents.
+ size = (width * bitsPerPixel)>>3;
+ } else {
+ size = width * bytesPerPixel;
+ }
+ return size;
+}
+
ssize_t bytesPerPixel(PixelFormat format)
{
PixelFormatInfo info;
@@ -47,7 +59,25 @@ status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info)
if (!valid) {
return BAD_INDEX;
}
-
+
+ #define COMPONENT(name) \
+ case GGL_##name: info->components = PixelFormatInfo::name; break;
+
+ switch (i->components) {
+ COMPONENT(ALPHA)
+ COMPONENT(RGB)
+ COMPONENT(RGBA)
+ COMPONENT(LUMINANCE)
+ COMPONENT(LUMINANCE_ALPHA)
+ COMPONENT(Y_CB_CR_SP)
+ COMPONENT(Y_CB_CR_P)
+ COMPONENT(Y_CB_CR_I)
+ default:
+ return BAD_INDEX;
+ }
+
+ #undef COMPONENT
+
info->format = format;
info->bytesPerPixel = i->size;
info->bitsPerPixel = i->bitsPerPixel;
@@ -59,6 +89,7 @@ status_t getPixelFormatInfo(PixelFormat format, PixelFormatInfo* info)
info->l_green = i->gl;
info->h_blue = i->bh;
info->l_blue = i->bl;
+
return NO_ERROR;
}