From 44820ac1e31ffa029ab5baa71238a11b6db3e6cc Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 30 Oct 2018 23:34:50 -0700 Subject: minui: Add a protected GRSurface ctor. This prepares for the removal of the default and copy ctors, by making GRSurface::Create() as the only way to get GRSurface instances. Test: mmma -j bootable/recovery Test: Run recovery_unit_test on marlin. Change-Id: I0c34c3f3967e252deb020907c83acbac8a8f36b9 --- minui/include/minui/minui.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'minui/include') diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h index e9bd1c4f1..66d992b93 100644 --- a/minui/include/minui/minui.h +++ b/minui/include/minui/minui.h @@ -33,10 +33,11 @@ class GRSurface { GRSurface() = default; virtual ~GRSurface(); - // Creates and returns a GRSurface instance for the given data_size. The starting address of the - // surface data is aligned to SURFACE_DATA_ALIGNMENT. Returns the created GRSurface instance (in - // std::unique_ptr), or nullptr on error. - static std::unique_ptr Create(size_t data_size); + // Creates and returns a GRSurface instance that's sufficient for storing an image of the given + // size. The starting address of the surface data is aligned to SURFACE_DATA_ALIGNMENT. Returns + // the created GRSurface instance (in std::unique_ptr), or nullptr on error. + static std::unique_ptr Create(int width, int height, int row_bytes, int pixel_bytes, + size_t data_size); virtual uint8_t* data() { return data_; @@ -51,6 +52,10 @@ class GRSurface { int row_bytes; int pixel_bytes; + protected: + GRSurface(int width, int height, int row_bytes, int pixel_bytes) + : width(width), height(height), row_bytes(row_bytes), pixel_bytes(pixel_bytes) {} + private: uint8_t* data_{ nullptr }; }; -- cgit v1.2.3