SF: Cleanup layer construction
Introduce a LayerCreationArg parameter object, and modify all layer
types to use it rather than having the same set of four arguments.
Along the way simplify all constructors by moving to C++11 style default
values defined in the header, and ensure the destructor is defined in
the implementation file (as a default for most layer types, as only
BufferLayer needs a non-default destructor).
Using a uniform parameter object reduces the amount of work needed to
maintain the upcoming factory interface.
Test: Works on marlin.
Test: atest libsurfaceflinger_unittest
Change-Id: Ic09291fd3213ff980bfc600166bf798ba09daa32
diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h
index 45906ff..92bf132 100644
--- a/services/surfaceflinger/BufferLayer.h
+++ b/services/surfaceflinger/BufferLayer.h
@@ -39,6 +39,8 @@
#include <utils/String8.h>
#include <utils/Timers.h>
+#include <system/window.h> // For NATIVE_WINDOW_SCALING_MODE_FREEZE
+
#include <stdint.h>
#include <sys/types.h>
#include <list>
@@ -47,9 +49,7 @@
class BufferLayer : public Layer {
public:
- BufferLayer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name, uint32_t w,
- uint32_t h, uint32_t flags);
-
+ explicit BufferLayer(const LayerCreationArgs& args);
~BufferLayer() override;
// -----------------------------------------------------------------------
@@ -172,15 +172,15 @@
uint64_t getHeadFrameNumber() const;
- uint32_t mCurrentScalingMode;
+ uint32_t mCurrentScalingMode{NATIVE_WINDOW_SCALING_MODE_FREEZE};
// main thread.
- bool mBufferLatched; // TODO: Use mActiveBuffer?
+ bool mBufferLatched{false}; // TODO: Use mActiveBuffer?
// The texture used to draw the layer in GLES composition mode
mutable renderengine::Texture mTexture;
- bool mRefreshPending;
+ bool mRefreshPending{false};
};
} // namespace android