SF: Introduce DisplayDeviceCreationArgs
Introduce a structure to hold the arguments used by the DisplayDevice
constructor. This simplifies the injector code used by the test, and
makes it easier to change the arguments without requiring a change to
the test or to the upcoming factory.
Test: atest libsurfaceflinger_unittest
Test: Marlin boots and appears usable
Bug: None
Change-Id: I4c806bf40f8f3c2c00f5115b83c6ab926317d628
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index ed73671..38482c9 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -43,14 +43,16 @@
namespace android {
-struct DisplayInfo;
class DisplaySurface;
class Fence;
+class HWComposer;
class IGraphicBufferProducer;
class Layer;
class SurfaceFlinger;
-class HWComposer;
+
struct CompositionInfo;
+struct DisplayDeviceCreationArgs;
+struct DisplayInfo;
class DisplayDevice : public LightRefBase<DisplayDevice>
{
@@ -76,25 +78,7 @@
NO_LAYER_STACK = 0xFFFFFFFF,
};
- // clang-format off
- DisplayDevice(
- const sp<SurfaceFlinger>& flinger,
- DisplayType type,
- int32_t id,
- bool isSecure,
- const wp<IBinder>& displayToken,
- const sp<ANativeWindow>& nativeWindow,
- const sp<DisplaySurface>& displaySurface,
- std::unique_ptr<renderengine::Surface> renderSurface,
- int displayWidth,
- int displayHeight,
- int displayInstallOrientation,
- bool hasWideColorGamut,
- const HdrCapabilities& hdrCapabilities,
- const int32_t supportedPerFrameMetadata,
- const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hwcColorModes,
- int initialPowerMode);
- // clang-format on
+ explicit DisplayDevice(DisplayDeviceCreationArgs&& args);
~DisplayDevice();
@@ -335,6 +319,31 @@
static std::atomic<int32_t> sNextSequenceId;
};
+struct DisplayDeviceCreationArgs {
+ // We use a constructor to ensure some of the values are set, without
+ // assuming a default value.
+ DisplayDeviceCreationArgs(const sp<SurfaceFlinger>& flinger, const wp<IBinder>& displayToken,
+ DisplayDevice::DisplayType type, int32_t id);
+
+ const sp<SurfaceFlinger> flinger;
+ const wp<IBinder> displayToken;
+ const DisplayDevice::DisplayType type;
+ const int32_t id;
+
+ bool isSecure{false};
+ sp<ANativeWindow> nativeWindow;
+ sp<DisplaySurface> displaySurface;
+ std::unique_ptr<renderengine::Surface> renderSurface;
+ int displayWidth{0};
+ int displayHeight{0};
+ int displayInstallOrientation{DisplayState::eOrientationDefault};
+ bool hasWideColorGamut{false};
+ HdrCapabilities hdrCapabilities;
+ int32_t supportedPerFrameMetadata{0};
+ std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hwcColorModes;
+ int initialPowerMode{HWC_POWER_MODE_NORMAL};
+};
+
class DisplayRenderArea : public RenderArea {
public:
DisplayRenderArea(const sp<const DisplayDevice> device,