surfaceflinger: simplify HWC buffer cache clean up
When a Layer is no longer connected, we destroy the associated HWC
layers on next call to SurfaceFlinger::rebuildLayerStacks or when
the Layer is destroyed. There is no need to listen to
onBuffersReleased. Besides, we need to perform the cleanup from the
main thread as we only talk to HWC process from the main thread.
While at it, move HWComposerBufferCache to its own files.
Bug: 35320590
Test: manual
Change-Id: Ifa32f24076b094c8fa9cda8572b03d5bfb8e0b93
diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
index 5eea6b6..69a72d7 100644
--- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
+++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h
@@ -18,14 +18,13 @@
#define ANDROID_SF_FRAMEBUFFER_SURFACE_H
#include "DisplaySurface.h"
+#include "HWComposerBufferCache.h"
#include <stdint.h>
#include <sys/types.h>
#include <gui/ConsumerBase.h>
-#include <memory>
-
// ---------------------------------------------------------------------------
namespace android {
// ---------------------------------------------------------------------------
@@ -33,7 +32,6 @@
class Rect;
class String8;
class HWComposer;
-class HWComposerBufferCache;
// ---------------------------------------------------------------------------
@@ -96,8 +94,7 @@
HWComposer& mHwc;
#ifdef USE_HWC2
- std::unique_ptr<HWComposerBufferCache> mHwcBufferCache =
- std::make_unique<HWComposerBufferCache>();
+ HWComposerBufferCache mHwcBufferCache;
// Previous buffer to release after getting an updated retire fence
bool mHasPendingRelease;