Merge "graphics: improve PRESENT_OR_VALIDATE_DISPLAY support"

am: f43ab227a5

Change-Id: Ief20e5b035a25b77fe714b0ace4d3d4fa543380d
This commit is contained in:
Chia-I Wu 2017-12-21 07:28:39 +00:00 committed by android-build-merger
commit 8e1ec23a5d
4 changed files with 40 additions and 26 deletions

View file

@ -38,6 +38,8 @@ class ComposerBase {
public: public:
virtual ~ComposerBase() {}; virtual ~ComposerBase() {};
virtual bool hasCapability(hwc2_capability_t capability) = 0;
virtual void removeClient() = 0; virtual void removeClient() = 0;
virtual void enableCallback(bool enable) = 0; virtual void enableCallback(bool enable) = 0;
virtual uint32_t getMaxVirtualDisplayCount() = 0; virtual uint32_t getMaxVirtualDisplayCount() = 0;

View file

@ -748,15 +748,17 @@ bool ComposerClient::CommandReader::parsePresentOrValidateDisplay(uint16_t lengt
} }
// First try to Present as is. // First try to Present as is.
int presentFence = -1; if (mHal.hasCapability(HWC2_CAPABILITY_SKIP_VALIDATE)) {
std::vector<Layer> layers; int presentFence = -1;
std::vector<int> fences; std::vector<Layer> layers;
auto err = mHal.presentDisplay(mDisplay, &presentFence, &layers, &fences); std::vector<int> fences;
if (err == Error::NONE) { auto err = mHal.presentDisplay(mDisplay, &presentFence, &layers, &fences);
mWriter.setPresentOrValidateResult(1); if (err == Error::NONE) {
mWriter.setPresentFence(presentFence); mWriter.setPresentOrValidateResult(1);
mWriter.setReleaseFences(layers, fences); mWriter.setPresentFence(presentFence);
return true; mWriter.setReleaseFences(layers, fences);
return true;
}
} }
// Present has failed. We need to fallback to validate // Present has failed. We need to fallback to validate
@ -766,9 +768,8 @@ bool ComposerClient::CommandReader::parsePresentOrValidateDisplay(uint16_t lengt
std::vector<Layer> requestedLayers; std::vector<Layer> requestedLayers;
std::vector<uint32_t> requestMasks; std::vector<uint32_t> requestMasks;
err = mHal.validateDisplay(mDisplay, &changedLayers, auto err = mHal.validateDisplay(mDisplay, &changedLayers, &compositionTypes,
&compositionTypes, &displayRequestMask, &displayRequestMask, &requestedLayers, &requestMasks);
&requestedLayers, &requestMasks);
if (err == Error::NONE) { if (err == Error::NONE) {
mWriter.setPresentOrValidateResult(0); mWriter.setPresentOrValidateResult(0);
mWriter.setChangedCompositionTypes(changedLayers, mWriter.setChangedCompositionTypes(changedLayers,

View file

@ -49,8 +49,7 @@ HwcHal::HwcHal(const hw_module_t* module)
} }
initCapabilities(); initCapabilities();
if (majorVersion >= 2 && if (majorVersion >= 2 && hasCapability(HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE)) {
hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
ALOGE("Present fence must be reliable from HWC2 on."); ALOGE("Present fence must be reliable from HWC2 on.");
abort(); abort();
} }
@ -116,12 +115,14 @@ void HwcHal::initCapabilities()
uint32_t count = 0; uint32_t count = 0;
mDevice->getCapabilities(mDevice, &count, nullptr); mDevice->getCapabilities(mDevice, &count, nullptr);
std::vector<Capability> caps(count); std::vector<int32_t> caps(count);
mDevice->getCapabilities(mDevice, &count, reinterpret_cast< mDevice->getCapabilities(mDevice, &count, caps.data());
std::underlying_type<Capability>::type*>(caps.data()));
caps.resize(count); caps.resize(count);
mCapabilities.insert(caps.cbegin(), caps.cend()); mCapabilities.reserve(count);
for (auto cap : caps) {
mCapabilities.insert(static_cast<hwc2_capability_t>(cap));
}
} }
template<typename T> template<typename T>
@ -190,7 +191,7 @@ void HwcHal::initDispatch()
initDispatch(HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA, initDispatch(HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
&mDispatch.setLayerPlaneAlpha); &mDispatch.setLayerPlaneAlpha);
if (hasCapability(Capability::SIDEBAND_STREAM)) { if (hasCapability(HWC2_CAPABILITY_SIDEBAND_STREAM)) {
initDispatch(HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM, initDispatch(HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
&mDispatch.setLayerSidebandStream); &mDispatch.setLayerSidebandStream);
} }
@ -210,15 +211,26 @@ void HwcHal::initDispatch()
initDispatch(HWC2_FUNCTION_VALIDATE_DISPLAY, &mDispatch.validateDisplay); initDispatch(HWC2_FUNCTION_VALIDATE_DISPLAY, &mDispatch.validateDisplay);
} }
bool HwcHal::hasCapability(Capability capability) const bool HwcHal::hasCapability(hwc2_capability_t capability) {
{
return (mCapabilities.count(capability) > 0); return (mCapabilities.count(capability) > 0);
} }
Return<void> HwcHal::getCapabilities(getCapabilities_cb hidl_cb) Return<void> HwcHal::getCapabilities(getCapabilities_cb hidl_cb)
{ {
std::vector<Capability> caps( std::vector<Capability> caps;
mCapabilities.cbegin(), mCapabilities.cend()); caps.reserve(mCapabilities.size());
for (auto cap : mCapabilities) {
switch (cap) {
case HWC2_CAPABILITY_SIDEBAND_STREAM:
case HWC2_CAPABILITY_SKIP_CLIENT_COLOR_TRANSFORM:
case HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE:
caps.push_back(static_cast<Capability>(cap));
break;
default:
// not all HWC2 caps are defined in HIDL
break;
}
}
hidl_vec<Capability> caps_reply; hidl_vec<Capability> caps_reply;
caps_reply.setToExternal(caps.data(), caps.size()); caps_reply.setToExternal(caps.data(), caps.size());

View file

@ -58,14 +58,13 @@ public:
HwcHal(const hw_module_t* module); HwcHal(const hw_module_t* module);
virtual ~HwcHal(); virtual ~HwcHal();
bool hasCapability(Capability capability) const;
// IComposer interface // IComposer interface
Return<void> getCapabilities(getCapabilities_cb hidl_cb) override; Return<void> getCapabilities(getCapabilities_cb hidl_cb) override;
Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override; Return<void> dumpDebugInfo(dumpDebugInfo_cb hidl_cb) override;
Return<void> createClient(createClient_cb hidl_cb) override; Return<void> createClient(createClient_cb hidl_cb) override;
// ComposerBase interface // ComposerBase interface
bool hasCapability(hwc2_capability_t capability) override;
void removeClient() override; void removeClient() override;
void enableCallback(bool enable) override; void enableCallback(bool enable) override;
uint32_t getMaxVirtualDisplayCount() override; uint32_t getMaxVirtualDisplayCount() override;
@ -168,7 +167,7 @@ private:
hwc2_device_t* mDevice; hwc2_device_t* mDevice;
std::unordered_set<Capability> mCapabilities; std::unordered_set<hwc2_capability_t> mCapabilities;
struct { struct {
HWC2_PFN_ACCEPT_DISPLAY_CHANGES acceptDisplayChanges; HWC2_PFN_ACCEPT_DISPLAY_CHANGES acceptDisplayChanges;