Loading services/surfaceflinger/tests/Transaction_test.cpp +102 −83 File changed.Preview size limit exceeded, changes collapsed. Show changes services/surfaceflinger/tests/utils/ScreenshotUtils.h +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public: void expectColor(const Rect& rect, const Color& color, uint8_t tolerance = 0) { ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mOutBuffer->getPixelFormat()); expectBufferColor(mOutBuffer, mPixels, rect, color, tolerance); TransactionUtils::expectBufferColor(mOutBuffer, mPixels, rect, color, tolerance); } void expectBorder(const Rect& rect, const Color& color, uint8_t tolerance = 0) { Loading services/surfaceflinger/tests/utils/TransactionUtils.h +99 −104 Original line number Diff line number Diff line Loading @@ -16,13 +16,7 @@ #pragma once //#include <algorithm> #include <chrono> //#include <cinttypes> //#include <functional> //#include <limits> //#include <ostream> //#include <thread> #include <gtest/gtest.h> #include <android/native_window.h> Loading @@ -39,22 +33,23 @@ #include <ui/Rect.h> #include "ColorUtils.h" //#include <sys/types.h> //#include <unistd.h> namespace android { namespace { using namespace std::chrono_literals; using Transaction = SurfaceComposerClient::Transaction; std::ostream& operator<<(std::ostream& os, const Color& color) { os << int(color.r) << ", " << int(color.g) << ", " << int(color.b) << ", " << int(color.a); return os; } class TransactionUtils { public: // Fill a region with the specified color. void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect& rect, static void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect& rect, const Color& color) { Rect r(0, 0, buffer.width, buffer.height); if (!r.intersect(rect, &r)) { Loading @@ -65,8 +60,8 @@ void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect int32_t height = r.bottom - r.top; for (int32_t row = 0; row < height; row++) { uint8_t* dst = static_cast<uint8_t*>(buffer.bits) + (buffer.stride * (r.top + row) + r.left) * 4; uint8_t* dst = static_cast<uint8_t*>(buffer.bits) + (buffer.stride * (r.top + row) + r.left) * 4; for (int32_t column = 0; column < width; column++) { dst[0] = color.r; dst[1] = color.g; Loading @@ -78,7 +73,8 @@ void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect } // Fill a region with the specified color. void fillGraphicBufferColor(const sp<GraphicBuffer>& buffer, const Rect& rect, const Color& color) { static void fillGraphicBufferColor(const sp<GraphicBuffer>& buffer, const Rect& rect, const Color& color) { Rect r(0, 0, buffer->width, buffer->height); if (!r.intersect(rect, &r)) { return; Loading @@ -105,8 +101,8 @@ void fillGraphicBufferColor(const sp<GraphicBuffer>& buffer, const Rect& rect, c } // Check if a region has the specified color. void expectBufferColor(const sp<GraphicBuffer>& outBuffer, uint8_t* pixels, const Rect& rect, const Color& color, uint8_t tolerance) { static void expectBufferColor(const sp<GraphicBuffer>& outBuffer, uint8_t* pixels, const Rect& rect, const Color& color, uint8_t tolerance) { int32_t x = rect.left; int32_t y = rect.top; int32_t width = rect.right - rect.left; Loading Loading @@ -140,8 +136,6 @@ void expectBufferColor(const sp<GraphicBuffer>& outBuffer, uint8_t* pixels, cons } } using Transaction = SurfaceComposerClient::Transaction; // Fill an RGBA_8888 formatted surface with a single color. static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, uint8_t b, bool unlock = true) { Loading @@ -163,6 +157,7 @@ static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, ASSERT_EQ(NO_ERROR, s->unlockAndPost()); } } }; enum class RenderPath { SCREENSHOT, VIRTUAL_DISPLAY }; Loading Loading
services/surfaceflinger/tests/Transaction_test.cpp +102 −83 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/surfaceflinger/tests/utils/ScreenshotUtils.h +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public: void expectColor(const Rect& rect, const Color& color, uint8_t tolerance = 0) { ASSERT_EQ(HAL_PIXEL_FORMAT_RGBA_8888, mOutBuffer->getPixelFormat()); expectBufferColor(mOutBuffer, mPixels, rect, color, tolerance); TransactionUtils::expectBufferColor(mOutBuffer, mPixels, rect, color, tolerance); } void expectBorder(const Rect& rect, const Color& color, uint8_t tolerance = 0) { Loading
services/surfaceflinger/tests/utils/TransactionUtils.h +99 −104 Original line number Diff line number Diff line Loading @@ -16,13 +16,7 @@ #pragma once //#include <algorithm> #include <chrono> //#include <cinttypes> //#include <functional> //#include <limits> //#include <ostream> //#include <thread> #include <gtest/gtest.h> #include <android/native_window.h> Loading @@ -39,22 +33,23 @@ #include <ui/Rect.h> #include "ColorUtils.h" //#include <sys/types.h> //#include <unistd.h> namespace android { namespace { using namespace std::chrono_literals; using Transaction = SurfaceComposerClient::Transaction; std::ostream& operator<<(std::ostream& os, const Color& color) { os << int(color.r) << ", " << int(color.g) << ", " << int(color.b) << ", " << int(color.a); return os; } class TransactionUtils { public: // Fill a region with the specified color. void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect& rect, static void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect& rect, const Color& color) { Rect r(0, 0, buffer.width, buffer.height); if (!r.intersect(rect, &r)) { Loading @@ -65,8 +60,8 @@ void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect int32_t height = r.bottom - r.top; for (int32_t row = 0; row < height; row++) { uint8_t* dst = static_cast<uint8_t*>(buffer.bits) + (buffer.stride * (r.top + row) + r.left) * 4; uint8_t* dst = static_cast<uint8_t*>(buffer.bits) + (buffer.stride * (r.top + row) + r.left) * 4; for (int32_t column = 0; column < width; column++) { dst[0] = color.r; dst[1] = color.g; Loading @@ -78,7 +73,8 @@ void fillANativeWindowBufferColor(const ANativeWindow_Buffer& buffer, const Rect } // Fill a region with the specified color. void fillGraphicBufferColor(const sp<GraphicBuffer>& buffer, const Rect& rect, const Color& color) { static void fillGraphicBufferColor(const sp<GraphicBuffer>& buffer, const Rect& rect, const Color& color) { Rect r(0, 0, buffer->width, buffer->height); if (!r.intersect(rect, &r)) { return; Loading @@ -105,8 +101,8 @@ void fillGraphicBufferColor(const sp<GraphicBuffer>& buffer, const Rect& rect, c } // Check if a region has the specified color. void expectBufferColor(const sp<GraphicBuffer>& outBuffer, uint8_t* pixels, const Rect& rect, const Color& color, uint8_t tolerance) { static void expectBufferColor(const sp<GraphicBuffer>& outBuffer, uint8_t* pixels, const Rect& rect, const Color& color, uint8_t tolerance) { int32_t x = rect.left; int32_t y = rect.top; int32_t width = rect.right - rect.left; Loading Loading @@ -140,8 +136,6 @@ void expectBufferColor(const sp<GraphicBuffer>& outBuffer, uint8_t* pixels, cons } } using Transaction = SurfaceComposerClient::Transaction; // Fill an RGBA_8888 formatted surface with a single color. static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, uint8_t b, bool unlock = true) { Loading @@ -163,6 +157,7 @@ static void fillSurfaceRGBA8(const sp<SurfaceControl>& sc, uint8_t r, uint8_t g, ASSERT_EQ(NO_ERROR, s->unlockAndPost()); } } }; enum class RenderPath { SCREENSHOT, VIRTUAL_DISPLAY }; Loading