diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/Canvas.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/Canvas.h index 28b5e69fb9..88eaf678fb 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/Canvas.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/Canvas.h @@ -9,63 +9,6 @@ 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 { public: virtual ~Image() = default; @@ -73,23 +16,29 @@ public: class Gradient { public: - Gradient(std::vector const &colors, std::vector const &locations) : + Gradient(std::vector const &colors, std::vector const &locations) : _colors(colors), _locations(locations) { assert(_colors.size() == _locations.size()); } - std::vector const &colors() const { + std::vector const &colors() const { return _colors; } - std::vector const &locations() const { + std::vector const &locations() const { return _locations; } private: - std::vector _colors; - std::vector _locations; + std::vector _colors; + std::vector _locations; +}; + +enum class BlendMode { + Normal, + DestinationIn, + DestinationOut }; class Canvas { @@ -104,18 +53,18 @@ public: virtual void saveState() = 0; virtual void restoreState() = 0; - virtual void fillPath(std::shared_ptr const &path, FillRule fillRule, Color const &color) = 0; - virtual void linearGradientFillPath(std::shared_ptr const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0; - virtual void radialGradientFillPath(std::shared_ptr const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) = 0; + virtual void fillPath(std::shared_ptr const &path, lottie::FillRule fillRule, lottie::Color const &color) = 0; + virtual void linearGradientFillPath(std::shared_ptr const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0; + virtual void radialGradientFillPath(std::shared_ptr 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 const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Color const &color) = 0; - virtual void linearGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0; - virtual void radialGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) = 0; + virtual void strokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) = 0; + virtual void linearGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) = 0; + virtual void radialGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector 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 setAlpha(double alpha) = 0; + virtual void setAlpha(float alpha) = 0; virtual void concatenate(lottie::CATransform3D const &transform) = 0; diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h index fc572306cd..dbc9ad5814 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.h @@ -29,17 +29,17 @@ public: virtual void saveState() override; virtual void restoreState() override; - virtual void fillPath(std::shared_ptr const &path, FillRule fillRule, Color const &color) override; - virtual void linearGradientFillPath(std::shared_ptr const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientFillPath(std::shared_ptr const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override; + virtual void fillPath(std::shared_ptr const &path, lottie::FillRule fillRule, lottie::Color const &color) override; + virtual void linearGradientFillPath(std::shared_ptr const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; + virtual void radialGradientFillPath(std::shared_ptr 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 const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Color const &color) override; - virtual void linearGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override; + virtual void strokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) override; + virtual void linearGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; + virtual void radialGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector 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 setAlpha(double alpha) override; + virtual void setAlpha(float alpha) override; virtual void concatenate(lottie::CATransform3D const &transform) override; virtual std::shared_ptr makeImage() const; diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm index 5a915888c6..2eb352c5c9 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/CoreGraphicsCanvasImpl.mm @@ -1,7 +1,5 @@ #include "CoreGraphicsCanvasImpl.h" - - namespace lottieRendering { namespace { @@ -89,7 +87,7 @@ void CanvasImpl::restoreState() { CGContextRestoreGState(_context); } -void CanvasImpl::fillPath(std::shared_ptr const &path, FillRule fillRule, Color const &color) { +void CanvasImpl::fillPath(std::shared_ptr const &path, lottie::FillRule fillRule, lottie::Color const &color) { CGContextBeginPath(_context); lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) { CGContextAddPath(context, nativePath); @@ -101,7 +99,7 @@ void CanvasImpl::fillPath(std::shared_ptr const &path, FillRule CFRelease(nativeColor); switch (fillRule) { - case FillRule::EvenOdd: { + case lottie::FillRule::EvenOdd: { CGContextEOFillPath(_context); break; } @@ -112,7 +110,7 @@ void CanvasImpl::fillPath(std::shared_ptr const &path, FillRule } } -void CanvasImpl::linearGradientFillPath(std::shared_ptr const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { +void CanvasImpl::linearGradientFillPath(std::shared_ptr const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { CGContextSaveGState(_context); CGContextBeginPath(_context); lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) { @@ -120,7 +118,7 @@ void CanvasImpl::linearGradientFillPath(std::shared_ptr const &p }); switch (fillRule) { - case FillRule::EvenOdd: { + case lottie::FillRule::EvenOdd: { CGContextEOClip(_context); break; } @@ -142,7 +140,12 @@ void CanvasImpl::linearGradientFillPath(std::shared_ptr const &p assert(gradient.colors().size() == gradient.locations().size()); - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size()); + std::vector locations; + for (const auto location : gradient.locations()) { + locations.push_back(location); + } + + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); if (nativeGradient) { CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); @@ -152,7 +155,7 @@ void CanvasImpl::linearGradientFillPath(std::shared_ptr const &p CGContextRestoreGState(_context); } -void CanvasImpl::radialGradientFillPath(std::shared_ptr 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 const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { CGContextSaveGState(_context); CGContextBeginPath(_context); lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) { @@ -160,7 +163,7 @@ void CanvasImpl::radialGradientFillPath(std::shared_ptr const &p }); switch (fillRule) { - case FillRule::EvenOdd: { + case lottie::FillRule::EvenOdd: { CGContextEOClip(_context); break; } @@ -182,7 +185,12 @@ void CanvasImpl::radialGradientFillPath(std::shared_ptr const &p assert(gradient.colors().size() == gradient.locations().size()); - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size()); + std::vector locations; + for (const auto location : gradient.locations()) { + locations.push_back(location); + } + + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); if (nativeGradient) { CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); @@ -192,7 +200,7 @@ void CanvasImpl::radialGradientFillPath(std::shared_ptr const &p CGContextRestoreGState(_context); } -void CanvasImpl::strokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Color const &color) { +void CanvasImpl::strokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) { CGContextBeginPath(_context); lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) { CGContextAddPath(context, nativePath); @@ -206,15 +214,15 @@ void CanvasImpl::strokePath(std::shared_ptr const &path, double CGContextSetLineWidth(_context, lineWidth); switch (lineJoin) { - case LineJoin::Miter: { + case lottie::LineJoin::Miter: { CGContextSetLineJoin(_context, kCGLineJoinMiter); break; } - case LineJoin::Round: { + case lottie::LineJoin::Round: { CGContextSetLineJoin(_context, kCGLineJoinRound); break; } - case LineJoin::Bevel: { + case lottie::LineJoin::Bevel: { CGContextSetLineJoin(_context, kCGLineJoinBevel); break; } @@ -225,15 +233,15 @@ void CanvasImpl::strokePath(std::shared_ptr const &path, double } switch (lineCap) { - case LineCap::Butt: { + case lottie::LineCap::Butt: { CGContextSetLineCap(_context, kCGLineCapButt); break; } - case LineCap::Round: { + case lottie::LineCap::Round: { CGContextSetLineCap(_context, kCGLineCapRound); break; } - case LineCap::Square: { + case lottie::LineCap::Square: { CGContextSetLineCap(_context, kCGLineCapSquare); break; } @@ -244,12 +252,16 @@ void CanvasImpl::strokePath(std::shared_ptr const &path, double } if (!dashPattern.empty()) { - CGContextSetLineDash(_context, dashPhase, dashPattern.data(), dashPattern.size()); + std::vector mappedDashPattern; + for (const auto value : dashPattern) { + mappedDashPattern.push_back(value); + } + CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); } CGContextStrokePath(_context); } -void CanvasImpl::linearGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { +void CanvasImpl::linearGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { CGContextSaveGState(_context); CGContextBeginPath(_context); lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) { @@ -259,15 +271,15 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr const CGContextSetLineWidth(_context, lineWidth); switch (lineJoin) { - case LineJoin::Miter: { + case lottie::LineJoin::Miter: { CGContextSetLineJoin(_context, kCGLineJoinMiter); break; } - case LineJoin::Round: { + case lottie::LineJoin::Round: { CGContextSetLineJoin(_context, kCGLineJoinRound); break; } - case LineJoin::Bevel: { + case lottie::LineJoin::Bevel: { CGContextSetLineJoin(_context, kCGLineJoinBevel); break; } @@ -278,15 +290,15 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr const } switch (lineCap) { - case LineCap::Butt: { + case lottie::LineCap::Butt: { CGContextSetLineCap(_context, kCGLineCapButt); break; } - case LineCap::Round: { + case lottie::LineCap::Round: { CGContextSetLineCap(_context, kCGLineCapRound); break; } - case LineCap::Square: { + case lottie::LineCap::Square: { CGContextSetLineCap(_context, kCGLineCapSquare); break; } @@ -297,7 +309,11 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr const } if (!dashPattern.empty()) { - CGContextSetLineDash(_context, dashPhase, dashPattern.data(), dashPattern.size()); + std::vector mappedDashPattern; + for (const auto value : dashPattern) { + mappedDashPattern.push_back(value); + } + CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); } CGContextReplacePathWithStrokedPath(_context); @@ -315,7 +331,12 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr const assert(gradient.colors().size() == gradient.locations().size()); - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size()); + std::vector locations; + for (const auto location : gradient.locations()) { + locations.push_back(location); + } + + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); if (nativeGradient) { CGContextDrawLinearGradient(_context, nativeGradient, CGPointMake(start.x, start.y), CGPointMake(end.x, end.y), kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); @@ -325,7 +346,7 @@ void CanvasImpl::linearGradientStrokePath(std::shared_ptr const CGContextRestoreGState(_context); } -void CanvasImpl::radialGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) { +void CanvasImpl::radialGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { CGContextSaveGState(_context); CGContextBeginPath(_context); lottie::CGPathCocoaImpl::withNativePath(path, [context = _context](CGPathRef nativePath) { @@ -335,15 +356,15 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr const CGContextSetLineWidth(_context, lineWidth); switch (lineJoin) { - case LineJoin::Miter: { + case lottie::LineJoin::Miter: { CGContextSetLineJoin(_context, kCGLineJoinMiter); break; } - case LineJoin::Round: { + case lottie::LineJoin::Round: { CGContextSetLineJoin(_context, kCGLineJoinRound); break; } - case LineJoin::Bevel: { + case lottie::LineJoin::Bevel: { CGContextSetLineJoin(_context, kCGLineJoinBevel); break; } @@ -354,15 +375,15 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr const } switch (lineCap) { - case LineCap::Butt: { + case lottie::LineCap::Butt: { CGContextSetLineCap(_context, kCGLineCapButt); break; } - case LineCap::Round: { + case lottie::LineCap::Round: { CGContextSetLineCap(_context, kCGLineCapRound); break; } - case LineCap::Square: { + case lottie::LineCap::Square: { CGContextSetLineCap(_context, kCGLineCapSquare); break; } @@ -373,7 +394,11 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr const } if (!dashPattern.empty()) { - CGContextSetLineDash(_context, dashPhase, dashPattern.data(), dashPattern.size()); + std::vector mappedDashPattern; + for (const auto value : dashPattern) { + mappedDashPattern.push_back(value); + } + CGContextSetLineDash(_context, dashPhase, mappedDashPattern.data(), mappedDashPattern.size()); } CGContextReplacePathWithStrokedPath(_context); @@ -391,7 +416,12 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr const assert(gradient.colors().size() == gradient.locations().size()); - CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), gradient.locations().data(), gradient.locations().size()); + std::vector locations; + for (const auto location : gradient.locations()) { + locations.push_back(location); + } + + CGGradientRef nativeGradient = CGGradientCreateWithColorComponents(CGBitmapContextGetColorSpace(_topContext), components.data(), locations.data(), locations.size()); if (nativeGradient) { CGContextDrawRadialGradient(_context, nativeGradient, CGPointMake(startCenter.x, startCenter.y), startRadius, CGPointMake(endCenter.x, endCenter.y), endRadius, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation); CFRelease(nativeGradient); @@ -401,7 +431,7 @@ void CanvasImpl::radialGradientStrokePath(std::shared_ptr const 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 }; CGColorRef nativeColor = CGColorCreate(CGBitmapContextGetColorSpace(_topContext), components); CGContextSetFillColorWithColor(_context, nativeColor); @@ -429,7 +459,7 @@ void CanvasImpl::setBlendMode(BlendMode blendMode) { CGContextSetBlendMode(_context, nativeMode); } -void CanvasImpl::setAlpha(double alpha) { +void CanvasImpl::setAlpha(float alpha) { CGContextSetAlpha(_context, alpha); } diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm index 367c31e5e2..3a843f08cf 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/SoftwareLottieRenderer.mm @@ -411,18 +411,18 @@ static void drawLottieContentItem(std::shared_ptr paren lottie::RenderTreeNodeContentItem::SolidShading *solidShading = (lottie::RenderTreeNodeContentItem::SolidShading *)shading->stroke->shading.get(); if (solidShading->opacity != 0.0) { - lottieRendering::LineJoin lineJoin = lottieRendering::LineJoin::Bevel; + lottie::LineJoin lineJoin = lottie::LineJoin::Bevel; switch (shading->stroke->lineJoin) { case lottie::LineJoin::Bevel: { - lineJoin = lottieRendering::LineJoin::Bevel; + lineJoin = lottie::LineJoin::Bevel; break; } case lottie::LineJoin::Round: { - lineJoin = lottieRendering::LineJoin::Round; + lineJoin = lottie::LineJoin::Round; break; } case lottie::LineJoin::Miter: { - lineJoin = lottieRendering::LineJoin::Miter; + lineJoin = lottie::LineJoin::Miter; break; } default: { @@ -430,18 +430,18 @@ static void drawLottieContentItem(std::shared_ptr paren } } - lottieRendering::LineCap lineCap = lottieRendering::LineCap::Square; + lottie::LineCap lineCap = lottie::LineCap::Square; switch (shading->stroke->lineCap) { case lottie::LineCap::Butt: { - lineCap = lottieRendering::LineCap::Butt; + lineCap = lottie::LineCap::Butt; break; } case lottie::LineCap::Round: { - lineCap = lottieRendering::LineCap::Round; + lineCap = lottie::LineCap::Round; break; } case lottie::LineCap::Square: { - lineCap = lottieRendering::LineCap::Square; + lineCap = lottie::LineCap::Square; break; } default: { @@ -449,25 +449,25 @@ static void drawLottieContentItem(std::shared_ptr paren } } - std::vector dashPattern; + std::vector dashPattern; if (!shading->stroke->dashPattern.empty()) { 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) { //TODO:gradient stroke } } } else if (shading->fill) { - lottieRendering::FillRule rule = lottieRendering::FillRule::NonZeroWinding; + lottie::FillRule rule = lottie::FillRule::NonZeroWinding; switch (shading->fill->rule) { case lottie::FillRule::EvenOdd: { - rule = lottieRendering::FillRule::EvenOdd; + rule = lottie::FillRule::EvenOdd; break; } case lottie::FillRule::NonZeroWinding: { - rule = lottieRendering::FillRule::NonZeroWinding; + rule = lottie::FillRule::NonZeroWinding; break; } default: { @@ -478,16 +478,16 @@ static void drawLottieContentItem(std::shared_ptr paren if (shading->fill->shading->type() == lottie::RenderTreeNodeContentItem::ShadingType::Solid) { lottie::RenderTreeNodeContentItem::SolidShading *solidShading = (lottie::RenderTreeNodeContentItem::SolidShading *)shading->fill->shading.get(); 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) { lottie::RenderTreeNodeContentItem::GradientShading *gradientShading = (lottie::RenderTreeNodeContentItem::GradientShading *)shading->fill->shading.get(); if (gradientShading->opacity != 0.0) { - std::vector colors; - std::vector locations; + std::vector colors; + std::vector locations; 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; @@ -562,7 +562,7 @@ static void renderLottieRenderNode(std::shared_ptr node, maskBackingStorage->concatenate(node->renderData.globalTransform); 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) { renderLottieRenderNode(node->mask(), maskBackingStorage, globalSize, 1.0); @@ -599,7 +599,7 @@ static void renderLottieRenderNode(std::shared_ptr node, } 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); } diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h index 6166b708a0..5c5bcba396 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.h @@ -20,17 +20,17 @@ public: virtual void saveState() override; virtual void restoreState() override; - virtual void fillPath(std::shared_ptr const &path, FillRule fillRule, Color const &color) override; - virtual void linearGradientFillPath(std::shared_ptr const &path, FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientFillPath(std::shared_ptr const &path, FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override; - virtual void strokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Color const &color) override; - virtual void linearGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; - virtual void radialGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) override; - virtual void fill(lottie::CGRect const &rect, Color const &fillColor) override; + virtual void fillPath(std::shared_ptr const &path, lottie::FillRule fillRule, lottie::Color const &color) override; + virtual void linearGradientFillPath(std::shared_ptr const &path, lottie::FillRule fillRule, lottieRendering::Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; + virtual void radialGradientFillPath(std::shared_ptr 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 const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) override; + virtual void linearGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) override; + virtual void radialGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector 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, lottie::Color const &fillColor) 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; @@ -51,8 +51,7 @@ private: int _height = 0; std::unique_ptr _canvas; - //SkBlendMode _blendMode = SkBlendMode::kSrcOver; - double _alpha = 1.0; + float _alpha = 1.0; lottie::CATransform3D _transform; std::vector _stateStack; int _bytesPerRow = 0; diff --git a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.mm b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.mm index 0c81b5c8a7..f2d642f1c7 100644 --- a/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.mm +++ b/Tests/LottieMetalTest/SoftwareLottieRenderer/Sources/ThorVGCanvasImpl.mm @@ -89,19 +89,19 @@ void ThorVGCanvasImpl::restoreState() { _stateStack.pop_back(); } -void ThorVGCanvasImpl::fillPath(std::shared_ptr const &path, FillRule fillRule, Color const &color) { +void ThorVGCanvasImpl::fillPath(std::shared_ptr const &path, lottie::FillRule fillRule, lottie::Color const &color) { auto shape = tvg::Shape::gen(); tvgPath(path, shape.get()); 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(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)); } -void ThorVGCanvasImpl::linearGradientFillPath(std::shared_ptr const &path, FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { +void ThorVGCanvasImpl::linearGradientFillPath(std::shared_ptr const &path, lottie::FillRule fillRule, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { auto shape = tvg::Shape::gen(); tvgPath(path, shape.get()); @@ -124,12 +124,12 @@ void ThorVGCanvasImpl::linearGradientFillPath(std::shared_ptr co fill->colorStops(colors.data(), (uint32_t)colors.size()); 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)); } -void ThorVGCanvasImpl::radialGradientFillPath(std::shared_ptr 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 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(); tvgPath(path, shape.get()); @@ -152,12 +152,12 @@ void ThorVGCanvasImpl::radialGradientFillPath(std::shared_ptr co fill->colorStops(colors.data(), (uint32_t)colors.size()); 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)); } -void ThorVGCanvasImpl::strokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Color const &color) { +void ThorVGCanvasImpl::strokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, lottie::Color const &color) { auto shape = tvg::Shape::gen(); tvgPath(path, shape.get()); @@ -167,15 +167,15 @@ void ThorVGCanvasImpl::strokePath(std::shared_ptr const &path, d shape->strokeWidth(lineWidth); switch (lineJoin) { - case LineJoin::Miter: { + case lottie::LineJoin::Miter: { shape->strokeJoin(tvg::StrokeJoin::Miter); break; } - case LineJoin::Round: { + case lottie::LineJoin::Round: { shape->strokeJoin(tvg::StrokeJoin::Round); break; } - case LineJoin::Bevel: { + case lottie::LineJoin::Bevel: { shape->strokeJoin(tvg::StrokeJoin::Bevel); break; } @@ -186,15 +186,15 @@ void ThorVGCanvasImpl::strokePath(std::shared_ptr const &path, d } switch (lineCap) { - case LineCap::Butt: { + case lottie::LineCap::Butt: { shape->strokeCap(tvg::StrokeCap::Butt); break; } - case LineCap::Round: { + case lottie::LineCap::Round: { shape->strokeCap(tvg::StrokeCap::Round); break; } - case LineCap::Square: { + case lottie::LineCap::Square: { shape->strokeCap(tvg::StrokeCap::Square); break; } @@ -217,15 +217,15 @@ void ThorVGCanvasImpl::strokePath(std::shared_ptr const &path, d _canvas->push(std::move(shape)); } -void ThorVGCanvasImpl::linearGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { +void ThorVGCanvasImpl::linearGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &start, lottie::Vector2D const &end) { assert(false); } -void ThorVGCanvasImpl::radialGradientStrokePath(std::shared_ptr const &path, double lineWidth, LineJoin lineJoin, LineCap lineCap, double dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, double startRadius, lottie::Vector2D const &endCenter, double endRadius) { +void ThorVGCanvasImpl::radialGradientStrokePath(std::shared_ptr const &path, float lineWidth, lottie::LineJoin lineJoin, lottie::LineCap lineCap, float dashPhase, std::vector const &dashPattern, Gradient const &gradient, lottie::Vector2D const &startCenter, float startRadius, lottie::Vector2D const &endCenter, float endRadius) { 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(); 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; } diff --git a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/CurveVertex.h b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/CurveVertex.h index 58f5ba3ae0..5b15a6eeab 100644 --- a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/CurveVertex.h +++ b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/CurveVertex.h @@ -91,7 +91,7 @@ public: /// TI and TO are the new tangents for the trimPoint /// NO and NI are the new tangents for the startPoint and endPoints /// S==NO=========TI==T==TO=======NI==E - CurveVertexSplitResult splitCurve(CurveVertex const &toVertex, double position) const { + CurveVertexSplitResult splitCurve(CurveVertex const &toVertex, float position) const { /// If position is less than or equal to 0, trim at start. if (position <= 0.0) { return CurveVertexSplitResult( @@ -147,8 +147,8 @@ public: /// /// This function should probably live in PathElement, since it deals with curve /// lengths. - CurveVertexSplitResult trimCurve(CurveVertex const &toVertex, double atLength, double curveLength, int maxSamples, double accuracy = 1.0) const { - double currentPosition = atLength / curveLength; + CurveVertexSplitResult trimCurve(CurveVertex const &toVertex, float atLength, float curveLength, int maxSamples, float accuracy = 1.0f) const { + float currentPosition = atLength / curveLength; auto results = splitCurve(toVertex, currentPosition); if (maxSamples == 0) { @@ -162,7 +162,7 @@ public: if (lengthDiff < accuracy) { 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; results = splitCurve(toVertex, currentPosition); } @@ -174,17 +174,17 @@ public: /// 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. /// 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()) { /// Return a linear distance. return point.distanceTo(toVertex.point); } - double distance = 0.0; + float distance = 0.0; auto previousPoint = point; 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); previousPoint = pointOnCurve.point; } diff --git a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/LottieAnimationContainer.h b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/LottieAnimationContainer.h index f92e613cee..f4e936e77d 100644 --- a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/LottieAnimationContainer.h +++ b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/LottieAnimationContainer.h @@ -25,7 +25,7 @@ typedef struct { CGRect bounds; CGPoint position; CATransform3D transform; - double opacity; + float opacity; bool masksToBounds; bool isHidden; } LottieRenderNodeLayerData; diff --git a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/PathElement.h b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/PathElement.h index 766fb21435..bb8a8f578d 100644 --- a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/PathElement.h +++ b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/PathElement.h @@ -41,7 +41,7 @@ struct __attribute__((packed)) PathElement { } /// Initializes a new path with length - explicit PathElement(std::optional length_, CurveVertex const &vertex_) : + explicit PathElement(std::optional length_, CurveVertex const &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 - PathSplitResult splitElementAtPosition(PathElement const &fromElement, double atLength) { + PathSplitResult splitElementAtPosition(PathElement const &fromElement, float atLength) { /// 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); @@ -81,8 +81,8 @@ struct __attribute__((packed)) PathElement { ); } - double length(PathElement const &previous) { - double result = previous.vertex.distanceTo(vertex); + float length(PathElement const &previous) { + float result = previous.vertex.distanceTo(vertex); return result; } }; diff --git a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/RenderTreeNode.h b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/RenderTreeNode.h index 2e5a8f2155..a19f2a9d10 100644 --- a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/RenderTreeNode.h +++ b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/RenderTreeNode.h @@ -19,7 +19,7 @@ public: CGRect _bounds; Vector2D _position; CATransform3D _transform; - double _opacity; + float _opacity; bool _masksToBounds; bool _isHidden; @@ -27,7 +27,7 @@ public: CGRect bounds_, Vector2D position_, CATransform3D transform_, - double opacity_, + float opacity_, bool masksToBounds_, bool isHidden_ ) : @@ -51,7 +51,7 @@ public: return _transform; } - double opacity() const { + float opacity() const { return _opacity; } @@ -135,19 +135,19 @@ public: struct Stroke { Color color; - double lineWidth = 0.0; + float lineWidth = 0.0; LineJoin lineJoin = LineJoin::Round; LineCap lineCap = LineCap::Square; - double dashPhase = 0.0; - std::vector dashPattern; + float dashPhase = 0.0; + std::vector dashPattern; Stroke( Color color_, - double lineWidth_, + float lineWidth_, LineJoin lineJoin_, LineCap lineCap_, - double dashPhase_, - std::vector dashPattern_ + float dashPhase_, + std::vector dashPattern_ ) : color(color_), lineWidth(lineWidth_), @@ -245,7 +245,7 @@ public: FillRule pathFillRule_, GradientType gradientType_, std::vector const &colors_, - std::vector const &locations_, + std::vector const &locations_, Vector2D const &start_, Vector2D const &end_, CGRect bounds_ @@ -301,7 +301,7 @@ public: FillRule pathFillRule; GradientType gradientType; std::vector colors; - std::vector locations; + std::vector locations; Vector2D start; Vector2D end; CGRect bounds; @@ -328,7 +328,7 @@ public: class SolidShading: public Shading { public: - SolidShading(Color const &color_, double opacity_) : + SolidShading(Color const &color_, float opacity_) : color(color_), opacity(opacity_) { } @@ -339,16 +339,16 @@ public: public: Color color; - double opacity = 0.0; + float opacity = 0.0; }; class GradientShading: public Shading { public: GradientShading( - double opacity_, + float opacity_, GradientType gradientType_, std::vector const &colors_, - std::vector const &locations_, + std::vector const &locations_, Vector2D const &start_, Vector2D const &end_ ) : @@ -365,31 +365,31 @@ public: } public: - double opacity = 0.0; + float opacity = 0.0; GradientType gradientType; std::vector colors; - std::vector locations; + std::vector locations; Vector2D start; Vector2D end; }; struct Stroke { std::shared_ptr shading; - double lineWidth = 0.0; + float lineWidth = 0.0; LineJoin lineJoin = LineJoin::Round; LineCap lineCap = LineCap::Square; - double miterLimit = 4.0; - double dashPhase = 0.0; - std::vector dashPattern; + float miterLimit = 4.0; + float dashPhase = 0.0; + std::vector dashPattern; Stroke( std::shared_ptr shading_, - double lineWidth_, + float lineWidth_, LineJoin lineJoin_, LineCap lineCap_, - double miterLimit_, - double dashPhase_, - std::vector dashPattern_ + float miterLimit_, + float dashPhase_, + std::vector dashPattern_ ) : shading(shading_), lineWidth(lineWidth_), @@ -421,7 +421,7 @@ public: public: bool isGroup = false; CATransform3D transform = CATransform3D::identity(); - double alpha = 0.0; + float alpha = 0.0; std::optional trimParams; std::optional path; CGRect pathBoundingBox = CGRect(0.0, 0.0, 0.0, 0.0); @@ -450,7 +450,7 @@ public: CGRect bounds_, Vector2D position_, CATransform3D transform_, - double alpha_, + float alpha_, bool masksToBounds_, bool isHidden_, std::vector> subnodes_, @@ -484,7 +484,7 @@ public: return _transform; } - double alpha() const { + float alpha() const { return _alpha; } @@ -512,7 +512,7 @@ public: CGRect _bounds; Vector2D _position; CATransform3D _transform = CATransform3D::identity(); - double _alpha = 1.0; + float _alpha = 1.0f; bool _masksToBounds = false; bool _isHidden = false; std::shared_ptr _contentItem; diff --git a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/ShapeAttributes.h b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/ShapeAttributes.h index c6f11afa4c..c3c6f9d809 100644 --- a/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/ShapeAttributes.h +++ b/submodules/TelegramUI/Components/LottieCpp/PublicHeaders/LottieCpp/ShapeAttributes.h @@ -37,12 +37,12 @@ enum class TrimType: int { }; struct TrimParams { - double start = 0.0; - double end = 0.0; - double offset = 0.0; + float start = 0.0; + float end = 0.0; + float offset = 0.0; TrimType type = TrimType::Simultaneously; - TrimParams(double start_, double end_, double offset_, TrimType type_) : + TrimParams(float start_, float end_, float offset_, TrimType type_) : start(start_), end(end_), offset(offset_), diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.hpp index 1d795079fe..13e275dfdd 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/CompositionLayer.hpp @@ -82,7 +82,7 @@ public: return _contentsLayer; } - void displayWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) { + void displayWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) { bool layerVisible = isInRangeOrEqual(frame, _inFrame, _outFrame); if (_transformNode->updateTree(frame, forceUpdates) || _contentsLayer->isHidden() != !layerVisible) { @@ -105,7 +105,7 @@ public: 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 } @@ -143,16 +143,16 @@ public: return _matteType; } - double inFrame() const { + float inFrame() const { return _inFrame; } - double outFrame() const { + float outFrame() const { return _outFrame; } - double startFrame() const { + float startFrame() const { return _startFrame; } - double timeStretch() const { + float timeStretch() const { return _timeStretch; } @@ -174,10 +174,10 @@ private: std::shared_ptr _maskLayer; - double _inFrame = 0.0; - double _outFrame = 0.0; - double _startFrame = 0.0; - double _timeStretch = 0.0; + float _inFrame = 0.0; + float _outFrame = 0.0; + float _startFrame = 0.0; + float _timeStretch = 0.0; // MARK: Keypath Searchable diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.hpp index 9c4e46f41b..95bdb3f093 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/MaskContainerLayer.hpp @@ -106,7 +106,7 @@ public: virtual ~MaskLayer() = default; - void updateWithFrame(double frame, bool forceUpdates) { + void updateWithFrame(float frame, bool forceUpdates) { if (_properties.opacity()->needsUpdate(frame) || forceUpdates) { _properties.opacity()->update(frame); setOpacity(_properties.opacity()->value().value); @@ -163,7 +163,7 @@ public: // MARK: Internal - void updateWithFrame(double frame, bool forceUpdates) { + void updateWithFrame(float frame, bool forceUpdates) { for (const auto &maskLayer : _maskLayers) { maskLayer->updateWithFrame(frame, forceUpdates); } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.hpp index adacde6a4b..4d3a51db1b 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/PreCompositionLayer.hpp @@ -23,7 +23,7 @@ public: std::shared_ptr const &textProvider, std::shared_ptr const &fontProvider, std::shared_ptr const &assetLibrary, - double frameRate + float frameRate ) : CompositionLayer(precomp, Vector2D(precomp->width, precomp->height)) { if (precomp->timeRemapping) { _remappingNode = std::make_shared>(std::make_shared>(precomp->timeRemapping->keyframes)); @@ -86,8 +86,8 @@ public: return result; } - virtual void displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override { - double localFrame = 0.0; + virtual void displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override { + float localFrame = 0.0; if (_remappingNode) { _remappingNode->update(frame); localFrame = _remappingNode->value().value * _frameRate; @@ -195,7 +195,7 @@ public: } private: - double _frameRate = 0.0; + float _frameRate = 0.0; std::shared_ptr> _remappingNode; std::vector> _animationLayers; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp index 8a7759e4b0..1c63b5b6c5 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.cpp @@ -74,7 +74,7 @@ public: Color colorValue = Color(0.0, 0.0, 0.0, 0.0); KeyframeInterpolator opacity; - double opacityValue = 0.0; + float opacityValue = 0.0; std::shared_ptr _fill; }; @@ -93,7 +93,7 @@ public: 0.0, gradientType, std::vector(), - std::vector(), + std::vector(), Vector2D(0.0, 0.0), Vector2D(0.0, 0.0) ); @@ -130,7 +130,7 @@ public: if (hasUpdates) { std::vector colors; - std::vector locations; + std::vector locations; getGradientParameters(numberOfColors, colorsValue, colors, locations); RenderTreeNodeContentItem::GradientShading *gradient = ((RenderTreeNodeContentItem::GradientShading *)_fill->shading.get()); @@ -161,7 +161,7 @@ public: Vector3D endPointValue = Vector3D(0.0, 0.0, 0.0); KeyframeInterpolator opacity; - double opacityValue = 0.0; + float opacityValue = 0.0; std::shared_ptr _fill; }; @@ -202,7 +202,7 @@ public: lineCap, miterLimit, 0.0, - std::vector() + std::vector() ); } @@ -257,7 +257,7 @@ public: _stroke->lineWidth = widthValue; _stroke->dashPhase = hasNonZeroDashes ? dashPhaseValue : 0.0; - _stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector(); + _stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector(); } } @@ -268,22 +268,22 @@ public: private: LineJoin lineJoin; LineCap lineCap; - double miterLimit = 4.0; + float miterLimit = 4.0; KeyframeInterpolator color; Color colorValue = Color(0.0, 0.0, 0.0, 0.0); KeyframeInterpolator opacity; - double opacityValue = 0.0; + float opacityValue = 0.0; KeyframeInterpolator width; - double widthValue = 0.0; + float widthValue = 0.0; std::unique_ptr dashPattern; DashPattern dashPatternValue = DashPattern({}); std::unique_ptr> dashPhase; - double dashPhaseValue = 0.0; + float dashPhaseValue = 0.0; std::shared_ptr _stroke; }; @@ -314,7 +314,7 @@ public: 0.0, gradientType, std::vector(), - std::vector(), + std::vector(), Vector2D(0.0, 0.0), Vector2D(0.0, 0.0) ); @@ -325,7 +325,7 @@ public: lineCap, miterLimit, 0.0, - std::vector() + std::vector() ); } @@ -385,7 +385,7 @@ public: } std::vector colors; - std::vector locations; + std::vector locations; getGradientParameters(numberOfColors, colorsValue, colors, locations); RenderTreeNodeContentItem::GradientShading *gradient = ((RenderTreeNodeContentItem::GradientShading *)_stroke->shading.get()); @@ -397,7 +397,7 @@ public: _stroke->lineWidth = widthValue; _stroke->dashPhase = hasNonZeroDashes ? dashPhaseValue : 0.0; - _stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector(); + _stroke->dashPattern = hasNonZeroDashes ? dashPatternValue.values : std::vector(); } } @@ -408,7 +408,7 @@ public: private: LineJoin lineJoin; LineCap lineCap; - double miterLimit = 4.0; + float miterLimit = 4.0; int numberOfColors = 0; GradientType gradientType; @@ -423,16 +423,16 @@ public: Vector3D endPointValue = Vector3D(0.0, 0.0, 0.0); KeyframeInterpolator opacity; - double opacityValue = 0.0; + float opacityValue = 0.0; KeyframeInterpolator width; - double widthValue = 0.0; + float widthValue = 0.0; std::unique_ptr dashPattern; DashPattern dashPatternValue = DashPattern({}); std::unique_ptr> dashPhase; - double dashPhaseValue = 0.0; + float dashPhaseValue = 0.0; std::shared_ptr _stroke; }; @@ -461,12 +461,12 @@ public: } TrimParams trimParams() { - double resolvedStartValue = startValue * 0.01; - double resolvedEndValue = endValue * 0.01; - double resolvedStart = std::min(resolvedStartValue, resolvedEndValue); - double resolvedEnd = std::max(resolvedStartValue, resolvedEndValue); + float resolvedStartValue = startValue * 0.01; + float resolvedEndValue = endValue * 0.01; + float resolvedStart = std::min(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); } @@ -475,13 +475,13 @@ public: TrimType type; KeyframeInterpolator start; - double startValue = 0.0; + float startValue = 0.0; KeyframeInterpolator end; - double endValue = 0.0; + float endValue = 0.0; KeyframeInterpolator offset; - double offsetValue = 0.0; + float offsetValue = 0.0; }; struct ShadingVariant { @@ -624,7 +624,7 @@ public: Vector3D sizeValue = Vector3D(0.0, 0.0, 0.0); KeyframeInterpolator cornerRadius; - double cornerRadiusValue = 0.0; + float cornerRadiusValue = 0.0; BezierPath resolvedPath; 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); KeyframeInterpolator outerRadius; - double outerRadiusValue = 0.0; + float outerRadiusValue = 0.0; KeyframeInterpolator outerRoundedness; - double outerRoundednessValue = 0.0; + float outerRoundednessValue = 0.0; std::unique_ptr> innerRadius; - double innerRadiusValue = 0.0; + float innerRadiusValue = 0.0; std::unique_ptr> innerRoundedness; - double innerRoundednessValue = 0.0; + float innerRoundednessValue = 0.0; KeyframeInterpolator rotation; - double rotationValue = 0.0; + float rotationValue = 0.0; KeyframeInterpolator points; - double pointsValue = 0.0; + float pointsValue = 0.0; BezierPath resolvedPath; CGRect resolvedPathBounds = CGRect(0.0, 0.0, 0.0, 0.0); @@ -861,17 +861,17 @@ public: scaleValue = _scale->value(frameTime); } - double rotationValue = 0.0; + float rotationValue = 0.0; if (_rotation) { rotationValue = _rotation->value(frameTime).value; } - double skewValue = 0.0; + float skewValue = 0.0; if (_skew) { skewValue = _skew->value(frameTime).value; } - double skewAxisValue = 0.0; + float skewAxisValue = 0.0; if (_skewAxis) { skewAxisValue = _skewAxis->value(frameTime).value; } @@ -892,7 +892,7 @@ public: return _transformValue; } - double opacity() { + float opacity() { return _opacityValue; } @@ -908,7 +908,7 @@ public: std::unique_ptr> _opacity; CATransform3D _transformValue = CATransform3D::identity(); - double _opacityValue = 1.0; + float _opacityValue = 1.0; }; class ContentItem { @@ -1089,7 +1089,7 @@ public: void updateContents(std::optional parentTrim) { CATransform3D containerTransform = CATransform3D::identity(); - double containerOpacity = 1.0; + float containerOpacity = 1.0; if (transform) { containerTransform = transform->transform(); containerOpacity = transform->opacity(); @@ -1333,7 +1333,7 @@ CompositionLayer(solidLayer, Vector2D::Zero()) { _contentTree = std::make_shared(solidLayer); } -void ShapeCompositionLayer::displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) { +void ShapeCompositionLayer::displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) { _frameTime = frame; _frameTimeInitialized = true; _contentTree->itemTree->updateFrame(_frameTime, boundingBoxContext); diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.hpp index 2be2f974f2..8aff5c77a6 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/ShapeCompositionLayer.hpp @@ -16,7 +16,7 @@ public: ShapeCompositionLayer(std::shared_ptr const &shapeLayer); ShapeCompositionLayer(std::shared_ptr 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(BezierPathsBoundingBoxContext &boundingBoxContext) override; void initializeContentsLayerParameters(); virtual void updateContentsLayerParameters() override; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.hpp index 9d7e916705..98d7edbbc2 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/CompLayers/TextCompositionLayer.hpp @@ -42,7 +42,7 @@ public: _fontProvider = fontProvider; } - virtual void displayContentsWithFrame(double frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override { + virtual void displayContentsWithFrame(float frame, bool forceUpdates, BezierPathsBoundingBoxContext &boundingBoxContext) override { if (!_textDocument) { return; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.hpp index 7f95758791..5a8467e0b0 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/MainThreadAnimationLayer.hpp @@ -98,7 +98,7 @@ public: } void display() { - double newFrame = currentFrame(); + float newFrame = currentFrame(); if (_respectAnimationFrameRate) { newFrame = floor(newFrame); } @@ -140,7 +140,7 @@ public: }*/ } - std::optional getValue(AnimationKeypath const &keypath, std::optional atFrame) { + std::optional getValue(AnimationKeypath const &keypath, std::optional atFrame) { /*for (const auto &layer : _animationLayers) { assert(false); if @@ -153,7 +153,7 @@ public: return std::nullopt; } - std::optional getOriginalValue(AnimationKeypath const &keypath, std::optional atFrame) { + std::optional getOriginalValue(AnimationKeypath const &keypath, std::optional atFrame) { /*for (const auto &layer : _animationLayers) { assert(false); if @@ -186,10 +186,10 @@ public: return results; } - double currentFrame() const { + float currentFrame() const { return _currentFrame; } - void setCurrentFrame(double currentFrame) { + void setCurrentFrame(float currentFrame) { _currentFrame = currentFrame; for (size_t i = 0; i < _animationLayers.size(); i++) { @@ -256,7 +256,7 @@ private: // MARK: Internal /// The animatable Current Frame Property - double _currentFrame = 0.0; + float _currentFrame = 0.0; std::shared_ptr _imageProvider; std::shared_ptr _textProvider; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.cpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.cpp index 1685790650..8a98548bd3 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.cpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.cpp @@ -14,7 +14,7 @@ std::vector> initializeCompositionLayers( std::shared_ptr const &layerImageProvider, std::shared_ptr const &textProvider, std::shared_ptr const &fontProvider, - double frameRate + float frameRate ) { std::vector> compositionLayers; std::map> layerMap; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.hpp index 247d8d5631..74df3529d3 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/CompositionLayersInitializer.hpp @@ -15,7 +15,7 @@ std::vector> initializeCompositionLayers( std::shared_ptr const &layerImageProvider, std::shared_ptr const &textProvider, std::shared_ptr const &fontProvider, - double frameRate + float frameRate ); } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.hpp index de22024145..d064a16782 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/LayerContainers/Utility/LayerTransformNode.hpp @@ -136,11 +136,11 @@ public: return _transformProperties; } - virtual bool shouldRebuildOutputs(double frame) override { + virtual bool shouldRebuildOutputs(float frame) override { return hasLocalUpdates() || hasUpstreamUpdates(); } - virtual void rebuildOutputs(double frame) override { + virtual void rebuildOutputs(float frame) override { _opacity = ((float)_transformProperties->opacity()->value().value) * 0.01f; Vector2D position(0.0, 0.0); diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.hpp index 1a6f995c1f..f77cdc470b 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/NodeProperty.hpp @@ -27,7 +27,7 @@ public: return _typedContainer.outputValue(); } - virtual bool needsUpdate(double frame) const override { + virtual bool needsUpdate(float frame) const override { return _typedContainer.needsUpdate() || _valueProvider->hasUpdate(frame); } @@ -39,7 +39,7 @@ public: _typedContainer.setNeedsUpdate();*/ } - virtual void update(double frame) override { + virtual void update(float frame) override { _typedContainer.setValue(_valueProvider->value(frame), frame); } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.hpp index f317e68b9f..ec682ceb93 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyNodeProperty.hpp @@ -16,10 +16,10 @@ public: public: /// 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 - virtual void update(double frame) = 0; + virtual void update(float frame) = 0; /// The Type of the value provider virtual AnyValue::Type valueType() const = 0; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.hpp index 55e6dac2e2..1776bd13bc 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/AnyValueContainer.hpp @@ -17,7 +17,7 @@ public: virtual bool needsUpdate() const = 0; /// The frame time of the last provided update - virtual double lastUpdateFrame() const = 0; + virtual float lastUpdateFrame() const = 0; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/HasRenderUpdates.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/HasRenderUpdates.hpp index cf30fec769..bc6a13261e 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/HasRenderUpdates.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/HasRenderUpdates.hpp @@ -5,7 +5,7 @@ namespace lottie { class HasRenderUpdates { public: - virtual bool hasRenderUpdates(double forFrame) = 0; + virtual bool hasRenderUpdates(float forFrame) = 0; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.hpp index 64eff898f4..0879d00c82 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/Protocols/NodePropertyMap.hpp @@ -13,7 +13,7 @@ class NodePropertyMap: virtual public HasChildKeypaths { public: virtual std::vector> &properties() = 0; - bool needsLocalUpdate(double frame) { + bool needsLocalUpdate(float frame) { for (auto &property : properties()) { if (property->needsUpdate(frame)) { return true; @@ -22,7 +22,7 @@ public: return false; } - void updateNodeProperties(double frame) { + void updateNodeProperties(float frame) { for (auto &property : properties()) { property->update(frame); } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.hpp index 54f1548b14..563de16de5 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueContainer.hpp @@ -15,7 +15,7 @@ public: } public: - double _lastUpdateFrame = std::numeric_limits::infinity(); + float _lastUpdateFrame = std::numeric_limits::infinity(); bool _needsUpdate = true; virtual AnyValue value() const override { @@ -26,7 +26,7 @@ public: return _needsUpdate; } - virtual double lastUpdateFrame() const override { + virtual float lastUpdateFrame() const override { return _lastUpdateFrame; } @@ -40,7 +40,7 @@ public: _needsUpdate = false; } - void setValue(AnyValue value, double forFrame) { + void setValue(AnyValue value, float forFrame) { if (value.type() == AnyValueType::type()) { _needsUpdate = false; _lastUpdateFrame = forFrame; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/DashPatternInterpolator.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/DashPatternInterpolator.hpp index 2200c4c113..5e744386dd 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/DashPatternInterpolator.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/DashPatternInterpolator.hpp @@ -23,14 +23,14 @@ public: } virtual DashPattern value(AnimationFrameTime frame) override { - std::vector values; + std::vector values; for (const auto &interpolator : _keyframeInterpolators) { values.push_back(interpolator->value(frame).value); } return DashPattern(std::move(values)); } - virtual bool hasUpdate(double frame) const override { + virtual bool hasUpdate(float frame) const override { for (const auto &interpolator : _keyframeInterpolators) { if (interpolator->hasUpdate(frame)) { return true; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.hpp index 4ea16e331a..de35d4887a 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/KeyframeInterpolator.hpp @@ -62,7 +62,7 @@ public: /// - If time is outside of the span, and there are more keyframes /// - If a value delegate is set /// - 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()) { return true; } @@ -94,7 +94,7 @@ public: // MARK: Fileprivate - std::optional lastUpdatedFrame; + std::optional lastUpdatedFrame; std::optional leadingIndex; std::optional trailingIndex; @@ -102,7 +102,7 @@ public: std::optional> trailingKeyframe; /// Finds the appropriate Leading and Trailing keyframe index for the given time. - void updateSpanIndices(double frame) { + void updateSpanIndices(float frame) { if (keyframes.empty()) { leadingIndex = std::nullopt; trailingIndex = std::nullopt; @@ -270,7 +270,7 @@ public: /// - If time is outside of the span, and there are more keyframes /// - If a value delegate is set /// - If leading and trailing are both nil. - bool hasUpdate(double frame) const { + bool hasUpdate(float frame) const { if (!lastUpdatedFrame.has_value()) { return true; } @@ -302,7 +302,7 @@ public: // MARK: Fileprivate - std::optional lastUpdatedFrame; + std::optional lastUpdatedFrame; std::optional leadingIndex; std::optional trailingIndex; @@ -310,7 +310,7 @@ public: std::optional> trailingKeyframe; /// Finds the appropriate Leading and Trailing keyframe index for the given time. - void updateSpanIndices(double frame) { + void updateSpanIndices(float frame) { if (keyframes.empty()) { leadingIndex = std::nullopt; trailingIndex = std::nullopt; @@ -434,7 +434,7 @@ private: ValueInterpolator::setInplace(from.value, outPath); } - void interpolateInplace(Keyframe const &from, Keyframe const &to, double progress, BezierPath &outPath) { + void interpolateInplace(Keyframe const &from, Keyframe const &to, float progress, BezierPath &outPath) { std::optional spatialOutTangent2d; if (from.spatialOutTangent) { spatialOutTangent2d = Vector2D(from.spatialOutTangent->x, from.spatialOutTangent->y); diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.hpp index dc1212ba28..b6c3fe6a1f 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/NodeProperties/ValueProviders/SingleValueProvider.hpp @@ -28,7 +28,7 @@ public: return AnyValueType::type(); } - virtual bool hasUpdate(double frame) const override { + virtual bool hasUpdate(float frame) const override { return _hasUpdate; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.hpp index c1d2db8959..f7b73a550d 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/OutputNodes/PassThroughOutputNode.hpp @@ -40,7 +40,7 @@ public: return nullptr; } - virtual bool hasOutputUpdates(double forFrame) override { + virtual bool hasOutputUpdates(float forFrame) override { /// Changes to this node do not affect downstream nodes. bool parentUpdate = false; if (_parent) { @@ -51,7 +51,7 @@ public: 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 bool upstreamUpdates = false; if (_parent) { diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.hpp index 6acdb2ee20..d5f6e2556a 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Nodes/Text/TextAnimatorNode.hpp @@ -112,16 +112,16 @@ public: scale = Vector2D(scale3d.x, scale3d.y); } - double rotation = 0.0; + float rotation = 0.0; if (_rotation) { rotation = _rotation->value().value; } - std::optional skew; + std::optional skew; if (_skew) { skew = _skew->value().value; } - std::optional skewAxis; + std::optional skewAxis; if (_skewAxis) { skewAxis = _skewAxis->value().value; } @@ -140,7 +140,7 @@ public: return nullptr; } - double opacity() { + float opacity() { if (_opacity) { return _opacity->value().value; } else { @@ -164,7 +164,7 @@ public: } } - double tracking() { + float tracking() { if (_tracking) { return _tracking->value().value; } else { @@ -172,7 +172,7 @@ public: } } - double strokeWidth() { + float strokeWidth() { if (_strokeWidth) { return _strokeWidth->value().value; } else { @@ -225,7 +225,7 @@ public: _xform = xform; } - double opacity() { + float opacity() { if (_opacity.has_value()) { return _opacity.value(); } else if (_parentTextNode) { @@ -234,7 +234,7 @@ public: return 1.0; } } - void setOpacity(double opacity) { + void setOpacity(float opacity) { _opacity = opacity; } @@ -264,7 +264,7 @@ public: _fillColor = fillColor; } - double tracking() { + float tracking() { if (_tracking.has_value()) { return _tracking.value(); } else if (_parentTextNode) { @@ -273,11 +273,11 @@ public: return 0.0; } } - void setTracking(double tracking) { + void setTracking(float tracking) { _tracking = tracking; } - double strokeWidth() { + float strokeWidth() { if (_strokeWidth.has_value()) { return _strokeWidth.value(); } else if (_parentTextNode) { @@ -286,11 +286,11 @@ public: return 0.0; } } - void setStrokeWidth(double strokeWidth) { + void setStrokeWidth(float strokeWidth) { _strokeWidth = strokeWidth; } - virtual bool hasOutputUpdates(double frame) override { + virtual bool hasOutputUpdates(float frame) override { // TODO Fix This return true; } @@ -313,11 +313,11 @@ private: std::shared_ptr _outputPath; std::optional _xform; - std::optional _opacity; + std::optional _opacity; std::optional _strokeColor; std::optional _fillColor; - std::optional _tracking; - std::optional _strokeWidth; + std::optional _tracking; + std::optional _strokeWidth; }; class TextAnimatorNode: public AnimatorNode { @@ -347,7 +347,7 @@ public: return true; } - virtual void rebuildOutputs(double frame) override { + virtual void rebuildOutputs(float frame) override { _textOutputNode->setXform(_textAnimatorProperties->caTransform()); _textOutputNode->setOpacity(((float)_textAnimatorProperties->opacity()) * 0.01f); _textOutputNode->setStrokeColor(_textAnimatorProperties->strokeColor()); diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.hpp index 8c07963fcd..249c055665 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/AnimatorNode.hpp @@ -55,7 +55,7 @@ public: virtual std::shared_ptr outputNode() = 0; /// 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. bool isEnabled() { @@ -79,10 +79,10 @@ public: _hasUpstreamUpdates = hasUpstreamUpdates; } - std::optional lastUpdateFrame() { + std::optional lastUpdateFrame() { return _lastUpdateFrame; } - virtual void setLastUpdateFrame(std::optional lastUpdateFrame) { + virtual void setLastUpdateFrame(std::optional lastUpdateFrame) { _lastUpdateFrame = lastUpdateFrame; } @@ -97,20 +97,20 @@ public: } /// 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 return forceLocalUpdate; } - virtual void performAdditionalOutputUpdates(double frame, bool forceOutputUpdate) { + virtual void performAdditionalOutputUpdates(float frame, bool forceOutputUpdate) { /// Optional } /// The default simply returns `hasLocalUpdates` - virtual bool shouldRebuildOutputs(double frame) { + virtual bool shouldRebuildOutputs(float frame) { return hasLocalUpdates(); } - virtual bool updateOutputs(double frame, bool forceOutputUpdate) { + virtual bool updateOutputs(float frame, bool forceOutputUpdate) { if (!isEnabled()) { setLastUpdateFrame(frame); if (const auto parentNodeValue = parentNode()) { @@ -147,7 +147,7 @@ public: } /// 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()) { // Disabled node, pass through. if (const auto parentNodeValue = parentNode()) { @@ -185,7 +185,7 @@ public: return localUpdatesPermeateDownstream() ? hasUpstreamUpdates() || hasLocalUpdates() : hasUpstreamUpdates(); } - bool updateTree(double frame, bool forceUpdates) { + bool updateTree(float frame, bool forceUpdates) { if (updateContents(frame, forceUpdates)) { return updateOutputs(frame, forceUpdates); } else { @@ -230,7 +230,7 @@ private: bool _isEnabled = true; bool _hasLocalUpdates = false; bool _hasUpstreamUpdates = false; - std::optional _lastUpdateFrame; + std::optional _lastUpdateFrame; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/NodeOutput.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/NodeOutput.hpp index ee400acf20..69d5dd81d5 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/NodeOutput.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/Protocols/NodeOutput.hpp @@ -15,7 +15,7 @@ public: virtual std::shared_ptr parent() = 0; /// 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 outputPath() = 0; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.cpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.cpp index 749cdd6825..a1ec1b2bed 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.cpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.cpp @@ -2,13 +2,13 @@ namespace lottie { -void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector &outColors, std::vector &outLocations) { +void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector &outColors, std::vector &outLocations) { std::vector alphaColors; - std::vector alphaValues; - std::vector alphaLocations; + std::vector alphaValues; + std::vector alphaLocations; std::vector gradientColors; - std::vector colorLocations; + std::vector colorLocations; for (int i = 0; i < numberOfColors; i++) { int ix = i * 4; @@ -26,7 +26,7 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s bool drawMask = false; 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) { drawMask = true; } @@ -36,7 +36,7 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s } if (drawMask) { - std::vector locations; + std::vector locations; for (size_t i = 0; i < std::min(gradientColors.size(), colorLocations.size()); i++) { if (std::find(locations.begin(), locations.end(), colorLocations[i]) == locations.end()) { locations.push_back(colorLocations[i]); @@ -62,7 +62,7 @@ void getGradientParameters(int numberOfColors, GradientColorSet const &colors, s Color color = gradientColors[0]; for (size_t i = 0; i < std::min(gradientColors.size(), colorLocations.size()) - 1; i++) { if (location >= colorLocations[i] && location <= colorLocations[i + 1]) { - double localLocation = 0.0; + float localLocation = 0.0; if (colorLocations[i] != colorLocations[i + 1]) { 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++) { if (location >= alphaLocations[i] && location <= alphaLocations[i + 1]) { - double localLocation = 0.0; + float localLocation = 0.0; if (alphaLocations[i] != alphaLocations[i + 1]) { localLocation = remapFloat(location, alphaLocations[i], alphaLocations[i + 1], 0.0, 1.0); } - alpha = ValueInterpolator::interpolate(alphaValues[i], alphaValues[i + 1], localLocation, std::nullopt, std::nullopt); + alpha = ValueInterpolator::interpolate(alphaValues[i], alphaValues[i + 1], localLocation, std::nullopt, std::nullopt); break; } } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.hpp index f14c578644..8319b8505b 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/MainThread/NodeRenderSystem/RenderLayers/GetGradientParameters.hpp @@ -6,7 +6,7 @@ namespace lottie { -void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector &outColors, std::vector &outLocations); +void getGradientParameters(int numberOfColors, GradientColorSet const &colors, std::vector &outColors, std::vector &outLocations); } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Animation.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Animation.hpp index 289ef8cc09..f34c23aed9 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Animation.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Animation.hpp @@ -32,7 +32,7 @@ public: std::optional tgs_, AnimationFrameTime startFrame_, AnimationFrameTime endFrame_, - double framerate_, + float framerate_, std::string const &version_, std::optional type_, int width_, @@ -93,7 +93,7 @@ public: AnimationFrameTime startFrame = getDouble(json, "ip"); AnimationFrameTime endFrame = getDouble(json, "op"); - double framerate = getDouble(json, "fr"); + float framerate = getDouble(json, "fr"); int width = getInt(json, "w"); int height = getInt(json, "h"); @@ -256,7 +256,7 @@ public: AnimationFrameTime endFrame; /// The frame rate of the composition. - double framerate; + float framerate; /// Return all marker names, in order, or an empty list if none are specified std::vector markerNames() { diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/ImageAsset.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/ImageAsset.hpp index 992f8534df..134b82961e 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/ImageAsset.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/ImageAsset.hpp @@ -18,8 +18,8 @@ public: std::string id_, std::string name_, std::string directory_, - double width_, - double height_ + float width_, + float height_ ) : Asset(id_), name(name_), directory(directory_), @@ -64,8 +64,8 @@ public: std::string directory; /// Image Size - double width; - double height; + float width; + float height; std::optional _e; std::optional _t; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/PrecompAsset.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/PrecompAsset.hpp index d79f0016b8..c79dca0066 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/PrecompAsset.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Assets/PrecompAsset.hpp @@ -56,7 +56,7 @@ public: /// Layers of the precomp std::vector> layers; - std::optional frameRate; + std::optional frameRate; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/LayerModel.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/LayerModel.hpp index 2670043c44..3508400786 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/LayerModel.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/LayerModel.hpp @@ -255,7 +255,7 @@ public: } } - double timeStretch() { + float timeStretch() { if (_timeStretch.has_value()) { return _timeStretch.value(); } else { @@ -279,12 +279,12 @@ public: std::optional coordinateSpace; /// The in time of the layer in frames. - double inFrame; + float inFrame; /// The out time of the layer in frames. - double outFrame; + float outFrame; /// The start time of the layer in frames. - double startTime; + float startTime; /// The transform of the layer std::shared_ptr transform; @@ -299,7 +299,7 @@ public: std::optional>> masks; /// A number that stretches time by a multiplier - std::optional _timeStretch; + std::optional _timeStretch; /// The type of matte if any. std::optional matte; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/PreCompLayerModel.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/PreCompLayerModel.hpp index 44ca30ea0f..3f861b569c 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/PreCompLayerModel.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/PreCompLayerModel.hpp @@ -46,10 +46,10 @@ public: std::optional> timeRemapping; /// Precomp Width - double width; + float width; /// Precomp Height - double height; + float height; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/SolidLayerModel.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/SolidLayerModel.hpp index 922d3e6342..399105e454 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/SolidLayerModel.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Layers/SolidLayerModel.hpp @@ -31,10 +31,10 @@ public: std::string colorHex; /// The Width of the color layer - double width; + float width; /// The height of the color layer - double height; + float height; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Objects/FitzModifier.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Objects/FitzModifier.hpp index 06553a99b6..632a2374f9 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Objects/FitzModifier.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Objects/FitzModifier.hpp @@ -19,33 +19,33 @@ public: lottiejson11::Json::object toJson() const { lottiejson11::Json::object result; - result.insert(std::make_pair("o", (double)original)); + result.insert(std::make_pair("o", (float)original)); 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()) { - result.insert(std::make_pair("f3", (double)type3.value())); + result.insert(std::make_pair("f3", (float)type3.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()) { - result.insert(std::make_pair("f5", (double)type5.value())); + result.insert(std::make_pair("f5", (float)type5.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; } public: - double original; - std::optional type12; - std::optional type3; - std::optional type4; - std::optional type5; - std::optional type6; + float original; + std::optional type12; + std::optional type3; + std::optional type4; + std::optional type5; + std::optional type6; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/GradientStroke.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/GradientStroke.hpp index 4110e7cf78..36319fb11e 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/GradientStroke.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/GradientStroke.hpp @@ -182,7 +182,7 @@ public: LineJoin lineJoin; /// Miter Limit - std::optional miterLimit; + std::optional miterLimit; /// The dash pattern of the stroke std::optional> dashPattern; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/Stroke.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/Stroke.hpp index b3d8ff3066..56920e52fa 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/Stroke.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/ShapeItems/Stroke.hpp @@ -128,7 +128,7 @@ public: LineJoin lineJoin; /// Miter Limit - std::optional miterLimit; + std::optional miterLimit; /// The dash pattern of the stroke std::optional> dashPattern; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Font.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Font.hpp index 229a85c9dd..065f3c34fe 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Font.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Font.hpp @@ -14,7 +14,7 @@ public: std::string const &name_, std::string const &familyName_, std::string const &style_, - double ascent_ + float ascent_ ) : name(name_), familyName(familyName_), @@ -63,7 +63,7 @@ public: std::optional weight; std::optional fontClass; std::string style; - double ascent; + float ascent; std::optional origin; }; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Glyph.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Glyph.hpp index 17b09c0ce0..44d5e771e0 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Glyph.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/Glyph.hpp @@ -13,10 +13,10 @@ class Glyph { public: Glyph( std::string const &character_, - double fontSize_, + float fontSize_, std::string const &fontFamily_, std::string const &fontStyle_, - double width_, + float width_, std::optional>> shapes_ ) : character(character_), @@ -86,7 +86,7 @@ public: std::string character; /// The font size of the character - double fontSize; + float fontSize; /// The font family of the character std::string fontFamily; @@ -95,7 +95,7 @@ public: std::string fontStyle; /// The Width of the character - double width; + float width; /// The Shape Data of the Character std::optional>> shapes; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/TextDocument.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/TextDocument.hpp index d692dd0d77..abb85dda71 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/TextDocument.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Model/Text/TextDocument.hpp @@ -20,15 +20,15 @@ class TextDocument { public: TextDocument( std::string const &text_, - double fontSize_, + float fontSize_, std::string const &fontFamily_, TextJustification justification_, int tracking_, - double lineHeight_, - std::optional baseline_, + float lineHeight_, + std::optional baseline_, std::optional fillColorData_, std::optional strokeColorData_, - std::optional strokeWidth_, + std::optional strokeWidth_, std::optional strokeOverFill_, std::optional textFramePosition_, std::optional textFrameSize_ @@ -145,7 +145,7 @@ public: std::string text; /// The Font size - double fontSize; + float fontSize; /// The Font Family std::string fontFamily; @@ -157,10 +157,10 @@ public: int tracking; /// Line Height - double lineHeight; + float lineHeight; /// Baseline - std::optional baseline; + std::optional baseline; /// Fill Color data std::optional fillColorData; @@ -169,7 +169,7 @@ public: std::optional strokeColorData; /// Stroke Width - std::optional strokeWidth; + std::optional strokeWidth; /// Stroke Over Fill std::optional strokeOverFill; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Utility/Primitives/CompoundBezierPath.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Utility/Primitives/CompoundBezierPath.hpp index 5a95f4f02d..3b85cc8af0 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Utility/Primitives/CompoundBezierPath.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Private/Utility/Primitives/CompoundBezierPath.hpp @@ -17,7 +17,7 @@ public: paths({ path }) { } - CompoundBezierPath(std::vector paths_, std::optional length_) : + CompoundBezierPath(std::vector paths_, std::optional length_) : paths(paths_), _length(length_) { } @@ -28,11 +28,11 @@ public: public: std::vector paths; - double length() { + float length() { if (_length.has_value()) { return _length.value(); } else { - double l = 0.0; + float l = 0.0; for (auto &path : paths) { l += path.length(); } @@ -42,7 +42,7 @@ public: } private: - std::optional _length; + std::optional _length; public: std::shared_ptr addingPath(BezierPath const &path) const { @@ -64,7 +64,7 @@ public: return std::make_shared(newPaths); } - std::shared_ptr trim(double fromPosition, double toPosition, double offset) { + std::shared_ptr trim(float fromPosition, float toPosition, float offset) { if (fromPosition == toPosition) { return std::make_shared(); } @@ -82,11 +82,11 @@ public: return std::make_shared(newPaths); }*/ - double lengthValue = length(); + float lengthValue = length(); /// Normalize lengths to the curve length. - double startPosition = fmod(fromPosition + offset, 1.0); - double endPosition = fmod(toPosition + offset, 1.0); + float startPosition = fmod(fromPosition + offset, 1.0); + float endPosition = fmod(toPosition + offset, 1.0); if (startPosition < 0.0) { startPosition = 1.0 + startPosition; @@ -123,7 +123,7 @@ public: auto compoundPath = std::make_shared(); auto trim = positions[0]; positions.erase(positions.begin()); - double pathStartPosition = 0.0; + float pathStartPosition = 0.0; bool finishedTrimming = false; int i = 0; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/FontProvider/AnimationFontProvider.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/FontProvider/AnimationFontProvider.hpp index f03a137db4..c14d46f8d9 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/FontProvider/AnimationFontProvider.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/FontProvider/AnimationFontProvider.hpp @@ -11,7 +11,7 @@ namespace lottie { /// class AnimationFontProvider { public: - virtual std::shared_ptr fontFor(std::string const &family, double size) = 0; + virtual std::shared_ptr fontFor(std::string const &family, float size) = 0; }; /// Default Font provider. @@ -22,7 +22,7 @@ public: virtual ~DefaultFontProvider() = default; - virtual std::shared_ptr fontFor(std::string const &family, double size) override { + virtual std::shared_ptr fontFor(std::string const &family, float size) override { //CTFontCreateWithName(family as CFString, size, nil) return nullptr; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/Keyframe.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/Keyframe.hpp index 124d629c4f..c4adf10367 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/Keyframe.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/Keyframe.hpp @@ -65,7 +65,7 @@ public: } public: - T interpolate(Keyframe const &to, double progress) { + T interpolate(Keyframe const &to, float progress) { std::optional spatialOutTangent2d; if (spatialOutTangent) { spatialOutTangent2d = Vector2D(spatialOutTangent->x, spatialOutTangent->y); @@ -78,9 +78,9 @@ public: } /// Interpolates the keyTime into a value from 0-1 - double interpolatedProgress(Keyframe const &to, double keyTime) { - double startTime = time; - double endTime = to.time; + float interpolatedProgress(Keyframe const &to, float keyTime) { + float startTime = time; + float endTime = to.time; if (keyTime <= startTime) { return 0.0; } @@ -100,7 +100,7 @@ public: if (to.inTangent.has_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)) { /// Cubic interpolation progress = cubicBezierInterpolate(progress, Vector2D::Zero(), outTanPoint, inTanPoint, Vector2D(1.0, 1.0)); diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.cpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.cpp index 7a92fd80ba..650d25e041 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.cpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.cpp @@ -4,7 +4,7 @@ namespace lottie { -void batchInterpolate(std::vector const &from, std::vector const &to, BezierPath &resultPath, double amount) { +void batchInterpolate(std::vector const &from, std::vector const &to, BezierPath &resultPath, float amount) { int elementCount = (int)from.size(); if (elementCount > (int)to.size()) { elementCount = (int)to.size(); diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.hpp index d3c098a6a3..4cc473bfc9 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Keyframes/ValueInterpolators.hpp @@ -18,9 +18,9 @@ struct ValueInterpolator { }; template<> -struct ValueInterpolator { +struct ValueInterpolator { public: - static double interpolate(double value, double to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static float interpolate(float value, float to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { return value + ((to - value) * amount); } }; @@ -28,22 +28,22 @@ public: template<> struct ValueInterpolator { public: - static Vector1D interpolate(Vector1D const &value, Vector1D const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { - return Vector1D(ValueInterpolator::interpolate(value.value, to.value, amount, spatialOutTangent, spatialInTangent)); + static Vector1D interpolate(Vector1D const &value, Vector1D const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + return Vector1D(ValueInterpolator::interpolate(value.value, to.value, amount, spatialOutTangent, spatialInTangent)); } }; template<> struct ValueInterpolator { 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 cp2 = to + spatialInTangent; 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); } }; @@ -51,7 +51,7 @@ public: template<> struct ValueInterpolator { public: - static Vector3D interpolate(Vector3D const &value, Vector3D const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static Vector3D interpolate(Vector3D const &value, Vector3D const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { if (spatialOutTangent && spatialInTangent) { Vector2D from2d(value.x, value.y); Vector2D to2d(to.x, to.y); @@ -64,14 +64,14 @@ public: return Vector3D( result2d.x, result2d.y, - ValueInterpolator::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent) + ValueInterpolator::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent) ); } return Vector3D( - ValueInterpolator::interpolate(value.x, to.x, amount, spatialOutTangent, spatialInTangent), - ValueInterpolator::interpolate(value.y, to.y, amount, spatialOutTangent, spatialInTangent), - ValueInterpolator::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent) + ValueInterpolator::interpolate(value.x, to.x, amount, spatialOutTangent, spatialInTangent), + ValueInterpolator::interpolate(value.y, to.y, amount, spatialOutTangent, spatialInTangent), + ValueInterpolator::interpolate(value.z, to.z, amount, spatialOutTangent, spatialInTangent) ); } }; @@ -79,22 +79,22 @@ public: template<> struct ValueInterpolator { public: - static Color interpolate(Color const &value, Color const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static Color interpolate(Color const &value, Color const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { return Color( - ValueInterpolator::interpolate(value.r, to.r, amount, spatialOutTangent, spatialInTangent), - ValueInterpolator::interpolate(value.g, to.g, amount, spatialOutTangent, spatialInTangent), - ValueInterpolator::interpolate(value.b, to.b, amount, spatialOutTangent, spatialInTangent), - ValueInterpolator::interpolate(value.a, to.a, amount, spatialOutTangent, spatialInTangent) + ValueInterpolator::interpolate(value.r, to.r, amount, spatialOutTangent, spatialInTangent), + ValueInterpolator::interpolate(value.g, to.g, amount, spatialOutTangent, spatialInTangent), + ValueInterpolator::interpolate(value.b, to.b, amount, spatialOutTangent, spatialInTangent), + ValueInterpolator::interpolate(value.a, to.a, amount, spatialOutTangent, spatialInTangent) ); } }; -void batchInterpolate(std::vector const &from, std::vector const &to, BezierPath &resultPath, double amount); +void batchInterpolate(std::vector const &from, std::vector const &to, BezierPath &resultPath, float amount); template<> struct ValueInterpolator { 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( ValueInterpolator::interpolate(value.point, to.point, amount, spatialOutTangent, spatialInTangent), ValueInterpolator::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( ValueInterpolator::interpolate(value.point, to.point, amount), ValueInterpolator::interpolate(value.inTangent, to.inTangent, amount), @@ -114,7 +114,7 @@ public: template<> struct ValueInterpolator { public: - static BezierPath interpolate(BezierPath const &value, BezierPath const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static BezierPath interpolate(BezierPath const &value, BezierPath const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { BezierPath newPath; newPath.reserveCapacity(std::max(value.elements().size(), to.elements().size())); //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)); } - static void interpolateInplace(BezierPath const &value, BezierPath const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent, BezierPath &resultPath) { + static void interpolateInplace(BezierPath const &value, BezierPath const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent, BezierPath &resultPath) { /*if (value.elements().size() != to.elements().size()) { return to; }*/ @@ -185,7 +185,7 @@ public: template<> struct ValueInterpolator { public: - static TextDocument interpolate(TextDocument const &value, TextDocument const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static TextDocument interpolate(TextDocument const &value, TextDocument const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { if (amount == 1.0) { return to; } else { @@ -197,12 +197,12 @@ public: template<> struct ValueInterpolator { public: - static GradientColorSet interpolate(GradientColorSet const &value, GradientColorSet const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static GradientColorSet interpolate(GradientColorSet const &value, GradientColorSet const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { assert(value.colors.size() == to.colors.size()); - std::vector colors; + std::vector colors; size_t colorCount = std::min(value.colors.size(), to.colors.size()); for (size_t i = 0; i < colorCount; i++) { - colors.push_back(ValueInterpolator::interpolate(value.colors[i], to.colors[i], amount, spatialOutTangent, spatialInTangent)); + colors.push_back(ValueInterpolator::interpolate(value.colors[i], to.colors[i], amount, spatialOutTangent, spatialInTangent)); } return GradientColorSet(colors); } @@ -211,12 +211,12 @@ public: template<> struct ValueInterpolator { public: - static DashPattern interpolate(DashPattern const &value, DashPattern const &to, double amount, std::optional spatialOutTangent, std::optional spatialInTangent) { + static DashPattern interpolate(DashPattern const &value, DashPattern const &to, float amount, std::optional spatialOutTangent, std::optional spatialInTangent) { assert(value.values.size() == to.values.size()); - std::vector values; + std::vector values; size_t colorCount = std::min(value.values.size(), to.values.size()); for (size_t i = 0; i < colorCount; i++) { - values.push_back(ValueInterpolator::interpolate(value.values[i], to.values[i], amount, spatialOutTangent, spatialInTangent)); + values.push_back(ValueInterpolator::interpolate(value.values[i], to.values[i], amount, spatialOutTangent, spatialInTangent)); } return DashPattern(std::move(values)); } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnimationTime.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnimationTime.hpp index 02a3e558d3..a2a7ec3fdd 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnimationTime.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnimationTime.hpp @@ -4,10 +4,10 @@ namespace lottie { /// 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) -typedef double AnimationProgressTime; +typedef float AnimationProgressTime; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnyValue.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnyValue.hpp index 0cd69ea851..f730fad652 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnyValue.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/AnyValue.hpp @@ -16,7 +16,7 @@ namespace lottie { class AnyValue { public: enum class Type { - Double, + Float, Vector1D, Vector2D, Vector3D, @@ -28,9 +28,9 @@ public: }; public: - AnyValue(double value) : - _type(Type::Double), - _doubleValue(value) { + AnyValue(float value) : + _type(Type::Float), + _floatValue(value) { } AnyValue(Vector1D const &value) : @@ -73,9 +73,9 @@ public: _dashPatternValue(value) { } - template::value>> - double get() { - return asDouble(); + template::value>> + float get() { + return asFloat(); } template::value>> @@ -123,8 +123,8 @@ public: return _type; } - double asDouble() { - return _doubleValue.value(); + float asFloat() { + return _floatValue.value(); } Vector1D asVector1D() { @@ -162,7 +162,7 @@ public: private: Type _type; - std::optional _doubleValue; + std::optional _floatValue; std::optional _vector1DValue; std::optional _vector2DValue; std::optional _vector3DValue; @@ -178,9 +178,9 @@ struct AnyValueType { }; template<> -struct AnyValueType { +struct AnyValueType { static AnyValue::Type type() { - return AnyValue::Type::Double; + return AnyValue::Type::Float; } }; diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/CALayer.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/CALayer.hpp index 171c75f850..dbc7006416 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/CALayer.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/CALayer.hpp @@ -186,10 +186,10 @@ public: _path = path; } - double lineWidth() const { + float lineWidth() const { return _lineWidth; } - void setLineWidth(double lineWidth) { + void setLineWidth(float lineWidth) { _lineWidth = lineWidth; } @@ -207,17 +207,17 @@ public: _lineCap = lineCap; } - double lineDashPhase() const { + float lineDashPhase() const { return _lineDashPhase; } - void setLineDashPhase(double lineDashPhase) { + void setLineDashPhase(float lineDashPhase) { _lineDashPhase = lineDashPhase; } - std::vector const &dashPattern() const { + std::vector const &dashPattern() const { return _dashPattern; } - void setDashPattern(std::vector const &dashPattern) { + void setDashPattern(std::vector const &dashPattern) { _dashPattern = dashPattern; } @@ -243,11 +243,11 @@ private: std::optional _fillColor = Color(0.0, 0.0, 0.0, 1.0); FillRule _fillRule = FillRule::NonZeroWinding; std::shared_ptr _path; - double _lineWidth = 1.0; + float _lineWidth = 1.0; LineJoin _lineJoin = LineJoin::Miter; LineCap _lineCap = LineCap::Butt; - double _lineDashPhase = 0.0; - std::vector _dashPattern; + float _lineDashPhase = 0.0; + std::vector _dashPattern; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/DashPattern.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/DashPattern.hpp index d22ee1e4d8..e6255ec821 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/DashPattern.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/DashPattern.hpp @@ -6,11 +6,11 @@ namespace lottie { struct DashPattern { - DashPattern(std::vector &&values_) : + DashPattern(std::vector &&values_) : values(std::move(values_)) { } - std::vector values; + std::vector values; }; } diff --git a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/GradientColorSet.hpp b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/GradientColorSet.hpp index d37448999a..abf576690f 100644 --- a/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/GradientColorSet.hpp +++ b/submodules/TelegramUI/Components/LottieCpp/Sources/Lottie/Public/Primitives/GradientColorSet.hpp @@ -34,7 +34,7 @@ struct GradientColorSet { return result; } - std::vector colors; + std::vector colors; }; } diff --git a/submodules/TelegramUI/Components/LottieMetal/Sources/LottieMetalAnimatedStickerNode.swift b/submodules/TelegramUI/Components/LottieMetal/Sources/LottieMetalAnimatedStickerNode.swift index 8b4ea6042e..9e08a17d94 100644 --- a/submodules/TelegramUI/Components/LottieMetal/Sources/LottieMetalAnimatedStickerNode.swift +++ b/submodules/TelegramUI/Components/LottieMetal/Sources/LottieMetalAnimatedStickerNode.swift @@ -468,7 +468,7 @@ private final class RenderFrameState { 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 layerAlpha = normalizedOpacity * parentAlpha @@ -534,7 +534,7 @@ private final class RenderFrameState { concat(node.layer.transform) } - var renderAlpha: CGFloat = 1.0 + var renderAlpha: Float = 1.0 if needsTempContext { renderAlpha = 1.0 } else {