summaryrefslogtreecommitdiffstats
path: root/libs/ui/PixelFormat.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:44:00 -0800
commitd24b8183b93e781080b2c16c487e60d51c12da31 (patch)
treefbb89154858984eb8e41556da7e9433040d55cd4 /libs/ui/PixelFormat.cpp
parentf1e484acb594a726fb57ad0ae4cfe902c7f35858 (diff)
downloadframeworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.zip
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.gz
frameworks_base-d24b8183b93e781080b2c16c487e60d51c12da31.tar.bz2
auto import from //branches/cupcake/...@130745
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;
}