mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
common fill: added spread mode.
Change-Id: I95d47bc492d5a22326a745a591d243e56a26bae4
This commit is contained in:
parent
c36f23e80d
commit
f3afd2a636
3 changed files with 27 additions and 1 deletions
|
@ -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 StrokeCap { Square = 0, Round, Butt };
|
||||
enum class TVG_EXPORT StrokeJoin { Bevel = 0, Round, Miter };
|
||||
enum class TVG_EXPORT FillSpread { Pad = 0, Reflect, Repeat };
|
||||
|
||||
|
||||
struct Point
|
||||
|
@ -117,14 +118,17 @@ class TVG_EXPORT Fill
|
|||
public:
|
||||
struct ColorStop
|
||||
{
|
||||
float pos;
|
||||
float offset;
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
|
||||
virtual ~Fill();
|
||||
|
||||
Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
|
||||
Result spread(FillSpread s) noexcept;
|
||||
|
||||
uint32_t colorStops(const ColorStop** colorStops) const noexcept;
|
||||
FillSpread spread() const noexcept;
|
||||
|
||||
_TVG_DECALRE_IDENTIFIER();
|
||||
_TVG_DECLARE_PRIVATE(Fill);
|
||||
|
|
|
@ -82,6 +82,7 @@ bool SwRenderer::dispose(const Shape& shape, void *data)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void* SwRenderer::prepare(const Shape& sdata, void* data, const RenderTransform* transform, RenderUpdateFlag flags)
|
||||
{
|
||||
//prepare shape data
|
||||
|
|
|
@ -28,6 +28,7 @@ struct Fill::Impl
|
|||
{
|
||||
ColorStop* colorStops = nullptr;
|
||||
uint32_t cnt = 0;
|
||||
FillSpread spread;
|
||||
|
||||
~Impl()
|
||||
{
|
||||
|
@ -85,4 +86,24 @@ uint32_t Fill::colorStops(const ColorStop** colorStops) const noexcept
|
|||
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_ */
|
Loading…
Add table
Reference in a new issue