diff --git a/libqcomui/Android.mk b/libqcomui/Android.mk index 5a39681..c60f18b 100644 --- a/libqcomui/Android.mk +++ b/libqcomui/Android.mk @@ -4,6 +4,10 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ qcom_ui.cpp +ifeq ($(call is-board-platform,msm7x27a),true) + LOCAL_CFLAGS += -DCHECK_FOR_EXTERNAL_FORMAT +endif + LOCAL_SHARED_LIBRARIES := \ libutils \ libcutils \ diff --git a/libqcomui/qcom_ui.cpp b/libqcomui/qcom_ui.cpp index e28fb02..7372c06 100644 --- a/libqcomui/qcom_ui.cpp +++ b/libqcomui/qcom_ui.cpp @@ -144,6 +144,35 @@ bool isGPUSupportedFormat(int format) { return true; } +/* + * Checks if the format is natively supported by the GPU. + * For now, we use this function to check only if CHECK_FOR_EXTERNAL_FORMAT + * is set. + * + * @param: format to check + * + * @return true if the format is supported by the GPU. + */ +bool isGPUSupportedFormatInHW(int format) { + // For 7x27A bypass creating EGL image for formats not natively supported + // in GPU. + // This is done to save CPU utilization by SurfaceFlinger thread +#ifdef CHECK_FOR_EXTERNAL_FORMAT + + if (format == HAL_PIXEL_FORMAT_YV12){ + return false; + } else if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { + return false; + } else if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP) { + return false; + } else if (format == HAL_PIXEL_FORMAT_NV12_ENCODEABLE) { + return false; + } +#endif + + return true; +} + /* * Function to check if the allocated buffer is of the correct size. * Reallocate the buffer with the correct size, if the size doesn't diff --git a/libqcomui/qcom_ui.h b/libqcomui/qcom_ui.h index d54280e..32e5ceb 100644 --- a/libqcomui/qcom_ui.h +++ b/libqcomui/qcom_ui.h @@ -123,6 +123,17 @@ int checkBuffer(native_handle_t *buffer_handle, int size, int usage); */ bool isGPUSupportedFormat(int format); +/* + * Checks if the format is natively supported by the GPU. + * For now, we use this function to check only if CHECK_FOR_EXTERNAL_FORMAT + * is set. + * + * @param: format to check + * + * @return true if the format is supported by the GPU. + */ +bool isGPUSupportedFormatInHW(int format); + /* * Gets the number of arguments required for this operation. *