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/BufferQueueLayer.h b/services/surfaceflinger/BufferQueueLayer.h
index 400f412..051b15d 100644
--- a/services/surfaceflinger/BufferQueueLayer.h
+++ b/services/surfaceflinger/BufferQueueLayer.h
@@ -31,8 +31,8 @@
*/
class BufferQueueLayer : public BufferLayer, public BufferLayerConsumer::ContentsChangedListener {
public:
- BufferQueueLayer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name,
- uint32_t w, uint32_t h, uint32_t flags);
+ explicit BufferQueueLayer(const LayerCreationArgs&);
+ ~BufferQueueLayer() override;
// -----------------------------------------------------------------------
// Interface implementation for Layer
@@ -121,20 +121,20 @@
sp<BufferLayerConsumer> mConsumer;
sp<IGraphicBufferProducer> mProducer;
- PixelFormat mFormat;
+ PixelFormat mFormat{PIXEL_FORMAT_NONE};
// Only accessed on the main thread.
- uint64_t mPreviousFrameNumber;
- bool mUpdateTexImageFailed;
+ uint64_t mPreviousFrameNumber{0};
+ bool mUpdateTexImageFailed{false};
// Local copy of the queued contents of the incoming BufferQueue
mutable Mutex mQueueItemLock;
Condition mQueueItemCondition;
Vector<BufferItem> mQueueItems;
- std::atomic<uint64_t> mLastFrameNumberReceived;
+ std::atomic<uint64_t> mLastFrameNumberReceived{0};
- bool mAutoRefresh;
- int mActiveBufferSlot;
+ bool mAutoRefresh{false};
+ int mActiveBufferSlot{BufferQueue::INVALID_BUFFER_SLOT};
// thread-safe
std::atomic<int32_t> mQueuedFrames{0};