HWC2: Fix virtual displays
Close the output buffer release fence per the contract in
hwcomposer2.h.
Also changes the HWC2 device to hold a weak pointer to the display,
which allows it to properly remove it when it gets torn down.
Bug: 29945684
Change-Id: Ib1b5d81e42a63d0e65b189f7c6c62e661e0ab6ae
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index 8ab61e9..68781da 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -88,7 +88,8 @@
// Other Device methods
// This will create a Display if one is not found, but it will not be marked
- // as connected
+ // as connected. This Display may be null if the display has been torn down
+ // but has not been removed from the map yet.
std::shared_ptr<Display> getDisplayById(hwc2_display_t id);
bool hasCapability(HWC2::Capability capability) const;
@@ -181,7 +182,7 @@
HWC2_PFN_SET_LAYER_Z_ORDER mSetLayerZOrder;
std::vector<Capability> mCapabilities;
- std::unordered_map<hwc2_display_t, std::shared_ptr<Display>> mDisplays;
+ std::unordered_map<hwc2_display_t, std::weak_ptr<Display>> mDisplays;
HotplugCallback mHotplug;
std::vector<std::pair<std::shared_ptr<Display>, Connection>>