srctree

Robin Linden parent b555e399 63301af6
render: Make it possible to call render_layout_depth w/o any setup

Previously, you had to clear the render surface w/ a background suitablefor whatever colours the render setup would draw.

inlinesplit
render/render.cpp added: 14, removed: 5, total 9
@@ -149,13 +149,21 @@ void render_layout(gfx::ICanvas &painter, layout::LayoutBox const &layout, std::
}
 
namespace debug {
namespace {
 
void render_layout_depth(gfx::ICanvas &painter, layout::LayoutBox const &layout) {
void render_layout_depth_impl(gfx::ICanvas &painter, layout::LayoutBox const &layout) {
painter.fill_rect(layout.dimensions.padding_box(), {0xFF, 0xFF, 0xFF, 0x30});
for (auto const &child : layout.children) {
render_layout_depth(painter, child);
render_layout_depth_impl(painter, child);
}
}
 
} // namespace
 
void render_layout_depth(gfx::ICanvas &painter, layout::LayoutBox const &layout) {
painter.clear(gfx::Color{});
render_layout_depth_impl(painter, layout);
}
 
} // namespace debug
} // namespace render
 
render/render_test.cpp added: 14, removed: 5, total 9
@@ -97,7 +97,8 @@ int main() {
geom::Rect expected_rect{10, 20, 100, 100};
gfx::Color expected_color{0xFF, 0xFF, 0xFF, 0x30};
 
expect_eq(saver.take_commands(), CanvasCommands{gfx::FillRectCmd{expected_rect, expected_color}});
expect_eq(saver.take_commands(),
CanvasCommands{gfx::ClearCmd{}, gfx::FillRectCmd{expected_rect, expected_color}});
});
 
etest::test("render block with transparent background-color", [] {