mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 21:53:41 +00:00
sw_engine: fix shape rendering skip issue.
tvg canvas must draw retained shapes for every draw call even though user missed call update() for shapes. that case canvs must draw shapes without update, it means drawing them within previous condition.
This commit is contained in:
parent
e49c9eb459
commit
4c0bce3fdc
3 changed files with 34 additions and 14 deletions
|
@ -138,28 +138,37 @@ bool SwRenderer::target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t
|
|||
|
||||
bool SwRenderer::preRender()
|
||||
{
|
||||
rasterClear(surface);
|
||||
return rasterClear(surface);
|
||||
}
|
||||
|
||||
//before we start rendering, we should finish all preparing tasks
|
||||
for (auto task : tasks) {
|
||||
task->get();
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
if (auto fill = task->sdata->fill()) {
|
||||
rasterGradientShape(surface, &task->shape, fill->id());
|
||||
} else{
|
||||
task->sdata->fill(&r, &g, &b, &a);
|
||||
if (a > 0) rasterSolidShape(surface, &task->shape, r, g, b, a);
|
||||
}
|
||||
task->sdata->strokeColor(&r, &g, &b, &a);
|
||||
if (a > 0) rasterStroke(surface, &task->shape, r, g, b, a);
|
||||
}
|
||||
bool SwRenderer::postRender()
|
||||
{
|
||||
tasks.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SwRenderer::render(const Shape& shape, void *data)
|
||||
{
|
||||
auto task = static_cast<SwTask*>(data);
|
||||
task->get();
|
||||
|
||||
uint8_t r, g, b, a;
|
||||
if (auto fill = task->sdata->fill()) {
|
||||
rasterGradientShape(surface, &task->shape, fill->id());
|
||||
} else{
|
||||
task->sdata->fill(&r, &g, &b, &a);
|
||||
if (a > 0) rasterSolidShape(surface, &task->shape, r, g, b, a);
|
||||
}
|
||||
task->sdata->strokeColor(&r, &g, &b, &a);
|
||||
if (a > 0) rasterStroke(surface, &task->shape, r, g, b, a);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SwRenderer::dispose(TVG_UNUSED const Shape& sdata, void *data)
|
||||
{
|
||||
auto task = static_cast<SwTask*>(data);
|
||||
|
|
|
@ -34,8 +34,10 @@ public:
|
|||
void* prepare(const Shape& shape, void* data, const RenderTransform* transform, RenderUpdateFlag flags) override;
|
||||
bool dispose(const Shape& shape, void *data) override;
|
||||
bool preRender() override;
|
||||
bool postRender() override;
|
||||
bool target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h, uint32_t cs);
|
||||
bool clear() override;
|
||||
bool render(const Shape& shape, void *data) override;
|
||||
|
||||
static SwRenderer* gen();
|
||||
static bool init();
|
||||
|
|
|
@ -9,6 +9,15 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
|||
{
|
||||
if (!canvas) return;
|
||||
|
||||
//Shape (for BG)
|
||||
auto bg = tvg::Shape::gen();
|
||||
bg->appendRect(0, 0, WIDTH, HEIGHT, 0, 0);
|
||||
|
||||
//fill property will be retained
|
||||
bg->fill(255, 255, 255, 255);
|
||||
|
||||
if (canvas->push(move(bg)) != tvg::Result::Success) return;
|
||||
|
||||
//Shape
|
||||
auto shape = tvg::Shape::gen();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue