summaryrefslogtreecommitdiffstats
path: root/minui/include
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-11-07 19:15:50 +0100
committerTao Bao <tbao@google.com>2018-11-07 23:36:45 +0100
commit9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b (patch)
tree5cc2d8d77ba8ee8c46b90fcac6e4c425545017e9 /minui/include
parentMerge changes If24c6b7c,I381b0103 (diff)
downloadandroid_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.gz
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.bz2
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.lz
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.xz
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.tar.zst
android_bootable_recovery-9cf163e6732de5dce5b1d3b4ff7cbe19ba3a094b.zip
Diffstat (limited to 'minui/include')
-rw-r--r--minui/include/minui/minui.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index 0b499e621..3231248a0 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -17,6 +17,7 @@
#pragma once
#include <stdint.h>
+#include <stdlib.h>
#include <sys/types.h>
#include <functional>
@@ -32,7 +33,7 @@
class GRSurface {
public:
- virtual ~GRSurface();
+ 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
@@ -44,7 +45,7 @@ class GRSurface {
std::unique_ptr<GRSurface> Clone() const;
virtual uint8_t* data() {
- return data_;
+ return data_.get();
}
const uint8_t* data() const {
@@ -61,7 +62,14 @@ class GRSurface {
: width(width), height(height), row_bytes(row_bytes), pixel_bytes(pixel_bytes) {}
private:
- uint8_t* data_{ nullptr };
+ // The deleter for data_, whose data is allocated via aligned_alloc(3).
+ struct DataDeleter {
+ void operator()(uint8_t* data) {
+ free(data);
+ }
+ };
+
+ std::unique_ptr<uint8_t, DataDeleter> data_;
size_t data_size_;
DISALLOW_COPY_AND_ASSIGN(GRSurface);