diff options
author | Tao Bao <tbao@google.com> | 2018-11-02 03:34:50 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-11-02 03:34:50 +0100 |
commit | 24b89ffd25fc51977c08d8272ef6ac31521dd7f9 (patch) | |
tree | ab4b045819468d3ea82af956c27a1e2892260d45 /minui/resources.cpp | |
parent | Merge changes I69ce001a,I14514017,I8e67cda7 (diff) | |
parent | Merge "minui: Add GRSurface::Clone()." (diff) | |
download | android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.tar android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.tar.gz android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.tar.bz2 android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.tar.lz android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.tar.xz android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.tar.zst android_bootable_recovery-24b89ffd25fc51977c08d8272ef6ac31521dd7f9.zip |
Diffstat (limited to 'minui/resources.cpp')
-rw-r--r-- | minui/resources.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/minui/resources.cpp b/minui/resources.cpp index 9c9af0242..9027bc668 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -44,13 +44,19 @@ std::unique_ptr<GRSurface> GRSurface::Create(int width, int height, int row_byte static constexpr size_t kSurfaceDataAlignment = 8; // Cannot use std::make_unique to access non-public ctor. auto result = std::unique_ptr<GRSurface>(new GRSurface(width, height, row_bytes, pixel_bytes)); - size_t aligned_size = + result->data_size_ = (data_size + kSurfaceDataAlignment - 1) / kSurfaceDataAlignment * kSurfaceDataAlignment; - result->data_ = static_cast<uint8_t*>(aligned_alloc(kSurfaceDataAlignment, aligned_size)); + result->data_ = static_cast<uint8_t*>(aligned_alloc(kSurfaceDataAlignment, result->data_size_)); if (result->data_ == nullptr) return nullptr; return result; } +std::unique_ptr<GRSurface> GRSurface::Clone() const { + auto result = GRSurface::Create(width, height, row_bytes, pixel_bytes, data_size_); + memcpy(result->data_, data_, data_size_); + return result; +} + GRSurface::~GRSurface() { if (data_ != nullptr) { free(data_); |