mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
SwRenderer: fixing unnecessary nesting in prepare()
Validating the above by adding shape/canvas update to testCapi.cpp Change-Id: I7db8d014f4aff7b5b2884c2dca5af119329e9d43
This commit is contained in:
parent
2ef3d05db9
commit
42a747fa17
2 changed files with 37 additions and 24 deletions
|
@ -127,28 +127,28 @@ void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform*
|
|||
if (!shapeGenRle(shape, &sdata, clip, antiAlias)) return shape;
|
||||
}
|
||||
}
|
||||
//Fill
|
||||
if (flags & (RenderUpdateFlag::Gradient | RenderUpdateFlag::Transform)) {
|
||||
auto fill = sdata.fill();
|
||||
if (fill) {
|
||||
auto ctable = (flags & RenderUpdateFlag::Gradient) ? true : false;
|
||||
if (ctable) shapeResetFill(shape);
|
||||
if (!shapeGenFillColors(shape, fill, matrix, surface, ctable)) return shape;
|
||||
} else {
|
||||
shapeDelFill(shape);
|
||||
}
|
||||
}
|
||||
//Stroke
|
||||
if (flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
|
||||
if (strokeAlpha > 0) {
|
||||
shapeResetStroke(shape, &sdata, matrix);
|
||||
if (!shapeGenStrokeRle(shape, &sdata, matrix, clip)) return shape;
|
||||
} else {
|
||||
shapeDelStroke(shape);
|
||||
}
|
||||
}
|
||||
shapeDelOutline(shape);
|
||||
}
|
||||
//Fill
|
||||
if (flags & (RenderUpdateFlag::Gradient | RenderUpdateFlag::Transform)) {
|
||||
auto fill = sdata.fill();
|
||||
if (fill) {
|
||||
auto ctable = (flags & RenderUpdateFlag::Gradient) ? true : false;
|
||||
if (ctable) shapeResetFill(shape);
|
||||
if (!shapeGenFillColors(shape, fill, matrix, surface, ctable)) return shape;
|
||||
} else {
|
||||
shapeDelFill(shape);
|
||||
}
|
||||
}
|
||||
//Stroke
|
||||
if (flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
|
||||
if (strokeAlpha > 0) {
|
||||
shapeResetStroke(shape, &sdata, matrix);
|
||||
if (!shapeGenStrokeRle(shape, &sdata, matrix, clip)) return shape;
|
||||
} else {
|
||||
shapeDelStroke(shape);
|
||||
}
|
||||
}
|
||||
shapeDelOutline(shape);
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
@ -182,4 +182,4 @@ SwRenderer* SwRenderer::inst()
|
|||
{
|
||||
//We know renderer type, avoid dynamic_cast for performance.
|
||||
return static_cast<SwRenderer*>(RenderInitializer::inst(renderInit));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ void testCapi()
|
|||
{.offset=1.0, .r=0, .g=0, .b=255, .a=255}
|
||||
};
|
||||
|
||||
|
||||
Tvg_Paint *shape1 = tvg_shape_new();
|
||||
tvg_shape_append_rect(shape1, 500, 500, 100, 100, 30, 30);
|
||||
Tvg_Gradient* grad1 = tvg_radial_gradient_new();
|
||||
|
@ -103,9 +102,23 @@ void testCapi()
|
|||
};
|
||||
tvg_gradient_color_stops(grad5, color_stops5, 2);
|
||||
tvg_shape_linear_gradient_set(shape4, grad5);
|
||||
|
||||
tvg_canvas_push(canvas, shape4);
|
||||
|
||||
Tvg_Gradient* grad6 = tvg_radial_gradient_new();
|
||||
tvg_radial_gradient_set(grad6, 550, 550, 50);
|
||||
Tvg_Color_Stop color_stops6[2] =
|
||||
{
|
||||
{.offset=0.0, .r=0, .g=125, .b=0, .a=255},
|
||||
{.offset=1, .r=125, .g=0, .b=125, .a=255},
|
||||
};
|
||||
tvg_gradient_color_stops(grad6, color_stops6, 2);
|
||||
tvg_shape_radial_gradient_set(shape1, grad6);
|
||||
tvg_canvas_update(canvas);
|
||||
|
||||
tvg_shape_set_stroke_width(shape,3);
|
||||
tvg_shape_set_stroke_color(shape, 125, 0, 125, 255);
|
||||
tvg_canvas_update_paint(canvas, shape);
|
||||
|
||||
tvg_canvas_draw(canvas);
|
||||
tvg_canvas_sync(canvas);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue