帧颜色格式优化
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#include <render_2D/base/Frame_2D.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
namespace {
|
||||
using namespace aethera;
|
||||
using namespace aethera::render_2d;
|
||||
void paint_translucent_red(Frame_2D& frame) {
|
||||
auto& target = detail::Frame_2D_Access::render_target(&frame);
|
||||
detail::Painter painter(target, Size{1, 1});
|
||||
painter.rect(Rect_F{0.0, 0.0, 1.0, 1.0},
|
||||
Pen{Color::transparent(), 0.0, Line_Style::none},
|
||||
Brush{Color{255, 0, 0, 128}, Brush_Style::solid});
|
||||
}
|
||||
}
|
||||
TEST(frame_pixel_format, publishes_native_bgra_premultiplied_by_default) {
|
||||
Frame_2D frame{Frame_Identity{1, 0}};
|
||||
paint_translucent_red(frame);
|
||||
const auto pixels = frame.output_pixels();
|
||||
ASSERT_EQ(pixels.format, Pixel_Format::bgra8_premultiplied);
|
||||
ASSERT_EQ(pixels.bytes.size(), 4U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[0]), 0U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[1]), 0U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[2]), 128U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[3]), 128U);
|
||||
}
|
||||
TEST(frame_pixel_format, uses_blend2d_to_publish_straight_rgba) {
|
||||
Frame_2D frame{Frame_Identity{2, 0}, Pixel_Format::rgba8};
|
||||
paint_translucent_red(frame);
|
||||
const auto pixels = frame.output_pixels();
|
||||
ASSERT_EQ(pixels.format, Pixel_Format::rgba8);
|
||||
ASSERT_EQ(pixels.bytes.size(), 4U);
|
||||
EXPECT_GE(std::to_integer<unsigned>(pixels.bytes[0]), 254U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[1]), 0U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[2]), 0U);
|
||||
EXPECT_EQ(std::to_integer<unsigned>(pixels.bytes[3]), 128U);
|
||||
}
|
||||
Reference in New Issue
Block a user