]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blobdiff - libkmstest/testpat.cpp
libkmstest: remove dependency to libdrm
[android/external-libkmsxx.git] / libkmstest / testpat.cpp
index 33a4ec1efea5b76529de178c332bbe2d3af31409..68f438540d563e754d9a4dcc594c8aa8e398006e 100644 (file)
@@ -5,35 +5,29 @@
 #include <cstring>
 #include <cassert>
 
-#include <xf86drm.h>
-#include <xf86drmMode.h>
-#include <drm_fourcc.h>
-#include <drm.h>
-#include <drm_mode.h>
-
 #include "kms++.h"
 #include "test.h"
-#include "mappedbuffer.h"
+#include "cpuframebuffer.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 namespace kms
 {
-static void draw_rgb_pixel(MappedBuffer& buf, unsigned x, unsigned y, RGB color)
+static void draw_rgb_pixel(IMappedFramebuffer& buf, unsigned x, unsigned y, RGB color)
 {
        switch (buf.format()) {
        case PixelFormat::XRGB8888:
        case PixelFormat::ARGB8888:
        {
                uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
-               *p = color.rgb888();
+               *p = color.argb8888();
                break;
        }
        case PixelFormat::XBGR8888:
        case PixelFormat::ABGR8888:
        {
                uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
-               *p = color.bgr888();
+               *p = color.abgr8888();
                break;
        }
        case PixelFormat::RGB565:
@@ -47,7 +41,7 @@ static void draw_rgb_pixel(MappedBuffer& buf, unsigned x, unsigned y, RGB color)
        }
 }
 
-static void draw_yuv422_macropixel(MappedBuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2)
+static void draw_yuv422_macropixel(IMappedFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2)
 {
        ASSERT((x & 1) == 0);
 
@@ -92,7 +86,7 @@ static void draw_yuv422_macropixel(MappedBuffer& buf, unsigned x, unsigned y, YU
        }
 }
 
-static void draw_yuv420_macropixel(MappedBuffer& buf, unsigned x, unsigned y,
+static void draw_yuv420_macropixel(IMappedFramebuffer& buf, unsigned x, unsigned y,
                                   YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4)
 {
        ASSERT((x & 1) == 0);
@@ -134,7 +128,7 @@ static void draw_yuv420_macropixel(MappedBuffer& buf, unsigned x, unsigned y,
        }
 }
 
-static RGB get_test_pattern_pixel(MappedBuffer& fb, unsigned x, unsigned y)
+static RGB get_test_pattern_pixel(IMappedFramebuffer& fb, unsigned x, unsigned y)
 {
        const unsigned w = fb.width();
        const unsigned h = fb.height();
@@ -215,7 +209,7 @@ static RGB get_test_pattern_pixel(MappedBuffer& fb, unsigned x, unsigned y)
        }
 }
 
-static void draw_test_pattern_impl(MappedBuffer& fb)
+static void draw_test_pattern_impl(IMappedFramebuffer& fb)
 {
        unsigned x, y;
        unsigned w = fb.width();
@@ -267,13 +261,7 @@ static void draw_test_pattern_impl(MappedBuffer& fb)
        }
 }
 
-void draw_test_pattern(DumbFramebuffer &fb)
-{
-       MappedDumbBuffer mfb(fb);
-       draw_test_pattern(mfb);
-}
-
-void draw_test_pattern(MappedBuffer &fb)
+void draw_test_pattern(IMappedFramebuffer &fb)
 {
 #ifdef DRAW_PERF_PRINT
        using namespace std::chrono;
@@ -290,4 +278,14 @@ void draw_test_pattern(MappedBuffer &fb)
        printf("draw took %u us\n", (unsigned)time_span.count());
 #endif
 }
+
+void draw_rect(IMappedFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color)
+{
+       for (unsigned i = x; i < x + w; ++i) {
+               for (unsigned j = y; j < y + h; ++j) {
+                       draw_rgb_pixel(fb, i, j, color);
+               }
+       }
+}
+
 }