This commit is contained in:
2026-08-26 22:11:50 +08:00
parent c50afae9c5
commit e187d9a9a8
12 changed files with 317 additions and 64 deletions
@@ -1,5 +1,8 @@
#include <render_2D/plottable/Afterglow.hpp>
#include <render_2D/plottable/Constellation_Diagram.hpp>
#include <render_2D/plottable/Frequency_Trace.hpp>
#include <render_2D/plottable/Spectrum.hpp>
#include <render_2D/plottable/Sweep_Spectrum.hpp>
#include <render_2D/plottable/Waterfall.hpp>
#include <render_2D/plottable/common/Raster_Plot.hpp>
#include <gtest/gtest.h>
@@ -26,6 +29,9 @@ TEST(partition_configuration,
using Power = Impl<Numeric_Axis>;
using Time = Impl<Time_Axis>;
using Spectrum_Object = Impl<Spectrum>;
using Trace_Object = Impl<Frequency_Trace>;
using Sweep_Object = Impl<Sweep_Spectrum>;
using Afterglow_Object = Impl<Afterglow>;
using Constellation_Object = Impl<Constellation_Diagram>;
using Waterfall_Object = Impl<Waterfall>;
@@ -35,6 +41,10 @@ TEST(partition_configuration,
auto time = build_object<Time>();
auto spectrum = build_object<Spectrum_Object>(frequency.get(), power.get(),
6u);
auto trace = build_object<Trace_Object>(time.get(), power.get(), 4u);
auto sweep = build_object<Sweep_Object>(frequency.get(), power.get(), 4u);
auto afterglow = build_object<Afterglow_Object>(
frequency.get(), power.get(), Plot_Partition_Grid{2, 3});
auto constellation = build_object<Constellation_Object>(
power.get(), q_axis.get(), 7u);
auto waterfall = build_object<Waterfall_Object>(
@@ -46,6 +56,12 @@ TEST(partition_configuration,
7u);
EXPECT_EQ(waterfall->read_prop<Waterfall::Base_Tag>().partition_grid,
(Plot_Partition_Grid{2, 3}));
EXPECT_FALSE(spectrum->read_prop<Renderable_2D::Base_Tag>().cache_enabled);
EXPECT_FALSE(trace->read_prop<Renderable_2D::Base_Tag>().cache_enabled);
EXPECT_FALSE(sweep->read_prop<Renderable_2D::Base_Tag>().cache_enabled);
EXPECT_FALSE(afterglow->read_prop<Renderable_2D::Base_Tag>().cache_enabled);
EXPECT_FALSE(waterfall->read_prop<Renderable_2D::Base_Tag>().cache_enabled);
EXPECT_FALSE(constellation->read_prop<Renderable_2D::Base_Tag>().cache_enabled);
spectrum->set<&Spectrum::Prop::partition_count>(3u);
constellation->set<&Constellation_Diagram::Prop::partition_count>(2u);
@@ -66,6 +82,65 @@ TEST(partition_configuration,
(Plot_Partition_Grid{0, 2}));
}
TEST(partition_configuration,
raster_grid_matches_a_single_framebuffer_view_without_seams) {
const Size canvas{137, 93};
const aethera::render_2d::detail::Raster_Layout layout{
19, 13, Rect_F{3.25, 5.5, 128.5, 80.25}, false, false, true};
std::vector<Pixel> pixels(
static_cast<std::size_t>(layout.width) * layout.height);
for (int y = 0; y < layout.height; ++y) {
for (int x = 0; x < layout.width; ++x) {
const auto red = static_cast<Pixel>((x * 255) /
(layout.width - 1));
const auto green = static_cast<Pixel>((y * 255) /
(layout.height - 1));
pixels[static_cast<std::size_t>(y) * layout.width + x] =
0xff000000u | (red << 16u) | (green << 8u) |
static_cast<Pixel>((x + y) & 0xff);
}
}
Blend2D_Cache single;
single.ensure_size(canvas);
single.clear();
{
aethera::render_2d::detail::Painter painter(single, canvas);
aethera::render_2d::detail::paint_raster(
painter, layout, pixels, Image_Interpolation_Mode::bilinear);
}
Blend2D_Cache partitioned;
partitioned.ensure_size(canvas);
partitioned.clear();
constexpr Plot_Partition_Grid grid{4, 3};
for (Plot_Partition_Count index = 0;
index < aethera::render_2d::detail::raster_partition_count(grid);
++index) {
const Rect_F region =
aethera::render_2d::detail::raster_paint_region(
layout, index, grid);
aethera::render_2d::detail::Painter painter(
partitioned, canvas, region);
aethera::render_2d::detail::paint_raster(
painter, layout, pixels, Image_Interpolation_Mode::bilinear);
}
const Image_View expected = single.view();
const Image_View actual = partitioned.view();
ASSERT_EQ(actual.width, expected.width);
ASSERT_EQ(actual.height, expected.height);
for (int y = 0; y < expected.height; ++y) {
const auto* expected_row = reinterpret_cast<const Pixel*>(
expected.data + static_cast<std::ptrdiff_t>(y) * expected.stride);
const auto* actual_row = reinterpret_cast<const Pixel*>(
actual.data + static_cast<std::ptrdiff_t>(y) * actual.stride);
for (int x = 0; x < expected.width; ++x)
EXPECT_EQ(actual_row[x], expected_row[x])
<< "pixel mismatch at " << x << ", " << y;
}
}
TEST(partition_configuration,
raster_grid_covers_each_matrix_cell_exactly_once) {
const aethera::render_2d::detail::Raster_Layout layout{