Loading libs/hwui/DeviceInfo.cpp +25 −35 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ #include <log/log.h> #include <GLES2/gl2.h> namespace android { namespace uirenderer { Loading @@ -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; } Loading @@ -90,7 +61,7 @@ DisplayInfo DeviceInfo::queryDisplayInfo() { return displayInfo; } void DeviceInfo::queryCompositionPreference(ui::Dataspace* dataSpace, void QueryCompositionPreference(ui::Dataspace* dataSpace, ui::PixelFormat* pixelFormat) { if (Properties::isolatedProcess) { *dataSpace = ui::Dataspace::V0_SRGB; Loading @@ -102,5 +73,24 @@ void DeviceInfo::queryCompositionPreference(ui::Dataspace* dataSpace, 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 */ libs/hwui/DeviceInfo.h +11 −24 Original line number Diff line number Diff line Loading @@ -19,51 +19,38 @@ #include <ui/DisplayInfo.h> #include <ui/GraphicTypes.h> #include "Extensions.h" #include "utils/Macros.h" namespace android { namespace uirenderer { namespace renderthread { class RenderThread; } class DeviceInfo { PREVENT_COPY_AND_ASSIGN(DeviceInfo); public: // returns nullptr if DeviceInfo is not initialized yet // Note this does not have a memory fence so it's up to the caller // to use one if required. Normally this should not be necessary static const DeviceInfo* get(); // only call this after GL has been initialized, or at any point if compiled // with HWUI_NULL_GPU static void initialize(); static void initialize(int maxTextureSize); // this value is only valid after the GPU has been initialized and there is a valid graphics // context or if you are using the HWUI_NULL_GPU int maxTextureSize() const; int maxTextureSize() const { return mMaxTextureSize; } ui::Dataspace getTargetDataSpace() const { return mTargetDataSpace; } ui::PixelFormat getTargetPixelFormat() const { return mTargetPixelFormat; } const DisplayInfo& displayInfo() const { return mDisplayInfo; } const Extensions& extensions() const { return mExtensions; } static uint32_t multiplyByResolution(uint32_t in) { auto di = DeviceInfo::get()->displayInfo(); return di.w * di.h * in; } static DisplayInfo queryDisplayInfo(); private: static void queryCompositionPreference(ui::Dataspace* dataSpace, ui::PixelFormat* pixelFormat); DeviceInfo() {} ~DeviceInfo() {} friend class renderthread::RenderThread; static void setMaxTextureSize(int maxTextureSize); void load(); DeviceInfo(); int mMaxTextureSize; DisplayInfo mDisplayInfo; Extensions mExtensions; // TODO(lpy) Replace below with android_ prefix types. ui::Dataspace mTargetDataSpace; ui::PixelFormat mTargetPixelFormat; Loading libs/hwui/Extensions.hdeleted 100644 → 0 +0 −59 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HWUI_EXTENSIONS_H #define ANDROID_HWUI_EXTENSIONS_H namespace android { namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// // Classes /////////////////////////////////////////////////////////////////////////////// class Extensions { public: Extensions() {} inline bool hasNPot() const { return false; } inline bool hasFramebufferFetch() const { return false; } inline bool hasDiscardFramebuffer() const { return false; } inline bool hasDebugMarker() const { return false; } inline bool has1BitStencil() const { return false; } inline bool has4BitStencil() const { return false; } inline bool hasUnpackRowLength() const { return mVersionMajor >= 3; } inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; } inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; } inline bool hasFloatTextures() const { return mVersionMajor >= 3; } inline bool hasRenderableFloatTextures() const { return (mVersionMajor >= 3 && mVersionMinor >= 2); } inline bool hasSRGB() const { return false; } inline bool hasSRGBWriteControl() const { return hasSRGB() && false; } inline bool hasLinearBlending() const { return hasSRGB() && false; } inline int getMajorGlVersion() const { return mVersionMajor; } inline int getMinorGlVersion() const { return mVersionMinor; } private: int mVersionMajor = 2; int mVersionMinor = 0; }; // class Extensions }; // namespace uirenderer }; // namespace android #endif // ANDROID_HWUI_EXTENSIONS_H libs/hwui/debug/wrap_gles.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ #include <GLES3/gl31.h> #include <GLES3/gl32.h> // constant used by the NULL GPU implementation as well as HWUI's unit tests constexpr int NULL_GPU_MAX_TEXTURE_SIZE = 2048; // Generate stubs that route all the calls to our function table #include "gles_redefine.h" Loading libs/hwui/renderthread/EglManager.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include "utils/Color.h" #include "utils/StringUtils.h" #include "DeviceInfo.h" #include "Frame.h" #include "Properties.h" Loading Loading @@ -127,7 +126,6 @@ void EglManager::initialize() { createContext(); createPBufferSurface(); makeCurrent(mPBufferSurface, nullptr, /* force */ true); DeviceInfo::initialize(); mSurfaceColorGamut = DataSpaceToColorGamut( static_cast<android_dataspace>(DeviceInfo::get()->getTargetDataSpace())); Loading Loading
libs/hwui/DeviceInfo.cpp +25 −35 Original line number Diff line number Diff line Loading @@ -26,8 +26,6 @@ #include <log/log.h> #include <GLES2/gl2.h> namespace android { namespace uirenderer { Loading @@ -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; } Loading @@ -90,7 +61,7 @@ DisplayInfo DeviceInfo::queryDisplayInfo() { return displayInfo; } void DeviceInfo::queryCompositionPreference(ui::Dataspace* dataSpace, void QueryCompositionPreference(ui::Dataspace* dataSpace, ui::PixelFormat* pixelFormat) { if (Properties::isolatedProcess) { *dataSpace = ui::Dataspace::V0_SRGB; Loading @@ -102,5 +73,24 @@ void DeviceInfo::queryCompositionPreference(ui::Dataspace* dataSpace, 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 */
libs/hwui/DeviceInfo.h +11 −24 Original line number Diff line number Diff line Loading @@ -19,51 +19,38 @@ #include <ui/DisplayInfo.h> #include <ui/GraphicTypes.h> #include "Extensions.h" #include "utils/Macros.h" namespace android { namespace uirenderer { namespace renderthread { class RenderThread; } class DeviceInfo { PREVENT_COPY_AND_ASSIGN(DeviceInfo); public: // returns nullptr if DeviceInfo is not initialized yet // Note this does not have a memory fence so it's up to the caller // to use one if required. Normally this should not be necessary static const DeviceInfo* get(); // only call this after GL has been initialized, or at any point if compiled // with HWUI_NULL_GPU static void initialize(); static void initialize(int maxTextureSize); // this value is only valid after the GPU has been initialized and there is a valid graphics // context or if you are using the HWUI_NULL_GPU int maxTextureSize() const; int maxTextureSize() const { return mMaxTextureSize; } ui::Dataspace getTargetDataSpace() const { return mTargetDataSpace; } ui::PixelFormat getTargetPixelFormat() const { return mTargetPixelFormat; } const DisplayInfo& displayInfo() const { return mDisplayInfo; } const Extensions& extensions() const { return mExtensions; } static uint32_t multiplyByResolution(uint32_t in) { auto di = DeviceInfo::get()->displayInfo(); return di.w * di.h * in; } static DisplayInfo queryDisplayInfo(); private: static void queryCompositionPreference(ui::Dataspace* dataSpace, ui::PixelFormat* pixelFormat); DeviceInfo() {} ~DeviceInfo() {} friend class renderthread::RenderThread; static void setMaxTextureSize(int maxTextureSize); void load(); DeviceInfo(); int mMaxTextureSize; DisplayInfo mDisplayInfo; Extensions mExtensions; // TODO(lpy) Replace below with android_ prefix types. ui::Dataspace mTargetDataSpace; ui::PixelFormat mTargetPixelFormat; Loading
libs/hwui/Extensions.hdeleted 100644 → 0 +0 −59 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef ANDROID_HWUI_EXTENSIONS_H #define ANDROID_HWUI_EXTENSIONS_H namespace android { namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// // Classes /////////////////////////////////////////////////////////////////////////////// class Extensions { public: Extensions() {} inline bool hasNPot() const { return false; } inline bool hasFramebufferFetch() const { return false; } inline bool hasDiscardFramebuffer() const { return false; } inline bool hasDebugMarker() const { return false; } inline bool has1BitStencil() const { return false; } inline bool has4BitStencil() const { return false; } inline bool hasUnpackRowLength() const { return mVersionMajor >= 3; } inline bool hasPixelBufferObjects() const { return mVersionMajor >= 3; } inline bool hasOcclusionQueries() const { return mVersionMajor >= 3; } inline bool hasFloatTextures() const { return mVersionMajor >= 3; } inline bool hasRenderableFloatTextures() const { return (mVersionMajor >= 3 && mVersionMinor >= 2); } inline bool hasSRGB() const { return false; } inline bool hasSRGBWriteControl() const { return hasSRGB() && false; } inline bool hasLinearBlending() const { return hasSRGB() && false; } inline int getMajorGlVersion() const { return mVersionMajor; } inline int getMinorGlVersion() const { return mVersionMinor; } private: int mVersionMajor = 2; int mVersionMinor = 0; }; // class Extensions }; // namespace uirenderer }; // namespace android #endif // ANDROID_HWUI_EXTENSIONS_H
libs/hwui/debug/wrap_gles.h +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,9 @@ #include <GLES3/gl31.h> #include <GLES3/gl32.h> // constant used by the NULL GPU implementation as well as HWUI's unit tests constexpr int NULL_GPU_MAX_TEXTURE_SIZE = 2048; // Generate stubs that route all the calls to our function table #include "gles_redefine.h" Loading
libs/hwui/renderthread/EglManager.cpp +0 −2 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include "utils/Color.h" #include "utils/StringUtils.h" #include "DeviceInfo.h" #include "Frame.h" #include "Properties.h" Loading Loading @@ -127,7 +126,6 @@ void EglManager::initialize() { createContext(); createPBufferSurface(); makeCurrent(mPBufferSurface, nullptr, /* force */ true); DeviceInfo::initialize(); mSurfaceColorGamut = DataSpaceToColorGamut( static_cast<android_dataspace>(DeviceInfo::get()->getTargetDataSpace())); Loading