Merge "graphics: improve PRESENT_OR_VALIDATE_DISPLAY support" am: f43ab227a5

am: 8e1ec23a5d

Change-Id: I856a4bfc708f34a331f83e1466e689a2fa5427b7
This commit is contained in:
Chia-I Wu 2017-12-21 07:30:24 +00:00 committed by android-build-merger
commit a72e80eafa
4 changed files with 40 additions and 26 deletions

View file

@ -38,6 +38,8 @@ class ComposerBase {
public:
virtual ~ComposerBase() {};
virtual bool hasCapability(hwc2_capability_t capability) = 0;
virtual void removeClient() = 0;
virtual void enableCallback(bool enable) = 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.
int presentFence = -1;
std::vector<Layer> layers;
std::vector<int> fences;
auto err = mHal.presentDisplay(mDisplay, &presentFence, &layers, &fences);
if (err == Error::NONE) {
mWriter.setPresentOrValidateResult(1);
mWriter.setPresentFence(presentFence);
mWriter.setReleaseFences(layers, fences);
return true;
if (mHal.hasCapability(HWC2_CAPABILITY_SKIP_VALIDATE)) {
int presentFence = -1;
std::vector<Layer> layers;
std::vector<int> fences;
auto err = mHal.presentDisplay(mDisplay, &presentFence, &layers, &fences);
if (err == Error::NONE) {
mWriter.setPresentOrValidateResult(1);
mWriter.setPresentFence(presentFence);
mWriter.setReleaseFences(layers, fences);
return true;
}
}
// 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<uint32_t> requestMasks;
err = mHal.validateDisplay(mDisplay, &changedLayers,
&compositionTypes, &displayRequestMask,
&requestedLayers, &requestMasks);
auto err = mHal.validateDisplay(mDisplay, &changedLayers, &compositionTypes,
&displayRequestMask, &requestedLayers, &requestMasks);
if (err == Error::NONE) {
mWriter.setPresentOrValidateResult(0);
mWriter.setChangedCompositionTypes(changedLayers,

View file

@ -47,8 +47,7 @@ HwcHal::HwcHal(const hw_module_t* module)
}
initCapabilities();
if (majorVersion >= 2 &&
hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
if (majorVersion >= 2 && hasCapability(HWC2_CAPABILITY_PRESENT_FENCE_IS_NOT_RELIABLE)) {
ALOGE("Present fence must be reliable from HWC2 on.");
abort();
}
@ -114,12 +113,14 @@ void HwcHal::initCapabilities()
uint32_t count = 0;
mDevice->getCapabilities(mDevice, &count, nullptr);
std::vector<Capability> caps(count);
mDevice->getCapabilities(mDevice, &count, reinterpret_cast<
std::underlying_type<Capability>::type*>(caps.data()));
std::vector<int32_t> caps(count);
mDevice->getCapabilities(mDevice, &count, caps.data());
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>
@ -188,7 +189,7 @@ void HwcHal::initDispatch()
initDispatch(HWC2_FUNCTION_SET_LAYER_PLANE_ALPHA,
&mDispatch.setLayerPlaneAlpha);
if (hasCapability(Capability::SIDEBAND_STREAM)) {
if (hasCapability(HWC2_CAPABILITY_SIDEBAND_STREAM)) {
initDispatch(HWC2_FUNCTION_SET_LAYER_SIDEBAND_STREAM,
&mDispatch.setLayerSidebandStream);
}
@ -208,15 +209,26 @@ void HwcHal::initDispatch()
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<void> HwcHal::getCapabilities(getCapabilities_cb hidl_cb)
{
std::vector<Capability> caps(
mCapabilities.cbegin(), mCapabilities.cend());
std::vector<Capability> caps;
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;
caps_reply.setToExternal(caps.data(), caps.size());

View file

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