common fill: code refactoring

removed unique_ptr in the interface because it's hard to get polymorphism benefits in programming perspective.
This commit is contained in:
Hermet Park 2020-09-22 10:56:53 +09:00 committed by Hermet Park
parent a85540397c
commit d601021b8f
9 changed files with 17 additions and 17 deletions

View file

@ -122,7 +122,7 @@ public:
uint32_t colorStops(const ColorStop** colorStops) const noexcept; uint32_t colorStops(const ColorStop** colorStops) const noexcept;
FillSpread spread() const noexcept; FillSpread spread() const noexcept;
std::unique_ptr<Fill> duplicate() const noexcept; Fill* duplicate() const noexcept;
_TVG_DECALRE_IDENTIFIER(); _TVG_DECALRE_IDENTIFIER();
_TVG_DECLARE_PRIVATE(Fill); _TVG_DECLARE_PRIVATE(Fill);

View file

@ -85,7 +85,7 @@ FillSpread Fill::spread() const noexcept
} }
unique_ptr<Fill> Fill::duplicate() const noexcept Fill* Fill::duplicate() const noexcept
{ {
return pImpl->duplicate(); return pImpl->duplicate();
} }

View file

@ -28,7 +28,7 @@ template<typename T>
struct DuplicateMethod struct DuplicateMethod
{ {
virtual ~DuplicateMethod(){} virtual ~DuplicateMethod(){}
virtual unique_ptr<T> duplicate() = 0; virtual T* duplicate() = 0;
}; };
template<class T> template<class T>
@ -39,7 +39,7 @@ struct FillDup : DuplicateMethod<Fill>
FillDup(T* _inst) : inst(_inst) {} FillDup(T* _inst) : inst(_inst) {}
~FillDup(){} ~FillDup(){}
unique_ptr<Fill> duplicate() override Fill* duplicate() override
{ {
return inst->duplicate(); return inst->duplicate();
} }
@ -63,7 +63,7 @@ struct Fill::Impl
this->dup = dup; this->dup = dup;
} }
unique_ptr<Fill> duplicate() Fill* duplicate()
{ {
auto ret = dup->duplicate(); auto ret = dup->duplicate();
if (!ret) return nullptr; if (!ret) return nullptr;

View file

@ -32,7 +32,7 @@ struct LinearGradient::Impl
float x2 = 0; float x2 = 0;
float y2 = 0; float y2 = 0;
unique_ptr<Fill> duplicate() Fill* duplicate()
{ {
auto ret = LinearGradient::gen(); auto ret = LinearGradient::gen();
if (!ret) return nullptr; if (!ret) return nullptr;
@ -42,7 +42,7 @@ struct LinearGradient::Impl
ret->pImpl->x2 = x2; ret->pImpl->x2 = x2;
ret->pImpl->y2 = y2; ret->pImpl->y2 = y2;
return ret; return ret.release();
} }
}; };

View file

@ -34,7 +34,7 @@ namespace tvg
virtual bool update(RenderMethod& renderer, const RenderTransform* transform, RenderUpdateFlag pFlag) = 0; virtual bool update(RenderMethod& renderer, const RenderTransform* transform, RenderUpdateFlag pFlag) = 0;
virtual bool render(RenderMethod& renderer) = 0; virtual bool render(RenderMethod& renderer) = 0;
virtual bool bounds(float* x, float* y, float* w, float* h) const = 0; virtual bool bounds(float* x, float* y, float* w, float* h) const = 0;
virtual unique_ptr<Paint> duplicate() = 0; virtual Paint* duplicate() = 0;
}; };
struct Paint::Impl struct Paint::Impl
@ -150,7 +150,7 @@ namespace tvg
Paint* duplicate() Paint* duplicate()
{ {
return smethod->duplicate().release(); return smethod->duplicate();
} }
}; };
@ -183,7 +183,7 @@ namespace tvg
return inst->render(renderer); return inst->render(renderer);
} }
unique_ptr<Paint> duplicate() override Paint* duplicate() override
{ {
return inst->duplicate(); return inst->duplicate();
} }

View file

@ -105,7 +105,7 @@ struct Picture::Impl
return Result::Success; return Result::Success;
} }
unique_ptr<Paint> duplicate() Paint* duplicate()
{ {
//TODO: //TODO:
return nullptr; return nullptr;

View file

@ -31,7 +31,7 @@ struct RadialGradient::Impl
float cy = 0; float cy = 0;
float radius = 0; float radius = 0;
unique_ptr<Fill> duplicate() Fill* duplicate()
{ {
auto ret = RadialGradient::gen(); auto ret = RadialGradient::gen();
if (!ret) return nullptr; if (!ret) return nullptr;
@ -40,7 +40,7 @@ struct RadialGradient::Impl
ret->pImpl->cy = cy; ret->pImpl->cy = cy;
ret->pImpl->radius = radius; ret->pImpl->radius = radius;
return ret; return ret.release();
} }
}; };

View file

@ -89,7 +89,7 @@ struct Scene::Impl
return true; return true;
} }
unique_ptr<Paint> duplicate() Paint* duplicate()
{ {
//TODO: //TODO:
return nullptr; return nullptr;

View file

@ -176,7 +176,7 @@ struct Shape::Impl
return true; return true;
} }
unique_ptr<Paint> duplicate() Paint* duplicate()
{ {
auto ret = Shape::gen(); auto ret = Shape::gen();
if (!ret) return nullptr; if (!ret) return nullptr;
@ -200,11 +200,11 @@ struct Shape::Impl
} }
if (fill) { if (fill) {
dup->fill = fill->duplicate().release(); dup->fill = fill->duplicate();
dup->flag |= RenderUpdateFlag::Gradient; dup->flag |= RenderUpdateFlag::Gradient;
} }
return ret; return ret.release();
} }
}; };