mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 12:34:30 +00:00
loader tvg: add missing strokeFirst property.
tvg binary missed the stroke order, this patch implements the missing condition. @Issue: https://github.com/thorvg/thorvg/issues/1499
This commit is contained in:
parent
1b7c882be4
commit
a74062d5f1
4 changed files with 27 additions and 3 deletions
|
@ -81,6 +81,7 @@ using TvgBinFlag = TvgBinByte;
|
||||||
#define TVG_TAG_SHAPE_STROKE_FILL (TvgBinTag)0x54
|
#define TVG_TAG_SHAPE_STROKE_FILL (TvgBinTag)0x54
|
||||||
#define TVG_TAG_SHAPE_STROKE_DASHPTRN (TvgBinTag)0x55
|
#define TVG_TAG_SHAPE_STROKE_DASHPTRN (TvgBinTag)0x55
|
||||||
#define TVG_TAG_SHAPE_STROKE_MITERLIMIT (TvgBinTag)0x56
|
#define TVG_TAG_SHAPE_STROKE_MITERLIMIT (TvgBinTag)0x56
|
||||||
|
#define TVG_TAG_SHAPE_STROKE_ORDER (TvgBinTag)0x57
|
||||||
|
|
||||||
|
|
||||||
//Fill
|
//Fill
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define _TVG_SHAPE_IMPL_H_
|
#define _TVG_SHAPE_IMPL_H_
|
||||||
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include "tvgMath.h"
|
||||||
#include "tvgPaint.h"
|
#include "tvgPaint.h"
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -294,6 +295,12 @@ struct Shape::Impl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool strokeFirst()
|
||||||
|
{
|
||||||
|
if (!rs.stroke) return true;
|
||||||
|
return rs.stroke->strokeFirst;
|
||||||
|
}
|
||||||
|
|
||||||
bool strokeFirst(bool strokeFirst)
|
bool strokeFirst(bool strokeFirst)
|
||||||
{
|
{
|
||||||
if (!rs.stroke) rs.stroke = new RenderStroke();
|
if (!rs.stroke) rs.stroke = new RenderStroke();
|
||||||
|
|
|
@ -31,8 +31,11 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "tvgTvgCommon.h"
|
#include "tvgTvgCommon.h"
|
||||||
|
#include "tvgShapeImpl.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define P(A) A->pImpl
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Internal Class Implementation */
|
/* Internal Class Implementation */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -287,6 +290,11 @@ static bool _parseShapeStroke(const char *ptr, const char *end, Shape *shape)
|
||||||
shape->stroke((StrokeJoin) *block.data);
|
shape->stroke((StrokeJoin) *block.data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case TVG_TAG_SHAPE_STROKE_ORDER: {
|
||||||
|
if (block.length != SIZE(TvgBinFlag)) return false;
|
||||||
|
P(shape)->strokeFirst((bool) *block.data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TVG_TAG_SHAPE_STROKE_WIDTH: {
|
case TVG_TAG_SHAPE_STROKE_WIDTH: {
|
||||||
if (block.length != SIZE(float)) return false;
|
if (block.length != SIZE(float)) return false;
|
||||||
float width;
|
float width;
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tvgMath.h"
|
#include <cstring>
|
||||||
|
|
||||||
#include "tvgSaveModule.h"
|
#include "tvgSaveModule.h"
|
||||||
#include "tvgTvgSaver.h"
|
#include "tvgTvgSaver.h"
|
||||||
#include "tvgLzw.h"
|
#include "tvgLzw.h"
|
||||||
|
#include "tvgShapeImpl.h"
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
@ -51,6 +51,8 @@ static FILE* _fopen(const char* filename, const char* mode)
|
||||||
|
|
||||||
#define SIZE(A) sizeof(A)
|
#define SIZE(A) sizeof(A)
|
||||||
|
|
||||||
|
#define P(A) A->pImpl
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* Internal Class Implementation */
|
/* Internal Class Implementation */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
@ -98,6 +100,8 @@ static bool _merge(Shape* from, Shape* to)
|
||||||
}
|
}
|
||||||
|
|
||||||
//stroke
|
//stroke
|
||||||
|
if (P(from)->strokeFirst() != P(to)->strokeFirst()) return false;
|
||||||
|
|
||||||
r = g = b = a = r2 = g2 = b2 = a2 = 0;
|
r = g = b = a = r2 = g2 = b2 = a2 = 0;
|
||||||
|
|
||||||
from->strokeColor(&r, &g, &b, &a);
|
from->strokeColor(&r, &g, &b, &a);
|
||||||
|
@ -455,6 +459,10 @@ TvgBinCounter TvgSaver::serializeStroke(const Shape* shape, const Matrix* pTrans
|
||||||
if (auto flag = static_cast<TvgBinFlag>(shape->strokeJoin()))
|
if (auto flag = static_cast<TvgBinFlag>(shape->strokeJoin()))
|
||||||
cnt += writeTagProperty(TVG_TAG_SHAPE_STROKE_JOIN, SIZE(TvgBinFlag), &flag);
|
cnt += writeTagProperty(TVG_TAG_SHAPE_STROKE_JOIN, SIZE(TvgBinFlag), &flag);
|
||||||
|
|
||||||
|
//order
|
||||||
|
if (auto flag = static_cast<TvgBinFlag>(P(shape)->strokeFirst()))
|
||||||
|
writeTagProperty(TVG_TAG_SHAPE_STROKE_ORDER, SIZE(TvgBinFlag), &flag);
|
||||||
|
|
||||||
//fill
|
//fill
|
||||||
if (auto fill = shape->strokeFill()) {
|
if (auto fill = shape->strokeFill()) {
|
||||||
cnt += serializeFill(fill, TVG_TAG_SHAPE_STROKE_FILL, (preTransform ? pTransform : nullptr));
|
cnt += serializeFill(fill, TVG_TAG_SHAPE_STROKE_FILL, (preTransform ? pTransform : nullptr));
|
||||||
|
|
Loading…
Add table
Reference in a new issue