SF: use shared_ptr to track hwcLayer
Add a wrapper class and use std::shared_ptr to track instances
of hwcLayer. This is necessary because the calculation of
data for HWComposer is done in Layer and the processing of that
data is done in SurfaceFlinger, and we need to make sure that
the hwcLayer is not destroyed by Layer while or before being
used by SurfaceFlinger.
Merged-in: Icc7c002b84aaded1966d24aa8f849b47f51d2efb
Test: Compile/Boot
Change-Id: Icc7c002b84aaded1966d24aa8f849b47f51d2efb
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 9c4f1ce..9187b9f 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -435,7 +435,15 @@
if (getBE().mHwcLayers.count(hwcId) == 0) {
return nullptr;
}
- return getBE().mHwcLayers[hwcId].layer;
+ return *(getBE().mHwcLayers[hwcId].layer.get());
+ }
+
+ bool setHwcLayer(int32_t hwcId) {
+ if (getBE().mHwcLayers.count(hwcId) == 0) {
+ return false;
+ }
+ getBE().compositionInfo.hwc.hwcLayer = getBE().mHwcLayers[hwcId].layer;
+ return true;
}
// -----------------------------------------------------------------------