diff options
author | Derek Sollenberger <djsollen@google.com> | 2018-09-13 14:14:00 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2018-09-18 09:30:13 -0400 |
commit | 17662389b970e8c710f146c15d5b78a767a251d3 (patch) | |
tree | 97a6da7a569f956c61d1d2c341c9857997f45e3f /libs/hwui/DeviceInfo.cpp | |
parent | bd2d5f7e37a9d4fba09b2e3df0d891af1f192247 (diff) |
Refactor DeviceInfo in HWUI
Remove the need for both Vulkan and EGL managers to initialize
it. Also remove unused code paths.
Test: hwui_unit_tests
Change-Id: I33ad881468eddbf91ec63207f0d82bed8d97f5ad
Diffstat (limited to 'libs/hwui/DeviceInfo.cpp')
-rw-r--r-- | libs/hwui/DeviceInfo.cpp | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/libs/hwui/DeviceInfo.cpp b/libs/hwui/DeviceInfo.cpp index b5b87d516ff7..21fbbdca7ad0 100644 --- a/libs/hwui/DeviceInfo.cpp +++ b/libs/hwui/DeviceInfo.cpp @@ -26,8 +26,6 @@ #include <log/log.h> -#include <GLES2/gl2.h> - namespace android { namespace uirenderer { @@ -46,39 +44,12 @@ static constexpr android::DisplayInfo sDummyDisplay{ 1920, // viewportH }; -static DeviceInfo* sDeviceInfo = nullptr; -static std::once_flag sInitializedFlag; - const DeviceInfo* DeviceInfo::get() { - LOG_ALWAYS_FATAL_IF(!sDeviceInfo, "DeviceInfo not yet initialized."); - return sDeviceInfo; -} - -void DeviceInfo::initialize() { - std::call_once(sInitializedFlag, []() { - sDeviceInfo = new DeviceInfo(); - sDeviceInfo->load(); - }); -} - -void DeviceInfo::initialize(int maxTextureSize) { - std::call_once(sInitializedFlag, [maxTextureSize]() { - sDeviceInfo = new DeviceInfo(); - sDeviceInfo->mDisplayInfo = DeviceInfo::queryDisplayInfo(); - sDeviceInfo->mMaxTextureSize = maxTextureSize; - sDeviceInfo->queryCompositionPreference(&sDeviceInfo->mTargetDataSpace, - &sDeviceInfo->mTargetPixelFormat); - }); -} - -void DeviceInfo::load() { - mDisplayInfo = queryDisplayInfo(); - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); - sDeviceInfo->queryCompositionPreference(&sDeviceInfo->mTargetDataSpace, - &sDeviceInfo->mTargetPixelFormat); + static DeviceInfo sDeviceInfo; + return &sDeviceInfo; } -DisplayInfo DeviceInfo::queryDisplayInfo() { +DisplayInfo QueryDisplayInfo() { if (Properties::isolatedProcess) { return sDummyDisplay; } @@ -90,17 +61,36 @@ DisplayInfo DeviceInfo::queryDisplayInfo() { return displayInfo; } -void DeviceInfo::queryCompositionPreference(ui::Dataspace* dataSpace, - ui::PixelFormat* pixelFormat) { +void QueryCompositionPreference(ui::Dataspace* dataSpace, + ui::PixelFormat* pixelFormat) { if (Properties::isolatedProcess) { *dataSpace = ui::Dataspace::V0_SRGB; *pixelFormat = ui::PixelFormat::RGBA_8888; } status_t status = - SurfaceComposerClient::getCompositionPreference(dataSpace, pixelFormat); + SurfaceComposerClient::getCompositionPreference(dataSpace, pixelFormat); LOG_ALWAYS_FATAL_IF(status, "Failed to get composition preference, error %d", status); } +DeviceInfo::DeviceInfo() { +#if HWUI_NULL_GPU + mMaxTextureSize = NULL_GPU_MAX_TEXTURE_SIZE; +#else + mMaxTextureSize = -1; +#endif + mDisplayInfo = QueryDisplayInfo(); + QueryCompositionPreference(&mTargetDataSpace, &mTargetPixelFormat); +} + +int DeviceInfo::maxTextureSize() const { + LOG_ALWAYS_FATAL_IF(mMaxTextureSize < 0, "MaxTextureSize has not been initialized yet."); + return mMaxTextureSize; +} + +void DeviceInfo::setMaxTextureSize(int maxTextureSize) { + const_cast<DeviceInfo*>(DeviceInfo::get())->mMaxTextureSize = maxTextureSize; +} + } /* namespace uirenderer */ } /* namespace android */ |