Merge changes Ia1fa4a32,I2a4c3d9f into oc-dev
* changes:
hwc2: Remove Display::{mIsVirtual,setVirtual}
hwc2: Cache display type at construction
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index 250631f..8270c39 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -244,7 +244,7 @@
ALOGE("Failed to get display by id");
return Error::BadDisplay;
}
- (*outDisplay)->setVirtual();
+ (*outDisplay)->setConnected(true);
return Error::None;
}
@@ -531,15 +531,28 @@
: mDevice(device),
mId(id),
mIsConnected(false),
- mIsVirtual(false)
+ mType(DisplayType::Invalid)
{
ALOGV("Created display %" PRIu64, id);
+
+#ifdef BYPASS_IHWC
+ int32_t intError = mDevice.mGetDisplayType(mDevice.mHwcDevice, mId,
+ reinterpret_cast<int32_t *>(&mType));
+#else
+ auto intError = mDevice.mComposer->getDisplayType(mId,
+ reinterpret_cast<Hwc2::IComposerClient::DisplayType *>(&mType));
+#endif
+ auto error = static_cast<Error>(intError);
+ if (error != Error::None) {
+ ALOGE("getDisplayType(%" PRIu64 ") failed: %s (%d)",
+ id, to_string(error).c_str(), intError);
+ }
}
Display::~Display()
{
ALOGV("Destroyed display %" PRIu64, mId);
- if (mIsVirtual) {
+ if (mType == DisplayType::Virtual) {
mDevice.destroyVirtualDisplay(mId);
}
}
@@ -802,21 +815,7 @@
Error Display::getType(DisplayType* outType) const
{
-#ifdef BYPASS_IHWC
- int32_t intType = 0;
- int32_t intError = mDevice.mGetDisplayType(mDevice.mHwcDevice, mId,
- &intType);
-#else
- Hwc2::IComposerClient::DisplayType intType =
- Hwc2::IComposerClient::DisplayType::INVALID;
- auto intError = mDevice.mComposer->getDisplayType(mId, &intType);
-#endif
- auto error = static_cast<Error>(intError);
- if (error != Error::None) {
- return error;
- }
-
- *outType = static_cast<DisplayType>(intType);
+ *outType = mType;
return Error::None;
}
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index da6c06f..643b1e0 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -352,12 +352,6 @@
private:
// For use by Device
- // Virtual displays are always connected
- void setVirtual() {
- mIsVirtual = true;
- mIsConnected = true;
- }
-
void setConnected(bool connected) { mIsConnected = connected; }
int32_t getAttribute(hwc2_config_t configId, Attribute attribute);
void loadConfig(hwc2_config_t configId);
@@ -375,7 +369,7 @@
Device& mDevice;
hwc2_display_t mId;
bool mIsConnected;
- bool mIsVirtual;
+ DisplayType mType;
std::unordered_map<hwc2_layer_t, std::weak_ptr<Layer>> mLayers;
std::unordered_map<hwc2_config_t, std::shared_ptr<const Config>> mConfigs;
};