bool SwRenderer::preRender()
{
- 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);
- }
+ return rasterClear(surface);
+}
+
+
+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);
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();
{
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();