From 748c5966a0b9ca55014076f601d4adf58121bc8f Mon Sep 17 00:00:00 2001 From: mikee47 Date: Mon, 5 Jun 2023 13:06:47 +0100 Subject: [PATCH] Support FilledRectObject with blender --- src/Arch/Host/Virtual.cpp | 2 +- src/Control/Screen.cpp | 9 ++++++--- src/include/Graphics/Control/Screen.h | 2 ++ src/include/Graphics/Object.h | 1 + src/include/Graphics/Renderer.h | 8 ++++---- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Arch/Host/Virtual.cpp b/src/Arch/Host/Virtual.cpp index b434666d..04cb0635 100644 --- a/src/Arch/Host/Virtual.cpp +++ b/src/Arch/Host/Virtual.cpp @@ -478,7 +478,7 @@ class VirtualSurface : public Surface case Object::Kind::FilledRect: { // Handle small transparent fills using display list auto obj = reinterpret_cast(object); - if(obj.radius != 0 || !obj.brush.isTransparent()) { + if(obj.blender || obj.radius != 0 || !obj.brush.isTransparent()) { break; } Rect absRect = obj.rect + location.topLeft(); diff --git a/src/Control/Screen.cpp b/src/Control/Screen.cpp index cbe04425..8398e3fa 100644 --- a/src/Control/Screen.cpp +++ b/src/Control/Screen.cpp @@ -11,10 +11,13 @@ void Screen::update(bool fullRedraw) flags += Flag::redrawFull; } - if(renderQueue.isActive()) { - return; + if(!renderQueue.isActive()) { + doUpdate(); } +} +void Screen::doUpdate() +{ auto scene = new SceneObject(target); if(flags[Flag::redrawFull]) { scene->clear(); @@ -30,7 +33,7 @@ void Screen::update(bool fullRedraw) renderQueue.render(scene, [this](SceneObject* scene) { delete scene; if(flags[Flag::redraw]) { - update(flags[Flag::redrawFull]); + doUpdate(); } }); } diff --git a/src/include/Graphics/Control/Screen.h b/src/include/Graphics/Control/Screen.h index 8380634b..27720b7e 100644 --- a/src/include/Graphics/Control/Screen.h +++ b/src/include/Graphics/Control/Screen.h @@ -61,6 +61,8 @@ class Screen virtual void handleControlEvent(ControlEvent event, Control& ctrl); private: + void doUpdate(); + enum class Flag { redraw, redrawFull, diff --git a/src/include/Graphics/Object.h b/src/include/Graphics/Object.h index 83c9c2e2..a7e40be1 100644 --- a/src/include/Graphics/Object.h +++ b/src/include/Graphics/Object.h @@ -245,6 +245,7 @@ class FilledRectObject : public ObjectTemplate Renderer* createRenderer(const Location& location) const override; + const Blend* blender{nullptr}; Brush brush; Rect rect; uint8_t radius{0}; diff --git a/src/include/Graphics/Renderer.h b/src/include/Graphics/Renderer.h index 0f552931..ca78725f 100644 --- a/src/include/Graphics/Renderer.h +++ b/src/include/Graphics/Renderer.h @@ -352,13 +352,13 @@ class RectRenderer : public Renderer class FilledRectRenderer : public Renderer { public: - FilledRectRenderer(const Location& location, const Brush& brush, const Rect& rect, std::unique_ptr blender) - : Renderer(location), brush(brush), rect{rect}, blender(std::move(blender)) + FilledRectRenderer(const Location& location, const Brush& brush, const Rect& rect, const Blend* blender = nullptr) + : Renderer(location), brush(brush), rect{rect}, blender(blender) { } FilledRectRenderer(const Location& location, const FilledRectObject& object) - : Renderer(location), brush(object.brush), rect(object.rect + location.dest.topLeft()) + : Renderer(location), brush(object.brush), rect(object.rect + location.dest.topLeft()), blender(object.blender) { } @@ -392,7 +392,7 @@ class FilledRectRenderer : public Renderer Rect rect; Point pos{}; Size blockSize; - std::unique_ptr blender; + const Blend* blender{nullptr}; Buffer buffers[2]; uint8_t index{0}; uint8_t busyCount{0};