From 13ab97b2a0564f3276dcc98101d6cc1f4fec5ab0 Mon Sep 17 00:00:00 2001 From: subhransu sekhar mohanty Date: Sun, 15 Jul 2018 11:59:30 +0900 Subject: [PATCH] lottie/vector: move all vector objects to its own namesapce Change-Id: I1f7ebc743b45d2ae0857f5d645ca1495e382b3c3 --- src/lottie/lottieitem.h | 2 ++ src/lottie/lottiemodel.h | 1 + src/vector/vbezier.cpp | 4 +++- src/vector/vbezier.h | 3 +++ src/vector/vbitmap.cpp | 3 +++ src/vector/vbitmap.h | 4 ++++ src/vector/vbrush.cpp | 4 ++++ src/vector/vbrush.h | 4 ++++ src/vector/vdasher.cpp | 3 +++ src/vector/vdasher.h | 6 ++++++ src/vector/vdrawhelper.h | 2 ++ src/vector/vglobal.h | 14 ++++++++++++++ src/vector/vinterpolator.cpp | 4 ++++ src/vector/vinterpolator.h | 5 +++++ src/vector/vmatrix.cpp | 3 +++ src/vector/vmatrix.h | 4 ++++ src/vector/vpainter.cpp | 4 ++++ src/vector/vpainter.h | 4 ++++ src/vector/vpath.cpp | 4 ++++ src/vector/vpath.h | 4 ++++ src/vector/vpathmesure.cpp | 6 +++++- src/vector/vpathmesure.h | 4 ++++ src/vector/vpoint.h | 4 ++++ src/vector/vraster.cpp | 4 ++++ src/vector/vraster.h | 5 +++++ src/vector/vrect.h | 4 ++++ src/vector/vregion.cpp | 4 ++++ src/vector/vregion.h | 5 +++++ src/vector/vrle.cpp | 3 +++ src/vector/vrle.h | 4 ++++ 30 files changed, 123 insertions(+), 2 deletions(-) diff --git a/src/lottie/lottieitem.h b/src/lottie/lottieitem.h index 829ac07..d6e9261 100644 --- a/src/lottie/lottieitem.h +++ b/src/lottie/lottieitem.h @@ -12,6 +12,8 @@ #include"vbrush.h" #include"vpainter.h" +V_USE_NAMESPACE + enum class DirtyFlagBit { None = 0x0001, diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index 80cca54..e6c5d9d 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -12,6 +12,7 @@ #include"vbrush.h" #include"vpath.h" +V_USE_NAMESPACE class LOTCompositionData; class LOTLayerData; diff --git a/src/vector/vbezier.cpp b/src/vector/vbezier.cpp index 3ae1e1d..34e5093 100644 --- a/src/vector/vbezier.cpp +++ b/src/vector/vbezier.cpp @@ -2,6 +2,8 @@ #include +V_BEGIN_NAMESPACE + // Approximate sqrt(x*x + y*y) using the alpha max plus beta min algorithm. // This uses alpha = 1, beta = 3/8, which results in a maximum error of less // than 7% compared to the correct value. @@ -112,5 +114,5 @@ VBezier::splitAtLength(float len, VBezier *left, VBezier *right) right->parameterSplitLeft(t, left); } - +V_END_NAMESPACE diff --git a/src/vector/vbezier.h b/src/vector/vbezier.h index 92f4418..dd3f4cf 100644 --- a/src/vector/vbezier.h +++ b/src/vector/vbezier.h @@ -3,6 +3,8 @@ #include +V_BEGIN_NAMESPACE + class VBezier { public: @@ -106,5 +108,6 @@ inline void VBezier::split(VBezier *firstHalf, VBezier *secondHalf) const firstHalf->y4 = secondHalf->y1 = (firstHalf->y3 + secondHalf->y2)*.5; } +V_END_NAMESPACE #endif //VBEZIER_H diff --git a/src/vector/vbitmap.cpp b/src/vector/vbitmap.cpp index 4746df9..a8edd23 100644 --- a/src/vector/vbitmap.cpp +++ b/src/vector/vbitmap.cpp @@ -2,6 +2,8 @@ #include "vglobal.h" #include +V_BEGIN_NAMESPACE + struct VBitmapData { ~VBitmapData(); @@ -280,3 +282,4 @@ void VBitmap::fill(uint pixel) return; } +V_END_NAMESPACE diff --git a/src/vector/vbitmap.h b/src/vector/vbitmap.h index 5017063..ca3f2a1 100644 --- a/src/vector/vbitmap.h +++ b/src/vector/vbitmap.h @@ -3,6 +3,8 @@ #include "vrect.h" +V_BEGIN_NAMESPACE + struct VBitmapData; typedef void (*VBitmapCleanupFunction)(void *); class VBitmap @@ -44,4 +46,6 @@ private: VBitmapData *d; }; +V_END_NAMESPACE + #endif // VBITMAP_H diff --git a/src/vector/vbrush.cpp b/src/vector/vbrush.cpp index aa8ba96..55b015d 100644 --- a/src/vector/vbrush.cpp +++ b/src/vector/vbrush.cpp @@ -1,5 +1,7 @@ #include"vbrush.h" +V_BEGIN_NAMESPACE + VGradient::VGradient(VGradient::Type type):mType(type), mSpread(VGradient::Spread::Pad), mMode(VGradient::Mode::Absolute) { @@ -75,3 +77,5 @@ VBrush::VBrush(const VGradient *gradient):mType(VBrush::Type::NoBrush) mType = VBrush::Type::RadialGradient; } } + +V_END_NAMESPACE diff --git a/src/vector/vbrush.h b/src/vector/vbrush.h index e93c9b1..772019f 100644 --- a/src/vector/vbrush.h +++ b/src/vector/vbrush.h @@ -6,6 +6,8 @@ #include"vmatrix.h" #include +V_BEGIN_NAMESPACE + typedef std::pair VGradientStop; typedef std::vector VGradientStops; class VGradient @@ -79,4 +81,6 @@ public: const VGradient *mGradient; }; +V_END_NAMESPACE + #endif // VBRUSH_H diff --git a/src/vector/vdasher.cpp b/src/vector/vdasher.cpp index f819bf9..8c9f738 100644 --- a/src/vector/vdasher.cpp +++ b/src/vector/vdasher.cpp @@ -1,6 +1,8 @@ #include"vdasher.h" #include"vbezier.h" +V_BEGIN_NAMESPACE + class VLine { public: @@ -238,3 +240,4 @@ VPath VDasher::dashed(const VPath &path) return mDashedPath; } +V_END_NAMESPACE diff --git a/src/vector/vdasher.h b/src/vector/vdasher.h index ed97558..5b5c66d 100644 --- a/src/vector/vdasher.h +++ b/src/vector/vdasher.h @@ -1,6 +1,9 @@ #ifndef VDASHER_H #define VDASHER_H #include "vpath.h" + +V_BEGIN_NAMESPACE + class VDasher { public: @@ -26,4 +29,7 @@ private: float mDashOffset; VPath mDashedPath; }; + +V_END_NAMESPACE + #endif // VDASHER_H diff --git a/src/vector/vdrawhelper.h b/src/vector/vdrawhelper.h index 0826f00..b480705 100644 --- a/src/vector/vdrawhelper.h +++ b/src/vector/vdrawhelper.h @@ -9,6 +9,8 @@ #include"assert.h" #include +V_USE_NAMESPACE + struct VSpanData; struct Operator; diff --git a/src/vector/vglobal.h b/src/vector/vglobal.h index fb96f30..aa9e617 100644 --- a/src/vector/vglobal.h +++ b/src/vector/vglobal.h @@ -12,6 +12,20 @@ typedef uint16_t ushort; typedef uint8_t uchar; +#if !defined(V_NAMESPACE) + +# define V_USE_NAMESPACE +# define V_BEGIN_NAMESPACE +# define V_END_NAMESPACE + +#else /* user namespace */ + +# define V_USE_NAMESPACE using namespace ::V_NAMESPACE; +# define V_BEGIN_NAMESPACE namespace V_NAMESPACE { +# define V_END_NAMESPACE } + +#endif + #define V_UNUSED __attribute__((__unused__)) #define V_REQUIRED_RESULT __attribute__ ((__warn_unused_result__)) diff --git a/src/vector/vinterpolator.cpp b/src/vector/vinterpolator.cpp index 5c285f6..90f0936 100644 --- a/src/vector/vinterpolator.cpp +++ b/src/vector/vinterpolator.cpp @@ -1,6 +1,8 @@ #include"vinterpolator.h" #include +V_BEGIN_NAMESPACE + #define NEWTON_ITERATIONS 4 #define NEWTON_MIN_SLOPE 0.02 #define SUBDIVISION_PRECISION 0.0000001 @@ -128,3 +130,5 @@ VInterpolator::BinarySubdivide(float aX, float aA, float aB) const return currentT; } + +V_END_NAMESPACE diff --git a/src/vector/vinterpolator.h b/src/vector/vinterpolator.h index 23c78e8..f609d0c 100644 --- a/src/vector/vinterpolator.h +++ b/src/vector/vinterpolator.h @@ -3,6 +3,8 @@ #include "vpoint.h" +V_BEGIN_NAMESPACE + class VInterpolator { public: @@ -76,4 +78,7 @@ private: float mSampleValues[kSplineTableSize]; static const float kSampleStepSize; }; + +V_END_NAMESPACE + #endif // VINTERPOLATOR_H diff --git a/src/vector/vmatrix.cpp b/src/vector/vmatrix.cpp index 9f47484..ad5192d 100644 --- a/src/vector/vmatrix.cpp +++ b/src/vector/vmatrix.cpp @@ -4,6 +4,8 @@ #include #include +V_BEGIN_NAMESPACE + /* m11 m21 mtx * m12 m22 mty * m13 m23 m33 @@ -832,4 +834,5 @@ float VMatrix::m33()const return d->m33; } +V_END_NAMESPACE diff --git a/src/vector/vmatrix.h b/src/vector/vmatrix.h index 4e43b47..10c632a 100644 --- a/src/vector/vmatrix.h +++ b/src/vector/vmatrix.h @@ -4,6 +4,8 @@ #include "vregion.h" #include "vglobal.h" +V_BEGIN_NAMESPACE + struct VMatrixData; class VMatrix { @@ -89,4 +91,6 @@ inline VPointF VMatrix::map(float x, float y) const return map(VPointF(x, y)); } +V_END_NAMESPACE + #endif // VMATRIX_H diff --git a/src/vector/vpainter.cpp b/src/vector/vpainter.cpp index 5d3f4eb..56fbf41 100644 --- a/src/vector/vpainter.cpp +++ b/src/vector/vpainter.cpp @@ -1,6 +1,8 @@ #include"vpainter.h" #include"vdrawhelper.h" +V_BEGIN_NAMESPACE + class VPainterImpl { public: @@ -62,3 +64,5 @@ void VPainter::drawRle(const VPoint &pos, const VRle &rle) { mImpl->drawRle(pos, rle); } + +V_END_NAMESPACE diff --git a/src/vector/vpainter.h b/src/vector/vpainter.h index 740f732..d7977fb 100644 --- a/src/vector/vpainter.h +++ b/src/vector/vpainter.h @@ -5,6 +5,8 @@ #include"vrle.h" #include"vbrush.h" +V_BEGIN_NAMESPACE + class VBitmap; class VPainterImpl; class VPainter { @@ -24,4 +26,6 @@ private: VPainterImpl *mImpl; }; +V_END_NAMESPACE + #endif //VPAINTER_H diff --git a/src/vector/vpath.cpp b/src/vector/vpath.cpp index 60f4c92..4df2918 100644 --- a/src/vector/vpath.cpp +++ b/src/vector/vpath.cpp @@ -5,6 +5,8 @@ #include"vbezier.h" #include "vrect.h" +V_BEGIN_NAMESPACE + struct VPathData { void copy(VPathData *o); @@ -733,3 +735,5 @@ void VPath::transform(const VMatrix &m) detach(); d->transform(m); } + +V_END_NAMESPACE diff --git a/src/vector/vpath.h b/src/vector/vpath.h index 93c4f53..2fe0b9d 100644 --- a/src/vector/vpath.h +++ b/src/vector/vpath.h @@ -5,6 +5,8 @@ #include "vmatrix.h" #include +V_BEGIN_NAMESPACE + struct VPathData; class VPath { @@ -77,4 +79,6 @@ inline void VPath::cubicTo(float c1x, float c1y, float c2x, float c2y, float ex, cubicTo(VPointF(c1x, c1y), VPointF(c2x, c2y), VPointF(ex, ey)); } +V_END_NAMESPACE + #endif // VPATH_H diff --git a/src/vector/vpathmesure.cpp b/src/vector/vpathmesure.cpp index 358721c..cabbe42 100644 --- a/src/vector/vpathmesure.cpp +++ b/src/vector/vpathmesure.cpp @@ -1,6 +1,10 @@ #include"vpathmesure.h" +V_BEGIN_NAMESPACE + class VPathMesureData { VPath *path; -}; \ No newline at end of file +}; + +V_END_NAMESPACE diff --git a/src/vector/vpathmesure.h b/src/vector/vpathmesure.h index 98605f7..0a97fc1 100644 --- a/src/vector/vpathmesure.h +++ b/src/vector/vpathmesure.h @@ -3,6 +3,8 @@ #include "vpath.h" +V_BEGIN_NAMESPACE + class VPathMesureData; class VPathMesure { @@ -15,4 +17,6 @@ private: VPathMesureData *d; }; +V_END_NAMESPACE + #endif // VPATHMESURE_H diff --git a/src/vector/vpoint.h b/src/vector/vpoint.h index 7eb2af5..9206856 100644 --- a/src/vector/vpoint.h +++ b/src/vector/vpoint.h @@ -3,6 +3,8 @@ #include"vglobal.h" +V_BEGIN_NAMESPACE + class VPointF { public: @@ -144,4 +146,6 @@ inline VSize &VSize::operator+=(const VSize &p) noexcept inline VSize &VSize::operator-=(const VSize &p) noexcept { mw-=p.mw; mh-=p.mh; return *this; } +V_END_NAMESPACE + #endif // VPOINT_H diff --git a/src/vector/vraster.cpp b/src/vector/vraster.cpp index 0bd3a2c..3328977 100644 --- a/src/vector/vraster.cpp +++ b/src/vector/vraster.cpp @@ -6,6 +6,8 @@ #include #include"vdebug.h" +V_BEGIN_NAMESPACE + struct FTOutline { public: @@ -312,3 +314,5 @@ VRle VRaster::generateStrokeInfo(const FTOutline *outline, CapStyle cap, JoinSty return d->generateStrokeInfoAsync(&outline->ft, ftCap, ftJoin, ftWidth, ftMeterLimit, ftbool); } + +V_END_NAMESPACE diff --git a/src/vector/vraster.h b/src/vector/vraster.h index 7beda50..5b8d0ad 100644 --- a/src/vector/vraster.h +++ b/src/vector/vraster.h @@ -3,6 +3,8 @@ #include"vrle.h" #include +V_BEGIN_NAMESPACE + struct FTOutline; class VPath; @@ -30,4 +32,7 @@ private: VRaster(); VRasterPrivate *d; }; + +V_END_NAMESPACE + #endif // VRASTER_H diff --git a/src/vector/vrect.h b/src/vector/vrect.h index 0f002df..c16ecab 100644 --- a/src/vector/vrect.h +++ b/src/vector/vrect.h @@ -3,6 +3,8 @@ #include"vglobal.h" #include"vpoint.h" +V_BEGIN_NAMESPACE + class VRect { public: @@ -181,4 +183,6 @@ V_CONSTEXPR inline float VRectF::width() const V_CONSTEXPR inline float VRectF::height() const { return y2 - y1; } +V_END_NAMESPACE + #endif // VRECT_H diff --git a/src/vector/vregion.cpp b/src/vector/vregion.cpp index 3db9ad2..a0cd00e 100644 --- a/src/vector/vregion.cpp +++ b/src/vector/vregion.cpp @@ -2041,6 +2041,8 @@ typedef region_type_t VRegionPrivate; #include "vregion.h" +V_BEGIN_NAMESPACE + static VRegionPrivate regionPrivate = {{0,0,0,0}, NULL}; const VRegion::VRegionData VRegion::shared_empty = {RefCount(-1), ®ionPrivate}; @@ -2366,3 +2368,5 @@ VDebug& operator<<(VDebug& os, const VRegion& o) } +V_END_NAMESPACE + diff --git a/src/vector/vregion.h b/src/vector/vregion.h index 75e7c38..e5986af 100644 --- a/src/vector/vregion.h +++ b/src/vector/vregion.h @@ -6,6 +6,8 @@ #include #include +V_BEGIN_NAMESPACE + typedef struct pixman_region region_type_t; typedef region_type_t VRegionPrivate; @@ -70,4 +72,7 @@ inline VRegion VRegion::translated(int dx, int dy) const { return translated(VPoint(dx,dy)); } + +V_END_NAMESPACE + #endif //VREGION_H diff --git a/src/vector/vrle.cpp b/src/vector/vrle.cpp index a7a70de..df0f24e 100644 --- a/src/vector/vrle.cpp +++ b/src/vector/vrle.cpp @@ -8,6 +8,8 @@ #include"vdebug.h" #include"vregion.h" +V_BEGIN_NAMESPACE + struct VRleHelper { ushort alloc; @@ -804,6 +806,7 @@ VDebug& operator<<(VDebug& os, const VRle& o) return os; } +V_END_NAMESPACE diff --git a/src/vector/vrle.h b/src/vector/vrle.h index 4697b1f..0fe3bcf 100644 --- a/src/vector/vrle.h +++ b/src/vector/vrle.h @@ -4,6 +4,8 @@ #include #include +V_BEGIN_NAMESPACE + struct VRleData; class VRle { @@ -59,4 +61,6 @@ inline VRle operator*(int alpha, const VRle &rle) return (rle * alpha); } +V_END_NAMESPACE + #endif // VRLE_H -- 2.7.4