common fill: added spread mode.

Change-Id: I95d47bc492d5a22326a745a591d243e56a26bae4
This commit is contained in:
Hermet Park 2020-06-11 14:27:20 +09:00
parent c36f23e80d
commit f3afd2a636
3 changed files with 27 additions and 1 deletions

View file

@ -72,6 +72,7 @@ enum class TVG_EXPORT Result { Success = 0, InvalidArguments, InsufficientCondit
enum class TVG_EXPORT PathCommand { Close = 0, MoveTo, LineTo, CubicTo }; enum class TVG_EXPORT PathCommand { Close = 0, MoveTo, LineTo, CubicTo };
enum class TVG_EXPORT StrokeCap { Square = 0, Round, Butt }; enum class TVG_EXPORT StrokeCap { Square = 0, Round, Butt };
enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter }; enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
enum class TVG_EXPORT FillSpread { Pad = 0, Reflect, Repeat };
struct Point struct Point
@ -117,14 +118,17 @@ class TVG_EXPORT Fill
public: public:
struct ColorStop struct ColorStop
{ {
float pos; float offset;
uint8_t r, g, b, a; uint8_t r, g, b, a;
}; };
virtual ~Fill(); virtual ~Fill();
Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept; Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
Result spread(FillSpread s) noexcept;
uint32_t colorStops(const ColorStop** colorStops) const noexcept; uint32_t colorStops(const ColorStop** colorStops) const noexcept;
FillSpread spread() const noexcept;
_TVG_DECALRE_IDENTIFIER(); _TVG_DECALRE_IDENTIFIER();
_TVG_DECLARE_PRIVATE(Fill); _TVG_DECLARE_PRIVATE(Fill);

View file

@ -82,6 +82,7 @@ bool SwRenderer::dispose(const Shape& shape, void *data)
return true; return true;
} }
void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform* transform, RenderUpdateFlag flags) void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform* transform, RenderUpdateFlag flags)
{ {
//prepare shape data //prepare shape data

View file

@ -28,6 +28,7 @@ struct Fill::Impl
{ {
ColorStop* colorStops = nullptr; ColorStop* colorStops = nullptr;
uint32_t cnt = 0; uint32_t cnt = 0;
FillSpread spread;
~Impl() ~Impl()
{ {
@ -85,4 +86,24 @@ uint32_t Fill::colorStops(const ColorStop** colorStops) const noexcept
return impl->cnt; return impl->cnt;
} }
Result Fill::spread(FillSpread s) noexcept
{
auto impl = pImpl.get();
if (!impl) return Result::MemoryCorruption;
impl->spread = s;
return Result::Success;
}
FillSpread Fill::spread() const noexcept
{
auto impl = pImpl.get();
assert(impl);
return impl->spread;
}
#endif /* _TVG_FILL_CPP_ */ #endif /* _TVG_FILL_CPP_ */