bool firstPt;
bool openSubPath;
bool handleWideStrokes;
+ bool preScaled;
};
struct SwDashStroke
bool shapePrepare(SwShape& shape, const Shape* sdata, const SwSize& clip, const Matrix* transform);
bool shapeGenRle(SwShape& shape, const Shape* sdata, const SwSize& clip, bool antiAlias);
void shapeDelOutline(SwShape& shape);
-void shapeResetStroke(SwShape& shape, const Shape* sdata);
+void shapeResetStroke(SwShape& shape, const Shape* sdata, const Matrix* transform);
bool shapeGenStrokeRle(SwShape& shape, const Shape* sdata, const Matrix* transform, const SwSize& clip);
void shapeFree(SwShape& shape);
void shapeDelStroke(SwShape& shape);
void shapeResetFill(SwShape& shape);
void shapeDelFill(SwShape& shape);
-void strokeReset(SwStroke& stroke, const Shape* shape);
+void strokeReset(SwStroke& stroke, const Shape* shape, const Matrix* transform);
bool strokeParseOutline(SwStroke& stroke, const SwOutline& outline);
SwOutline* strokeExportOutline(SwStroke& stroke);
void strokeFree(SwStroke* stroke);
//Stroke
if (task->flags & (RenderUpdateFlag::Stroke | RenderUpdateFlag::Transform)) {
if (strokeAlpha > 0) {
- shapeResetStroke(task->shape, task->sdata);
+ shapeResetStroke(task->shape, task->sdata, task->transform);
if (!shapeGenStrokeRle(task->shape, task->sdata, task->transform, task->clip)) return;
} else {
shapeDelStroke(task->shape);
return static_cast<SwRenderer*>(RenderInitializer::inst(renderInit));
}
-#endif /* _TVG_SW_RENDERER_CPP_ */
+#endif /* _TVG_SW_RENDERER_CPP_ */
\ No newline at end of file
}
-void shapeResetStroke(SwShape& shape, const Shape* sdata)
+void shapeResetStroke(SwShape& shape, const Shape* sdata, const Matrix* transform)
{
if (!shape.stroke) shape.stroke = static_cast<SwStroke*>(calloc(1, sizeof(SwStroke)));
auto stroke = shape.stroke;
assert(stroke);
- strokeReset(*stroke, sdata);
+ strokeReset(*stroke, sdata, transform);
rleFree(shape.strokeRle);
shape.strokeRle = nullptr;
}
-void strokeReset(SwStroke& stroke, const Shape* sdata)
+void strokeReset(SwStroke& stroke, const Shape* sdata, const Matrix* transform)
{
assert(sdata);
- stroke.width = TO_SWCOORD(sdata->strokeWidth() * 0.5);
+ //If x/y scale factor is identical, we can scale width size simply.
+ auto scale = 1.0f;
+ if (transform && fabsf(transform->e11 - transform->e22) < FLT_EPSILON) {
+ scale = transform->e11;
+ stroke.preScaled = true;
+ }
+
+ stroke.width = TO_SWCOORD(sdata->strokeWidth() * 0.5 * scale);
stroke.cap = sdata->strokeCap();
//Save line join: it can be temporarily changed when stroking curves...
struct RenderTransform
{
- Matrix m; //3x3 Matrix Elements
+ Matrix m; //3x3 Matrix Elements
float x = 0.0f;
float y = 0.0f;
float degree = 0.0f; //rotation degree