From 23f2ec210346f3cb170b8544d94c0ef64d666487 Mon Sep 17 00:00:00 2001 From: Harshad Bhutada Date: Fri, 3 Feb 2012 20:19:50 +0530 Subject: [PATCH] libqcomui: add function to find if GPU supports a format in hardware This is a helper function that will return false if the given format is supported by adreno drivers but not supported in GPU HW. For these formats, adreno will use software color conversion routines to convert them to acceptable format by the GPU HW. This may be required if we want to avoid creating texture for certain formats when not absolutely necessary. Could be defaulted to return true depending on a compile time flag. Change-Id: Idb2200b5ed13bb8c184288d44340ed1aefeaa8df --- libqcomui/Android.mk | 4 ++++ libqcomui/qcom_ui.cpp | 29 +++++++++++++++++++++++++++++ libqcomui/qcom_ui.h | 11 +++++++++++ 3 files changed, 44 insertions(+) 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. *