minui: Add GRSurface::Clone().

Clone() allows duplicating the image that's stored in the GRSurface.

Test: Run recovery_unit_test.
Change-Id: Ia50d507c6200f2de5f17143775de805247a60e1f
This commit is contained in:
Tao Bao
2018-11-01 12:14:46 -07:00
parent d2e1c0a981
commit 63b59dcead
3 changed files with 25 additions and 3 deletions
+13 -1
View File
@@ -15,8 +15,9 @@
*/
#include <stdint.h>
#include <stdlib.h>
#include <memory>
#include <vector>
#include <gtest/gtest.h>
@@ -30,3 +31,14 @@ TEST(GRSurfaceTest, Create_aligned) {
ASSERT_EQ(0, reinterpret_cast<uintptr_t>(surface->data()) % kSurfaceDataAlignment);
}
}
TEST(GRSurfaceTest, Clone) {
static constexpr size_t kImageSize = 10 * 50;
auto image = GRSurface::Create(50, 10, 50, 1, kImageSize);
for (auto i = 0; i < kImageSize; i++) {
image->data()[i] = rand() % 128;
}
auto image_copy = image->Clone();
ASSERT_EQ(std::vector(image->data(), image->data() + kImageSize),
std::vector(image_copy->data(), image_copy->data() + kImageSize));
}