diff --git a/libqcomui/qcom_ui.cpp b/libqcomui/qcom_ui.cpp index 7372c06..725c13f 100644 --- a/libqcomui/qcom_ui.cpp +++ b/libqcomui/qcom_ui.cpp @@ -37,6 +37,10 @@ #include #include +#include +#include +#include + using gralloc::IMemAlloc; using gralloc::IonController; using gralloc::alloc_data; @@ -144,6 +148,33 @@ bool isGPUSupportedFormat(int format) { return true; } +/* decide the texture target dynamically, based on the pixel format*/ + +int decideTextureTarget(int pixel_format) +{ + + // Default the return value to GL_TEXTURE_EXTERAL_OES + int retVal = GL_TEXTURE_EXTERNAL_OES; + + // Change texture target to TEXTURE_2D for RGB formats + switch (pixel_format) { + + case HAL_PIXEL_FORMAT_RGBA_8888: + case HAL_PIXEL_FORMAT_RGBX_8888: + case HAL_PIXEL_FORMAT_RGB_888: + case HAL_PIXEL_FORMAT_RGB_565: + case HAL_PIXEL_FORMAT_BGRA_8888: + case HAL_PIXEL_FORMAT_RGBA_5551: + case HAL_PIXEL_FORMAT_RGBA_4444: + retVal = GL_TEXTURE_2D; + break; + default: + retVal = GL_TEXTURE_EXTERNAL_OES; + break; + } + return retVal; +} + /* * Checks if the format is natively supported by the GPU. * For now, we use this function to check only if CHECK_FOR_EXTERNAL_FORMAT diff --git a/libqcomui/qcom_ui.h b/libqcomui/qcom_ui.h index 32e5ceb..c79286d 100644 --- a/libqcomui/qcom_ui.h +++ b/libqcomui/qcom_ui.h @@ -134,6 +134,22 @@ bool isGPUSupportedFormat(int format); */ bool isGPUSupportedFormatInHW(int format); +/* + * Adreno is not optimized for GL_TEXTURE_EXTERNAL_OES + * texure target. DO NOT choose TEXTURE_EXTERNAL_OES + * target for RGB formats. + * + * Based on the pixel format, decide the texture target. + * + * @param : pixel format to check + * + * @return : GL_TEXTURE_2D for RGB formats, and + * GL_TEXTURE_EXTERNAL_OES for YUV formats. + * +*/ + +int decideTextureTarget (const int pixel_format); + /* * Gets the number of arguments required for this operation. *