From 6c6cc9b230add3f487735d9fc990513c82b16fdc Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 19 Jul 2021 20:07:58 +0900 Subject: [PATCH] common: code refactoring unify tvg class identifiers --- src/lib/sw_engine/tvgSwFill.cpp | 4 ++-- src/lib/sw_engine/tvgSwRaster.cpp | 6 +++--- src/lib/tvgCommon.h | 13 +++++++------ src/lib/tvgLinearGradient.cpp | 2 +- src/lib/tvgPicture.cpp | 2 +- src/lib/tvgRadialGradient.cpp | 2 +- src/lib/tvgSaverImpl.h | 8 ++++---- src/lib/tvgScene.cpp | 2 +- src/lib/tvgSceneImpl.h | 2 +- src/lib/tvgShape.cpp | 2 +- 10 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/lib/sw_engine/tvgSwFill.cpp b/src/lib/sw_engine/tvgSwFill.cpp index 19eda1c..ac7b57f 100644 --- a/src/lib/sw_engine/tvgSwFill.cpp +++ b/src/lib/sw_engine/tvgSwFill.cpp @@ -276,9 +276,9 @@ bool fillGenColorTable(SwFill* fill, const Fill* fdata, const Matrix* transform, if (!_updateColorTable(fill, fdata, surface, opacity)) return false; } - if (fdata->id() == FILL_ID_LINEAR) { + if (fdata->id() == TVG_CLASS_ID_LINEAR) { return _prepareLinear(fill, static_cast(fdata), transform); - } else if (fdata->id() == FILL_ID_RADIAL) { + } else if (fdata->id() == TVG_CLASS_ID_RADIAL) { return _prepareRadial(fill, static_cast(fdata), transform); } diff --git a/src/lib/sw_engine/tvgSwRaster.cpp b/src/lib/sw_engine/tvgSwRaster.cpp index b41da00..169da04 100644 --- a/src/lib/sw_engine/tvgSwRaster.cpp +++ b/src/lib/sw_engine/tvgSwRaster.cpp @@ -1104,7 +1104,7 @@ bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id) //Fast Track if (shape->rect) { - if (id == FILL_ID_LINEAR) { + if (id == TVG_CLASS_ID_LINEAR) { if (translucent) return _rasterTranslucentLinearGradientRect(surface, shape->bbox, shape->fill); return _rasterOpaqueLinearGradientRect(surface, shape->bbox, shape->fill); } else { @@ -1113,7 +1113,7 @@ bool rasterGradientShape(SwSurface* surface, SwShape* shape, unsigned id) } } else { if (!shape->rle) return false; - if (id == FILL_ID_LINEAR) { + if (id == TVG_CLASS_ID_LINEAR) { if (translucent) return _rasterTranslucentLinearGradientRle(surface, shape->rle, shape->fill); return _rasterOpaqueLinearGradientRle(surface, shape->rle, shape->fill); } else { @@ -1170,7 +1170,7 @@ bool rasterGradientStroke(SwSurface* surface, SwShape* shape, unsigned id) auto translucent = shape->stroke->fill->translucent || (surface->compositor && surface->compositor->method != CompositeMethod::None); - if (id == FILL_ID_LINEAR) { + if (id == TVG_CLASS_ID_LINEAR) { if (translucent) return _rasterTranslucentLinearGradientRle(surface, shape->strokeRle, shape->stroke->fill); return _rasterOpaqueLinearGradientRle(surface, shape->strokeRle, shape->stroke->fill); } else { diff --git a/src/lib/tvgCommon.h b/src/lib/tvgCommon.h index 1be9fb1..6ef28b3 100644 --- a/src/lib/tvgCommon.h +++ b/src/lib/tvgCommon.h @@ -28,12 +28,13 @@ using namespace std; using namespace tvg; -#define FILL_ID_LINEAR 0 -#define FILL_ID_RADIAL 1 - -#define PAINT_ID_SHAPE 0 -#define PAINT_ID_SCENE 1 -#define PAINT_ID_PICTURE 2 +//TVG class identifier values +#define TVG_CLASS_ID_UNDEFINED 0 +#define TVG_CLASS_ID_SHAPE 1 +#define TVG_CLASS_ID_SCENE 2 +#define TVG_CLASS_ID_PICTURE 3 +#define TVG_CLASS_ID_LINEAR 4 +#define TVG_CLASS_ID_RADIAL 5 //for MSVC Compat #ifdef _MSC_VER diff --git a/src/lib/tvgLinearGradient.cpp b/src/lib/tvgLinearGradient.cpp index 2374353..57f2b3f 100644 --- a/src/lib/tvgLinearGradient.cpp +++ b/src/lib/tvgLinearGradient.cpp @@ -54,7 +54,7 @@ struct LinearGradient::Impl LinearGradient::LinearGradient():pImpl(new Impl()) { - _id = FILL_ID_LINEAR; + _id = TVG_CLASS_ID_LINEAR; Fill::pImpl->method(new FillDup(pImpl)); } diff --git a/src/lib/tvgPicture.cpp b/src/lib/tvgPicture.cpp index acfe2b0..7fda461 100644 --- a/src/lib/tvgPicture.cpp +++ b/src/lib/tvgPicture.cpp @@ -28,7 +28,7 @@ Picture::Picture() : pImpl(new Impl(this)) { - _id = PAINT_ID_PICTURE; + _id = TVG_CLASS_ID_PICTURE; Paint::pImpl->method(new PaintMethod(pImpl)); } diff --git a/src/lib/tvgRadialGradient.cpp b/src/lib/tvgRadialGradient.cpp index fac2d4e..2680286 100644 --- a/src/lib/tvgRadialGradient.cpp +++ b/src/lib/tvgRadialGradient.cpp @@ -52,7 +52,7 @@ struct RadialGradient::Impl RadialGradient::RadialGradient():pImpl(new Impl()) { - _id = FILL_ID_RADIAL; + _id = TVG_CLASS_ID_RADIAL; Fill::pImpl->method(new FillDup(pImpl)); } diff --git a/src/lib/tvgSaverImpl.h b/src/lib/tvgSaverImpl.h index 8013238..deba0f2 100644 --- a/src/lib/tvgSaverImpl.h +++ b/src/lib/tvgSaverImpl.h @@ -248,7 +248,7 @@ struct Saver::Impl writeMemberIndicator(fillTvgFlag); skipInBufferMemberDataSize(); - if (f->id() == FILL_ID_RADIAL) { + if (f->id() == TVG_CLASS_ID_RADIAL) { float argRadial[3]; auto radGrad = static_cast(f); if (radGrad->radial(argRadial, argRadial + 1,argRadial + 2) != Result::Success) { @@ -459,15 +459,15 @@ struct Saver::Impl ByteCounter dataByteCnt = 0; switch (paint->id()) { - case PAINT_ID_SHAPE: { + case TVG_CLASS_ID_SHAPE: { dataByteCnt += serializeShape(paint); break; } - case PAINT_ID_SCENE: { + case TVG_CLASS_ID_SCENE: { dataByteCnt += serializeScene(paint); break; } - case PAINT_ID_PICTURE: { + case TVG_CLASS_ID_PICTURE: { dataByteCnt += serializePicture(paint); break; } diff --git a/src/lib/tvgScene.cpp b/src/lib/tvgScene.cpp index 9ec6f05..08cc743 100644 --- a/src/lib/tvgScene.cpp +++ b/src/lib/tvgScene.cpp @@ -27,7 +27,7 @@ Scene::Scene() : pImpl(new Impl(this)) { - _id = PAINT_ID_SCENE; + _id = TVG_CLASS_ID_SCENE; Paint::pImpl->method(new PaintMethod(pImpl)); } diff --git a/src/lib/tvgSceneImpl.h b/src/lib/tvgSceneImpl.h index d4ef719..eb062be 100644 --- a/src/lib/tvgSceneImpl.h +++ b/src/lib/tvgSceneImpl.h @@ -65,7 +65,7 @@ struct Scene::Impl //If scene has several children or only scene, it may require composition. if (paints.count > 1) return true; - if (paints.count == 1 && (*paints.data)->id() == PAINT_ID_SCENE) return true; + if (paints.count == 1 && (*paints.data)->id() == TVG_CLASS_ID_SCENE) return true; return false; } diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index 3e67195..1ba9a46 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -38,7 +38,7 @@ constexpr auto PATH_KAPPA = 0.552284f; Shape :: Shape() : pImpl(new Impl(this)) { - _id = PAINT_ID_SHAPE; + _id = TVG_CLASS_ID_SHAPE; Paint::pImpl->method(new PaintMethod(pImpl)); } -- 2.7.4