mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
renderer: code clean++
This commit is contained in:
parent
4c3beb1cb1
commit
4cf68b75e5
5 changed files with 14 additions and 9 deletions
|
@ -1357,7 +1357,7 @@ bool GlRenderer::renderShape(RenderData data)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (sdata->rshape->stroke && sdata->rshape->stroke->strokeFirst) {
|
if (sdata->rshape->strokeFirst()) {
|
||||||
processStroke();
|
processStroke();
|
||||||
processFill();
|
processFill();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct SwShapeTask : SwTask
|
||||||
Additionally, the stroke style should not be dashed. */
|
Additionally, the stroke style should not be dashed. */
|
||||||
bool antialiasing(float strokeWidth)
|
bool antialiasing(float strokeWidth)
|
||||||
{
|
{
|
||||||
return strokeWidth < 2.0f || rshape->stroke->dash.count > 0 || rshape->stroke->strokeFirst || rshape->trimpath() || rshape->stroke->color.a < 255;
|
return strokeWidth < 2.0f || rshape->stroke->dash.count > 0 || rshape->stroke->first || rshape->trimpath() || rshape->stroke->color.a < 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
float validStrokeWidth(bool clipper)
|
float validStrokeWidth(bool clipper)
|
||||||
|
@ -418,7 +418,7 @@ bool SwRenderer::renderShape(RenderData data)
|
||||||
if (task->opacity == 0) return true;
|
if (task->opacity == 0) return true;
|
||||||
|
|
||||||
//Main raster stage
|
//Main raster stage
|
||||||
if (task->rshape->stroke && task->rshape->stroke->strokeFirst) {
|
if (task->rshape->strokeFirst()) {
|
||||||
_renderStroke(task, surface, task->opacity);
|
_renderStroke(task, surface, task->opacity);
|
||||||
_renderFill(task, surface, task->opacity);
|
_renderFill(task, surface, task->opacity);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -150,7 +150,7 @@ struct RenderStroke
|
||||||
RenderTrimPath trim;
|
RenderTrimPath trim;
|
||||||
StrokeCap cap = StrokeCap::Square;
|
StrokeCap cap = StrokeCap::Square;
|
||||||
StrokeJoin join = StrokeJoin::Bevel;
|
StrokeJoin join = StrokeJoin::Bevel;
|
||||||
bool strokeFirst = false;
|
bool first = false;
|
||||||
|
|
||||||
void operator=(const RenderStroke& rhs)
|
void operator=(const RenderStroke& rhs)
|
||||||
{
|
{
|
||||||
|
@ -174,7 +174,7 @@ struct RenderStroke
|
||||||
miterlimit = rhs.miterlimit;
|
miterlimit = rhs.miterlimit;
|
||||||
cap = rhs.cap;
|
cap = rhs.cap;
|
||||||
join = rhs.join;
|
join = rhs.join;
|
||||||
strokeFirst = rhs.strokeFirst;
|
first = rhs.first;
|
||||||
trim = rhs.trim;
|
trim = rhs.trim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +213,11 @@ struct RenderShape
|
||||||
return stroke->trim.valid();
|
return stroke->trim.valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool strokeFirst() const
|
||||||
|
{
|
||||||
|
return (stroke && stroke->first) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
float strokeWidth() const
|
float strokeWidth() const
|
||||||
{
|
{
|
||||||
if (!stroke) return 0;
|
if (!stroke) return 0;
|
||||||
|
|
|
@ -320,13 +320,13 @@ struct ShapeImpl : Shape
|
||||||
bool strokeFirst()
|
bool strokeFirst()
|
||||||
{
|
{
|
||||||
if (!rs.stroke) return true;
|
if (!rs.stroke) return true;
|
||||||
return rs.stroke->strokeFirst;
|
return rs.stroke->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
void strokeFirst(bool strokeFirst)
|
void strokeFirst(bool first)
|
||||||
{
|
{
|
||||||
if (!rs.stroke) rs.stroke = new RenderStroke();
|
if (!rs.stroke) rs.stroke = new RenderStroke();
|
||||||
rs.stroke->strokeFirst = strokeFirst;
|
rs.stroke->first = first;
|
||||||
impl.mark(RenderUpdateFlag::Stroke);
|
impl.mark(RenderUpdateFlag::Stroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ void WgRenderDataShape::updateAABB(const Matrix& tr) {
|
||||||
void WgRenderDataShape::updateMeshes(WgContext& context, const RenderShape &rshape, const Matrix& tr, WgGeometryBufferPool* pool)
|
void WgRenderDataShape::updateMeshes(WgContext& context, const RenderShape &rshape, const Matrix& tr, WgGeometryBufferPool* pool)
|
||||||
{
|
{
|
||||||
releaseMeshes(context);
|
releaseMeshes(context);
|
||||||
strokeFirst = rshape.stroke ? rshape.stroke->strokeFirst : false;
|
strokeFirst = rshape.strokeFirst();
|
||||||
|
|
||||||
// get object scale
|
// get object scale
|
||||||
float scale = std::max(std::min(length(Point{tr.e11 + tr.e12,tr.e21 + tr.e22}), 8.0f), 1.0f);
|
float scale = std::max(std::min(length(Point{tr.e11 + tr.e12,tr.e21 + tr.e22}), 8.0f), 1.0f);
|
||||||
|
|
Loading…
Add table
Reference in a new issue