blend2D并行绘制
This commit is contained in:
@@ -33,3 +33,52 @@ TEST(frame_pixel_format, uses_blend2d_to_publish_straight_rgba) {
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[2]), 0U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[3]), 128U);
|
||||
}
|
||||
TEST(framebuffer_view, writes_only_the_requested_external_image_region) {
|
||||
Blend2D_Cache framebuffer;
|
||||
framebuffer.ensure_size(Size{8, 6});
|
||||
{
|
||||
aethera::render_2d::detail::Painter painter(
|
||||
framebuffer, Size{8, 6}, Rect_F{2.0, 1.0, 3.0, 2.0});
|
||||
painter.rect(Rect_F{0.0, 0.0, 8.0, 6.0},
|
||||
Pen{.style = Line_Style::none},
|
||||
Brush{Color::red_color(), Brush_Style::solid});
|
||||
}
|
||||
const Image_View view = framebuffer.view();
|
||||
ASSERT_EQ(view.width, 8);
|
||||
ASSERT_EQ(view.height, 6);
|
||||
for (int y = 0; y < view.height; ++y) {
|
||||
const auto* row = reinterpret_cast<const Pixel*>(
|
||||
view.data + static_cast<std::ptrdiff_t>(y) * view.stride);
|
||||
for (int x = 0; x < view.width; ++x) {
|
||||
const bool inside = x >= 2 && x < 5 && y >= 1 && y < 3;
|
||||
EXPECT_EQ(row[x] != 0, inside) << "pixel " << x << ',' << y;
|
||||
}
|
||||
}
|
||||
}
|
||||
TEST(framebuffer_view, overlapping_views_share_the_same_authoritative_pixels) {
|
||||
Blend2D_Cache framebuffer;
|
||||
framebuffer.ensure_size(Size{8, 6});
|
||||
{
|
||||
aethera::render_2d::detail::Painter first(
|
||||
framebuffer, Size{8, 6}, Rect_F{1.0, 1.0, 4.0, 3.0});
|
||||
first.rect(Rect_F{0.0, 0.0, 8.0, 6.0},
|
||||
Pen{.style = Line_Style::none},
|
||||
Brush{Color::red_color(), Brush_Style::solid});
|
||||
}
|
||||
{
|
||||
aethera::render_2d::detail::Painter second(
|
||||
framebuffer, Size{8, 6}, Rect_F{3.0, 2.0, 4.0, 3.0});
|
||||
second.rect(Rect_F{0.0, 0.0, 8.0, 6.0},
|
||||
Pen{.style = Line_Style::none},
|
||||
Brush{Color{0, 0, 255, 255}, Brush_Style::solid});
|
||||
}
|
||||
const Image_View view = framebuffer.view();
|
||||
const auto pixel = [&](int x, int y) {
|
||||
const auto* row = reinterpret_cast<const Pixel*>(
|
||||
view.data + static_cast<std::ptrdiff_t>(y) * view.stride);
|
||||
return row[x];
|
||||
};
|
||||
EXPECT_NE(pixel(2, 2), 0u);
|
||||
EXPECT_NE(pixel(4, 3), 0u);
|
||||
EXPECT_NE(pixel(2, 2), pixel(4, 3));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user