Support resetting vecr::renderer to an existing image
This commit is contained in:
parent
afd942af14
commit
14b18197bf
2 changed files with 10 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ namespace psemek::vecr
|
||||||
struct renderer
|
struct renderer
|
||||||
{
|
{
|
||||||
void reset(math::vector<std::size_t, 2> const & size, std::size_t samples = 4, gfx::color_rgba const & color = {0, 0, 0, 0});
|
void reset(math::vector<std::size_t, 2> const & size, std::size_t samples = 4, gfx::color_rgba const & color = {0, 0, 0, 0});
|
||||||
|
void reset(gfx::pixmap_rgba image, std::size_t samples = 4);
|
||||||
|
|
||||||
math::vector<std::size_t, 2> size() const;
|
math::vector<std::size_t, 2> size() const;
|
||||||
std::size_t samples() const;
|
std::size_t samples() const;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,15 @@ namespace psemek::vecr
|
||||||
need_resolve_ = false;
|
need_resolve_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void renderer::reset(gfx::pixmap_rgba image, std::size_t samples)
|
||||||
|
{
|
||||||
|
result_ = std::move(image);
|
||||||
|
canvas_.resize({result_.width() * samples, result_.height() * samples});
|
||||||
|
for (auto idx : canvas_.indices())
|
||||||
|
canvas_(idx) = result_({idx[0] / samples, idx[1] / samples});
|
||||||
|
need_resolve_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
math::vector<std::size_t, 2> renderer::size() const
|
math::vector<std::size_t, 2> renderer::size() const
|
||||||
{
|
{
|
||||||
return {result_.width(), result_.height()};
|
return {result_.width(), result_.height()};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue