diff options
-rw-r--r-- | platform/default/headless_view.cpp | 9 | ||||
-rw-r--r-- | test/headless.cpp | 9 |
2 files changed, 9 insertions, 9 deletions
diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 1f5a0ec987..59bf7f49ae 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -237,6 +237,15 @@ std::unique_ptr<uint32_t[]> HeadlessView::readPixels() { glReadPixels(0, 0, width_, height_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); make_inactive(); + const int stride = w * 4; + auto tmp = std::unique_ptr<char[]>(new char[stride]()); + char *rgba = reinterpret_cast<char *>(pixels.get()); + for (int i = 0, j = height_ - 1; i < j; i++, j--) { + memcpy(tmp.get(), rgba + i * stride, stride); + memcpy(rgba + i * stride, rgba + j * stride, stride); + memcpy(rgba + j * stride, tmp.get(), stride); + } + return pixels; } diff --git a/test/headless.cpp b/test/headless.cpp index 680f51aeb1..e0409c4739 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -203,15 +203,6 @@ TEST_P(HeadlessTest, render) { auto pixels = view.readPixels(); - const int stride = w * 4; - auto tmp = std::unique_ptr<char[]>(new char[stride]()); - char *rgba = reinterpret_cast<char *>(pixels.get()); - for (int i = 0, j = height - 1; i < j; i++, j--) { - memcpy(tmp.get(), rgba + i * stride, stride); - memcpy(rgba + i * stride, rgba + j * stride, stride); - memcpy(rgba + j * stride, tmp.get(), stride); - } - const std::string image = util::compress_png(w, h, pixels.get()); util::write_file(actual_image, image); } |