diff options
author | Mathias Agopian <mathias@google.com> | 2010-02-16 17:33:37 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-02-16 17:33:37 -0800 |
commit | 8f2423e8f394ae0666f1b61f83df4c0c7a4782d9 (patch) | |
tree | cf8ea7a6f5a60e1ff45b7eeb44c2a83576787161 /libs/surfaceflinger | |
parent | 4b71fc0fa8dee98764b55aefc176599bd982f53e (diff) | |
download | frameworks_base-8f2423e8f394ae0666f1b61f83df4c0c7a4782d9.zip frameworks_base-8f2423e8f394ae0666f1b61f83df4c0c7a4782d9.tar.gz frameworks_base-8f2423e8f394ae0666f1b61f83df4c0c7a4782d9.tar.bz2 |
get rid off the YUV formats at the libui layer
Diffstat (limited to 'libs/surfaceflinger')
-rw-r--r-- | libs/surfaceflinger/Layer.cpp | 18 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.cpp | 37 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerBase.h | 1 |
3 files changed, 35 insertions, 21 deletions
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp index f38efab..c080513 100644 --- a/libs/surfaceflinger/Layer.cpp +++ b/libs/surfaceflinger/Layer.cpp @@ -185,20 +185,20 @@ void Layer::reloadTexture(const Region& dirty) if (res == NO_ERROR) { int bpp = 0; switch (t.format) { - case GGL_PIXEL_FORMAT_RGB_565: - case GGL_PIXEL_FORMAT_RGBA_4444: + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_RGBA_4444: bpp = 2; break; - case GGL_PIXEL_FORMAT_RGBA_8888: - case GGL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: bpp = 4; break; - case GGL_PIXEL_FORMAT_YCbCr_422_SP: - case GGL_PIXEL_FORMAT_YCbCr_420_SP: - // just show the Y plane of YUV buffers - bpp = 1; - break; default: + if (isSupportedYuvFormat(t.format)) { + // just show the Y plane of YUV buffers + bpp = 1; + break; + } // oops, we don't handle this format! LOGE("layer %p, texture=%d, using format %d, which is not " "supported by the GL", this, texture->name, t.format); diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp index 4d7bef8..5b96e9d 100644 --- a/libs/surfaceflinger/LayerBase.cpp +++ b/libs/surfaceflinger/LayerBase.cpp @@ -509,6 +509,21 @@ void LayerBase::validateTexture(GLint textureName) const } } +bool LayerBase::isSupportedYuvFormat(int format) const +{ + switch (format) { + case HAL_PIXEL_FORMAT_YCbCr_422_SP: + case HAL_PIXEL_FORMAT_YCbCr_420_SP: + case HAL_PIXEL_FORMAT_YCbCr_422_P: + case HAL_PIXEL_FORMAT_YCbCr_420_P: + case HAL_PIXEL_FORMAT_YCbCr_422_I: + case HAL_PIXEL_FORMAT_YCbCr_420_I: + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + return true; + } + return false; +} + void LayerBase::loadTexture(Texture* texture, const Region& dirty, const GGLSurface& t) const { @@ -573,21 +588,20 @@ void LayerBase::loadTexture(Texture* texture, data = t.data; } - if (t.format == GGL_PIXEL_FORMAT_RGB_565) { + if (t.format == HAL_PIXEL_FORMAT_RGB_565) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture->potWidth, texture->potHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data); - } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) { + } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->potWidth, texture->potHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data); - } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 || - t.format == GGL_PIXEL_FORMAT_RGBX_8888) { + } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 || + t.format == HAL_PIXEL_FORMAT_RGBX_8888) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->potWidth, texture->potHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); - } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP || - t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) { + } else if (isSupportedYuvFormat(t.format)) { // just show the Y plane of YUV buffers glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, texture->potWidth, texture->potHeight, 0, @@ -599,24 +613,23 @@ void LayerBase::loadTexture(Texture* texture, } } if (!data) { - if (t.format == GGL_PIXEL_FORMAT_RGB_565) { + if (t.format == HAL_PIXEL_FORMAT_RGB_565) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, bounds.top, t.width, bounds.height(), GL_RGB, GL_UNSIGNED_SHORT_5_6_5, t.data + bounds.top*t.stride*2); - } else if (t.format == GGL_PIXEL_FORMAT_RGBA_4444) { + } else if (t.format == HAL_PIXEL_FORMAT_RGBA_4444) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, bounds.top, t.width, bounds.height(), GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, t.data + bounds.top*t.stride*2); - } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 || - t.format == GGL_PIXEL_FORMAT_RGBX_8888) { + } else if (t.format == HAL_PIXEL_FORMAT_RGBA_8888 || + t.format == HAL_PIXEL_FORMAT_RGBX_8888) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, bounds.top, t.width, bounds.height(), GL_RGBA, GL_UNSIGNED_BYTE, t.data + bounds.top*t.stride*4); - } else if ( t.format == GGL_PIXEL_FORMAT_YCbCr_422_SP || - t.format == GGL_PIXEL_FORMAT_YCbCr_420_SP) { + } else if (isSupportedYuvFormat(t.format)) { // just show the Y plane of YUV buffers glTexSubImage2D(GL_TEXTURE_2D, 0, 0, bounds.top, t.width, bounds.height(), diff --git a/libs/surfaceflinger/LayerBase.h b/libs/surfaceflinger/LayerBase.h index a49faf7..d1bbd04 100644 --- a/libs/surfaceflinger/LayerBase.h +++ b/libs/surfaceflinger/LayerBase.h @@ -265,6 +265,7 @@ protected: status_t initializeEglImage( const sp<GraphicBuffer>& buffer, Texture* texture); + bool isSupportedYuvFormat(int format) const; sp<SurfaceFlinger> mFlinger; uint32_t mFlags; |