SF: Separate Hwc2::Composer into interface and impl
This makes the android::Hwc2::Composer substitutable. In this case the
intent is to allow a mock::Composer GMock class to be defined.
Hwc2::Composer now is a pure interface class. Hwc2::impl::Composer is
the normal implementation.
Also included is another minor change to allow HWC2::Device to be
constructed with a Hwc2::Composer (interface) pointer instead of a
service name. This means that now SurfaceFlinger itself constructs the
Hwc2::impl::Composer using the service name, rather than passing it down
a call chain.
Test: Code builds
Bug: None
Change-Id: Ic79f645cee40c534651b9c7b70f05497d98e51dc
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 7eb3998..2cafd8e 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -59,25 +59,10 @@
// ---------------------------------------------------------------------------
-HWComposer::HWComposer(const std::string& serviceName)
- : mHwcDevice(),
- mDisplayData(2),
- mFreeDisplaySlots(),
- mHwcDisplaySlots(),
- mCBContext(),
- mVSyncCounts(),
- mRemainingHwcVirtualDisplays(0)
-{
- for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) {
- mLastHwVSync[i] = 0;
- mVSyncCounts[i] = 0;
- }
+HWComposer::HWComposer(std::unique_ptr<android::Hwc2::Composer> composer)
+ : mHwcDevice(std::make_unique<HWC2::Device>(std::move(composer))) {}
- mHwcDevice = std::make_unique<HWC2::Device>(serviceName);
- mRemainingHwcVirtualDisplays = mHwcDevice->getMaxVirtualDisplayCount();
-}
-
-HWComposer::~HWComposer() {}
+HWComposer::~HWComposer() = default;
void HWComposer::registerCallback(HWC2::ComposerCallback* callback,
int32_t sequenceId) {