index 519f960ec700bc8470404c9d98f22dc8e27e135b..cf43d002a31dd1c40021775d12746bfc287d5282 100644 (file)
namespace kms
{
-static RGB get_test_pattern_pixel(IMappedFramebuffer& fb, unsigned x, unsigned y)
+static RGB get_test_pattern_pixel(IFramebuffer& fb, unsigned x, unsigned y)
{
const unsigned w = fb.width();
const unsigned h = fb.height();
// white margin lines
if (x == xm1 || x == xm2 || y == ym1 || y == ym2)
return RGB(255, 255, 255);
+ // white box in top left corner
+ else if (x < xm1 && y < ym1)
+ return RGB(255, 255, 255);
// white box outlines to corners
else if ((x == 0 || x == w - 1) && (y < ym1 || y > ym2))
return RGB(255, 255, 255);
if (x == y || w - x == h - y)
return RGB(255, 255, 255);
// diagonal line
- else if (w - x == y || x == h - y)
+ else if (w - x - 1 == y || x == h - y - 1)
return RGB(255, 255, 255);
else {
int t = (x - xm1 - 1) * 8 / (xm2 - xm1 - 1);
}
}
-static void draw_test_pattern_part(IMappedFramebuffer& fb, unsigned start_y, unsigned end_y)
+static void draw_test_pattern_part(IFramebuffer& fb, unsigned start_y, unsigned end_y, YUVType yuvt)
{
unsigned x, y;
unsigned w = fb.width();
@@ -124,7 +127,7 @@ static void draw_test_pattern_part(IMappedFramebuffer& fb, unsigned start_y, uns
for (x = 0; x < w; x += 2) {
RGB pixel1 = get_test_pattern_pixel(fb, x, y);
RGB pixel2 = get_test_pattern_pixel(fb, x + 1, y);
- draw_yuv422_macropixel(fb, x, y, pixel1.yuv(), pixel2.yuv());
+ draw_yuv422_macropixel(fb, x, y, pixel1.yuv(yuvt), pixel2.yuv(yuvt));
}
}
break;
@@ -138,8 +141,8 @@ static void draw_test_pattern_part(IMappedFramebuffer& fb, unsigned start_y, uns
RGB pixel01 = get_test_pattern_pixel(fb, x, y + 1);
RGB pixel11 = get_test_pattern_pixel(fb, x + 1, y + 1);
draw_yuv420_macropixel(fb, x, y,
- pixel00.yuv(), pixel10.yuv(),
- pixel01.yuv(), pixel11.yuv());
+ pixel00.yuv(yuvt), pixel10.yuv(yuvt),
+ pixel01.yuv(yuvt), pixel11.yuv(yuvt));
}
}
break;
@@ -148,13 +151,17 @@ static void draw_test_pattern_part(IMappedFramebuffer& fb, unsigned start_y, uns
}
}
-static void draw_test_pattern_impl(IMappedFramebuffer& fb)
+static void draw_test_pattern_impl(IFramebuffer& fb, YUVType yuvt)
{
if (fb.height() < 20) {
- draw_test_pattern_part(fb, 0, fb.height());
+ draw_test_pattern_part(fb, 0, fb.height(), yuvt);
return;
}
+ // Create the mmaps before starting the threads
+ for (unsigned i = 0; i < fb.num_planes(); ++i)
+ fb.map(0);
+
unsigned num_threads = thread::hardware_concurrency();
vector<thread> workers;
if (n == num_threads - 1)
end = fb.height();
- workers.push_back(thread([&fb, start, end]() { draw_test_pattern_part(fb, start, end); }));
+ workers.push_back(thread([&fb, start, end, yuvt]() { draw_test_pattern_part(fb, start, end, yuvt); }));
}
for (thread& t : workers)
t.join();
}
-void draw_test_pattern(IMappedFramebuffer &fb)
+void draw_test_pattern(IFramebuffer &fb, YUVType yuvt)
{
#ifdef DRAW_PERF_PRINT
Stopwatch sw;
sw.start();
#endif
- draw_test_pattern_impl(fb);
+ draw_test_pattern_impl(fb, yuvt);
#ifdef DRAW_PERF_PRINT
double us = sw.elapsed_us();