Bump .clang-format to 100 columns
diff --git a/.clang-format b/.clang-format
index 2ce7c13..690438d 100644
--- a/.clang-format
+++ b/.clang-format
@@ -12,7 +12,7 @@
AccessModifierOffset: -4
BreakConstructorInitializers: AfterColon
ConstructorInitializerAllOnOneLineOrOnePerLine: true
-ColumnLimit: 80
+ColumnLimit: 100
BinPackArguments: false
BinPackParameters: false
AlignAfterOpenBracket: Align
diff --git a/include/rive/animation/animation_state_instance.hpp b/include/rive/animation/animation_state_instance.hpp
index 8c6244a..57fce73 100644
--- a/include/rive/animation/animation_state_instance.hpp
+++ b/include/rive/animation/animation_state_instance.hpp
@@ -22,13 +22,9 @@
bool keepGoing() const override;
- const LinearAnimationInstance* animationInstance() const {
- return &m_AnimationInstance;
- }
+ const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; }
- LinearAnimationInstance* animationInstance() {
- return &m_AnimationInstance;
- }
+ LinearAnimationInstance* animationInstance() { return &m_AnimationInstance; }
};
} // namespace rive
#endif
\ No newline at end of file
diff --git a/include/rive/animation/blend_state.hpp b/include/rive/animation/blend_state.hpp
index 779d822..4673d6b 100644
--- a/include/rive/animation/blend_state.hpp
+++ b/include/rive/animation/blend_state.hpp
@@ -18,9 +18,7 @@
public:
~BlendState();
- inline const std::vector<BlendAnimation*>& animations() const {
- return m_Animations;
- }
+ inline const std::vector<BlendAnimation*>& animations() const { return m_Animations; }
#ifdef TESTING
size_t animationCount() { return m_Animations.size(); }
diff --git a/include/rive/animation/blend_state_1d_instance.hpp b/include/rive/animation/blend_state_1d_instance.hpp
index 51a2beb..ccd2d15 100644
--- a/include/rive/animation/blend_state_1d_instance.hpp
+++ b/include/rive/animation/blend_state_1d_instance.hpp
@@ -6,8 +6,7 @@
#include "rive/animation/blend_animation_1d.hpp"
namespace rive {
- class BlendState1DInstance
- : public BlendStateInstance<BlendState1D, BlendAnimation1D> {
+ class BlendState1DInstance : public BlendStateInstance<BlendState1D, BlendAnimation1D> {
private:
BlendStateAnimationInstance<BlendAnimation1D>* m_From = nullptr;
BlendStateAnimationInstance<BlendAnimation1D>* m_To = nullptr;
diff --git a/include/rive/animation/blend_state_instance.hpp b/include/rive/animation/blend_state_instance.hpp
index 717aed9..3b863bd 100644
--- a/include/rive/animation/blend_state_instance.hpp
+++ b/include/rive/animation/blend_state_instance.hpp
@@ -21,19 +21,15 @@
public:
const T* blendAnimation() const { return m_BlendAnimation; }
- const LinearAnimationInstance* animationInstance() const {
- return &m_AnimationInstance;
- }
+ const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; }
BlendStateAnimationInstance(const T* blendAnimation) :
- m_BlendAnimation(blendAnimation),
- m_AnimationInstance(blendAnimation->animation()) {}
+ m_BlendAnimation(blendAnimation), m_AnimationInstance(blendAnimation->animation()) {}
void mix(float value) { m_Mix = value; }
};
- template <class K, class T>
- class BlendStateInstance : public StateInstance {
+ template <class K, class T> class BlendStateInstance : public StateInstance {
protected:
std::vector<BlendStateAnimationInstance<T>> m_AnimationInstances;
bool m_KeepGoing = true;
@@ -42,8 +38,7 @@
BlendStateInstance(const K* blendState) : StateInstance(blendState) {
for (auto blendAnimation : blendState->animations()) {
m_AnimationInstances.emplace_back(
- BlendStateAnimationInstance<T>(
- static_cast<T*>(blendAnimation)));
+ BlendStateAnimationInstance<T>(static_cast<T*>(blendAnimation)));
}
}
diff --git a/include/rive/animation/blend_state_transition.hpp b/include/rive/animation/blend_state_transition.hpp
index 2ecbf49..e8dd5cb 100644
--- a/include/rive/animation/blend_state_transition.hpp
+++ b/include/rive/animation/blend_state_transition.hpp
@@ -12,15 +12,12 @@
BlendAnimation* m_ExitBlendAnimation = nullptr;
public:
- BlendAnimation* exitBlendAnimation() const {
- return m_ExitBlendAnimation;
- }
+ BlendAnimation* exitBlendAnimation() const { return m_ExitBlendAnimation; }
const LinearAnimationInstance*
exitTimeAnimationInstance(const StateInstance* from) const override;
- const LinearAnimation*
- exitTimeAnimation(const LayerState* from) const override;
+ const LinearAnimation* exitTimeAnimation(const LayerState* from) const override;
};
} // namespace rive
diff --git a/include/rive/animation/keyframe.hpp b/include/rive/animation/keyframe.hpp
index e8bd6db..6fda087 100644
--- a/include/rive/animation/keyframe.hpp
+++ b/include/rive/animation/keyframe.hpp
@@ -11,19 +11,14 @@
public:
inline float seconds() const { return m_Seconds; }
- inline CubicInterpolator* interpolator() const {
- return m_Interpolator;
- }
+ inline CubicInterpolator* interpolator() const { return m_Interpolator; }
void computeSeconds(int fps);
StatusCode onAddedDirty(CoreContext* context) override;
virtual void apply(Core* object, int propertyKey, float mix) = 0;
- virtual void applyInterpolation(Core* object,
- int propertyKey,
- float seconds,
- const KeyFrame* nextFrame,
- float mix) = 0;
+ virtual void applyInterpolation(
+ Core* object, int propertyKey, float seconds, const KeyFrame* nextFrame, float mix) = 0;
StatusCode import(ImportStack& importStack) override;
};
diff --git a/include/rive/animation/state_machine_input_instance.hpp b/include/rive/animation/state_machine_input_instance.hpp
index 3744a4b..06af9b9 100644
--- a/include/rive/animation/state_machine_input_instance.hpp
+++ b/include/rive/animation/state_machine_input_instance.hpp
@@ -26,8 +26,7 @@
protected:
void valueChanged();
- SMIInput(const StateMachineInput* input,
- StateMachineInstance* machineInstance);
+ SMIInput(const StateMachineInput* input, StateMachineInstance* machineInstance);
public:
virtual ~SMIInput() {}
@@ -43,8 +42,7 @@
private:
bool m_Value;
- SMIBool(const StateMachineBool* input,
- StateMachineInstance* machineInstance);
+ SMIBool(const StateMachineBool* input, StateMachineInstance* machineInstance);
public:
bool value() const { return m_Value; }
@@ -57,8 +55,7 @@
private:
float m_Value;
- SMINumber(const StateMachineNumber* input,
- StateMachineInstance* machineInstance);
+ SMINumber(const StateMachineNumber* input, StateMachineInstance* machineInstance);
public:
float value() const { return m_Value; }
@@ -72,8 +69,7 @@
private:
bool m_Fired = false;
- SMITrigger(const StateMachineTrigger* input,
- StateMachineInstance* machineInstance);
+ SMITrigger(const StateMachineTrigger* input, StateMachineInstance* machineInstance);
void advanced() override { m_Fired = false; }
public:
diff --git a/include/rive/animation/state_machine_instance.hpp b/include/rive/animation/state_machine_instance.hpp
index 8db2b78..5b1629e 100644
--- a/include/rive/animation/state_machine_instance.hpp
+++ b/include/rive/animation/state_machine_instance.hpp
@@ -52,8 +52,7 @@
SMITrigger* getTrigger(std::string name) const;
const size_t currentAnimationCount() const;
- const LinearAnimationInstance*
- currentAnimationByIndex(size_t index) const;
+ const LinearAnimationInstance* currentAnimationByIndex(size_t index) const;
// The number of state changes that occurred across all layers on the
// previous advance.
diff --git a/include/rive/animation/state_transition.hpp b/include/rive/animation/state_transition.hpp
index 53339b3..8c800a5 100644
--- a/include/rive/animation/state_transition.hpp
+++ b/include/rive/animation/state_transition.hpp
@@ -46,9 +46,8 @@
/// Returns AllowTransition::yes when this transition can be taken from
/// stateFrom with the given inputs.
- AllowTransition allowed(StateInstance* stateFrom,
- SMIInput** inputs,
- bool ignoreTriggers) const;
+ AllowTransition
+ allowed(StateInstance* stateFrom, SMIInput** inputs, bool ignoreTriggers) const;
/// Whether the animation is held at exit or if it keeps advancing
/// during mixing.
@@ -83,8 +82,7 @@
/// true if you want the returned time to be relative to the entire
/// animation. Set absolute to false if you want it relative to the work
/// area.
- float exitTimeSeconds(const LayerState* stateFrom,
- bool absolute = false) const;
+ float exitTimeSeconds(const LayerState* stateFrom, bool absolute = false) const;
/// Provide the animation instance to use for computing percentage
/// durations for exit time.
@@ -93,8 +91,7 @@
/// Provide the animation to use for computing percentage durations for
/// exit time.
- virtual const LinearAnimation*
- exitTimeAnimation(const LayerState* from) const;
+ virtual const LinearAnimation* exitTimeAnimation(const LayerState* from) const;
/// Retruns true when we need to hold the exit time, also applies the
/// correct time to the animation instance in the stateFrom, when
diff --git a/include/rive/animation/state_transition_flags.hpp b/include/rive/animation/state_transition_flags.hpp
index e55cb01..2fee901 100644
--- a/include/rive/animation/state_transition_flags.hpp
+++ b/include/rive/animation/state_transition_flags.hpp
@@ -48,12 +48,10 @@
inline constexpr StateTransitionFlags operator~(StateTransitionFlags rhs) {
return static_cast<StateTransitionFlags>(
- ~static_cast<std::underlying_type<StateTransitionFlags>::type>(
- rhs));
+ ~static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs));
}
- inline StateTransitionFlags& operator|=(StateTransitionFlags& lhs,
- StateTransitionFlags rhs) {
+ inline StateTransitionFlags& operator|=(StateTransitionFlags& lhs, StateTransitionFlags rhs) {
lhs = static_cast<StateTransitionFlags>(
static_cast<std::underlying_type<StateTransitionFlags>::type>(lhs) |
static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs));
@@ -61,8 +59,7 @@
return lhs;
}
- inline StateTransitionFlags& operator&=(StateTransitionFlags& lhs,
- StateTransitionFlags rhs) {
+ inline StateTransitionFlags& operator&=(StateTransitionFlags& lhs, StateTransitionFlags rhs) {
lhs = static_cast<StateTransitionFlags>(
static_cast<std::underlying_type<StateTransitionFlags>::type>(lhs) &
static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs));
@@ -70,8 +67,7 @@
return lhs;
}
- inline StateTransitionFlags& operator^=(StateTransitionFlags& lhs,
- StateTransitionFlags rhs) {
+ inline StateTransitionFlags& operator^=(StateTransitionFlags& lhs, StateTransitionFlags rhs) {
lhs = static_cast<StateTransitionFlags>(
static_cast<std::underlying_type<StateTransitionFlags>::type>(lhs) ^
static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs));
diff --git a/include/rive/animation/transition_condition.hpp b/include/rive/animation/transition_condition.hpp
index 0e6b0b2..6a60321 100644
--- a/include/rive/animation/transition_condition.hpp
+++ b/include/rive/animation/transition_condition.hpp
@@ -13,14 +13,10 @@
StatusCode import(ImportStack& importStack) override;
- virtual bool evaluate(const SMIInput* inputInstance) const {
- return true;
- }
+ virtual bool evaluate(const SMIInput* inputInstance) const { return true; }
protected:
- virtual bool validateInputType(const StateMachineInput* input) const {
- return true;
- }
+ virtual bool validateInputType(const StateMachineInput* input) const { return true; }
};
} // namespace rive
diff --git a/include/rive/animation/transition_value_condition.hpp b/include/rive/animation/transition_value_condition.hpp
index cc362a4..839279f 100644
--- a/include/rive/animation/transition_value_condition.hpp
+++ b/include/rive/animation/transition_value_condition.hpp
@@ -6,9 +6,7 @@
namespace rive {
class TransitionValueCondition : public TransitionValueConditionBase {
public:
- TransitionConditionOp op() const {
- return (TransitionConditionOp)opValue();
- }
+ TransitionConditionOp op() const { return (TransitionConditionOp)opValue(); }
};
} // namespace rive
diff --git a/include/rive/artboard.hpp b/include/rive/artboard.hpp
index 9cee3f7..a246f5b 100644
--- a/include/rive/artboard.hpp
+++ b/include/rive/artboard.hpp
@@ -19,9 +19,7 @@
class ArtboardImporter;
class NestedArtboard;
- class Artboard : public ArtboardBase,
- public CoreContext,
- public ShapePaintContainer {
+ class Artboard : public ArtboardBase, public CoreContext, public ShapePaintContainer {
friend class File;
friend class ArtboardImporter;
friend class Component;
@@ -89,8 +87,7 @@
template <typename T = Component> T* find(std::string name) {
for (auto object : m_Objects) {
- if (object != nullptr && object->is<T>() &&
- object->as<T>()->name() == name) {
+ if (object != nullptr && object->is<T>() && object->as<T>()->name() == name) {
return reinterpret_cast<T*>(object);
}
}
diff --git a/include/rive/bones/bone.hpp b/include/rive/bones/bone.hpp
index ce7505c..357b855 100644
--- a/include/rive/bones/bone.hpp
+++ b/include/rive/bones/bone.hpp
@@ -22,9 +22,7 @@
void addChildBone(Bone* bone);
void tipWorldTranslation(Vec2D& result);
void addPeerConstraint(Constraint* peer);
- const std::vector<Constraint*>& peerConstraints() const {
- return m_PeerConstraints;
- }
+ const std::vector<Constraint*>& peerConstraints() const { return m_PeerConstraints; }
private:
void lengthChanged() override;
diff --git a/include/rive/command_path.hpp b/include/rive/command_path.hpp
index 5108df3..f22d4a2 100644
--- a/include/rive/command_path.hpp
+++ b/include/rive/command_path.hpp
@@ -17,8 +17,7 @@
virtual void moveTo(float x, float y) = 0;
virtual void lineTo(float x, float y) = 0;
- virtual void
- cubicTo(float ox, float oy, float ix, float iy, float x, float y) = 0;
+ virtual void cubicTo(float ox, float oy, float ix, float iy, float x, float y) = 0;
virtual void close() = 0;
virtual RenderPath* renderPath() = 0;
@@ -32,7 +31,7 @@
lineTo(x, y + height);
close();
}
-
+
void move(Vec2D v) { this->moveTo(v.x(), v.y()); }
void line(Vec2D v) { this->lineTo(v.x(), v.y()); }
void cubic(Vec2D a, Vec2D b, Vec2D c) {
diff --git a/include/rive/component.hpp b/include/rive/component.hpp
index 0e488d2..443854b 100644
--- a/include/rive/component.hpp
+++ b/include/rive/component.hpp
@@ -26,9 +26,7 @@
inline Artboard* artboard() const { return m_Artboard; }
StatusCode onAddedDirty(CoreContext* context) override;
inline ContainerComponent* parent() const { return m_Parent; }
- const std::vector<Component*>& dependents() const {
- return m_Dependents;
- }
+ const std::vector<Component*>& dependents() const { return m_Dependents; }
void addDependent(Component* component);
// TODO: re-evaluate when more of the lib is complete...
@@ -41,9 +39,7 @@
unsigned int graphOrder() const { return m_GraphOrder; }
bool addDirt(ComponentDirt value, bool recurse = false);
- inline bool hasDirt(ComponentDirt flag) const {
- return (m_Dirt & flag) == flag;
- }
+ inline bool hasDirt(ComponentDirt flag) const { return (m_Dirt & flag) == flag; }
static inline bool hasDirt(ComponentDirt value, ComponentDirt flag) {
return (value & flag) != ComponentDirt::None;
}
diff --git a/include/rive/component_dirt.hpp b/include/rive/component_dirt.hpp
index 887266b..1fc3a2a 100644
--- a/include/rive/component_dirt.hpp
+++ b/include/rive/component_dirt.hpp
@@ -50,22 +50,19 @@
Filthy = 0xFFFF
};
- inline constexpr ComponentDirt operator&(ComponentDirt lhs,
- ComponentDirt rhs) {
+ inline constexpr ComponentDirt operator&(ComponentDirt lhs, ComponentDirt rhs) {
return static_cast<ComponentDirt>(
static_cast<std::underlying_type<ComponentDirt>::type>(lhs) &
static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
}
- inline constexpr ComponentDirt operator^(ComponentDirt lhs,
- ComponentDirt rhs) {
+ inline constexpr ComponentDirt operator^(ComponentDirt lhs, ComponentDirt rhs) {
return static_cast<ComponentDirt>(
static_cast<std::underlying_type<ComponentDirt>::type>(lhs) ^
static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
}
- inline constexpr ComponentDirt operator|(ComponentDirt lhs,
- ComponentDirt rhs) {
+ inline constexpr ComponentDirt operator|(ComponentDirt lhs, ComponentDirt rhs) {
return static_cast<ComponentDirt>(
static_cast<std::underlying_type<ComponentDirt>::type>(lhs) |
static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
@@ -77,25 +74,25 @@
}
inline ComponentDirt& operator|=(ComponentDirt& lhs, ComponentDirt rhs) {
- lhs = static_cast<ComponentDirt>(
- static_cast<std::underlying_type<ComponentDirt>::type>(lhs) |
- static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
+ lhs =
+ static_cast<ComponentDirt>(static_cast<std::underlying_type<ComponentDirt>::type>(lhs) |
+ static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
return lhs;
}
inline ComponentDirt& operator&=(ComponentDirt& lhs, ComponentDirt rhs) {
- lhs = static_cast<ComponentDirt>(
- static_cast<std::underlying_type<ComponentDirt>::type>(lhs) &
- static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
+ lhs =
+ static_cast<ComponentDirt>(static_cast<std::underlying_type<ComponentDirt>::type>(lhs) &
+ static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
return lhs;
}
inline ComponentDirt& operator^=(ComponentDirt& lhs, ComponentDirt rhs) {
- lhs = static_cast<ComponentDirt>(
- static_cast<std::underlying_type<ComponentDirt>::type>(lhs) ^
- static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
+ lhs =
+ static_cast<ComponentDirt>(static_cast<std::underlying_type<ComponentDirt>::type>(lhs) ^
+ static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
return lhs;
}
diff --git a/include/rive/constraints/ik_constraint.hpp b/include/rive/constraints/ik_constraint.hpp
index c6abd1c..b245b34 100644
--- a/include/rive/constraints/ik_constraint.hpp
+++ b/include/rive/constraints/ik_constraint.hpp
@@ -18,9 +18,7 @@
};
std::vector<BoneChainLink> m_FkChain;
void solve1(BoneChainLink* fk1, const Vec2D& worldTargetTranslation);
- void solve2(BoneChainLink* fk1,
- BoneChainLink* fk2,
- const Vec2D& worldTargetTranslation);
+ void solve2(BoneChainLink* fk1, BoneChainLink* fk2, const Vec2D& worldTargetTranslation);
void constrainRotation(BoneChainLink& fk, float rotation);
public:
diff --git a/include/rive/constraints/transform_component_constraint.hpp b/include/rive/constraints/transform_component_constraint.hpp
index 13f9a62..80f4b9c 100644
--- a/include/rive/constraints/transform_component_constraint.hpp
+++ b/include/rive/constraints/transform_component_constraint.hpp
@@ -4,12 +4,9 @@
#include "rive/transform_space.hpp"
#include <stdio.h>
namespace rive {
- class TransformComponentConstraint
- : public TransformComponentConstraintBase {
+ class TransformComponentConstraint : public TransformComponentConstraintBase {
public:
- TransformSpace minMaxSpace() const {
- return (TransformSpace)minMaxSpaceValue();
- }
+ TransformSpace minMaxSpace() const { return (TransformSpace)minMaxSpaceValue(); }
};
} // namespace rive
diff --git a/include/rive/constraints/transform_component_constraint_y.hpp b/include/rive/constraints/transform_component_constraint_y.hpp
index cc4427f..99162c3 100644
--- a/include/rive/constraints/transform_component_constraint_y.hpp
+++ b/include/rive/constraints/transform_component_constraint_y.hpp
@@ -3,8 +3,7 @@
#include "rive/generated/constraints/transform_component_constraint_y_base.hpp"
#include <stdio.h>
namespace rive {
- class TransformComponentConstraintY
- : public TransformComponentConstraintYBase {
+ class TransformComponentConstraintY : public TransformComponentConstraintYBase {
public:
};
} // namespace rive
diff --git a/include/rive/constraints/transform_space_constraint.hpp b/include/rive/constraints/transform_space_constraint.hpp
index 0a05e42..94a55af 100644
--- a/include/rive/constraints/transform_space_constraint.hpp
+++ b/include/rive/constraints/transform_space_constraint.hpp
@@ -6,12 +6,8 @@
namespace rive {
class TransformSpaceConstraint : public TransformSpaceConstraintBase {
public:
- TransformSpace sourceSpace() const {
- return (TransformSpace)sourceSpaceValue();
- }
- TransformSpace destSpace() const {
- return (TransformSpace)destSpaceValue();
- }
+ TransformSpace sourceSpace() const { return (TransformSpace)sourceSpaceValue(); }
+ TransformSpace destSpace() const { return (TransformSpace)destSpaceValue(); }
};
} // namespace rive
diff --git a/include/rive/core.hpp b/include/rive/core.hpp
index 2bee8cd..df228e8 100644
--- a/include/rive/core.hpp
+++ b/include/rive/core.hpp
@@ -14,12 +14,9 @@
virtual ~Core() {}
virtual uint16_t coreType() const = 0;
virtual bool isTypeOf(uint16_t typeKey) const = 0;
- virtual bool deserialize(uint16_t propertyKey,
- BinaryReader& reader) = 0;
+ virtual bool deserialize(uint16_t propertyKey, BinaryReader& reader) = 0;
- template <typename T> inline bool is() const {
- return isTypeOf(T::typeKey);
- }
+ template <typename T> inline bool is() const { return isTypeOf(T::typeKey); }
template <typename T> inline T* as() {
assert(is<T>());
return reinterpret_cast<T*>(this);
@@ -38,21 +35,15 @@
/// to look up objects referenced by id, but not assume that they in
/// turn have resolved their references yet. Called during
/// load/instance.
- virtual StatusCode onAddedDirty(CoreContext* context) {
- return StatusCode::Ok;
- }
+ virtual StatusCode onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
/// Called when all the objects in the context have had onAddedDirty
/// called. This is an opportunity to reference things referenced by
/// dependencies. (A path should be able to find a Shape somewhere in
/// its hierarchy, which may be multiple levels up).
- virtual StatusCode onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
- }
+ virtual StatusCode onAddedClean(CoreContext* context) { return StatusCode::Ok; }
- virtual StatusCode import(ImportStack& importStack) {
- return StatusCode::Ok;
- }
+ virtual StatusCode import(ImportStack& importStack) { return StatusCode::Ok; }
};
} // namespace rive
#endif
diff --git a/include/rive/draw_target.hpp b/include/rive/draw_target.hpp
index c647422..4d48737 100644
--- a/include/rive/draw_target.hpp
+++ b/include/rive/draw_target.hpp
@@ -23,9 +23,7 @@
StatusCode onAddedDirty(CoreContext* context) override;
StatusCode onAddedClean(CoreContext* context) override;
- DrawTargetPlacement placement() const {
- return (DrawTargetPlacement)placementValue();
- }
+ DrawTargetPlacement placement() const { return (DrawTargetPlacement)placementValue(); }
protected:
void placementValueChanged() override;
diff --git a/include/rive/generated/animation/blend_animation_base.hpp b/include/rive/generated/animation/blend_animation_base.hpp
index 874fd2e..385d081 100644
--- a/include/rive/generated/animation/blend_animation_base.hpp
+++ b/include/rive/generated/animation/blend_animation_base.hpp
@@ -38,9 +38,7 @@
animationIdChanged();
}
- void copy(const BlendAnimationBase& object) {
- m_AnimationId = object.m_AnimationId;
- }
+ void copy(const BlendAnimationBase& object) { m_AnimationId = object.m_AnimationId; }
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
diff --git a/include/rive/generated/animation/blend_state_transition_base.hpp b/include/rive/generated/animation/blend_state_transition_base.hpp
index 5b89fd5..e1ff13f 100644
--- a/include/rive/generated/animation/blend_state_transition_base.hpp
+++ b/include/rive/generated/animation/blend_state_transition_base.hpp
@@ -31,9 +31,7 @@
int m_ExitBlendAnimationId = -1;
public:
- inline int exitBlendAnimationId() const {
- return m_ExitBlendAnimationId;
- }
+ inline int exitBlendAnimationId() const { return m_ExitBlendAnimationId; }
void exitBlendAnimationId(int value) {
if (m_ExitBlendAnimationId == value) {
return;
diff --git a/include/rive/generated/animation/keyed_object_base.hpp b/include/rive/generated/animation/keyed_object_base.hpp
index 4b88558..f43a36b 100644
--- a/include/rive/generated/animation/keyed_object_base.hpp
+++ b/include/rive/generated/animation/keyed_object_base.hpp
@@ -39,9 +39,7 @@
}
Core* clone() const override;
- void copy(const KeyedObjectBase& object) {
- m_ObjectId = object.m_ObjectId;
- }
+ void copy(const KeyedObjectBase& object) { m_ObjectId = object.m_ObjectId; }
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
diff --git a/include/rive/generated/animation/keyed_property_base.hpp b/include/rive/generated/animation/keyed_property_base.hpp
index 1114f5d..467896f 100644
--- a/include/rive/generated/animation/keyed_property_base.hpp
+++ b/include/rive/generated/animation/keyed_property_base.hpp
@@ -39,9 +39,7 @@
}
Core* clone() const override;
- void copy(const KeyedPropertyBase& object) {
- m_PropertyKey = object.m_PropertyKey;
- }
+ void copy(const KeyedPropertyBase& object) { m_PropertyKey = object.m_PropertyKey; }
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
diff --git a/include/rive/generated/animation/state_machine_component_base.hpp b/include/rive/generated/animation/state_machine_component_base.hpp
index 63e4521..9cdb1c1 100644
--- a/include/rive/generated/animation/state_machine_component_base.hpp
+++ b/include/rive/generated/animation/state_machine_component_base.hpp
@@ -39,9 +39,7 @@
nameChanged();
}
- void copy(const StateMachineComponentBase& object) {
- m_Name = object.m_Name;
- }
+ void copy(const StateMachineComponentBase& object) { m_Name = object.m_Name; }
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
diff --git a/include/rive/generated/animation/transition_condition_base.hpp b/include/rive/generated/animation/transition_condition_base.hpp
index 961fd16..5ef5322 100644
--- a/include/rive/generated/animation/transition_condition_base.hpp
+++ b/include/rive/generated/animation/transition_condition_base.hpp
@@ -38,9 +38,7 @@
inputIdChanged();
}
- void copy(const TransitionConditionBase& object) {
- m_InputId = object.m_InputId;
- }
+ void copy(const TransitionConditionBase& object) { m_InputId = object.m_InputId; }
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
diff --git a/include/rive/generated/constraints/transform_component_constraint_y_base.hpp b/include/rive/generated/constraints/transform_component_constraint_y_base.hpp
index 9558cdc..d18b581 100644
--- a/include/rive/generated/constraints/transform_component_constraint_y_base.hpp
+++ b/include/rive/generated/constraints/transform_component_constraint_y_base.hpp
@@ -4,8 +4,7 @@
#include "rive/core/field_types/core_bool_type.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
- class TransformComponentConstraintYBase
- : public TransformComponentConstraint {
+ class TransformComponentConstraintYBase : public TransformComponentConstraint {
protected:
typedef TransformComponentConstraint Super;
@@ -131,8 +130,7 @@
m_MaxY = CoreBoolType::deserialize(reader);
return true;
}
- return TransformComponentConstraint::deserialize(propertyKey,
- reader);
+ return TransformComponentConstraint::deserialize(propertyKey, reader);
}
protected:
diff --git a/include/rive/generated/core_registry.hpp b/include/rive/generated/core_registry.hpp
index dbe63f3..4a62729 100644
--- a/include/rive/generated/core_registry.hpp
+++ b/include/rive/generated/core_registry.hpp
@@ -261,8 +261,7 @@
}
return nullptr;
}
- static void
- setString(Core* object, int propertyKey, std::string value) {
+ static void setString(Core* object, int propertyKey, std::string value) {
switch (propertyKey) {
case ComponentBase::namePropertyKey:
object->as<ComponentBase>()->name(value);
@@ -296,17 +295,13 @@
object->as<DistanceConstraintBase>()->modeValue(value);
break;
case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
- object->as<TransformSpaceConstraintBase>()
- ->sourceSpaceValue(value);
+ object->as<TransformSpaceConstraintBase>()->sourceSpaceValue(value);
break;
case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
- object->as<TransformSpaceConstraintBase>()->destSpaceValue(
- value);
+ object->as<TransformSpaceConstraintBase>()->destSpaceValue(value);
break;
- case TransformComponentConstraintBase::
- minMaxSpaceValuePropertyKey:
- object->as<TransformComponentConstraintBase>()
- ->minMaxSpaceValue(value);
+ case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
+ object->as<TransformComponentConstraintBase>()->minMaxSpaceValue(value);
break;
case IKConstraintBase::parentBoneCountPropertyKey:
object->as<IKConstraintBase>()->parentBoneCount(value);
@@ -387,8 +382,7 @@
object->as<BlendState1DBase>()->inputId(value);
break;
case BlendStateTransitionBase::exitBlendAnimationIdPropertyKey:
- object->as<BlendStateTransitionBase>()
- ->exitBlendAnimationId(value);
+ object->as<BlendStateTransitionBase>()->exitBlendAnimationId(value);
break;
case StrokeBase::capPropertyKey:
object->as<StrokeBase>()->cap(value);
@@ -455,28 +449,22 @@
object->as<DistanceConstraintBase>()->distance(value);
break;
case TransformComponentConstraintBase::copyFactorPropertyKey:
- object->as<TransformComponentConstraintBase>()->copyFactor(
- value);
+ object->as<TransformComponentConstraintBase>()->copyFactor(value);
break;
case TransformComponentConstraintBase::minValuePropertyKey:
- object->as<TransformComponentConstraintBase>()->minValue(
- value);
+ object->as<TransformComponentConstraintBase>()->minValue(value);
break;
case TransformComponentConstraintBase::maxValuePropertyKey:
- object->as<TransformComponentConstraintBase>()->maxValue(
- value);
+ object->as<TransformComponentConstraintBase>()->maxValue(value);
break;
case TransformComponentConstraintYBase::copyFactorYPropertyKey:
- object->as<TransformComponentConstraintYBase>()
- ->copyFactorY(value);
+ object->as<TransformComponentConstraintYBase>()->copyFactorY(value);
break;
case TransformComponentConstraintYBase::minValueYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->minValueY(
- value);
+ object->as<TransformComponentConstraintYBase>()->minValueY(value);
break;
case TransformComponentConstraintYBase::maxValueYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->maxValueY(
- value);
+ object->as<TransformComponentConstraintYBase>()->maxValueY(value);
break;
case WorldTransformComponentBase::opacityPropertyKey:
object->as<WorldTransformComponentBase>()->opacity(value);
@@ -708,12 +696,10 @@
static void setBool(Core* object, int propertyKey, bool value) {
switch (propertyKey) {
case TransformComponentConstraintBase::offsetPropertyKey:
- object->as<TransformComponentConstraintBase>()->offset(
- value);
+ object->as<TransformComponentConstraintBase>()->offset(value);
break;
case TransformComponentConstraintBase::doesCopyPropertyKey:
- object->as<TransformComponentConstraintBase>()->doesCopy(
- value);
+ object->as<TransformComponentConstraintBase>()->doesCopy(value);
break;
case TransformComponentConstraintBase::minPropertyKey:
object->as<TransformComponentConstraintBase>()->min(value);
@@ -722,16 +708,13 @@
object->as<TransformComponentConstraintBase>()->max(value);
break;
case TransformComponentConstraintYBase::doesCopyYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->doesCopyY(
- value);
+ object->as<TransformComponentConstraintYBase>()->doesCopyY(value);
break;
case TransformComponentConstraintYBase::minYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->minY(
- value);
+ object->as<TransformComponentConstraintYBase>()->minY(value);
break;
case TransformComponentConstraintYBase::maxYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->maxY(
- value);
+ object->as<TransformComponentConstraintYBase>()->maxY(value);
break;
case IKConstraintBase::invertDirectionPropertyKey:
object->as<IKConstraintBase>()->invertDirection(value);
@@ -807,15 +790,11 @@
case DistanceConstraintBase::modeValuePropertyKey:
return object->as<DistanceConstraintBase>()->modeValue();
case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
- return object->as<TransformSpaceConstraintBase>()
- ->sourceSpaceValue();
+ return object->as<TransformSpaceConstraintBase>()->sourceSpaceValue();
case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
- return object->as<TransformSpaceConstraintBase>()
- ->destSpaceValue();
- case TransformComponentConstraintBase::
- minMaxSpaceValuePropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->minMaxSpaceValue();
+ return object->as<TransformSpaceConstraintBase>()->destSpaceValue();
+ case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
+ return object->as<TransformComponentConstraintBase>()->minMaxSpaceValue();
case IKConstraintBase::parentBoneCountPropertyKey:
return object->as<IKConstraintBase>()->parentBoneCount();
case DrawableBase::blendModeValuePropertyKey:
@@ -847,8 +826,7 @@
case KeyFrameIdBase::valuePropertyKey:
return object->as<KeyFrameIdBase>()->value();
case TransitionValueConditionBase::opValuePropertyKey:
- return object->as<TransitionValueConditionBase>()
- ->opValue();
+ return object->as<TransitionValueConditionBase>()->opValue();
case StateTransitionBase::stateToIdPropertyKey:
return object->as<StateTransitionBase>()->stateToId();
case StateTransitionBase::flagsPropertyKey:
@@ -870,8 +848,7 @@
case BlendState1DBase::inputIdPropertyKey:
return object->as<BlendState1DBase>()->inputId();
case BlendStateTransitionBase::exitBlendAnimationIdPropertyKey:
- return object->as<BlendStateTransitionBase>()
- ->exitBlendAnimationId();
+ return object->as<BlendStateTransitionBase>()->exitBlendAnimationId();
case StrokeBase::capPropertyKey:
return object->as<StrokeBase>()->cap();
case StrokeBase::joinPropertyKey:
@@ -918,23 +895,17 @@
case DistanceConstraintBase::distancePropertyKey:
return object->as<DistanceConstraintBase>()->distance();
case TransformComponentConstraintBase::copyFactorPropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->copyFactor();
+ return object->as<TransformComponentConstraintBase>()->copyFactor();
case TransformComponentConstraintBase::minValuePropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->minValue();
+ return object->as<TransformComponentConstraintBase>()->minValue();
case TransformComponentConstraintBase::maxValuePropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->maxValue();
+ return object->as<TransformComponentConstraintBase>()->maxValue();
case TransformComponentConstraintYBase::copyFactorYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()
- ->copyFactorY();
+ return object->as<TransformComponentConstraintYBase>()->copyFactorY();
case TransformComponentConstraintYBase::minValueYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()
- ->minValueY();
+ return object->as<TransformComponentConstraintYBase>()->minValueY();
case TransformComponentConstraintYBase::maxValueYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()
- ->maxValueY();
+ return object->as<TransformComponentConstraintYBase>()->maxValueY();
case WorldTransformComponentBase::opacityPropertyKey:
return object->as<WorldTransformComponentBase>()->opacity();
case TransformComponentBase::rotationPropertyKey:
@@ -1004,11 +975,9 @@
case CubicAsymmetricVertexBase::rotationPropertyKey:
return object->as<CubicAsymmetricVertexBase>()->rotation();
case CubicAsymmetricVertexBase::inDistancePropertyKey:
- return object->as<CubicAsymmetricVertexBase>()
- ->inDistance();
+ return object->as<CubicAsymmetricVertexBase>()->inDistance();
case CubicAsymmetricVertexBase::outDistancePropertyKey:
- return object->as<CubicAsymmetricVertexBase>()
- ->outDistance();
+ return object->as<CubicAsymmetricVertexBase>()->outDistance();
case ParametricPathBase::widthPropertyKey:
return object->as<ParametricPathBase>()->width();
case ParametricPathBase::heightPropertyKey:
@@ -1093,26 +1062,19 @@
static bool getBool(Core* object, int propertyKey) {
switch (propertyKey) {
case TransformComponentConstraintBase::offsetPropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->offset();
+ return object->as<TransformComponentConstraintBase>()->offset();
case TransformComponentConstraintBase::doesCopyPropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->doesCopy();
+ return object->as<TransformComponentConstraintBase>()->doesCopy();
case TransformComponentConstraintBase::minPropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->min();
+ return object->as<TransformComponentConstraintBase>()->min();
case TransformComponentConstraintBase::maxPropertyKey:
- return object->as<TransformComponentConstraintBase>()
- ->max();
+ return object->as<TransformComponentConstraintBase>()->max();
case TransformComponentConstraintYBase::doesCopyYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()
- ->doesCopyY();
+ return object->as<TransformComponentConstraintYBase>()->doesCopyY();
case TransformComponentConstraintYBase::minYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()
- ->minY();
+ return object->as<TransformComponentConstraintYBase>()->minY();
case TransformComponentConstraintYBase::maxYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()
- ->maxY();
+ return object->as<TransformComponentConstraintYBase>()->maxY();
case IKConstraintBase::invertDirectionPropertyKey:
return object->as<IKConstraintBase>()->invertDirection();
case NestedSimpleAnimationBase::isPlayingPropertyKey:
@@ -1163,8 +1125,7 @@
case DistanceConstraintBase::modeValuePropertyKey:
case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
- case TransformComponentConstraintBase::
- minMaxSpaceValuePropertyKey:
+ case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
case IKConstraintBase::parentBoneCountPropertyKey:
case DrawableBase::blendModeValuePropertyKey:
case DrawableBase::drawableFlagsPropertyKey:
diff --git a/include/rive/generated/shapes/mesh_base.hpp b/include/rive/generated/shapes/mesh_base.hpp
index f565213..39fd6bb 100644
--- a/include/rive/generated/shapes/mesh_base.hpp
+++ b/include/rive/generated/shapes/mesh_base.hpp
@@ -41,8 +41,7 @@
bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
switch (propertyKey) {
case triangleIndexBytesPropertyKey:
- decodeTriangleIndexBytes(
- CoreBytesType::deserialize(reader));
+ decodeTriangleIndexBytes(CoreBytesType::deserialize(reader));
return true;
}
return ContainerComponent::deserialize(propertyKey, reader);
diff --git a/include/rive/generated/shapes/paint/stroke_base.hpp b/include/rive/generated/shapes/paint/stroke_base.hpp
index 85d64d1..6f4e9ec 100644
--- a/include/rive/generated/shapes/paint/stroke_base.hpp
+++ b/include/rive/generated/shapes/paint/stroke_base.hpp
@@ -67,9 +67,7 @@
joinChanged();
}
- inline bool transformAffectsStroke() const {
- return m_TransformAffectsStroke;
- }
+ inline bool transformAffectsStroke() const { return m_TransformAffectsStroke; }
void transformAffectsStroke(bool value) {
if (m_TransformAffectsStroke == value) {
return;
@@ -99,8 +97,7 @@
m_Join = CoreUintType::deserialize(reader);
return true;
case transformAffectsStrokePropertyKey:
- m_TransformAffectsStroke =
- CoreBoolType::deserialize(reader);
+ m_TransformAffectsStroke = CoreBoolType::deserialize(reader);
return true;
}
return ShapePaint::deserialize(propertyKey, reader);
diff --git a/include/rive/hit_info.hpp b/include/rive/hit_info.hpp
index 9ca9136..cd2e9c6 100644
--- a/include/rive/hit_info.hpp
+++ b/include/rive/hit_info.hpp
@@ -10,12 +10,12 @@
namespace rive {
-class NestedArtboard;
+ class NestedArtboard;
-struct HitInfo {
- IAABB area; // input
- std::vector<NestedArtboard*> mounts; // output
-};
+ struct HitInfo {
+ IAABB area; // input
+ std::vector<NestedArtboard*> mounts; // output
+ };
-}
+} // namespace rive
#endif
diff --git a/include/rive/hittest_command_path.hpp b/include/rive/hittest_command_path.hpp
index 2301449..dd1383c 100644
--- a/include/rive/hittest_command_path.hpp
+++ b/include/rive/hittest_command_path.hpp
@@ -13,12 +13,11 @@
class HitTestCommandPath : public CommandPath {
HitTester m_Tester;
- Mat2D m_Xform;
- IAABB m_Area;
- FillRule m_FillRule = FillRule::nonZero;
+ Mat2D m_Xform;
+ IAABB m_Area;
+ FillRule m_FillRule = FillRule::nonZero;
public:
-
HitTestCommandPath(const IAABB& area);
// can call this between calls to move/line/etc.
@@ -34,8 +33,7 @@
void moveTo(float x, float y) override;
void lineTo(float x, float y) override;
- void
- cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
+ void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
void close() override;
};
} // namespace rive
diff --git a/include/rive/importers/file_asset_importer.hpp b/include/rive/importers/file_asset_importer.hpp
index 6629ae3..6ad9d0c 100644
--- a/include/rive/importers/file_asset_importer.hpp
+++ b/include/rive/importers/file_asset_importer.hpp
@@ -16,8 +16,7 @@
FileAssetResolver* m_FileAssetResolver;
public:
- FileAssetImporter(FileAsset* fileAsset,
- FileAssetResolver* assetResolver);
+ FileAssetImporter(FileAsset* fileAsset, FileAssetResolver* assetResolver);
void loadContents(const FileAssetContents& contents);
StatusCode resolve() override;
};
diff --git a/include/rive/importers/import_stack.hpp b/include/rive/importers/import_stack.hpp
index 23ba8ad..c662d12 100644
--- a/include/rive/importers/import_stack.hpp
+++ b/include/rive/importers/import_stack.hpp
@@ -35,8 +35,7 @@
auto stackObject = itr->second;
// Remove it from latests.
- auto itr = std::find(
- m_LastAdded.begin(), m_LastAdded.end(), stackObject);
+ auto itr = std::find(m_LastAdded.begin(), m_LastAdded.end(), stackObject);
if (itr != m_LastAdded.end()) {
m_LastAdded.erase(itr);
}
@@ -76,8 +75,7 @@
}
bool readNullObject() {
- for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend();
- itr++) {
+ for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend(); itr++) {
if ((*itr)->readNullObject()) {
return true;
}
diff --git a/include/rive/importers/keyed_property_importer.hpp b/include/rive/importers/keyed_property_importer.hpp
index 47bd92c..a07d50d 100644
--- a/include/rive/importers/keyed_property_importer.hpp
+++ b/include/rive/importers/keyed_property_importer.hpp
@@ -14,8 +14,7 @@
KeyedProperty* m_KeyedProperty;
public:
- KeyedPropertyImporter(LinearAnimation* animation,
- KeyedProperty* keyedProperty);
+ KeyedPropertyImporter(LinearAnimation* animation, KeyedProperty* keyedProperty);
void addKeyFrame(KeyFrame* keyFrame);
bool readNullObject() override;
};
diff --git a/include/rive/importers/state_machine_layer_importer.hpp b/include/rive/importers/state_machine_layer_importer.hpp
index a31e64a..886e41c 100644
--- a/include/rive/importers/state_machine_layer_importer.hpp
+++ b/include/rive/importers/state_machine_layer_importer.hpp
@@ -14,8 +14,7 @@
const Artboard* m_Artboard;
public:
- StateMachineLayerImporter(StateMachineLayer* layer,
- const Artboard* artboard);
+ StateMachineLayerImporter(StateMachineLayer* layer, const Artboard* artboard);
void addState(LayerState* state);
StatusCode resolve() override;
bool readNullObject() override;
diff --git a/include/rive/layout.hpp b/include/rive/layout.hpp
index 9eda329..57ed905 100644
--- a/include/rive/layout.hpp
+++ b/include/rive/layout.hpp
@@ -1,15 +1,7 @@
#ifndef _RIVE_LAYOUT_HPP_
#define _RIVE_LAYOUT_HPP_
namespace rive {
- enum class Fit : unsigned char {
- fill,
- contain,
- cover,
- fitWidth,
- fitHeight,
- none,
- scaleDown
- };
+ enum class Fit : unsigned char { fill, contain, cover, fitWidth, fitHeight, none, scaleDown };
class Alignment {
private:
diff --git a/include/rive/math/aabb.hpp b/include/rive/math/aabb.hpp
index 9f9151e..c61feda 100644
--- a/include/rive/math/aabb.hpp
+++ b/include/rive/math/aabb.hpp
@@ -8,14 +8,12 @@
namespace rive {
struct IAABB {
int32_t left, top, right, bottom;
-
+
constexpr int width() const { return right - left; }
constexpr int height() const { return bottom - top; }
constexpr bool empty() const { return width() <= 0 || height() <= 0; }
- IAABB inset(int dx, int dy) const {
- return {left + dx, top + dy, right - dx, bottom - dy};
- }
+ IAABB inset(int dx, int dy) const { return {left + dx, top + dy, right - dx, bottom - dy}; }
IAABB offset(int dx, int dy) const {
return {left + dx, top + dy, right + dx, bottom + dy};
}
@@ -32,25 +30,17 @@
public:
AABB() : buffer{0} {}
- AABB(const AABB& o) :
- minX(o.minX), minY(o.minY), maxX(o.maxX), maxY(o.maxY)
- {}
+ AABB(const AABB& o) : minX(o.minX), minY(o.minY), maxX(o.maxX), maxY(o.maxY) {}
AABB(float minX, float minY, float maxX, float maxY) :
- minX(minX), minY(minY), maxX(maxX), maxY(maxY)
- {}
+ minX(minX), minY(minY), maxX(maxX), maxY(maxY) {}
- AABB(const IAABB& o) :
- AABB((float)o.left, (float)o.top, (float)o.right, (float)o.bottom)
- {}
+ AABB(const IAABB& o) : AABB((float)o.left, (float)o.top, (float)o.right, (float)o.bottom) {}
bool operator==(const AABB& o) const {
- return minX == o.minX && minY == o.minY &&
- maxX == o.maxX && maxY == o.maxY;
+ return minX == o.minX && minY == o.minY && maxX == o.maxX && maxY == o.maxY;
}
- bool operator!=(const AABB& o) const {
- return !(*this == o);
- }
+ bool operator!=(const AABB& o) const { return !(*this == o); }
inline const float* values() const { return buffer; }
@@ -70,12 +60,8 @@
float width() const { return maxX - minX; }
float height() const { return maxY - minY; }
- Vec2D size() const {
- return {width(), height()};
- }
- Vec2D center() const {
- return {(minX + maxX) * 0.5f, (minY + maxY) * 0.5f};
- }
+ Vec2D size() const { return {width(), height()}; }
+ Vec2D center() const { return {(minX + maxX) * 0.5f, (minY + maxY) * 0.5f}; }
AABB inset(float dx, float dy) const {
AABB r = {minX + dx, minY + dy, maxX - dx, maxY - dy};
diff --git a/include/rive/math/color.hpp b/include/rive/math/color.hpp
index ca8144b..6ad5937 100644
--- a/include/rive/math/color.hpp
+++ b/include/rive/math/color.hpp
@@ -18,8 +18,7 @@
Color(int r, int g, int b, int a) :
m_Buffer{r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f} {}
- Color(int r, int g, int b) :
- m_Buffer{r / 255.0f, g / 255.0f, b / 255.0f, 1.0f} {}
+ Color(int r, int g, int b) : m_Buffer{r / 255.0f, g / 255.0f, b / 255.0f, 1.0f} {}
Color(float rgba) : m_Buffer{rgba, rgba, rgba, rgba} {}
@@ -28,8 +27,8 @@
float& operator[](std::size_t idx) { return m_Buffer[idx]; }
const float& operator[](std::size_t idx) const { return m_Buffer[idx]; }
bool operator==(const Color& b) const {
- return m_Buffer[0] == b[0] && m_Buffer[1] == b[1] &&
- m_Buffer[2] == b[2] && m_Buffer[3] == b[3];
+ return m_Buffer[0] == b[0] && m_Buffer[1] == b[1] && m_Buffer[2] == b[2] &&
+ m_Buffer[3] == b[3];
}
void set(float r, float g, float b, float a) {
@@ -42,8 +41,7 @@
void lerp(const Color& second, float amount) {
float iamount = 1.0f - amount;
for (int i = 0; i < 4; i++) {
- m_Buffer[i] =
- second.m_Buffer[i] * amount + m_Buffer[i] * iamount;
+ m_Buffer[i] = second.m_Buffer[i] * amount + m_Buffer[i] * iamount;
}
}
diff --git a/include/rive/math/hit_test.hpp b/include/rive/math/hit_test.hpp
index dadee50..f812cd8 100644
--- a/include/rive/math/hit_test.hpp
+++ b/include/rive/math/hit_test.hpp
@@ -14,35 +14,34 @@
namespace rive {
-class HitTester {
- std::vector<int> m_DW; // width * height delta-windings
- Vec2D m_First, m_Prev;
- Vec2D m_offset;
- float m_height;
- int m_IWidth, m_IHeight;
- bool m_ExpectsMove;
+ class HitTester {
+ std::vector<int> m_DW; // width * height delta-windings
+ Vec2D m_First, m_Prev;
+ Vec2D m_offset;
+ float m_height;
+ int m_IWidth, m_IHeight;
+ bool m_ExpectsMove;
- void recurse_cubic(Vec2D b, Vec2D c, Vec2D d, int count);
+ void recurse_cubic(Vec2D b, Vec2D c, Vec2D d, int count);
-public:
- HitTester() {}
- HitTester(const IAABB& area) { reset(area); }
+ public:
+ HitTester() {}
+ HitTester(const IAABB& area) { reset(area); }
- void reset();
- void reset(const IAABB& area);
+ void reset();
+ void reset(const IAABB& area);
- void move(Vec2D);
- void line(Vec2D);
- void quad(Vec2D, Vec2D);
- void cubic(Vec2D, Vec2D, Vec2D);
- void close();
-
- void addRect(const AABB&, const Mat2D&, PathDirection = PathDirection::ccw);
+ void move(Vec2D);
+ void line(Vec2D);
+ void quad(Vec2D, Vec2D);
+ void cubic(Vec2D, Vec2D, Vec2D);
+ void close();
- bool test(FillRule = rive::FillRule::nonZero);
-};
+ void addRect(const AABB&, const Mat2D&, PathDirection = PathDirection::ccw);
-}
+ bool test(FillRule = rive::FillRule::nonZero);
+ };
+
+} // namespace rive
#endif
-
diff --git a/include/rive/math/mat2d.hpp b/include/rive/math/mat2d.hpp
index 8d42f5f..c2876dc 100644
--- a/include/rive/math/mat2d.hpp
+++ b/include/rive/math/mat2d.hpp
@@ -13,9 +13,8 @@
public:
Mat2D() : m_Buffer{1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f} {}
Mat2D(const Mat2D& copy) = default;
- Mat2D(float x1, float y1, float x2, float y2, float tx, float ty)
- : m_Buffer{x1, y1, x2, y2, tx, ty}
- {}
+ Mat2D(float x1, float y1, float x2, float y2, float tx, float ty) :
+ m_Buffer{x1, y1, x2, y2, tx, ty} {}
inline const float* values() const { return m_Buffer; }
@@ -23,12 +22,8 @@
const float& operator[](std::size_t idx) const { return m_Buffer[idx]; }
static Mat2D fromRotation(float rad);
- static Mat2D fromScale(float sx, float sy) {
- return {sx, 0, 0, sy, 0, 0};
- }
- static Mat2D fromTranslate(float tx, float ty) {
- return {1, 0, 0, 1, tx, ty};
- }
+ static Mat2D fromScale(float sx, float sy) { return {sx, 0, 0, sy, 0, 0}; }
+ static Mat2D fromTranslate(float tx, float ty) { return {1, 0, 0, 1, tx, ty}; }
void scaleByValues(float sx, float sy);
@@ -41,8 +36,7 @@
static Mat2D multiply(const Mat2D& a, const Mat2D& b);
static bool invert(Mat2D& result, const Mat2D& a);
static void decompose(TransformComponents& result, const Mat2D& m);
- static void compose(Mat2D& result,
- const TransformComponents& components);
+ static void compose(Mat2D& result, const TransformComponents& components);
float xx() const { return m_Buffer[0]; }
float xy() const { return m_Buffer[1]; }
@@ -66,13 +60,11 @@
};
}
- inline Mat2D operator*(const Mat2D& a, const Mat2D& b) {
- return Mat2D::multiply(a, b);
- }
+ inline Mat2D operator*(const Mat2D& a, const Mat2D& b) { return Mat2D::multiply(a, b); }
inline bool operator==(const Mat2D& a, const Mat2D& b) {
- return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3] &&
- a[4] == b[4] && a[5] == b[5];
+ return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3] && a[4] == b[4] &&
+ a[5] == b[5];
}
} // namespace rive
#endif
diff --git a/include/rive/math/path_types.hpp b/include/rive/math/path_types.hpp
index d5f7846..d6d1711 100644
--- a/include/rive/math/path_types.hpp
+++ b/include/rive/math/path_types.hpp
@@ -9,27 +9,27 @@
namespace rive {
-enum class FillRule {
- nonZero,
- evenOdd,
-};
+ enum class FillRule {
+ nonZero,
+ evenOdd,
+ };
-enum class PathDirection {
- cw,
- ccw,
- // aliases
- clockwise = cw,
- counterclockwise = ccw,
-};
+ enum class PathDirection {
+ cw,
+ ccw,
+ // aliases
+ clockwise = cw,
+ counterclockwise = ccw,
+ };
-enum class PathVerb : uint8_t {
- move,
- line,
- quad,
- conic_unused, // so we match skia's order
- cubic,
- close,
-};
+ enum class PathVerb : uint8_t {
+ move,
+ line,
+ quad,
+ conic_unused, // so we match skia's order
+ cubic,
+ close,
+ };
-}
+} // namespace rive
#endif
diff --git a/include/rive/math/raw_path.hpp b/include/rive/math/raw_path.hpp
index 26b8ddb..0e06446 100644
--- a/include/rive/math/raw_path.hpp
+++ b/include/rive/math/raw_path.hpp
@@ -18,49 +18,47 @@
namespace rive {
-class RawPath {
-public:
- std::vector<Vec2D> m_Points;
- std::vector<PathVerb> m_Verbs;
-
- RawPath() {}
- ~RawPath() {}
+ class RawPath {
+ public:
+ std::vector<Vec2D> m_Points;
+ std::vector<PathVerb> m_Verbs;
- bool empty() const { return m_Points.empty(); }
- AABB bounds() const;
-
- void move(Vec2D);
- void line(Vec2D);
- void quad(Vec2D, Vec2D);
- void cubic(Vec2D, Vec2D, Vec2D);
- void close();
-
- RawPath transform(const Mat2D&) const;
- void transformInPlace(const Mat2D&);
-
- Span<const Vec2D> points() const { return toSpan(m_Points); }
- Span<Vec2D> points() { return toSpan(m_Points); }
+ RawPath() {}
+ ~RawPath() {}
- Span<const PathVerb> verbs() const { return toSpan(m_Verbs); }
- Span<PathVerb> verbs() { return toSpan(m_Verbs); }
+ bool empty() const { return m_Points.empty(); }
+ AABB bounds() const;
- // Syntactic sugar for x,y -vs- vec2d
+ void move(Vec2D);
+ void line(Vec2D);
+ void quad(Vec2D, Vec2D);
+ void cubic(Vec2D, Vec2D, Vec2D);
+ void close();
- void moveTo(float x, float y) { move({x, y}); }
- void lineTo(float x, float y) { line({x, y}); }
- void quadTo(float x, float y, float x1, float y1) {
- quad({x, y}, {x1, y1});
- }
- void cubicTo(float x, float y, float x1, float y1, float x2, float y2) {
- cubic({x, y}, {x1, y1}, {x2, y2});
- }
+ RawPath transform(const Mat2D&) const;
+ void transformInPlace(const Mat2D&);
- // Helpers for adding new contours
+ Span<const Vec2D> points() const { return toSpan(m_Points); }
+ Span<Vec2D> points() { return toSpan(m_Points); }
- void addRect(const AABB&, PathDirection = PathDirection::cw);
- void addOval(const AABB&, PathDirection = PathDirection::cw);
- void addPoly(Span<const Vec2D>, bool isClosed);
-};
+ Span<const PathVerb> verbs() const { return toSpan(m_Verbs); }
+ Span<PathVerb> verbs() { return toSpan(m_Verbs); }
+
+ // Syntactic sugar for x,y -vs- vec2d
+
+ void moveTo(float x, float y) { move({x, y}); }
+ void lineTo(float x, float y) { line({x, y}); }
+ void quadTo(float x, float y, float x1, float y1) { quad({x, y}, {x1, y1}); }
+ void cubicTo(float x, float y, float x1, float y1, float x2, float y2) {
+ cubic({x, y}, {x1, y1}, {x2, y2});
+ }
+
+ // Helpers for adding new contours
+
+ void addRect(const AABB&, PathDirection = PathDirection::cw);
+ void addOval(const AABB&, PathDirection = PathDirection::cw);
+ void addPoly(Span<const Vec2D>, bool isClosed);
+ };
} // namespace rive
diff --git a/include/rive/math/transform_components.hpp b/include/rive/math/transform_components.hpp
index 2087f30..44e9d4b 100644
--- a/include/rive/math/transform_components.hpp
+++ b/include/rive/math/transform_components.hpp
@@ -15,12 +15,7 @@
public:
TransformComponents() :
- m_X(0.0f),
- m_Y(0.0f),
- m_ScaleX(1.0f),
- m_ScaleY(1.0f),
- m_Rotation(0.0f),
- m_Skew(0.0f) {}
+ m_X(0.0f), m_Y(0.0f), m_ScaleX(1.0f), m_ScaleY(1.0f), m_Rotation(0.0f), m_Skew(0.0f) {}
TransformComponents(const TransformComponents& copy) :
m_X(copy.m_X),
m_Y(copy.m_Y),
@@ -51,8 +46,7 @@
result[1] = m_ScaleY;
}
- static void copy(TransformComponents& result,
- const TransformComponents& a) {
+ static void copy(TransformComponents& result, const TransformComponents& a) {
result.m_X = a.m_X;
result.m_Y = a.m_Y;
result.m_ScaleX = a.m_ScaleX;
diff --git a/include/rive/math/vec2d.hpp b/include/rive/math/vec2d.hpp
index 60e236b..1e462d8 100644
--- a/include/rive/math/vec2d.hpp
+++ b/include/rive/math/vec2d.hpp
@@ -21,13 +21,11 @@
float& operator[](std::size_t idx) { return m_Buffer[idx]; }
const float& operator[](std::size_t idx) const { return m_Buffer[idx]; }
- float lengthSquared() const {
- return x() * x() + y() * y();
- }
+ float lengthSquared() const { return x() * x() + y() * y(); }
float length() const;
Vec2D normalized() const;
- Vec2D operator-() const { return { -x(), -y() }; }
+ Vec2D operator-() const { return {-x(), -y()}; }
void operator*=(float s) {
m_Buffer[0] *= s;
@@ -41,18 +39,14 @@
static Vec2D lerp(const Vec2D& a, const Vec2D& b, float f);
static Vec2D transformDir(const Vec2D& a, const Mat2D& m);
- static float dot(Vec2D a, Vec2D b) {
- return a[0] * b[0] + a[1] * b[1];
- }
+ static float dot(Vec2D a, Vec2D b) { return a[0] * b[0] + a[1] * b[1]; }
static Vec2D scaleAndAdd(Vec2D a, Vec2D b, float scale) {
return {
a[0] + b[0] * scale,
a[1] + b[1] * scale,
};
}
- static float distance(const Vec2D& a, const Vec2D& b) {
- return (a - b).length();
- }
+ static float distance(const Vec2D& a, const Vec2D& b) { return (a - b).length(); }
static float distanceSquared(const Vec2D& a, const Vec2D& b) {
return (a - b).lengthSquared();
}
@@ -69,25 +63,13 @@
}
};
- inline Vec2D operator*(const Vec2D& v, float s) {
- return { v[0] * s, v[1] * s };
- }
- inline Vec2D operator*(float s, const Vec2D& v) {
- return { v[0] * s, v[1] * s };
- }
- inline Vec2D operator/(const Vec2D& v, float s) {
- return { v[0] / s, v[1] / s };
- }
+ inline Vec2D operator*(const Vec2D& v, float s) { return {v[0] * s, v[1] * s}; }
+ inline Vec2D operator*(float s, const Vec2D& v) { return {v[0] * s, v[1] * s}; }
+ inline Vec2D operator/(const Vec2D& v, float s) { return {v[0] / s, v[1] / s}; }
- inline Vec2D operator+(const Vec2D& a, const Vec2D& b) {
- return {a[0] + b[0], a[1] + b[1]};
- }
+ inline Vec2D operator+(const Vec2D& a, const Vec2D& b) { return {a[0] + b[0], a[1] + b[1]}; }
- inline bool operator==(const Vec2D& a, const Vec2D& b) {
- return a[0] == b[0] && a[1] == b[1];
- }
- inline bool operator!=(const Vec2D& a, const Vec2D& b) {
- return a[0] != b[0] || a[1] != b[1];
- }
+ inline bool operator==(const Vec2D& a, const Vec2D& b) { return a[0] == b[0] && a[1] == b[1]; }
+ inline bool operator!=(const Vec2D& a, const Vec2D& b) { return a[0] != b[0] || a[1] != b[1]; }
} // namespace rive
#endif
diff --git a/include/rive/refcnt.hpp b/include/rive/refcnt.hpp
index 7edae60..67bbcfb 100644
--- a/include/rive/refcnt.hpp
+++ b/include/rive/refcnt.hpp
@@ -27,153 +27,140 @@
namespace rive {
-class RefCnt {
-public:
- RefCnt() : m_refcnt(1) {}
+ class RefCnt {
+ public:
+ RefCnt() : m_refcnt(1) {}
- virtual ~RefCnt() {
- assert(this->debugging_refcnt() == 1);
- }
+ virtual ~RefCnt() { assert(this->debugging_refcnt() == 1); }
- void ref() const {
- (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed);
- }
+ void ref() const { (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed); }
- void unref() const {
- if (1 == m_refcnt.fetch_add(-1, std::memory_order_acq_rel)) {
+ void unref() const {
+ if (1 == m_refcnt.fetch_add(-1, std::memory_order_acq_rel)) {
#ifndef NDEBUG
- // we restore the "1" in debug builds just to make our destructor happy
- (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed);
+ // we restore the "1" in debug builds just to make our destructor happy
+ (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed);
#endif
- delete this;
+ delete this;
+ }
+ }
+
+ // not reliable in actual threaded scenarios, but useful (perhaps) for debugging
+ int32_t debugging_refcnt() const { return m_refcnt.load(std::memory_order_relaxed); }
+
+ private:
+ // mutable, so can be changed even on a const object
+ mutable std::atomic<int32_t> m_refcnt;
+
+ RefCnt(RefCnt&&) = delete;
+ RefCnt(const RefCnt&) = delete;
+ RefCnt& operator=(RefCnt&&) = delete;
+ RefCnt& operator=(const RefCnt&) = delete;
+ };
+
+ template <typename T> static inline T* safe_ref(T* obj) {
+ if (obj) {
+ obj->ref();
+ }
+ return obj;
+ }
+
+ template <typename T> static inline void safe_unref(T* obj) {
+ if (obj) {
+ obj->unref();
}
}
- // not reliable in actual threaded scenarios, but useful (perhaps) for debugging
- int32_t debugging_refcnt() const {
- return m_refcnt.load(std::memory_order_relaxed);
- }
+ // rcp : smart point template for holding subclasses of RefCnt
-private:
- // mutable, so can be changed even on a const object
- mutable std::atomic<int32_t> m_refcnt;
-
- RefCnt(RefCnt&&) = delete;
- RefCnt(const RefCnt&) = delete;
- RefCnt& operator=(RefCnt&&) = delete;
- RefCnt& operator=(const RefCnt&) = delete;
-};
+ template <typename T> class rcp {
+ public:
+ constexpr rcp() : m_ptr(nullptr) {}
+ constexpr rcp(std::nullptr_t) : m_ptr(nullptr) {}
+ explicit rcp(T* ptr) : m_ptr(ptr) {}
-template <typename T> static inline T* safe_ref(T* obj) {
- if (obj) {
- obj->ref();
- }
- return obj;
-}
+ rcp(const rcp<T>& other) : m_ptr(safe_ref(other.get())) {}
+ rcp(rcp<T>&& other) : m_ptr(other.release()) {}
-template <typename T> static inline void safe_unref(T* obj) {
- if (obj) {
- obj->unref();
- }
-}
+ /**
+ * Calls unref() on the underlying object pointer.
+ */
+ ~rcp() { safe_unref(m_ptr); }
-// rcp : smart point template for holding subclasses of RefCnt
-
-template <typename T> class rcp {
-public:
- constexpr rcp() : m_ptr(nullptr) {}
- constexpr rcp(std::nullptr_t) : m_ptr(nullptr) {}
- explicit rcp(T* ptr) : m_ptr(ptr) {}
-
- rcp(const rcp<T>& other) : m_ptr(safe_ref(other.get())) {}
- rcp(rcp<T>&& other) : m_ptr(other.release()) {}
-
- /**
- * Calls unref() on the underlying object pointer.
- */
- ~rcp() {
- safe_unref(m_ptr);
- }
-
- rcp<T>& operator=(std::nullptr_t) { this->reset(); return *this; }
-
- rcp<T>& operator=(const rcp<T>& other) {
- if (this != &other) {
- this->reset(safe_ref(other.get()));
+ rcp<T>& operator=(std::nullptr_t) {
+ this->reset();
+ return *this;
}
- return *this;
+
+ rcp<T>& operator=(const rcp<T>& other) {
+ if (this != &other) {
+ this->reset(safe_ref(other.get()));
+ }
+ return *this;
+ }
+
+ rcp<T>& operator=(rcp<T>&& other) {
+ this->reset(other.release());
+ return *this;
+ }
+
+ T& operator*() const {
+ assert(this->get() != nullptr);
+ return *this->get();
+ }
+
+ explicit operator bool() const { return this->get() != nullptr; }
+
+ T* get() const { return m_ptr; }
+ T* operator->() const { return m_ptr; }
+
+ // Unrefs the current pointer, and accepts the new pointer, but
+ // DOES NOT increment ownership of the new pointer.
+ void reset(T* ptr = nullptr) {
+ // Calling m_ptr->unref() may call this->~() or this->reset(T*).
+ // http://wg21.cmeerw.net/lwg/issue998
+ // http://wg21.cmeerw.net/lwg/issue2262
+ T* oldPtr = m_ptr;
+ m_ptr = ptr;
+ safe_unref(oldPtr);
+ }
+
+ // This returns the bare point WITHOUT CHANGING ITS REFCNT, but removes it
+ // from this object, so the caller must manually manage its count.
+ T* release() {
+ T* ptr = m_ptr;
+ m_ptr = nullptr;
+ return ptr;
+ }
+
+ void swap(rcp<T>& other) { std::swap(m_ptr, other.m_ptr); }
+
+ private:
+ T* m_ptr;
+ };
+
+ template <typename T> inline void swap(rcp<T>& a, rcp<T>& b) { a.swap(b); }
+
+ // == variants
+
+ template <typename T> inline bool operator==(const rcp<T>& a, std::nullptr_t) { return !a; }
+ template <typename T> inline bool operator==(std::nullptr_t, const rcp<T>& b) { return !b; }
+ template <typename T, typename U> inline bool operator==(const rcp<T>& a, const rcp<U>& b) {
+ return a.get() == b.get();
}
- rcp<T>& operator=(rcp<T>&& other) {
- this->reset(other.release());
- return *this;
+ // != variants
+
+ template <typename T> inline bool operator!=(const rcp<T>& a, std::nullptr_t) {
+ return static_cast<bool>(a);
}
-
- T& operator*() const {
- assert(this->get() != nullptr);
- return *this->get();
+ template <typename T> inline bool operator!=(std::nullptr_t, const rcp<T>& b) {
+ return static_cast<bool>(b);
}
-
- explicit operator bool() const { return this->get() != nullptr; }
-
- T* get() const { return m_ptr; }
- T* operator->() const { return m_ptr; }
-
- // Unrefs the current pointer, and accepts the new pointer, but
- // DOES NOT increment ownership of the new pointer.
- void reset(T* ptr = nullptr) {
- // Calling m_ptr->unref() may call this->~() or this->reset(T*).
- // http://wg21.cmeerw.net/lwg/issue998
- // http://wg21.cmeerw.net/lwg/issue2262
- T* oldPtr = m_ptr;
- m_ptr = ptr;
- safe_unref(oldPtr);
+ template <typename T, typename U> inline bool operator!=(const rcp<T>& a, const rcp<U>& b) {
+ return a.get() != b.get();
}
- // This returns the bare point WITHOUT CHANGING ITS REFCNT, but removes it
- // from this object, so the caller must manually manage its count.
- T* release() {
- T* ptr = m_ptr;
- m_ptr = nullptr;
- return ptr;
- }
-
- void swap(rcp<T>& other) {
- std::swap(m_ptr, other.m_ptr);
- }
-
-private:
- T* m_ptr;
-};
-
-template <typename T> inline void swap(rcp<T>& a, rcp<T>& b) {
- a.swap(b);
-}
-
-// == variants
-
-template <typename T> inline bool operator==(const rcp<T>& a, std::nullptr_t) {
- return !a;
-}
-template <typename T> inline bool operator==(std::nullptr_t, const rcp<T>& b) {
- return !b;
-}
-template <typename T, typename U> inline bool operator==(const rcp<T>& a, const rcp<U>& b) {
- return a.get() == b.get();
-}
-
-// != variants
-
-template <typename T> inline bool operator!=(const rcp<T>& a, std::nullptr_t) {
- return static_cast<bool>(a);
-}
-template <typename T> inline bool operator!=(std::nullptr_t, const rcp<T>& b) {
- return static_cast<bool>(b);
-}
-template <typename T, typename U> inline bool operator!=(const rcp<T>& a, const rcp<U>& b) {
- return a.get() != b.get();
-}
-
} // namespace rive
#endif
diff --git a/include/rive/renderer.hpp b/include/rive/renderer.hpp
index 8c9a3f6..9bcb3ee 100644
--- a/include/rive/renderer.hpp
+++ b/include/rive/renderer.hpp
@@ -22,6 +22,7 @@
// A render buffer holds an immutable array of values
class RenderBuffer : public RefCnt {
const size_t m_Count;
+
public:
RenderBuffer(size_t count) : m_Count(count) {}
@@ -38,7 +39,7 @@
clamp,
repeat,
mirror,
- decal, // fill outside the domain with transparent
+ decal, // fill outside the domain with transparent
};
/*
@@ -51,24 +52,29 @@
*/
class RenderShader : public RefCnt {};
- extern rcp<RenderShader> makeLinearGradient(float sx, float sy,
- float ex, float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
+ extern rcp<RenderShader> makeLinearGradient(float sx,
+ float sy,
+ float ex,
+ float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
int count,
RenderTileMode,
const Mat2D* localMatrix = nullptr);
- extern rcp<RenderShader> makeRadialGradient(float cx, float cy, float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
+ extern rcp<RenderShader> makeRadialGradient(float cx,
+ float cy,
+ float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
int count,
RenderTileMode,
const Mat2D* localMatrix = nullptr);
- extern rcp<RenderShader> makeSweepGradient(float cx, float cy,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
+ extern rcp<RenderShader> makeSweepGradient(float cx,
+ float cy,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
int count,
const Mat2D* localMatrix = nullptr);
@@ -95,8 +101,9 @@
virtual bool decode(Span<const uint8_t>) = 0;
int width() const { return m_Width; }
int height() const { return m_Height; }
-
- virtual rcp<RenderShader> makeShader(RenderTileMode tx, RenderTileMode ty,
+
+ virtual rcp<RenderShader> makeShader(RenderTileMode tx,
+ RenderTileMode ty,
const Mat2D* localMatrix = nullptr) const = 0;
};
@@ -107,8 +114,7 @@
addRenderPath(path->renderPath(), transform);
}
- virtual void addRenderPath(RenderPath* path,
- const Mat2D& transform) = 0;
+ virtual void addRenderPath(RenderPath* path, const Mat2D& transform) = 0;
};
class Renderer {
@@ -139,16 +145,12 @@
const AABB& frame,
const AABB& content);
- void align(Fit fit,
- const Alignment& alignment,
- const AABB& frame,
- const AABB& content);
+ void align(Fit fit, const Alignment& alignment, const AABB& frame, const AABB& content);
};
// Returns a full-formed RenderPath -- can be treated as immutable
- extern RenderPath* makeRenderPath(Span<const Vec2D> points,
- Span<const uint8_t> verbs,
- FillRule);
+ extern RenderPath*
+ makeRenderPath(Span<const Vec2D> points, Span<const uint8_t> verbs, FillRule);
extern RenderPath* makeRenderPath();
extern RenderPaint* makeRenderPaint();
diff --git a/include/rive/rive_types.hpp b/include/rive/rive_types.hpp
index 0f25495..f3de296 100644
--- a/include/rive/rive_types.hpp
+++ b/include/rive/rive_types.hpp
@@ -15,21 +15,21 @@
// ... they just can't set them inconsistently.
#ifdef NDEBUG
- // we're in release mode
- #ifdef DEBUG
- #error "can't define both DEBUG and NDEBUG"
- #endif
- #ifndef RELEASE
- #define RELEASE
- #endif
+// we're in release mode
+#ifdef DEBUG
+#error "can't define both DEBUG and NDEBUG"
+#endif
+#ifndef RELEASE
+#define RELEASE
+#endif
#else
- // we're in debug mode
- #ifdef RELEASE
- #error "can't define RELEASE and not NDEBUG"
- #endif
- #ifndef DEBUG
- #define DEBUG
- #endif
+// we're in debug mode
+#ifdef RELEASE
+#error "can't define RELEASE and not NDEBUG"
+#endif
+#ifndef DEBUG
+#define DEBUG
+#endif
#endif
// We really like these headers, so we include them all the time.
@@ -40,4 +40,4 @@
#include <memory>
#include <type_traits>
-#endif // rive_types
+#endif // rive_types
diff --git a/include/rive/runtime_header.hpp b/include/rive/runtime_header.hpp
index bdfb755..636befc 100644
--- a/include/rive/runtime_header.hpp
+++ b/include/rive/runtime_header.hpp
@@ -64,8 +64,7 @@
}
std::vector<int> propertyKeys;
- for (int propertyKey = (int)reader.readVarUint64();
- propertyKey != 0;
+ for (int propertyKey = (int)reader.readVarUint64(); propertyKey != 0;
propertyKey = (int)reader.readVarUint64())
{
propertyKeys.push_back(propertyKey);
diff --git a/include/rive/shapes/cubic_vertex.hpp b/include/rive/shapes/cubic_vertex.hpp
index b4ee4e4..a31e00f 100644
--- a/include/rive/shapes/cubic_vertex.hpp
+++ b/include/rive/shapes/cubic_vertex.hpp
@@ -26,8 +26,7 @@
void xChanged() override;
void yChanged() override;
- void deform(const Mat2D& worldTransform,
- const float* boneTransforms) override;
+ void deform(const Mat2D& worldTransform, const float* boneTransforms) override;
};
} // namespace rive
diff --git a/include/rive/shapes/mesh.hpp b/include/rive/shapes/mesh.hpp
index a92c96d..e63f444 100644
--- a/include/rive/shapes/mesh.hpp
+++ b/include/rive/shapes/mesh.hpp
@@ -29,10 +29,7 @@
void copyTriangleIndexBytes(const MeshBase& object) override;
void buildDependencies() override;
void update(ComponentDirt value) override;
- void draw(Renderer* renderer,
- const RenderImage* image,
- BlendMode blendMode,
- float opacity);
+ void draw(Renderer* renderer, const RenderImage* image, BlendMode blendMode, float opacity);
void updateVertexRenderBuffer(Renderer* renderer);
void markSkinDirty() override;
diff --git a/include/rive/shapes/metrics_path.hpp b/include/rive/shapes/metrics_path.hpp
index a6c696c..c504c3a 100644
--- a/include/rive/shapes/metrics_path.hpp
+++ b/include/rive/shapes/metrics_path.hpp
@@ -11,8 +11,7 @@
struct CubicSegment {
float t;
float length;
- CubicSegment(float tValue, float lengthValue) :
- t(tValue), length(lengthValue) {}
+ CubicSegment(float tValue, float lengthValue) : t(tValue), length(lengthValue) {}
};
struct PathPart {
@@ -30,8 +29,7 @@
// this part.
unsigned char numSegments;
- PathPart(unsigned char t, unsigned char l) :
- type(t), offset(l), numSegments(0) {}
+ PathPart(unsigned char t, unsigned char l) : type(t), offset(l), numSegments(0) {}
};
class MetricsPath : public CommandPath {
@@ -51,8 +49,7 @@
void reset() override;
void moveTo(float x, float y) override;
void lineTo(float x, float y) override;
- void cubicTo(
- float ox, float oy, float ix, float iy, float x, float y) override;
+ void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
void close() override;
float length() const { return m_ComputedLength; }
@@ -60,21 +57,14 @@
/// Add commands to the result RenderPath that will draw the segment
/// from startLength to endLength of this MetricsPath. Requires
/// computeLength be called prior to trimming.
- void trim(float startLength,
- float endLength,
- bool moveTo,
- RenderPath* result);
+ void trim(float startLength, float endLength, bool moveTo, RenderPath* result);
private:
float computeLength(const Mat2D& transform);
/// Extract a single segment from startT to endT as render commands
/// added to result.
- void extractSubPart(int index,
- float startT,
- float endT,
- bool moveTo,
- RenderPath* result);
+ void extractSubPart(int index, float startT, float endT, bool moveTo, RenderPath* result);
};
class OnlyMetricsPath : public MetricsPath {
@@ -102,8 +92,7 @@
void reset() override;
void moveTo(float x, float y) override;
void lineTo(float x, float y) override;
- void cubicTo(
- float ox, float oy, float ix, float iy, float x, float y) override;
+ void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
void close() override;
};
} // namespace rive
diff --git a/include/rive/shapes/paint/linear_gradient.hpp b/include/rive/shapes/paint/linear_gradient.hpp
index d89bfcf..e763b4c 100644
--- a/include/rive/shapes/paint/linear_gradient.hpp
+++ b/include/rive/shapes/paint/linear_gradient.hpp
@@ -32,8 +32,8 @@
void renderOpacityChanged() override;
bool internalIsTranslucent() const override;
- virtual void makeGradient(Vec2D start, Vec2D end,
- const ColorInt[], const float[], size_t count);
+ virtual void
+ makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count);
};
} // namespace rive
diff --git a/include/rive/shapes/paint/radial_gradient.hpp b/include/rive/shapes/paint/radial_gradient.hpp
index 680f8fc..f0a1ef7 100644
--- a/include/rive/shapes/paint/radial_gradient.hpp
+++ b/include/rive/shapes/paint/radial_gradient.hpp
@@ -4,8 +4,8 @@
namespace rive {
class RadialGradient : public RadialGradientBase {
public:
- void makeGradient(Vec2D start, Vec2D end,
- const ColorInt[], const float[], size_t count) override;
+ void makeGradient(
+ Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count) override;
};
} // namespace rive
diff --git a/include/rive/shapes/paint/shape_paint.hpp b/include/rive/shapes/paint/shape_paint.hpp
index f08feec..ed6b3b7 100644
--- a/include/rive/shapes/paint/shape_paint.hpp
+++ b/include/rive/shapes/paint/shape_paint.hpp
@@ -18,9 +18,7 @@
StatusCode onAddedClean(CoreContext* context) override;
float renderOpacity() const { return m_PaintMutator->renderOpacity(); }
- void renderOpacity(float value) {
- m_PaintMutator->renderOpacity(value);
- }
+ void renderOpacity(float value) { m_PaintMutator->renderOpacity(value); }
void blendMode(BlendMode value);
@@ -38,9 +36,7 @@
/// RadialGradient.
Component* paint() const { return m_PaintMutator->component(); }
- bool isTranslucent() const {
- return !this->isVisible() || m_PaintMutator->isTranslucent();
- }
+ bool isTranslucent() const { return !this->isVisible() || m_PaintMutator->isTranslucent(); }
};
} // namespace rive
diff --git a/include/rive/shapes/paint/shape_paint_mutator.hpp b/include/rive/shapes/paint/shape_paint_mutator.hpp
index e985db7..dea8ae5 100644
--- a/include/rive/shapes/paint/shape_paint_mutator.hpp
+++ b/include/rive/shapes/paint/shape_paint_mutator.hpp
@@ -27,9 +27,7 @@
Component* component() const { return m_Component; }
- bool isTranslucent() const {
- return m_RenderOpacity < 1 || this->internalIsTranslucent();
- }
+ bool isTranslucent() const { return m_RenderOpacity < 1 || this->internalIsTranslucent(); }
};
} // namespace rive
#endif
diff --git a/include/rive/shapes/path_space.hpp b/include/rive/shapes/path_space.hpp
index 73fd815..395dbe6 100644
--- a/include/rive/shapes/path_space.hpp
+++ b/include/rive/shapes/path_space.hpp
@@ -13,48 +13,41 @@
};
inline constexpr PathSpace operator&(PathSpace lhs, PathSpace rhs) {
- return static_cast<PathSpace>(
- static_cast<std::underlying_type<PathSpace>::type>(lhs) &
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) &
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
}
inline constexpr PathSpace operator^(PathSpace lhs, PathSpace rhs) {
- return static_cast<PathSpace>(
- static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
}
inline constexpr PathSpace operator|(PathSpace lhs, PathSpace rhs) {
- return static_cast<PathSpace>(
- static_cast<std::underlying_type<PathSpace>::type>(lhs) |
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) |
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
}
inline constexpr PathSpace operator~(PathSpace rhs) {
- return static_cast<PathSpace>(
- ~static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ return static_cast<PathSpace>(~static_cast<std::underlying_type<PathSpace>::type>(rhs));
}
inline PathSpace& operator|=(PathSpace& lhs, PathSpace rhs) {
- lhs = static_cast<PathSpace>(
- static_cast<std::underlying_type<PathSpace>::type>(lhs) |
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) |
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
return lhs;
}
inline PathSpace& operator&=(PathSpace& lhs, PathSpace rhs) {
- lhs = static_cast<PathSpace>(
- static_cast<std::underlying_type<PathSpace>::type>(lhs) &
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) &
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
return lhs;
}
inline PathSpace& operator^=(PathSpace& lhs, PathSpace rhs) {
- lhs = static_cast<PathSpace>(
- static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
return lhs;
}
diff --git a/include/rive/shapes/shape.hpp b/include/rive/shapes/shape.hpp
index 4112d46..f8933bb 100644
--- a/include/rive/shapes/shape.hpp
+++ b/include/rive/shapes/shape.hpp
@@ -29,9 +29,7 @@
void draw(Renderer* renderer) override;
Core* hitTest(HitInfo*, const Mat2D&) override;
- PathComposer* pathComposer() const {
- return (PathComposer*)&m_PathComposer;
- }
+ PathComposer* pathComposer() const { return (PathComposer*)&m_PathComposer; }
void pathChanged();
void addDefaultPathSpace(PathSpace space);
diff --git a/include/rive/shapes/vertex.hpp b/include/rive/shapes/vertex.hpp
index ec09902..308fe07 100644
--- a/include/rive/shapes/vertex.hpp
+++ b/include/rive/shapes/vertex.hpp
@@ -13,8 +13,7 @@
public:
template <typename T> T* weight() { return m_Weight->as<T>(); }
- virtual void deform(const Mat2D& worldTransform,
- const float* boneTransforms);
+ virtual void deform(const Mat2D& worldTransform, const float* boneTransforms);
bool hasWeight() { return m_Weight != nullptr; }
Vec2D renderTranslation();
diff --git a/include/rive/span.hpp b/include/rive/span.hpp
index abfae67..c7e867b 100644
--- a/include/rive/span.hpp
+++ b/include/rive/span.hpp
@@ -15,58 +15,56 @@
namespace rive {
-template <typename T> class Span {
- T* m_Ptr;
- size_t m_Size;
+ template <typename T> class Span {
+ T* m_Ptr;
+ size_t m_Size;
-public:
- Span() : m_Ptr(nullptr), m_Size(0) {}
- Span(T* ptr, size_t size) : m_Ptr(ptr), m_Size(size) {
- assert(ptr <= ptr + size);
- }
+ public:
+ Span() : m_Ptr(nullptr), m_Size(0) {}
+ Span(T* ptr, size_t size) : m_Ptr(ptr), m_Size(size) { assert(ptr <= ptr + size); }
- // Handle Span<foo> --> Span<const foo>
- template <typename U,
- typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
- constexpr Span(const Span<U>& that) : Span(that.data(), that.size()) {}
- constexpr Span(const Span&) = default;
+ // Handle Span<foo> --> Span<const foo>
+ template <typename U,
+ typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
+ constexpr Span(const Span<U>& that) : Span(that.data(), that.size()) {}
+ constexpr Span(const Span&) = default;
- constexpr T& operator[](size_t index) const {
- assert(index < m_Size);
- return m_Ptr[index];
- }
+ constexpr T& operator[](size_t index) const {
+ assert(index < m_Size);
+ return m_Ptr[index];
+ }
- constexpr T* data() const { return m_Ptr; }
- constexpr size_t size() const { return m_Size; }
- constexpr bool empty() const { return m_Size == 0; }
-
- constexpr T* begin() const { return m_Ptr; }
- constexpr T* end() const { return m_Ptr + m_Size; }
+ constexpr T* data() const { return m_Ptr; }
+ constexpr size_t size() const { return m_Size; }
+ constexpr bool empty() const { return m_Size == 0; }
- constexpr T& front() const { return (*this)[0]; }
- constexpr T& back() const { return (*this)[m_Size-1]; }
+ constexpr T* begin() const { return m_Ptr; }
+ constexpr T* end() const { return m_Ptr + m_Size; }
- // returns byte-size of the entire span
- constexpr size_t size_bytes() const { return m_Size * sizeof(T); }
+ constexpr T& front() const { return (*this)[0]; }
+ constexpr T& back() const { return (*this)[m_Size - 1]; }
- constexpr int count() const {
- const int n = static_cast<int>(m_Size);
- assert(n >= 0);
- return n;
- }
+ // returns byte-size of the entire span
+ constexpr size_t size_bytes() const { return m_Size * sizeof(T); }
- constexpr Span<T> subset(size_t offset, size_t size) const {
- assert(offset <= m_Size);
- assert(size <= m_Size - offset);
- return {m_Ptr + offset, size};
- }
-};
+ constexpr int count() const {
+ const int n = static_cast<int>(m_Size);
+ assert(n >= 0);
+ return n;
+ }
-template <typename Container>
-inline auto toSpan(Container& c)
+ constexpr Span<T> subset(size_t offset, size_t size) const {
+ assert(offset <= m_Size);
+ assert(size <= m_Size - offset);
+ return {m_Ptr + offset, size};
+ }
+ };
+
+ template <typename Container>
+ inline auto toSpan(Container& c)
-> Span<typename std::remove_reference<decltype(*(c.data()))>::type> {
- return {c.data(), c.size()};
-}
+ return {c.data(), c.size()};
+ }
} // namespace rive
diff --git a/include/rive/status_code.hpp b/include/rive/status_code.hpp
index e6f7847..2d50dbc 100644
--- a/include/rive/status_code.hpp
+++ b/include/rive/status_code.hpp
@@ -4,11 +4,6 @@
#include "rive/rive_types.hpp"
namespace rive {
- enum class StatusCode : unsigned char {
- Ok,
- MissingObject,
- InvalidObject,
- FailedInversion
- };
+ enum class StatusCode : unsigned char { Ok, MissingObject, InvalidObject, FailedInversion };
}
#endif
diff --git a/include/rive/transform_component.hpp b/include/rive/transform_component.hpp
index 3ee689a..9990146 100644
--- a/include/rive/transform_component.hpp
+++ b/include/rive/transform_component.hpp
@@ -15,9 +15,7 @@
public:
#ifdef TESTING
- const std::vector<Constraint*>& constraints() const {
- return m_Constraints;
- }
+ const std::vector<Constraint*>& constraints() const { return m_Constraints; }
#endif
StatusCode onAddedClean(CoreContext* context) override;
void buildDependencies() override;
diff --git a/src/animation/animation_state_instance.cpp b/src/animation/animation_state_instance.cpp
index 09619f1..9d345e6 100644
--- a/src/animation/animation_state_instance.cpp
+++ b/src/animation/animation_state_instance.cpp
@@ -4,9 +4,7 @@
using namespace rive;
AnimationStateInstance::AnimationStateInstance(const AnimationState* state) :
- StateInstance(state),
- m_AnimationInstance(state->animation()),
- m_KeepGoing(true) {}
+ StateInstance(state), m_AnimationInstance(state->animation()), m_KeepGoing(true) {}
void AnimationStateInstance::advance(float seconds, SMIInput** inputs) {
m_KeepGoing = m_AnimationInstance.advance(seconds);
diff --git a/src/animation/blend_animation.cpp b/src/animation/blend_animation.cpp
index fe46a0d..737491d 100644
--- a/src/animation/blend_animation.cpp
+++ b/src/animation/blend_animation.cpp
@@ -7,16 +7,14 @@
using namespace rive;
StatusCode BlendAnimation::import(ImportStack& importStack) {
- auto importer =
- importStack.latest<LayerStateImporter>(LayerStateBase::typeKey);
+ auto importer = importStack.latest<LayerStateImporter>(LayerStateBase::typeKey);
if (importer == nullptr) {
return StatusCode::MissingObject;
} else if (!importer->addBlendAnimation(this)) {
return StatusCode::InvalidObject;
}
- auto artboardImporter =
- importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
if (artboardImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/blend_animation_1d.cpp b/src/animation/blend_animation_1d.cpp
index 338dcca..90c7f25 100644
--- a/src/animation/blend_animation_1d.cpp
+++ b/src/animation/blend_animation_1d.cpp
@@ -2,10 +2,6 @@
using namespace rive;
-StatusCode BlendAnimation1D::onAddedDirty(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode BlendAnimation1D::onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
-StatusCode BlendAnimation1D::onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
-}
\ No newline at end of file
+StatusCode BlendAnimation1D::onAddedClean(CoreContext* context) { return StatusCode::Ok; }
\ No newline at end of file
diff --git a/src/animation/blend_animation_direct.cpp b/src/animation/blend_animation_direct.cpp
index 1ebc63d..0fe8e1b 100644
--- a/src/animation/blend_animation_direct.cpp
+++ b/src/animation/blend_animation_direct.cpp
@@ -5,24 +5,18 @@
using namespace rive;
-StatusCode BlendAnimationDirect::onAddedDirty(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode BlendAnimationDirect::onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
-StatusCode BlendAnimationDirect::onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode BlendAnimationDirect::onAddedClean(CoreContext* context) { return StatusCode::Ok; }
StatusCode BlendAnimationDirect::import(ImportStack& importStack) {
- auto stateMachineImporter =
- importStack.latest<StateMachineImporter>(StateMachine::typeKey);
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
if (stateMachineImporter == nullptr) {
return StatusCode::MissingObject;
}
// Make sure the inputId doesn't overflow the input buffer.
- if ((size_t)inputId() >= stateMachineImporter->stateMachine()->inputCount())
- {
+ if ((size_t)inputId() >= stateMachineImporter->stateMachine()->inputCount()) {
return StatusCode::InvalidObject;
}
auto input = stateMachineImporter->stateMachine()->input((size_t)inputId());
diff --git a/src/animation/blend_state.cpp b/src/animation/blend_state.cpp
index fdfb41a..321926b 100644
--- a/src/animation/blend_state.cpp
+++ b/src/animation/blend_state.cpp
@@ -11,7 +11,6 @@
void BlendState::addAnimation(BlendAnimation* animation) {
// Assert it's not already contained.
- assert(std::find(m_Animations.begin(), m_Animations.end(), animation) ==
- m_Animations.end());
+ assert(std::find(m_Animations.begin(), m_Animations.end(), animation) == m_Animations.end());
m_Animations.push_back(animation);
}
\ No newline at end of file
diff --git a/src/animation/blend_state_1d.cpp b/src/animation/blend_state_1d.cpp
index 497790c..f531b9a 100644
--- a/src/animation/blend_state_1d.cpp
+++ b/src/animation/blend_state_1d.cpp
@@ -6,13 +6,10 @@
using namespace rive;
-StateInstance* BlendState1D::makeInstance() const {
- return new BlendState1DInstance(this);
-}
+StateInstance* BlendState1D::makeInstance() const { return new BlendState1DInstance(this); }
StatusCode BlendState1D::import(ImportStack& importStack) {
- auto stateMachineImporter =
- importStack.latest<StateMachineImporter>(StateMachine::typeKey);
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
if (stateMachineImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -23,8 +20,7 @@
if ((size_t)inputId() >= stateMachineImporter->stateMachine()->inputCount()) {
return StatusCode::InvalidObject;
}
- auto input =
- stateMachineImporter->stateMachine()->input((size_t)inputId());
+ auto input = stateMachineImporter->stateMachine()->input((size_t)inputId());
if (input == nullptr || !input->is<StateMachineNumber>()) {
return StatusCode::InvalidObject;
}
diff --git a/src/animation/blend_state_1d_instance.cpp b/src/animation/blend_state_1d_instance.cpp
index a186f50..a98c631 100644
--- a/src/animation/blend_state_1d_instance.cpp
+++ b/src/animation/blend_state_1d_instance.cpp
@@ -31,8 +31,7 @@
}
void BlendState1DInstance::advance(float seconds, SMIInput** inputs) {
- BlendStateInstance<BlendState1D, BlendAnimation1D>::advance(seconds,
- inputs);
+ BlendStateInstance<BlendState1D, BlendAnimation1D>::advance(seconds, inputs);
auto id = state()->as<BlendState1D>()->inputId();
float value = 0.0f;
@@ -43,16 +42,13 @@
}
int index = animationIndex(value);
auto animationsCount = static_cast<int>(m_AnimationInstances.size());
- m_To = index >= 0 && index < animationsCount ? &m_AnimationInstances[index]
- : nullptr;
- m_From = index - 1 >= 0 && index - 1 < animationsCount
- ? &m_AnimationInstances[index - 1]
- : nullptr;
+ m_To = index >= 0 && index < animationsCount ? &m_AnimationInstances[index] : nullptr;
+ m_From =
+ index - 1 >= 0 && index - 1 < animationsCount ? &m_AnimationInstances[index - 1] : nullptr;
float mix, mixFrom;
auto toValue = m_To == nullptr ? 0.0f : m_To->blendAnimation()->value();
- auto fromValue =
- m_From == nullptr ? 0.0f : m_From->blendAnimation()->value();
+ auto fromValue = m_From == nullptr ? 0.0f : m_From->blendAnimation()->value();
if (m_To == nullptr || m_From == nullptr || toValue == fromValue) {
mix = mixFrom = 1.0f;
diff --git a/src/animation/blend_state_direct.cpp b/src/animation/blend_state_direct.cpp
index 3dd5deb..dfe1f42 100644
--- a/src/animation/blend_state_direct.cpp
+++ b/src/animation/blend_state_direct.cpp
@@ -6,6 +6,4 @@
using namespace rive;
-StateInstance* BlendStateDirect::makeInstance() const {
- return new BlendStateDirectInstance(this);
-}
\ No newline at end of file
+StateInstance* BlendStateDirect::makeInstance() const { return new BlendStateDirectInstance(this); }
\ No newline at end of file
diff --git a/src/animation/blend_state_direct_instance.cpp b/src/animation/blend_state_direct_instance.cpp
index a969825..09fe7d0 100644
--- a/src/animation/blend_state_direct_instance.cpp
+++ b/src/animation/blend_state_direct_instance.cpp
@@ -3,13 +3,11 @@
using namespace rive;
-BlendStateDirectInstance::BlendStateDirectInstance(
- const BlendStateDirect* blendState) :
+BlendStateDirectInstance::BlendStateDirectInstance(const BlendStateDirect* blendState) :
BlendStateInstance<BlendStateDirect, BlendAnimationDirect>(blendState) {}
void BlendStateDirectInstance::advance(float seconds, SMIInput** inputs) {
- BlendStateInstance<BlendStateDirect, BlendAnimationDirect>::advance(seconds,
- inputs);
+ BlendStateInstance<BlendStateDirect, BlendAnimationDirect>::advance(seconds, inputs);
for (auto& animation : m_AnimationInstances) {
auto inputInstance = inputs[animation.blendAnimation()->inputId()];
diff --git a/src/animation/blend_state_transition.cpp b/src/animation/blend_state_transition.cpp
index 28c2b61..793cc84 100644
--- a/src/animation/blend_state_transition.cpp
+++ b/src/animation/blend_state_transition.cpp
@@ -8,27 +8,26 @@
using namespace rive;
-const LinearAnimationInstance* BlendStateTransition::exitTimeAnimationInstance(
- const StateInstance* from) const {
+const LinearAnimationInstance*
+BlendStateTransition::exitTimeAnimationInstance(const StateInstance* from) const {
if (from != nullptr) {
switch (from->state()->coreType()) {
case BlendState1D::typeKey:
- return static_cast<const BlendState1DInstance*>(from)
- ->animationInstance(m_ExitBlendAnimation);
+ return static_cast<const BlendState1DInstance*>(from)->animationInstance(
+ m_ExitBlendAnimation);
case BlendStateDirect::typeKey:
- return static_cast<const BlendStateDirectInstance*>(from)
- ->animationInstance(m_ExitBlendAnimation);
+ return static_cast<const BlendStateDirectInstance*>(from)->animationInstance(
+ m_ExitBlendAnimation);
}
}
return nullptr;
}
-const LinearAnimation*
-BlendStateTransition::exitTimeAnimation(const LayerState* from) const {
+const LinearAnimation* BlendStateTransition::exitTimeAnimation(const LayerState* from) const {
if (m_ExitBlendAnimation != nullptr) {
return m_ExitBlendAnimation->animation();
}
diff --git a/src/animation/cubic_interpolator.cpp b/src/animation/cubic_interpolator.cpp
index 215ccdd..47fa860 100644
--- a/src/animation/cubic_interpolator.cpp
+++ b/src/animation/cubic_interpolator.cpp
@@ -13,9 +13,7 @@
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
static float calcBezier(float aT, float aA1, float aA2) {
- return (((1.0f - 3.0f * aA2 + 3.0f * aA1) * aT +
- (3.0f * aA2 - 6.0f * aA1)) *
- aT +
+ return (((1.0f - 3.0f * aA2 + 3.0f * aA1) * aT + (3.0f * aA2 - 6.0f * aA1)) * aT +
(3.0f * aA1)) *
aT;
}
@@ -38,16 +36,14 @@
int currentSample = 1;
int lastSample = SplineTableSize - 1;
- for (; currentSample != lastSample && m_Values[currentSample] <= x;
- ++currentSample)
- {
+ for (; currentSample != lastSample && m_Values[currentSample] <= x; ++currentSample) {
intervalStart += SampleStepSize;
}
--currentSample;
// Interpolate to provide an initial guess for t
- float dist = (x - m_Values[currentSample]) /
- (m_Values[currentSample + 1] - m_Values[currentSample]);
+ float dist =
+ (x - m_Values[currentSample]) / (m_Values[currentSample + 1] - m_Values[currentSample]);
float guessForT = intervalStart + dist * SampleStepSize;
float _x1 = x1(), _x2 = x2();
@@ -77,19 +73,15 @@
} else {
intervalStart = currentT;
}
- } while (std::abs(currentX) > SubdivisionPrecision &&
- ++i < SubdivisionMaxIterations);
+ } while (std::abs(currentX) > SubdivisionPrecision && ++i < SubdivisionMaxIterations);
return currentT;
}
}
-float CubicInterpolator::transform(float mix) const {
- return calcBezier(getT(mix), y1(), y2());
-}
+float CubicInterpolator::transform(float mix) const { return calcBezier(getT(mix), y1(), y2()); }
StatusCode CubicInterpolator::import(ImportStack& importStack) {
- auto artboardImporter =
- importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
if (artboardImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/keyed_object.cpp b/src/animation/keyed_object.cpp
index bb0943b..2c60f02 100644
--- a/src/animation/keyed_object.cpp
+++ b/src/animation/keyed_object.cpp
@@ -48,8 +48,7 @@
}
StatusCode KeyedObject::import(ImportStack& importStack) {
- auto importer = importStack.latest<LinearAnimationImporter>(
- LinearAnimationBase::typeKey);
+ auto importer = importStack.latest<LinearAnimationImporter>(LinearAnimationBase::typeKey);
if (importer == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/keyed_property.cpp b/src/animation/keyed_property.cpp
index 46db944..8c7891c 100644
--- a/src/animation/keyed_property.cpp
+++ b/src/animation/keyed_property.cpp
@@ -12,9 +12,7 @@
}
}
-void KeyedProperty::addKeyFrame(KeyFrame* keyframe) {
- m_KeyFrames.push_back(keyframe);
-}
+void KeyedProperty::addKeyFrame(KeyFrame* keyframe) { m_KeyFrames.push_back(keyframe); }
void KeyedProperty::apply(Core* object, float seconds, float mix) {
assert(!m_KeyFrames.empty());
@@ -52,8 +50,7 @@
if (fromFrame->interpolationType() == 0) {
fromFrame->apply(object, pk, mix);
} else {
- fromFrame->applyInterpolation(
- object, pk, seconds, toFrame, mix);
+ fromFrame->applyInterpolation(object, pk, seconds, toFrame, mix);
}
}
} else {
@@ -83,8 +80,7 @@
}
StatusCode KeyedProperty::import(ImportStack& importStack) {
- auto importer =
- importStack.latest<KeyedObjectImporter>(KeyedObjectBase::typeKey);
+ auto importer = importStack.latest<KeyedObjectImporter>(KeyedObjectBase::typeKey);
if (importer == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/keyframe.cpp b/src/animation/keyframe.cpp
index 37ad9fe..f208316 100644
--- a/src/animation/keyframe.cpp
+++ b/src/animation/keyframe.cpp
@@ -22,8 +22,7 @@
void KeyFrame::computeSeconds(int fps) { m_Seconds = frame() / (float)fps; }
StatusCode KeyFrame::import(ImportStack& importStack) {
- auto importer =
- importStack.latest<KeyedPropertyImporter>(KeyedProperty::typeKey);
+ auto importer = importStack.latest<KeyedPropertyImporter>(KeyedProperty::typeKey);
if (importer == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/keyframe_bool.cpp b/src/animation/keyframe_bool.cpp
index a7eba61..3e7de85 100644
--- a/src/animation/keyframe_bool.cpp
+++ b/src/animation/keyframe_bool.cpp
@@ -7,10 +7,7 @@
CoreRegistry::setBool(object, propertyKey, value());
}
-void KeyFrameBool::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameBool::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
CoreRegistry::setBool(object, propertyKey, value());
}
\ No newline at end of file
diff --git a/src/animation/keyframe_color.cpp b/src/animation/keyframe_color.cpp
index 3accfcd..074d92e 100644
--- a/src/animation/keyframe_color.cpp
+++ b/src/animation/keyframe_color.cpp
@@ -8,8 +8,7 @@
if (mix == 1.0f) {
CoreRegistry::setColor(object, propertyKey, value);
} else {
- auto mixedColor =
- colorLerp(CoreRegistry::getColor(object, propertyKey), value, mix);
+ auto mixedColor = colorLerp(CoreRegistry::getColor(object, propertyKey), value, mix);
CoreRegistry::setColor(object, propertyKey, mixedColor);
}
}
@@ -18,11 +17,8 @@
applyColor(object, propertyKey, mix, value());
}
-void KeyFrameColor::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameColor::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
auto kfc = nextFrame->as<KeyFrameColor>();
const KeyFrameColor& nextColor = *kfc;
float f = (currentTime - seconds()) / (nextColor.seconds() - seconds());
@@ -31,6 +27,5 @@
f = cubic->transform(f);
}
- applyColor(
- object, propertyKey, mix, colorLerp(value(), nextColor.value(), f));
+ applyColor(object, propertyKey, mix, colorLerp(value(), nextColor.value(), f));
}
\ No newline at end of file
diff --git a/src/animation/keyframe_double.cpp b/src/animation/keyframe_double.cpp
index bb4776f..b059062 100644
--- a/src/animation/keyframe_double.cpp
+++ b/src/animation/keyframe_double.cpp
@@ -14,9 +14,7 @@
} else {
float mixi = 1.0 - mix;
CoreRegistry::setDouble(
- object,
- propertyKey,
- CoreRegistry::getDouble(object, propertyKey) * mixi + value * mix);
+ object, propertyKey, CoreRegistry::getDouble(object, propertyKey) * mixi + value * mix);
}
}
@@ -24,11 +22,8 @@
applyDouble(object, propertyKey, mix, value());
}
-void KeyFrameDouble::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameDouble::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
auto kfd = nextFrame->as<KeyFrameDouble>();
const KeyFrameDouble& nextDouble = *kfd;
float f = (currentTime - seconds()) / (nextDouble.seconds() - seconds());
@@ -37,6 +32,5 @@
f = cubic->transform(f);
}
- applyDouble(
- object, propertyKey, mix, value() + (nextDouble.value() - value()) * f);
+ applyDouble(object, propertyKey, mix, value() + (nextDouble.value() - value()) * f);
}
\ No newline at end of file
diff --git a/src/animation/keyframe_id.cpp b/src/animation/keyframe_id.cpp
index 00be39a..38a3f5d 100644
--- a/src/animation/keyframe_id.cpp
+++ b/src/animation/keyframe_id.cpp
@@ -7,10 +7,7 @@
CoreRegistry::setUint(object, propertyKey, value());
}
-void KeyFrameId::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameId::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
CoreRegistry::setUint(object, propertyKey, value());
}
\ No newline at end of file
diff --git a/src/animation/layer_state.cpp b/src/animation/layer_state.cpp
index 20c3679..3cafeaf 100644
--- a/src/animation/layer_state.cpp
+++ b/src/animation/layer_state.cpp
@@ -35,8 +35,8 @@
}
StatusCode LayerState::import(ImportStack& importStack) {
- auto layerImporter = importStack.latest<StateMachineLayerImporter>(
- StateMachineLayerBase::typeKey);
+ auto layerImporter =
+ importStack.latest<StateMachineLayerImporter>(StateMachineLayerBase::typeKey);
if (layerImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -44,10 +44,6 @@
return Super::import(importStack);
}
-void LayerState::addTransition(StateTransition* transition) {
- m_Transitions.push_back(transition);
-}
+void LayerState::addTransition(StateTransition* transition) { m_Transitions.push_back(transition); }
-StateInstance* LayerState::makeInstance() const {
- return new SystemStateInstance(this);
-}
\ No newline at end of file
+StateInstance* LayerState::makeInstance() const { return new SystemStateInstance(this); }
\ No newline at end of file
diff --git a/src/animation/linear_animation.cpp b/src/animation/linear_animation.cpp
index 4a8d743..91e3d4c 100644
--- a/src/animation/linear_animation.cpp
+++ b/src/animation/linear_animation.cpp
@@ -39,9 +39,7 @@
return StatusCode::Ok;
}
-void LinearAnimation::addKeyedObject(KeyedObject* object) {
- m_KeyedObjects.push_back(object);
-}
+void LinearAnimation::addKeyedObject(KeyedObject* object) { m_KeyedObjects.push_back(object); }
void LinearAnimation::apply(Artboard* artboard, float time, float mix) const {
for (auto object : m_KeyedObjects) {
@@ -50,8 +48,7 @@
}
StatusCode LinearAnimation::import(ImportStack& importStack) {
- auto artboardImporter =
- importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
if (artboardImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -65,23 +62,17 @@
float LinearAnimation::endSeconds() const {
return (enableWorkArea() ? workEnd() : duration()) / (float)fps();
}
-float LinearAnimation::durationSeconds() const {
- return endSeconds() - startSeconds();
-}
+float LinearAnimation::durationSeconds() const { return endSeconds() - startSeconds(); }
float LinearAnimation::globalToLocalSeconds(float seconds) const {
switch (loop()) {
case Loop::oneShot:
return seconds + startSeconds();
case Loop::loop:
- return std::fmod(seconds, (endSeconds() - startSeconds())) +
- startSeconds();
+ return std::fmod(seconds, (endSeconds() - startSeconds())) + startSeconds();
case Loop::pingPong:
- float localTime =
- std::fmod(seconds, (endSeconds() - startSeconds()));
- int direction =
- ((int)(seconds / (endSeconds() - startSeconds()))) % 2;
- return direction == 0 ? localTime + startSeconds()
- : endSeconds() - localTime;
+ float localTime = std::fmod(seconds, (endSeconds() - startSeconds()));
+ int direction = ((int)(seconds / (endSeconds() - startSeconds()))) % 2;
+ return direction == 0 ? localTime + startSeconds() : endSeconds() - localTime;
}
}
\ No newline at end of file
diff --git a/src/animation/linear_animation_instance.cpp b/src/animation/linear_animation_instance.cpp
index b9a27eb..6ed6e72 100644
--- a/src/animation/linear_animation_instance.cpp
+++ b/src/animation/linear_animation_instance.cpp
@@ -5,12 +5,9 @@
using namespace rive;
-LinearAnimationInstance::LinearAnimationInstance(
- const LinearAnimation* animation) :
+LinearAnimationInstance::LinearAnimationInstance(const LinearAnimation* animation) :
m_Animation(animation),
- m_Time(animation->enableWorkArea()
- ? (float)animation->workStart() / animation->fps()
- : 0),
+ m_Time(animation->enableWorkArea() ? (float)animation->workStart() / animation->fps() : 0),
m_TotalTime(0.0f),
m_LastTotalTime(0.0f),
m_SpilledTime(0.0f),
@@ -27,8 +24,7 @@
float frames = m_Time * fps;
int start = animation.enableWorkArea() ? animation.workStart() : 0;
- int end =
- animation.enableWorkArea() ? animation.workEnd() : animation.duration();
+ int end = animation.enableWorkArea() ? animation.workEnd() : animation.duration();
int range = end - start;
bool keepGoing = true;
@@ -107,8 +103,7 @@
// can track change even when setting time.
auto diff = m_TotalTime - m_LastTotalTime;
- int start = (m_Animation->enableWorkArea() ? m_Animation->workStart() : 0) *
- m_Animation->fps();
+ int start = (m_Animation->enableWorkArea() ? m_Animation->workStart() : 0) * m_Animation->fps();
m_TotalTime = value - start;
m_LastTotalTime = m_TotalTime - diff;
@@ -136,6 +131,4 @@
m_LoopValue = value;
}
-float LinearAnimationInstance::durationSeconds() const {
- return m_Animation->durationSeconds();
-}
\ No newline at end of file
+float LinearAnimationInstance::durationSeconds() const { return m_Animation->durationSeconds(); }
\ No newline at end of file
diff --git a/src/animation/nested_linear_animation.cpp b/src/animation/nested_linear_animation.cpp
index 631194b..264b1af 100644
--- a/src/animation/nested_linear_animation.cpp
+++ b/src/animation/nested_linear_animation.cpp
@@ -7,6 +7,5 @@
void NestedLinearAnimation::initializeAnimation(Artboard* artboard) {
assert(m_AnimationInstance == nullptr);
- m_AnimationInstance =
- new LinearAnimationInstance(artboard->animation(animationId()));
+ m_AnimationInstance = new LinearAnimationInstance(artboard->animation(animationId()));
}
\ No newline at end of file
diff --git a/src/animation/nested_remap_animation.cpp b/src/animation/nested_remap_animation.cpp
index 47b81be..2cba49e 100644
--- a/src/animation/nested_remap_animation.cpp
+++ b/src/animation/nested_remap_animation.cpp
@@ -5,9 +5,8 @@
void NestedRemapAnimation::timeChanged() {
if (m_AnimationInstance != nullptr) {
- m_AnimationInstance->time(
- m_AnimationInstance->animation()->globalToLocalSeconds(
- m_AnimationInstance->durationSeconds() * time()));
+ m_AnimationInstance->time(m_AnimationInstance->animation()->globalToLocalSeconds(
+ m_AnimationInstance->durationSeconds() * time()));
}
}
diff --git a/src/animation/state_instance.cpp b/src/animation/state_instance.cpp
index d27cef7..e698651 100644
--- a/src/animation/state_instance.cpp
+++ b/src/animation/state_instance.cpp
@@ -1,8 +1,7 @@
#include "rive/animation/state_instance.hpp"
using namespace rive;
-StateInstance::StateInstance(const LayerState* layerState) :
- m_LayerState(layerState) {}
+StateInstance::StateInstance(const LayerState* layerState) : m_LayerState(layerState) {}
StateInstance::~StateInstance() {}
diff --git a/src/animation/state_machine.cpp b/src/animation/state_machine.cpp
index 885000d..1f8314b 100644
--- a/src/animation/state_machine.cpp
+++ b/src/animation/state_machine.cpp
@@ -46,8 +46,7 @@
}
StatusCode StateMachine::import(ImportStack& importStack) {
- auto artboardImporter =
- importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
if (artboardImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -55,13 +54,9 @@
return Super::import(importStack);
}
-void StateMachine::addLayer(StateMachineLayer* layer) {
- m_Layers.push_back(layer);
-}
+void StateMachine::addLayer(StateMachineLayer* layer) { m_Layers.push_back(layer); }
-void StateMachine::addInput(StateMachineInput* input) {
- m_Inputs.push_back(input);
-}
+void StateMachine::addInput(StateMachineInput* input) { m_Inputs.push_back(input); }
const StateMachineInput* StateMachine::input(std::string name) const {
for (auto input : m_Inputs) {
diff --git a/src/animation/state_machine_input.cpp b/src/animation/state_machine_input.cpp
index bf22152..6133a35 100644
--- a/src/animation/state_machine_input.cpp
+++ b/src/animation/state_machine_input.cpp
@@ -5,17 +5,12 @@
using namespace rive;
-StatusCode StateMachineInput::onAddedDirty(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode StateMachineInput::onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
-StatusCode StateMachineInput::onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode StateMachineInput::onAddedClean(CoreContext* context) { return StatusCode::Ok; }
StatusCode StateMachineInput::import(ImportStack& importStack) {
- auto stateMachineImporter =
- importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
if (stateMachineImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/state_machine_input_instance.cpp b/src/animation/state_machine_input_instance.cpp
index f3f99df..b188d17 100644
--- a/src/animation/state_machine_input_instance.cpp
+++ b/src/animation/state_machine_input_instance.cpp
@@ -6,8 +6,7 @@
using namespace rive;
-SMIInput::SMIInput(const StateMachineInput* input,
- StateMachineInstance* machineInstance) :
+SMIInput::SMIInput(const StateMachineInput* input, StateMachineInstance* machineInstance) :
m_MachineInstance(machineInstance), m_Input(input) {}
uint16_t SMIInput::inputCoreType() const { return m_Input->coreType(); }
@@ -18,8 +17,7 @@
// bool
-SMIBool::SMIBool(const StateMachineBool* input,
- StateMachineInstance* machineInstance) :
+SMIBool::SMIBool(const StateMachineBool* input, StateMachineInstance* machineInstance) :
SMIInput(input, machineInstance), m_Value(input->value()) {}
void SMIBool::value(bool newValue) {
@@ -31,8 +29,7 @@
}
// number
-SMINumber::SMINumber(const StateMachineNumber* input,
- StateMachineInstance* machineInstance) :
+SMINumber::SMINumber(const StateMachineNumber* input, StateMachineInstance* machineInstance) :
SMIInput(input, machineInstance), m_Value(input->value()) {}
void SMINumber::value(float newValue) {
@@ -44,8 +41,7 @@
}
// trigger
-SMITrigger::SMITrigger(const StateMachineTrigger* input,
- StateMachineInstance* machineInstance) :
+SMITrigger::SMITrigger(const StateMachineTrigger* input, StateMachineInstance* machineInstance) :
SMIInput(input, machineInstance) {}
void SMITrigger::fire() {
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp
index 06bed78..e37dad3 100644
--- a/src/animation/state_machine_instance.cpp
+++ b/src/animation/state_machine_instance.cpp
@@ -56,23 +56,18 @@
}
void updateMix(float seconds) {
- if (m_Transition != nullptr && m_StateFrom != nullptr &&
- m_Transition->duration() != 0)
+ if (m_Transition != nullptr && m_StateFrom != nullptr && m_Transition->duration() != 0)
{
m_Mix = std::min(
1.0f,
std::max(0.0f,
- (m_Mix + seconds / m_Transition->mixTime(
- m_StateFrom->state()))));
+ (m_Mix + seconds / m_Transition->mixTime(m_StateFrom->state()))));
} else {
m_Mix = 1.0f;
}
}
- bool advance(Artboard* artboard,
- float seconds,
- SMIInput** inputs,
- size_t inputCount) {
+ bool advance(Artboard* artboard, float seconds, SMIInput** inputs, size_t inputCount) {
m_StateChangedOnAdvance = false;
if (m_CurrentState != nullptr) {
@@ -81,8 +76,7 @@
updateMix(seconds);
- if (m_StateFrom != nullptr && m_Mix < 1.0f && !m_HoldAnimationFrom)
- {
+ if (m_StateFrom != nullptr && m_Mix < 1.0f && !m_HoldAnimationFrom) {
// This didn't advance during our updateState, but it should now
// that we realize we need to mix it in.
m_StateFrom->advance(seconds, inputs);
@@ -125,32 +119,24 @@
}
bool changeState(const LayerState* stateTo) {
- if ((m_CurrentState == nullptr
- ? nullptr
- : m_CurrentState->state()) == stateTo) {
+ if ((m_CurrentState == nullptr ? nullptr : m_CurrentState->state()) == stateTo) {
return false;
}
- m_CurrentState =
- stateTo == nullptr ? nullptr : stateTo->makeInstance();
+ m_CurrentState = stateTo == nullptr ? nullptr : stateTo->makeInstance();
return true;
}
- bool tryChangeState(StateInstance* stateFromInstance,
- SMIInput** inputs,
- bool ignoreTriggers) {
+ bool
+ tryChangeState(StateInstance* stateFromInstance, SMIInput** inputs, bool ignoreTriggers) {
if (stateFromInstance == nullptr) {
return false;
}
auto stateFrom = stateFromInstance->state();
auto outState = m_CurrentState;
- for (size_t i = 0, length = stateFrom->transitionCount();
- i < length;
- i++) {
+ for (size_t i = 0, length = stateFrom->transitionCount(); i < length; i++) {
auto transition = stateFrom->transition(i);
- auto allowed = transition->allowed(
- stateFromInstance, inputs, ignoreTriggers);
- if (allowed == AllowTransition::yes &&
- changeState(transition->stateTo())) {
+ auto allowed = transition->allowed(stateFromInstance, inputs, ignoreTriggers);
+ if (allowed == AllowTransition::yes && changeState(transition->stateTo())) {
m_StateChangedOnAdvance = true;
// state actually has changed
m_Transition = transition;
@@ -163,13 +149,11 @@
// If we had an exit time and wanted to pause on exit, make
// sure to hold the exit time. Delegate this to the
// transition by telling it that it was completed.
- if (outState != nullptr &&
- transition->applyExitCondition(outState)) {
+ if (outState != nullptr && transition->applyExitCondition(outState)) {
// Make sure we apply this state. This only returns true
// when it's an animation state instance.
auto instance =
- static_cast<AnimationStateInstance*>(m_StateFrom)
- ->animationInstance();
+ static_cast<AnimationStateInstance*>(m_StateFrom)->animationInstance();
m_HoldAnimation = instance->animation();
m_HoldTime = instance->time();
@@ -180,13 +164,11 @@
if (m_Mix != 0.0f) {
m_HoldAnimationFrom = transition->pauseOnExit();
}
- if (m_StateFrom != nullptr &&
- m_StateFrom->state()->is<AnimationState>() &&
+ if (m_StateFrom != nullptr && m_StateFrom->state()->is<AnimationState>() &&
m_CurrentState != nullptr)
{
auto instance =
- static_cast<AnimationStateInstance*>(m_StateFrom)
- ->animationInstance();
+ static_cast<AnimationStateInstance*>(m_StateFrom)->animationInstance();
auto spilledTime = instance->spilledTime();
m_CurrentState->advance(spilledTime, inputs);
@@ -219,23 +201,19 @@
bool stateChangedOnAdvance() const { return m_StateChangedOnAdvance; }
const LayerState* currentState() {
- return m_CurrentState == nullptr ? nullptr
- : m_CurrentState->state();
+ return m_CurrentState == nullptr ? nullptr : m_CurrentState->state();
}
const LinearAnimationInstance* currentAnimation() const {
- if (m_CurrentState == nullptr ||
- !m_CurrentState->state()->is<AnimationState>()) {
+ if (m_CurrentState == nullptr || !m_CurrentState->state()->is<AnimationState>()) {
return nullptr;
}
- return static_cast<AnimationStateInstance*>(m_CurrentState)
- ->animationInstance();
+ return static_cast<AnimationStateInstance*>(m_CurrentState)->animationInstance();
}
};
} // namespace rive
-StateMachineInstance::StateMachineInstance(const StateMachine* machine) :
- m_Machine(machine) {
+StateMachineInstance::StateMachineInstance(const StateMachine* machine) : m_Machine(machine) {
m_InputCount = machine->inputCount();
m_InputInstances = new SMIInput*[m_InputCount];
for (size_t i = 0; i < m_InputCount; i++) {
@@ -246,16 +224,13 @@
}
switch (input->coreType()) {
case StateMachineBool::typeKey:
- m_InputInstances[i] =
- new SMIBool(input->as<StateMachineBool>(), this);
+ m_InputInstances[i] = new SMIBool(input->as<StateMachineBool>(), this);
break;
case StateMachineNumber::typeKey:
- m_InputInstances[i] =
- new SMINumber(input->as<StateMachineNumber>(), this);
+ m_InputInstances[i] = new SMINumber(input->as<StateMachineNumber>(), this);
break;
case StateMachineTrigger::typeKey:
- m_InputInstances[i] =
- new SMITrigger(input->as<StateMachineTrigger>(), this);
+ m_InputInstances[i] = new SMITrigger(input->as<StateMachineTrigger>(), this);
break;
default:
// Sanity check.
@@ -283,8 +258,7 @@
bool StateMachineInstance::advance(Artboard* artboard, float seconds) {
m_NeedsAdvance = false;
for (size_t i = 0; i < m_LayerCount; i++) {
- if (m_Layers[i].advance(
- artboard, seconds, m_InputInstances, m_InputCount)) {
+ if (m_Layers[i].advance(artboard, seconds, m_InputInstances, m_InputCount)) {
m_NeedsAdvance = true;
}
}
@@ -345,8 +319,7 @@
return count;
}
-const LayerState*
-StateMachineInstance::stateChangedByIndex(size_t index) const {
+const LayerState* StateMachineInstance::stateChangedByIndex(size_t index) const {
size_t count = 0;
for (size_t i = 0; i < m_LayerCount; i++) {
if (m_Layers[i].stateChangedOnAdvance()) {
@@ -369,8 +342,7 @@
return count;
}
-const LinearAnimationInstance*
-StateMachineInstance::currentAnimationByIndex(size_t index) const {
+const LinearAnimationInstance* StateMachineInstance::currentAnimationByIndex(size_t index) const {
size_t count = 0;
for (size_t i = 0; i < m_LayerCount; i++) {
if (m_Layers[i].currentAnimation() != nullptr) {
diff --git a/src/animation/state_machine_layer.cpp b/src/animation/state_machine_layer.cpp
index a75ce1b..363c3f8 100644
--- a/src/animation/state_machine_layer.cpp
+++ b/src/animation/state_machine_layer.cpp
@@ -51,13 +51,10 @@
return StatusCode::Ok;
}
-void StateMachineLayer::addState(LayerState* state) {
- m_States.push_back(state);
-}
+void StateMachineLayer::addState(LayerState* state) { m_States.push_back(state); }
StatusCode StateMachineLayer::import(ImportStack& importStack) {
- auto stateMachineImporter =
- importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
if (stateMachineImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/state_transition.cpp b/src/animation/state_transition.cpp
index 11cda62..2a442ca 100644
--- a/src/animation/state_transition.cpp
+++ b/src/animation/state_transition.cpp
@@ -39,8 +39,7 @@
}
StatusCode StateTransition::import(ImportStack& importStack) {
- auto stateImporter =
- importStack.latest<LayerStateImporter>(LayerState::typeKey);
+ auto stateImporter = importStack.latest<LayerStateImporter>(LayerState::typeKey);
if (stateImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -72,8 +71,7 @@
}
}
-float StateTransition::exitTimeSeconds(const LayerState* stateFrom,
- bool absolute) const {
+float StateTransition::exitTimeSeconds(const LayerState* stateFrom, bool absolute) const {
if ((transitionFlags() & StateTransitionFlags::ExitTimeIsPercentage) ==
StateTransitionFlags::ExitTimeIsPercentage)
{
@@ -94,21 +92,17 @@
const LinearAnimationInstance*
StateTransition::exitTimeAnimationInstance(const StateInstance* from) const {
return from != nullptr && from->state()->is<AnimationState>()
- ? static_cast<const AnimationStateInstance*>(from)
- ->animationInstance()
+ ? static_cast<const AnimationStateInstance*>(from)->animationInstance()
: nullptr;
}
-const LinearAnimation*
-StateTransition::exitTimeAnimation(const LayerState* from) const {
- return from != nullptr && from->is<AnimationState>()
- ? from->as<AnimationState>()->animation()
- : nullptr;
+const LinearAnimation* StateTransition::exitTimeAnimation(const LayerState* from) const {
+ return from != nullptr && from->is<AnimationState>() ? from->as<AnimationState>()->animation()
+ : nullptr;
}
-AllowTransition StateTransition::allowed(StateInstance* stateFrom,
- SMIInput** inputs,
- bool ignoreTriggers) const {
+AllowTransition
+StateTransition::allowed(StateInstance* stateFrom, SMIInput** inputs, bool ignoreTriggers) const {
if (isDisabled()) {
return AllowTransition::no;
}
@@ -118,8 +112,7 @@
auto input = inputs[condition->inputId()];
if ((ignoreTriggers && condition->is<TransitionTriggerCondition>()) ||
- !condition->evaluate(input))
- {
+ !condition->evaluate(input)) {
return AllowTransition::no;
}
}
@@ -149,8 +142,7 @@
// .... but i suspect that will introduce some more issues?
// There's only one iteration in oneShot,
- if (exitTime <= duration && animationFrom->loop() != Loop::oneShot)
- {
+ if (exitTime <= duration && animationFrom->loop() != Loop::oneShot) {
// Get exit time relative to the loop lastTime was in.
exitTime += std::floor(lastTime / duration) * duration;
}
@@ -166,8 +158,7 @@
bool StateTransition::applyExitCondition(StateInstance* from) const {
// Hold exit time when the user has set to pauseOnExit on this condition
// (only valid when exiting from an Animation).
- bool useExitTime = enableExitTime() &&
- (from != nullptr && from->state()->is<AnimationState>());
+ bool useExitTime = enableExitTime() && (from != nullptr && from->state()->is<AnimationState>());
if (pauseOnExit() && useExitTime) {
static_cast<AnimationStateInstance*>(from)->animationInstance()->time(
exitTimeSeconds(from->state(), true));
diff --git a/src/animation/transition_bool_condition.cpp b/src/animation/transition_bool_condition.cpp
index 1b9ca6b..34b1292 100644
--- a/src/animation/transition_bool_condition.cpp
+++ b/src/animation/transition_bool_condition.cpp
@@ -5,8 +5,7 @@
using namespace rive;
-bool TransitionBoolCondition::validateInputType(
- const StateMachineInput* input) const {
+bool TransitionBoolCondition::validateInputType(const StateMachineInput* input) const {
// A null input is valid as the StateMachine can attempt to limp along if we
// introduce new input types that old conditions are expected to handle in
// newer runtimes. The older runtimes will just evaluate them to true.
diff --git a/src/animation/transition_condition.cpp b/src/animation/transition_condition.cpp
index a377b05..39d008e 100644
--- a/src/animation/transition_condition.cpp
+++ b/src/animation/transition_condition.cpp
@@ -6,17 +6,12 @@
using namespace rive;
-StatusCode TransitionCondition::onAddedDirty(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode TransitionCondition::onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
-StatusCode TransitionCondition::onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode TransitionCondition::onAddedClean(CoreContext* context) { return StatusCode::Ok; }
StatusCode TransitionCondition::import(ImportStack& importStack) {
- auto stateMachineImporter =
- importStack.latest<StateMachineImporter>(StateMachine::typeKey);
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
if (stateMachineImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -25,14 +20,11 @@
if ((size_t)inputId() >= stateMachineImporter->stateMachine()->inputCount()) {
return StatusCode::InvalidObject;
}
- if (!validateInputType(
- stateMachineImporter->stateMachine()->input((size_t)inputId())))
- {
+ if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) {
return StatusCode::InvalidObject;
}
- auto transitionImporter =
- importStack.latest<StateTransitionImporter>(StateTransition::typeKey);
+ auto transitionImporter = importStack.latest<StateTransitionImporter>(StateTransition::typeKey);
if (transitionImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/animation/transition_number_condition.cpp b/src/animation/transition_number_condition.cpp
index b6bbd8d..c15f82c 100644
--- a/src/animation/transition_number_condition.cpp
+++ b/src/animation/transition_number_condition.cpp
@@ -5,8 +5,7 @@
using namespace rive;
-bool TransitionNumberCondition::validateInputType(
- const StateMachineInput* input) const {
+bool TransitionNumberCondition::validateInputType(const StateMachineInput* input) const {
// A null input is valid as the StateMachine can attempt to limp along if we
// introduce new input types that old conditions are expected to handle in
// newer runtimes. The older runtimes will just evaluate them to true.
diff --git a/src/animation/transition_trigger_condition.cpp b/src/animation/transition_trigger_condition.cpp
index 0587062..b5e8524 100644
--- a/src/animation/transition_trigger_condition.cpp
+++ b/src/animation/transition_trigger_condition.cpp
@@ -5,8 +5,7 @@
using namespace rive;
-bool TransitionTriggerCondition::validateInputType(
- const StateMachineInput* input) const {
+bool TransitionTriggerCondition::validateInputType(const StateMachineInput* input) const {
// A null input is valid as the StateMachine can attempt to limp along if we
// introduce new input types that old conditions are expected to handle in
// newer runtimes. The older runtimes will just evaluate them to true.
diff --git a/src/artboard.cpp b/src/artboard.cpp
index 090f776..bdd4614 100644
--- a/src/artboard.cpp
+++ b/src/artboard.cpp
@@ -138,8 +138,7 @@
m_Drawables.push_back(drawable);
for (ContainerComponent* parent = drawable; parent != nullptr;
- parent = parent->parent())
- {
+ parent = parent->parent()) {
auto itr = componentDrawRules.find(parent);
if (itr != componentDrawRules.end()) {
drawable->flattenedDrawRules = itr->second;
@@ -271,13 +270,9 @@
void Artboard::addObject(Core* object) { m_Objects.push_back(object); }
-void Artboard::addAnimation(LinearAnimation* object) {
- m_Animations.push_back(object);
-}
+void Artboard::addAnimation(LinearAnimation* object) { m_Animations.push_back(object); }
-void Artboard::addStateMachine(StateMachine* object) {
- m_StateMachines.push_back(object);
-}
+void Artboard::addStateMachine(StateMachine* object) { m_StateMachines.push_back(object); }
void Artboard::addNestedArtboard(NestedArtboard* artboard) {
m_NestedArtboards.push_back(artboard);
@@ -301,9 +296,7 @@
}
}
-void Artboard::onDirty(ComponentDirt dirt) {
- m_Dirt |= ComponentDirt::Components;
-}
+void Artboard::onDirty(ComponentDirt dirt) { m_Dirt |= ComponentDirt::Components; }
void Artboard::update(ComponentDirt value) {
if (hasDirt(value, ComponentDirt::DrawOrder)) {
@@ -314,11 +307,9 @@
if (m_FrameOrigin) {
m_ClipPath->addRect(0.0f, 0.0f, width(), height());
} else {
- m_ClipPath->addRect(
- -width() * originX(), -height() * originY(), width(), height());
+ m_ClipPath->addRect(-width() * originX(), -height() * originY(), width(), height());
}
- m_BackgroundPath->addRect(
- -width() * originX(), -height() * originY(), width(), height());
+ m_BackgroundPath->addRect(-width() * originX(), -height() * originY(), width(), height());
}
}
@@ -391,9 +382,9 @@
return c;
}
}
-
+
// TODO: should we hit-test the background?
-
+
return nullptr;
}
@@ -417,9 +408,7 @@
}
if (option != DrawOption::kHideFG) {
- for (auto drawable = m_FirstDrawable; drawable != nullptr;
- drawable = drawable->prev)
- {
+ for (auto drawable = m_FirstDrawable; drawable != nullptr; drawable = drawable->prev) {
if (drawable->isHidden()) {
continue;
}
@@ -541,8 +530,7 @@
}
StatusCode Artboard::import(ImportStack& importStack) {
- auto backboardImporter =
- importStack.latest<BackboardImporter>(Backboard::typeKey);
+ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey);
if (backboardImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/assets/file_asset.cpp b/src/assets/file_asset.cpp
index edd4eb8..cdf6bb6 100644
--- a/src/assets/file_asset.cpp
+++ b/src/assets/file_asset.cpp
@@ -5,8 +5,7 @@
using namespace rive;
StatusCode FileAsset::import(ImportStack& importStack) {
- auto backboardImporter =
- importStack.latest<BackboardImporter>(Backboard::typeKey);
+ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey);
if (backboardImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -23,6 +22,5 @@
if (finalDot != std::string::npos) {
uniqueFilename = uniqueFilename.substr(0, finalDot);
}
- return uniqueFilename + "-" + std::to_string(assetId()) + "." +
- fileExtension();
+ return uniqueFilename + "-" + std::to_string(assetId()) + "." + fileExtension();
}
diff --git a/src/assets/file_asset_contents.cpp b/src/assets/file_asset_contents.cpp
index d4c0340..2047b11 100644
--- a/src/assets/file_asset_contents.cpp
+++ b/src/assets/file_asset_contents.cpp
@@ -5,8 +5,7 @@
using namespace rive;
StatusCode FileAssetContents::import(ImportStack& importStack) {
- auto fileAssetImporter =
- importStack.latest<FileAssetImporter>(FileAsset::typeKey);
+ auto fileAssetImporter = importStack.latest<FileAssetImporter>(FileAsset::typeKey);
if (fileAssetImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -24,6 +23,4 @@
assert(false);
}
-Span<const uint8_t> FileAssetContents::bytes() const {
- return toSpan(m_Bytes);
-}
+Span<const uint8_t> FileAssetContents::bytes() const { return toSpan(m_Bytes); }
diff --git a/src/bones/bone.cpp b/src/bones/bone.cpp
index 35d0c51..ec72eb9 100644
--- a/src/bones/bone.cpp
+++ b/src/bones/bone.cpp
@@ -25,13 +25,10 @@
float Bone::y() const { return 0.0f; }
-void Bone::tipWorldTranslation(Vec2D& result) {
- result = worldTransform() * Vec2D(length(), 0);
-}
+void Bone::tipWorldTranslation(Vec2D& result) { result = worldTransform() * Vec2D(length(), 0); }
void Bone::addPeerConstraint(Constraint* peer) {
- assert(std::find(m_PeerConstraints.begin(),
- m_PeerConstraints.end(),
- peer) == m_PeerConstraints.end());
+ assert(std::find(m_PeerConstraints.begin(), m_PeerConstraints.end(), peer) ==
+ m_PeerConstraints.end());
m_PeerConstraints.push_back(peer);
}
diff --git a/src/component.cpp b/src/component.cpp
index ae09548..864768e 100644
--- a/src/component.cpp
+++ b/src/component.cpp
@@ -24,9 +24,7 @@
void Component::addDependent(Component* component) {
// Make it's not already a dependent.
- if (std::find(m_Dependents.begin(), m_Dependents.end(), component) !=
- m_Dependents.end())
- {
+ if (std::find(m_Dependents.begin(), m_Dependents.end(), component) != m_Dependents.end()) {
return;
}
m_Dependents.push_back(component);
@@ -63,8 +61,7 @@
return Super::import(importStack);
}
- auto artboardImporter =
- importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
if (artboardImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/constraints/constraint.cpp b/src/constraints/constraint.cpp
index ec207c4..ed04718 100644
--- a/src/constraints/constraint.cpp
+++ b/src/constraints/constraint.cpp
@@ -16,9 +16,7 @@
return StatusCode::Ok;
}
-void Constraint::markConstraintDirty() {
- parent()->as<TransformComponent>()->markTransformDirty();
-}
+void Constraint::markConstraintDirty() { parent()->as<TransformComponent>()->markTransformDirty(); }
void Constraint::strengthChanged() { markConstraintDirty(); }
diff --git a/src/constraints/ik_constraint.cpp b/src/constraints/ik_constraint.cpp
index 3400a5e..c2c3613 100644
--- a/src/constraints/ik_constraint.cpp
+++ b/src/constraints/ik_constraint.cpp
@@ -62,8 +62,7 @@
for (int i = 1; i < numBones; i++) {
auto bone = bones[i];
if (transformComponent->parent() == bone &&
- std::find(bones.begin(), bones.end(), transformComponent) ==
- bones.end())
+ std::find(bones.begin(), bones.end(), transformComponent) == bones.end())
{
tip->addDependent(transformComponent);
}
@@ -82,8 +81,7 @@
}
}
-void IKConstraint::solve1(BoneChainLink* fk1,
- const Vec2D& worldTargetTranslation) {
+void IKConstraint::solve1(BoneChainLink* fk1, const Vec2D& worldTargetTranslation) {
Mat2D iworld = fk1->parentWorldInverse;
Vec2D pA;
fk1->bone->worldTranslation(pA);
@@ -124,10 +122,8 @@
Vec2D av = pB - pC, bv = pC - pA, cv = pBT - pA;
float a = av.length(), b = bv.length(), c = cv.length();
- float A = std::acos(std::max(
- -1.0f, std::min(1.0f, (-a * a + b * b + c * c) / (2.0f * b * c))));
- float C = std::acos(std::max(
- -1.0f, std::min(1.0f, (a * a + b * b - c * c) / (2.0f * a * b))));
+ float A = std::acos(std::max(-1.0f, std::min(1.0f, (-a * a + b * b + c * c) / (2.0f * b * c))));
+ float C = std::acos(std::max(-1.0f, std::min(1.0f, (a * a + b * b - c * c) / (2.0f * a * b))));
float r1, r2;
if (b2->parent() != b1) {
@@ -160,8 +156,7 @@
constrainRotation(*firstChild, r2);
if (firstChild != fk2) {
Bone* bone = fk2->bone;
- bone->mutableWorldTransform() =
- getParentWorld(*bone) * bone->transform();
+ bone->mutableWorldTransform() = getParentWorld(*bone) * bone->transform();
}
// Simple storage, need this for interpolation.
@@ -231,12 +226,9 @@
for (int i = 0; i < last; i++) {
BoneChainLink* item = &m_FkChain[i];
solve2(item, tip, worldTargetTranslation);
- for (int j = item->index + 1, end = m_FkChain.size() - 1;
- j < end;
- j++) {
+ for (int j = item->index + 1, end = m_FkChain.size() - 1; j < end; j++) {
BoneChainLink& fk = m_FkChain[j];
- Mat2D::invert(fk.parentWorldInverse,
- getParentWorld(*fk.bone));
+ Mat2D::invert(fk.parentWorldInverse, getParentWorld(*fk.bone));
}
}
break;
@@ -245,8 +237,7 @@
// At the end, mix the FK angle with the IK angle by strength
if (strength() != 1.0f) {
for (BoneChainLink& fk : m_FkChain) {
- float fromAngle =
- std::fmod(fk.transformComponents.rotation(), (float)M_PI * 2);
+ float fromAngle = std::fmod(fk.transformComponents.rotation(), (float)M_PI * 2);
float toAngle = std::fmod(fk.angle, (float)M_PI * 2);
float diff = toAngle - fromAngle;
if (diff > M_PI) {
diff --git a/src/constraints/rotation_constraint.cpp b/src/constraints/rotation_constraint.cpp
index 1738243..798f4b7 100644
--- a/src/constraints/rotation_constraint.cpp
+++ b/src/constraints/rotation_constraint.cpp
@@ -26,14 +26,12 @@
Mat2D::decompose(m_ComponentsB, transformB);
if (!doesCopy()) {
- m_ComponentsB.rotation(destSpace() == TransformSpace::local
- ? 0.0f
- : m_ComponentsA.rotation());
+ m_ComponentsB.rotation(destSpace() == TransformSpace::local ? 0.0f
+ : m_ComponentsA.rotation());
} else {
m_ComponentsB.rotation(m_ComponentsB.rotation() * copyFactor());
if (offset()) {
- m_ComponentsB.rotation(m_ComponentsB.rotation() +
- component->rotation());
+ m_ComponentsB.rotation(m_ComponentsB.rotation() + component->rotation());
}
}
diff --git a/src/constraints/scale_constraint.cpp b/src/constraints/scale_constraint.cpp
index 301e5f3..891fd29 100644
--- a/src/constraints/scale_constraint.cpp
+++ b/src/constraints/scale_constraint.cpp
@@ -24,26 +24,22 @@
Mat2D::decompose(m_ComponentsB, transformB);
if (!doesCopy()) {
- m_ComponentsB.scaleX(destSpace() == TransformSpace::local
- ? 1.0f
- : m_ComponentsA.scaleX());
+ m_ComponentsB.scaleX(destSpace() == TransformSpace::local ? 1.0f
+ : m_ComponentsA.scaleX());
} else {
m_ComponentsB.scaleX(m_ComponentsB.scaleX() * copyFactor());
if (offset()) {
- m_ComponentsB.scaleX(m_ComponentsB.scaleX() *
- component->scaleX());
+ m_ComponentsB.scaleX(m_ComponentsB.scaleX() * component->scaleX());
}
}
if (!doesCopyY()) {
- m_ComponentsB.scaleY(destSpace() == TransformSpace::local
- ? 1.0f
- : m_ComponentsA.scaleY());
+ m_ComponentsB.scaleY(destSpace() == TransformSpace::local ? 1.0f
+ : m_ComponentsA.scaleY());
} else {
m_ComponentsB.scaleY(m_ComponentsB.scaleY() * copyFactorY());
if (offset()) {
- m_ComponentsB.scaleY(m_ComponentsB.scaleY() *
- component->scaleY());
+ m_ComponentsB.scaleY(m_ComponentsB.scaleY() * component->scaleY());
}
}
@@ -95,10 +91,8 @@
m_ComponentsB.rotation(m_ComponentsA.rotation());
m_ComponentsB.x(m_ComponentsA.x());
m_ComponentsB.y(m_ComponentsA.y());
- m_ComponentsB.scaleX(m_ComponentsA.scaleX() * ti +
- m_ComponentsB.scaleX() * t);
- m_ComponentsB.scaleY(m_ComponentsA.scaleY() * ti +
- m_ComponentsB.scaleY() * t);
+ m_ComponentsB.scaleX(m_ComponentsA.scaleX() * ti + m_ComponentsB.scaleX() * t);
+ m_ComponentsB.scaleY(m_ComponentsA.scaleY() * ti + m_ComponentsB.scaleY() * t);
m_ComponentsB.skew(m_ComponentsA.skew());
Mat2D::compose(component->mutableWorldTransform(), m_ComponentsB);
diff --git a/src/constraints/transform_constraint.cpp b/src/constraints/transform_constraint.cpp
index 0459dec..d92d824 100644
--- a/src/constraints/transform_constraint.cpp
+++ b/src/constraints/transform_constraint.cpp
@@ -44,10 +44,8 @@
m_ComponentsB.rotation(angleA + diff * t);
m_ComponentsB.x(m_ComponentsA.x() * ti + m_ComponentsB.x() * t);
m_ComponentsB.y(m_ComponentsA.y() * ti + m_ComponentsB.y() * t);
- m_ComponentsB.scaleX(m_ComponentsA.scaleX() * ti +
- m_ComponentsB.scaleX() * t);
- m_ComponentsB.scaleY(m_ComponentsA.scaleY() * ti +
- m_ComponentsB.scaleY() * t);
+ m_ComponentsB.scaleX(m_ComponentsA.scaleX() * ti + m_ComponentsB.scaleX() * t);
+ m_ComponentsB.scaleY(m_ComponentsA.scaleY() * ti + m_ComponentsB.scaleY() * t);
m_ComponentsB.skew(m_ComponentsA.skew() * ti + m_ComponentsB.skew() * t);
Mat2D::compose(component->mutableWorldTransform(), m_ComponentsB);
diff --git a/src/constraints/translation_constraint.cpp b/src/constraints/translation_constraint.cpp
index 4ab34ef..1c12267 100644
--- a/src/constraints/translation_constraint.cpp
+++ b/src/constraints/translation_constraint.cpp
@@ -27,8 +27,7 @@
translationB[1] = transformB[5];
if (!doesCopy()) {
- translationB[0] =
- destSpace() == TransformSpace::local ? 0.0f : translationA[0];
+ translationB[0] = destSpace() == TransformSpace::local ? 0.0f : translationA[0];
} else {
translationB[0] *= copyFactor();
if (offset()) {
@@ -37,8 +36,7 @@
}
if (!doesCopyY()) {
- translationB[1] =
- destSpace() == TransformSpace::local ? 0.0f : translationA[1];
+ translationB[1] = destSpace() == TransformSpace::local ? 0.0f : translationA[1];
} else {
translationB[1] *= copyFactorY();
diff --git a/src/core/binary_reader.cpp b/src/core/binary_reader.cpp
index b6c3205..5e2c578 100644
--- a/src/core/binary_reader.cpp
+++ b/src/core/binary_reader.cpp
@@ -5,18 +5,12 @@
using namespace rive;
-BinaryReader::BinaryReader(Span<const uint8_t> span) :
- BinaryReader(span.begin(), span.size()) {}
+BinaryReader::BinaryReader(Span<const uint8_t> span) : BinaryReader(span.begin(), span.size()) {}
BinaryReader::BinaryReader(const uint8_t* bytes, size_t length) :
- m_Position(bytes),
- m_End(bytes + length),
- m_Overflowed(false),
- m_Length(length) {}
+ m_Position(bytes), m_End(bytes + length), m_Overflowed(false), m_Length(length) {}
-bool BinaryReader::reachedEnd() const {
- return m_Position == m_End || didOverflow();
-}
+bool BinaryReader::reachedEnd() const { return m_Position == m_End || didOverflow(); }
size_t BinaryReader::lengthInBytes() const { return m_Length; }
diff --git a/src/core/field_types/core_bool_type.cpp b/src/core/field_types/core_bool_type.cpp
index 8672715..705043d 100644
--- a/src/core/field_types/core_bool_type.cpp
+++ b/src/core/field_types/core_bool_type.cpp
@@ -3,6 +3,4 @@
using namespace rive;
-bool CoreBoolType::deserialize(BinaryReader& reader) {
- return reader.readByte() == 1;
-}
\ No newline at end of file
+bool CoreBoolType::deserialize(BinaryReader& reader) { return reader.readByte() == 1; }
\ No newline at end of file
diff --git a/src/core/field_types/core_bytes_type.cpp b/src/core/field_types/core_bytes_type.cpp
index 8ec41bc..78929fb 100644
--- a/src/core/field_types/core_bytes_type.cpp
+++ b/src/core/field_types/core_bytes_type.cpp
@@ -3,6 +3,4 @@
using namespace rive;
-Span<const uint8_t> CoreBytesType::deserialize(BinaryReader& reader) {
- return reader.readBytes();
-}
\ No newline at end of file
+Span<const uint8_t> CoreBytesType::deserialize(BinaryReader& reader) { return reader.readBytes(); }
\ No newline at end of file
diff --git a/src/core/field_types/core_color_type.cpp b/src/core/field_types/core_color_type.cpp
index b87ffbd..c1cda27 100644
--- a/src/core/field_types/core_color_type.cpp
+++ b/src/core/field_types/core_color_type.cpp
@@ -3,6 +3,4 @@
using namespace rive;
-int CoreColorType::deserialize(BinaryReader& reader) {
- return reader.readUint32();
-}
\ No newline at end of file
+int CoreColorType::deserialize(BinaryReader& reader) { return reader.readUint32(); }
\ No newline at end of file
diff --git a/src/core/field_types/core_double_type.cpp b/src/core/field_types/core_double_type.cpp
index 73ab59d..a0c26e7 100644
--- a/src/core/field_types/core_double_type.cpp
+++ b/src/core/field_types/core_double_type.cpp
@@ -3,6 +3,4 @@
using namespace rive;
-double CoreDoubleType::deserialize(BinaryReader& reader) {
- return reader.readFloat32();
-}
\ No newline at end of file
+double CoreDoubleType::deserialize(BinaryReader& reader) { return reader.readFloat32(); }
\ No newline at end of file
diff --git a/src/core/field_types/core_string_type.cpp b/src/core/field_types/core_string_type.cpp
index f16f74f..2e87b99 100644
--- a/src/core/field_types/core_string_type.cpp
+++ b/src/core/field_types/core_string_type.cpp
@@ -3,6 +3,4 @@
using namespace rive;
-std::string CoreStringType::deserialize(BinaryReader& reader) {
- return reader.readString();
-}
\ No newline at end of file
+std::string CoreStringType::deserialize(BinaryReader& reader) { return reader.readString(); }
\ No newline at end of file
diff --git a/src/core/field_types/core_uint_type.cpp b/src/core/field_types/core_uint_type.cpp
index ce9eea7..d0d1242 100644
--- a/src/core/field_types/core_uint_type.cpp
+++ b/src/core/field_types/core_uint_type.cpp
@@ -3,6 +3,4 @@
using namespace rive;
-unsigned int CoreUintType::deserialize(BinaryReader& reader) {
- return (int)reader.readVarUint64();
-}
+unsigned int CoreUintType::deserialize(BinaryReader& reader) { return (int)reader.readVarUint64(); }
diff --git a/src/dependency_sorter.cpp b/src/dependency_sorter.cpp
index 711b3fe..a2f399b 100644
--- a/src/dependency_sorter.cpp
+++ b/src/dependency_sorter.cpp
@@ -8,8 +8,7 @@
visit(root, order);
}
-bool DependencySorter::visit(Component* component,
- std::vector<Component*>& order) {
+bool DependencySorter::visit(Component* component, std::vector<Component*>& order) {
if (m_Perm.find(component) != m_Perm.end()) {
return true;
}
diff --git a/src/draw_rules.cpp b/src/draw_rules.cpp
index b29a0eb..4acb10f 100644
--- a/src/draw_rules.cpp
+++ b/src/draw_rules.cpp
@@ -18,9 +18,7 @@
return StatusCode::Ok;
}
-StatusCode DrawRules::onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode DrawRules::onAddedClean(CoreContext* context) { return StatusCode::Ok; }
void DrawRules::drawTargetIdChanged() {
auto coreObject = artboard()->resolve(drawTargetId());
diff --git a/src/draw_target.cpp b/src/draw_target.cpp
index 948d85b..4f7ab45 100644
--- a/src/draw_target.cpp
+++ b/src/draw_target.cpp
@@ -18,10 +18,6 @@
return StatusCode::Ok;
}
-StatusCode DrawTarget::onAddedClean(CoreContext* context) {
- return StatusCode::Ok;
-}
+StatusCode DrawTarget::onAddedClean(CoreContext* context) { return StatusCode::Ok; }
-void DrawTarget::placementValueChanged() {
- artboard()->addDirt(ComponentDirt::DrawOrder);
-}
\ No newline at end of file
+void DrawTarget::placementValueChanged() { artboard()->addDirt(ComponentDirt::DrawOrder); }
\ No newline at end of file
diff --git a/src/drawable.cpp b/src/drawable.cpp
index fbc930d..aa8857f 100644
--- a/src/drawable.cpp
+++ b/src/drawable.cpp
@@ -6,9 +6,7 @@
using namespace rive;
-void Drawable::addClippingShape(ClippingShape* shape) {
- m_ClippingShapes.push_back(shape);
-}
+void Drawable::addClippingShape(ClippingShape* shape) { m_ClippingShapes.push_back(shape); }
bool Drawable::clip(Renderer* renderer) const {
if (m_ClippingShapes.size() == 0) {
diff --git a/src/file.cpp b/src/file.cpp
index b5174fe..3f1de50 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -48,8 +48,7 @@
// Import a single Rive runtime object.
// Used by the file importer.
-static Core* readRuntimeObject(BinaryReader& reader,
- const RuntimeHeader& header) {
+static Core* readRuntimeObject(BinaryReader& reader, const RuntimeHeader& header) {
auto coreObjectKey = reader.readVarUint64();
auto object = CoreRegistry::makeCoreInstance((int)coreObjectKey);
while (true) {
@@ -63,8 +62,7 @@
delete object;
return nullptr;
}
- if (object == nullptr || !object->deserialize((int)propertyKey, reader))
- {
+ if (object == nullptr || !object->deserialize((int)propertyKey, reader)) {
// We have an unknown object or property, first see if core knows
// the property type.
int id = CoreRegistry::propertyFieldId((int)propertyKey);
@@ -76,8 +74,7 @@
if (id == -1) {
// Still couldn't find it, give up.
fprintf(stderr,
- "Unknown property key " RIVE_FMT_U64
- ", missing from property ToC.\n",
+ "Unknown property key " RIVE_FMT_U64 ", missing from property ToC.\n",
propertyKey);
delete object;
return nullptr;
@@ -119,9 +116,8 @@
}
// Import a Rive file from a file handle
-ImportResult File::import(BinaryReader& reader,
- File** importedFile,
- FileAssetResolver* assetResolver) {
+ImportResult
+File::import(BinaryReader& reader, File** importedFile, FileAssetResolver* assetResolver) {
RuntimeHeader header;
if (!RuntimeHeader::read(reader, header)) {
fprintf(stderr, "Bad header\n");
@@ -164,9 +160,7 @@
break;
}
} else {
- fprintf(stderr,
- "Failed to import object of type %d\n",
- object->coreType());
+ fprintf(stderr, "Failed to import object of type %d\n", object->coreType());
delete object;
continue;
}
@@ -181,37 +175,32 @@
stackObject = new ArtboardImporter(object->as<Artboard>());
break;
case LinearAnimation::typeKey:
- stackObject =
- new LinearAnimationImporter(object->as<LinearAnimation>());
+ stackObject = new LinearAnimationImporter(object->as<LinearAnimation>());
break;
case KeyedObject::typeKey:
- stackObject =
- new KeyedObjectImporter(object->as<KeyedObject>());
+ stackObject = new KeyedObjectImporter(object->as<KeyedObject>());
break;
case KeyedProperty::typeKey: {
- auto importer = importStack.latest<LinearAnimationImporter>(
- LinearAnimation::typeKey);
+ auto importer =
+ importStack.latest<LinearAnimationImporter>(LinearAnimation::typeKey);
if (importer == nullptr) {
return ImportResult::malformed;
}
- stackObject = new KeyedPropertyImporter(
- importer->animation(), object->as<KeyedProperty>());
+ stackObject =
+ new KeyedPropertyImporter(importer->animation(), object->as<KeyedProperty>());
break;
}
case StateMachine::typeKey:
- stackObject =
- new StateMachineImporter(object->as<StateMachine>());
+ stackObject = new StateMachineImporter(object->as<StateMachine>());
break;
case StateMachineLayer::typeKey: {
- auto artboardImporter =
- importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
+ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey);
if (artboardImporter == nullptr) {
return ImportResult::malformed;
}
- stackObject = new StateMachineLayerImporter(
- object->as<StateMachineLayer>(),
- artboardImporter->artboard());
+ stackObject = new StateMachineLayerImporter(object->as<StateMachineLayer>(),
+ artboardImporter->artboard());
break;
}
@@ -226,13 +215,11 @@
break;
case StateTransition::typeKey:
case BlendStateTransition::typeKey:
- stackObject =
- new StateTransitionImporter(object->as<StateTransition>());
+ stackObject = new StateTransitionImporter(object->as<StateTransition>());
stackType = StateTransition::typeKey;
break;
case ImageAsset::typeKey:
- stackObject = new FileAssetImporter(object->as<FileAsset>(),
- m_AssetResolver);
+ stackObject = new FileAssetImporter(object->as<FileAsset>(), m_AssetResolver);
stackType = FileAsset::typeKey;
break;
}
diff --git a/src/hittest_command_path.cpp b/src/hittest_command_path.cpp
index 4dec9af..ef5a784 100644
--- a/src/hittest_command_path.cpp
+++ b/src/hittest_command_path.cpp
@@ -6,17 +6,11 @@
using namespace rive;
-HitTestCommandPath::HitTestCommandPath(const IAABB& area) : m_Area(area) {
- m_Tester.reset(m_Area);
-}
+HitTestCommandPath::HitTestCommandPath(const IAABB& area) : m_Area(area) { m_Tester.reset(m_Area); }
-bool HitTestCommandPath::wasHit() {
- return m_Tester.test(m_FillRule);
-}
+bool HitTestCommandPath::wasHit() { return m_Tester.test(m_FillRule); }
-void HitTestCommandPath::reset() {
- m_Tester.reset(m_Area);
-}
+void HitTestCommandPath::reset() { m_Tester.reset(m_Area); }
void HitTestCommandPath::fillRule(FillRule value) {
// remember this here, and pass it to test()
@@ -34,20 +28,12 @@
return nullptr;
}
-void HitTestCommandPath::moveTo(float x, float y) {
- m_Tester.move(m_Xform * Vec2D(x, y));
-}
+void HitTestCommandPath::moveTo(float x, float y) { m_Tester.move(m_Xform * Vec2D(x, y)); }
-void HitTestCommandPath::lineTo(float x, float y) {
- m_Tester.line(m_Xform * Vec2D(x, y));
-}
+void HitTestCommandPath::lineTo(float x, float y) { m_Tester.line(m_Xform * Vec2D(x, y)); }
void HitTestCommandPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) {
- m_Tester.cubic(m_Xform * Vec2D(ox, oy),
- m_Xform * Vec2D(ix, iy),
- m_Xform * Vec2D( x, y));
+ m_Tester.cubic(m_Xform * Vec2D(ox, oy), m_Xform * Vec2D(ix, iy), m_Xform * Vec2D(x, y));
}
-void HitTestCommandPath::close() {
- m_Tester.close();
-}
+void HitTestCommandPath::close() { m_Tester.close(); }
diff --git a/src/importers/artboard_importer.cpp b/src/importers/artboard_importer.cpp
index 34959fe..c831324 100644
--- a/src/importers/artboard_importer.cpp
+++ b/src/importers/artboard_importer.cpp
@@ -8,9 +8,7 @@
ArtboardImporter::ArtboardImporter(Artboard* artboard) : m_Artboard(artboard) {}
-void ArtboardImporter::addComponent(Core* object) {
- m_Artboard->addObject(object);
-}
+void ArtboardImporter::addComponent(Core* object) { m_Artboard->addObject(object); }
void ArtboardImporter::addAnimation(LinearAnimation* animation) {
m_Artboard->addAnimation(animation);
diff --git a/src/importers/backboard_importer.cpp b/src/importers/backboard_importer.cpp
index 306d56c..35efecd 100644
--- a/src/importers/backboard_importer.cpp
+++ b/src/importers/backboard_importer.cpp
@@ -11,12 +11,9 @@
m_NestedArtboards.push_back(artboard);
}
-void BackboardImporter::addFileAsset(FileAsset* asset) {
- m_FileAssets.push_back(asset);
-}
+void BackboardImporter::addFileAsset(FileAsset* asset) { m_FileAssets.push_back(asset); }
-void BackboardImporter::addFileAssetReferencer(
- FileAssetReferencer* referencer) {
+void BackboardImporter::addFileAssetReferencer(FileAssetReferencer* referencer) {
m_FileAssetReferencers.push_back(referencer);
}
diff --git a/src/importers/file_asset_importer.cpp b/src/importers/file_asset_importer.cpp
index 9c69728..0357271 100644
--- a/src/importers/file_asset_importer.cpp
+++ b/src/importers/file_asset_importer.cpp
@@ -7,8 +7,7 @@
using namespace rive;
-FileAssetImporter::FileAssetImporter(FileAsset* fileAsset,
- FileAssetResolver* assetResolver) :
+FileAssetImporter::FileAssetImporter(FileAsset* fileAsset, FileAssetResolver* assetResolver) :
m_FileAsset(fileAsset), m_FileAssetResolver(assetResolver) {}
void FileAssetImporter::loadContents(const FileAssetContents& contents) {
diff --git a/src/importers/keyed_object_importer.cpp b/src/importers/keyed_object_importer.cpp
index 6d570e1..8cbbf1f 100644
--- a/src/importers/keyed_object_importer.cpp
+++ b/src/importers/keyed_object_importer.cpp
@@ -5,8 +5,7 @@
using namespace rive;
-KeyedObjectImporter::KeyedObjectImporter(KeyedObject* keyedObject) :
- m_KeyedObject(keyedObject) {}
+KeyedObjectImporter::KeyedObjectImporter(KeyedObject* keyedObject) : m_KeyedObject(keyedObject) {}
void KeyedObjectImporter::addKeyedProperty(KeyedProperty* property) {
m_KeyedObject->addKeyedProperty(property);
diff --git a/src/importers/layer_state_importer.cpp b/src/importers/layer_state_importer.cpp
index 0923800..5ac3056 100644
--- a/src/importers/layer_state_importer.cpp
+++ b/src/importers/layer_state_importer.cpp
@@ -32,8 +32,7 @@
auto blendStateTransition = transition->as<BlendStateTransition>();
size_t exitId = blendStateTransition->exitBlendAnimationId();
if (exitId < blendState->m_Animations.size()) {
- blendStateTransition->m_ExitBlendAnimation =
- blendState->m_Animations[exitId];
+ blendStateTransition->m_ExitBlendAnimation = blendState->m_Animations[exitId];
}
}
}
diff --git a/src/importers/state_machine_importer.cpp b/src/importers/state_machine_importer.cpp
index a5b54b3..6acd11d 100644
--- a/src/importers/state_machine_importer.cpp
+++ b/src/importers/state_machine_importer.cpp
@@ -3,16 +3,11 @@
using namespace rive;
-StateMachineImporter::StateMachineImporter(StateMachine* machine) :
- m_StateMachine(machine) {}
+StateMachineImporter::StateMachineImporter(StateMachine* machine) : m_StateMachine(machine) {}
-void StateMachineImporter::addLayer(StateMachineLayer* layer) {
- m_StateMachine->addLayer(layer);
-}
+void StateMachineImporter::addLayer(StateMachineLayer* layer) { m_StateMachine->addLayer(layer); }
-void StateMachineImporter::addInput(StateMachineInput* input) {
- m_StateMachine->addInput(input);
-}
+void StateMachineImporter::addInput(StateMachineInput* input) { m_StateMachine->addInput(input); }
bool StateMachineImporter::readNullObject() {
// Hard assumption that we won't add new layer types...
diff --git a/src/importers/state_machine_layer_importer.cpp b/src/importers/state_machine_layer_importer.cpp
index 65116f1..0859927 100644
--- a/src/importers/state_machine_layer_importer.cpp
+++ b/src/importers/state_machine_layer_importer.cpp
@@ -9,9 +9,7 @@
StateMachineLayerImporter::StateMachineLayerImporter(StateMachineLayer* layer,
const Artboard* artboard) :
m_Layer(layer), m_Artboard(artboard) {}
-void StateMachineLayerImporter::addState(LayerState* state) {
- m_Layer->addState(state);
-}
+void StateMachineLayerImporter::addState(LayerState* state) { m_Layer->addState(state); }
StatusCode StateMachineLayerImporter::resolve() {
@@ -20,8 +18,7 @@
auto animationState = state->as<AnimationState>();
if (animationState->animationId() != -1) {
- animationState->m_Animation =
- m_Artboard->animation(animationState->animationId());
+ animationState->m_Animation = m_Artboard->animation(animationState->animationId());
if (animationState->m_Animation == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/math/aabb.cpp b/src/math/aabb.cpp
index 5e77188..44248ab 100644
--- a/src/math/aabb.cpp
+++ b/src/math/aabb.cpp
@@ -10,8 +10,8 @@
bool AABB::isValid(const AABB& a) {
float dx = a[2] - a[0];
float dy = a[3] - a[1];
- return dx >= 0.0f && dy >= 0.0f && std::isfinite(a[0]) &&
- std::isfinite(a[1]) && std::isfinite(a[2]) && std::isfinite(a[3]);
+ return dx >= 0.0f && dy >= 0.0f && std::isfinite(a[0]) && std::isfinite(a[1]) &&
+ std::isfinite(a[2]) && std::isfinite(a[3]);
}
bool AABB::testOverlap(const AABB& a, const AABB& b) {
@@ -44,13 +44,9 @@
out[3] = std::fmax(p1[1], std::fmax(p2[1], std::fmax(p3[1], p4[1])));
}
-static inline float graphics_roundf(float x) {
- return std::floor(x + 0.5f);
-}
+static inline float graphics_roundf(float x) { return std::floor(x + 0.5f); }
-static inline int graphics_round(float x) {
- return (int)graphics_roundf(x);
-}
+static inline int graphics_round(float x) { return (int)graphics_roundf(x); }
IAABB AABB::round() const {
return {
@@ -60,4 +56,3 @@
graphics_round(bottom()),
};
}
-
diff --git a/src/math/hit_test.cpp b/src/math/hit_test.cpp
index d652c0b..038273b 100644
--- a/src/math/hit_test.cpp
+++ b/src/math/hit_test.cpp
@@ -10,27 +10,19 @@
using namespace rive;
-static inline float graphics_roundf(float x) {
- return std::floor(x + 0.5f);
-}
+static inline float graphics_roundf(float x) { return std::floor(x + 0.5f); }
-static inline int graphics_round(float x) {
- return (int)graphics_roundf(x);
-}
+static inline int graphics_round(float x) { return (int)graphics_roundf(x); }
struct Point {
float x, y;
-
+
Point() {}
Point(float xx, float yy) : x(xx), y(yy) {}
Point(const Vec2D& src) : x(src.x()), y(src.y()) {}
- Point operator+(Point v) const {
- return { x + v.x, y + v.y };
- }
- Point operator-(Point v) const {
- return { x - v.x, y - v.y };
- }
+ Point operator+(Point v) const { return {x + v.x, y + v.y}; }
+ Point operator-(Point v) const { return {x - v.x, y - v.y}; }
Point& operator+=(Point v) {
*this = *this + v;
@@ -41,24 +33,16 @@
return *this;
}
- friend Point operator*(Point v, float s) {
- return { v.x * s, v.y * s };
- }
- friend Point operator*(float s, Point v) {
- return { v.x * s, v.y * s };
- }
+ friend Point operator*(Point v, float s) { return {v.x * s, v.y * s}; }
+ friend Point operator*(float s, Point v) { return {v.x * s, v.y * s}; }
};
-template <typename T> T lerp(T a, T b, float t) {
- return a + (b - a) * t;
-}
+template <typename T> T lerp(T a, T b, float t) { return a + (b - a) * t; }
-template <typename T> T ave(T a, T b) {
- return lerp(a, b, 0.5f);
-}
+template <typename T> T ave(T a, T b) { return lerp(a, b, 0.5f); }
-static void append_line(const float height, Point p0, Point p1, float m,
- int winding, int delta[], int iwidth) {
+static void
+append_line(const float height, Point p0, Point p1, float m, int winding, int delta[], int iwidth) {
assert(winding == 1 || winding == -1);
int top = graphics_round(p0.y);
@@ -109,7 +93,7 @@
p1.x += m * (height - p1.y);
p1.y = height;
}
-
+
assert(p0.y <= p1.y);
assert(p0.y >= 0);
assert(p1.y <= height);
@@ -117,18 +101,18 @@
append_line(height, p0, p1, m, winding, delta, iwidth);
}
-#define MAX_CURVE_SEGMENTS (1 << 8)
+#define MAX_CURVE_SEGMENTS (1 << 8)
static int compute_cubic_segments(Point a, Point b, Point c, Point d) {
Point abc = a - b - b + c;
Point bcd = b - c - c + d;
float dx = std::max(std::abs(abc.x), std::abs(bcd.x));
float dy = std::max(std::abs(abc.y), std::abs(bcd.y));
- float dist = sqrtf(dx*dx + dy*dy);
+ float dist = sqrtf(dx * dx + dy * dy);
// count = sqrt(6*dist / 8*tol)
// tol = 0.25
// count = sqrt(3*dist)
- float count = sqrtf(3*dist);
+ float count = sqrtf(3 * dist);
return std::max(1, std::min((int)ceilf(count), MAX_CURVE_SEGMENTS));
}
@@ -138,7 +122,7 @@
//
struct CubicCoeff {
Point A, B, C, D;
-
+
// a(1-t)^3 + 3bt(1-t)^2 + 3ct^2(1-t) + dt^3
// a - 3at + 3at^2 - at^3 a(1 - 3t + 3t^2 - t^3)
// 3bt - 6bt^2 + 3bt^3 3b( t - 2t^2 + t^3)
@@ -148,25 +132,21 @@
// D + Ct + Bt^2 + At^3
//
CubicCoeff(Point a, Point b, Point c, Point d) {
- A = (d - a) + 3.0f*(b - c);
- B = 3.0f*((c - b) + (a - b));
- C = 3.0f*(b - a);
+ A = (d - a) + 3.0f * (b - c);
+ B = 3.0f * ((c - b) + (a - b));
+ C = 3.0f * (b - a);
D = a;
}
-
- Point eval(float t) const {
- return ((A*t + B)*t + C)*t + D;
- }
+
+ Point eval(float t) const { return ((A * t + B) * t + C) * t + D; }
};
////////////////////////////////////////////
-void HitTester::reset() {
- m_DW.clear();
-}
+void HitTester::reset() { m_DW.clear(); }
void HitTester::reset(const IAABB& clip) {
- m_offset = Vec2D{ (float)clip.left, (float)clip.top };
+ m_offset = Vec2D{(float)clip.left, (float)clip.top};
m_height = (float)clip.height();
m_IWidth = clip.width();
@@ -198,7 +178,6 @@
void HitTester::quad(Vec2D b, Vec2D c) {
assert(!m_ExpectsMove);
-
m_Prev = c;
}
@@ -210,14 +189,14 @@
struct CubicChop {
Vec2D storage[7];
-
+
CubicChop(Vec2D a, Vec2D b, Vec2D c, Vec2D d) {
auto ab = ave(a, b);
auto bc = ave(b, c);
auto cd = ave(c, d);
auto abc = ave(ab, bc);
auto bcd = ave(bc, cd);
-
+
storage[0] = a;
storage[1] = ab;
storage[2] = abc;
@@ -226,7 +205,7 @@
storage[5] = cd;
storage[6] = d;
}
-
+
Vec2D operator[](unsigned index) const {
assert(index < 7);
return storage[index];
@@ -242,14 +221,14 @@
// The key win is quickRejectCubic. This is how we save time over just
// evaluating the cubic up front.
//
-#define MAX_LOCAL_SEGMENTS 16
+#define MAX_LOCAL_SEGMENTS 16
void HitTester::recurse_cubic(Vec2D b, Vec2D c, Vec2D d, int count) {
if (quickRejectCubic(m_height, m_Prev, b, c, d)) {
m_Prev = d;
return;
}
-
+
if (count > MAX_LOCAL_SEGMENTS) {
CubicChop chop(m_Prev, b, c, d);
const int newCount = (count + 1) >> 1;
@@ -279,12 +258,12 @@
b = b - m_offset;
c = c - m_offset;
d = d - m_offset;
-
+
if (quickRejectCubic(m_height, m_Prev, b, c, d)) {
m_Prev = d;
return;
}
-
+
const int count = compute_cubic_segments(m_Prev, b, c, d);
this->recurse_cubic(b, c, d, count);
@@ -299,10 +278,10 @@
void HitTester::addRect(const AABB& rect, const Mat2D& xform, PathDirection dir) {
const Vec2D pts[] = {
- xform * Vec2D{rect.left(), rect.top()},
+ xform * Vec2D{rect.left(), rect.top()},
xform * Vec2D{rect.right(), rect.top()},
xform * Vec2D{rect.right(), rect.bottom()},
- xform * Vec2D{rect.left(), rect.bottom()},
+ xform * Vec2D{rect.left(), rect.bottom()},
};
move(pts[0]);
diff --git a/src/math/mat2d.cpp b/src/math/mat2d.cpp
index 4b91ae4..7d62d59 100644
--- a/src/math/mat2d.cpp
+++ b/src/math/mat2d.cpp
@@ -6,8 +6,7 @@
using namespace rive;
Mat2D Mat2D::fromRotation(float rad) {
- float s = 0,
- c = 1;
+ float s = 0, c = 1;
if (rad != 0) {
s = sin(rad);
c = cos(rad);
@@ -16,16 +15,20 @@
}
Mat2D Mat2D::scale(const Mat2D& mat, const Vec2D& vec) {
- const float v0 = vec[0],
- v1 = vec[1];
+ const float v0 = vec[0], v1 = vec[1];
return {
- mat[0] * v0, mat[1] * v0, mat[2] * v1, mat[3] * v1, mat[4], mat[5],
+ mat[0] * v0,
+ mat[1] * v0,
+ mat[2] * v1,
+ mat[3] * v1,
+ mat[4],
+ mat[5],
};
}
Mat2D Mat2D::multiply(const Mat2D& a, const Mat2D& b) {
- float a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
- b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
+ float a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], b0 = b[0], b1 = b[1],
+ b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
return {
a0 * b0 + a2 * b1,
a1 * b0 + a3 * b1,
diff --git a/src/math/raw_path.cpp b/src/math/raw_path.cpp
index 775b94b..651eb79 100644
--- a/src/math/raw_path.cpp
+++ b/src/math/raw_path.cpp
@@ -11,7 +11,7 @@
if (this->empty()) {
return {0, 0, 0, 0};
}
-
+
float l, t, r, b;
l = r = m_Points[0].x();
t = b = m_Points[0].y();
@@ -28,8 +28,8 @@
void RawPath::move(Vec2D a) {
const auto n = m_Verbs.size();
- if (n > 0 && m_Verbs[n-1] == PathVerb::move) {
- m_Points[n-1] = a; // replace previous move position
+ if (n > 0 && m_Verbs[n - 1] == PathVerb::move) {
+ m_Points[n - 1] = a; // replace previous move position
} else {
m_Points.push_back(a);
m_Verbs.push_back(PathVerb::move);
@@ -56,7 +56,7 @@
void RawPath::close() {
const auto n = m_Verbs.size();
- if (n > 0 && m_Verbs[n-1] != PathVerb::close) {
+ if (n > 0 && m_Verbs[n - 1] != PathVerb::close) {
m_Verbs.push_back(PathVerb::close);
}
}
@@ -115,11 +115,19 @@
constexpr float C = 0.5519150244935105707435627f;
// precompute clockwise unit circle, starting and ending at {1, 0}
constexpr rive::Vec2D unit[] = {
- { 1, 0}, { 1, C}, { C, 1}, // quadrant 1 ( 4:30)
- { 0, 1}, {-C, 1}, {-1, C}, // quadrant 2 ( 7:30)
- {-1, 0}, {-1, -C}, {-C, -1}, // quadrant 3 (10:30)
- { 0, -1}, { C, -1}, { 1, -C}, // quadrant 4 ( 1:30)
- { 1, 0},
+ {1, 0},
+ {1, C},
+ {C, 1}, // quadrant 1 ( 4:30)
+ {0, 1},
+ {-C, 1},
+ {-1, C}, // quadrant 2 ( 7:30)
+ {-1, 0},
+ {-1, -C},
+ {-C, -1}, // quadrant 3 (10:30)
+ {0, -1},
+ {C, -1},
+ {1, -C}, // quadrant 4 ( 1:30)
+ {1, 0},
};
const auto center = r.center();
@@ -138,12 +146,12 @@
if (dir == PathDirection::clockwise) {
move(map(unit[0]));
for (int i = 1; i <= 12; i += 3) {
- cubic(map(unit[i+0]), map(unit[i+1]), map(unit[i+2]));
+ cubic(map(unit[i + 0]), map(unit[i + 1]), map(unit[i + 2]));
}
} else {
move(map(unit[12]));
for (int i = 11; i >= 0; i -= 3) {
- cubic(map(unit[i-0]), map(unit[i-1]), map(unit[i-2]));
+ cubic(map(unit[i - 0]), map(unit[i - 1]), map(unit[i - 2]));
}
}
close();
@@ -153,7 +161,7 @@
if (span.size() == 0) {
return;
}
-
+
// should we permit must moveTo() or just moveTo()/close() ?
m_Points.reserve(span.size() + isClosed);
diff --git a/src/math/vec2d.cpp b/src/math/vec2d.cpp
index 45d19c4..52b27a8 100644
--- a/src/math/vec2d.cpp
+++ b/src/math/vec2d.cpp
@@ -10,9 +10,7 @@
m[1] * a.x() + m[3] * a.y(),
};
}
-float Vec2D::length() const {
- return std::sqrt(lengthSquared());
-}
+float Vec2D::length() const { return std::sqrt(lengthSquared()); }
Vec2D Vec2D::normalized() const {
auto len2 = lengthSquared();
diff --git a/src/nested_artboard.cpp b/src/nested_artboard.cpp
index a4658ad..adae05a 100644
--- a/src/nested_artboard.cpp
+++ b/src/nested_artboard.cpp
@@ -13,8 +13,7 @@
}
}
Core* NestedArtboard::clone() const {
- NestedArtboard* nestedArtboard =
- static_cast<NestedArtboard*>(NestedArtboardBase::clone());
+ NestedArtboard* nestedArtboard = static_cast<NestedArtboard*>(NestedArtboardBase::clone());
if (m_NestedInstance == nullptr) {
return nestedArtboard;
}
@@ -57,8 +56,7 @@
}
StatusCode NestedArtboard::import(ImportStack& importStack) {
- auto backboardImporter =
- importStack.latest<BackboardImporter>(Backboard::typeKey);
+ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey);
if (backboardImporter == nullptr) {
return StatusCode::MissingObject;
}
@@ -98,9 +96,7 @@
void NestedArtboard::update(ComponentDirt value) {
Super::update(value);
- if (hasDirt(value, ComponentDirt::WorldTransform) &&
- m_NestedInstance != nullptr)
- {
+ if (hasDirt(value, ComponentDirt::WorldTransform) && m_NestedInstance != nullptr) {
m_NestedInstance->opacity(renderOpacity());
}
}
diff --git a/src/renderer.cpp b/src/renderer.cpp
index 16c01a0..fc961a2 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -3,13 +3,9 @@
using namespace rive;
-void Renderer::translate(float tx, float ty) {
- this->transform(Mat2D(1, 0, 0, 1, tx, ty));
-}
+void Renderer::translate(float tx, float ty) { this->transform(Mat2D(1, 0, 0, 1, tx, ty)); }
-void Renderer::scale(float sx, float sy) {
- this->transform(Mat2D(sx, 0, 0, sy, 0, 0));
-}
+void Renderer::scale(float sx, float sy) { this->transform(Mat2D(sx, 0, 0, sy, 0, 0)); }
void Renderer::rotate(float radians) {
const float s = std::sin(radians);
@@ -17,74 +13,63 @@
this->transform(Mat2D(c, s, -s, c, 0, 0));
}
-void Renderer::computeAlignment(Mat2D& result,
- Fit fit,
- const Alignment& alignment,
- const AABB& frame,
- const AABB& content)
-{
+void Renderer::computeAlignment(
+ Mat2D& result, Fit fit, const Alignment& alignment, const AABB& frame, const AABB& content) {
float contentWidth = content[2] - content[0];
float contentHeight = content[3] - content[1];
- float x = -content[0] - contentWidth / 2.0 -
- (alignment.x() * contentWidth / 2.0);
- float y = -content[1] - contentHeight / 2.0 -
- (alignment.y() * contentHeight / 2.0);
+ float x = -content[0] - contentWidth / 2.0 - (alignment.x() * contentWidth / 2.0);
+ float y = -content[1] - contentHeight / 2.0 - (alignment.y() * contentHeight / 2.0);
float scaleX = 1.0, scaleY = 1.0;
switch (fit) {
- case Fit::fill: {
- scaleX = frame.width() / contentWidth;
- scaleY = frame.height() / contentHeight;
- break;
- }
- case Fit::contain: {
- float minScale = std::fmin(frame.width() / contentWidth,
- frame.height() / contentHeight);
- scaleX = scaleY = minScale;
- break;
- }
- case Fit::cover: {
- float maxScale = std::fmax(frame.width() / contentWidth,
- frame.height() / contentHeight);
- scaleX = scaleY = maxScale;
- break;
- }
- case Fit::fitHeight: {
- float minScale = frame.height() / contentHeight;
- scaleX = scaleY = minScale;
- break;
- }
- case Fit::fitWidth: {
- float minScale = frame.width() / contentWidth;
- scaleX = scaleY = minScale;
- break;
- }
- case Fit::none: {
- scaleX = scaleY = 1.0;
- break;
- }
- case Fit::scaleDown: {
- float minScale = std::fmin(frame.width() / contentWidth,
- frame.height() / contentHeight);
- scaleX = scaleY = minScale < 1.0 ? minScale : 1.0;
- break;
- }
+ case Fit::fill: {
+ scaleX = frame.width() / contentWidth;
+ scaleY = frame.height() / contentHeight;
+ break;
+ }
+ case Fit::contain: {
+ float minScale =
+ std::fmin(frame.width() / contentWidth, frame.height() / contentHeight);
+ scaleX = scaleY = minScale;
+ break;
+ }
+ case Fit::cover: {
+ float maxScale =
+ std::fmax(frame.width() / contentWidth, frame.height() / contentHeight);
+ scaleX = scaleY = maxScale;
+ break;
+ }
+ case Fit::fitHeight: {
+ float minScale = frame.height() / contentHeight;
+ scaleX = scaleY = minScale;
+ break;
+ }
+ case Fit::fitWidth: {
+ float minScale = frame.width() / contentWidth;
+ scaleX = scaleY = minScale;
+ break;
+ }
+ case Fit::none: {
+ scaleX = scaleY = 1.0;
+ break;
+ }
+ case Fit::scaleDown: {
+ float minScale =
+ std::fmin(frame.width() / contentWidth, frame.height() / contentHeight);
+ scaleX = scaleY = minScale < 1.0 ? minScale : 1.0;
+ break;
+ }
}
Mat2D translation;
- translation[4] = frame[0] + frame.width() / 2.0 +
- (alignment.x() * frame.width() / 2.0);
- translation[5] = frame[1] + frame.height() / 2.0 +
- (alignment.y() * frame.height() / 2.0);
+ translation[4] = frame[0] + frame.width() / 2.0 + (alignment.x() * frame.width() / 2.0);
+ translation[5] = frame[1] + frame.height() / 2.0 + (alignment.y() * frame.height() / 2.0);
result = translation * Mat2D::fromScale(scaleX, scaleY) * Mat2D::fromTranslate(x, y);
}
-void Renderer::align(Fit fit,
- const Alignment& alignment,
- const AABB& frame,
- const AABB& content) {
+void Renderer::align(Fit fit, const Alignment& alignment, const AABB& frame, const AABB& content) {
Mat2D result;
computeAlignment(result, fit, alignment, frame, content);
transform(result);
diff --git a/src/shapes/clipping_shape.cpp b/src/shapes/clipping_shape.cpp
index 3ba12b9..f9bbc7d 100644
--- a/src/shapes/clipping_shape.cpp
+++ b/src/shapes/clipping_shape.cpp
@@ -38,8 +38,7 @@
while (component != nullptr) {
if (component == m_Source) {
auto shape = core->as<Shape>();
- shape->addDefaultPathSpace(PathSpace::World |
- PathSpace::Clipping);
+ shape->addDefaultPathSpace(PathSpace::World | PathSpace::Clipping);
m_Shapes.push_back(shape);
break;
}
@@ -82,8 +81,7 @@
m_RenderPath->fillRule((FillRule)fillRule());
for (auto shape : m_Shapes) {
if (!shape->isHidden()) {
- m_RenderPath->addPath(shape->pathComposer()->worldPath(),
- identity);
+ m_RenderPath->addPath(shape->pathComposer()->worldPath(), identity);
}
}
}
diff --git a/src/shapes/cubic_asymmetric_vertex.cpp b/src/shapes/cubic_asymmetric_vertex.cpp
index 96fb60a..703c104 100644
--- a/src/shapes/cubic_asymmetric_vertex.cpp
+++ b/src/shapes/cubic_asymmetric_vertex.cpp
@@ -4,27 +4,19 @@
using namespace rive;
-static Vec2D get_point(const CubicAsymmetricVertex& v) {
- return Vec2D(v.x(), v.y());
-}
+static Vec2D get_point(const CubicAsymmetricVertex& v) { return Vec2D(v.x(), v.y()); }
static Vec2D in_vector(const CubicAsymmetricVertex& v) {
- return Vec2D(cos(v.rotation()) * v.inDistance(),
- sin(v.rotation()) * v.inDistance());
+ return Vec2D(cos(v.rotation()) * v.inDistance(), sin(v.rotation()) * v.inDistance());
}
static Vec2D out_vector(const CubicAsymmetricVertex& v) {
- return Vec2D(cos(v.rotation()) * v.outDistance(),
- sin(v.rotation()) * v.outDistance());
+ return Vec2D(cos(v.rotation()) * v.outDistance(), sin(v.rotation()) * v.outDistance());
}
-void CubicAsymmetricVertex::computeIn() {
- m_InPoint = get_point(*this) - in_vector(*this);
-}
+void CubicAsymmetricVertex::computeIn() { m_InPoint = get_point(*this) - in_vector(*this); }
-void CubicAsymmetricVertex::computeOut() {
- m_OutPoint = get_point(*this) + out_vector(*this);
-}
+void CubicAsymmetricVertex::computeOut() { m_OutPoint = get_point(*this) + out_vector(*this); }
void CubicAsymmetricVertex::rotationChanged() {
m_InValid = false;
diff --git a/src/shapes/cubic_detached_vertex.cpp b/src/shapes/cubic_detached_vertex.cpp
index c60acc8..8a93166 100644
--- a/src/shapes/cubic_detached_vertex.cpp
+++ b/src/shapes/cubic_detached_vertex.cpp
@@ -4,27 +4,19 @@
using namespace rive;
-static Vec2D get_point(const CubicDetachedVertex& v) {
- return Vec2D(v.x(), v.y());
-}
+static Vec2D get_point(const CubicDetachedVertex& v) { return Vec2D(v.x(), v.y()); }
static Vec2D in_vector(const CubicDetachedVertex& v) {
- return Vec2D(cos(v.inRotation()) * v.inDistance(),
- sin(v.inRotation()) * v.inDistance());
+ return Vec2D(cos(v.inRotation()) * v.inDistance(), sin(v.inRotation()) * v.inDistance());
}
static Vec2D out_vector(const CubicDetachedVertex& v) {
- return Vec2D(cos(v.outRotation()) * v.outDistance(),
- sin(v.outRotation()) * v.outDistance());
+ return Vec2D(cos(v.outRotation()) * v.outDistance(), sin(v.outRotation()) * v.outDistance());
}
-void CubicDetachedVertex::computeIn() {
- m_InPoint = get_point(*this) + in_vector(*this);
-}
+void CubicDetachedVertex::computeIn() { m_InPoint = get_point(*this) + in_vector(*this); }
-void CubicDetachedVertex::computeOut() {
- m_OutPoint = get_point(*this) + out_vector(*this);
-}
+void CubicDetachedVertex::computeOut() { m_OutPoint = get_point(*this) + out_vector(*this); }
void CubicDetachedVertex::inRotationChanged() {
m_InValid = false;
diff --git a/src/shapes/cubic_mirrored_vertex.cpp b/src/shapes/cubic_mirrored_vertex.cpp
index 8757d69..5656622 100644
--- a/src/shapes/cubic_mirrored_vertex.cpp
+++ b/src/shapes/cubic_mirrored_vertex.cpp
@@ -4,22 +4,15 @@
using namespace rive;
-static Vec2D get_point(const CubicMirroredVertex& v) {
- return Vec2D(v.x(), v.y());
-}
+static Vec2D get_point(const CubicMirroredVertex& v) { return Vec2D(v.x(), v.y()); }
static Vec2D get_vector(const CubicMirroredVertex& v) {
- return Vec2D(cos(v.rotation()) * v.distance(),
- sin(v.rotation()) * v.distance());
+ return Vec2D(cos(v.rotation()) * v.distance(), sin(v.rotation()) * v.distance());
}
-void CubicMirroredVertex::computeIn() {
- m_InPoint = get_point(*this) - get_vector(*this);
-}
+void CubicMirroredVertex::computeIn() { m_InPoint = get_point(*this) - get_vector(*this); }
-void CubicMirroredVertex::computeOut() {
- m_OutPoint = get_point(*this) + get_vector(*this);
-}
+void CubicMirroredVertex::computeOut() { m_OutPoint = get_point(*this) + get_vector(*this); }
void CubicMirroredVertex::rotationChanged() {
m_InValid = m_OutValid = false;
diff --git a/src/shapes/cubic_vertex.cpp b/src/shapes/cubic_vertex.cpp
index 1a1c7c8..c359f01 100644
--- a/src/shapes/cubic_vertex.cpp
+++ b/src/shapes/cubic_vertex.cpp
@@ -53,8 +53,7 @@
m_InValid = m_OutValid = false;
}
-void CubicVertex::deform(const Mat2D& worldTransform,
- const float* boneTransforms) {
+void CubicVertex::deform(const Mat2D& worldTransform, const float* boneTransforms) {
Super::deform(worldTransform, boneTransforms);
auto cubicWeight = weight<CubicWeight>();
diff --git a/src/shapes/image.cpp b/src/shapes/image.cpp
index 6fe50c6..9d11a61 100644
--- a/src/shapes/image.cpp
+++ b/src/shapes/image.cpp
@@ -45,7 +45,7 @@
printf("Missing mesh\n");
// TODO: hittest mesh
} else {
- auto mx = xform * worldTransform() * Mat2D::fromTranslate(-width*0.5f, -height*0.5f);
+ auto mx = xform * worldTransform() * Mat2D::fromTranslate(-width * 0.5f, -height * 0.5f);
HitTester tester(hinfo->area);
tester.addRect(AABB(0, 0, width, height), mx);
if (tester.test()) {
@@ -55,10 +55,8 @@
return nullptr;
}
-
StatusCode Image::import(ImportStack& importStack) {
- auto backboardImporter =
- importStack.latest<BackboardImporter>(Backboard::typeKey);
+ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey);
if (backboardImporter == nullptr) {
return StatusCode::MissingObject;
}
diff --git a/src/shapes/mesh.cpp b/src/shapes/mesh.cpp
index ded4edc..5f24336 100644
--- a/src/shapes/mesh.cpp
+++ b/src/shapes/mesh.cpp
@@ -104,10 +104,7 @@
Super::update(value);
}
-void Mesh::draw(Renderer* renderer,
- const RenderImage* image,
- BlendMode blendMode,
- float opacity) {
+void Mesh::draw(Renderer* renderer, const RenderImage* image, BlendMode blendMode, float opacity) {
if (m_VertexRenderBuffer == nullptr) {
std::vector<float> vertices(m_Vertices.size() * 2);
@@ -121,13 +118,8 @@
}
if (skin() == nullptr) {
- renderer->transform(
- parent()->as<WorldTransformComponent>()->worldTransform());
+ renderer->transform(parent()->as<WorldTransformComponent>()->worldTransform());
}
- renderer->drawImageMesh(image,
- m_VertexRenderBuffer,
- m_UVRenderBuffer,
- m_IndexRenderBuffer,
- blendMode,
- opacity);
+ renderer->drawImageMesh(
+ image, m_VertexRenderBuffer, m_UVRenderBuffer, m_IndexRenderBuffer, blendMode, opacity);
}
diff --git a/src/shapes/mesh_vertex.cpp b/src/shapes/mesh_vertex.cpp
index 1d2439a..d381f17 100644
--- a/src/shapes/mesh_vertex.cpp
+++ b/src/shapes/mesh_vertex.cpp
@@ -2,9 +2,7 @@
#include "rive/shapes/mesh.hpp"
using namespace rive;
-void MeshVertex::markGeometryDirty() {
- parent()->as<Mesh>()->markDrawableDirty();
-}
+void MeshVertex::markGeometryDirty() { parent()->as<Mesh>()->markDrawableDirty(); }
StatusCode MeshVertex::onAddedDirty(CoreContext* context) {
StatusCode code = Super::onAddedDirty(context);
diff --git a/src/shapes/metrics_path.cpp b/src/shapes/metrics_path.cpp
index 6d80319..6399d6c 100644
--- a/src/shapes/metrics_path.cpp
+++ b/src/shapes/metrics_path.cpp
@@ -38,8 +38,7 @@
m_Points.emplace_back(Vec2D(x, y));
}
-void MetricsPath::cubicTo(
- float ox, float oy, float ix, float iy, float x, float y) {
+void MetricsPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) {
m_Parts.push_back(PathPart(1, m_Points.size()));
m_Points.emplace_back(Vec2D(ox, oy));
m_Points.emplace_back(Vec2D(ix, iy));
@@ -71,10 +70,8 @@
return std::max(std::abs(a[0] - b[0]), std::abs(a[1] - b[1])) > distTooFar;
}
-static bool shouldSplitCubic(const Vec2D& from,
- const Vec2D& fromOut,
- const Vec2D& toIn,
- const Vec2D& to) {
+static bool
+shouldSplitCubic(const Vec2D& from, const Vec2D& fromOut, const Vec2D& toIn, const Vec2D& to) {
const Vec2D oneThird = Vec2D::lerp(from, to, 1.0f / 3.0f),
twoThird = Vec2D::lerp(from, to, 2.0f / 3.0f);
return tooFar(fromOut, oneThird) || tooFar(toIn, twoThird);
@@ -95,16 +92,10 @@
Vec2D hull[6];
computeHull(from, fromOut, toIn, to, 0.5f, hull);
- runningLength = segmentCubic(from,
- hull[0],
- hull[3],
- hull[5],
- runningLength,
- t1,
- halfT,
- segments);
- runningLength = segmentCubic(
- hull[5], hull[4], hull[2], to, runningLength, halfT, t2, segments);
+ runningLength =
+ segmentCubic(from, hull[0], hull[3], hull[5], runningLength, t1, halfT, segments);
+ runningLength =
+ segmentCubic(hull[5], hull[4], hull[2], to, runningLength, halfT, t2, segments);
} else {
float length = Vec2D::distance(from, to);
runningLength += length;
@@ -167,8 +158,8 @@
int index = (int)m_CubicSegments.size();
part.type = index + 1;
- float partLength = segmentCubic(
- from, fromOut, toIn, to, 0.0f, 0.0f, 1.0f, m_CubicSegments);
+ float partLength =
+ segmentCubic(from, fromOut, toIn, to, 0.0f, 0.0f, 1.0f, m_CubicSegments);
m_Lengths.push_back(partLength);
length += partLength;
part.numSegments = m_CubicSegments.size() - index;
@@ -180,10 +171,7 @@
return length;
}
-void MetricsPath::trim(float startLength,
- float endLength,
- bool moveTo,
- RenderPath* result) {
+void MetricsPath::trim(float startLength, float endLength, bool moveTo, RenderPath* result) {
assert(endLength >= startLength);
if (!m_Paths.empty()) {
m_Paths.front()->trim(startLength, endLength, moveTo, result);
@@ -246,12 +234,8 @@
const Vec2D& point1 = m_TransformedPoints[part.offset];
const Vec2D& point2 = m_TransformedPoints[part.offset + 1];
const Vec2D& point3 = m_TransformedPoints[part.offset + 2];
- result->cubicTo(point1[0],
- point1[1],
- point2[0],
- point2[1],
- point3[0],
- point3[1]);
+ result->cubicTo(
+ point1[0], point1[1], point2[0], point2[1], point3[0], point3[1]);
break;
}
}
@@ -289,20 +273,17 @@
float length = m_Lengths[index];
if (startT != 0.0f) {
float startLength = startT * length;
- for (int si = startingSegmentIndex; si < endingSegmentIndex;
- si++) {
+ for (int si = startingSegmentIndex; si < endingSegmentIndex; si++) {
const CubicSegment& segment = m_CubicSegments[si];
if (segment.length >= startLength) {
if (si == startingSegmentIndex) {
startT = segment.t * (startLength / segment.length);
} else {
- float previousLength =
- m_CubicSegments[si - 1].length;
+ float previousLength = m_CubicSegments[si - 1].length;
- float t = (startLength - previousLength) /
- (segment.length - previousLength);
- startT =
- lerp(m_CubicSegments[si - 1].t, segment.t, t);
+ float t =
+ (startLength - previousLength) / (segment.length - previousLength);
+ startT = lerp(m_CubicSegments[si - 1].t, segment.t, t);
}
// Help out the ending segment finder by setting its
// start to where we landed while finding the first
@@ -315,20 +296,17 @@
if (endT != 1.0f) {
float endLength = endT * length;
- for (int si = startEndSegmentIndex; si < endingSegmentIndex;
- si++) {
+ for (int si = startEndSegmentIndex; si < endingSegmentIndex; si++) {
const CubicSegment& segment = m_CubicSegments[si];
if (segment.length >= endLength) {
if (si == startingSegmentIndex) {
endT = segment.t * (endLength / segment.length);
} else {
- float previousLength =
- m_CubicSegments[si - 1].length;
+ float previousLength = m_CubicSegments[si - 1].length;
- float t = (endLength - previousLength) /
- (segment.length - previousLength);
- endT =
- lerp(m_CubicSegments[si - 1].t, segment.t, t);
+ float t =
+ (endLength - previousLength) / (segment.length - previousLength);
+ endT = lerp(m_CubicSegments[si - 1].t, segment.t, t);
}
break;
}
@@ -348,12 +326,8 @@
if (moveTo) {
result->moveTo(from[0], from[1]);
}
- result->cubicTo(hull[0][0],
- hull[0][1],
- hull[3][0],
- hull[3][1],
- hull[5][0],
- hull[5][1]);
+ result->cubicTo(
+ hull[0][0], hull[0][1], hull[3][0], hull[3][1], hull[5][0], hull[5][1]);
} else {
// Split at start since it's non 0.
computeHull(from, fromOut, toIn, to, startT, hull);
@@ -364,28 +338,15 @@
if (endT == 1.0f) {
// End is 1, so no further split is necessary just cubicTo
// the remaining right side.
- result->cubicTo(hull[4][0],
- hull[4][1],
- hull[2][0],
- hull[2][1],
- to[0],
- to[1]);
+ result->cubicTo(hull[4][0], hull[4][1], hull[2][0], hull[2][1], to[0], to[1]);
} else {
// End is not 1, so split again and cubic to the left side
// of the split and remap endT to the new curve range
- computeHull(hull[5],
- hull[4],
- hull[2],
- to,
- (endT - startT) / (1.0f - startT),
- hull);
+ computeHull(
+ hull[5], hull[4], hull[2], to, (endT - startT) / (1.0f - startT), hull);
- result->cubicTo(hull[0][0],
- hull[0][1],
- hull[3][0],
- hull[3][1],
- hull[5][0],
- hull[5][1]);
+ result->cubicTo(
+ hull[0][0], hull[0][1], hull[3][0], hull[3][1], hull[5][0], hull[5][1]);
}
}
break;
@@ -416,8 +377,7 @@
m_RenderPath->lineTo(x, y);
}
-void RenderMetricsPath::cubicTo(
- float ox, float oy, float ix, float iy, float x, float y) {
+void RenderMetricsPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) {
MetricsPath::cubicTo(ox, oy, ix, iy, x, y);
m_RenderPath->cubicTo(ox, oy, ix, iy, x, y);
}
@@ -427,6 +387,4 @@
m_RenderPath->close();
}
-void RenderMetricsPath::fillRule(FillRule value) {
- m_RenderPath->fillRule(value);
-}
+void RenderMetricsPath::fillRule(FillRule value) { m_RenderPath->fillRule(value); }
diff --git a/src/shapes/paint/color.cpp b/src/shapes/paint/color.cpp
index 0112ed4..3820e4f 100644
--- a/src/shapes/paint/color.cpp
+++ b/src/shapes/paint/color.cpp
@@ -3,30 +3,22 @@
namespace rive {
unsigned int colorARGB(int a, int r, int g, int b) {
- return (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) |
- ((b & 0xff) << 0)) &
+ return (((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | ((b & 0xff) << 0)) &
0xFFFFFFFF;
}
unsigned int colorRed(ColorInt value) { return (0x00ff0000 & value) >> 16; }
- unsigned int colorGreen(ColorInt value) {
- return (0x0000ff00 & value) >> 8;
- }
+ unsigned int colorGreen(ColorInt value) { return (0x0000ff00 & value) >> 8; }
unsigned int colorBlue(ColorInt value) { return (0x000000ff & value) >> 0; }
- unsigned int colorAlpha(ColorInt value) {
- return (0xff000000 & value) >> 24;
- }
+ unsigned int colorAlpha(ColorInt value) { return (0xff000000 & value) >> 24; }
- float colorOpacity(ColorInt value) {
- return (float)colorAlpha(value) / 0xFF;
- }
+ float colorOpacity(ColorInt value) { return (float)colorAlpha(value) / 0xFF; }
ColorInt colorWithAlpha(ColorInt value, unsigned int a) {
- return colorARGB(
- a, colorRed(value), colorGreen(value), colorBlue(value));
+ return colorARGB(a, colorRed(value), colorGreen(value), colorBlue(value));
}
ColorInt colorWithOpacity(ColorInt value, float opacity) {
@@ -34,8 +26,7 @@
}
ColorInt colorModulateOpacity(ColorInt value, float opacity) {
- return colorWithAlpha(
- value, std::round(255.0f * colorOpacity(value) * opacity));
+ return colorWithAlpha(value, std::round(255.0f * colorOpacity(value) * opacity));
}
static unsigned int lerp(unsigned int a, unsigned int b, float mix) {
diff --git a/src/shapes/paint/gradient_stop.cpp b/src/shapes/paint/gradient_stop.cpp
index d8c1d8a..7a026e0 100644
--- a/src/shapes/paint/gradient_stop.cpp
+++ b/src/shapes/paint/gradient_stop.cpp
@@ -16,9 +16,5 @@
return StatusCode::Ok;
}
-void GradientStop::colorValueChanged() {
- parent()->as<LinearGradient>()->markGradientDirty();
-}
-void GradientStop::positionChanged() {
- parent()->as<LinearGradient>()->markStopsDirty();
-}
\ No newline at end of file
+void GradientStop::colorValueChanged() { parent()->as<LinearGradient>()->markGradientDirty(); }
+void GradientStop::positionChanged() { parent()->as<LinearGradient>()->markStopsDirty(); }
\ No newline at end of file
diff --git a/src/shapes/paint/linear_gradient.cpp b/src/shapes/paint/linear_gradient.cpp
index 4b0ef36..0e5b978 100644
--- a/src/shapes/paint/linear_gradient.cpp
+++ b/src/shapes/paint/linear_gradient.cpp
@@ -33,8 +33,7 @@
// that can return a world transform. We store the container just for
// doing the transform to world in update. If it's the artboard, then
// we're already in world so no need to transform.
- m_ShapePaintContainer =
- parentsParent->is<Node>() ? parentsParent->as<Node>() : nullptr;
+ m_ShapePaintContainer = parentsParent->is<Node>() ? parentsParent->as<Node>() : nullptr;
parentsParent->addDependent(this);
}
}
@@ -54,15 +53,13 @@
bool worldTransformed = hasDirt(value, ComponentDirt::WorldTransform);
- bool paintsInWorldSpace =
- parent()->as<ShapePaint>()->pathSpace() == PathSpace::World;
+ bool paintsInWorldSpace = parent()->as<ShapePaint>()->pathSpace() == PathSpace::World;
// We rebuild the gradient if the gradient is dirty or we paint in world
// space and the world space transform has changed, or the local transform
// has changed. Local transform changes when a stop moves in local space.
bool rebuildGradient =
hasDirt(value,
- ComponentDirt::Paint | ComponentDirt::RenderOpacity |
- ComponentDirt::Transform) ||
+ ComponentDirt::Paint | ComponentDirt::RenderOpacity | ComponentDirt::Transform) ||
(paintsInWorldSpace && worldTransformed);
if (rebuildGradient) {
Vec2D start(startX(), startY());
@@ -88,22 +85,20 @@
colors[i] = colorModulateOpacity(m_Stops[i]->colorValue(), ro);
stops[i] = m_Stops[i]->position();
}
-
+
makeGradient(start, end, colors, stops, count);
}
}
-void LinearGradient::makeGradient(Vec2D start, Vec2D end,
- const ColorInt colors[], const float stops[], size_t count) {
+void LinearGradient::makeGradient(
+ Vec2D start, Vec2D end, const ColorInt colors[], const float stops[], size_t count) {
auto paint = renderPaint();
- paint->shader(makeLinearGradient(start[0], start[1], end[0], end[1],
- colors, stops, count, RenderTileMode::clamp));
+ paint->shader(makeLinearGradient(
+ start[0], start[1], end[0], end[1], colors, stops, count, RenderTileMode::clamp));
}
void LinearGradient::markGradientDirty() { addDirt(ComponentDirt::Paint); }
-void LinearGradient::markStopsDirty() {
- addDirt(ComponentDirt::Paint | ComponentDirt::Stops);
-}
+void LinearGradient::markStopsDirty() { addDirt(ComponentDirt::Paint | ComponentDirt::Stops); }
void LinearGradient::renderOpacityChanged() { markGradientDirty(); }
diff --git a/src/shapes/paint/radial_gradient.cpp b/src/shapes/paint/radial_gradient.cpp
index e5e45c0..d327d4e 100644
--- a/src/shapes/paint/radial_gradient.cpp
+++ b/src/shapes/paint/radial_gradient.cpp
@@ -3,9 +3,14 @@
using namespace rive;
-void RadialGradient::makeGradient(Vec2D start, Vec2D end,
- const ColorInt colors[], const float stops[], size_t count) {
+void RadialGradient::makeGradient(
+ Vec2D start, Vec2D end, const ColorInt colors[], const float stops[], size_t count) {
auto paint = renderPaint();
- paint->shader(makeRadialGradient(start[0], start[1], Vec2D::distance(start, end),
- colors, stops, count, RenderTileMode::clamp));
+ paint->shader(makeRadialGradient(start[0],
+ start[1],
+ Vec2D::distance(start, end),
+ colors,
+ stops,
+ count,
+ RenderTileMode::clamp));
}
diff --git a/src/shapes/paint/solid_color.cpp b/src/shapes/paint/solid_color.cpp
index 8c5078a..b9fd08e 100644
--- a/src/shapes/paint/solid_color.cpp
+++ b/src/shapes/paint/solid_color.cpp
@@ -26,6 +26,4 @@
void SolidColor::colorValueChanged() { renderOpacityChanged(); }
-bool SolidColor::internalIsTranslucent() const {
- return colorAlpha(colorValue()) != 0xFF;
-}
+bool SolidColor::internalIsTranslucent() const { return colorAlpha(colorValue()) != 0xFF; }
diff --git a/src/shapes/paint/stroke.cpp b/src/shapes/paint/stroke.cpp
index 9891b28..ff48cf7 100644
--- a/src/shapes/paint/stroke.cpp
+++ b/src/shapes/paint/stroke.cpp
@@ -18,9 +18,7 @@
return renderPaint;
}
-bool Stroke::isVisible() const {
- return Super::isVisible() && thickness() > 0.0f;
-}
+bool Stroke::isVisible() const { return Super::isVisible() && thickness() > 0.0f; }
void Stroke::draw(Renderer* renderer, CommandPath* path) {
if (!isVisible()) {
diff --git a/src/shapes/path.cpp b/src/shapes/path.cpp
index e4227f9..243d758 100644
--- a/src/shapes/path.cpp
+++ b/src/shapes/path.cpp
@@ -44,7 +44,7 @@
void Path::buildPath(CommandPath& commandPath) const {
commandPath.reset();
-
+
const bool isClosed = isPathClosed();
const std::vector<PathVertex*>& vertices = m_Vertices;
@@ -82,10 +82,9 @@
Vec2D pos = point.renderTranslation();
- Vec2D toPrev =
- (prev->is<CubicVertex>() ? prev->as<CubicVertex>()->renderOut()
- : prev->renderTranslation()) -
- pos;
+ Vec2D toPrev = (prev->is<CubicVertex>() ? prev->as<CubicVertex>()->renderOut()
+ : prev->renderTranslation()) -
+ pos;
auto toPrevLength = toPrev.length();
toPrev[0] /= toPrevLength;
@@ -93,25 +92,21 @@
auto next = vertices[1];
- Vec2D toNext =
- (next->is<CubicVertex>() ? next->as<CubicVertex>()->renderIn()
- : next->renderTranslation()) -
- pos;
+ Vec2D toNext = (next->is<CubicVertex>() ? next->as<CubicVertex>()->renderIn()
+ : next->renderTranslation()) -
+ pos;
auto toNextLength = toNext.length();
toNext[0] /= toNextLength;
toNext[1] /= toNextLength;
- float renderRadius =
- std::min(toPrevLength, std::min(toNextLength, radius));
+ float renderRadius = std::min(toPrevLength, std::min(toNextLength, radius));
Vec2D translation = Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
commandPath.moveTo(startInX = startX = translation[0],
startInY = startY = translation[1]);
- Vec2D outPoint =
- Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
- Vec2D inPoint =
- Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
+ Vec2D outPoint = Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
+ Vec2D inPoint = Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
Vec2D posNext = Vec2D::scaleAndAdd(pos, toNext, renderRadius);
commandPath.cubicTo(outPoint[0],
outPoint[1],
@@ -135,12 +130,7 @@
auto inPoint = cubic->renderIn();
auto translation = cubic->renderTranslation();
- commandPath.cubicTo(outX,
- outY,
- inPoint[0],
- inPoint[1],
- translation[0],
- translation[1]);
+ commandPath.cubicTo(outX, outY, inPoint[0], inPoint[1], translation[0], translation[1]);
prevIsCubic = true;
auto outPoint = cubic->renderOut();
@@ -158,34 +148,25 @@
auto next = vertices[(i + 1) % length];
- Vec2D toNext = (next->is<CubicVertex>()
- ? next->as<CubicVertex>()->renderIn()
- : next->renderTranslation()) -
+ Vec2D toNext = (next->is<CubicVertex>() ? next->as<CubicVertex>()->renderIn()
+ : next->renderTranslation()) -
pos;
auto toNextLength = toNext.length();
toNext[0] /= toNextLength;
toNext[1] /= toNextLength;
- float renderRadius =
- std::min(toPrevLength, std::min(toNextLength, radius));
+ float renderRadius = std::min(toPrevLength, std::min(toNextLength, radius));
- Vec2D translation =
- Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
+ Vec2D translation = Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
if (prevIsCubic) {
- commandPath.cubicTo(outX,
- outY,
- translation[0],
- translation[1],
- translation[0],
- translation[1]);
+ commandPath.cubicTo(
+ outX, outY, translation[0], translation[1], translation[0], translation[1]);
} else {
commandPath.lineTo(translation[0], translation[1]);
}
- Vec2D outPoint = Vec2D::scaleAndAdd(
- pos, toPrev, icircleConstant * renderRadius);
- Vec2D inPoint = Vec2D::scaleAndAdd(
- pos, toNext, icircleConstant * renderRadius);
+ Vec2D outPoint = Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
+ Vec2D inPoint = Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
Vec2D posNext = Vec2D::scaleAndAdd(pos, toNext, renderRadius);
commandPath.cubicTo(outPoint[0],
outPoint[1],
@@ -250,9 +231,7 @@
class DisplayCubicVertex : public CubicVertex {
public:
- DisplayCubicVertex(const Vec2D& in,
- const Vec2D& out,
- const Vec2D& translation)
+ DisplayCubicVertex(const Vec2D& in, const Vec2D& out, const Vec2D& translation)
{
m_InPoint = in;
@@ -295,17 +274,14 @@
switch (vertex->coreType()) {
case StraightVertex::typeKey: {
auto point = *vertex->as<StraightVertex>();
- if (point.radius() > 0.0f &&
- (isPathClosed() || (i != 0 && i != length - 1))) {
+ if (point.radius() > 0.0f && (isPathClosed() || (i != 0 && i != length - 1))) {
auto next = m_Vertices[(i + 1) % length];
- Vec2D prevPoint =
- previous->is<CubicVertex>()
- ? previous->as<CubicVertex>()->renderOut()
- : previous->renderTranslation();
- Vec2D nextPoint = next->is<CubicVertex>()
- ? next->as<CubicVertex>()->renderIn()
- : next->renderTranslation();
+ Vec2D prevPoint = previous->is<CubicVertex>()
+ ? previous->as<CubicVertex>()->renderOut()
+ : previous->renderTranslation();
+ Vec2D nextPoint = next->is<CubicVertex>() ? next->as<CubicVertex>()->renderIn()
+ : next->renderTranslation();
Vec2D pos = point.renderTranslation();
@@ -319,26 +295,21 @@
toNext[0] /= toNextLength;
toNext[1] /= toNextLength;
- auto renderRadius = std::min(
- toPrevLength, std::min(toNextLength, point.radius()));
- Vec2D translation =
- Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
+ auto renderRadius =
+ std::min(toPrevLength, std::min(toNextLength, point.radius()));
+ Vec2D translation = Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
- Vec2D out = Vec2D::scaleAndAdd(
- pos, toPrev, icircleConstant * renderRadius);
+ Vec2D out = Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
{
- auto v1 = new DisplayCubicVertex(
- translation, out, translation);
+ auto v1 = new DisplayCubicVertex(translation, out, translation);
flat->addVertex(v1, transform);
delete v1;
}
translation = Vec2D::scaleAndAdd(pos, toNext, renderRadius);
- Vec2D in = Vec2D::scaleAndAdd(
- pos, toNext, icircleConstant * renderRadius);
- auto v2 =
- new DisplayCubicVertex(in, translation, translation);
+ Vec2D in = Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
+ auto v2 = new DisplayCubicVertex(in, translation, translation);
flat->addVertex(v2, transform);
if (deletePrevious) {
diff --git a/src/shapes/shape.cpp b/src/shapes/shape.cpp
index b7c4cdc..b620f93 100644
--- a/src/shapes/shape.cpp
+++ b/src/shapes/shape.cpp
@@ -43,14 +43,12 @@
continue;
}
renderer->save();
- bool paintsInLocal =
- (shapePaint->pathSpace() & PathSpace::Local) == PathSpace::Local;
+ bool paintsInLocal = (shapePaint->pathSpace() & PathSpace::Local) == PathSpace::Local;
if (paintsInLocal) {
renderer->transform(worldTransform());
}
shapePaint->draw(renderer,
- paintsInLocal ? m_PathComposer.localPath()
- : m_PathComposer.worldPath());
+ paintsInLocal ? m_PathComposer.localPath() : m_PathComposer.worldPath());
renderer->restore();
}
@@ -63,7 +61,7 @@
if (renderOpacity() == 0.0f) {
return nullptr;
}
-
+
// TODO: clip:
const bool shapeIsLocal = (pathSpace() & PathSpace::Local) == PathSpace::Local;
@@ -83,9 +81,9 @@
if (paintIsLocal) {
mx *= worldTransform();
}
-
+
HitTestCommandPath tester(hinfo->area);
-
+
for (auto path : m_Paths) {
if (shapeIsLocal) {
tester.setXform(xform * path->pathTransform());
@@ -116,9 +114,7 @@
}
}
-void Shape::addDefaultPathSpace(PathSpace space) {
- m_DefaultPathSpace |= space;
-}
+void Shape::addDefaultPathSpace(PathSpace space) { m_DefaultPathSpace |= space; }
StatusCode Shape::onAddedDirty(CoreContext* context) {
auto code = Super::onAddedDirty(context);
diff --git a/src/shapes/shape_paint_container.cpp b/src/shapes/shape_paint_container.cpp
index bdd5356..044b40d 100644
--- a/src/shapes/shape_paint_container.cpp
+++ b/src/shapes/shape_paint_container.cpp
@@ -20,9 +20,7 @@
return nullptr;
}
-void ShapePaintContainer::addPaint(ShapePaint* paint) {
- m_ShapePaints.push_back(paint);
-}
+void ShapePaintContainer::addPaint(ShapePaint* paint) { m_ShapePaints.push_back(paint); }
PathSpace ShapePaintContainer::pathSpace() const {
PathSpace space = m_DefaultPathSpace;
@@ -43,14 +41,13 @@
std::unique_ptr<CommandPath> ShapePaintContainer::makeCommandPath(PathSpace space) {
// Force a render path if we specifically request to use it for clipping or
// this shape is used for clipping.
- bool needForRender = ((space | m_DefaultPathSpace) & PathSpace::Clipping) ==
- PathSpace::Clipping;
+ bool needForRender =
+ ((space | m_DefaultPathSpace) & PathSpace::Clipping) == PathSpace::Clipping;
bool needForEffects = false;
for (auto paint : m_ShapePaints) {
- if (space != PathSpace::Neither &&
- (space & paint->pathSpace()) != space) {
+ if (space != PathSpace::Neither && (space & paint->pathSpace()) != space) {
continue;
}
diff --git a/src/transform_component.cpp b/src/transform_component.cpp
index 7f58894..4c62c54 100644
--- a/src/transform_component.cpp
+++ b/src/transform_component.cpp
@@ -7,10 +7,9 @@
using namespace rive;
StatusCode TransformComponent::onAddedClean(CoreContext* context) {
- m_ParentTransformComponent =
- parent() != nullptr && parent()->is<WorldTransformComponent>()
- ? parent()->as<WorldTransformComponent>()
- : nullptr;
+ m_ParentTransformComponent = parent() != nullptr && parent()->is<WorldTransformComponent>()
+ ? parent()->as<WorldTransformComponent>()
+ : nullptr;
return StatusCode::Ok;
}
@@ -36,8 +35,7 @@
void TransformComponent::updateWorldTransform() {
if (m_ParentTransformComponent != nullptr) {
- m_WorldTransform = m_ParentTransformComponent->m_WorldTransform
- * m_Transform;
+ m_WorldTransform = m_ParentTransformComponent->m_WorldTransform * m_Transform;
} else {
m_WorldTransform = m_Transform;
}
diff --git a/src/world_transform_component.cpp b/src/world_transform_component.cpp
index ea3d931..d4e19dc 100644
--- a/src/world_transform_component.cpp
+++ b/src/world_transform_component.cpp
@@ -11,17 +11,11 @@
addDirt(ComponentDirt::WorldTransform, true);
}
-const Mat2D& WorldTransformComponent::worldTransform() const {
- return m_WorldTransform;
-}
+const Mat2D& WorldTransformComponent::worldTransform() const { return m_WorldTransform; }
-Mat2D& WorldTransformComponent::mutableWorldTransform() {
- return m_WorldTransform;
-}
+Mat2D& WorldTransformComponent::mutableWorldTransform() { return m_WorldTransform; }
-void WorldTransformComponent::opacityChanged() {
- addDirt(ComponentDirt::RenderOpacity, true);
-}
+void WorldTransformComponent::opacityChanged() { addDirt(ComponentDirt::RenderOpacity, true); }
void WorldTransformComponent::worldTranslation(Vec2D& result) const {
result[0] = m_WorldTransform[4];