Skip to content

Commit

Permalink
Support FilledRectObject with blender
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Jun 5, 2023
1 parent a5a0c5e commit 748c596
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Arch/Host/Virtual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ class VirtualSurface : public Surface
case Object::Kind::FilledRect: {
// Handle small transparent fills using display list
auto obj = reinterpret_cast<const FilledRectObject&>(object);
if(obj.radius != 0 || !obj.brush.isTransparent()) {
if(obj.blender || obj.radius != 0 || !obj.brush.isTransparent()) {
break;
}
Rect absRect = obj.rect + location.topLeft();
Expand Down
9 changes: 6 additions & 3 deletions src/Control/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/include/Graphics/Control/Screen.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class Screen
virtual void handleControlEvent(ControlEvent event, Control& ctrl);

private:
void doUpdate();

enum class Flag {
redraw,
redrawFull,
Expand Down
1 change: 1 addition & 0 deletions src/include/Graphics/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class FilledRectObject : public ObjectTemplate<Object::Kind::FilledRect>

Renderer* createRenderer(const Location& location) const override;

const Blend* blender{nullptr};
Brush brush;
Rect rect;
uint8_t radius{0};
Expand Down
8 changes: 4 additions & 4 deletions src/include/Graphics/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Blend> 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)
{
}

Expand Down Expand Up @@ -392,7 +392,7 @@ class FilledRectRenderer : public Renderer
Rect rect;
Point pos{};
Size blockSize;
std::unique_ptr<Blend> blender;
const Blend* blender{nullptr};
Buffer buffers[2];
uint8_t index{0};
uint8_t busyCount{0};
Expand Down

0 comments on commit 748c596

Please sign in to comment.