int reserve(size_t n) noexcept;
virtual int push(std::unique_ptr<PaintNode> paint) noexcept;
- virtual int clear(bool clearPaints = true) noexcept;
+ virtual int clear() noexcept;
virtual int update() noexcept;
virtual int draw(bool async = true) noexcept;
virtual int sync() = 0;
~Impl()
{
- clearPaints();
+ clear();
renderer->unref();
}
return node->update(renderer);
}
- bool clearRender()
- {
- assert(renderer);
- return renderer->clear());
- }
-
- int clearPaints()
+ int clear()
{
assert(renderer);
{
assert(renderer);
- auto ret = 0;
-
for(auto node: nodes) {
- ret |= node->update(renderer);
+ if (!node->update(renderer)) return -1;
}
- return ret;
+ return 0;
}
int draw()
{
assert(renderer);
+ //Clear render target before drawing
+ if (!renderer->clear()) return -1;
+
for(auto node: nodes) {
if (SceneNode *scene = dynamic_cast<SceneNode *>(node)) {
cout << "TODO: " << scene << endl;
}
-int Canvas::clear(bool clearPaints) noexcept
+int Canvas::clear() noexcept
{
auto impl = pImpl.get();
assert(impl);
- auto ret = 0;
- if (clearPaints) ret |= impl->clearPaints();
- ret |= impl->clearRender();
- return ret;
+ return impl->clear();
}