From dd78982d580aa61c39bfd13940140e5830f489b2 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 26 Nov 2018 16:28:07 -0800 Subject: minui: GRSurface::Create() computes data_size on its own. GRSurface::Create() doesn't need to rely on caller specifying the buffer size, as it can compute that info based on the given args. This CL also uses `size_t` for all the parameters in GRSurface::Create(). Test: Run recovery_unit_test on marlin. Test: Build and boot into blueline recovery. `Run graphics test`. Test: Build and boot into blueline charger mode. Change-Id: Idec9381079196abf13553a475006fefcfca10950 --- minui/include/minui/minui.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'minui/include') diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h index 3231248a0..e49c6ac97 100644 --- a/minui/include/minui/minui.h +++ b/minui/include/minui/minui.h @@ -33,13 +33,16 @@ class GRSurface { public: + static constexpr size_t kSurfaceDataAlignment = 8; + virtual ~GRSurface() = default; // 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); + // size (i.e. row_bytes * height). The starting address of the surface data is aligned to + // kSurfaceDataAlignment. Returns the created GRSurface instance (in std::unique_ptr), or nullptr + // on error. + static std::unique_ptr Create(size_t width, size_t height, size_t row_bytes, + size_t pixel_bytes); // Clones the current GRSurface instance (i.e. an image). std::unique_ptr Clone() const; @@ -52,13 +55,17 @@ class GRSurface { return const_cast(const_cast(this)->data()); } - int width; - int height; - int row_bytes; - int pixel_bytes; + size_t data_size() const { + return data_size_; + } + + size_t width; + size_t height; + size_t row_bytes; + size_t pixel_bytes; protected: - GRSurface(int width, int height, int row_bytes, int pixel_bytes) + GRSurface(size_t width, size_t height, size_t row_bytes, size_t pixel_bytes) : width(width), height(height), row_bytes(row_bytes), pixel_bytes(pixel_bytes) {} private: -- cgit v1.2.3