Commit 83dfdcb0 by Nicolas Capens

Disable R5G6B5 conversion in gralloc.

Bug 20891368 Change-Id: Ie293159d2092985c496202eb25733e69f9a3ff6f Reviewed-on: https://swiftshader-review.googlesource.com/3252Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 5a86ee94
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <cutils/log.h> #include <cutils/log.h>
GrallocModule* GrallocModule::getInstance() GrallocModule *GrallocModule::getInstance()
{ {
static GrallocModule instance; static GrallocModule instance;
return &instance; return &instance;
...@@ -10,22 +10,13 @@ GrallocModule* GrallocModule::getInstance() ...@@ -10,22 +10,13 @@ GrallocModule* GrallocModule::getInstance()
GrallocModule::GrallocModule() GrallocModule::GrallocModule()
{ {
const hw_module_t* module; const hw_module_t *module = nullptr;
hw_get_module("converting_gralloc", &module); hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
if (module)
{ if(!module)
m_supportsConversion = true;
ALOGI("Loaded converting gralloc");
}
else
{
m_supportsConversion = false;
ALOGE("Falling back to standard gralloc with reduced format support");
hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
}
if (!module)
{ {
ALOGE("Failed to load standard gralloc"); ALOGE("Failed to load standard gralloc");
} }
m_module = reinterpret_cast<const gralloc_module_t*>(module); m_module = reinterpret_cast<const gralloc_module_t*>(module);
} }
...@@ -6,22 +6,20 @@ ...@@ -6,22 +6,20 @@
class GrallocModule class GrallocModule
{ {
public: public:
static GrallocModule* getInstance(); static GrallocModule *getInstance();
bool supportsConversion() const { return m_supportsConversion; } int lock(buffer_handle_t handle, int usage, int left, int top, int width, int height, void **vaddr)
int lock( {
buffer_handle_t handle, int usage,
int left, int top, int width, int height, void**vaddr) {
return m_module->lock(m_module, handle, usage, left, top, width, height, vaddr); return m_module->lock(m_module, handle, usage, left, top, width, height, vaddr);
} }
int unlock(buffer_handle_t handle) { int unlock(buffer_handle_t handle)
{
return m_module->unlock(m_module, handle); return m_module->unlock(m_module, handle);
} }
private: private:
GrallocModule(); GrallocModule();
bool m_supportsConversion; const gralloc_module_t *m_module;
const gralloc_module_t* m_module;
}; };
#endif // GRALLOC_ANDROID #endif // GRALLOC_ANDROID
...@@ -26,17 +26,7 @@ GLenum getColorFormatFromAndroid(int format) ...@@ -26,17 +26,7 @@ GLenum getColorFormatFromAndroid(int format)
case HAL_PIXEL_FORMAT_BGRA_8888: case HAL_PIXEL_FORMAT_BGRA_8888:
return GL_BGRA_EXT; return GL_BGRA_EXT;
case HAL_PIXEL_FORMAT_RGB_565: case HAL_PIXEL_FORMAT_RGB_565:
#if LATER
if (GrallocModule::getInstance()->supportsConversion()) {
return GL_RGB565;
} else {
ALOGE("%s badness converting gralloc not supported for RGB_565",
__FUNCTION__);
return GL_RGB565;
}
#else
return GL_RGB565; return GL_RGB565;
#endif
case HAL_PIXEL_FORMAT_YV12: case HAL_PIXEL_FORMAT_YV12:
return SW_YV12_BT601; return SW_YV12_BT601;
case HAL_PIXEL_FORMAT_BLOB: case HAL_PIXEL_FORMAT_BLOB:
...@@ -58,17 +48,7 @@ GLenum getPixelFormatFromAndroid(int format) ...@@ -58,17 +48,7 @@ GLenum getPixelFormatFromAndroid(int format)
case HAL_PIXEL_FORMAT_BGRA_8888: case HAL_PIXEL_FORMAT_BGRA_8888:
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
case HAL_PIXEL_FORMAT_RGB_565: case HAL_PIXEL_FORMAT_RGB_565:
#if LATER
if (GrallocModule::getInstance()->supportsConversion()) {
return GL_UNSIGNED_SHORT_5_6_5;
} else {
ALOGE("%s badness converting gralloc not supported for RGB_565",
__FUNCTION__);
return GL_UNSIGNED_SHORT_5_6_5;
}
#else
return GL_UNSIGNED_SHORT_5_6_5; return GL_UNSIGNED_SHORT_5_6_5;
#endif
case HAL_PIXEL_FORMAT_YV12: case HAL_PIXEL_FORMAT_YV12:
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
case HAL_PIXEL_FORMAT_BLOB: case HAL_PIXEL_FORMAT_BLOB:
......
...@@ -12,9 +12,6 @@ ...@@ -12,9 +12,6 @@
#include <system/window.h> #include <system/window.h>
#include "../../Common/GrallocAndroid.hpp" #include "../../Common/GrallocAndroid.hpp"
#include "../common/AndroidCommon.hpp" #include "../common/AndroidCommon.hpp"
#endif
#ifdef __ANDROID__
#include "../../Common/DebugAndroid.hpp" #include "../../Common/DebugAndroid.hpp"
#define LOGLOCK(fmt, ...) // ALOGI(fmt " tid=%d", ##__VA_ARGS__, gettid()) #define LOGLOCK(fmt, ...) // ALOGI(fmt " tid=%d", ##__VA_ARGS__, gettid())
#else #else
...@@ -215,7 +212,7 @@ private: ...@@ -215,7 +212,7 @@ private:
ALOGI("badness: %s called with unsupported parms: image=%p x=%d y=%d z=%d", __FUNCTION__, this, x, y, z); ALOGI("badness: %s called with unsupported parms: image=%p x=%d y=%d z=%d", __FUNCTION__, this, x, y, z);
} }
LOGLOCK("image=%p op=%s.ani lock=%d", this, __FUNCTION__, lock); LOGLOCK("image=%p op=%s.ani lock=%d", this, __FUNCTION__, lock);
// Lock the ANativeWindowBuffer and use it's address. // Lock the ANativeWindowBuffer and use its address.
data = lockNativeBuffer( data = lockNativeBuffer(
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN); GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN);
if (lock == sw::LOCK_UNLOCKED) if (lock == sw::LOCK_UNLOCKED)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment