diff options
author | 2016-03-16 12:23:40 -0700 | |
---|---|---|
committer | 2016-04-08 19:32:08 +0000 | |
commit | 7d7ae7345abfb91be55c4aed6c9be9d09a144e4c (patch) | |
tree | 2c847a881e0e5a2ee57bdffad215773b07afd04e | |
parent | ed40eba4c1264806a1b795bf45b0dea366ee9975 (diff) |
HWC2: Add getHdrCapabilities to C++ shim
Adds support for the getHdrCapabilities call to the HWC2 C++ shim.
Bug: 25684127
Change-Id: Ib4635ee437a06b48945e7f0328492c1e74e27aaa
-rw-r--r-- | include/ui/HdrCapabilities.h | 66 | ||||
-rw-r--r-- | libs/ui/Android.mk | 2 | ||||
-rw-r--r-- | libs/ui/HdrCapabilities.cpp | 59 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWC2.cpp | 106 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWC2.h | 5 |
5 files changed, 201 insertions, 37 deletions
diff --git a/include/ui/HdrCapabilities.h b/include/ui/HdrCapabilities.h new file mode 100644 index 0000000000..a7cd5fb58e --- /dev/null +++ b/include/ui/HdrCapabilities.h @@ -0,0 +1,66 @@ +/* + * Copyright 2016 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_UI_HDR_CAPABILTIES_H +#define ANDROID_UI_HDR_CAPABILTIES_H + +#include <binder/Parcelable.h> + +namespace android { + +class HdrCapabilities : public Parcelable +{ +public: + HdrCapabilities(const std::vector<int32_t /*android_hdr_t*/>& types, + float maxLuminance, float maxAverageLuminance, float minLuminance) + : mSupportedHdrTypes(types), + mMaxLuminance(maxLuminance), + mMaxAverageLuminance(maxAverageLuminance), + mMinLuminance(minLuminance) {} + + // Make this move-constructable and move-assignable + HdrCapabilities(HdrCapabilities&& other) = default; + HdrCapabilities& operator=(HdrCapabilities&& other) = default; + + HdrCapabilities() + : mSupportedHdrTypes(), + mMaxLuminance(-1.0f), + mMaxAverageLuminance(-1.0f), + mMinLuminance(-1.0f) {} + + virtual ~HdrCapabilities() = default; + + const std::vector<int32_t /*android_hdr_t*/>& getSupportedHdrTypes() const { + return mSupportedHdrTypes; + } + float getDesiredMaxLuminance() const { return mMaxLuminance; } + float getDesiredMaxAverageLuminance() const { return mMaxAverageLuminance; } + float getDesiredMinLuminance() const { return mMinLuminance; } + + // Parcelable interface + virtual status_t writeToParcel(Parcel* parcel) const override; + virtual status_t readFromParcel(const Parcel* parcel) override; + +private: + std::vector<int32_t /*android_hdr_t*/> mSupportedHdrTypes; + float mMaxLuminance; + float mMaxAverageLuminance; + float mMinLuminance; +}; + +} // namespace android + +#endif diff --git a/libs/ui/Android.mk b/libs/ui/Android.mk index e4cdcab04a..ee6c093bcf 100644 --- a/libs/ui/Android.mk +++ b/libs/ui/Android.mk @@ -40,12 +40,14 @@ LOCAL_SRC_FILES := \ GraphicBuffer.cpp \ GraphicBufferAllocator.cpp \ GraphicBufferMapper.cpp \ + HdrCapabilities.cpp \ PixelFormat.cpp \ Rect.cpp \ Region.cpp \ UiConfig.cpp LOCAL_SHARED_LIBRARIES := \ + libbinder \ libcutils \ libhardware \ libsync \ diff --git a/libs/ui/HdrCapabilities.cpp b/libs/ui/HdrCapabilities.cpp new file mode 100644 index 0000000000..511f68ab4c --- /dev/null +++ b/libs/ui/HdrCapabilities.cpp @@ -0,0 +1,59 @@ +/* + * Copyright 2016 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. + */ + +#include <ui/HdrCapabilities.h> + +#include <binder/Parcel.h> + +namespace android { + +status_t HdrCapabilities::writeToParcel(Parcel* parcel) const +{ + status_t result = parcel->writeInt32Vector(mSupportedHdrTypes); + if (result != OK) { + return result; + } + result = parcel->writeFloat(mMaxLuminance); + if (result != OK) { + return result; + } + result = parcel->writeFloat(mMaxAverageLuminance); + if (result != OK) { + return result; + } + result = parcel->writeFloat(mMinLuminance); + return result; +} + +status_t HdrCapabilities::readFromParcel(const Parcel* parcel) +{ + status_t result = parcel->readInt32Vector(&mSupportedHdrTypes); + if (result != OK) { + return result; + } + result = parcel->readFloat(&mMaxLuminance); + if (result != OK) { + return result; + } + result = parcel->readFloat(&mMaxAverageLuminance); + if (result != OK) { + return result; + } + result = parcel->readFloat(&mMinLuminance); + return result; +} + +} // namespace android diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp index 0e97a5382a..5c78c68ef2 100644 --- a/services/surfaceflinger/DisplayHardware/HWC2.cpp +++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp @@ -74,6 +74,7 @@ extern "C" { using android::Fence; using android::FloatRect; using android::GraphicBuffer; +using android::HdrCapabilities; using android::Rect; using android::Region; using android::sp; @@ -100,6 +101,7 @@ Device::Device(hwc2_device_t* device) mGetDisplayRequests(nullptr), mGetDisplayType(nullptr), mGetDozeSupport(nullptr), + mGetHdrCapabilities(nullptr), mGetReleaseFences(nullptr), mPresentDisplay(nullptr), mSetActiveConfig(nullptr), @@ -307,82 +309,84 @@ void Device::loadFunctionPointers() // loadFunctionPointer specifying which function failed to load // Display function pointers - if(!loadFunctionPointer(FunctionDescriptor::CreateVirtualDisplay, + if (!loadFunctionPointer(FunctionDescriptor::CreateVirtualDisplay, mCreateVirtualDisplay)) return; - if(!loadFunctionPointer(FunctionDescriptor::DestroyVirtualDisplay, + if (!loadFunctionPointer(FunctionDescriptor::DestroyVirtualDisplay, mDestroyVirtualDisplay)) return; - if(!loadFunctionPointer(FunctionDescriptor::Dump, mDump)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetMaxVirtualDisplayCount, + if (!loadFunctionPointer(FunctionDescriptor::Dump, mDump)) return; + if (!loadFunctionPointer(FunctionDescriptor::GetMaxVirtualDisplayCount, mGetMaxVirtualDisplayCount)) return; - if(!loadFunctionPointer(FunctionDescriptor::RegisterCallback, + if (!loadFunctionPointer(FunctionDescriptor::RegisterCallback, mRegisterCallback)) return; // Device function pointers - if(!loadFunctionPointer(FunctionDescriptor::AcceptDisplayChanges, + if (!loadFunctionPointer(FunctionDescriptor::AcceptDisplayChanges, mAcceptDisplayChanges)) return; - if(!loadFunctionPointer(FunctionDescriptor::CreateLayer, + if (!loadFunctionPointer(FunctionDescriptor::CreateLayer, mCreateLayer)) return; - if(!loadFunctionPointer(FunctionDescriptor::DestroyLayer, + if (!loadFunctionPointer(FunctionDescriptor::DestroyLayer, mDestroyLayer)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetActiveConfig, + if (!loadFunctionPointer(FunctionDescriptor::GetActiveConfig, mGetActiveConfig)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetChangedCompositionTypes, + if (!loadFunctionPointer(FunctionDescriptor::GetChangedCompositionTypes, mGetChangedCompositionTypes)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetDisplayAttribute, + if (!loadFunctionPointer(FunctionDescriptor::GetDisplayAttribute, mGetDisplayAttribute)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetDisplayConfigs, + if (!loadFunctionPointer(FunctionDescriptor::GetDisplayConfigs, mGetDisplayConfigs)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetDisplayName, + if (!loadFunctionPointer(FunctionDescriptor::GetDisplayName, mGetDisplayName)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetDisplayRequests, + if (!loadFunctionPointer(FunctionDescriptor::GetDisplayRequests, mGetDisplayRequests)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetDisplayType, + if (!loadFunctionPointer(FunctionDescriptor::GetDisplayType, mGetDisplayType)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetDozeSupport, + if (!loadFunctionPointer(FunctionDescriptor::GetDozeSupport, mGetDozeSupport)) return; - if(!loadFunctionPointer(FunctionDescriptor::GetReleaseFences, + if (!loadFunctionPointer(FunctionDescriptor::GetHdrCapabilities, + mGetHdrCapabilities)) return; + if (!loadFunctionPointer(FunctionDescriptor::GetReleaseFences, mGetReleaseFences)) return; - if(!loadFunctionPointer(FunctionDescriptor::PresentDisplay, + if (!loadFunctionPointer(FunctionDescriptor::PresentDisplay, mPresentDisplay)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetActiveConfig, + if (!loadFunctionPointer(FunctionDescriptor::SetActiveConfig, mSetActiveConfig)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetClientTarget, + if (!loadFunctionPointer(FunctionDescriptor::SetClientTarget, mSetClientTarget)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetOutputBuffer, + if (!loadFunctionPointer(FunctionDescriptor::SetOutputBuffer, mSetOutputBuffer)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetPowerMode, + if (!loadFunctionPointer(FunctionDescriptor::SetPowerMode, mSetPowerMode)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetVsyncEnabled, + if (!loadFunctionPointer(FunctionDescriptor::SetVsyncEnabled, mSetVsyncEnabled)) return; - if(!loadFunctionPointer(FunctionDescriptor::ValidateDisplay, + if (!loadFunctionPointer(FunctionDescriptor::ValidateDisplay, mValidateDisplay)) return; // Layer function pointers - if(!loadFunctionPointer(FunctionDescriptor::SetCursorPosition, + if (!loadFunctionPointer(FunctionDescriptor::SetCursorPosition, mSetCursorPosition)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerBuffer, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerBuffer, mSetLayerBuffer)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerSurfaceDamage, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerSurfaceDamage, mSetLayerSurfaceDamage)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerBlendMode, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerBlendMode, mSetLayerBlendMode)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerColor, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerColor, mSetLayerColor)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerCompositionType, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerCompositionType, mSetLayerCompositionType)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerDisplayFrame, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerDisplayFrame, mSetLayerDisplayFrame)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerPlaneAlpha, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerPlaneAlpha, mSetLayerPlaneAlpha)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerSidebandStream, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerSidebandStream, mSetLayerSidebandStream)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerSourceCrop, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerSourceCrop, mSetLayerSourceCrop)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerTransform, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerTransform, mSetLayerTransform)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerVisibleRegion, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerVisibleRegion, mSetLayerVisibleRegion)) return; - if(!loadFunctionPointer(FunctionDescriptor::SetLayerZOrder, + if (!loadFunctionPointer(FunctionDescriptor::SetLayerZOrder, mSetLayerZOrder)) return; } @@ -637,6 +641,34 @@ Error Display::supportsDoze(bool* outSupport) const return Error::None; } +Error Display::getHdrCapabilities( + std::unique_ptr<HdrCapabilities>* outCapabilities) const +{ + uint32_t numTypes = 0; + float maxLuminance = -1.0f; + float maxAverageLuminance = -1.0f; + float minLuminance = -1.0f; + int32_t intError = mDevice.mGetHdrCapabilities(mDevice.mHwcDevice, mId, + &numTypes, nullptr, &maxLuminance, &maxAverageLuminance, + &minLuminance); + auto error = static_cast<HWC2::Error>(intError); + if (error != Error::None) { + return error; + } + + std::vector<int32_t> types(numTypes); + intError = mDevice.mGetHdrCapabilities(mDevice.mHwcDevice, mId, &numTypes, + types.data(), &maxLuminance, &maxAverageLuminance, &minLuminance); + error = static_cast<HWC2::Error>(intError); + if (error != Error::None) { + return error; + } + + *outCapabilities = std::make_unique<HdrCapabilities>(std::move(types), + maxLuminance, maxAverageLuminance, minLuminance); + return Error::None; +} + Error Display::getReleaseFences( std::unordered_map<std::shared_ptr<Layer>, sp<Fence>>* outFences) const { diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h index a7bd28c2e7..7d33a0a4d4 100644 --- a/services/surfaceflinger/DisplayHardware/HWC2.h +++ b/services/surfaceflinger/DisplayHardware/HWC2.h @@ -23,6 +23,8 @@ #undef HWC2_INCLUDE_STRINGIFICATION #undef HWC2_USE_CPP11 +#include <ui/HdrCapabilities.h> + #include <utils/Log.h> #include <utils/StrongPointer.h> #include <utils/Timers.h> @@ -145,6 +147,7 @@ private: HWC2_PFN_GET_DISPLAY_REQUESTS mGetDisplayRequests; HWC2_PFN_GET_DISPLAY_TYPE mGetDisplayType; HWC2_PFN_GET_DOZE_SUPPORT mGetDozeSupport; + HWC2_PFN_GET_HDR_CAPABILITIES mGetHdrCapabilities; HWC2_PFN_GET_RELEASE_FENCES mGetReleaseFences; HWC2_PFN_PRESENT_DISPLAY mPresentDisplay; HWC2_PFN_SET_ACTIVE_CONFIG mSetActiveConfig; @@ -279,6 +282,8 @@ public: outLayerRequests); [[clang::warn_unused_result]] Error getType(DisplayType* outType) const; [[clang::warn_unused_result]] Error supportsDoze(bool* outSupport) const; + [[clang::warn_unused_result]] Error getHdrCapabilities( + std::unique_ptr<android::HdrCapabilities>* outCapabilities) const; [[clang::warn_unused_result]] Error getReleaseFences( std::unordered_map<std::shared_ptr<Layer>, android::sp<android::Fence>>* outFences) const; |