mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-06 17:00:13 +00:00
Refactoring
This commit is contained in:
parent
1ee81d91d2
commit
6f63e9a624
@ -9,63 +9,6 @@
|
|||||||
|
|
||||||
namespace lottieRendering {
|
namespace lottieRendering {
|
||||||
|
|
||||||
struct Color {
|
|
||||||
double r;
|
|
||||||
double g;
|
|
||||||
double b;
|
|
||||||
double a;
|
|
||||||
|
|
||||||
Color(double r_, double g_, double b_, double a_) :
|
|
||||||
r(r_), g(g_), b(b_), a(a_) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(Color const &rhs) const {
|
|
||||||
if (r != rhs.r) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (g != rhs.g) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (b != rhs.b) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (a != rhs.a) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(Color const &rhs) const {
|
|
||||||
return !(*this == rhs);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class BlendMode {
|
|
||||||
Normal,
|
|
||||||
DestinationIn,
|
|
||||||
DestinationOut
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class FillRule: int {
|
|
||||||
None = 0,
|
|
||||||
NonZeroWinding = 1,
|
|
||||||
EvenOdd = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class LineCap: int {
|
|
||||||
None = 0,
|
|
||||||
Butt = 1,
|
|
||||||
Round = 2,
|
|
||||||
Square = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class LineJoin: int {
|
|
||||||
None = 0,
|
|
||||||
Miter = 1,
|
|
||||||
Round = 2,
|
|
||||||
Bevel = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
class Image {
|
class Image {
|
||||||
public:
|
public:
|
||||||
virtual ~Image() = default;
|
virtual ~Image() = default;
|
||||||
@ -73,23 +16,29 @@ public:
|
|||||||
|
|
||||||
class Gradient {
|
class Gradient {
|
||||||
public:
|
public:
|
||||||
Gradient(std::vector<Color> const &colors, std::vector<double> const &locations) :
|
Gradient(std::vector<lottie::Color> const &colors, std::vector<float> const &locations) :
|
||||||
_colors(colors),
|
_colors(colors),
|
||||||
_locations(locations) {
|
_locations(locations) {
|
||||||
assert(_colors.size() == _locations.size());
|
assert(_colors.size() == _locations.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Color> const &colors() const {
|
std::vector<lottie::Color> const &colors() const {
|
||||||
return _colors;
|
return _colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> const &locations() const {
|
std::vector<float> const &locations() const {
|
||||||
return _locations;
|
return _locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Color> _colors;
|
std::vector<lottie::Color> _colors;
|
||||||
std::vector<double> _locations;
|
std::vector<float> _locations;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BlendMode {
|
||||||
|
Normal,
|
||||||
|
DestinationIn,
|
||||||
|
DestinationOut
|
||||||
};
|
};
|
||||||
|
|
||||||
class Canvas {
|
class Canvas {
|
||||||
@ -104,18 +53,18 @@ public:
|
|||||||
virtual void saveState() = 0;
|
virtual void saveState() = 0;
|
||||||
virtual void restoreState() = 0;
|
virtual void restoreState() = 0;
|
||||||
|
|
||||||
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Color const &color) = 0;
|
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottie::Color const &color) = 0;
|
||||||
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0;
|
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0;
|
||||||
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) = 0;
|
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) = 0;
|
||||||
|
|
||||||
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Color const &color) = 0;
|
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, lottie::Color const &color) = 0;
|
||||||
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0;
|
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0;
|
||||||
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) = 0;
|
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) = 0;
|
||||||
|
|
||||||
virtual void fill(lottie::CGRect const &rect, Color const &fillColor) = 0;
|
virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) = 0;
|
||||||
virtual void setBlendMode(BlendMode blendMode) = 0;
|
virtual void setBlendMode(BlendMode blendMode) = 0;
|
||||||
|
|
||||||
virtual void setAlpha(double alpha) = 0;
|
virtual void setAlpha(float alpha) = 0;
|
||||||
|
|
||||||
virtual void concatenate(lottie::CATransform3D const &transform) = 0;
|
virtual void concatenate(lottie::CATransform3D const &transform) = 0;
|
||||||
|
|
||||||
|
|||||||
@ -29,17 +29,17 @@ public:
|
|||||||
virtual void saveState() override;
|
virtual void saveState() override;
|
||||||
virtual void restoreState() override;
|
virtual void restoreState() override;
|
||||||
|
|
||||||
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Color const &color) override;
|
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottie::Color const &color) override;
|
||||||
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
||||||
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override;
|
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override;
|
||||||
|
|
||||||
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Color const &color) override;
|
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, lottie::Color const &color) override;
|
||||||
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
||||||
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override;
|
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override;
|
||||||
|
|
||||||
virtual void fill(lottie::CGRect const &rect, Color const &fillColor) override;
|
virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) override;
|
||||||
virtual void setBlendMode(BlendMode blendMode) override;
|
virtual void setBlendMode(BlendMode blendMode) override;
|
||||||
virtual void setAlpha(double alpha) override;
|
virtual void setAlpha(float alpha) override;
|
||||||
virtual void concatenate(lottie::CATransform3D const &transform) override;
|
virtual void concatenate(lottie::CATransform3D const &transform) override;
|
||||||
|
|
||||||
virtual std::shared_ptr<Image> makeImage() const;
|
virtual std::shared_ptr<Image> makeImage() const;
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
#include "CoreGraphicsCanvasImpl.h"
|
#include "CoreGraphicsCanvasImpl.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace lottieRendering {
|
namespace lottieRendering {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -89,7 +87,7 @@ void CanvasImpl::restoreState() {
|
|||||||
CGContextRestoreGState(_context);
|
CGContextRestoreGState(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Color const &color) {
|
void CanvasImpl::fillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottie::Color const &color) {
|
||||||
CGContextBeginPath(_context);
|
CGContextBeginPath(_context);
|
||||||
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
||||||
CGContextAddPath(context, nativePath);
|
CGContextAddPath(context, nativePath);
|
||||||
@ -101,7 +99,7 @@ void CanvasImpl::fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule
|
|||||||
CFRelease(nativeColor);
|
CFRelease(nativeColor);
|
||||||
|
|
||||||
switch (fillRule) {
|
switch (fillRule) {
|
||||||
case FillRule::EvenOdd: {
|
case lottie::FillRule::EvenOdd: {
|
||||||
CGContextEOFillPath(_context);
|
CGContextEOFillPath(_context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -112,7 +110,7 @@ void CanvasImpl::fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
void CanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
||||||
CGContextSaveGState(_context);
|
CGContextSaveGState(_context);
|
||||||
CGContextBeginPath(_context);
|
CGContextBeginPath(_context);
|
||||||
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
||||||
@ -120,7 +118,7 @@ void CanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &p
|
|||||||
});
|
});
|
||||||
|
|
||||||
switch (fillRule) {
|
switch (fillRule) {
|
||||||
case FillRule::EvenOdd: {
|
case lottie::FillRule::EvenOdd: {
|
||||||
CGContextEOClip(_context);
|
CGContextEOClip(_context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -142,7 +140,12 @@ void CanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &p
|
|||||||
|
|
||||||
assert(gradient.colors().size() == gradient.locations().size());
|
assert(gradient.colors().size() == gradient.locations().size());
|
||||||
|
|
||||||
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size());
|
std::vector<double> locations;
|
||||||
|
for (const auto location : gradient.locations()) {
|
||||||
|
locations.push_back(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size());
|
||||||
if (nativeGradient) {
|
if (nativeGradient) {
|
||||||
CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
||||||
CFRelease(nativeGradient);
|
CFRelease(nativeGradient);
|
||||||
@ -152,7 +155,7 @@ void CanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &p
|
|||||||
CGContextRestoreGState(_context);
|
CGContextRestoreGState(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) {
|
void CanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) {
|
||||||
CGContextSaveGState(_context);
|
CGContextSaveGState(_context);
|
||||||
CGContextBeginPath(_context);
|
CGContextBeginPath(_context);
|
||||||
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
||||||
@ -160,7 +163,7 @@ void CanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &p
|
|||||||
});
|
});
|
||||||
|
|
||||||
switch (fillRule) {
|
switch (fillRule) {
|
||||||
case FillRule::EvenOdd: {
|
case lottie::FillRule::EvenOdd: {
|
||||||
CGContextEOClip(_context);
|
CGContextEOClip(_context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -182,7 +185,12 @@ void CanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &p
|
|||||||
|
|
||||||
assert(gradient.colors().size() == gradient.locations().size());
|
assert(gradient.colors().size() == gradient.locations().size());
|
||||||
|
|
||||||
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size());
|
std::vector<double> locations;
|
||||||
|
for (const auto location : gradient.locations()) {
|
||||||
|
locations.push_back(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size());
|
||||||
if (nativeGradient) {
|
if (nativeGradient) {
|
||||||
CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
||||||
CFRelease(nativeGradient);
|
CFRelease(nativeGradient);
|
||||||
@ -192,7 +200,7 @@ void CanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &p
|
|||||||
CGContextRestoreGState(_context);
|
CGContextRestoreGState(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Color const &color) {
|
void CanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, lottie::Color const &color) {
|
||||||
CGContextBeginPath(_context);
|
CGContextBeginPath(_context);
|
||||||
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
||||||
CGContextAddPath(context, nativePath);
|
CGContextAddPath(context, nativePath);
|
||||||
@ -206,15 +214,15 @@ void CanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, double
|
|||||||
CGContextSetLineWidth(_context, lineWidth);
|
CGContextSetLineWidth(_context, lineWidth);
|
||||||
|
|
||||||
switch (lineJoin) {
|
switch (lineJoin) {
|
||||||
case LineJoin::Miter: {
|
case lottie::LineJoin::Miter: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinMiter);
|
CGContextSetLineJoin(_context, kCGLineJoinMiter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Round: {
|
case lottie::LineJoin::Round: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinRound);
|
CGContextSetLineJoin(_context, kCGLineJoinRound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Bevel: {
|
case lottie::LineJoin::Bevel: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinBevel);
|
CGContextSetLineJoin(_context, kCGLineJoinBevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -225,15 +233,15 @@ void CanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, double
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (lineCap) {
|
switch (lineCap) {
|
||||||
case LineCap::Butt: {
|
case lottie::LineCap::Butt: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapButt);
|
CGContextSetLineCap(_context, kCGLineCapButt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Round: {
|
case lottie::LineCap::Round: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapRound);
|
CGContextSetLineCap(_context, kCGLineCapRound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Square: {
|
case lottie::LineCap::Square: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapSquare);
|
CGContextSetLineCap(_context, kCGLineCapSquare);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -244,12 +252,16 @@ void CanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, double
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dashPattern.empty()) {
|
if (!dashPattern.empty()) {
|
||||||
CGContextSetLineDash(_context, dashPhase, dashPattern.data(), dashPattern.size());
|
std::vector<double> mappedDashPattern;
|
||||||
|
for (const auto value : dashPattern) {
|
||||||
|
mappedDashPattern.push_back(value);
|
||||||
|
}
|
||||||
|
CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size());
|
||||||
}
|
}
|
||||||
CGContextStrokePath(_context);
|
CGContextStrokePath(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
||||||
CGContextSaveGState(_context);
|
CGContextSaveGState(_context);
|
||||||
CGContextBeginPath(_context);
|
CGContextBeginPath(_context);
|
||||||
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
||||||
@ -259,15 +271,15 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
CGContextSetLineWidth(_context, lineWidth);
|
CGContextSetLineWidth(_context, lineWidth);
|
||||||
|
|
||||||
switch (lineJoin) {
|
switch (lineJoin) {
|
||||||
case LineJoin::Miter: {
|
case lottie::LineJoin::Miter: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinMiter);
|
CGContextSetLineJoin(_context, kCGLineJoinMiter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Round: {
|
case lottie::LineJoin::Round: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinRound);
|
CGContextSetLineJoin(_context, kCGLineJoinRound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Bevel: {
|
case lottie::LineJoin::Bevel: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinBevel);
|
CGContextSetLineJoin(_context, kCGLineJoinBevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -278,15 +290,15 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (lineCap) {
|
switch (lineCap) {
|
||||||
case LineCap::Butt: {
|
case lottie::LineCap::Butt: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapButt);
|
CGContextSetLineCap(_context, kCGLineCapButt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Round: {
|
case lottie::LineCap::Round: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapRound);
|
CGContextSetLineCap(_context, kCGLineCapRound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Square: {
|
case lottie::LineCap::Square: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapSquare);
|
CGContextSetLineCap(_context, kCGLineCapSquare);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -297,7 +309,11 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dashPattern.empty()) {
|
if (!dashPattern.empty()) {
|
||||||
CGContextSetLineDash(_context, dashPhase, dashPattern.data(), dashPattern.size());
|
std::vector<double> mappedDashPattern;
|
||||||
|
for (const auto value : dashPattern) {
|
||||||
|
mappedDashPattern.push_back(value);
|
||||||
|
}
|
||||||
|
CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
CGContextReplacePathWithStrokedPath(_context);
|
CGContextReplacePathWithStrokedPath(_context);
|
||||||
@ -315,7 +331,12 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
|
|
||||||
assert(gradient.colors().size() == gradient.locations().size());
|
assert(gradient.colors().size() == gradient.locations().size());
|
||||||
|
|
||||||
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size());
|
std::vector<double> locations;
|
||||||
|
for (const auto location : gradient.locations()) {
|
||||||
|
locations.push_back(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size());
|
||||||
if (nativeGradient) {
|
if (nativeGradient) {
|
||||||
CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
||||||
CFRelease(nativeGradient);
|
CFRelease(nativeGradient);
|
||||||
@ -325,7 +346,7 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
CGContextRestoreGState(_context);
|
CGContextRestoreGState(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) {
|
void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) {
|
||||||
CGContextSaveGState(_context);
|
CGContextSaveGState(_context);
|
||||||
CGContextBeginPath(_context);
|
CGContextBeginPath(_context);
|
||||||
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) {
|
||||||
@ -335,15 +356,15 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
CGContextSetLineWidth(_context, lineWidth);
|
CGContextSetLineWidth(_context, lineWidth);
|
||||||
|
|
||||||
switch (lineJoin) {
|
switch (lineJoin) {
|
||||||
case LineJoin::Miter: {
|
case lottie::LineJoin::Miter: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinMiter);
|
CGContextSetLineJoin(_context, kCGLineJoinMiter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Round: {
|
case lottie::LineJoin::Round: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinRound);
|
CGContextSetLineJoin(_context, kCGLineJoinRound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Bevel: {
|
case lottie::LineJoin::Bevel: {
|
||||||
CGContextSetLineJoin(_context, kCGLineJoinBevel);
|
CGContextSetLineJoin(_context, kCGLineJoinBevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -354,15 +375,15 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (lineCap) {
|
switch (lineCap) {
|
||||||
case LineCap::Butt: {
|
case lottie::LineCap::Butt: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapButt);
|
CGContextSetLineCap(_context, kCGLineCapButt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Round: {
|
case lottie::LineCap::Round: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapRound);
|
CGContextSetLineCap(_context, kCGLineCapRound);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Square: {
|
case lottie::LineCap::Square: {
|
||||||
CGContextSetLineCap(_context, kCGLineCapSquare);
|
CGContextSetLineCap(_context, kCGLineCapSquare);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -373,7 +394,11 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dashPattern.empty()) {
|
if (!dashPattern.empty()) {
|
||||||
CGContextSetLineDash(_context, dashPhase, dashPattern.data(), dashPattern.size());
|
std::vector<double> mappedDashPattern;
|
||||||
|
for (const auto value : dashPattern) {
|
||||||
|
mappedDashPattern.push_back(value);
|
||||||
|
}
|
||||||
|
CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
CGContextReplacePathWithStrokedPath(_context);
|
CGContextReplacePathWithStrokedPath(_context);
|
||||||
@ -391,7 +416,12 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
|
|
||||||
assert(gradient.colors().size() == gradient.locations().size());
|
assert(gradient.colors().size() == gradient.locations().size());
|
||||||
|
|
||||||
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size());
|
std::vector<double> locations;
|
||||||
|
for (const auto location : gradient.locations()) {
|
||||||
|
locations.push_back(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size());
|
||||||
if (nativeGradient) {
|
if (nativeGradient) {
|
||||||
CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
|
||||||
CFRelease(nativeGradient);
|
CFRelease(nativeGradient);
|
||||||
@ -401,7 +431,7 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const
|
|||||||
CGContextRestoreGState(_context);
|
CGContextRestoreGState(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::fill(lottie::CGRect const &rect, Color const &fillColor) {
|
void CanvasImpl::fill(lottie::CGRect const &rect, lottie::Color const &fillColor) {
|
||||||
CGFloat components[4] = { fillColor.r, fillColor.g, fillColor.b, fillColor.a };
|
CGFloat components[4] = { fillColor.r, fillColor.g, fillColor.b, fillColor.a };
|
||||||
CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(_topContext), components);
|
CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(_topContext), components);
|
||||||
CGContextSetFillColorWithColor(_context, nativeColor);
|
CGContextSetFillColorWithColor(_context, nativeColor);
|
||||||
@ -429,7 +459,7 @@ void CanvasImpl::setBlendMode(BlendMode blendMode) {
|
|||||||
CGContextSetBlendMode(_context, nativeMode);
|
CGContextSetBlendMode(_context, nativeMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CanvasImpl::setAlpha(double alpha) {
|
void CanvasImpl::setAlpha(float alpha) {
|
||||||
CGContextSetAlpha(_context, alpha);
|
CGContextSetAlpha(_context, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -411,18 +411,18 @@ static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> paren
|
|||||||
lottie::RenderTreeNodeContentItem::SolidShading *solidShading = (lottie::RenderTreeNodeContentItem::SolidShading *)shading->stroke->shading.get();
|
lottie::RenderTreeNodeContentItem::SolidShading *solidShading = (lottie::RenderTreeNodeContentItem::SolidShading *)shading->stroke->shading.get();
|
||||||
|
|
||||||
if (solidShading->opacity != 0.0) {
|
if (solidShading->opacity != 0.0) {
|
||||||
lottieRendering::LineJoin lineJoin = lottieRendering::LineJoin::Bevel;
|
lottie::LineJoin lineJoin = lottie::LineJoin::Bevel;
|
||||||
switch (shading->stroke->lineJoin) {
|
switch (shading->stroke->lineJoin) {
|
||||||
case lottie::LineJoin::Bevel: {
|
case lottie::LineJoin::Bevel: {
|
||||||
lineJoin = lottieRendering::LineJoin::Bevel;
|
lineJoin = lottie::LineJoin::Bevel;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case lottie::LineJoin::Round: {
|
case lottie::LineJoin::Round: {
|
||||||
lineJoin = lottieRendering::LineJoin::Round;
|
lineJoin = lottie::LineJoin::Round;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case lottie::LineJoin::Miter: {
|
case lottie::LineJoin::Miter: {
|
||||||
lineJoin = lottieRendering::LineJoin::Miter;
|
lineJoin = lottie::LineJoin::Miter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -430,18 +430,18 @@ static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> paren
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lottieRendering::LineCap lineCap = lottieRendering::LineCap::Square;
|
lottie::LineCap lineCap = lottie::LineCap::Square;
|
||||||
switch (shading->stroke->lineCap) {
|
switch (shading->stroke->lineCap) {
|
||||||
case lottie::LineCap::Butt: {
|
case lottie::LineCap::Butt: {
|
||||||
lineCap = lottieRendering::LineCap::Butt;
|
lineCap = lottie::LineCap::Butt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case lottie::LineCap::Round: {
|
case lottie::LineCap::Round: {
|
||||||
lineCap = lottieRendering::LineCap::Round;
|
lineCap = lottie::LineCap::Round;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case lottie::LineCap::Square: {
|
case lottie::LineCap::Square: {
|
||||||
lineCap = lottieRendering::LineCap::Square;
|
lineCap = lottie::LineCap::Square;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -449,25 +449,25 @@ static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> paren
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> dashPattern;
|
std::vector<float> dashPattern;
|
||||||
if (!shading->stroke->dashPattern.empty()) {
|
if (!shading->stroke->dashPattern.empty()) {
|
||||||
dashPattern = shading->stroke->dashPattern;
|
dashPattern = shading->stroke->dashPattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentContext->strokePath(path, shading->stroke->lineWidth, lineJoin, lineCap, shading->stroke->dashPhase, dashPattern, lottieRendering::Color(solidShading->color.r, solidShading->color.g, solidShading->color.b, solidShading->color.a * solidShading->opacity * renderAlpha));
|
currentContext->strokePath(path, shading->stroke->lineWidth, lineJoin, lineCap, shading->stroke->dashPhase, dashPattern, lottie::Color(solidShading->color.r, solidShading->color.g, solidShading->color.b, solidShading->color.a * solidShading->opacity * renderAlpha));
|
||||||
} else if (shading->stroke->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Gradient) {
|
} else if (shading->stroke->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Gradient) {
|
||||||
//TODO:gradient stroke
|
//TODO:gradient stroke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (shading->fill) {
|
} else if (shading->fill) {
|
||||||
lottieRendering::FillRule rule = lottieRendering::FillRule::NonZeroWinding;
|
lottie::FillRule rule = lottie::FillRule::NonZeroWinding;
|
||||||
switch (shading->fill->rule) {
|
switch (shading->fill->rule) {
|
||||||
case lottie::FillRule::EvenOdd: {
|
case lottie::FillRule::EvenOdd: {
|
||||||
rule = lottieRendering::FillRule::EvenOdd;
|
rule = lottie::FillRule::EvenOdd;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case lottie::FillRule::NonZeroWinding: {
|
case lottie::FillRule::NonZeroWinding: {
|
||||||
rule = lottieRendering::FillRule::NonZeroWinding;
|
rule = lottie::FillRule::NonZeroWinding;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@ -478,16 +478,16 @@ static void drawLottieContentItem(std::shared_ptr<lottieRendering::Canvas> paren
|
|||||||
if (shading->fill->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Solid) {
|
if (shading->fill->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Solid) {
|
||||||
lottie::RenderTreeNodeContentItem::SolidShading *solidShading = (lottie::RenderTreeNodeContentItem::SolidShading *)shading->fill->shading.get();
|
lottie::RenderTreeNodeContentItem::SolidShading *solidShading = (lottie::RenderTreeNodeContentItem::SolidShading *)shading->fill->shading.get();
|
||||||
if (solidShading->opacity != 0.0) {
|
if (solidShading->opacity != 0.0) {
|
||||||
currentContext->fillPath(path, rule, lottieRendering::Color(solidShading->color.r, solidShading->color.g, solidShading->color.b, solidShading->color.a * solidShading->opacity * renderAlpha));
|
currentContext->fillPath(path, rule, lottie::Color(solidShading->color.r, solidShading->color.g, solidShading->color.b, solidShading->color.a * solidShading->opacity * renderAlpha));
|
||||||
}
|
}
|
||||||
} else if (shading->fill->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Gradient) {
|
} else if (shading->fill->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Gradient) {
|
||||||
lottie::RenderTreeNodeContentItem::GradientShading *gradientShading = (lottie::RenderTreeNodeContentItem::GradientShading *)shading->fill->shading.get();
|
lottie::RenderTreeNodeContentItem::GradientShading *gradientShading = (lottie::RenderTreeNodeContentItem::GradientShading *)shading->fill->shading.get();
|
||||||
|
|
||||||
if (gradientShading->opacity != 0.0) {
|
if (gradientShading->opacity != 0.0) {
|
||||||
std::vector<lottieRendering::Color> colors;
|
std::vector<lottie::Color> colors;
|
||||||
std::vector<double> locations;
|
std::vector<float> locations;
|
||||||
for (const auto &color : gradientShading->colors) {
|
for (const auto &color : gradientShading->colors) {
|
||||||
colors.push_back(lottieRendering::Color(color.r, color.g, color.b, color.a * gradientShading->opacity * renderAlpha));
|
colors.push_back(lottie::Color(color.r, color.g, color.b, color.a * gradientShading->opacity * renderAlpha));
|
||||||
}
|
}
|
||||||
locations = gradientShading->locations;
|
locations = gradientShading->locations;
|
||||||
|
|
||||||
@ -562,7 +562,7 @@ static void renderLottieRenderNode(std::shared_ptr<lottie::RenderTreeNode> node,
|
|||||||
maskBackingStorage->concatenate(node->renderData.globalTransform);
|
maskBackingStorage->concatenate(node->renderData.globalTransform);
|
||||||
|
|
||||||
if (node->renderData.layer.masksToBounds()) {
|
if (node->renderData.layer.masksToBounds()) {
|
||||||
maskBackingStorage->fill(lottie::CGRect(node->renderData.layer.bounds().x, node->renderData.layer.bounds().y, node->renderData.layer.bounds().width, node->renderData.layer.bounds().height), lottieRendering::Color(1.0, 1.0, 1.0, 1.0));
|
maskBackingStorage->fill(lottie::CGRect(node->renderData.layer.bounds().x, node->renderData.layer.bounds().y, node->renderData.layer.bounds().width, node->renderData.layer.bounds().height), lottie::Color(1.0, 1.0, 1.0, 1.0));
|
||||||
}
|
}
|
||||||
if (node->mask() && node->mask()->renderData.isValid) {
|
if (node->mask() && node->mask()->renderData.isValid) {
|
||||||
renderLottieRenderNode(node->mask(), maskBackingStorage, globalSize, 1.0);
|
renderLottieRenderNode(node->mask(), maskBackingStorage, globalSize, 1.0);
|
||||||
@ -599,7 +599,7 @@ static void renderLottieRenderNode(std::shared_ptr<lottie::RenderTreeNode> node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (node->renderData.isInvertedMatte) {
|
if (node->renderData.isInvertedMatte) {
|
||||||
currentContext->fill(lottie::CGRect(node->renderData.layer.bounds().x, node->renderData.layer.bounds().y, node->renderData.layer.bounds().width, node->renderData.layer.bounds().height), lottieRendering::Color(0.0, 0.0, 0.0, 1.0));
|
currentContext->fill(lottie::CGRect(node->renderData.layer.bounds().x, node->renderData.layer.bounds().y, node->renderData.layer.bounds().width, node->renderData.layer.bounds().height), lottie::Color(0.0, 0.0, 0.0, 1.0));
|
||||||
currentContext->setBlendMode(lottieRendering::BlendMode::DestinationOut);
|
currentContext->setBlendMode(lottieRendering::BlendMode::DestinationOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,17 +20,17 @@ public:
|
|||||||
virtual void saveState() override;
|
virtual void saveState() override;
|
||||||
virtual void restoreState() override;
|
virtual void restoreState() override;
|
||||||
|
|
||||||
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Color const &color) override;
|
virtual void fillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottie::Color const &color) override;
|
||||||
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
virtual void linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
||||||
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override;
|
virtual void radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override;
|
||||||
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Color const &color) override;
|
virtual void strokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, lottie::Color const &color) override;
|
||||||
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
virtual void linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override;
|
||||||
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override;
|
virtual void radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) override;
|
||||||
virtual void fill(lottie::CGRect const &rect, Color const &fillColor) override;
|
virtual void fill(lottie::CGRect const &rect, lottie::Color const &fillColor) override;
|
||||||
|
|
||||||
virtual void setBlendMode(BlendMode blendMode) override;
|
virtual void setBlendMode(BlendMode blendMode) override;
|
||||||
|
|
||||||
virtual void setAlpha(double alpha) override;
|
virtual void setAlpha(float alpha) override;
|
||||||
|
|
||||||
virtual void concatenate(lottie::CATransform3D const &transform) override;
|
virtual void concatenate(lottie::CATransform3D const &transform) override;
|
||||||
|
|
||||||
@ -51,8 +51,7 @@ private:
|
|||||||
int _height = 0;
|
int _height = 0;
|
||||||
std::unique_ptr<tvg::SwCanvas> _canvas;
|
std::unique_ptr<tvg::SwCanvas> _canvas;
|
||||||
|
|
||||||
//SkBlendMode _blendMode = SkBlendMode::kSrcOver;
|
float _alpha = 1.0;
|
||||||
double _alpha = 1.0;
|
|
||||||
lottie::CATransform3D _transform;
|
lottie::CATransform3D _transform;
|
||||||
std::vector<lottie::CATransform3D> _stateStack;
|
std::vector<lottie::CATransform3D> _stateStack;
|
||||||
int _bytesPerRow = 0;
|
int _bytesPerRow = 0;
|
||||||
|
|||||||
@ -89,19 +89,19 @@ void ThorVGCanvasImpl::restoreState() {
|
|||||||
_stateStack.pop_back();
|
_stateStack.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::fillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Color const &color) {
|
void ThorVGCanvasImpl::fillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, lottie::Color const &color) {
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
tvgPath(path, shape.get());
|
tvgPath(path, shape.get());
|
||||||
|
|
||||||
shape->transform(tvgTransform(_transform));
|
shape->transform(tvgTransform(_transform));
|
||||||
|
|
||||||
shape->fill((int)(color.r * 255.0), (int)(color.g * 255.0), (int)(color.b * 255.0), (int)(color.a * _alpha * 255.0));
|
shape->fill((int)(color.r * 255.0), (int)(color.g * 255.0), (int)(color.b * 255.0), (int)(color.a * _alpha * 255.0));
|
||||||
shape->fill(fillRule == FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding);
|
shape->fill(fillRule == lottie::FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding);
|
||||||
|
|
||||||
_canvas->push(std::move(shape));
|
_canvas->push(std::move(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
void ThorVGCanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
tvgPath(path, shape.get());
|
tvgPath(path, shape.get());
|
||||||
|
|
||||||
@ -124,12 +124,12 @@ void ThorVGCanvasImpl::linearGradientFillPath(std::shared_ptr<lottie::CGPath> co
|
|||||||
fill->colorStops(colors.data(), (uint32_t)colors.size());
|
fill->colorStops(colors.data(), (uint32_t)colors.size());
|
||||||
shape->fill(std::move(fill));
|
shape->fill(std::move(fill));
|
||||||
|
|
||||||
shape->fill(fillRule == FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding);
|
shape->fill(fillRule == lottie::FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding);
|
||||||
|
|
||||||
_canvas->push(std::move(shape));
|
_canvas->push(std::move(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) {
|
void ThorVGCanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) {
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
tvgPath(path, shape.get());
|
tvgPath(path, shape.get());
|
||||||
|
|
||||||
@ -152,12 +152,12 @@ void ThorVGCanvasImpl::radialGradientFillPath(std::shared_ptr<lottie::CGPath> co
|
|||||||
fill->colorStops(colors.data(), (uint32_t)colors.size());
|
fill->colorStops(colors.data(), (uint32_t)colors.size());
|
||||||
shape->fill(std::move(fill));
|
shape->fill(std::move(fill));
|
||||||
|
|
||||||
shape->fill(fillRule == FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding);
|
shape->fill(fillRule == lottie::FillRule::EvenOdd ? tvg::FillRule::EvenOdd : tvg::FillRule::Winding);
|
||||||
|
|
||||||
_canvas->push(std::move(shape));
|
_canvas->push(std::move(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Color const &color) {
|
void ThorVGCanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, lottie::Color const &color) {
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
tvgPath(path, shape.get());
|
tvgPath(path, shape.get());
|
||||||
|
|
||||||
@ -167,15 +167,15 @@ void ThorVGCanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, d
|
|||||||
shape->strokeWidth(lineWidth);
|
shape->strokeWidth(lineWidth);
|
||||||
|
|
||||||
switch (lineJoin) {
|
switch (lineJoin) {
|
||||||
case LineJoin::Miter: {
|
case lottie::LineJoin::Miter: {
|
||||||
shape->strokeJoin(tvg::StrokeJoin::Miter);
|
shape->strokeJoin(tvg::StrokeJoin::Miter);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Round: {
|
case lottie::LineJoin::Round: {
|
||||||
shape->strokeJoin(tvg::StrokeJoin::Round);
|
shape->strokeJoin(tvg::StrokeJoin::Round);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineJoin::Bevel: {
|
case lottie::LineJoin::Bevel: {
|
||||||
shape->strokeJoin(tvg::StrokeJoin::Bevel);
|
shape->strokeJoin(tvg::StrokeJoin::Bevel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -186,15 +186,15 @@ void ThorVGCanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (lineCap) {
|
switch (lineCap) {
|
||||||
case LineCap::Butt: {
|
case lottie::LineCap::Butt: {
|
||||||
shape->strokeCap(tvg::StrokeCap::Butt);
|
shape->strokeCap(tvg::StrokeCap::Butt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Round: {
|
case lottie::LineCap::Round: {
|
||||||
shape->strokeCap(tvg::StrokeCap::Round);
|
shape->strokeCap(tvg::StrokeCap::Round);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LineCap::Square: {
|
case lottie::LineCap::Square: {
|
||||||
shape->strokeCap(tvg::StrokeCap::Square);
|
shape->strokeCap(tvg::StrokeCap::Square);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -217,15 +217,15 @@ void ThorVGCanvasImpl::strokePath(std::shared_ptr<lottie::CGPath> const &path, d
|
|||||||
_canvas->push(std::move(shape));
|
_canvas->push(std::move(shape));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
void ThorVGCanvasImpl::linearGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector<double> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) {
|
void ThorVGCanvasImpl::radialGradientStrokePath(std::shared_ptr<lottie::CGPath> const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector<float> const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::fill(lottie::CGRect const &rect, Color const &fillColor) {
|
void ThorVGCanvasImpl::fill(lottie::CGRect const &rect, lottie::Color const &fillColor) {
|
||||||
auto shape = tvg::Shape::gen();
|
auto shape = tvg::Shape::gen();
|
||||||
shape->appendRect(rect.x, rect.y, rect.width, rect.height, 0.0f, 0.0f);
|
shape->appendRect(rect.x, rect.y, rect.width, rect.height, 0.0f, 0.0f);
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ void ThorVGCanvasImpl::setBlendMode(BlendMode blendMode) {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThorVGCanvasImpl::setAlpha(double alpha) {
|
void ThorVGCanvasImpl::setAlpha(float alpha) {
|
||||||
_alpha = alpha;
|
_alpha = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,7 @@ public:
|
|||||||
/// TI and TO are the new tangents for the trimPoint
|
/// TI and TO are the new tangents for the trimPoint
|
||||||
/// NO and NI are the new tangents for the startPoint and endPoints
|
/// NO and NI are the new tangents for the startPoint and endPoints
|
||||||
/// S==NO=========TI==T==TO=======NI==E
|
/// S==NO=========TI==T==TO=======NI==E
|
||||||
CurveVertexSplitResult<CurveVertex> splitCurve(CurveVertex const &toVertex, double position) const {
|
CurveVertexSplitResult<CurveVertex> splitCurve(CurveVertex const &toVertex, float position) const {
|
||||||
/// If position is less than or equal to 0, trim at start.
|
/// If position is less than or equal to 0, trim at start.
|
||||||
if (position <= 0.0) {
|
if (position <= 0.0) {
|
||||||
return CurveVertexSplitResult<CurveVertex>(
|
return CurveVertexSplitResult<CurveVertex>(
|
||||||
@ -147,8 +147,8 @@ public:
|
|||||||
///
|
///
|
||||||
/// This function should probably live in PathElement, since it deals with curve
|
/// This function should probably live in PathElement, since it deals with curve
|
||||||
/// lengths.
|
/// lengths.
|
||||||
CurveVertexSplitResult<CurveVertex> trimCurve(CurveVertex const &toVertex, double atLength, double curveLength, int maxSamples, double accuracy = 1.0) const {
|
CurveVertexSplitResult<CurveVertex> trimCurve(CurveVertex const &toVertex, float atLength, float curveLength, int maxSamples, float accuracy = 1.0f) const {
|
||||||
double currentPosition = atLength / curveLength;
|
float currentPosition = atLength / curveLength;
|
||||||
auto results = splitCurve(toVertex, currentPosition);
|
auto results = splitCurve(toVertex, currentPosition);
|
||||||
|
|
||||||
if (maxSamples == 0) {
|
if (maxSamples == 0) {
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
if (lengthDiff < accuracy) {
|
if (lengthDiff < accuracy) {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
auto diffPosition = std::max(std::min((currentPosition / length) * lengthDiff, currentPosition * 0.5), currentPosition * (-0.5));
|
auto diffPosition = std::max(std::min((currentPosition / length) * lengthDiff, currentPosition * 0.5f), currentPosition * (-0.5f));
|
||||||
currentPosition = diffPosition + currentPosition;
|
currentPosition = diffPosition + currentPosition;
|
||||||
results = splitCurve(toVertex, currentPosition);
|
results = splitCurve(toVertex, currentPosition);
|
||||||
}
|
}
|
||||||
@ -174,17 +174,17 @@ public:
|
|||||||
/// For lines (zeroed tangents) the distance between the two points is measured.
|
/// For lines (zeroed tangents) the distance between the two points is measured.
|
||||||
/// For curves the curve is iterated over by sample count and the points are measured.
|
/// For curves the curve is iterated over by sample count and the points are measured.
|
||||||
/// This is ~99% accurate at a sample count of 30
|
/// This is ~99% accurate at a sample count of 30
|
||||||
double distanceTo(CurveVertex const &toVertex, int sampleCount = 25) const {
|
float distanceTo(CurveVertex const &toVertex, int sampleCount = 25) const {
|
||||||
if (outTangentRelative().isZero() && toVertex.inTangentRelative().isZero()) {
|
if (outTangentRelative().isZero() && toVertex.inTangentRelative().isZero()) {
|
||||||
/// Return a linear distance.
|
/// Return a linear distance.
|
||||||
return point.distanceTo(toVertex.point);
|
return point.distanceTo(toVertex.point);
|
||||||
}
|
}
|
||||||
|
|
||||||
double distance = 0.0;
|
float distance = 0.0;
|
||||||
|
|
||||||
auto previousPoint = point;
|
auto previousPoint = point;
|
||||||
for (int i = 0; i < sampleCount; i++) {
|
for (int i = 0; i < sampleCount; i++) {
|
||||||
auto pointOnCurve = splitCurve(toVertex, ((double)(i)) / ((double)(sampleCount))).trimPoint;
|
auto pointOnCurve = splitCurve(toVertex, ((float)(i)) / ((float)(sampleCount))).trimPoint;
|
||||||
distance = distance + previousPoint.distanceTo(pointOnCurve.point);
|
distance = distance + previousPoint.distanceTo(pointOnCurve.point);
|
||||||
previousPoint = pointOnCurve.point;
|
previousPoint = pointOnCurve.point;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ typedef struct {
|
|||||||
CGRect bounds;
|
CGRect bounds;
|
||||||
CGPoint position;
|
CGPoint position;
|
||||||
CATransform3D transform;
|
CATransform3D transform;
|
||||||
double opacity;
|
float opacity;
|
||||||
bool masksToBounds;
|
bool masksToBounds;
|
||||||
bool isHidden;
|
bool isHidden;
|
||||||
} LottieRenderNodeLayerData;
|
} LottieRenderNodeLayerData;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ struct __attribute__((packed)) PathElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes a new path with length
|
/// Initializes a new path with length
|
||||||
explicit PathElement(std::optional<double> length_, CurveVertex const &vertex_) :
|
explicit PathElement(std::optional<float> length_, CurveVertex const &vertex_) :
|
||||||
vertex(vertex_) {
|
vertex(vertex_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ struct __attribute__((packed)) PathElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Splits an element span defined by the receiver and fromElement to a position 0-1
|
/// Splits an element span defined by the receiver and fromElement to a position 0-1
|
||||||
PathSplitResult<PathElement> splitElementAtPosition(PathElement const &fromElement, double atLength) {
|
PathSplitResult<PathElement> splitElementAtPosition(PathElement const &fromElement, float atLength) {
|
||||||
/// Trim the span. Start and trim go into the first, trim and end go into second.
|
/// Trim the span. Start and trim go into the first, trim and end go into second.
|
||||||
auto trimResults = fromElement.vertex.trimCurve(vertex, atLength, length(fromElement), 3);
|
auto trimResults = fromElement.vertex.trimCurve(vertex, atLength, length(fromElement), 3);
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ struct __attribute__((packed)) PathElement {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
double length(PathElement const &previous) {
|
float length(PathElement const &previous) {
|
||||||
double result = previous.vertex.distanceTo(vertex);
|
float result = previous.vertex.distanceTo(vertex);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public:
|
|||||||
CGRect _bounds;
|
CGRect _bounds;
|
||||||
Vector2D _position;
|
Vector2D _position;
|
||||||
CATransform3D _transform;
|
CATransform3D _transform;
|
||||||
double _opacity;
|
float _opacity;
|
||||||
bool _masksToBounds;
|
bool _masksToBounds;
|
||||||
bool _isHidden;
|
bool _isHidden;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ public:
|
|||||||
CGRect bounds_,
|
CGRect bounds_,
|
||||||
Vector2D position_,
|
Vector2D position_,
|
||||||
CATransform3D transform_,
|
CATransform3D transform_,
|
||||||
double opacity_,
|
float opacity_,
|
||||||
bool masksToBounds_,
|
bool masksToBounds_,
|
||||||
bool isHidden_
|
bool isHidden_
|
||||||
) :
|
) :
|
||||||
@ -51,7 +51,7 @@ public:
|
|||||||
return _transform;
|
return _transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
double opacity() const {
|
float opacity() const {
|
||||||
return _opacity;
|
return _opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,19 +135,19 @@ public:
|
|||||||
|
|
||||||
struct Stroke {
|
struct Stroke {
|
||||||
Color color;
|
Color color;
|
||||||
double lineWidth = 0.0;
|
float lineWidth = 0.0;
|
||||||
LineJoin lineJoin = LineJoin::Round;
|
LineJoin lineJoin = LineJoin::Round;
|
||||||
LineCap lineCap = LineCap::Square;
|
LineCap lineCap = LineCap::Square;
|
||||||
double dashPhase = 0.0;
|
float dashPhase = 0.0;
|
||||||
std::vector<double> dashPattern;
|
std::vector<float> dashPattern;
|
||||||
|
|
||||||
Stroke(
|
Stroke(
|
||||||
Color color_,
|
Color color_,
|
||||||
double lineWidth_,
|
float lineWidth_,
|
||||||
LineJoin lineJoin_,
|
LineJoin lineJoin_,
|
||||||
LineCap lineCap_,
|
LineCap lineCap_,
|
||||||
double dashPhase_,
|
float dashPhase_,
|
||||||
std::vector<double> dashPattern_
|
std::vector<float> dashPattern_
|
||||||
) :
|
) :
|
||||||
color(color_),
|
color(color_),
|
||||||
lineWidth(lineWidth_),
|
lineWidth(lineWidth_),
|
||||||
@ -245,7 +245,7 @@ public:
|
|||||||
FillRule pathFillRule_,
|
FillRule pathFillRule_,
|
||||||
GradientType gradientType_,
|
GradientType gradientType_,
|
||||||
std::vector<Color> const &colors_,
|
std::vector<Color> const &colors_,
|
||||||
std::vector<double> const &locations_,
|
std::vector<float> const &locations_,
|
||||||
Vector2D const &start_,
|
Vector2D const &start_,
|
||||||
Vector2D const &end_,
|
Vector2D const &end_,
|
||||||
CGRect bounds_
|
CGRect bounds_
|
||||||
@ -301,7 +301,7 @@ public:
|
|||||||
FillRule pathFillRule;
|
FillRule pathFillRule;
|
||||||
GradientType gradientType;
|
GradientType gradientType;
|
||||||
std::vector<Color> colors;
|
std::vector<Color> colors;
|
||||||
std::vector<double> locations;
|
std::vector<float> locations;
|
||||||
Vector2D start;
|
Vector2D start;
|
||||||
Vector2D end;
|
Vector2D end;
|
||||||
CGRect bounds;
|
CGRect bounds;
|
||||||
@ -328,7 +328,7 @@ public:
|
|||||||
|
|
||||||
class SolidShading: public Shading {
|
class SolidShading: public Shading {
|
||||||
public:
|
public:
|
||||||
SolidShading(Color const &color_, double opacity_) :
|
SolidShading(Color const &color_, float opacity_) :
|
||||||
color(color_),
|
color(color_),
|
||||||
opacity(opacity_) {
|
opacity(opacity_) {
|
||||||
}
|
}
|
||||||
@ -339,16 +339,16 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Color color;
|
Color color;
|
||||||
double opacity = 0.0;
|
float opacity = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GradientShading: public Shading {
|
class GradientShading: public Shading {
|
||||||
public:
|
public:
|
||||||
GradientShading(
|
GradientShading(
|
||||||
double opacity_,
|
float opacity_,
|
||||||
GradientType gradientType_,
|
GradientType gradientType_,
|
||||||
std::vector<Color> const &colors_,
|
std::vector<Color> const &colors_,
|
||||||
std::vector<double> const &locations_,
|
std::vector<float> const &locations_,
|
||||||
Vector2D const &start_,
|
Vector2D const &start_,
|
||||||
Vector2D const &end_
|
Vector2D const &end_
|
||||||
) :
|
) :
|
||||||
@ -365,31 +365,31 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double opacity = 0.0;
|
float opacity = 0.0;
|
||||||
GradientType gradientType;
|
GradientType gradientType;
|
||||||
std::vector<Color> colors;
|
std::vector<Color> colors;
|
||||||
std::vector<double> locations;
|
std::vector<float> locations;
|
||||||
Vector2D start;
|
Vector2D start;
|
||||||
Vector2D end;
|
Vector2D end;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Stroke {
|
struct Stroke {
|
||||||
std::shared_ptr<Shading> shading;
|
std::shared_ptr<Shading> shading;
|
||||||
double lineWidth = 0.0;
|
float lineWidth = 0.0;
|
||||||
LineJoin lineJoin = LineJoin::Round;
|
LineJoin lineJoin = LineJoin::Round;
|
||||||
LineCap lineCap = LineCap::Square;
|
LineCap lineCap = LineCap::Square;
|
||||||
double miterLimit = 4.0;
|
float miterLimit = 4.0;
|
||||||
double dashPhase = 0.0;
|
float dashPhase = 0.0;
|
||||||
std::vector<double> dashPattern;
|
std::vector<float> dashPattern;
|
||||||
|
|
||||||
Stroke(
|
Stroke(
|
||||||
std::shared_ptr<Shading> shading_,
|
std::shared_ptr<Shading> shading_,
|
||||||
double lineWidth_,
|
float lineWidth_,
|
||||||
LineJoin lineJoin_,
|
LineJoin lineJoin_,
|
||||||
LineCap lineCap_,
|
LineCap lineCap_,
|
||||||
double miterLimit_,
|
float miterLimit_,
|
||||||
double dashPhase_,
|
float dashPhase_,
|
||||||
std::vector<double> dashPattern_
|
std::vector<float> dashPattern_
|
||||||
) :
|
) :
|
||||||
shading(shading_),
|
shading(shading_),
|
||||||
lineWidth(lineWidth_),
|
lineWidth(lineWidth_),
|
||||||
@ -421,7 +421,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
bool isGroup = false;
|
bool isGroup = false;
|
||||||
CATransform3D transform = CATransform3D::identity();
|
CATransform3D transform = CATransform3D::identity();
|
||||||
double alpha = 0.0;
|
float alpha = 0.0;
|
||||||
std::optional<TrimParams> trimParams;
|
std::optional<TrimParams> trimParams;
|
||||||
std::optional<BezierPath> path;
|
std::optional<BezierPath> path;
|
||||||
CGRect pathBoundingBox = CGRect(0.0, 0.0, 0.0, 0.0);
|
CGRect pathBoundingBox = CGRect(0.0, 0.0, 0.0, 0.0);
|
||||||
@ -450,7 +450,7 @@ public:
|
|||||||
CGRect bounds_,
|
CGRect bounds_,
|
||||||
Vector2D position_,
|
Vector2D position_,
|
||||||
CATransform3D transform_,
|
CATransform3D transform_,
|
||||||
double alpha_,
|
float alpha_,
|
||||||
bool masksToBounds_,
|
bool masksToBounds_,
|
||||||
bool isHidden_,
|
bool isHidden_,
|
||||||
std::vector<std::shared_ptr<RenderTreeNode>> subnodes_,
|
std::vector<std::shared_ptr<RenderTreeNode>> subnodes_,
|
||||||
@ -484,7 +484,7 @@ public:
|
|||||||
return _transform;
|
return _transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
double alpha() const {
|
float alpha() const {
|
||||||
return _alpha;
|
return _alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ public:
|
|||||||
CGRect _bounds;
|
CGRect _bounds;
|
||||||
Vector2D _position;
|
Vector2D _position;
|
||||||
CATransform3D _transform = CATransform3D::identity();
|
CATransform3D _transform = CATransform3D::identity();
|
||||||
double _alpha = 1.0;
|
float _alpha = 1.0f;
|
||||||
bool _masksToBounds = false;
|
bool _masksToBounds = false;
|
||||||
bool _isHidden = false;
|
bool _isHidden = false;
|
||||||
std::shared_ptr<RenderTreeNodeContentItem> _contentItem;
|
std::shared_ptr<RenderTreeNodeContentItem> _contentItem;
|
||||||
|
|||||||
@ -37,12 +37,12 @@ enum class TrimType: int {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct TrimParams {
|
struct TrimParams {
|
||||||
double start = 0.0;
|
float start = 0.0;
|
||||||
double end = 0.0;
|
float end = 0.0;
|
||||||
double offset = 0.0;
|
float offset = 0.0;
|
||||||
TrimType type = TrimType::Simultaneously;
|
TrimType type = TrimType::Simultaneously;
|
||||||
|
|
||||||
TrimParams(double start_, double end_, double offset_, TrimType type_) :
|
TrimParams(float start_, float end_, float offset_, TrimType type_) :
|
||||||
start(start_),
|
start(start_),
|
||||||
end(end_),
|
end(end_),
|
||||||
offset(offset_),
|
offset(offset_),
|
||||||
|
|||||||
@ -82,7 +82,7 @@ public:
|
|||||||
return _contentsLayer;
|
return _contentsLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) {
|
void displayWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) {
|
||||||
bool layerVisible = isInRangeOrEqual(frame, _inFrame, _outFrame);
|
bool layerVisible = isInRangeOrEqual(frame, _inFrame, _outFrame);
|
||||||
|
|
||||||
if (_transformNode->updateTree(frame, forceUpdates) || _contentsLayer->isHidden() != !layerVisible) {
|
if (_transformNode->updateTree(frame, forceUpdates) || _contentsLayer->isHidden() != !layerVisible) {
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
virtual void updateContentsLayerParameters() {
|
virtual void updateContentsLayerParameters() {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) {
|
virtual void displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) {
|
||||||
/// To be overridden by subclass
|
/// To be overridden by subclass
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,16 +143,16 @@ public:
|
|||||||
return _matteType;
|
return _matteType;
|
||||||
}
|
}
|
||||||
|
|
||||||
double inFrame() const {
|
float inFrame() const {
|
||||||
return _inFrame;
|
return _inFrame;
|
||||||
}
|
}
|
||||||
double outFrame() const {
|
float outFrame() const {
|
||||||
return _outFrame;
|
return _outFrame;
|
||||||
}
|
}
|
||||||
double startFrame() const {
|
float startFrame() const {
|
||||||
return _startFrame;
|
return _startFrame;
|
||||||
}
|
}
|
||||||
double timeStretch() const {
|
float timeStretch() const {
|
||||||
return _timeStretch;
|
return _timeStretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,10 +174,10 @@ private:
|
|||||||
|
|
||||||
std::shared_ptr<MaskContainerLayer> _maskLayer;
|
std::shared_ptr<MaskContainerLayer> _maskLayer;
|
||||||
|
|
||||||
double _inFrame = 0.0;
|
float _inFrame = 0.0;
|
||||||
double _outFrame = 0.0;
|
float _outFrame = 0.0;
|
||||||
double _startFrame = 0.0;
|
float _startFrame = 0.0;
|
||||||
double _timeStretch = 0.0;
|
float _timeStretch = 0.0;
|
||||||
|
|
||||||
// MARK: Keypath Searchable
|
// MARK: Keypath Searchable
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ public:
|
|||||||
|
|
||||||
virtual ~MaskLayer() = default;
|
virtual ~MaskLayer() = default;
|
||||||
|
|
||||||
void updateWithFrame(double frame, bool forceUpdates) {
|
void updateWithFrame(float frame, bool forceUpdates) {
|
||||||
if (_properties.opacity()->needsUpdate(frame) || forceUpdates) {
|
if (_properties.opacity()->needsUpdate(frame) || forceUpdates) {
|
||||||
_properties.opacity()->update(frame);
|
_properties.opacity()->update(frame);
|
||||||
setOpacity(_properties.opacity()->value().value);
|
setOpacity(_properties.opacity()->value().value);
|
||||||
@ -163,7 +163,7 @@ public:
|
|||||||
|
|
||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
void updateWithFrame(double frame, bool forceUpdates) {
|
void updateWithFrame(float frame, bool forceUpdates) {
|
||||||
for (const auto &maskLayer : _maskLayers) {
|
for (const auto &maskLayer : _maskLayers) {
|
||||||
maskLayer->updateWithFrame(frame, forceUpdates);
|
maskLayer->updateWithFrame(frame, forceUpdates);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public:
|
|||||||
std::shared_ptr<AnimationTextProvider> const &textProvider,
|
std::shared_ptr<AnimationTextProvider> const &textProvider,
|
||||||
std::shared_ptr<AnimationFontProvider> const &fontProvider,
|
std::shared_ptr<AnimationFontProvider> const &fontProvider,
|
||||||
std::shared_ptr<AssetLibrary> const &assetLibrary,
|
std::shared_ptr<AssetLibrary> const &assetLibrary,
|
||||||
double frameRate
|
float frameRate
|
||||||
) : CompositionLayer(precomp, Vector2D(precomp->width, precomp->height)) {
|
) : CompositionLayer(precomp, Vector2D(precomp->width, precomp->height)) {
|
||||||
if (precomp->timeRemapping) {
|
if (precomp->timeRemapping) {
|
||||||
_remappingNode = std::make_shared<NodeProperty<Vector1D>>(std::make_shared<KeyframeInterpolator<Vector1D>>(precomp->timeRemapping->keyframes));
|
_remappingNode = std::make_shared<NodeProperty<Vector1D>>(std::make_shared<KeyframeInterpolator<Vector1D>>(precomp->timeRemapping->keyframes));
|
||||||
@ -86,8 +86,8 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override {
|
virtual void displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override {
|
||||||
double localFrame = 0.0;
|
float localFrame = 0.0;
|
||||||
if (_remappingNode) {
|
if (_remappingNode) {
|
||||||
_remappingNode->update(frame);
|
_remappingNode->update(frame);
|
||||||
localFrame = _remappingNode->value().value * _frameRate;
|
localFrame = _remappingNode->value().value * _frameRate;
|
||||||
@ -195,7 +195,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double _frameRate = 0.0;
|
float _frameRate = 0.0;
|
||||||
std::shared_ptr<NodeProperty<Vector1D>> _remappingNode;
|
std::shared_ptr<NodeProperty<Vector1D>> _remappingNode;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<CompositionLayer>> _animationLayers;
|
std::vector<std::shared_ptr<CompositionLayer>> _animationLayers;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public:
|
|||||||
Color colorValue = Color(0.0, 0.0, 0.0, 0.0);
|
Color colorValue = Color(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> opacity;
|
KeyframeInterpolator<Vector1D> opacity;
|
||||||
double opacityValue = 0.0;
|
float opacityValue = 0.0;
|
||||||
|
|
||||||
std::shared_ptr<RenderTreeNodeContentItem::Fill> _fill;
|
std::shared_ptr<RenderTreeNodeContentItem::Fill> _fill;
|
||||||
};
|
};
|
||||||
@ -93,7 +93,7 @@ public:
|
|||||||
0.0,
|
0.0,
|
||||||
gradientType,
|
gradientType,
|
||||||
std::vector<Color>(),
|
std::vector<Color>(),
|
||||||
std::vector<double>(),
|
std::vector<float>(),
|
||||||
Vector2D(0.0, 0.0),
|
Vector2D(0.0, 0.0),
|
||||||
Vector2D(0.0, 0.0)
|
Vector2D(0.0, 0.0)
|
||||||
);
|
);
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
|
|
||||||
if (hasUpdates) {
|
if (hasUpdates) {
|
||||||
std::vector<Color> colors;
|
std::vector<Color> colors;
|
||||||
std::vector<double> locations;
|
std::vector<float> locations;
|
||||||
getGradientParameters(numberOfColors, colorsValue, colors, locations);
|
getGradientParameters(numberOfColors, colorsValue, colors, locations);
|
||||||
|
|
||||||
RenderTreeNodeContentItem::GradientShading *gradient = ((RenderTreeNodeContentItem::GradientShading *)_fill->shading.get());
|
RenderTreeNodeContentItem::GradientShading *gradient = ((RenderTreeNodeContentItem::GradientShading *)_fill->shading.get());
|
||||||
@ -161,7 +161,7 @@ public:
|
|||||||
Vector3D endPointValue = Vector3D(0.0, 0.0, 0.0);
|
Vector3D endPointValue = Vector3D(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> opacity;
|
KeyframeInterpolator<Vector1D> opacity;
|
||||||
double opacityValue = 0.0;
|
float opacityValue = 0.0;
|
||||||
|
|
||||||
std::shared_ptr<RenderTreeNodeContentItem::Fill> _fill;
|
std::shared_ptr<RenderTreeNodeContentItem::Fill> _fill;
|
||||||
};
|
};
|
||||||
@ -202,7 +202,7 @@ public:
|
|||||||
lineCap,
|
lineCap,
|
||||||
miterLimit,
|
miterLimit,
|
||||||
0.0,
|
0.0,
|
||||||
std::vector<double>()
|
std::vector<float>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public:
|
|||||||
|
|
||||||
_stroke->lineWidth = widthValue;
|
_stroke->lineWidth = widthValue;
|
||||||
_stroke->dashPhase = hasNonZeroDashes ? dashPhaseValue : 0.0;
|
_stroke->dashPhase = hasNonZeroDashes ? dashPhaseValue : 0.0;
|
||||||
_stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector<double>();
|
_stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector<float>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,22 +268,22 @@ public:
|
|||||||
private:
|
private:
|
||||||
LineJoin lineJoin;
|
LineJoin lineJoin;
|
||||||
LineCap lineCap;
|
LineCap lineCap;
|
||||||
double miterLimit = 4.0;
|
float miterLimit = 4.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Color> color;
|
KeyframeInterpolator<Color> color;
|
||||||
Color colorValue = Color(0.0, 0.0, 0.0, 0.0);
|
Color colorValue = Color(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> opacity;
|
KeyframeInterpolator<Vector1D> opacity;
|
||||||
double opacityValue = 0.0;
|
float opacityValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> width;
|
KeyframeInterpolator<Vector1D> width;
|
||||||
double widthValue = 0.0;
|
float widthValue = 0.0;
|
||||||
|
|
||||||
std::unique_ptr<DashPatternInterpolator> dashPattern;
|
std::unique_ptr<DashPatternInterpolator> dashPattern;
|
||||||
DashPattern dashPatternValue = DashPattern({});
|
DashPattern dashPatternValue = DashPattern({});
|
||||||
|
|
||||||
std::unique_ptr<KeyframeInterpolator<Vector1D>> dashPhase;
|
std::unique_ptr<KeyframeInterpolator<Vector1D>> dashPhase;
|
||||||
double dashPhaseValue = 0.0;
|
float dashPhaseValue = 0.0;
|
||||||
|
|
||||||
std::shared_ptr<RenderTreeNodeContentItem::Stroke> _stroke;
|
std::shared_ptr<RenderTreeNodeContentItem::Stroke> _stroke;
|
||||||
};
|
};
|
||||||
@ -314,7 +314,7 @@ public:
|
|||||||
0.0,
|
0.0,
|
||||||
gradientType,
|
gradientType,
|
||||||
std::vector<Color>(),
|
std::vector<Color>(),
|
||||||
std::vector<double>(),
|
std::vector<float>(),
|
||||||
Vector2D(0.0, 0.0),
|
Vector2D(0.0, 0.0),
|
||||||
Vector2D(0.0, 0.0)
|
Vector2D(0.0, 0.0)
|
||||||
);
|
);
|
||||||
@ -325,7 +325,7 @@ public:
|
|||||||
lineCap,
|
lineCap,
|
||||||
miterLimit,
|
miterLimit,
|
||||||
0.0,
|
0.0,
|
||||||
std::vector<double>()
|
std::vector<float>()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Color> colors;
|
std::vector<Color> colors;
|
||||||
std::vector<double> locations;
|
std::vector<float> locations;
|
||||||
getGradientParameters(numberOfColors, colorsValue, colors, locations);
|
getGradientParameters(numberOfColors, colorsValue, colors, locations);
|
||||||
|
|
||||||
RenderTreeNodeContentItem::GradientShading *gradient = ((RenderTreeNodeContentItem::GradientShading *)_stroke->shading.get());
|
RenderTreeNodeContentItem::GradientShading *gradient = ((RenderTreeNodeContentItem::GradientShading *)_stroke->shading.get());
|
||||||
@ -397,7 +397,7 @@ public:
|
|||||||
|
|
||||||
_stroke->lineWidth = widthValue;
|
_stroke->lineWidth = widthValue;
|
||||||
_stroke->dashPhase = hasNonZeroDashes ? dashPhaseValue : 0.0;
|
_stroke->dashPhase = hasNonZeroDashes ? dashPhaseValue : 0.0;
|
||||||
_stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector<double>();
|
_stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector<float>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
LineJoin lineJoin;
|
LineJoin lineJoin;
|
||||||
LineCap lineCap;
|
LineCap lineCap;
|
||||||
double miterLimit = 4.0;
|
float miterLimit = 4.0;
|
||||||
|
|
||||||
int numberOfColors = 0;
|
int numberOfColors = 0;
|
||||||
GradientType gradientType;
|
GradientType gradientType;
|
||||||
@ -423,16 +423,16 @@ public:
|
|||||||
Vector3D endPointValue = Vector3D(0.0, 0.0, 0.0);
|
Vector3D endPointValue = Vector3D(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> opacity;
|
KeyframeInterpolator<Vector1D> opacity;
|
||||||
double opacityValue = 0.0;
|
float opacityValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> width;
|
KeyframeInterpolator<Vector1D> width;
|
||||||
double widthValue = 0.0;
|
float widthValue = 0.0;
|
||||||
|
|
||||||
std::unique_ptr<DashPatternInterpolator> dashPattern;
|
std::unique_ptr<DashPatternInterpolator> dashPattern;
|
||||||
DashPattern dashPatternValue = DashPattern({});
|
DashPattern dashPatternValue = DashPattern({});
|
||||||
|
|
||||||
std::unique_ptr<KeyframeInterpolator<Vector1D>> dashPhase;
|
std::unique_ptr<KeyframeInterpolator<Vector1D>> dashPhase;
|
||||||
double dashPhaseValue = 0.0;
|
float dashPhaseValue = 0.0;
|
||||||
|
|
||||||
std::shared_ptr<RenderTreeNodeContentItem::Stroke> _stroke;
|
std::shared_ptr<RenderTreeNodeContentItem::Stroke> _stroke;
|
||||||
};
|
};
|
||||||
@ -461,12 +461,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrimParams trimParams() {
|
TrimParams trimParams() {
|
||||||
double resolvedStartValue = startValue * 0.01;
|
float resolvedStartValue = startValue * 0.01;
|
||||||
double resolvedEndValue = endValue * 0.01;
|
float resolvedEndValue = endValue * 0.01;
|
||||||
double resolvedStart = std::min(resolvedStartValue, resolvedEndValue);
|
float resolvedStart = std::min(resolvedStartValue, resolvedEndValue);
|
||||||
double resolvedEnd = std::max(resolvedStartValue, resolvedEndValue);
|
float resolvedEnd = std::max(resolvedStartValue, resolvedEndValue);
|
||||||
|
|
||||||
double resolvedOffset = fmod(offsetValue, 360.0) / 360.0;
|
float resolvedOffset = fmod(offsetValue, 360.0) / 360.0;
|
||||||
|
|
||||||
return TrimParams(resolvedStart, resolvedEnd, resolvedOffset, type);
|
return TrimParams(resolvedStart, resolvedEnd, resolvedOffset, type);
|
||||||
}
|
}
|
||||||
@ -475,13 +475,13 @@ public:
|
|||||||
TrimType type;
|
TrimType type;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> start;
|
KeyframeInterpolator<Vector1D> start;
|
||||||
double startValue = 0.0;
|
float startValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> end;
|
KeyframeInterpolator<Vector1D> end;
|
||||||
double endValue = 0.0;
|
float endValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> offset;
|
KeyframeInterpolator<Vector1D> offset;
|
||||||
double offsetValue = 0.0;
|
float offsetValue = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShadingVariant {
|
struct ShadingVariant {
|
||||||
@ -624,7 +624,7 @@ public:
|
|||||||
Vector3D sizeValue = Vector3D(0.0, 0.0, 0.0);
|
Vector3D sizeValue = Vector3D(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> cornerRadius;
|
KeyframeInterpolator<Vector1D> cornerRadius;
|
||||||
double cornerRadiusValue = 0.0;
|
float cornerRadiusValue = 0.0;
|
||||||
|
|
||||||
BezierPath resolvedPath;
|
BezierPath resolvedPath;
|
||||||
CGRect resolvedPathBounds = CGRect(0.0, 0.0, 0.0, 0.0);
|
CGRect resolvedPathBounds = CGRect(0.0, 0.0, 0.0, 0.0);
|
||||||
@ -768,22 +768,22 @@ public:
|
|||||||
Vector3D positionValue = Vector3D(0.0, 0.0, 0.0);
|
Vector3D positionValue = Vector3D(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> outerRadius;
|
KeyframeInterpolator<Vector1D> outerRadius;
|
||||||
double outerRadiusValue = 0.0;
|
float outerRadiusValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> outerRoundedness;
|
KeyframeInterpolator<Vector1D> outerRoundedness;
|
||||||
double outerRoundednessValue = 0.0;
|
float outerRoundednessValue = 0.0;
|
||||||
|
|
||||||
std::unique_ptr<NodeProperty<Vector1D>> innerRadius;
|
std::unique_ptr<NodeProperty<Vector1D>> innerRadius;
|
||||||
double innerRadiusValue = 0.0;
|
float innerRadiusValue = 0.0;
|
||||||
|
|
||||||
std::unique_ptr<NodeProperty<Vector1D>> innerRoundedness;
|
std::unique_ptr<NodeProperty<Vector1D>> innerRoundedness;
|
||||||
double innerRoundednessValue = 0.0;
|
float innerRoundednessValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> rotation;
|
KeyframeInterpolator<Vector1D> rotation;
|
||||||
double rotationValue = 0.0;
|
float rotationValue = 0.0;
|
||||||
|
|
||||||
KeyframeInterpolator<Vector1D> points;
|
KeyframeInterpolator<Vector1D> points;
|
||||||
double pointsValue = 0.0;
|
float pointsValue = 0.0;
|
||||||
|
|
||||||
BezierPath resolvedPath;
|
BezierPath resolvedPath;
|
||||||
CGRect resolvedPathBounds = CGRect(0.0, 0.0, 0.0, 0.0);
|
CGRect resolvedPathBounds = CGRect(0.0, 0.0, 0.0, 0.0);
|
||||||
@ -861,17 +861,17 @@ public:
|
|||||||
scaleValue = _scale->value(frameTime);
|
scaleValue = _scale->value(frameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
double rotationValue = 0.0;
|
float rotationValue = 0.0;
|
||||||
if (_rotation) {
|
if (_rotation) {
|
||||||
rotationValue = _rotation->value(frameTime).value;
|
rotationValue = _rotation->value(frameTime).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double skewValue = 0.0;
|
float skewValue = 0.0;
|
||||||
if (_skew) {
|
if (_skew) {
|
||||||
skewValue = _skew->value(frameTime).value;
|
skewValue = _skew->value(frameTime).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
double skewAxisValue = 0.0;
|
float skewAxisValue = 0.0;
|
||||||
if (_skewAxis) {
|
if (_skewAxis) {
|
||||||
skewAxisValue = _skewAxis->value(frameTime).value;
|
skewAxisValue = _skewAxis->value(frameTime).value;
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ public:
|
|||||||
return _transformValue;
|
return _transformValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double opacity() {
|
float opacity() {
|
||||||
return _opacityValue;
|
return _opacityValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,7 +908,7 @@ public:
|
|||||||
std::unique_ptr<KeyframeInterpolator<Vector1D>> _opacity;
|
std::unique_ptr<KeyframeInterpolator<Vector1D>> _opacity;
|
||||||
|
|
||||||
CATransform3D _transformValue = CATransform3D::identity();
|
CATransform3D _transformValue = CATransform3D::identity();
|
||||||
double _opacityValue = 1.0;
|
float _opacityValue = 1.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContentItem {
|
class ContentItem {
|
||||||
@ -1089,7 +1089,7 @@ public:
|
|||||||
|
|
||||||
void updateContents(std::optional<TrimParams> parentTrim) {
|
void updateContents(std::optional<TrimParams> parentTrim) {
|
||||||
CATransform3D containerTransform = CATransform3D::identity();
|
CATransform3D containerTransform = CATransform3D::identity();
|
||||||
double containerOpacity = 1.0;
|
float containerOpacity = 1.0;
|
||||||
if (transform) {
|
if (transform) {
|
||||||
containerTransform = transform->transform();
|
containerTransform = transform->transform();
|
||||||
containerOpacity = transform->opacity();
|
containerOpacity = transform->opacity();
|
||||||
@ -1333,7 +1333,7 @@ CompositionLayer(solidLayer, Vector2D::Zero()) {
|
|||||||
_contentTree = std::make_shared<ShapeLayerPresentationTree>(solidLayer);
|
_contentTree = std::make_shared<ShapeLayerPresentationTree>(solidLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeCompositionLayer::displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) {
|
void ShapeCompositionLayer::displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) {
|
||||||
_frameTime = frame;
|
_frameTime = frame;
|
||||||
_frameTimeInitialized = true;
|
_frameTimeInitialized = true;
|
||||||
_contentTree->itemTree->updateFrame(_frameTime, boundingBoxContext);
|
_contentTree->itemTree->updateFrame(_frameTime, boundingBoxContext);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public:
|
|||||||
ShapeCompositionLayer(std::shared_ptr<ShapeLayerModel> const &shapeLayer);
|
ShapeCompositionLayer(std::shared_ptr<ShapeLayerModel> const &shapeLayer);
|
||||||
ShapeCompositionLayer(std::shared_ptr<SolidLayerModel> const &solidLayer);
|
ShapeCompositionLayer(std::shared_ptr<SolidLayerModel> const &solidLayer);
|
||||||
|
|
||||||
virtual void displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override;
|
virtual void displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override;
|
||||||
virtual std::shared_ptr<RenderTreeNode> renderTreeNode(BezierPathsBoundingBoxContext &boundingBoxContext) override;
|
virtual std::shared_ptr<RenderTreeNode> renderTreeNode(BezierPathsBoundingBoxContext &boundingBoxContext) override;
|
||||||
void initializeContentsLayerParameters();
|
void initializeContentsLayerParameters();
|
||||||
virtual void updateContentsLayerParameters() override;
|
virtual void updateContentsLayerParameters() override;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public:
|
|||||||
_fontProvider = fontProvider;
|
_fontProvider = fontProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override {
|
virtual void displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override {
|
||||||
if (!_textDocument) {
|
if (!_textDocument) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void display() {
|
void display() {
|
||||||
double newFrame = currentFrame();
|
float newFrame = currentFrame();
|
||||||
if (_respectAnimationFrameRate) {
|
if (_respectAnimationFrameRate) {
|
||||||
newFrame = floor(newFrame);
|
newFrame = floor(newFrame);
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<AnyValue> getValue(AnimationKeypath const &keypath, std::optional<double> atFrame) {
|
std::optional<AnyValue> getValue(AnimationKeypath const &keypath, std::optional<float> atFrame) {
|
||||||
/*for (const auto &layer : _animationLayers) {
|
/*for (const auto &layer : _animationLayers) {
|
||||||
assert(false);
|
assert(false);
|
||||||
if
|
if
|
||||||
@ -153,7 +153,7 @@ public:
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<AnyValue> getOriginalValue(AnimationKeypath const &keypath, std::optional<double> atFrame) {
|
std::optional<AnyValue> getOriginalValue(AnimationKeypath const &keypath, std::optional<float> atFrame) {
|
||||||
/*for (const auto &layer : _animationLayers) {
|
/*for (const auto &layer : _animationLayers) {
|
||||||
assert(false);
|
assert(false);
|
||||||
if
|
if
|
||||||
@ -186,10 +186,10 @@ public:
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
double currentFrame() const {
|
float currentFrame() const {
|
||||||
return _currentFrame;
|
return _currentFrame;
|
||||||
}
|
}
|
||||||
void setCurrentFrame(double currentFrame) {
|
void setCurrentFrame(float currentFrame) {
|
||||||
_currentFrame = currentFrame;
|
_currentFrame = currentFrame;
|
||||||
|
|
||||||
for (size_t i = 0; i < _animationLayers.size(); i++) {
|
for (size_t i = 0; i < _animationLayers.size(); i++) {
|
||||||
@ -256,7 +256,7 @@ private:
|
|||||||
// MARK: Internal
|
// MARK: Internal
|
||||||
|
|
||||||
/// The animatable Current Frame Property
|
/// The animatable Current Frame Property
|
||||||
double _currentFrame = 0.0;
|
float _currentFrame = 0.0;
|
||||||
|
|
||||||
std::shared_ptr<AnimationImageProvider> _imageProvider;
|
std::shared_ptr<AnimationImageProvider> _imageProvider;
|
||||||
std::shared_ptr<AnimationTextProvider> _textProvider;
|
std::shared_ptr<AnimationTextProvider> _textProvider;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ std::vector<std::shared_ptr<CompositionLayer>> initializeCompositionLayers(
|
|||||||
std::shared_ptr<LayerImageProvider> const &layerImageProvider,
|
std::shared_ptr<LayerImageProvider> const &layerImageProvider,
|
||||||
std::shared_ptr<AnimationTextProvider> const &textProvider,
|
std::shared_ptr<AnimationTextProvider> const &textProvider,
|
||||||
std::shared_ptr<AnimationFontProvider> const &fontProvider,
|
std::shared_ptr<AnimationFontProvider> const &fontProvider,
|
||||||
double frameRate
|
float frameRate
|
||||||
) {
|
) {
|
||||||
std::vector<std::shared_ptr<CompositionLayer>> compositionLayers;
|
std::vector<std::shared_ptr<CompositionLayer>> compositionLayers;
|
||||||
std::map<int, std::shared_ptr<CompositionLayer>> layerMap;
|
std::map<int, std::shared_ptr<CompositionLayer>> layerMap;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ std::vector<std::shared_ptr<CompositionLayer>> initializeCompositionLayers(
|
|||||||
std::shared_ptr<LayerImageProvider> const &layerImageProvider,
|
std::shared_ptr<LayerImageProvider> const &layerImageProvider,
|
||||||
std::shared_ptr<AnimationTextProvider> const &textProvider,
|
std::shared_ptr<AnimationTextProvider> const &textProvider,
|
||||||
std::shared_ptr<AnimationFontProvider> const &fontProvider,
|
std::shared_ptr<AnimationFontProvider> const &fontProvider,
|
||||||
double frameRate
|
float frameRate
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -136,11 +136,11 @@ public:
|
|||||||
return _transformProperties;
|
return _transformProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool shouldRebuildOutputs(double frame) override {
|
virtual bool shouldRebuildOutputs(float frame) override {
|
||||||
return hasLocalUpdates() || hasUpstreamUpdates();
|
return hasLocalUpdates() || hasUpstreamUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void rebuildOutputs(double frame) override {
|
virtual void rebuildOutputs(float frame) override {
|
||||||
_opacity = ((float)_transformProperties->opacity()->value().value) * 0.01f;
|
_opacity = ((float)_transformProperties->opacity()->value().value) * 0.01f;
|
||||||
|
|
||||||
Vector2D position(0.0, 0.0);
|
Vector2D position(0.0, 0.0);
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public:
|
|||||||
return _typedContainer.outputValue();
|
return _typedContainer.outputValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool needsUpdate(double frame) const override {
|
virtual bool needsUpdate(float frame) const override {
|
||||||
return _typedContainer.needsUpdate() || _valueProvider->hasUpdate(frame);
|
return _typedContainer.needsUpdate() || _valueProvider->hasUpdate(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public:
|
|||||||
_typedContainer.setNeedsUpdate();*/
|
_typedContainer.setNeedsUpdate();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void update(double frame) override {
|
virtual void update(float frame) override {
|
||||||
_typedContainer.setValue(_valueProvider->value(frame), frame);
|
_typedContainer.setValue(_valueProvider->value(frame), frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,10 +16,10 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// Returns true if the property needs to recompute its stored value
|
/// Returns true if the property needs to recompute its stored value
|
||||||
virtual bool needsUpdate(double frame) const = 0;
|
virtual bool needsUpdate(float frame) const = 0;
|
||||||
|
|
||||||
/// Updates the property for the frame
|
/// Updates the property for the frame
|
||||||
virtual void update(double frame) = 0;
|
virtual void update(float frame) = 0;
|
||||||
|
|
||||||
/// The Type of the value provider
|
/// The Type of the value provider
|
||||||
virtual AnyValue::Type valueType() const = 0;
|
virtual AnyValue::Type valueType() const = 0;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public:
|
|||||||
virtual bool needsUpdate() const = 0;
|
virtual bool needsUpdate() const = 0;
|
||||||
|
|
||||||
/// The frame time of the last provided update
|
/// The frame time of the last provided update
|
||||||
virtual double lastUpdateFrame() const = 0;
|
virtual float lastUpdateFrame() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace lottie {
|
|||||||
|
|
||||||
class HasRenderUpdates {
|
class HasRenderUpdates {
|
||||||
public:
|
public:
|
||||||
virtual bool hasRenderUpdates(double forFrame) = 0;
|
virtual bool hasRenderUpdates(float forFrame) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class NodePropertyMap: virtual public HasChildKeypaths {
|
|||||||
public:
|
public:
|
||||||
virtual std::vector<std::shared_ptr<AnyNodeProperty>> &properties() = 0;
|
virtual std::vector<std::shared_ptr<AnyNodeProperty>> &properties() = 0;
|
||||||
|
|
||||||
bool needsLocalUpdate(double frame) {
|
bool needsLocalUpdate(float frame) {
|
||||||
for (auto &property : properties()) {
|
for (auto &property : properties()) {
|
||||||
if (property->needsUpdate(frame)) {
|
if (property->needsUpdate(frame)) {
|
||||||
return true;
|
return true;
|
||||||
@ -22,7 +22,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateNodeProperties(double frame) {
|
void updateNodeProperties(float frame) {
|
||||||
for (auto &property : properties()) {
|
for (auto &property : properties()) {
|
||||||
property->update(frame);
|
property->update(frame);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double _lastUpdateFrame = std::numeric_limits<double>::infinity();
|
float _lastUpdateFrame = std::numeric_limits<float>::infinity();
|
||||||
bool _needsUpdate = true;
|
bool _needsUpdate = true;
|
||||||
|
|
||||||
virtual AnyValue value() const override {
|
virtual AnyValue value() const override {
|
||||||
@ -26,7 +26,7 @@ public:
|
|||||||
return _needsUpdate;
|
return _needsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual double lastUpdateFrame() const override {
|
virtual float lastUpdateFrame() const override {
|
||||||
return _lastUpdateFrame;
|
return _lastUpdateFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public:
|
|||||||
_needsUpdate = false;
|
_needsUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setValue(AnyValue value, double forFrame) {
|
void setValue(AnyValue value, float forFrame) {
|
||||||
if (value.type() == AnyValueType<T>::type()) {
|
if (value.type() == AnyValueType<T>::type()) {
|
||||||
_needsUpdate = false;
|
_needsUpdate = false;
|
||||||
_lastUpdateFrame = forFrame;
|
_lastUpdateFrame = forFrame;
|
||||||
|
|||||||
@ -23,14 +23,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual DashPattern value(AnimationFrameTime frame) override {
|
virtual DashPattern value(AnimationFrameTime frame) override {
|
||||||
std::vector<double> values;
|
std::vector<float> values;
|
||||||
for (const auto &interpolator : _keyframeInterpolators) {
|
for (const auto &interpolator : _keyframeInterpolators) {
|
||||||
values.push_back(interpolator->value(frame).value);
|
values.push_back(interpolator->value(frame).value);
|
||||||
}
|
}
|
||||||
return DashPattern(std::move(values));
|
return DashPattern(std::move(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hasUpdate(double frame) const override {
|
virtual bool hasUpdate(float frame) const override {
|
||||||
for (const auto &interpolator : _keyframeInterpolators) {
|
for (const auto &interpolator : _keyframeInterpolators) {
|
||||||
if (interpolator->hasUpdate(frame)) {
|
if (interpolator->hasUpdate(frame)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -62,7 +62,7 @@ public:
|
|||||||
/// - If time is outside of the span, and there are more keyframes
|
/// - If time is outside of the span, and there are more keyframes
|
||||||
/// - If a value delegate is set
|
/// - If a value delegate is set
|
||||||
/// - If leading and trailing are both nil.
|
/// - If leading and trailing are both nil.
|
||||||
virtual bool hasUpdate(double frame) const override {
|
virtual bool hasUpdate(float frame) const override {
|
||||||
if (!lastUpdatedFrame.has_value()) {
|
if (!lastUpdatedFrame.has_value()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
// MARK: Fileprivate
|
// MARK: Fileprivate
|
||||||
|
|
||||||
std::optional<double> lastUpdatedFrame;
|
std::optional<float> lastUpdatedFrame;
|
||||||
|
|
||||||
std::optional<int> leadingIndex;
|
std::optional<int> leadingIndex;
|
||||||
std::optional<int> trailingIndex;
|
std::optional<int> trailingIndex;
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
std::optional<Keyframe<T>> trailingKeyframe;
|
std::optional<Keyframe<T>> trailingKeyframe;
|
||||||
|
|
||||||
/// Finds the appropriate Leading and Trailing keyframe index for the given time.
|
/// Finds the appropriate Leading and Trailing keyframe index for the given time.
|
||||||
void updateSpanIndices(double frame) {
|
void updateSpanIndices(float frame) {
|
||||||
if (keyframes.empty()) {
|
if (keyframes.empty()) {
|
||||||
leadingIndex = std::nullopt;
|
leadingIndex = std::nullopt;
|
||||||
trailingIndex = std::nullopt;
|
trailingIndex = std::nullopt;
|
||||||
@ -270,7 +270,7 @@ public:
|
|||||||
/// - If time is outside of the span, and there are more keyframes
|
/// - If time is outside of the span, and there are more keyframes
|
||||||
/// - If a value delegate is set
|
/// - If a value delegate is set
|
||||||
/// - If leading and trailing are both nil.
|
/// - If leading and trailing are both nil.
|
||||||
bool hasUpdate(double frame) const {
|
bool hasUpdate(float frame) const {
|
||||||
if (!lastUpdatedFrame.has_value()) {
|
if (!lastUpdatedFrame.has_value()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -302,7 +302,7 @@ public:
|
|||||||
|
|
||||||
// MARK: Fileprivate
|
// MARK: Fileprivate
|
||||||
|
|
||||||
std::optional<double> lastUpdatedFrame;
|
std::optional<float> lastUpdatedFrame;
|
||||||
|
|
||||||
std::optional<int> leadingIndex;
|
std::optional<int> leadingIndex;
|
||||||
std::optional<int> trailingIndex;
|
std::optional<int> trailingIndex;
|
||||||
@ -310,7 +310,7 @@ public:
|
|||||||
std::optional<Keyframe<BezierPath>> trailingKeyframe;
|
std::optional<Keyframe<BezierPath>> trailingKeyframe;
|
||||||
|
|
||||||
/// Finds the appropriate Leading and Trailing keyframe index for the given time.
|
/// Finds the appropriate Leading and Trailing keyframe index for the given time.
|
||||||
void updateSpanIndices(double frame) {
|
void updateSpanIndices(float frame) {
|
||||||
if (keyframes.empty()) {
|
if (keyframes.empty()) {
|
||||||
leadingIndex = std::nullopt;
|
leadingIndex = std::nullopt;
|
||||||
trailingIndex = std::nullopt;
|
trailingIndex = std::nullopt;
|
||||||
@ -434,7 +434,7 @@ private:
|
|||||||
ValueInterpolator<BezierPath>::setInplace(from.value, outPath);
|
ValueInterpolator<BezierPath>::setInplace(from.value, outPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void interpolateInplace(Keyframe<BezierPath> const &from, Keyframe<BezierPath> const &to, double progress, BezierPath &outPath) {
|
void interpolateInplace(Keyframe<BezierPath> const &from, Keyframe<BezierPath> const &to, float progress, BezierPath &outPath) {
|
||||||
std::optional<Vector2D> spatialOutTangent2d;
|
std::optional<Vector2D> spatialOutTangent2d;
|
||||||
if (from.spatialOutTangent) {
|
if (from.spatialOutTangent) {
|
||||||
spatialOutTangent2d = Vector2D(from.spatialOutTangent->x, from.spatialOutTangent->y);
|
spatialOutTangent2d = Vector2D(from.spatialOutTangent->x, from.spatialOutTangent->y);
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public:
|
|||||||
return AnyValueType<T>::type();
|
return AnyValueType<T>::type();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hasUpdate(double frame) const override {
|
virtual bool hasUpdate(float frame) const override {
|
||||||
return _hasUpdate;
|
return _hasUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hasOutputUpdates(double forFrame) override {
|
virtual bool hasOutputUpdates(float forFrame) override {
|
||||||
/// Changes to this node do not affect downstream nodes.
|
/// Changes to this node do not affect downstream nodes.
|
||||||
bool parentUpdate = false;
|
bool parentUpdate = false;
|
||||||
if (_parent) {
|
if (_parent) {
|
||||||
@ -51,7 +51,7 @@ public:
|
|||||||
return parentUpdate;
|
return parentUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hasRenderUpdates(double forFrame) override {
|
virtual bool hasRenderUpdates(float forFrame) override {
|
||||||
/// Return true if there are upstream updates or if this node has updates
|
/// Return true if there are upstream updates or if this node has updates
|
||||||
bool upstreamUpdates = false;
|
bool upstreamUpdates = false;
|
||||||
if (_parent) {
|
if (_parent) {
|
||||||
|
|||||||
@ -112,16 +112,16 @@ public:
|
|||||||
scale = Vector2D(scale3d.x, scale3d.y);
|
scale = Vector2D(scale3d.x, scale3d.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
double rotation = 0.0;
|
float rotation = 0.0;
|
||||||
if (_rotation) {
|
if (_rotation) {
|
||||||
rotation = _rotation->value().value;
|
rotation = _rotation->value().value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<double> skew;
|
std::optional<float> skew;
|
||||||
if (_skew) {
|
if (_skew) {
|
||||||
skew = _skew->value().value;
|
skew = _skew->value().value;
|
||||||
}
|
}
|
||||||
std::optional<double> skewAxis;
|
std::optional<float> skewAxis;
|
||||||
if (_skewAxis) {
|
if (_skewAxis) {
|
||||||
skewAxis = _skewAxis->value().value;
|
skewAxis = _skewAxis->value().value;
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
double opacity() {
|
float opacity() {
|
||||||
if (_opacity) {
|
if (_opacity) {
|
||||||
return _opacity->value().value;
|
return _opacity->value().value;
|
||||||
} else {
|
} else {
|
||||||
@ -164,7 +164,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double tracking() {
|
float tracking() {
|
||||||
if (_tracking) {
|
if (_tracking) {
|
||||||
return _tracking->value().value;
|
return _tracking->value().value;
|
||||||
} else {
|
} else {
|
||||||
@ -172,7 +172,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double strokeWidth() {
|
float strokeWidth() {
|
||||||
if (_strokeWidth) {
|
if (_strokeWidth) {
|
||||||
return _strokeWidth->value().value;
|
return _strokeWidth->value().value;
|
||||||
} else {
|
} else {
|
||||||
@ -225,7 +225,7 @@ public:
|
|||||||
_xform = xform;
|
_xform = xform;
|
||||||
}
|
}
|
||||||
|
|
||||||
double opacity() {
|
float opacity() {
|
||||||
if (_opacity.has_value()) {
|
if (_opacity.has_value()) {
|
||||||
return _opacity.value();
|
return _opacity.value();
|
||||||
} else if (_parentTextNode) {
|
} else if (_parentTextNode) {
|
||||||
@ -234,7 +234,7 @@ public:
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void setOpacity(double opacity) {
|
void setOpacity(float opacity) {
|
||||||
_opacity = opacity;
|
_opacity = opacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ public:
|
|||||||
_fillColor = fillColor;
|
_fillColor = fillColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
double tracking() {
|
float tracking() {
|
||||||
if (_tracking.has_value()) {
|
if (_tracking.has_value()) {
|
||||||
return _tracking.value();
|
return _tracking.value();
|
||||||
} else if (_parentTextNode) {
|
} else if (_parentTextNode) {
|
||||||
@ -273,11 +273,11 @@ public:
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void setTracking(double tracking) {
|
void setTracking(float tracking) {
|
||||||
_tracking = tracking;
|
_tracking = tracking;
|
||||||
}
|
}
|
||||||
|
|
||||||
double strokeWidth() {
|
float strokeWidth() {
|
||||||
if (_strokeWidth.has_value()) {
|
if (_strokeWidth.has_value()) {
|
||||||
return _strokeWidth.value();
|
return _strokeWidth.value();
|
||||||
} else if (_parentTextNode) {
|
} else if (_parentTextNode) {
|
||||||
@ -286,11 +286,11 @@ public:
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void setStrokeWidth(double strokeWidth) {
|
void setStrokeWidth(float strokeWidth) {
|
||||||
_strokeWidth = strokeWidth;
|
_strokeWidth = strokeWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hasOutputUpdates(double frame) override {
|
virtual bool hasOutputUpdates(float frame) override {
|
||||||
// TODO Fix This
|
// TODO Fix This
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -313,11 +313,11 @@ private:
|
|||||||
std::shared_ptr<CGPath> _outputPath;
|
std::shared_ptr<CGPath> _outputPath;
|
||||||
|
|
||||||
std::optional<CATransform3D> _xform;
|
std::optional<CATransform3D> _xform;
|
||||||
std::optional<double> _opacity;
|
std::optional<float> _opacity;
|
||||||
std::optional<Color> _strokeColor;
|
std::optional<Color> _strokeColor;
|
||||||
std::optional<Color> _fillColor;
|
std::optional<Color> _fillColor;
|
||||||
std::optional<double> _tracking;
|
std::optional<float> _tracking;
|
||||||
std::optional<double> _strokeWidth;
|
std::optional<float> _strokeWidth;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextAnimatorNode: public AnimatorNode {
|
class TextAnimatorNode: public AnimatorNode {
|
||||||
@ -347,7 +347,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void rebuildOutputs(double frame) override {
|
virtual void rebuildOutputs(float frame) override {
|
||||||
_textOutputNode->setXform(_textAnimatorProperties->caTransform());
|
_textOutputNode->setXform(_textAnimatorProperties->caTransform());
|
||||||
_textOutputNode->setOpacity(((float)_textAnimatorProperties->opacity()) * 0.01f);
|
_textOutputNode->setOpacity(((float)_textAnimatorProperties->opacity()) * 0.01f);
|
||||||
_textOutputNode->setStrokeColor(_textAnimatorProperties->strokeColor());
|
_textOutputNode->setStrokeColor(_textAnimatorProperties->strokeColor());
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public:
|
|||||||
virtual std::shared_ptr<NodeOutput> outputNode() = 0;
|
virtual std::shared_ptr<NodeOutput> outputNode() = 0;
|
||||||
|
|
||||||
/// Update the outputs of the node. Called if local contents were update or if outputsNeedUpdate returns true.
|
/// Update the outputs of the node. Called if local contents were update or if outputsNeedUpdate returns true.
|
||||||
virtual void rebuildOutputs(double frame) = 0;
|
virtual void rebuildOutputs(float frame) = 0;
|
||||||
|
|
||||||
/// Setters for marking current node state.
|
/// Setters for marking current node state.
|
||||||
bool isEnabled() {
|
bool isEnabled() {
|
||||||
@ -79,10 +79,10 @@ public:
|
|||||||
_hasUpstreamUpdates = hasUpstreamUpdates;
|
_hasUpstreamUpdates = hasUpstreamUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<double> lastUpdateFrame() {
|
std::optional<float> lastUpdateFrame() {
|
||||||
return _lastUpdateFrame;
|
return _lastUpdateFrame;
|
||||||
}
|
}
|
||||||
virtual void setLastUpdateFrame(std::optional<double> lastUpdateFrame) {
|
virtual void setLastUpdateFrame(std::optional<float> lastUpdateFrame) {
|
||||||
_lastUpdateFrame = lastUpdateFrame;
|
_lastUpdateFrame = lastUpdateFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,20 +97,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Called at the end of this nodes update cycle. Always called. Optional.
|
/// Called at the end of this nodes update cycle. Always called. Optional.
|
||||||
virtual bool performAdditionalLocalUpdates(double frame, bool forceLocalUpdate) {
|
virtual bool performAdditionalLocalUpdates(float frame, bool forceLocalUpdate) {
|
||||||
/// Optional
|
/// Optional
|
||||||
return forceLocalUpdate;
|
return forceLocalUpdate;
|
||||||
}
|
}
|
||||||
virtual void performAdditionalOutputUpdates(double frame, bool forceOutputUpdate) {
|
virtual void performAdditionalOutputUpdates(float frame, bool forceOutputUpdate) {
|
||||||
/// Optional
|
/// Optional
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The default simply returns `hasLocalUpdates`
|
/// The default simply returns `hasLocalUpdates`
|
||||||
virtual bool shouldRebuildOutputs(double frame) {
|
virtual bool shouldRebuildOutputs(float frame) {
|
||||||
return hasLocalUpdates();
|
return hasLocalUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool updateOutputs(double frame, bool forceOutputUpdate) {
|
virtual bool updateOutputs(float frame, bool forceOutputUpdate) {
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
setLastUpdateFrame(frame);
|
setLastUpdateFrame(frame);
|
||||||
if (const auto parentNodeValue = parentNode()) {
|
if (const auto parentNodeValue = parentNode()) {
|
||||||
@ -147,7 +147,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Rebuilds the content of this node, and upstream nodes if necessary.
|
/// Rebuilds the content of this node, and upstream nodes if necessary.
|
||||||
virtual bool updateContents(double frame, bool forceLocalUpdate) {
|
virtual bool updateContents(float frame, bool forceLocalUpdate) {
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
// Disabled node, pass through.
|
// Disabled node, pass through.
|
||||||
if (const auto parentNodeValue = parentNode()) {
|
if (const auto parentNodeValue = parentNode()) {
|
||||||
@ -185,7 +185,7 @@ public:
|
|||||||
return localUpdatesPermeateDownstream() ? hasUpstreamUpdates() || hasLocalUpdates() : hasUpstreamUpdates();
|
return localUpdatesPermeateDownstream() ? hasUpstreamUpdates() || hasLocalUpdates() : hasUpstreamUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool updateTree(double frame, bool forceUpdates) {
|
bool updateTree(float frame, bool forceUpdates) {
|
||||||
if (updateContents(frame, forceUpdates)) {
|
if (updateContents(frame, forceUpdates)) {
|
||||||
return updateOutputs(frame, forceUpdates);
|
return updateOutputs(frame, forceUpdates);
|
||||||
} else {
|
} else {
|
||||||
@ -230,7 +230,7 @@ private:
|
|||||||
bool _isEnabled = true;
|
bool _isEnabled = true;
|
||||||
bool _hasLocalUpdates = false;
|
bool _hasLocalUpdates = false;
|
||||||
bool _hasUpstreamUpdates = false;
|
bool _hasUpstreamUpdates = false;
|
||||||
std::optional<double> _lastUpdateFrame;
|
std::optional<float> _lastUpdateFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public:
|
|||||||
virtual std::shared_ptr<NodeOutput> parent() = 0;
|
virtual std::shared_ptr<NodeOutput> parent() = 0;
|
||||||
|
|
||||||
/// Returns true if there are any updates upstream. OutputPath must be built before returning.
|
/// Returns true if there are any updates upstream. OutputPath must be built before returning.
|
||||||
virtual bool hasOutputUpdates(double forFrame) = 0;
|
virtual bool hasOutputUpdates(float forFrame) = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<CGPath> outputPath() = 0;
|
virtual std::shared_ptr<CGPath> outputPath() = 0;
|
||||||
|
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace lottie {
|
namespace lottie {
|
||||||
|
|
||||||
void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector<Color> &outColors, std::vector<double> &outLocations) {
|
void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector<Color> &outColors, std::vector<float> &outLocations) {
|
||||||
std::vector<Color> alphaColors;
|
std::vector<Color> alphaColors;
|
||||||
std::vector<double> alphaValues;
|
std::vector<float> alphaValues;
|
||||||
std::vector<double> alphaLocations;
|
std::vector<float> alphaLocations;
|
||||||
|
|
||||||
std::vector<Color> gradientColors;
|
std::vector<Color> gradientColors;
|
||||||
std::vector<double> colorLocations;
|
std::vector<float> colorLocations;
|
||||||
|
|
||||||
for (int i = 0; i < numberOfColors; i++) {
|
for (int i = 0; i < numberOfColors; i++) {
|
||||||
int ix = i * 4;
|
int ix = i * 4;
|
||||||
@ -26,7 +26,7 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s
|
|||||||
|
|
||||||
bool drawMask = false;
|
bool drawMask = false;
|
||||||
for (int i = numberOfColors * 4; i < (int)colors.colors.size(); i += 2) {
|
for (int i = numberOfColors * 4; i < (int)colors.colors.size(); i += 2) {
|
||||||
double alpha = colors.colors[i + 1];
|
float alpha = colors.colors[i + 1];
|
||||||
if (alpha < 1.0) {
|
if (alpha < 1.0) {
|
||||||
drawMask = true;
|
drawMask = true;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (drawMask) {
|
if (drawMask) {
|
||||||
std::vector<double> locations;
|
std::vector<float> locations;
|
||||||
for (size_t i = 0; i < std::min(gradientColors.size(), colorLocations.size()); i++) {
|
for (size_t i = 0; i < std::min(gradientColors.size(), colorLocations.size()); i++) {
|
||||||
if (std::find(locations.begin(), locations.end(), colorLocations[i]) == locations.end()) {
|
if (std::find(locations.begin(), locations.end(), colorLocations[i]) == locations.end()) {
|
||||||
locations.push_back(colorLocations[i]);
|
locations.push_back(colorLocations[i]);
|
||||||
@ -62,7 +62,7 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s
|
|||||||
Color color = gradientColors[0];
|
Color color = gradientColors[0];
|
||||||
for (size_t i = 0; i < std::min(gradientColors.size(), colorLocations.size()) - 1; i++) {
|
for (size_t i = 0; i < std::min(gradientColors.size(), colorLocations.size()) - 1; i++) {
|
||||||
if (location >= colorLocations[i] && location <= colorLocations[i + 1]) {
|
if (location >= colorLocations[i] && location <= colorLocations[i + 1]) {
|
||||||
double localLocation = 0.0;
|
float localLocation = 0.0;
|
||||||
if (colorLocations[i] != colorLocations[i + 1]) {
|
if (colorLocations[i] != colorLocations[i + 1]) {
|
||||||
localLocation = remapFloat(location, colorLocations[i], colorLocations[i + 1], 0.0, 1.0);
|
localLocation = remapFloat(location, colorLocations[i], colorLocations[i + 1], 0.0, 1.0);
|
||||||
}
|
}
|
||||||
@ -71,14 +71,14 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double alpha = 1.0;
|
float alpha = 1.0;
|
||||||
for (size_t i = 0; i < std::min(alphaValues.size(), alphaLocations.size()) - 1; i++) {
|
for (size_t i = 0; i < std::min(alphaValues.size(), alphaLocations.size()) - 1; i++) {
|
||||||
if (location >= alphaLocations[i] && location <= alphaLocations[i + 1]) {
|
if (location >= alphaLocations[i] && location <= alphaLocations[i + 1]) {
|
||||||
double localLocation = 0.0;
|
float localLocation = 0.0;
|
||||||
if (alphaLocations[i] != alphaLocations[i + 1]) {
|
if (alphaLocations[i] != alphaLocations[i + 1]) {
|
||||||
localLocation = remapFloat(location, alphaLocations[i], alphaLocations[i + 1], 0.0, 1.0);
|
localLocation = remapFloat(location, alphaLocations[i], alphaLocations[i + 1], 0.0, 1.0);
|
||||||
}
|
}
|
||||||
alpha = ValueInterpolator<double>::interpolate(alphaValues[i], alphaValues[i + 1], localLocation, std::nullopt, std::nullopt);
|
alpha = ValueInterpolator<float>::interpolate(alphaValues[i], alphaValues[i + 1], localLocation, std::nullopt, std::nullopt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace lottie {
|
namespace lottie {
|
||||||
|
|
||||||
void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector<Color> &outColors, std::vector<double> &outLocations);
|
void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector<Color> &outColors, std::vector<float> &outLocations);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ public:
|
|||||||
std::optional<int> tgs_,
|
std::optional<int> tgs_,
|
||||||
AnimationFrameTime startFrame_,
|
AnimationFrameTime startFrame_,
|
||||||
AnimationFrameTime endFrame_,
|
AnimationFrameTime endFrame_,
|
||||||
double framerate_,
|
float framerate_,
|
||||||
std::string const &version_,
|
std::string const &version_,
|
||||||
std::optional<CoordinateSpace> type_,
|
std::optional<CoordinateSpace> type_,
|
||||||
int width_,
|
int width_,
|
||||||
@ -93,7 +93,7 @@ public:
|
|||||||
AnimationFrameTime startFrame = getDouble(json, "ip");
|
AnimationFrameTime startFrame = getDouble(json, "ip");
|
||||||
AnimationFrameTime endFrame = getDouble(json, "op");
|
AnimationFrameTime endFrame = getDouble(json, "op");
|
||||||
|
|
||||||
double framerate = getDouble(json, "fr");
|
float framerate = getDouble(json, "fr");
|
||||||
|
|
||||||
int width = getInt(json, "w");
|
int width = getInt(json, "w");
|
||||||
int height = getInt(json, "h");
|
int height = getInt(json, "h");
|
||||||
@ -256,7 +256,7 @@ public:
|
|||||||
AnimationFrameTime endFrame;
|
AnimationFrameTime endFrame;
|
||||||
|
|
||||||
/// The frame rate of the composition.
|
/// The frame rate of the composition.
|
||||||
double framerate;
|
float framerate;
|
||||||
|
|
||||||
/// Return all marker names, in order, or an empty list if none are specified
|
/// Return all marker names, in order, or an empty list if none are specified
|
||||||
std::vector<std::string> markerNames() {
|
std::vector<std::string> markerNames() {
|
||||||
|
|||||||
@ -18,8 +18,8 @@ public:
|
|||||||
std::string id_,
|
std::string id_,
|
||||||
std::string name_,
|
std::string name_,
|
||||||
std::string directory_,
|
std::string directory_,
|
||||||
double width_,
|
float width_,
|
||||||
double height_
|
float height_
|
||||||
) : Asset(id_),
|
) : Asset(id_),
|
||||||
name(name_),
|
name(name_),
|
||||||
directory(directory_),
|
directory(directory_),
|
||||||
@ -64,8 +64,8 @@ public:
|
|||||||
std::string directory;
|
std::string directory;
|
||||||
|
|
||||||
/// Image Size
|
/// Image Size
|
||||||
double width;
|
float width;
|
||||||
double height;
|
float height;
|
||||||
|
|
||||||
std::optional<int> _e;
|
std::optional<int> _e;
|
||||||
std::optional<std::string> _t;
|
std::optional<std::string> _t;
|
||||||
|
|||||||
@ -56,7 +56,7 @@ public:
|
|||||||
/// Layers of the precomp
|
/// Layers of the precomp
|
||||||
std::vector<std::shared_ptr<LayerModel>> layers;
|
std::vector<std::shared_ptr<LayerModel>> layers;
|
||||||
|
|
||||||
std::optional<double> frameRate;
|
std::optional<float> frameRate;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -255,7 +255,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double timeStretch() {
|
float timeStretch() {
|
||||||
if (_timeStretch.has_value()) {
|
if (_timeStretch.has_value()) {
|
||||||
return _timeStretch.value();
|
return _timeStretch.value();
|
||||||
} else {
|
} else {
|
||||||
@ -279,12 +279,12 @@ public:
|
|||||||
std::optional<CoordinateSpace> coordinateSpace;
|
std::optional<CoordinateSpace> coordinateSpace;
|
||||||
|
|
||||||
/// The in time of the layer in frames.
|
/// The in time of the layer in frames.
|
||||||
double inFrame;
|
float inFrame;
|
||||||
/// The out time of the layer in frames.
|
/// The out time of the layer in frames.
|
||||||
double outFrame;
|
float outFrame;
|
||||||
|
|
||||||
/// The start time of the layer in frames.
|
/// The start time of the layer in frames.
|
||||||
double startTime;
|
float startTime;
|
||||||
|
|
||||||
/// The transform of the layer
|
/// The transform of the layer
|
||||||
std::shared_ptr<Transform> transform;
|
std::shared_ptr<Transform> transform;
|
||||||
@ -299,7 +299,7 @@ public:
|
|||||||
std::optional<std::vector<std::shared_ptr<Mask>>> masks;
|
std::optional<std::vector<std::shared_ptr<Mask>>> masks;
|
||||||
|
|
||||||
/// A number that stretches time by a multiplier
|
/// A number that stretches time by a multiplier
|
||||||
std::optional<double> _timeStretch;
|
std::optional<float> _timeStretch;
|
||||||
|
|
||||||
/// The type of matte if any.
|
/// The type of matte if any.
|
||||||
std::optional<MatteType> matte;
|
std::optional<MatteType> matte;
|
||||||
|
|||||||
@ -46,10 +46,10 @@ public:
|
|||||||
std::optional<KeyframeGroup<Vector1D>> timeRemapping;
|
std::optional<KeyframeGroup<Vector1D>> timeRemapping;
|
||||||
|
|
||||||
/// Precomp Width
|
/// Precomp Width
|
||||||
double width;
|
float width;
|
||||||
|
|
||||||
/// Precomp Height
|
/// Precomp Height
|
||||||
double height;
|
float height;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,10 +31,10 @@ public:
|
|||||||
std::string colorHex;
|
std::string colorHex;
|
||||||
|
|
||||||
/// The Width of the color layer
|
/// The Width of the color layer
|
||||||
double width;
|
float width;
|
||||||
|
|
||||||
/// The height of the color layer
|
/// The height of the color layer
|
||||||
double height;
|
float height;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,33 +19,33 @@ public:
|
|||||||
lottiejson11::Json::object toJson() const {
|
lottiejson11::Json::object toJson() const {
|
||||||
lottiejson11::Json::object result;
|
lottiejson11::Json::object result;
|
||||||
|
|
||||||
result.insert(std::make_pair("o", (double)original));
|
result.insert(std::make_pair("o", (float)original));
|
||||||
if (type12.has_value()) {
|
if (type12.has_value()) {
|
||||||
result.insert(std::make_pair("f12", (double)type12.value()));
|
result.insert(std::make_pair("f12", (float)type12.value()));
|
||||||
}
|
}
|
||||||
if (type3.has_value()) {
|
if (type3.has_value()) {
|
||||||
result.insert(std::make_pair("f3", (double)type3.value()));
|
result.insert(std::make_pair("f3", (float)type3.value()));
|
||||||
}
|
}
|
||||||
if (type4.has_value()) {
|
if (type4.has_value()) {
|
||||||
result.insert(std::make_pair("f4", (double)type4.value()));
|
result.insert(std::make_pair("f4", (float)type4.value()));
|
||||||
}
|
}
|
||||||
if (type5.has_value()) {
|
if (type5.has_value()) {
|
||||||
result.insert(std::make_pair("f5", (double)type5.value()));
|
result.insert(std::make_pair("f5", (float)type5.value()));
|
||||||
}
|
}
|
||||||
if (type6.has_value()) {
|
if (type6.has_value()) {
|
||||||
result.insert(std::make_pair("f6", (double)type6.value()));
|
result.insert(std::make_pair("f6", (float)type6.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double original;
|
float original;
|
||||||
std::optional<double> type12;
|
std::optional<float> type12;
|
||||||
std::optional<double> type3;
|
std::optional<float> type3;
|
||||||
std::optional<double> type4;
|
std::optional<float> type4;
|
||||||
std::optional<double> type5;
|
std::optional<float> type5;
|
||||||
std::optional<double> type6;
|
std::optional<float> type6;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,7 +182,7 @@ public:
|
|||||||
LineJoin lineJoin;
|
LineJoin lineJoin;
|
||||||
|
|
||||||
/// Miter Limit
|
/// Miter Limit
|
||||||
std::optional<double> miterLimit;
|
std::optional<float> miterLimit;
|
||||||
|
|
||||||
/// The dash pattern of the stroke
|
/// The dash pattern of the stroke
|
||||||
std::optional<std::vector<DashElement>> dashPattern;
|
std::optional<std::vector<DashElement>> dashPattern;
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public:
|
|||||||
LineJoin lineJoin;
|
LineJoin lineJoin;
|
||||||
|
|
||||||
/// Miter Limit
|
/// Miter Limit
|
||||||
std::optional<double> miterLimit;
|
std::optional<float> miterLimit;
|
||||||
|
|
||||||
/// The dash pattern of the stroke
|
/// The dash pattern of the stroke
|
||||||
std::optional<std::vector<DashElement>> dashPattern;
|
std::optional<std::vector<DashElement>> dashPattern;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ public:
|
|||||||
std::string const &name_,
|
std::string const &name_,
|
||||||
std::string const &familyName_,
|
std::string const &familyName_,
|
||||||
std::string const &style_,
|
std::string const &style_,
|
||||||
double ascent_
|
float ascent_
|
||||||
) :
|
) :
|
||||||
name(name_),
|
name(name_),
|
||||||
familyName(familyName_),
|
familyName(familyName_),
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
std::optional<std::string> weight;
|
std::optional<std::string> weight;
|
||||||
std::optional<std::string> fontClass;
|
std::optional<std::string> fontClass;
|
||||||
std::string style;
|
std::string style;
|
||||||
double ascent;
|
float ascent;
|
||||||
std::optional<int> origin;
|
std::optional<int> origin;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -13,10 +13,10 @@ class Glyph {
|
|||||||
public:
|
public:
|
||||||
Glyph(
|
Glyph(
|
||||||
std::string const &character_,
|
std::string const &character_,
|
||||||
double fontSize_,
|
float fontSize_,
|
||||||
std::string const &fontFamily_,
|
std::string const &fontFamily_,
|
||||||
std::string const &fontStyle_,
|
std::string const &fontStyle_,
|
||||||
double width_,
|
float width_,
|
||||||
std::optional<std::vector<std::shared_ptr<ShapeItem>>> shapes_
|
std::optional<std::vector<std::shared_ptr<ShapeItem>>> shapes_
|
||||||
) :
|
) :
|
||||||
character(character_),
|
character(character_),
|
||||||
@ -86,7 +86,7 @@ public:
|
|||||||
std::string character;
|
std::string character;
|
||||||
|
|
||||||
/// The font size of the character
|
/// The font size of the character
|
||||||
double fontSize;
|
float fontSize;
|
||||||
|
|
||||||
/// The font family of the character
|
/// The font family of the character
|
||||||
std::string fontFamily;
|
std::string fontFamily;
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
std::string fontStyle;
|
std::string fontStyle;
|
||||||
|
|
||||||
/// The Width of the character
|
/// The Width of the character
|
||||||
double width;
|
float width;
|
||||||
|
|
||||||
/// The Shape Data of the Character
|
/// The Shape Data of the Character
|
||||||
std::optional<std::vector<std::shared_ptr<ShapeItem>>> shapes;
|
std::optional<std::vector<std::shared_ptr<ShapeItem>>> shapes;
|
||||||
|
|||||||
@ -20,15 +20,15 @@ class TextDocument {
|
|||||||
public:
|
public:
|
||||||
TextDocument(
|
TextDocument(
|
||||||
std::string const &text_,
|
std::string const &text_,
|
||||||
double fontSize_,
|
float fontSize_,
|
||||||
std::string const &fontFamily_,
|
std::string const &fontFamily_,
|
||||||
TextJustification justification_,
|
TextJustification justification_,
|
||||||
int tracking_,
|
int tracking_,
|
||||||
double lineHeight_,
|
float lineHeight_,
|
||||||
std::optional<double> baseline_,
|
std::optional<float> baseline_,
|
||||||
std::optional<Color> fillColorData_,
|
std::optional<Color> fillColorData_,
|
||||||
std::optional<Color> strokeColorData_,
|
std::optional<Color> strokeColorData_,
|
||||||
std::optional<double> strokeWidth_,
|
std::optional<float> strokeWidth_,
|
||||||
std::optional<bool> strokeOverFill_,
|
std::optional<bool> strokeOverFill_,
|
||||||
std::optional<Vector3D> textFramePosition_,
|
std::optional<Vector3D> textFramePosition_,
|
||||||
std::optional<Vector3D> textFrameSize_
|
std::optional<Vector3D> textFrameSize_
|
||||||
@ -145,7 +145,7 @@ public:
|
|||||||
std::string text;
|
std::string text;
|
||||||
|
|
||||||
/// The Font size
|
/// The Font size
|
||||||
double fontSize;
|
float fontSize;
|
||||||
|
|
||||||
/// The Font Family
|
/// The Font Family
|
||||||
std::string fontFamily;
|
std::string fontFamily;
|
||||||
@ -157,10 +157,10 @@ public:
|
|||||||
int tracking;
|
int tracking;
|
||||||
|
|
||||||
/// Line Height
|
/// Line Height
|
||||||
double lineHeight;
|
float lineHeight;
|
||||||
|
|
||||||
/// Baseline
|
/// Baseline
|
||||||
std::optional<double> baseline;
|
std::optional<float> baseline;
|
||||||
|
|
||||||
/// Fill Color data
|
/// Fill Color data
|
||||||
std::optional<Color> fillColorData;
|
std::optional<Color> fillColorData;
|
||||||
@ -169,7 +169,7 @@ public:
|
|||||||
std::optional<Color> strokeColorData;
|
std::optional<Color> strokeColorData;
|
||||||
|
|
||||||
/// Stroke Width
|
/// Stroke Width
|
||||||
std::optional<double> strokeWidth;
|
std::optional<float> strokeWidth;
|
||||||
|
|
||||||
/// Stroke Over Fill
|
/// Stroke Over Fill
|
||||||
std::optional<bool> strokeOverFill;
|
std::optional<bool> strokeOverFill;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ public:
|
|||||||
paths({ path }) {
|
paths({ path }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundBezierPath(std::vector<BezierPath> paths_, std::optional<double> length_) :
|
CompoundBezierPath(std::vector<BezierPath> paths_, std::optional<float> length_) :
|
||||||
paths(paths_), _length(length_) {
|
paths(paths_), _length(length_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,11 +28,11 @@ public:
|
|||||||
public:
|
public:
|
||||||
std::vector<BezierPath> paths;
|
std::vector<BezierPath> paths;
|
||||||
|
|
||||||
double length() {
|
float length() {
|
||||||
if (_length.has_value()) {
|
if (_length.has_value()) {
|
||||||
return _length.value();
|
return _length.value();
|
||||||
} else {
|
} else {
|
||||||
double l = 0.0;
|
float l = 0.0;
|
||||||
for (auto &path : paths) {
|
for (auto &path : paths) {
|
||||||
l += path.length();
|
l += path.length();
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::optional<double> _length;
|
std::optional<float> _length;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<CompoundBezierPath> addingPath(BezierPath const &path) const {
|
std::shared_ptr<CompoundBezierPath> addingPath(BezierPath const &path) const {
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
return std::make_shared<CompoundBezierPath>(newPaths);
|
return std::make_shared<CompoundBezierPath>(newPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CompoundBezierPath> trim(double fromPosition, double toPosition, double offset) {
|
std::shared_ptr<CompoundBezierPath> trim(float fromPosition, float toPosition, float offset) {
|
||||||
if (fromPosition == toPosition) {
|
if (fromPosition == toPosition) {
|
||||||
return std::make_shared<CompoundBezierPath>();
|
return std::make_shared<CompoundBezierPath>();
|
||||||
}
|
}
|
||||||
@ -82,11 +82,11 @@ public:
|
|||||||
return std::make_shared<CompoundBezierPath>(newPaths);
|
return std::make_shared<CompoundBezierPath>(newPaths);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
double lengthValue = length();
|
float lengthValue = length();
|
||||||
|
|
||||||
/// Normalize lengths to the curve length.
|
/// Normalize lengths to the curve length.
|
||||||
double startPosition = fmod(fromPosition + offset, 1.0);
|
float startPosition = fmod(fromPosition + offset, 1.0);
|
||||||
double endPosition = fmod(toPosition + offset, 1.0);
|
float endPosition = fmod(toPosition + offset, 1.0);
|
||||||
|
|
||||||
if (startPosition < 0.0) {
|
if (startPosition < 0.0) {
|
||||||
startPosition = 1.0 + startPosition;
|
startPosition = 1.0 + startPosition;
|
||||||
@ -123,7 +123,7 @@ public:
|
|||||||
auto compoundPath = std::make_shared<CompoundBezierPath>();
|
auto compoundPath = std::make_shared<CompoundBezierPath>();
|
||||||
auto trim = positions[0];
|
auto trim = positions[0];
|
||||||
positions.erase(positions.begin());
|
positions.erase(positions.begin());
|
||||||
double pathStartPosition = 0.0;
|
float pathStartPosition = 0.0;
|
||||||
|
|
||||||
bool finishedTrimming = false;
|
bool finishedTrimming = false;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace lottie {
|
|||||||
///
|
///
|
||||||
class AnimationFontProvider {
|
class AnimationFontProvider {
|
||||||
public:
|
public:
|
||||||
virtual std::shared_ptr<CTFont> fontFor(std::string const &family, double size) = 0;
|
virtual std::shared_ptr<CTFont> fontFor(std::string const &family, float size) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Default Font provider.
|
/// Default Font provider.
|
||||||
@ -22,7 +22,7 @@ public:
|
|||||||
|
|
||||||
virtual ~DefaultFontProvider() = default;
|
virtual ~DefaultFontProvider() = default;
|
||||||
|
|
||||||
virtual std::shared_ptr<CTFont> fontFor(std::string const &family, double size) override {
|
virtual std::shared_ptr<CTFont> fontFor(std::string const &family, float size) override {
|
||||||
//CTFontCreateWithName(family as CFString, size, nil)
|
//CTFontCreateWithName(family as CFString, size, nil)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T interpolate(Keyframe<T> const &to, double progress) {
|
T interpolate(Keyframe<T> const &to, float progress) {
|
||||||
std::optional<Vector2D> spatialOutTangent2d;
|
std::optional<Vector2D> spatialOutTangent2d;
|
||||||
if (spatialOutTangent) {
|
if (spatialOutTangent) {
|
||||||
spatialOutTangent2d = Vector2D(spatialOutTangent->x, spatialOutTangent->y);
|
spatialOutTangent2d = Vector2D(spatialOutTangent->x, spatialOutTangent->y);
|
||||||
@ -78,9 +78,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Interpolates the keyTime into a value from 0-1
|
/// Interpolates the keyTime into a value from 0-1
|
||||||
double interpolatedProgress(Keyframe<T> const &to, double keyTime) {
|
float interpolatedProgress(Keyframe<T> const &to, float keyTime) {
|
||||||
double startTime = time;
|
float startTime = time;
|
||||||
double endTime = to.time;
|
float endTime = to.time;
|
||||||
if (keyTime <= startTime) {
|
if (keyTime <= startTime) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ public:
|
|||||||
if (to.inTangent.has_value()) {
|
if (to.inTangent.has_value()) {
|
||||||
inTanPoint = to.inTangent.value();
|
inTanPoint = to.inTangent.value();
|
||||||
}
|
}
|
||||||
double progress = remapFloat(keyTime, startTime, endTime, 0.0f, 1.0f);
|
float progress = remapFloat(keyTime, startTime, endTime, 0.0f, 1.0f);
|
||||||
if (!outTanPoint.isZero() || inTanPoint != Vector2D(1.0f, 1.0f)) {
|
if (!outTanPoint.isZero() || inTanPoint != Vector2D(1.0f, 1.0f)) {
|
||||||
/// Cubic interpolation
|
/// Cubic interpolation
|
||||||
progress = cubicBezierInterpolate(progress, Vector2D::Zero(), outTanPoint, inTanPoint, Vector2D(1.0, 1.0));
|
progress = cubicBezierInterpolate(progress, Vector2D::Zero(), outTanPoint, inTanPoint, Vector2D(1.0, 1.0));
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace lottie {
|
namespace lottie {
|
||||||
|
|
||||||
void batchInterpolate(std::vector<PathElement> const &from, std::vector<PathElement> const &to, BezierPath &resultPath, double amount) {
|
void batchInterpolate(std::vector<PathElement> const &from, std::vector<PathElement> const &to, BezierPath &resultPath, float amount) {
|
||||||
int elementCount = (int)from.size();
|
int elementCount = (int)from.size();
|
||||||
if (elementCount > (int)to.size()) {
|
if (elementCount > (int)to.size()) {
|
||||||
elementCount = (int)to.size();
|
elementCount = (int)to.size();
|
||||||
|
|||||||
@ -18,9 +18,9 @@ struct ValueInterpolator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<double> {
|
struct ValueInterpolator<float> {
|
||||||
public:
|
public:
|
||||||
static double interpolate(double value, double to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static float interpolate(float value, float to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
return value + ((to - value) * amount);
|
return value + ((to - value) * amount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -28,22 +28,22 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<Vector1D> {
|
struct ValueInterpolator<Vector1D> {
|
||||||
public:
|
public:
|
||||||
static Vector1D interpolate(Vector1D const &value, Vector1D const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static Vector1D interpolate(Vector1D const &value, Vector1D const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
return Vector1D(ValueInterpolator<double>::interpolate(value.value, to.value, amount, spatialOutTangent, spatialInTangent));
|
return Vector1D(ValueInterpolator<float>::interpolate(value.value, to.value, amount, spatialOutTangent, spatialInTangent));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<Vector2D> {
|
struct ValueInterpolator<Vector2D> {
|
||||||
public:
|
public:
|
||||||
static Vector2D interpolate(Vector2D const &value, Vector2D const &to, double amount, Vector2D spatialOutTangent, Vector2D spatialInTangent) {
|
static Vector2D interpolate(Vector2D const &value, Vector2D const &to, float amount, Vector2D spatialOutTangent, Vector2D spatialInTangent) {
|
||||||
auto cp1 = value + spatialOutTangent;
|
auto cp1 = value + spatialOutTangent;
|
||||||
auto cp2 = to + spatialInTangent;
|
auto cp2 = to + spatialInTangent;
|
||||||
|
|
||||||
return value.interpolate(to, cp1, cp2, amount);
|
return value.interpolate(to, cp1, cp2, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector2D interpolate(Vector2D const &value, Vector2D const &to, double amount) {
|
static Vector2D interpolate(Vector2D const &value, Vector2D const &to, float amount) {
|
||||||
return value.interpolate(to, amount);
|
return value.interpolate(to, amount);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -51,7 +51,7 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<Vector3D> {
|
struct ValueInterpolator<Vector3D> {
|
||||||
public:
|
public:
|
||||||
static Vector3D interpolate(Vector3D const &value, Vector3D const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static Vector3D interpolate(Vector3D const &value, Vector3D const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
if (spatialOutTangent && spatialInTangent) {
|
if (spatialOutTangent && spatialInTangent) {
|
||||||
Vector2D from2d(value.x, value.y);
|
Vector2D from2d(value.x, value.y);
|
||||||
Vector2D to2d(to.x, to.y);
|
Vector2D to2d(to.x, to.y);
|
||||||
@ -64,14 +64,14 @@ public:
|
|||||||
return Vector3D(
|
return Vector3D(
|
||||||
result2d.x,
|
result2d.x,
|
||||||
result2d.y,
|
result2d.y,
|
||||||
ValueInterpolator<double>::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent)
|
ValueInterpolator<float>::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Vector3D(
|
return Vector3D(
|
||||||
ValueInterpolator<double>::interpolate(value.x, to.x, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<float>::interpolate(value.x, to.x, amount, spatialOutTangent, spatialInTangent),
|
||||||
ValueInterpolator<double>::interpolate(value.y, to.y, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<float>::interpolate(value.y, to.y, amount, spatialOutTangent, spatialInTangent),
|
||||||
ValueInterpolator<double>::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent)
|
ValueInterpolator<float>::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -79,22 +79,22 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<Color> {
|
struct ValueInterpolator<Color> {
|
||||||
public:
|
public:
|
||||||
static Color interpolate(Color const &value, Color const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static Color interpolate(Color const &value, Color const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
return Color(
|
return Color(
|
||||||
ValueInterpolator<double>::interpolate(value.r, to.r, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<float>::interpolate(value.r, to.r, amount, spatialOutTangent, spatialInTangent),
|
||||||
ValueInterpolator<double>::interpolate(value.g, to.g, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<float>::interpolate(value.g, to.g, amount, spatialOutTangent, spatialInTangent),
|
||||||
ValueInterpolator<double>::interpolate(value.b, to.b, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<float>::interpolate(value.b, to.b, amount, spatialOutTangent, spatialInTangent),
|
||||||
ValueInterpolator<double>::interpolate(value.a, to.a, amount, spatialOutTangent, spatialInTangent)
|
ValueInterpolator<float>::interpolate(value.a, to.a, amount, spatialOutTangent, spatialInTangent)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void batchInterpolate(std::vector<PathElement> const &from, std::vector<PathElement> const &to, BezierPath &resultPath, double amount);
|
void batchInterpolate(std::vector<PathElement> const &from, std::vector<PathElement> const &to, BezierPath &resultPath, float amount);
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<CurveVertex> {
|
struct ValueInterpolator<CurveVertex> {
|
||||||
public:
|
public:
|
||||||
static CurveVertex interpolate(CurveVertex const &value, CurveVertex const &to, double amount, Vector2D spatialOutTangent, Vector2D spatialInTangent) {
|
static CurveVertex interpolate(CurveVertex const &value, CurveVertex const &to, float amount, Vector2D spatialOutTangent, Vector2D spatialInTangent) {
|
||||||
return CurveVertex::absolute(
|
return CurveVertex::absolute(
|
||||||
ValueInterpolator<Vector2D>::interpolate(value.point, to.point, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<Vector2D>::interpolate(value.point, to.point, amount, spatialOutTangent, spatialInTangent),
|
||||||
ValueInterpolator<Vector2D>::interpolate(value.inTangent, to.inTangent, amount, spatialOutTangent, spatialInTangent),
|
ValueInterpolator<Vector2D>::interpolate(value.inTangent, to.inTangent, amount, spatialOutTangent, spatialInTangent),
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static CurveVertex interpolate(CurveVertex const &value, CurveVertex const &to, double amount) {
|
static CurveVertex interpolate(CurveVertex const &value, CurveVertex const &to, float amount) {
|
||||||
return CurveVertex::absolute(
|
return CurveVertex::absolute(
|
||||||
ValueInterpolator<Vector2D>::interpolate(value.point, to.point, amount),
|
ValueInterpolator<Vector2D>::interpolate(value.point, to.point, amount),
|
||||||
ValueInterpolator<Vector2D>::interpolate(value.inTangent, to.inTangent, amount),
|
ValueInterpolator<Vector2D>::interpolate(value.inTangent, to.inTangent, amount),
|
||||||
@ -114,7 +114,7 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<BezierPath> {
|
struct ValueInterpolator<BezierPath> {
|
||||||
public:
|
public:
|
||||||
static BezierPath interpolate(BezierPath const &value, BezierPath const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static BezierPath interpolate(BezierPath const &value, BezierPath const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
BezierPath newPath;
|
BezierPath newPath;
|
||||||
newPath.reserveCapacity(std::max(value.elements().size(), to.elements().size()));
|
newPath.reserveCapacity(std::max(value.elements().size(), to.elements().size()));
|
||||||
//TODO:probably a bug in the upstream code, uncomment
|
//TODO:probably a bug in the upstream code, uncomment
|
||||||
@ -150,7 +150,7 @@ public:
|
|||||||
memcpy(resultPath.mutableElements().data(), value.elements().data(), value.elements().size() * sizeof(PathElement));
|
memcpy(resultPath.mutableElements().data(), value.elements().data(), value.elements().size() * sizeof(PathElement));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void interpolateInplace(BezierPath const &value, BezierPath const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent, BezierPath &resultPath) {
|
static void interpolateInplace(BezierPath const &value, BezierPath const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent, BezierPath &resultPath) {
|
||||||
/*if (value.elements().size() != to.elements().size()) {
|
/*if (value.elements().size() != to.elements().size()) {
|
||||||
return to;
|
return to;
|
||||||
}*/
|
}*/
|
||||||
@ -185,7 +185,7 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<TextDocument> {
|
struct ValueInterpolator<TextDocument> {
|
||||||
public:
|
public:
|
||||||
static TextDocument interpolate(TextDocument const &value, TextDocument const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static TextDocument interpolate(TextDocument const &value, TextDocument const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
if (amount == 1.0) {
|
if (amount == 1.0) {
|
||||||
return to;
|
return to;
|
||||||
} else {
|
} else {
|
||||||
@ -197,12 +197,12 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<GradientColorSet> {
|
struct ValueInterpolator<GradientColorSet> {
|
||||||
public:
|
public:
|
||||||
static GradientColorSet interpolate(GradientColorSet const &value, GradientColorSet const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static GradientColorSet interpolate(GradientColorSet const &value, GradientColorSet const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
assert(value.colors.size() == to.colors.size());
|
assert(value.colors.size() == to.colors.size());
|
||||||
std::vector<double> colors;
|
std::vector<float> colors;
|
||||||
size_t colorCount = std::min(value.colors.size(), to.colors.size());
|
size_t colorCount = std::min(value.colors.size(), to.colors.size());
|
||||||
for (size_t i = 0; i < colorCount; i++) {
|
for (size_t i = 0; i < colorCount; i++) {
|
||||||
colors.push_back(ValueInterpolator<double>::interpolate(value.colors[i], to.colors[i], amount, spatialOutTangent, spatialInTangent));
|
colors.push_back(ValueInterpolator<float>::interpolate(value.colors[i], to.colors[i], amount, spatialOutTangent, spatialInTangent));
|
||||||
}
|
}
|
||||||
return GradientColorSet(colors);
|
return GradientColorSet(colors);
|
||||||
}
|
}
|
||||||
@ -211,12 +211,12 @@ public:
|
|||||||
template<>
|
template<>
|
||||||
struct ValueInterpolator<DashPattern> {
|
struct ValueInterpolator<DashPattern> {
|
||||||
public:
|
public:
|
||||||
static DashPattern interpolate(DashPattern const &value, DashPattern const &to, double amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
static DashPattern interpolate(DashPattern const &value, DashPattern const &to, float amount, std::optional<Vector2D> spatialOutTangent, std::optional<Vector2D> spatialInTangent) {
|
||||||
assert(value.values.size() == to.values.size());
|
assert(value.values.size() == to.values.size());
|
||||||
std::vector<double> values;
|
std::vector<float> values;
|
||||||
size_t colorCount = std::min(value.values.size(), to.values.size());
|
size_t colorCount = std::min(value.values.size(), to.values.size());
|
||||||
for (size_t i = 0; i < colorCount; i++) {
|
for (size_t i = 0; i < colorCount; i++) {
|
||||||
values.push_back(ValueInterpolator<double>::interpolate(value.values[i], to.values[i], amount, spatialOutTangent, spatialInTangent));
|
values.push_back(ValueInterpolator<float>::interpolate(value.values[i], to.values[i], amount, spatialOutTangent, spatialInTangent));
|
||||||
}
|
}
|
||||||
return DashPattern(std::move(values));
|
return DashPattern(std::move(values));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,10 @@
|
|||||||
namespace lottie {
|
namespace lottie {
|
||||||
|
|
||||||
/// Defines animation time in Frames (Seconds * Framerate).
|
/// Defines animation time in Frames (Seconds * Framerate).
|
||||||
typedef double AnimationFrameTime;
|
typedef float AnimationFrameTime;
|
||||||
|
|
||||||
/// Defines animation time by a progress from 0 (beginning of the animation) to 1 (end of the animation)
|
/// Defines animation time by a progress from 0 (beginning of the animation) to 1 (end of the animation)
|
||||||
typedef double AnimationProgressTime;
|
typedef float AnimationProgressTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace lottie {
|
|||||||
class AnyValue {
|
class AnyValue {
|
||||||
public:
|
public:
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Double,
|
Float,
|
||||||
Vector1D,
|
Vector1D,
|
||||||
Vector2D,
|
Vector2D,
|
||||||
Vector3D,
|
Vector3D,
|
||||||
@ -28,9 +28,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnyValue(double value) :
|
AnyValue(float value) :
|
||||||
_type(Type::Double),
|
_type(Type::Float),
|
||||||
_doubleValue(value) {
|
_floatValue(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnyValue(Vector1D const &value) :
|
AnyValue(Vector1D const &value) :
|
||||||
@ -73,9 +73,9 @@ public:
|
|||||||
_dashPatternValue(value) {
|
_dashPatternValue(value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename = std::enable_if_t<std::is_same<T, double>::value>>
|
template<typename T, typename = std::enable_if_t<std::is_same<T, float>::value>>
|
||||||
double get() {
|
float get() {
|
||||||
return asDouble();
|
return asFloat();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename = std::enable_if_t<std::is_same<T, Vector1D>::value>>
|
template<typename T, typename = std::enable_if_t<std::is_same<T, Vector1D>::value>>
|
||||||
@ -123,8 +123,8 @@ public:
|
|||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
double asDouble() {
|
float asFloat() {
|
||||||
return _doubleValue.value();
|
return _floatValue.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector1D asVector1D() {
|
Vector1D asVector1D() {
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Type _type;
|
Type _type;
|
||||||
|
|
||||||
std::optional<double> _doubleValue;
|
std::optional<float> _floatValue;
|
||||||
std::optional<Vector1D> _vector1DValue;
|
std::optional<Vector1D> _vector1DValue;
|
||||||
std::optional<Vector2D> _vector2DValue;
|
std::optional<Vector2D> _vector2DValue;
|
||||||
std::optional<Vector3D> _vector3DValue;
|
std::optional<Vector3D> _vector3DValue;
|
||||||
@ -178,9 +178,9 @@ struct AnyValueType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct AnyValueType<double> {
|
struct AnyValueType<float> {
|
||||||
static AnyValue::Type type() {
|
static AnyValue::Type type() {
|
||||||
return AnyValue::Type::Double;
|
return AnyValue::Type::Float;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -186,10 +186,10 @@ public:
|
|||||||
_path = path;
|
_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lineWidth() const {
|
float lineWidth() const {
|
||||||
return _lineWidth;
|
return _lineWidth;
|
||||||
}
|
}
|
||||||
void setLineWidth(double lineWidth) {
|
void setLineWidth(float lineWidth) {
|
||||||
_lineWidth = lineWidth;
|
_lineWidth = lineWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,17 +207,17 @@ public:
|
|||||||
_lineCap = lineCap;
|
_lineCap = lineCap;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lineDashPhase() const {
|
float lineDashPhase() const {
|
||||||
return _lineDashPhase;
|
return _lineDashPhase;
|
||||||
}
|
}
|
||||||
void setLineDashPhase(double lineDashPhase) {
|
void setLineDashPhase(float lineDashPhase) {
|
||||||
_lineDashPhase = lineDashPhase;
|
_lineDashPhase = lineDashPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> const &dashPattern() const {
|
std::vector<float> const &dashPattern() const {
|
||||||
return _dashPattern;
|
return _dashPattern;
|
||||||
}
|
}
|
||||||
void setDashPattern(std::vector<double> const &dashPattern) {
|
void setDashPattern(std::vector<float> const &dashPattern) {
|
||||||
_dashPattern = dashPattern;
|
_dashPattern = dashPattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,11 +243,11 @@ private:
|
|||||||
std::optional<Color> _fillColor = Color(0.0, 0.0, 0.0, 1.0);
|
std::optional<Color> _fillColor = Color(0.0, 0.0, 0.0, 1.0);
|
||||||
FillRule _fillRule = FillRule::NonZeroWinding;
|
FillRule _fillRule = FillRule::NonZeroWinding;
|
||||||
std::shared_ptr<CGPath> _path;
|
std::shared_ptr<CGPath> _path;
|
||||||
double _lineWidth = 1.0;
|
float _lineWidth = 1.0;
|
||||||
LineJoin _lineJoin = LineJoin::Miter;
|
LineJoin _lineJoin = LineJoin::Miter;
|
||||||
LineCap _lineCap = LineCap::Butt;
|
LineCap _lineCap = LineCap::Butt;
|
||||||
double _lineDashPhase = 0.0;
|
float _lineDashPhase = 0.0;
|
||||||
std::vector<double> _dashPattern;
|
std::vector<float> _dashPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,11 @@
|
|||||||
namespace lottie {
|
namespace lottie {
|
||||||
|
|
||||||
struct DashPattern {
|
struct DashPattern {
|
||||||
DashPattern(std::vector<double> &&values_) :
|
DashPattern(std::vector<float> &&values_) :
|
||||||
values(std::move(values_)) {
|
values(std::move(values_)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> values;
|
std::vector<float> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@ struct GradientColorSet {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> colors;
|
std::vector<float> colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -468,7 +468,7 @@ private final class RenderFrameState {
|
|||||||
restoreState()
|
restoreState()
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderNode(animationContainer: LottieAnimationContainer, node: LottieRenderNodeProxy, globalSize: CGSize, parentAlpha: CGFloat) {
|
func renderNode(animationContainer: LottieAnimationContainer, node: LottieRenderNodeProxy, globalSize: CGSize, parentAlpha: Float) {
|
||||||
let normalizedOpacity = node.layer.opacity
|
let normalizedOpacity = node.layer.opacity
|
||||||
let layerAlpha = normalizedOpacity * parentAlpha
|
let layerAlpha = normalizedOpacity * parentAlpha
|
||||||
|
|
||||||
@ -534,7 +534,7 @@ private final class RenderFrameState {
|
|||||||
concat(node.layer.transform)
|
concat(node.layer.transform)
|
||||||
}
|
}
|
||||||
|
|
||||||
var renderAlpha: CGFloat = 1.0
|
var renderAlpha: Float = 1.0
|
||||||
if needsTempContext {
|
if needsTempContext {
|
||||||
renderAlpha = 1.0
|
renderAlpha = 1.0
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user