common: code refactoring

unify tvg class identifiers
This commit is contained in:
Hermet Park 2021-07-19 20:07:58 +09:00 committed by Hermet Park
parent 0150391f03
commit b13dec31cd
10 changed files with 22 additions and 21 deletions

View file

@ -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<const LinearGradient*>(fdata), transform);
} else if (fdata->id() == FILL_ID_RADIAL) {
} else if (fdata->id() == TVG_CLASS_ID_RADIAL) {
return _prepareRadial(fill, static_cast<const RadialGradient*>(fdata), transform);
}

View file

@ -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 {

View file

@ -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

View file

@ -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<LinearGradient::Impl>(pImpl));
}

View file

@ -28,7 +28,7 @@
Picture::Picture() : pImpl(new Impl(this))
{
_id = PAINT_ID_PICTURE;
_id = TVG_CLASS_ID_PICTURE;
Paint::pImpl->method(new PaintMethod<Picture::Impl>(pImpl));
}

View file

@ -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<RadialGradient::Impl>(pImpl));
}

View file

@ -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<const RadialGradient*>(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;
}

View file

@ -27,7 +27,7 @@
Scene::Scene() : pImpl(new Impl(this))
{
_id = PAINT_ID_SCENE;
_id = TVG_CLASS_ID_SCENE;
Paint::pImpl->method(new PaintMethod<Scene::Impl>(pImpl));
}

View file

@ -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;
}

View file

@ -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<Shape::Impl>(pImpl));
}