clang-format updates - Put braces on their own line - Turn off single-line case labels Diffs= 32e79999a clang-format updates
diff --git a/.rive_head b/.rive_head index b77e8cb..01bc573 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -4342233383156cba2154ad05b74157b139dc8bfc +32e79999a88138e308ba4aef905c411361fa410b
diff --git a/include/rive/animation/animation.hpp b/include/rive/animation/animation.hpp index f61e44d..757bca8 100644 --- a/include/rive/animation/animation.hpp +++ b/include/rive/animation/animation.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_ANIMATION_HPP_ #define _RIVE_ANIMATION_HPP_ #include "rive/generated/animation/animation_base.hpp" -namespace rive { -class Animation : public AnimationBase {}; +namespace rive +{ +class Animation : public AnimationBase +{}; } // namespace rive #endif \ No newline at end of file
diff --git a/include/rive/animation/animation_state.hpp b/include/rive/animation/animation_state.hpp index d9fc715..9a2a062 100644 --- a/include/rive/animation/animation_state.hpp +++ b/include/rive/animation/animation_state.hpp
@@ -2,12 +2,14 @@ #define _RIVE_ANIMATION_STATE_HPP_ #include "rive/generated/animation/animation_state_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class LinearAnimation; class ArtboardInstance; class StateMachineLayerImporter; -class AnimationState : public AnimationStateBase { +class AnimationState : public AnimationStateBase +{ friend class StateMachineLayerImporter; private:
diff --git a/include/rive/animation/animation_state_instance.hpp b/include/rive/animation/animation_state_instance.hpp index fa3efd8..379f5d3 100644 --- a/include/rive/animation/animation_state_instance.hpp +++ b/include/rive/animation/animation_state_instance.hpp
@@ -5,11 +5,13 @@ #include "rive/animation/state_instance.hpp" #include "rive/animation/linear_animation_instance.hpp" -namespace rive { +namespace rive +{ class AnimationState; /// Represents an instance of an animation state. -class AnimationStateInstance : public StateInstance { +class AnimationStateInstance : public StateInstance +{ private: LinearAnimationInstance m_AnimationInstance; bool m_KeepGoing;
diff --git a/include/rive/animation/any_state.hpp b/include/rive/animation/any_state.hpp index f6f8b5a..bd07c14 100644 --- a/include/rive/animation/any_state.hpp +++ b/include/rive/animation/any_state.hpp
@@ -2,8 +2,10 @@ #define _RIVE_ANY_STATE_HPP_ #include "rive/generated/animation/any_state_base.hpp" #include <stdio.h> -namespace rive { -class AnyState : public AnyStateBase { +namespace rive +{ +class AnyState : public AnyStateBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/blend_animation.hpp b/include/rive/animation/blend_animation.hpp index 7e8dde7..32e575e 100644 --- a/include/rive/animation/blend_animation.hpp +++ b/include/rive/animation/blend_animation.hpp
@@ -1,9 +1,11 @@ #ifndef _RIVE_BLEND_ANIMATION_HPP_ #define _RIVE_BLEND_ANIMATION_HPP_ #include "rive/generated/animation/blend_animation_base.hpp" -namespace rive { +namespace rive +{ class LinearAnimation; -class BlendAnimation : public BlendAnimationBase { +class BlendAnimation : public BlendAnimationBase +{ private: LinearAnimation* m_Animation = nullptr;
diff --git a/include/rive/animation/blend_animation_1d.hpp b/include/rive/animation/blend_animation_1d.hpp index 4fb15f2..42b77e1 100644 --- a/include/rive/animation/blend_animation_1d.hpp +++ b/include/rive/animation/blend_animation_1d.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_ANIMATION1_D_HPP_ #include "rive/generated/animation/blend_animation_1d_base.hpp" #include <stdio.h> -namespace rive { -class BlendAnimation1D : public BlendAnimation1DBase { +namespace rive +{ +class BlendAnimation1D : public BlendAnimation1DBase +{ public: StatusCode onAddedDirty(CoreContext* context) override; StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/animation/blend_animation_direct.hpp b/include/rive/animation/blend_animation_direct.hpp index 6c098f4..97355cd 100644 --- a/include/rive/animation/blend_animation_direct.hpp +++ b/include/rive/animation/blend_animation_direct.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_ANIMATION_DIRECT_HPP_ #include "rive/generated/animation/blend_animation_direct_base.hpp" #include <stdio.h> -namespace rive { -class BlendAnimationDirect : public BlendAnimationDirectBase { +namespace rive +{ +class BlendAnimationDirect : public BlendAnimationDirectBase +{ public: StatusCode onAddedDirty(CoreContext* context) override; StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/animation/blend_state.hpp b/include/rive/animation/blend_state.hpp index 7ab97a1..6dded33 100644 --- a/include/rive/animation/blend_state.hpp +++ b/include/rive/animation/blend_state.hpp
@@ -5,11 +5,13 @@ #include <vector> #include <algorithm> -namespace rive { +namespace rive +{ class BlendAnimation; class LayerStateImporter; -class BlendState : public BlendStateBase { +class BlendState : public BlendStateBase +{ friend class LayerStateImporter; private:
diff --git a/include/rive/animation/blend_state_1d.hpp b/include/rive/animation/blend_state_1d.hpp index 7cdc8dd..ebe394a 100644 --- a/include/rive/animation/blend_state_1d.hpp +++ b/include/rive/animation/blend_state_1d.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_STATE1_D_HPP_ #include "rive/generated/animation/blend_state_1d_base.hpp" -namespace rive { -class BlendState1D : public BlendState1DBase { +namespace rive +{ +class BlendState1D : public BlendState1DBase +{ public: // -1 (4294967295) is our flag value for input not set. It means it wasn't set at edit // time.
diff --git a/include/rive/animation/blend_state_1d_instance.hpp b/include/rive/animation/blend_state_1d_instance.hpp index aa9760f..5f97cde 100644 --- a/include/rive/animation/blend_state_1d_instance.hpp +++ b/include/rive/animation/blend_state_1d_instance.hpp
@@ -5,8 +5,10 @@ #include "rive/animation/blend_state_1d.hpp" #include "rive/animation/blend_animation_1d.hpp" -namespace rive { -class BlendState1DInstance : public BlendStateInstance<BlendState1D, BlendAnimation1D> { +namespace rive +{ +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_direct.hpp b/include/rive/animation/blend_state_direct.hpp index b0d46e3..1d8707e 100644 --- a/include/rive/animation/blend_state_direct.hpp +++ b/include/rive/animation/blend_state_direct.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_STATE_DIRECT_HPP_ #include "rive/generated/animation/blend_state_direct_base.hpp" #include <stdio.h> -namespace rive { -class BlendStateDirect : public BlendStateDirectBase { +namespace rive +{ +class BlendStateDirect : public BlendStateDirectBase +{ public: std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override; };
diff --git a/include/rive/animation/blend_state_direct_instance.hpp b/include/rive/animation/blend_state_direct_instance.hpp index efb2c30..8fd8cf8 100644 --- a/include/rive/animation/blend_state_direct_instance.hpp +++ b/include/rive/animation/blend_state_direct_instance.hpp
@@ -5,8 +5,10 @@ #include "rive/animation/blend_state_direct.hpp" #include "rive/animation/blend_animation_direct.hpp" -namespace rive { -class BlendStateDirectInstance : public BlendStateInstance<BlendStateDirect, BlendAnimationDirect> { +namespace rive +{ +class BlendStateDirectInstance : public BlendStateInstance<BlendStateDirect, BlendAnimationDirect> +{ public: BlendStateDirectInstance(const BlendStateDirect* blendState, ArtboardInstance* instance); void advance(float seconds, Span<SMIInput*> inputs) override;
diff --git a/include/rive/animation/blend_state_instance.hpp b/include/rive/animation/blend_state_instance.hpp index ecd6e79..0311f01 100644 --- a/include/rive/animation/blend_state_instance.hpp +++ b/include/rive/animation/blend_state_instance.hpp
@@ -7,11 +7,13 @@ #include "rive/animation/blend_state.hpp" #include "rive/animation/linear_animation_instance.hpp" -namespace rive { +namespace rive +{ class AnimationState; template <class K, class T> class BlendStateInstance; -template <class T> class BlendStateAnimationInstance { +template <class T> class BlendStateAnimationInstance +{ template <class A, class B> friend class BlendStateInstance; private: @@ -24,23 +26,25 @@ const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; } BlendStateAnimationInstance(const T* blendAnimation, ArtboardInstance* instance) : - m_BlendAnimation(blendAnimation), - m_AnimationInstance(blendAnimation->animation(), instance) {} + m_BlendAnimation(blendAnimation), m_AnimationInstance(blendAnimation->animation(), instance) + {} 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; public: - BlendStateInstance(const K* blendState, ArtboardInstance* instance) : - StateInstance(blendState) { + BlendStateInstance(const K* blendState, ArtboardInstance* instance) : StateInstance(blendState) + { m_AnimationInstances.reserve(blendState->animations().size()); - for (auto blendAnimation : blendState->animations()) { + for (auto blendAnimation : blendState->animations()) + { m_AnimationInstances.emplace_back( BlendStateAnimationInstance<T>(static_cast<T*>(blendAnimation), instance)); } @@ -48,26 +52,34 @@ bool keepGoing() const override { return m_KeepGoing; } - void advance(float seconds, Span<SMIInput*>) override { + void advance(float seconds, Span<SMIInput*>) override + { m_KeepGoing = false; - for (auto& animation : m_AnimationInstances) { - if (animation.m_AnimationInstance.advance(seconds)) { + for (auto& animation : m_AnimationInstances) + { + if (animation.m_AnimationInstance.advance(seconds)) + { m_KeepGoing = true; } } } - void apply(float mix) override { - for (auto& animation : m_AnimationInstances) { + void apply(float mix) override + { + for (auto& animation : m_AnimationInstances) + { float m = mix * animation.m_Mix; animation.m_AnimationInstance.apply(m); } } // Find the animationInstance that corresponds to the blendAnimation. - const LinearAnimationInstance* animationInstance(const BlendAnimation* blendAnimation) const { - for (auto& animation : m_AnimationInstances) { - if (animation.m_BlendAnimation == blendAnimation) { + const LinearAnimationInstance* animationInstance(const BlendAnimation* blendAnimation) const + { + for (auto& animation : m_AnimationInstances) + { + if (animation.m_BlendAnimation == blendAnimation) + { return animation.animationInstance(); } }
diff --git a/include/rive/animation/blend_state_transition.hpp b/include/rive/animation/blend_state_transition.hpp index 3c83d8d..a406ba9 100644 --- a/include/rive/animation/blend_state_transition.hpp +++ b/include/rive/animation/blend_state_transition.hpp
@@ -2,10 +2,12 @@ #define _RIVE_BLEND_STATE_TRANSITION_HPP_ #include "rive/generated/animation/blend_state_transition_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class BlendAnimation; class LayerStateImporter; -class BlendStateTransition : public BlendStateTransitionBase { +class BlendStateTransition : public BlendStateTransitionBase +{ friend class LayerStateImporter; private:
diff --git a/include/rive/animation/cubic_interpolator.hpp b/include/rive/animation/cubic_interpolator.hpp index 6da4387..95cb660 100644 --- a/include/rive/animation/cubic_interpolator.hpp +++ b/include/rive/animation/cubic_interpolator.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CUBIC_INTERPOLATOR_HPP_ #define _RIVE_CUBIC_INTERPOLATOR_HPP_ #include "rive/generated/animation/cubic_interpolator_base.hpp" -namespace rive { -class CubicInterpolator : public CubicInterpolatorBase { +namespace rive +{ +class CubicInterpolator : public CubicInterpolatorBase +{ private: static constexpr int SplineTableSize = 11; static constexpr float SampleStepSize = 1.0f / (SplineTableSize - 1.0f);
diff --git a/include/rive/animation/entry_state.hpp b/include/rive/animation/entry_state.hpp index 000f96b..e9bbfa2 100644 --- a/include/rive/animation/entry_state.hpp +++ b/include/rive/animation/entry_state.hpp
@@ -2,8 +2,10 @@ #define _RIVE_ENTRY_STATE_HPP_ #include "rive/generated/animation/entry_state_base.hpp" #include <stdio.h> -namespace rive { -class EntryState : public EntryStateBase { +namespace rive +{ +class EntryState : public EntryStateBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/exit_state.hpp b/include/rive/animation/exit_state.hpp index b3d79d2..607526d 100644 --- a/include/rive/animation/exit_state.hpp +++ b/include/rive/animation/exit_state.hpp
@@ -2,8 +2,10 @@ #define _RIVE_EXIT_STATE_HPP_ #include "rive/generated/animation/exit_state_base.hpp" #include <stdio.h> -namespace rive { -class ExitState : public ExitStateBase { +namespace rive +{ +class ExitState : public ExitStateBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/keyed_object.hpp b/include/rive/animation/keyed_object.hpp index 24eb2ac..70c97ab 100644 --- a/include/rive/animation/keyed_object.hpp +++ b/include/rive/animation/keyed_object.hpp
@@ -2,10 +2,12 @@ #define _RIVE_KEYED_OBJECT_HPP_ #include "rive/generated/animation/keyed_object_base.hpp" #include <vector> -namespace rive { +namespace rive +{ class Artboard; class KeyedProperty; -class KeyedObject : public KeyedObjectBase { +class KeyedObject : public KeyedObjectBase +{ private: std::vector<std::unique_ptr<KeyedProperty>> m_KeyedProperties;
diff --git a/include/rive/animation/keyed_property.hpp b/include/rive/animation/keyed_property.hpp index 69baa9e..29b8ffe 100644 --- a/include/rive/animation/keyed_property.hpp +++ b/include/rive/animation/keyed_property.hpp
@@ -2,9 +2,11 @@ #define _RIVE_KEYED_PROPERTY_HPP_ #include "rive/generated/animation/keyed_property_base.hpp" #include <vector> -namespace rive { +namespace rive +{ class KeyFrame; -class KeyedProperty : public KeyedPropertyBase { +class KeyedProperty : public KeyedPropertyBase +{ private: std::vector<std::unique_ptr<KeyFrame>> m_KeyFrames;
diff --git a/include/rive/animation/keyframe.hpp b/include/rive/animation/keyframe.hpp index 7d1a0c7..961f2aa 100644 --- a/include/rive/animation/keyframe.hpp +++ b/include/rive/animation/keyframe.hpp
@@ -1,10 +1,12 @@ #ifndef _RIVE_KEY_FRAME_HPP_ #define _RIVE_KEY_FRAME_HPP_ #include "rive/generated/animation/keyframe_base.hpp" -namespace rive { +namespace rive +{ class CubicInterpolator; -class KeyFrame : public KeyFrameBase { +class KeyFrame : public KeyFrameBase +{ private: CubicInterpolator* m_Interpolator = nullptr; float m_Seconds;
diff --git a/include/rive/animation/keyframe_bool.hpp b/include/rive/animation/keyframe_bool.hpp index eff1d5a..88a234f 100644 --- a/include/rive/animation/keyframe_bool.hpp +++ b/include/rive/animation/keyframe_bool.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_BOOL_HPP_ #include "rive/generated/animation/keyframe_bool_base.hpp" #include <stdio.h> -namespace rive { -class KeyFrameBool : public KeyFrameBoolBase { +namespace rive +{ +class KeyFrameBool : public KeyFrameBoolBase +{ public: void apply(Core* object, int propertyKey, float mix) override; void applyInterpolation(Core* object,
diff --git a/include/rive/animation/keyframe_color.hpp b/include/rive/animation/keyframe_color.hpp index ba0061d..82c8bd9 100644 --- a/include/rive/animation/keyframe_color.hpp +++ b/include/rive/animation/keyframe_color.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_KEY_FRAME_COLOR_HPP_ #define _RIVE_KEY_FRAME_COLOR_HPP_ #include "rive/generated/animation/keyframe_color_base.hpp" -namespace rive { -class KeyFrameColor : public KeyFrameColorBase { +namespace rive +{ +class KeyFrameColor : public KeyFrameColorBase +{ public: void apply(Core* object, int propertyKey, float mix) override; void applyInterpolation(Core* object,
diff --git a/include/rive/animation/keyframe_double.hpp b/include/rive/animation/keyframe_double.hpp index e94cfbc..2bdff78 100644 --- a/include/rive/animation/keyframe_double.hpp +++ b/include/rive/animation/keyframe_double.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_KEY_FRAME_DOUBLE_HPP_ #define _RIVE_KEY_FRAME_DOUBLE_HPP_ #include "rive/generated/animation/keyframe_double_base.hpp" -namespace rive { -class KeyFrameDouble : public KeyFrameDoubleBase { +namespace rive +{ +class KeyFrameDouble : public KeyFrameDoubleBase +{ public: void apply(Core* object, int propertyKey, float mix) override; void applyInterpolation(Core* object,
diff --git a/include/rive/animation/keyframe_id.hpp b/include/rive/animation/keyframe_id.hpp index 5ef658c..cf706a1 100644 --- a/include/rive/animation/keyframe_id.hpp +++ b/include/rive/animation/keyframe_id.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_ID_HPP_ #include "rive/generated/animation/keyframe_id_base.hpp" #include <stdio.h> -namespace rive { -class KeyFrameId : public KeyFrameIdBase { +namespace rive +{ +class KeyFrameId : public KeyFrameIdBase +{ public: void apply(Core* object, int propertyKey, float mix) override; void applyInterpolation(Core* object,
diff --git a/include/rive/animation/layer_state.hpp b/include/rive/animation/layer_state.hpp index 778632c..7229640 100644 --- a/include/rive/animation/layer_state.hpp +++ b/include/rive/animation/layer_state.hpp
@@ -4,14 +4,16 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class ArtboardInstance; class StateTransition; class LayerStateImporter; class StateMachineLayerImporter; class StateInstance; -class LayerState : public LayerStateBase { +class LayerState : public LayerStateBase +{ friend class LayerStateImporter; friend class StateMachineLayerImporter; @@ -27,8 +29,10 @@ StatusCode import(ImportStack& importStack) override; size_t transitionCount() const { return m_Transitions.size(); } - StateTransition* transition(size_t index) const { - if (index < m_Transitions.size()) { + StateTransition* transition(size_t index) const + { + if (index < m_Transitions.size()) + { return m_Transitions[index]; } return nullptr;
diff --git a/include/rive/animation/linear_animation.hpp b/include/rive/animation/linear_animation.hpp index b205443..309c6d7 100644 --- a/include/rive/animation/linear_animation.hpp +++ b/include/rive/animation/linear_animation.hpp
@@ -3,11 +3,13 @@ #include "rive/animation/loop.hpp" #include "rive/generated/animation/linear_animation_base.hpp" #include <vector> -namespace rive { +namespace rive +{ class Artboard; class KeyedObject; -class LinearAnimation : public LinearAnimationBase { +class LinearAnimation : public LinearAnimationBase +{ private: std::vector<std::unique_ptr<KeyedObject>> m_KeyedObjects;
diff --git a/include/rive/animation/linear_animation_instance.hpp b/include/rive/animation/linear_animation_instance.hpp index d834441..a88122b 100644 --- a/include/rive/animation/linear_animation_instance.hpp +++ b/include/rive/animation/linear_animation_instance.hpp
@@ -4,10 +4,12 @@ #include "rive/artboard.hpp" #include "rive/scene.hpp" -namespace rive { +namespace rive +{ class LinearAnimation; -class LinearAnimationInstance : public Scene { +class LinearAnimationInstance : public Scene +{ private: const LinearAnimation* m_Animation = nullptr; float m_Time; @@ -39,10 +41,14 @@ // Update the direction of the animation instance, positive value for // forwards Negative for backwards - void direction(int direction) { - if (direction > 0) { + void direction(int direction) + { + if (direction > 0) + { m_Direction = 1; - } else { + } + else + { m_Direction = -1; } }
diff --git a/include/rive/animation/listener_action.hpp b/include/rive/animation/listener_action.hpp index 46d3dc0..370a5cc 100644 --- a/include/rive/animation/listener_action.hpp +++ b/include/rive/animation/listener_action.hpp
@@ -3,9 +3,11 @@ #include "rive/generated/animation/listener_action_base.hpp" #include "rive/math/vec2d.hpp" -namespace rive { +namespace rive +{ class StateMachineInstance; -class ListenerAction : public ListenerActionBase { +class ListenerAction : public ListenerActionBase +{ public: StatusCode import(ImportStack& importStack) override; virtual void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const = 0;
diff --git a/include/rive/animation/listener_align_target.hpp b/include/rive/animation/listener_align_target.hpp index a3221e2..dd71108 100644 --- a/include/rive/animation/listener_align_target.hpp +++ b/include/rive/animation/listener_align_target.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_ALIGN_TARGET_HPP_ #include "rive/generated/animation/listener_align_target_base.hpp" #include <stdio.h> -namespace rive { -class ListenerAlignTarget : public ListenerAlignTargetBase { +namespace rive +{ +class ListenerAlignTarget : public ListenerAlignTargetBase +{ public: void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override; };
diff --git a/include/rive/animation/listener_bool_change.hpp b/include/rive/animation/listener_bool_change.hpp index 53a7bf8..060a886 100644 --- a/include/rive/animation/listener_bool_change.hpp +++ b/include/rive/animation/listener_bool_change.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_BOOL_CHANGE_HPP_ #include "rive/generated/animation/listener_bool_change_base.hpp" -namespace rive { -class ListenerBoolChange : public ListenerBoolChangeBase { +namespace rive +{ +class ListenerBoolChange : public ListenerBoolChangeBase +{ public: bool validateInputType(const StateMachineInput* input) const override; void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
diff --git a/include/rive/animation/listener_input_change.hpp b/include/rive/animation/listener_input_change.hpp index 7946acb..713fa99 100644 --- a/include/rive/animation/listener_input_change.hpp +++ b/include/rive/animation/listener_input_change.hpp
@@ -2,9 +2,11 @@ #define _RIVE_LISTENER_INPUT_CHANGE_HPP_ #include "rive/generated/animation/listener_input_change_base.hpp" -namespace rive { +namespace rive +{ class StateMachineInput; -class ListenerInputChange : public ListenerInputChangeBase { +class ListenerInputChange : public ListenerInputChangeBase +{ public: StatusCode import(ImportStack& importStack) override; virtual bool validateInputType(const StateMachineInput* input) const { return true; }
diff --git a/include/rive/animation/listener_number_change.hpp b/include/rive/animation/listener_number_change.hpp index ac8a658..75cf223 100644 --- a/include/rive/animation/listener_number_change.hpp +++ b/include/rive/animation/listener_number_change.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_NUMBER_CHANGE_HPP_ #include "rive/generated/animation/listener_number_change_base.hpp" -namespace rive { -class ListenerNumberChange : public ListenerNumberChangeBase { +namespace rive +{ +class ListenerNumberChange : public ListenerNumberChangeBase +{ public: bool validateInputType(const StateMachineInput* input) const override; void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
diff --git a/include/rive/animation/listener_trigger_change.hpp b/include/rive/animation/listener_trigger_change.hpp index fe8bab5..ecd4261 100644 --- a/include/rive/animation/listener_trigger_change.hpp +++ b/include/rive/animation/listener_trigger_change.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_TRIGGER_CHANGE_HPP_ #include "rive/generated/animation/listener_trigger_change_base.hpp" -namespace rive { -class ListenerTriggerChange : public ListenerTriggerChangeBase { +namespace rive +{ +class ListenerTriggerChange : public ListenerTriggerChangeBase +{ public: bool validateInputType(const StateMachineInput* input) const override; void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
diff --git a/include/rive/animation/loop.hpp b/include/rive/animation/loop.hpp index 9b7bc1f..d4f0d53 100644 --- a/include/rive/animation/loop.hpp +++ b/include/rive/animation/loop.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_LOOP_HPP_ #define _RIVE_LOOP_HPP_ -namespace rive { +namespace rive +{ /// Loop options for linear animations. -enum class Loop : unsigned int { +enum class Loop : unsigned int +{ /// Play until the duration or end of work area of the animation. oneShot = 0,
diff --git a/include/rive/animation/nested_bool.hpp b/include/rive/animation/nested_bool.hpp index 9684564..99f0dab 100644 --- a/include/rive/animation/nested_bool.hpp +++ b/include/rive/animation/nested_bool.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_BOOL_HPP_ #include "rive/generated/animation/nested_bool_base.hpp" #include <stdio.h> -namespace rive { -class NestedBool : public NestedBoolBase { +namespace rive +{ +class NestedBool : public NestedBoolBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/nested_input.hpp b/include/rive/animation/nested_input.hpp index d6bf34f..158cf05 100644 --- a/include/rive/animation/nested_input.hpp +++ b/include/rive/animation/nested_input.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_INPUT_HPP_ #include "rive/generated/animation/nested_input_base.hpp" #include <stdio.h> -namespace rive { -class NestedInput : public NestedInputBase { +namespace rive +{ +class NestedInput : public NestedInputBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/nested_linear_animation.hpp b/include/rive/animation/nested_linear_animation.hpp index 88c65c5..7de512c 100644 --- a/include/rive/animation/nested_linear_animation.hpp +++ b/include/rive/animation/nested_linear_animation.hpp
@@ -2,9 +2,11 @@ #define _RIVE_NESTED_LINEAR_ANIMATION_HPP_ #include "rive/generated/animation/nested_linear_animation_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class LinearAnimationInstance; -class NestedLinearAnimation : public NestedLinearAnimationBase { +class NestedLinearAnimation : public NestedLinearAnimationBase +{ protected: std::unique_ptr<LinearAnimationInstance> m_AnimationInstance;
diff --git a/include/rive/animation/nested_number.hpp b/include/rive/animation/nested_number.hpp index 83e3568..5ae1053 100644 --- a/include/rive/animation/nested_number.hpp +++ b/include/rive/animation/nested_number.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_NUMBER_HPP_ #include "rive/generated/animation/nested_number_base.hpp" #include <stdio.h> -namespace rive { -class NestedNumber : public NestedNumberBase { +namespace rive +{ +class NestedNumber : public NestedNumberBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/nested_remap_animation.hpp b/include/rive/animation/nested_remap_animation.hpp index 410aa6a..c83002c 100644 --- a/include/rive/animation/nested_remap_animation.hpp +++ b/include/rive/animation/nested_remap_animation.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_REMAP_ANIMATION_HPP_ #include "rive/generated/animation/nested_remap_animation_base.hpp" #include <stdio.h> -namespace rive { -class NestedRemapAnimation : public NestedRemapAnimationBase { +namespace rive +{ +class NestedRemapAnimation : public NestedRemapAnimationBase +{ public: void timeChanged() override; void advance(float elapsedSeconds) override;
diff --git a/include/rive/animation/nested_simple_animation.hpp b/include/rive/animation/nested_simple_animation.hpp index 628e243..41bc958 100644 --- a/include/rive/animation/nested_simple_animation.hpp +++ b/include/rive/animation/nested_simple_animation.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_SIMPLE_ANIMATION_HPP_ #include "rive/generated/animation/nested_simple_animation_base.hpp" #include <stdio.h> -namespace rive { -class NestedSimpleAnimation : public NestedSimpleAnimationBase { +namespace rive +{ +class NestedSimpleAnimation : public NestedSimpleAnimationBase +{ public: void advance(float elapsedSeconds) override; };
diff --git a/include/rive/animation/nested_state_machine.hpp b/include/rive/animation/nested_state_machine.hpp index da2e7a9..46790e7 100644 --- a/include/rive/animation/nested_state_machine.hpp +++ b/include/rive/animation/nested_state_machine.hpp
@@ -4,10 +4,12 @@ #include "rive/math/vec2d.hpp" #include <memory> -namespace rive { +namespace rive +{ class ArtboardInstance; class StateMachineInstance; -class NestedStateMachine : public NestedStateMachineBase { +class NestedStateMachine : public NestedStateMachineBase +{ private: std::unique_ptr<StateMachineInstance> m_StateMachineInstance;
diff --git a/include/rive/animation/nested_trigger.hpp b/include/rive/animation/nested_trigger.hpp index 57d3a9e..7861dbd 100644 --- a/include/rive/animation/nested_trigger.hpp +++ b/include/rive/animation/nested_trigger.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_TRIGGER_HPP_ #include "rive/generated/animation/nested_trigger_base.hpp" #include <stdio.h> -namespace rive { -class NestedTrigger : public NestedTriggerBase { +namespace rive +{ +class NestedTrigger : public NestedTriggerBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/state_instance.hpp b/include/rive/animation/state_instance.hpp index d5fa0d5..3465a43 100644 --- a/include/rive/animation/state_instance.hpp +++ b/include/rive/animation/state_instance.hpp
@@ -6,13 +6,15 @@ #include "rive/rive_types.hpp" #include "rive/span.hpp" -namespace rive { +namespace rive +{ class LayerState; class SMIInput; class ArtboardInstance; /// Represents an instance of a state tracked by the State Machine. -class StateInstance { +class StateInstance +{ private: const LayerState* m_LayerState;
diff --git a/include/rive/animation/state_machine.hpp b/include/rive/animation/state_machine.hpp index 329a6ea..9899893 100644 --- a/include/rive/animation/state_machine.hpp +++ b/include/rive/animation/state_machine.hpp
@@ -4,12 +4,14 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class StateMachineLayer; class StateMachineInput; class StateMachineListener; class StateMachineImporter; -class StateMachine : public StateMachineBase { +class StateMachine : public StateMachineBase +{ friend class StateMachineImporter; private:
diff --git a/include/rive/animation/state_machine_bool.hpp b/include/rive/animation/state_machine_bool.hpp index f06e94f..a441e55 100644 --- a/include/rive/animation/state_machine_bool.hpp +++ b/include/rive/animation/state_machine_bool.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_BOOL_HPP_ #include "rive/generated/animation/state_machine_bool_base.hpp" #include <stdio.h> -namespace rive { -class StateMachineBool : public StateMachineBoolBase { +namespace rive +{ +class StateMachineBool : public StateMachineBoolBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/state_machine_component.hpp b/include/rive/animation/state_machine_component.hpp index d4118fb..8f6e340 100644 --- a/include/rive/animation/state_machine_component.hpp +++ b/include/rive/animation/state_machine_component.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_COMPONENT_HPP_ #include "rive/generated/animation/state_machine_component_base.hpp" #include <stdio.h> -namespace rive { -class StateMachineComponent : public StateMachineComponentBase { +namespace rive +{ +class StateMachineComponent : public StateMachineComponentBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/state_machine_input.hpp b/include/rive/animation/state_machine_input.hpp index 096ff94..d7d29ae 100644 --- a/include/rive/animation/state_machine_input.hpp +++ b/include/rive/animation/state_machine_input.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_INPUT_HPP_ #include "rive/generated/animation/state_machine_input_base.hpp" #include <stdio.h> -namespace rive { -class StateMachineInput : public StateMachineInputBase { +namespace rive +{ +class StateMachineInput : public StateMachineInputBase +{ public: StatusCode onAddedDirty(CoreContext* context) override; StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/animation/state_machine_input_instance.hpp b/include/rive/animation/state_machine_input_instance.hpp index 1b014a4..e5f732c 100644 --- a/include/rive/animation/state_machine_input_instance.hpp +++ b/include/rive/animation/state_machine_input_instance.hpp
@@ -4,7 +4,8 @@ #include <string> #include <stdint.h> -namespace rive { +namespace rive +{ class StateMachineInstance; class StateMachineInput; class StateMachineBool; @@ -13,7 +14,8 @@ class TransitionTriggerCondition; class StateMachineLayerInstance; -class SMIInput { +class SMIInput +{ friend class StateMachineInstance; friend class StateMachineLayerInstance; @@ -36,7 +38,8 @@ uint16_t inputCoreType() const; }; -class SMIBool : public SMIInput { +class SMIBool : public SMIInput +{ friend class StateMachineInstance; private: @@ -49,7 +52,8 @@ void value(bool newValue); }; -class SMINumber : public SMIInput { +class SMINumber : public SMIInput +{ friend class StateMachineInstance; private: @@ -62,7 +66,8 @@ void value(float newValue); }; -class SMITrigger : public SMIInput { +class SMITrigger : public SMIInput +{ friend class StateMachineInstance; friend class TransitionTriggerCondition;
diff --git a/include/rive/animation/state_machine_instance.hpp b/include/rive/animation/state_machine_instance.hpp index 7a907bd..5013b34 100644 --- a/include/rive/animation/state_machine_instance.hpp +++ b/include/rive/animation/state_machine_instance.hpp
@@ -8,7 +8,8 @@ #include "rive/listener_type.hpp" #include "rive/scene.hpp" -namespace rive { +namespace rive +{ class StateMachine; class LayerState; class SMIInput; @@ -21,7 +22,8 @@ class HitShape; class NestedArtboard; -class StateMachineInstance : public Scene { +class StateMachineInstance : public Scene +{ friend class SMIInput; private:
diff --git a/include/rive/animation/state_machine_layer.hpp b/include/rive/animation/state_machine_layer.hpp index 431491a..74ba7e3 100644 --- a/include/rive/animation/state_machine_layer.hpp +++ b/include/rive/animation/state_machine_layer.hpp
@@ -4,13 +4,15 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class LayerState; class StateMachineLayerImporter; class AnyState; class EntryState; class ExitState; -class StateMachineLayer : public StateMachineLayerBase { +class StateMachineLayer : public StateMachineLayerBase +{ friend class StateMachineLayerImporter; private: @@ -34,8 +36,10 @@ #ifdef TESTING size_t stateCount() const { return m_States.size(); } - LayerState* state(size_t index) const { - if (index < m_States.size()) { + LayerState* state(size_t index) const + { + if (index < m_States.size()) + { return m_States[index]; } return nullptr;
diff --git a/include/rive/animation/state_machine_layer_component.hpp b/include/rive/animation/state_machine_layer_component.hpp index aaf2581..4016d5e 100644 --- a/include/rive/animation/state_machine_layer_component.hpp +++ b/include/rive/animation/state_machine_layer_component.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_LAYER_COMPONENT_HPP_ #include "rive/generated/animation/state_machine_layer_component_base.hpp" #include <stdio.h> -namespace rive { -class StateMachineLayerComponent : public StateMachineLayerComponentBase { +namespace rive +{ +class StateMachineLayerComponent : public StateMachineLayerComponentBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/state_machine_listener.hpp b/include/rive/animation/state_machine_listener.hpp index f962b8c..88be3c0 100644 --- a/include/rive/animation/state_machine_listener.hpp +++ b/include/rive/animation/state_machine_listener.hpp
@@ -4,12 +4,14 @@ #include "rive/listener_type.hpp" #include "rive/math/vec2d.hpp" -namespace rive { +namespace rive +{ class Shape; class StateMachineListenerImporter; class ListenerAction; class StateMachineInstance; -class StateMachineListener : public StateMachineListenerBase { +class StateMachineListener : public StateMachineListenerBase +{ friend class StateMachineListenerImporter; private:
diff --git a/include/rive/animation/state_machine_number.hpp b/include/rive/animation/state_machine_number.hpp index e67e812..ca3e4e1 100644 --- a/include/rive/animation/state_machine_number.hpp +++ b/include/rive/animation/state_machine_number.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_NUMBER_HPP_ #include "rive/generated/animation/state_machine_number_base.hpp" #include <stdio.h> -namespace rive { -class StateMachineNumber : public StateMachineNumberBase { +namespace rive +{ +class StateMachineNumber : public StateMachineNumberBase +{ public: }; } // namespace rive
diff --git a/include/rive/animation/state_machine_trigger.hpp b/include/rive/animation/state_machine_trigger.hpp index f9320d5..c556c57 100644 --- a/include/rive/animation/state_machine_trigger.hpp +++ b/include/rive/animation/state_machine_trigger.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_TRIGGER_HPP_ #include "rive/generated/animation/state_machine_trigger_base.hpp" #include <stdio.h> -namespace rive { -class StateMachineTrigger : public StateMachineTriggerBase {}; +namespace rive +{ +class StateMachineTrigger : public StateMachineTriggerBase +{}; } // namespace rive #endif \ No newline at end of file
diff --git a/include/rive/animation/state_transition.hpp b/include/rive/animation/state_transition.hpp index 101b3de..ce63bbf 100644 --- a/include/rive/animation/state_transition.hpp +++ b/include/rive/animation/state_transition.hpp
@@ -5,7 +5,8 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class LayerState; class StateMachineLayerImporter; class StateTransitionImporter; @@ -15,14 +16,21 @@ class LinearAnimation; class LinearAnimationInstance; -enum class AllowTransition : unsigned char { no, waitingForExit, yes }; +enum class AllowTransition : unsigned char +{ + no, + waitingForExit, + yes +}; -class StateTransition : public StateTransitionBase { +class StateTransition : public StateTransitionBase +{ friend class StateMachineLayerImporter; friend class StateTransitionImporter; private: - StateTransitionFlags transitionFlags() const { + StateTransitionFlags transitionFlags() const + { return static_cast<StateTransitionFlags>(flags()); } LayerState* m_StateTo = nullptr; @@ -39,7 +47,8 @@ /// Whether the transition is marked disabled (usually done in the /// editor). - bool isDisabled() const { + bool isDisabled() const + { return (transitionFlags() & StateTransitionFlags::Disabled) == StateTransitionFlags::Disabled; } @@ -52,14 +61,16 @@ /// Whether the animation is held at exit or if it keeps advancing /// during mixing. - bool pauseOnExit() const { + bool pauseOnExit() const + { return (transitionFlags() & StateTransitionFlags::PauseOnExit) == StateTransitionFlags::PauseOnExit; } /// Whether exit time is enabled. All other conditions still apply, the /// exit time is effectively an AND with the rest of the conditions. - bool enableExitTime() const { + bool enableExitTime() const + { return (transitionFlags() & StateTransitionFlags::EnableExitTime) == StateTransitionFlags::EnableExitTime; } @@ -67,8 +78,10 @@ StatusCode import(ImportStack& importStack) override; size_t conditionCount() const { return m_Conditions.size(); } - TransitionCondition* condition(size_t index) const { - if (index < m_Conditions.size()) { + TransitionCondition* condition(size_t index) const + { + if (index < m_Conditions.size()) + { return m_Conditions[index]; } return nullptr;
diff --git a/include/rive/animation/state_transition_flags.hpp b/include/rive/animation/state_transition_flags.hpp index 7ce6758..542c231 100644 --- a/include/rive/animation/state_transition_flags.hpp +++ b/include/rive/animation/state_transition_flags.hpp
@@ -3,8 +3,10 @@ #include <type_traits> -namespace rive { -enum class StateTransitionFlags : unsigned char { +namespace rive +{ +enum class StateTransitionFlags : unsigned char +{ None = 0, /// Whether the transition is disabled. @@ -25,33 +27,35 @@ }; -inline constexpr StateTransitionFlags operator&(StateTransitionFlags lhs, - StateTransitionFlags rhs) { +inline constexpr StateTransitionFlags operator&(StateTransitionFlags lhs, StateTransitionFlags rhs) +{ return static_cast<StateTransitionFlags>( static_cast<std::underlying_type<StateTransitionFlags>::type>(lhs) & static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs)); } -inline constexpr StateTransitionFlags operator^(StateTransitionFlags lhs, - StateTransitionFlags rhs) { +inline constexpr StateTransitionFlags operator^(StateTransitionFlags lhs, StateTransitionFlags rhs) +{ return static_cast<StateTransitionFlags>( static_cast<std::underlying_type<StateTransitionFlags>::type>(lhs) ^ static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs)); } -inline constexpr StateTransitionFlags operator|(StateTransitionFlags lhs, - StateTransitionFlags rhs) { +inline constexpr StateTransitionFlags operator|(StateTransitionFlags lhs, StateTransitionFlags rhs) +{ return static_cast<StateTransitionFlags>( static_cast<std::underlying_type<StateTransitionFlags>::type>(lhs) | static_cast<std::underlying_type<StateTransitionFlags>::type>(rhs)); } -inline constexpr StateTransitionFlags operator~(StateTransitionFlags rhs) { +inline constexpr StateTransitionFlags operator~(StateTransitionFlags rhs) +{ return static_cast<StateTransitionFlags>( ~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)); @@ -59,7 +63,8 @@ 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)); @@ -67,7 +72,8 @@ 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/system_state_instance.hpp b/include/rive/animation/system_state_instance.hpp index f0a9853..0adc062 100644 --- a/include/rive/animation/system_state_instance.hpp +++ b/include/rive/animation/system_state_instance.hpp
@@ -4,11 +4,13 @@ #include <string> #include "rive/animation/state_instance.hpp" -namespace rive { +namespace rive +{ /// Represents an instance of a system state machine. Basically a /// placeholder that may have meaning to the state machine itself, or is /// just a no-op state (perhaps an unknown to this runtime state-type). -class SystemStateInstance : public StateInstance { +class SystemStateInstance : public StateInstance +{ public: SystemStateInstance(const LayerState* layerState, ArtboardInstance* instance);
diff --git a/include/rive/animation/transition_bool_condition.hpp b/include/rive/animation/transition_bool_condition.hpp index a737d6c..3a41a16 100644 --- a/include/rive/animation/transition_bool_condition.hpp +++ b/include/rive/animation/transition_bool_condition.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSITION_BOOL_CONDITION_HPP_ #include "rive/generated/animation/transition_bool_condition_base.hpp" #include <stdio.h> -namespace rive { -class TransitionBoolCondition : public TransitionBoolConditionBase { +namespace rive +{ +class TransitionBoolCondition : public TransitionBoolConditionBase +{ public: bool evaluate(const SMIInput* inputInstance) const override;
diff --git a/include/rive/animation/transition_condition.hpp b/include/rive/animation/transition_condition.hpp index c8772b7..5198013 100644 --- a/include/rive/animation/transition_condition.hpp +++ b/include/rive/animation/transition_condition.hpp
@@ -2,11 +2,13 @@ #define _RIVE_TRANSITION_CONDITION_HPP_ #include "rive/generated/animation/transition_condition_base.hpp" -namespace rive { +namespace rive +{ class StateMachineInput; class SMIInput; -class TransitionCondition : public TransitionConditionBase { +class TransitionCondition : public TransitionConditionBase +{ public: StatusCode onAddedDirty(CoreContext* context) override; StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/animation/transition_condition_op.hpp b/include/rive/animation/transition_condition_op.hpp index 8585d38..cf2ef7c 100644 --- a/include/rive/animation/transition_condition_op.hpp +++ b/include/rive/animation/transition_condition_op.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_TRANSITION_CONDITION_OP_HPP_ #define _RIVE_TRANSITION_CONDITION_OP_HPP_ -namespace rive { -enum class TransitionConditionOp : int { +namespace rive +{ +enum class TransitionConditionOp : int +{ equal = 0, notEqual = 1, lessThanOrEqual = 2,
diff --git a/include/rive/animation/transition_number_condition.hpp b/include/rive/animation/transition_number_condition.hpp index bcad26e..e8c88d9 100644 --- a/include/rive/animation/transition_number_condition.hpp +++ b/include/rive/animation/transition_number_condition.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSITION_NUMBER_CONDITION_HPP_ #include "rive/generated/animation/transition_number_condition_base.hpp" #include <stdio.h> -namespace rive { -class TransitionNumberCondition : public TransitionNumberConditionBase { +namespace rive +{ +class TransitionNumberCondition : public TransitionNumberConditionBase +{ protected: bool validateInputType(const StateMachineInput* input) const override;
diff --git a/include/rive/animation/transition_trigger_condition.hpp b/include/rive/animation/transition_trigger_condition.hpp index d81157b..cb53566 100644 --- a/include/rive/animation/transition_trigger_condition.hpp +++ b/include/rive/animation/transition_trigger_condition.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSITION_TRIGGER_CONDITION_HPP_ #include "rive/generated/animation/transition_trigger_condition_base.hpp" #include <stdio.h> -namespace rive { -class TransitionTriggerCondition : public TransitionTriggerConditionBase { +namespace rive +{ +class TransitionTriggerCondition : public TransitionTriggerConditionBase +{ public: bool evaluate(const SMIInput* inputInstance) const override;
diff --git a/include/rive/animation/transition_value_condition.hpp b/include/rive/animation/transition_value_condition.hpp index a3d68ee..6f79a02 100644 --- a/include/rive/animation/transition_value_condition.hpp +++ b/include/rive/animation/transition_value_condition.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/animation/transition_value_condition_base.hpp" #include "rive/animation/transition_condition_op.hpp" -namespace rive { -class TransitionValueCondition : public TransitionValueConditionBase { +namespace rive +{ +class TransitionValueCondition : public TransitionValueConditionBase +{ public: TransitionConditionOp op() const { return (TransitionConditionOp)opValue(); } };
diff --git a/include/rive/artboard.hpp b/include/rive/artboard.hpp index e3a5962..e788a07 100644 --- a/include/rive/artboard.hpp +++ b/include/rive/artboard.hpp
@@ -13,7 +13,8 @@ #include <queue> #include <vector> -namespace rive { +namespace rive +{ class File; class Drawable; class Factory; @@ -26,7 +27,8 @@ class Scene; class StateMachineInstance; -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; @@ -88,7 +90,8 @@ bool advance(double elapsedSeconds); - enum class DrawOption { + enum class DrawOption + { kNormal, kHideBG, kHideFG, @@ -108,9 +111,12 @@ bool isTranslucent(const LinearAnimation*) const; bool isTranslucent(const LinearAnimationInstance*) const; - template <typename T = Component> T* find(const std::string& name) { - for (auto object : m_Objects) { - if (object != nullptr && object->is<T>() && object->as<T>()->name() == name) { + template <typename T = Component> T* find(const std::string& name) + { + for (auto object : m_Objects) + { + if (object != nullptr && object->is<T>() && object->as<T>()->name() == name) + { return reinterpret_cast<T*>(object); } } @@ -159,7 +165,8 @@ StatusCode import(ImportStack& importStack) override; }; -class ArtboardInstance : public Artboard { +class ArtboardInstance : public Artboard +{ public: ArtboardInstance(); ~ArtboardInstance() override;
diff --git a/include/rive/assets/asset.hpp b/include/rive/assets/asset.hpp index b747b0e..16f8cef 100644 --- a/include/rive/assets/asset.hpp +++ b/include/rive/assets/asset.hpp
@@ -2,8 +2,10 @@ #define _RIVE_ASSET_HPP_ #include "rive/generated/assets/asset_base.hpp" #include <stdio.h> -namespace rive { -class Asset : public AssetBase { +namespace rive +{ +class Asset : public AssetBase +{ public: }; } // namespace rive
diff --git a/include/rive/assets/drawable_asset.hpp b/include/rive/assets/drawable_asset.hpp index 13c2f9a..ce2ddaf 100644 --- a/include/rive/assets/drawable_asset.hpp +++ b/include/rive/assets/drawable_asset.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DRAWABLE_ASSET_HPP_ #include "rive/generated/assets/drawable_asset_base.hpp" #include <stdio.h> -namespace rive { -class DrawableAsset : public DrawableAssetBase { +namespace rive +{ +class DrawableAsset : public DrawableAssetBase +{ public: }; } // namespace rive
diff --git a/include/rive/assets/file_asset.hpp b/include/rive/assets/file_asset.hpp index fcf7bdb..d506558 100644 --- a/include/rive/assets/file_asset.hpp +++ b/include/rive/assets/file_asset.hpp
@@ -4,9 +4,11 @@ #include "rive/span.hpp" #include <string> -namespace rive { +namespace rive +{ class Factory; -class FileAsset : public FileAssetBase { +class FileAsset : public FileAssetBase +{ public: virtual bool decode(Span<const uint8_t>, Factory*) = 0; virtual std::string fileExtension() = 0;
diff --git a/include/rive/assets/file_asset_contents.hpp b/include/rive/assets/file_asset_contents.hpp index 65477e2..c0afb30 100644 --- a/include/rive/assets/file_asset_contents.hpp +++ b/include/rive/assets/file_asset_contents.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/assets/file_asset_contents_base.hpp" #include <cstdint> -namespace rive { -class FileAssetContents : public FileAssetContentsBase { +namespace rive +{ +class FileAssetContents : public FileAssetContentsBase +{ private: std::vector<uint8_t> m_Bytes;
diff --git a/include/rive/assets/file_asset_referencer.hpp b/include/rive/assets/file_asset_referencer.hpp index 87eeb5e..fa0be00 100644 --- a/include/rive/assets/file_asset_referencer.hpp +++ b/include/rive/assets/file_asset_referencer.hpp
@@ -1,9 +1,11 @@ #ifndef _RIVE_FILE_ASSET_REFERENCER_HPP_ #define _RIVE_FILE_ASSET_REFERENCER_HPP_ -namespace rive { +namespace rive +{ class FileAsset; -class FileAssetReferencer { +class FileAssetReferencer +{ public: virtual ~FileAssetReferencer() {} virtual void assets(const std::vector<FileAsset*>& assets) = 0;
diff --git a/include/rive/assets/folder.hpp b/include/rive/assets/folder.hpp index af31810..d51c359 100644 --- a/include/rive/assets/folder.hpp +++ b/include/rive/assets/folder.hpp
@@ -2,8 +2,10 @@ #define _RIVE_FOLDER_HPP_ #include "rive/generated/assets/folder_base.hpp" #include <stdio.h> -namespace rive { -class Folder : public FolderBase { +namespace rive +{ +class Folder : public FolderBase +{ public: }; } // namespace rive
diff --git a/include/rive/assets/image_asset.hpp b/include/rive/assets/image_asset.hpp index 0083e79..6d941fc 100644 --- a/include/rive/assets/image_asset.hpp +++ b/include/rive/assets/image_asset.hpp
@@ -5,8 +5,10 @@ #include "rive/renderer.hpp" #include <string> -namespace rive { -class ImageAsset : public ImageAssetBase { +namespace rive +{ +class ImageAsset : public ImageAssetBase +{ private: std::unique_ptr<RenderImage> m_RenderImage;
diff --git a/include/rive/backboard.hpp b/include/rive/backboard.hpp index 1ace6fe..475011c 100644 --- a/include/rive/backboard.hpp +++ b/include/rive/backboard.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_BACKBOARD_HPP_ #define _RIVE_BACKBOARD_HPP_ #include "rive/generated/backboard_base.hpp" -namespace rive { -class Backboard : public BackboardBase {}; +namespace rive +{ +class Backboard : public BackboardBase +{}; } // namespace rive #endif \ No newline at end of file
diff --git a/include/rive/bones/bone.hpp b/include/rive/bones/bone.hpp index 7f3d5e1..d5d2a16 100644 --- a/include/rive/bones/bone.hpp +++ b/include/rive/bones/bone.hpp
@@ -4,9 +4,11 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class Constraint; -class Bone : public BoneBase { +class Bone : public BoneBase +{ private: std::vector<Bone*> m_ChildBones;
diff --git a/include/rive/bones/cubic_weight.hpp b/include/rive/bones/cubic_weight.hpp index fc75855..23af090 100644 --- a/include/rive/bones/cubic_weight.hpp +++ b/include/rive/bones/cubic_weight.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CUBIC_WEIGHT_HPP_ #include "rive/generated/bones/cubic_weight_base.hpp" #include <stdio.h> -namespace rive { -class CubicWeight : public CubicWeightBase { +namespace rive +{ +class CubicWeight : public CubicWeightBase +{ private: Vec2D m_InTranslation; Vec2D m_OutTranslation;
diff --git a/include/rive/bones/root_bone.hpp b/include/rive/bones/root_bone.hpp index 9a9cdd6..b6f4aeb 100644 --- a/include/rive/bones/root_bone.hpp +++ b/include/rive/bones/root_bone.hpp
@@ -2,8 +2,10 @@ #define _RIVE_ROOT_BONE_HPP_ #include "rive/generated/bones/root_bone_base.hpp" #include <stdio.h> -namespace rive { -class RootBone : public RootBoneBase { +namespace rive +{ +class RootBone : public RootBoneBase +{ public: StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/bones/skeletal_component.hpp b/include/rive/bones/skeletal_component.hpp index 3eaf647..03b49ef 100644 --- a/include/rive/bones/skeletal_component.hpp +++ b/include/rive/bones/skeletal_component.hpp
@@ -2,8 +2,10 @@ #define _RIVE_SKELETAL_COMPONENT_HPP_ #include "rive/generated/bones/skeletal_component_base.hpp" #include <stdio.h> -namespace rive { -class SkeletalComponent : public SkeletalComponentBase { +namespace rive +{ +class SkeletalComponent : public SkeletalComponentBase +{ public: }; } // namespace rive
diff --git a/include/rive/bones/skin.hpp b/include/rive/bones/skin.hpp index 20d3639..ba70420 100644 --- a/include/rive/bones/skin.hpp +++ b/include/rive/bones/skin.hpp
@@ -6,12 +6,14 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class Tendon; class Vertex; class Skinnable; -class Skin : public SkinBase { +class Skin : public SkinBase +{ friend class Tendon; public:
diff --git a/include/rive/bones/skinnable.hpp b/include/rive/bones/skinnable.hpp index 63ab749..345dbf9 100644 --- a/include/rive/bones/skinnable.hpp +++ b/include/rive/bones/skinnable.hpp
@@ -3,11 +3,13 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ class Skin; class Component; -class Skinnable { +class Skinnable +{ friend class Skin; private:
diff --git a/include/rive/bones/tendon.hpp b/include/rive/bones/tendon.hpp index e37b086..6a8f456 100644 --- a/include/rive/bones/tendon.hpp +++ b/include/rive/bones/tendon.hpp
@@ -5,9 +5,11 @@ #include "rive/math/mat2d.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class Bone; -class Tendon : public TendonBase { +class Tendon : public TendonBase +{ private: Mat2D m_InverseBind; Bone* m_Bone = nullptr;
diff --git a/include/rive/bones/weight.hpp b/include/rive/bones/weight.hpp index 0dcf361..4b8658f 100644 --- a/include/rive/bones/weight.hpp +++ b/include/rive/bones/weight.hpp
@@ -4,8 +4,10 @@ #include "rive/math/vec2d.hpp" #include <stdio.h> -namespace rive { -class Weight : public WeightBase { +namespace rive +{ +class Weight : public WeightBase +{ private: Vec2D m_Translation;
diff --git a/include/rive/command_path.hpp b/include/rive/command_path.hpp index 2b6bc2f..3f77b15 100644 --- a/include/rive/command_path.hpp +++ b/include/rive/command_path.hpp
@@ -4,11 +4,13 @@ #include "rive/math/mat2d.hpp" #include "rive/math/path_types.hpp" -namespace rive { +namespace rive +{ class RenderPath; /// Abstract path used to build up commands used for rendering. -class CommandPath { +class CommandPath +{ public: virtual ~CommandPath() {} virtual void reset() = 0; @@ -24,7 +26,8 @@ // non-virtual helpers - void addRect(float x, float y, float width, float height) { + void addRect(float x, float y, float width, float height) + { moveTo(x, y); lineTo(x + width, y); lineTo(x + width, y + height);
diff --git a/include/rive/component.hpp b/include/rive/component.hpp index 5ed9999..0c52a6c 100644 --- a/include/rive/component.hpp +++ b/include/rive/component.hpp
@@ -5,11 +5,13 @@ #include <vector> -namespace rive { +namespace rive +{ class ContainerComponent; class Artboard; -class Component : public ComponentBase { +class Component : public ComponentBase +{ friend class Artboard; private: @@ -40,7 +42,8 @@ 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; } - static inline bool hasDirt(ComponentDirt value, ComponentDirt 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 a22331d..f0097e6 100644 --- a/include/rive/component_dirt.hpp +++ b/include/rive/component_dirt.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DIRTY_FLAGS_HPP_ #include <type_traits> -namespace rive { -enum class ComponentDirt : unsigned short { +namespace rive +{ +enum class ComponentDirt : unsigned short +{ None = 0, Dependents = 1 << 0, @@ -50,40 +52,47 @@ 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)); } -inline constexpr ComponentDirt operator~(ComponentDirt rhs) { +inline constexpr ComponentDirt operator~(ComponentDirt rhs) +{ return static_cast<ComponentDirt>(~static_cast<std::underlying_type<ComponentDirt>::type>(rhs)); } -inline ComponentDirt& operator|=(ComponentDirt& lhs, ComponentDirt rhs) { +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)); return lhs; } -inline ComponentDirt& operator&=(ComponentDirt& lhs, ComponentDirt rhs) { +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)); return lhs; } -inline ComponentDirt& operator^=(ComponentDirt& lhs, ComponentDirt rhs) { +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));
diff --git a/include/rive/constraints/constraint.hpp b/include/rive/constraints/constraint.hpp index cc7ca1d..bb29fb2 100644 --- a/include/rive/constraints/constraint.hpp +++ b/include/rive/constraints/constraint.hpp
@@ -2,11 +2,13 @@ #define _RIVE_CONSTRAINT_HPP_ #include "rive/generated/constraints/constraint_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class TransformComponent; class Mat2D; -class Constraint : public ConstraintBase { +class Constraint : public ConstraintBase +{ public: void strengthChanged() override; StatusCode onAddedClean(CoreContext* context) override;
diff --git a/include/rive/constraints/distance_constraint.hpp b/include/rive/constraints/distance_constraint.hpp index 3fd97f2..83a9f9f 100644 --- a/include/rive/constraints/distance_constraint.hpp +++ b/include/rive/constraints/distance_constraint.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DISTANCE_CONSTRAINT_HPP_ #include "rive/generated/constraints/distance_constraint_base.hpp" #include <stdio.h> -namespace rive { -class DistanceConstraint : public DistanceConstraintBase { +namespace rive +{ +class DistanceConstraint : public DistanceConstraintBase +{ public: void constrain(TransformComponent* component) override; };
diff --git a/include/rive/constraints/ik_constraint.hpp b/include/rive/constraints/ik_constraint.hpp index 51943ea..80a9892 100644 --- a/include/rive/constraints/ik_constraint.hpp +++ b/include/rive/constraints/ik_constraint.hpp
@@ -5,11 +5,14 @@ #include "rive/math/transform_components.hpp" #include <vector> -namespace rive { +namespace rive +{ class Bone; -class IKConstraint : public IKConstraintBase { +class IKConstraint : public IKConstraintBase +{ private: - struct BoneChainLink { + struct BoneChainLink + { int index; Bone* bone; float angle;
diff --git a/include/rive/constraints/rotation_constraint.hpp b/include/rive/constraints/rotation_constraint.hpp index f9dc699..596ade3 100644 --- a/include/rive/constraints/rotation_constraint.hpp +++ b/include/rive/constraints/rotation_constraint.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/constraints/rotation_constraint_base.hpp" #include "rive/math/transform_components.hpp" #include <stdio.h> -namespace rive { -class RotationConstraint : public RotationConstraintBase { +namespace rive +{ +class RotationConstraint : public RotationConstraintBase +{ private: TransformComponents m_ComponentsA; TransformComponents m_ComponentsB;
diff --git a/include/rive/constraints/scale_constraint.hpp b/include/rive/constraints/scale_constraint.hpp index 6dad482..10d5030 100644 --- a/include/rive/constraints/scale_constraint.hpp +++ b/include/rive/constraints/scale_constraint.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/constraints/scale_constraint_base.hpp" #include "rive/math/transform_components.hpp" #include <stdio.h> -namespace rive { -class ScaleConstraint : public ScaleConstraintBase { +namespace rive +{ +class ScaleConstraint : public ScaleConstraintBase +{ private: TransformComponents m_ComponentsA; TransformComponents m_ComponentsB;
diff --git a/include/rive/constraints/targeted_constraint.hpp b/include/rive/constraints/targeted_constraint.hpp index eeb3665..7d08846 100644 --- a/include/rive/constraints/targeted_constraint.hpp +++ b/include/rive/constraints/targeted_constraint.hpp
@@ -2,9 +2,11 @@ #define _RIVE_TARGETED_CONSTRAINT_HPP_ #include "rive/generated/constraints/targeted_constraint_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class TransformComponent; -class TargetedConstraint : public TargetedConstraintBase { +class TargetedConstraint : public TargetedConstraintBase +{ protected: TransformComponent* m_Target = nullptr;
diff --git a/include/rive/constraints/transform_component_constraint.hpp b/include/rive/constraints/transform_component_constraint.hpp index b38650f..c890ca1 100644 --- a/include/rive/constraints/transform_component_constraint.hpp +++ b/include/rive/constraints/transform_component_constraint.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/constraints/transform_component_constraint_base.hpp" #include "rive/transform_space.hpp" #include <stdio.h> -namespace rive { -class TransformComponentConstraint : public TransformComponentConstraintBase { +namespace rive +{ +class TransformComponentConstraint : public TransformComponentConstraintBase +{ public: TransformSpace minMaxSpace() const { return (TransformSpace)minMaxSpaceValue(); } };
diff --git a/include/rive/constraints/transform_component_constraint_y.hpp b/include/rive/constraints/transform_component_constraint_y.hpp index b755a39..05aaf3d 100644 --- a/include/rive/constraints/transform_component_constraint_y.hpp +++ b/include/rive/constraints/transform_component_constraint_y.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSFORM_COMPONENT_CONSTRAINT_Y_HPP_ #include "rive/generated/constraints/transform_component_constraint_y_base.hpp" #include <stdio.h> -namespace rive { -class TransformComponentConstraintY : public TransformComponentConstraintYBase { +namespace rive +{ +class TransformComponentConstraintY : public TransformComponentConstraintYBase +{ public: }; } // namespace rive
diff --git a/include/rive/constraints/transform_constraint.hpp b/include/rive/constraints/transform_constraint.hpp index 5fec7b6..3368b08 100644 --- a/include/rive/constraints/transform_constraint.hpp +++ b/include/rive/constraints/transform_constraint.hpp
@@ -4,8 +4,10 @@ #include "rive/math/transform_components.hpp" #include <stdio.h> -namespace rive { -class TransformConstraint : public TransformConstraintBase { +namespace rive +{ +class TransformConstraint : public TransformConstraintBase +{ private: TransformComponents m_ComponentsA; TransformComponents m_ComponentsB;
diff --git a/include/rive/constraints/transform_space_constraint.hpp b/include/rive/constraints/transform_space_constraint.hpp index 6d2b322..fe7be1a 100644 --- a/include/rive/constraints/transform_space_constraint.hpp +++ b/include/rive/constraints/transform_space_constraint.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/constraints/transform_space_constraint_base.hpp" #include "rive/transform_space.hpp" #include <stdio.h> -namespace rive { -class TransformSpaceConstraint : public TransformSpaceConstraintBase { +namespace rive +{ +class TransformSpaceConstraint : public TransformSpaceConstraintBase +{ public: TransformSpace sourceSpace() const { return (TransformSpace)sourceSpaceValue(); } TransformSpace destSpace() const { return (TransformSpace)destSpaceValue(); }
diff --git a/include/rive/constraints/translation_constraint.hpp b/include/rive/constraints/translation_constraint.hpp index 9311b4b..08c2cf3 100644 --- a/include/rive/constraints/translation_constraint.hpp +++ b/include/rive/constraints/translation_constraint.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSLATION_CONSTRAINT_HPP_ #include "rive/generated/constraints/translation_constraint_base.hpp" #include <stdio.h> -namespace rive { -class TranslationConstraint : public TranslationConstraintBase { +namespace rive +{ +class TranslationConstraint : public TranslationConstraintBase +{ public: void constrain(TransformComponent* component) override; };
diff --git a/include/rive/container_component.hpp b/include/rive/container_component.hpp index ba4f9f6..81b38a3 100644 --- a/include/rive/container_component.hpp +++ b/include/rive/container_component.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CONTAINER_COMPONENT_HPP_ #include "rive/generated/container_component_base.hpp" #include <vector> -namespace rive { -class ContainerComponent : public ContainerComponentBase {}; +namespace rive +{ +class ContainerComponent : public ContainerComponentBase +{}; } // namespace rive #endif \ No newline at end of file
diff --git a/include/rive/core.hpp b/include/rive/core.hpp index 0c97734..832fccd 100644 --- a/include/rive/core.hpp +++ b/include/rive/core.hpp
@@ -5,10 +5,12 @@ #include "rive/core/binary_reader.hpp" #include "rive/status_code.hpp" -namespace rive { +namespace rive +{ class CoreContext; class ImportStack; -class Core { +class Core +{ public: static const int invalidPropertyKey = 0; virtual ~Core() {} @@ -17,7 +19,8 @@ virtual bool deserialize(uint16_t propertyKey, BinaryReader& reader) = 0; template <typename T> inline bool is() const { return isTypeOf(T::typeKey); } - template <typename T> inline T* as() { + template <typename T> inline T* as() + { assert(is<T>()); return reinterpret_cast<T*>(this); } @@ -25,7 +28,8 @@ /// Make a shallow copy of the object. virtual Core* clone() const { return nullptr; } - template <typename T> inline const T* as() const { + template <typename T> inline const T* as() const + { assert(is<T>()); return reinterpret_cast<const T*>(this); }
diff --git a/include/rive/core/binary_reader.hpp b/include/rive/core/binary_reader.hpp index a1b9591..c0c2c3b 100644 --- a/include/rive/core/binary_reader.hpp +++ b/include/rive/core/binary_reader.hpp
@@ -7,8 +7,10 @@ #include "rive/span.hpp" #include "rive/core/type_conversions.hpp" -namespace rive { -class BinaryReader { +namespace rive +{ +class BinaryReader +{ private: Span<const uint8_t> m_Bytes; const uint8_t* m_Position; @@ -37,9 +39,11 @@ // This will cast the uint read to the requested size, but if the // raw value was out-of-range, instead returns 0 and sets the IntRangeError. - template <typename T> T readVarUintAs() { + template <typename T> T readVarUintAs() + { auto value = this->readVarUint64(); - if (!fitsIn<T>(value)) { + if (!fitsIn<T>(value)) + { value = 0; this->intRangeError(); }
diff --git a/include/rive/core/field_types/core_bool_type.hpp b/include/rive/core/field_types/core_bool_type.hpp index 3c699cf..c6b0fcc 100644 --- a/include/rive/core/field_types/core_bool_type.hpp +++ b/include/rive/core/field_types/core_bool_type.hpp
@@ -1,9 +1,11 @@ #ifndef _RIVE_CORE_BOOL_TYPE_HPP_ #define _RIVE_CORE_BOOL_TYPE_HPP_ -namespace rive { +namespace rive +{ class BinaryReader; -class CoreBoolType { +class CoreBoolType +{ public: static const int id = 0; static bool deserialize(BinaryReader& reader);
diff --git a/include/rive/core/field_types/core_bytes_type.hpp b/include/rive/core/field_types/core_bytes_type.hpp index 879619a..90f1886 100644 --- a/include/rive/core/field_types/core_bytes_type.hpp +++ b/include/rive/core/field_types/core_bytes_type.hpp
@@ -4,9 +4,11 @@ #include "rive/span.hpp" #include <cstdint> -namespace rive { +namespace rive +{ class BinaryReader; -class CoreBytesType { +class CoreBytesType +{ public: static const int id = 1; static Span<const uint8_t> deserialize(BinaryReader& reader);
diff --git a/include/rive/core/field_types/core_color_type.hpp b/include/rive/core/field_types/core_color_type.hpp index 16b8f94..afacba9 100644 --- a/include/rive/core/field_types/core_color_type.hpp +++ b/include/rive/core/field_types/core_color_type.hpp
@@ -1,9 +1,11 @@ #ifndef _RIVE_CORE_COLOR_TYPE_HPP_ #define _RIVE_CORE_COLOR_TYPE_HPP_ -namespace rive { +namespace rive +{ class BinaryReader; -class CoreColorType { +class CoreColorType +{ public: static const int id = 3; static int deserialize(BinaryReader& reader);
diff --git a/include/rive/core/field_types/core_double_type.hpp b/include/rive/core/field_types/core_double_type.hpp index c46c9e2..6351572 100644 --- a/include/rive/core/field_types/core_double_type.hpp +++ b/include/rive/core/field_types/core_double_type.hpp
@@ -1,9 +1,11 @@ #ifndef _RIVE_CORE_DOUBLE_TYPE_HPP_ #define _RIVE_CORE_DOUBLE_TYPE_HPP_ -namespace rive { +namespace rive +{ class BinaryReader; -class CoreDoubleType { +class CoreDoubleType +{ public: static const int id = 2; static float deserialize(BinaryReader& reader);
diff --git a/include/rive/core/field_types/core_string_type.hpp b/include/rive/core/field_types/core_string_type.hpp index 1719a60..5962545 100644 --- a/include/rive/core/field_types/core_string_type.hpp +++ b/include/rive/core/field_types/core_string_type.hpp
@@ -3,9 +3,11 @@ #include <string> -namespace rive { +namespace rive +{ class BinaryReader; -class CoreStringType { +class CoreStringType +{ public: static const int id = 1; static std::string deserialize(BinaryReader& reader);
diff --git a/include/rive/core/field_types/core_uint_type.hpp b/include/rive/core/field_types/core_uint_type.hpp index 3faad66..af9c399 100644 --- a/include/rive/core/field_types/core_uint_type.hpp +++ b/include/rive/core/field_types/core_uint_type.hpp
@@ -1,9 +1,11 @@ #ifndef _RIVE_CORE_UINT_TYPE_HPP_ #define _RIVE_CORE_UINT_TYPE_HPP_ -namespace rive { +namespace rive +{ class BinaryReader; -class CoreUintType { +class CoreUintType +{ public: static const int id = 0; static unsigned int deserialize(BinaryReader& reader);
diff --git a/include/rive/core/reader.h b/include/rive/core/reader.h index 9e6fa22..2c9a2fc 100644 --- a/include/rive/core/reader.h +++ b/include/rive/core/reader.h
@@ -1,8 +1,10 @@ #include <stdlib.h> #include <string.h> -static bool is_big_endian(void) { - union { +static bool is_big_endian(void) +{ + union + { uint32_t i; char c[4]; } bint = {0x01020304}; @@ -12,14 +14,17 @@ /* Decode an unsigned int LEB128 at buf into r, returning the nr of bytes read. */ -inline size_t decode_uint_leb(const uint8_t* buf, const uint8_t* buf_end, uint64_t* r) { +inline size_t decode_uint_leb(const uint8_t* buf, const uint8_t* buf_end, uint64_t* r) +{ const uint8_t* p = buf; uint8_t shift = 0; uint64_t result = 0; uint8_t byte; - do { - if (p >= buf_end) { + do + { + if (p >= buf_end) + { return 0; } byte = *p++; @@ -33,13 +38,16 @@ /* Decodes a string */ inline uint64_t -decode_string(uint64_t str_len, const uint8_t* buf, const uint8_t* buf_end, char* char_buf) { +decode_string(uint64_t str_len, const uint8_t* buf, const uint8_t* buf_end, char* char_buf) +{ // Return zero bytes read on buffer overflow - if (buf_end < buf + str_len) { + if (buf_end < buf + str_len) + { return 0; } const uint8_t* p = buf; - for (int i = 0; i < str_len; i++) { + for (int i = 0; i < str_len; i++) + { char_buf[i] = *p++; } // Add the null terminator @@ -49,15 +57,20 @@ /* Decodes a float (4 bytes) */ -inline size_t decode_float(const uint8_t* buf, const uint8_t* buf_end, float* r) { +inline size_t decode_float(const uint8_t* buf, const uint8_t* buf_end, float* r) +{ // Return zero bytes read on buffer overflow - if (buf_end - buf < (unsigned)sizeof(float)) { + if (buf_end - buf < (unsigned)sizeof(float)) + { return 0; } - if (is_big_endian()) { + if (is_big_endian()) + { uint8_t inverted[4] = {buf[3], buf[2], buf[1], buf[0]}; memcpy(r, inverted, sizeof(float)); - } else { + } + else + { memcpy(r, buf, sizeof(float)); } return sizeof(float); @@ -65,9 +78,11 @@ /* Decodes a single byte */ -inline size_t decode_uint_8(const uint8_t* buf, const uint8_t* buf_end, uint8_t* r) { +inline size_t decode_uint_8(const uint8_t* buf, const uint8_t* buf_end, uint8_t* r) +{ // Return zero bytes read on buffer overflow - if (buf_end - buf < (unsigned)sizeof(uint8_t)) { + if (buf_end - buf < (unsigned)sizeof(uint8_t)) + { return 0; } memcpy(r, buf, sizeof(uint8_t)); @@ -76,15 +91,20 @@ /* Decodes a 32 bit unsigned integer. */ -inline size_t decode_uint_32(const uint8_t* buf, const uint8_t* buf_end, uint32_t* r) { +inline size_t decode_uint_32(const uint8_t* buf, const uint8_t* buf_end, uint32_t* r) +{ // Return zero bytes read on buffer overflow - if (buf_end - buf < (unsigned)sizeof(uint32_t)) { + if (buf_end - buf < (unsigned)sizeof(uint32_t)) + { return 0; } - if (is_big_endian()) { + if (is_big_endian()) + { uint8_t inverted[4] = {buf[3], buf[2], buf[1], buf[0]}; memcpy(r, inverted, sizeof(uint32_t)); - } else { + } + else + { memcpy(r, buf, sizeof(uint32_t)); } return sizeof(uint32_t);
diff --git a/include/rive/core/type_conversions.hpp b/include/rive/core/type_conversions.hpp index e51162b..406d9fc 100644 --- a/include/rive/core/type_conversions.hpp +++ b/include/rive/core/type_conversions.hpp
@@ -8,13 +8,16 @@ #include "rive/rive_types.hpp" #include <limits> -namespace rive { +namespace rive +{ -template <typename T> bool fitsIn(intmax_t x) { +template <typename T> bool fitsIn(intmax_t x) +{ return x >= std::numeric_limits<T>::min() && x <= std::numeric_limits<T>::max(); } -template <typename T> T castTo(intmax_t x) { +template <typename T> T castTo(intmax_t x) +{ assert(sizeof(T) <= 4); // don't cast to 64bit types assert(fitsIn<T>(x)); return static_cast<T>(x);
diff --git a/include/rive/core_context.hpp b/include/rive/core_context.hpp index c9baafb..655c751 100644 --- a/include/rive/core_context.hpp +++ b/include/rive/core_context.hpp
@@ -3,10 +3,12 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ class Artboard; class Core; -class CoreContext { +class CoreContext +{ public: virtual ~CoreContext() {} virtual Core* resolve(uint32_t id) const = 0;
diff --git a/include/rive/dependency_sorter.hpp b/include/rive/dependency_sorter.hpp index aa9ef5f..3c9cea3 100644 --- a/include/rive/dependency_sorter.hpp +++ b/include/rive/dependency_sorter.hpp
@@ -4,9 +4,11 @@ #include <unordered_set> #include <vector> -namespace rive { +namespace rive +{ class Component; -class DependencySorter { +class DependencySorter +{ private: std::unordered_set<Component*> m_Perm; std::unordered_set<Component*> m_Temp;
diff --git a/include/rive/draw_rules.hpp b/include/rive/draw_rules.hpp index 27a775d..7ff58e5 100644 --- a/include/rive/draw_rules.hpp +++ b/include/rive/draw_rules.hpp
@@ -2,9 +2,11 @@ #define _RIVE_DRAW_RULES_HPP_ #include "rive/generated/draw_rules_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class DrawTarget; -class DrawRules : public DrawRulesBase { +class DrawRules : public DrawRulesBase +{ private: DrawTarget* m_ActiveTarget = nullptr;
diff --git a/include/rive/draw_target.hpp b/include/rive/draw_target.hpp index e214572..b37113c 100644 --- a/include/rive/draw_target.hpp +++ b/include/rive/draw_target.hpp
@@ -5,10 +5,12 @@ #include "rive/generated/draw_target_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class Drawable; class Artboard; -class DrawTarget : public DrawTargetBase { +class DrawTarget : public DrawTargetBase +{ friend class Artboard; private:
diff --git a/include/rive/draw_target_placement.hpp b/include/rive/draw_target_placement.hpp index 33579b7..b2e45cd 100644 --- a/include/rive/draw_target_placement.hpp +++ b/include/rive/draw_target_placement.hpp
@@ -1,6 +1,11 @@ #ifndef _RIVE_DRAW_TARGET_PLACEMENT_HPP_ #define _RIVE_DRAW_TARGET_PLACEMENT_HPP_ -namespace rive { -enum class DrawTargetPlacement : unsigned char { before = 0, after = 1 }; +namespace rive +{ +enum class DrawTargetPlacement : unsigned char +{ + before = 0, + after = 1 +}; } #endif \ No newline at end of file
diff --git a/include/rive/drawable.hpp b/include/rive/drawable.hpp index 1699e71..aa048b1 100644 --- a/include/rive/drawable.hpp +++ b/include/rive/drawable.hpp
@@ -5,12 +5,14 @@ #include "rive/renderer.hpp" #include <vector> -namespace rive { +namespace rive +{ class ClippingShape; class Artboard; class DrawRules; -class Drawable : public DrawableBase { +class Drawable : public DrawableBase +{ friend class Artboard; private: @@ -29,7 +31,8 @@ void addClippingShape(ClippingShape* shape); inline const std::vector<ClippingShape*>& clippingShapes() const { return m_ClippingShapes; } - inline bool isHidden() const { + inline bool isHidden() const + { // For now we have a single drawable flag, when we have more we can // make an actual enum for this. return (drawableFlags() & 0x1) == 0x1;
diff --git a/include/rive/factory.hpp b/include/rive/factory.hpp index f60aeec..fd0232d 100644 --- a/include/rive/factory.hpp +++ b/include/rive/factory.hpp
@@ -16,11 +16,13 @@ #include <stdio.h> #include <cstdint> -namespace rive { +namespace rive +{ class RawPath; -class Factory { +class Factory +{ public: Factory() {} virtual ~Factory() {}
diff --git a/include/rive/file.hpp b/include/rive/file.hpp index 60ed1e6..3f79648 100644 --- a/include/rive/file.hpp +++ b/include/rive/file.hpp
@@ -11,7 +11,8 @@ /// /// Default namespace for Rive Cpp runtime code. /// -namespace rive { +namespace rive +{ class BinaryReader; class RuntimeHeader; class Factory; @@ -19,7 +20,8 @@ /// /// Tracks the success/failure result when importing a Rive file. /// -enum class ImportResult { +enum class ImportResult +{ /// Indicates that a file's been successfully imported. success, /// Indicates that the Rive file is not supported by this runtime. @@ -31,7 +33,8 @@ /// /// A Rive file. /// -class File { +class File +{ public: /// Major version number supported by the runtime. static const int majorVersion = 7;
diff --git a/include/rive/file_asset_resolver.hpp b/include/rive/file_asset_resolver.hpp index 36f58b8..9f8b7bf 100644 --- a/include/rive/file_asset_resolver.hpp +++ b/include/rive/file_asset_resolver.hpp
@@ -4,9 +4,11 @@ #include <cstdint> #include <vector> -namespace rive { +namespace rive +{ class FileAsset; -class FileAssetResolver { +class FileAssetResolver +{ public: virtual ~FileAssetResolver() {}
diff --git a/include/rive/generated/animation/animation_base.hpp b/include/rive/generated/animation/animation_base.hpp index 60fde7c..7a11b3f 100644 --- a/include/rive/generated/animation/animation_base.hpp +++ b/include/rive/generated/animation/animation_base.hpp
@@ -3,8 +3,10 @@ #include <string> #include "rive/core.hpp" #include "rive/core/field_types/core_string_type.hpp" -namespace rive { -class AnimationBase : public Core { +namespace rive +{ +class AnimationBase : public Core +{ protected: typedef Core Super; @@ -13,10 +15,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case AnimationBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case AnimationBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline const std::string& name() const { return m_Name; } - void name(std::string value) { - if (m_Name == value) { + void name(std::string value) + { + if (m_Name == value) + { return; } m_Name = value; @@ -40,9 +48,13 @@ Core* clone() const override; void copy(const AnimationBase& object) { m_Name = object.m_Name; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case namePropertyKey: m_Name = CoreStringType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case namePropertyKey: + m_Name = CoreStringType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/animation/animation_state_base.hpp b/include/rive/generated/animation/animation_state_base.hpp index 8b5c6c7..ee85b58 100644 --- a/include/rive/generated/animation/animation_state_base.hpp +++ b/include/rive/generated/animation/animation_state_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_ANIMATION_STATE_BASE_HPP_ #include "rive/animation/layer_state.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class AnimationStateBase : public LayerState { +namespace rive +{ +class AnimationStateBase : public LayerState +{ protected: typedef LayerState Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case AnimationStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline uint32_t animationId() const { return m_AnimationId; } - void animationId(uint32_t value) { - if (m_AnimationId == value) { + void animationId(uint32_t value) + { + if (m_AnimationId == value) + { return; } m_AnimationId = value; @@ -39,13 +47,16 @@ } Core* clone() const override; - void copy(const AnimationStateBase& object) { + void copy(const AnimationStateBase& object) + { m_AnimationId = object.m_AnimationId; LayerState::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case animationIdPropertyKey: m_AnimationId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/any_state_base.hpp b/include/rive/generated/animation/any_state_base.hpp index dba19c4..d41bd12 100644 --- a/include/rive/generated/animation/any_state_base.hpp +++ b/include/rive/generated/animation/any_state_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_ANY_STATE_BASE_HPP_ #define _RIVE_ANY_STATE_BASE_HPP_ #include "rive/animation/layer_state.hpp" -namespace rive { -class AnyStateBase : public LayerState { +namespace rive +{ +class AnyStateBase : public LayerState +{ protected: typedef LayerState Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case AnyStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/blend_animation_1d_base.hpp b/include/rive/generated/animation/blend_animation_1d_base.hpp index fac5089..c6b147e 100644 --- a/include/rive/generated/animation/blend_animation_1d_base.hpp +++ b/include/rive/generated/animation/blend_animation_1d_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_ANIMATION1_DBASE_HPP_ #include "rive/animation/blend_animation.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class BlendAnimation1DBase : public BlendAnimation { +namespace rive +{ +class BlendAnimation1DBase : public BlendAnimation +{ protected: typedef BlendAnimation Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BlendAnimation1DBase::typeKey: - case BlendAnimationBase::typeKey: return true; - default: return false; + case BlendAnimationBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline float value() const { return m_Value; } - void value(float value) { - if (m_Value == value) { + void value(float value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const BlendAnimation1DBase& object) { + void copy(const BlendAnimation1DBase& object) + { m_Value = object.m_Value; BlendAnimation::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreDoubleType::deserialize(reader); + return true; } return BlendAnimation::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/blend_animation_base.hpp b/include/rive/generated/animation/blend_animation_base.hpp index 4ebb876..5247bcb 100644 --- a/include/rive/generated/animation/blend_animation_base.hpp +++ b/include/rive/generated/animation/blend_animation_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_ANIMATION_BASE_HPP_ #include "rive/core.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class BlendAnimationBase : public Core { +namespace rive +{ +class BlendAnimationBase : public Core +{ protected: typedef Core Super; @@ -12,10 +14,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case BlendAnimationBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case BlendAnimationBase::typeKey: + return true; + default: + return false; } } @@ -28,8 +34,10 @@ public: inline uint32_t animationId() const { return m_AnimationId; } - void animationId(uint32_t value) { - if (m_AnimationId == value) { + void animationId(uint32_t value) + { + if (m_AnimationId == value) + { return; } m_AnimationId = value; @@ -38,8 +46,10 @@ void copy(const BlendAnimationBase& object) { m_AnimationId = object.m_AnimationId; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case animationIdPropertyKey: m_AnimationId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/blend_animation_direct_base.hpp b/include/rive/generated/animation/blend_animation_direct_base.hpp index 5eca77e..74ce655 100644 --- a/include/rive/generated/animation/blend_animation_direct_base.hpp +++ b/include/rive/generated/animation/blend_animation_direct_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_ANIMATION_DIRECT_BASE_HPP_ #include "rive/animation/blend_animation.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class BlendAnimationDirectBase : public BlendAnimation { +namespace rive +{ +class BlendAnimationDirectBase : public BlendAnimation +{ protected: typedef BlendAnimation Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BlendAnimationDirectBase::typeKey: - case BlendAnimationBase::typeKey: return true; - default: return false; + case BlendAnimationBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline uint32_t inputId() const { return m_InputId; } - void inputId(uint32_t value) { - if (m_InputId == value) { + void inputId(uint32_t value) + { + if (m_InputId == value) + { return; } m_InputId = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const BlendAnimationDirectBase& object) { + void copy(const BlendAnimationDirectBase& object) + { m_InputId = object.m_InputId; BlendAnimation::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case inputIdPropertyKey: m_InputId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case inputIdPropertyKey: + m_InputId = CoreUintType::deserialize(reader); + return true; } return BlendAnimation::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/blend_state_1d_base.hpp b/include/rive/generated/animation/blend_state_1d_base.hpp index 91e3ebb..8b1ba7a 100644 --- a/include/rive/generated/animation/blend_state_1d_base.hpp +++ b/include/rive/generated/animation/blend_state_1d_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_STATE1_DBASE_HPP_ #include "rive/animation/blend_state.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class BlendState1DBase : public BlendState { +namespace rive +{ +class BlendState1DBase : public BlendState +{ protected: typedef BlendState Super; @@ -12,13 +14,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BlendState1DBase::typeKey: case BlendStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,8 +37,10 @@ public: inline uint32_t inputId() const { return m_InputId; } - void inputId(uint32_t value) { - if (m_InputId == value) { + void inputId(uint32_t value) + { + if (m_InputId == value) + { return; } m_InputId = value; @@ -40,14 +48,19 @@ } Core* clone() const override; - void copy(const BlendState1DBase& object) { + void copy(const BlendState1DBase& object) + { m_InputId = object.m_InputId; BlendState::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case inputIdPropertyKey: m_InputId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case inputIdPropertyKey: + m_InputId = CoreUintType::deserialize(reader); + return true; } return BlendState::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/blend_state_base.hpp b/include/rive/generated/animation/blend_state_base.hpp index 926841c..31ee3bc 100644 --- a/include/rive/generated/animation/blend_state_base.hpp +++ b/include/rive/generated/animation/blend_state_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_BLEND_STATE_BASE_HPP_ #define _RIVE_BLEND_STATE_BASE_HPP_ #include "rive/animation/layer_state.hpp" -namespace rive { -class BlendStateBase : public LayerState { +namespace rive +{ +class BlendStateBase : public LayerState +{ protected: typedef LayerState Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BlendStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/blend_state_direct_base.hpp b/include/rive/generated/animation/blend_state_direct_base.hpp index 2a15fbb..232a90b 100644 --- a/include/rive/generated/animation/blend_state_direct_base.hpp +++ b/include/rive/generated/animation/blend_state_direct_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_BLEND_STATE_DIRECT_BASE_HPP_ #define _RIVE_BLEND_STATE_DIRECT_BASE_HPP_ #include "rive/animation/blend_state.hpp" -namespace rive { -class BlendStateDirectBase : public BlendState { +namespace rive +{ +class BlendStateDirectBase : public BlendState +{ protected: typedef BlendState Super; @@ -11,13 +13,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BlendStateDirectBase::typeKey: case BlendStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/blend_state_transition_base.hpp b/include/rive/generated/animation/blend_state_transition_base.hpp index 7cd4f44..6494ee8 100644 --- a/include/rive/generated/animation/blend_state_transition_base.hpp +++ b/include/rive/generated/animation/blend_state_transition_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BLEND_STATE_TRANSITION_BASE_HPP_ #include "rive/animation/state_transition.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class BlendStateTransitionBase : public StateTransition { +namespace rive +{ +class BlendStateTransitionBase : public StateTransition +{ protected: typedef StateTransition Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BlendStateTransitionBase::typeKey: case StateTransitionBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline uint32_t exitBlendAnimationId() const { return m_ExitBlendAnimationId; } - void exitBlendAnimationId(uint32_t value) { - if (m_ExitBlendAnimationId == value) { + void exitBlendAnimationId(uint32_t value) + { + if (m_ExitBlendAnimationId == value) + { return; } m_ExitBlendAnimationId = value; @@ -39,13 +47,16 @@ } Core* clone() const override; - void copy(const BlendStateTransitionBase& object) { + void copy(const BlendStateTransitionBase& object) + { m_ExitBlendAnimationId = object.m_ExitBlendAnimationId; StateTransition::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case exitBlendAnimationIdPropertyKey: m_ExitBlendAnimationId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/cubic_interpolator_base.hpp b/include/rive/generated/animation/cubic_interpolator_base.hpp index 15eb866..57abc03 100644 --- a/include/rive/generated/animation/cubic_interpolator_base.hpp +++ b/include/rive/generated/animation/cubic_interpolator_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CUBIC_INTERPOLATOR_BASE_HPP_ #include "rive/core.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class CubicInterpolatorBase : public Core { +namespace rive +{ +class CubicInterpolatorBase : public Core +{ protected: typedef Core Super; @@ -12,10 +14,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case CubicInterpolatorBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case CubicInterpolatorBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline float x1() const { return m_X1; } - void x1(float value) { - if (m_X1 == value) { + void x1(float value) + { + if (m_X1 == value) + { return; } m_X1 = value; @@ -43,8 +51,10 @@ } inline float y1() const { return m_Y1; } - void y1(float value) { - if (m_Y1 == value) { + void y1(float value) + { + if (m_Y1 == value) + { return; } m_Y1 = value; @@ -52,8 +62,10 @@ } inline float x2() const { return m_X2; } - void x2(float value) { - if (m_X2 == value) { + void x2(float value) + { + if (m_X2 == value) + { return; } m_X2 = value; @@ -61,8 +73,10 @@ } inline float y2() const { return m_Y2; } - void y2(float value) { - if (m_Y2 == value) { + void y2(float value) + { + if (m_Y2 == value) + { return; } m_Y2 = value; @@ -70,19 +84,30 @@ } Core* clone() const override; - void copy(const CubicInterpolatorBase& object) { + void copy(const CubicInterpolatorBase& object) + { m_X1 = object.m_X1; m_Y1 = object.m_Y1; m_X2 = object.m_X2; m_Y2 = object.m_Y2; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case x1PropertyKey: m_X1 = CoreDoubleType::deserialize(reader); return true; - case y1PropertyKey: m_Y1 = CoreDoubleType::deserialize(reader); return true; - case x2PropertyKey: m_X2 = CoreDoubleType::deserialize(reader); return true; - case y2PropertyKey: m_Y2 = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case x1PropertyKey: + m_X1 = CoreDoubleType::deserialize(reader); + return true; + case y1PropertyKey: + m_Y1 = CoreDoubleType::deserialize(reader); + return true; + case x2PropertyKey: + m_X2 = CoreDoubleType::deserialize(reader); + return true; + case y2PropertyKey: + m_Y2 = CoreDoubleType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/animation/entry_state_base.hpp b/include/rive/generated/animation/entry_state_base.hpp index 0b2102c..69b913a 100644 --- a/include/rive/generated/animation/entry_state_base.hpp +++ b/include/rive/generated/animation/entry_state_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_ENTRY_STATE_BASE_HPP_ #define _RIVE_ENTRY_STATE_BASE_HPP_ #include "rive/animation/layer_state.hpp" -namespace rive { -class EntryStateBase : public LayerState { +namespace rive +{ +class EntryStateBase : public LayerState +{ protected: typedef LayerState Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case EntryStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/exit_state_base.hpp b/include/rive/generated/animation/exit_state_base.hpp index 32993bb..b69f10f 100644 --- a/include/rive/generated/animation/exit_state_base.hpp +++ b/include/rive/generated/animation/exit_state_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_EXIT_STATE_BASE_HPP_ #define _RIVE_EXIT_STATE_BASE_HPP_ #include "rive/animation/layer_state.hpp" -namespace rive { -class ExitStateBase : public LayerState { +namespace rive +{ +class ExitStateBase : public LayerState +{ protected: typedef LayerState Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ExitStateBase::typeKey: case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/keyed_object_base.hpp b/include/rive/generated/animation/keyed_object_base.hpp index 2b532d9..37d2f51 100644 --- a/include/rive/generated/animation/keyed_object_base.hpp +++ b/include/rive/generated/animation/keyed_object_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEYED_OBJECT_BASE_HPP_ #include "rive/core.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class KeyedObjectBase : public Core { +namespace rive +{ +class KeyedObjectBase : public Core +{ protected: typedef Core Super; @@ -12,10 +14,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case KeyedObjectBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case KeyedObjectBase::typeKey: + return true; + default: + return false; } } @@ -28,8 +34,10 @@ public: inline uint32_t objectId() const { return m_ObjectId; } - void objectId(uint32_t value) { - if (m_ObjectId == value) { + void objectId(uint32_t value) + { + if (m_ObjectId == value) + { return; } m_ObjectId = value; @@ -39,9 +47,13 @@ Core* clone() const override; void copy(const KeyedObjectBase& object) { m_ObjectId = object.m_ObjectId; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case objectIdPropertyKey: m_ObjectId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case objectIdPropertyKey: + m_ObjectId = CoreUintType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/animation/keyed_property_base.hpp b/include/rive/generated/animation/keyed_property_base.hpp index 7bac263..6a111eb 100644 --- a/include/rive/generated/animation/keyed_property_base.hpp +++ b/include/rive/generated/animation/keyed_property_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEYED_PROPERTY_BASE_HPP_ #include "rive/core.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class KeyedPropertyBase : public Core { +namespace rive +{ +class KeyedPropertyBase : public Core +{ protected: typedef Core Super; @@ -12,10 +14,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case KeyedPropertyBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case KeyedPropertyBase::typeKey: + return true; + default: + return false; } } @@ -28,8 +34,10 @@ public: inline uint32_t propertyKey() const { return m_PropertyKey; } - void propertyKey(uint32_t value) { - if (m_PropertyKey == value) { + void propertyKey(uint32_t value) + { + if (m_PropertyKey == value) + { return; } m_PropertyKey = value; @@ -39,8 +47,10 @@ Core* clone() const override; void copy(const KeyedPropertyBase& object) { m_PropertyKey = object.m_PropertyKey; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case propertyKeyPropertyKey: m_PropertyKey = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/keyframe_base.hpp b/include/rive/generated/animation/keyframe_base.hpp index d70fa2b..7570d87 100644 --- a/include/rive/generated/animation/keyframe_base.hpp +++ b/include/rive/generated/animation/keyframe_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_BASE_HPP_ #include "rive/core.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class KeyFrameBase : public Core { +namespace rive +{ +class KeyFrameBase : public Core +{ protected: typedef Core Super; @@ -12,10 +14,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case KeyFrameBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case KeyFrameBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline uint32_t frame() const { return m_Frame; } - void frame(uint32_t value) { - if (m_Frame == value) { + void frame(uint32_t value) + { + if (m_Frame == value) + { return; } m_Frame = value; @@ -41,8 +49,10 @@ } inline uint32_t interpolationType() const { return m_InterpolationType; } - void interpolationType(uint32_t value) { - if (m_InterpolationType == value) { + void interpolationType(uint32_t value) + { + if (m_InterpolationType == value) + { return; } m_InterpolationType = value; @@ -50,23 +60,30 @@ } inline uint32_t interpolatorId() const { return m_InterpolatorId; } - void interpolatorId(uint32_t value) { - if (m_InterpolatorId == value) { + void interpolatorId(uint32_t value) + { + if (m_InterpolatorId == value) + { return; } m_InterpolatorId = value; interpolatorIdChanged(); } - void copy(const KeyFrameBase& object) { + void copy(const KeyFrameBase& object) + { m_Frame = object.m_Frame; m_InterpolationType = object.m_InterpolationType; m_InterpolatorId = object.m_InterpolatorId; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case framePropertyKey: m_Frame = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case framePropertyKey: + m_Frame = CoreUintType::deserialize(reader); + return true; case interpolationTypePropertyKey: m_InterpolationType = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/keyframe_bool_base.hpp b/include/rive/generated/animation/keyframe_bool_base.hpp index 3194f87..c20a703 100644 --- a/include/rive/generated/animation/keyframe_bool_base.hpp +++ b/include/rive/generated/animation/keyframe_bool_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_BOOL_BASE_HPP_ #include "rive/animation/keyframe.hpp" #include "rive/core/field_types/core_bool_type.hpp" -namespace rive { -class KeyFrameBoolBase : public KeyFrame { +namespace rive +{ +class KeyFrameBoolBase : public KeyFrame +{ protected: typedef KeyFrame Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case KeyFrameBoolBase::typeKey: - case KeyFrameBase::typeKey: return true; - default: return false; + case KeyFrameBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline bool value() const { return m_Value; } - void value(bool value) { - if (m_Value == value) { + void value(bool value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const KeyFrameBoolBase& object) { + void copy(const KeyFrameBoolBase& object) + { m_Value = object.m_Value; KeyFrame::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreBoolType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreBoolType::deserialize(reader); + return true; } return KeyFrame::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/keyframe_color_base.hpp b/include/rive/generated/animation/keyframe_color_base.hpp index 03d6d62..16d80fe 100644 --- a/include/rive/generated/animation/keyframe_color_base.hpp +++ b/include/rive/generated/animation/keyframe_color_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_COLOR_BASE_HPP_ #include "rive/animation/keyframe.hpp" #include "rive/core/field_types/core_color_type.hpp" -namespace rive { -class KeyFrameColorBase : public KeyFrame { +namespace rive +{ +class KeyFrameColorBase : public KeyFrame +{ protected: typedef KeyFrame Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case KeyFrameColorBase::typeKey: - case KeyFrameBase::typeKey: return true; - default: return false; + case KeyFrameBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline int value() const { return m_Value; } - void value(int value) { - if (m_Value == value) { + void value(int value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const KeyFrameColorBase& object) { + void copy(const KeyFrameColorBase& object) + { m_Value = object.m_Value; KeyFrame::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreColorType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreColorType::deserialize(reader); + return true; } return KeyFrame::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/keyframe_double_base.hpp b/include/rive/generated/animation/keyframe_double_base.hpp index d1253c6..df52746 100644 --- a/include/rive/generated/animation/keyframe_double_base.hpp +++ b/include/rive/generated/animation/keyframe_double_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_DOUBLE_BASE_HPP_ #include "rive/animation/keyframe.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class KeyFrameDoubleBase : public KeyFrame { +namespace rive +{ +class KeyFrameDoubleBase : public KeyFrame +{ protected: typedef KeyFrame Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case KeyFrameDoubleBase::typeKey: - case KeyFrameBase::typeKey: return true; - default: return false; + case KeyFrameBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline float value() const { return m_Value; } - void value(float value) { - if (m_Value == value) { + void value(float value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const KeyFrameDoubleBase& object) { + void copy(const KeyFrameDoubleBase& object) + { m_Value = object.m_Value; KeyFrame::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreDoubleType::deserialize(reader); + return true; } return KeyFrame::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/keyframe_id_base.hpp b/include/rive/generated/animation/keyframe_id_base.hpp index 76f8361..086f5c9 100644 --- a/include/rive/generated/animation/keyframe_id_base.hpp +++ b/include/rive/generated/animation/keyframe_id_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_KEY_FRAME_ID_BASE_HPP_ #include "rive/animation/keyframe.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class KeyFrameIdBase : public KeyFrame { +namespace rive +{ +class KeyFrameIdBase : public KeyFrame +{ protected: typedef KeyFrame Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case KeyFrameIdBase::typeKey: - case KeyFrameBase::typeKey: return true; - default: return false; + case KeyFrameBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline uint32_t value() const { return m_Value; } - void value(uint32_t value) { - if (m_Value == value) { + void value(uint32_t value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const KeyFrameIdBase& object) { + void copy(const KeyFrameIdBase& object) + { m_Value = object.m_Value; KeyFrame::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreUintType::deserialize(reader); + return true; } return KeyFrame::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/layer_state_base.hpp b/include/rive/generated/animation/layer_state_base.hpp index ae28eb2..a14df6c 100644 --- a/include/rive/generated/animation/layer_state_base.hpp +++ b/include/rive/generated/animation/layer_state_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_LAYER_STATE_BASE_HPP_ #define _RIVE_LAYER_STATE_BASE_HPP_ #include "rive/animation/state_machine_layer_component.hpp" -namespace rive { -class LayerStateBase : public StateMachineLayerComponent { +namespace rive +{ +class LayerStateBase : public StateMachineLayerComponent +{ protected: typedef StateMachineLayerComponent Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case LayerStateBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/linear_animation_base.hpp b/include/rive/generated/animation/linear_animation_base.hpp index 674d251..8ff3dcc 100644 --- a/include/rive/generated/animation/linear_animation_base.hpp +++ b/include/rive/generated/animation/linear_animation_base.hpp
@@ -4,8 +4,10 @@ #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class LinearAnimationBase : public Animation { +namespace rive +{ +class LinearAnimationBase : public Animation +{ protected: typedef Animation Super; @@ -14,11 +16,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case LinearAnimationBase::typeKey: - case AnimationBase::typeKey: return true; - default: return false; + case AnimationBase::typeKey: + return true; + default: + return false; } } @@ -43,8 +49,10 @@ public: inline uint32_t fps() const { return m_Fps; } - void fps(uint32_t value) { - if (m_Fps == value) { + void fps(uint32_t value) + { + if (m_Fps == value) + { return; } m_Fps = value; @@ -52,8 +60,10 @@ } inline uint32_t duration() const { return m_Duration; } - void duration(uint32_t value) { - if (m_Duration == value) { + void duration(uint32_t value) + { + if (m_Duration == value) + { return; } m_Duration = value; @@ -61,8 +71,10 @@ } inline float speed() const { return m_Speed; } - void speed(float value) { - if (m_Speed == value) { + void speed(float value) + { + if (m_Speed == value) + { return; } m_Speed = value; @@ -70,8 +82,10 @@ } inline uint32_t loopValue() const { return m_LoopValue; } - void loopValue(uint32_t value) { - if (m_LoopValue == value) { + void loopValue(uint32_t value) + { + if (m_LoopValue == value) + { return; } m_LoopValue = value; @@ -79,8 +93,10 @@ } inline uint32_t workStart() const { return m_WorkStart; } - void workStart(uint32_t value) { - if (m_WorkStart == value) { + void workStart(uint32_t value) + { + if (m_WorkStart == value) + { return; } m_WorkStart = value; @@ -88,8 +104,10 @@ } inline uint32_t workEnd() const { return m_WorkEnd; } - void workEnd(uint32_t value) { - if (m_WorkEnd == value) { + void workEnd(uint32_t value) + { + if (m_WorkEnd == value) + { return; } m_WorkEnd = value; @@ -97,8 +115,10 @@ } inline bool enableWorkArea() const { return m_EnableWorkArea; } - void enableWorkArea(bool value) { - if (m_EnableWorkArea == value) { + void enableWorkArea(bool value) + { + if (m_EnableWorkArea == value) + { return; } m_EnableWorkArea = value; @@ -106,7 +126,8 @@ } Core* clone() const override; - void copy(const LinearAnimationBase& object) { + void copy(const LinearAnimationBase& object) + { m_Fps = object.m_Fps; m_Duration = object.m_Duration; m_Speed = object.m_Speed; @@ -117,14 +138,28 @@ Animation::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case fpsPropertyKey: m_Fps = CoreUintType::deserialize(reader); return true; - case durationPropertyKey: m_Duration = CoreUintType::deserialize(reader); return true; - case speedPropertyKey: m_Speed = CoreDoubleType::deserialize(reader); return true; - case loopValuePropertyKey: m_LoopValue = CoreUintType::deserialize(reader); return true; - case workStartPropertyKey: m_WorkStart = CoreUintType::deserialize(reader); return true; - case workEndPropertyKey: m_WorkEnd = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case fpsPropertyKey: + m_Fps = CoreUintType::deserialize(reader); + return true; + case durationPropertyKey: + m_Duration = CoreUintType::deserialize(reader); + return true; + case speedPropertyKey: + m_Speed = CoreDoubleType::deserialize(reader); + return true; + case loopValuePropertyKey: + m_LoopValue = CoreUintType::deserialize(reader); + return true; + case workStartPropertyKey: + m_WorkStart = CoreUintType::deserialize(reader); + return true; + case workEndPropertyKey: + m_WorkEnd = CoreUintType::deserialize(reader); + return true; case enableWorkAreaPropertyKey: m_EnableWorkArea = CoreBoolType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/listener_action_base.hpp b/include/rive/generated/animation/listener_action_base.hpp index c06aabb..d10a5f1 100644 --- a/include/rive/generated/animation/listener_action_base.hpp +++ b/include/rive/generated/animation/listener_action_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_LISTENER_ACTION_BASE_HPP_ #define _RIVE_LISTENER_ACTION_BASE_HPP_ #include "rive/core.hpp" -namespace rive { -class ListenerActionBase : public Core { +namespace rive +{ +class ListenerActionBase : public Core +{ protected: typedef Core Super; @@ -11,10 +13,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case ListenerActionBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case ListenerActionBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/listener_align_target_base.hpp b/include/rive/generated/animation/listener_align_target_base.hpp index bcdd2e5..79c0cfc 100644 --- a/include/rive/generated/animation/listener_align_target_base.hpp +++ b/include/rive/generated/animation/listener_align_target_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_ALIGN_TARGET_BASE_HPP_ #include "rive/animation/listener_action.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class ListenerAlignTargetBase : public ListenerAction { +namespace rive +{ +class ListenerAlignTargetBase : public ListenerAction +{ protected: typedef ListenerAction Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ListenerAlignTargetBase::typeKey: - case ListenerActionBase::typeKey: return true; - default: return false; + case ListenerActionBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline uint32_t targetId() const { return m_TargetId; } - void targetId(uint32_t value) { - if (m_TargetId == value) { + void targetId(uint32_t value) + { + if (m_TargetId == value) + { return; } m_TargetId = value; @@ -38,14 +46,19 @@ } Core* clone() const override; - void copy(const ListenerAlignTargetBase& object) { + void copy(const ListenerAlignTargetBase& object) + { m_TargetId = object.m_TargetId; ListenerAction::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case targetIdPropertyKey: m_TargetId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case targetIdPropertyKey: + m_TargetId = CoreUintType::deserialize(reader); + return true; } return ListenerAction::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/listener_bool_change_base.hpp b/include/rive/generated/animation/listener_bool_change_base.hpp index 9caad20..c7260b9 100644 --- a/include/rive/generated/animation/listener_bool_change_base.hpp +++ b/include/rive/generated/animation/listener_bool_change_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_BOOL_CHANGE_BASE_HPP_ #include "rive/animation/listener_input_change.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class ListenerBoolChangeBase : public ListenerInputChange { +namespace rive +{ +class ListenerBoolChangeBase : public ListenerInputChange +{ protected: typedef ListenerInputChange Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ListenerBoolChangeBase::typeKey: case ListenerInputChangeBase::typeKey: - case ListenerActionBase::typeKey: return true; - default: return false; + case ListenerActionBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline uint32_t value() const { return m_Value; } - void value(uint32_t value) { - if (m_Value == value) { + void value(uint32_t value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -39,14 +47,19 @@ } Core* clone() const override; - void copy(const ListenerBoolChangeBase& object) { + void copy(const ListenerBoolChangeBase& object) + { m_Value = object.m_Value; ListenerInputChange::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreUintType::deserialize(reader); + return true; } return ListenerInputChange::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/listener_input_change_base.hpp b/include/rive/generated/animation/listener_input_change_base.hpp index 52cada6..f0c982a 100644 --- a/include/rive/generated/animation/listener_input_change_base.hpp +++ b/include/rive/generated/animation/listener_input_change_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_INPUT_CHANGE_BASE_HPP_ #include "rive/animation/listener_action.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class ListenerInputChangeBase : public ListenerAction { +namespace rive +{ +class ListenerInputChangeBase : public ListenerAction +{ protected: typedef ListenerAction Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ListenerInputChangeBase::typeKey: - case ListenerActionBase::typeKey: return true; - default: return false; + case ListenerActionBase::typeKey: + return true; + default: + return false; } } @@ -29,22 +35,29 @@ public: inline uint32_t inputId() const { return m_InputId; } - void inputId(uint32_t value) { - if (m_InputId == value) { + void inputId(uint32_t value) + { + if (m_InputId == value) + { return; } m_InputId = value; inputIdChanged(); } - void copy(const ListenerInputChangeBase& object) { + void copy(const ListenerInputChangeBase& object) + { m_InputId = object.m_InputId; ListenerAction::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case inputIdPropertyKey: m_InputId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case inputIdPropertyKey: + m_InputId = CoreUintType::deserialize(reader); + return true; } return ListenerAction::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/listener_number_change_base.hpp b/include/rive/generated/animation/listener_number_change_base.hpp index 0fecff4..b75949f 100644 --- a/include/rive/generated/animation/listener_number_change_base.hpp +++ b/include/rive/generated/animation/listener_number_change_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LISTENER_NUMBER_CHANGE_BASE_HPP_ #include "rive/animation/listener_input_change.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class ListenerNumberChangeBase : public ListenerInputChange { +namespace rive +{ +class ListenerNumberChangeBase : public ListenerInputChange +{ protected: typedef ListenerInputChange Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ListenerNumberChangeBase::typeKey: case ListenerInputChangeBase::typeKey: - case ListenerActionBase::typeKey: return true; - default: return false; + case ListenerActionBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline float value() const { return m_Value; } - void value(float value) { - if (m_Value == value) { + void value(float value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -39,14 +47,19 @@ } Core* clone() const override; - void copy(const ListenerNumberChangeBase& object) { + void copy(const ListenerNumberChangeBase& object) + { m_Value = object.m_Value; ListenerInputChange::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreDoubleType::deserialize(reader); + return true; } return ListenerInputChange::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/listener_trigger_change_base.hpp b/include/rive/generated/animation/listener_trigger_change_base.hpp index f4af15e..a8306db 100644 --- a/include/rive/generated/animation/listener_trigger_change_base.hpp +++ b/include/rive/generated/animation/listener_trigger_change_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_LISTENER_TRIGGER_CHANGE_BASE_HPP_ #define _RIVE_LISTENER_TRIGGER_CHANGE_BASE_HPP_ #include "rive/animation/listener_input_change.hpp" -namespace rive { -class ListenerTriggerChangeBase : public ListenerInputChange { +namespace rive +{ +class ListenerTriggerChangeBase : public ListenerInputChange +{ protected: typedef ListenerInputChange Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ListenerTriggerChangeBase::typeKey: case ListenerInputChangeBase::typeKey: - case ListenerActionBase::typeKey: return true; - default: return false; + case ListenerActionBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/nested_bool_base.hpp b/include/rive/generated/animation/nested_bool_base.hpp index 6478300..d756d95 100644 --- a/include/rive/generated/animation/nested_bool_base.hpp +++ b/include/rive/generated/animation/nested_bool_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_BOOL_BASE_HPP_ #include "rive/animation/nested_input.hpp" #include "rive/core/field_types/core_bool_type.hpp" -namespace rive { -class NestedBoolBase : public NestedInput { +namespace rive +{ +class NestedBoolBase : public NestedInput +{ protected: typedef NestedInput Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedBoolBase::typeKey: case NestedInputBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline bool nestedValue() const { return m_NestedValue; } - void nestedValue(bool value) { - if (m_NestedValue == value) { + void nestedValue(bool value) + { + if (m_NestedValue == value) + { return; } m_NestedValue = value; @@ -39,13 +47,16 @@ } Core* clone() const override; - void copy(const NestedBoolBase& object) { + void copy(const NestedBoolBase& object) + { m_NestedValue = object.m_NestedValue; NestedInput::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case nestedValuePropertyKey: m_NestedValue = CoreBoolType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/nested_input_base.hpp b/include/rive/generated/animation/nested_input_base.hpp index 54b2f73..40cab82 100644 --- a/include/rive/generated/animation/nested_input_base.hpp +++ b/include/rive/generated/animation/nested_input_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_INPUT_BASE_HPP_ #include "rive/component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class NestedInputBase : public Component { +namespace rive +{ +class NestedInputBase : public Component +{ protected: typedef Component Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedInputBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -29,22 +35,29 @@ public: inline uint32_t inputId() const { return m_InputId; } - void inputId(uint32_t value) { - if (m_InputId == value) { + void inputId(uint32_t value) + { + if (m_InputId == value) + { return; } m_InputId = value; inputIdChanged(); } - void copy(const NestedInputBase& object) { + void copy(const NestedInputBase& object) + { m_InputId = object.m_InputId; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case inputIdPropertyKey: m_InputId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case inputIdPropertyKey: + m_InputId = CoreUintType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/nested_linear_animation_base.hpp b/include/rive/generated/animation/nested_linear_animation_base.hpp index 540afad..e3875e4 100644 --- a/include/rive/generated/animation/nested_linear_animation_base.hpp +++ b/include/rive/generated/animation/nested_linear_animation_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_LINEAR_ANIMATION_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/nested_animation.hpp" -namespace rive { -class NestedLinearAnimationBase : public NestedAnimation { +namespace rive +{ +class NestedLinearAnimationBase : public NestedAnimation +{ protected: typedef NestedAnimation Super; @@ -12,13 +14,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedLinearAnimationBase::typeKey: case NestedAnimationBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,22 +37,29 @@ public: inline float mix() const { return m_Mix; } - void mix(float value) { - if (m_Mix == value) { + void mix(float value) + { + if (m_Mix == value) + { return; } m_Mix = value; mixChanged(); } - void copy(const NestedLinearAnimationBase& object) { + void copy(const NestedLinearAnimationBase& object) + { m_Mix = object.m_Mix; NestedAnimation::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case mixPropertyKey: m_Mix = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case mixPropertyKey: + m_Mix = CoreDoubleType::deserialize(reader); + return true; } return NestedAnimation::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/nested_number_base.hpp b/include/rive/generated/animation/nested_number_base.hpp index 051b375..e50ecac 100644 --- a/include/rive/generated/animation/nested_number_base.hpp +++ b/include/rive/generated/animation/nested_number_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_NUMBER_BASE_HPP_ #include "rive/animation/nested_input.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class NestedNumberBase : public NestedInput { +namespace rive +{ +class NestedNumberBase : public NestedInput +{ protected: typedef NestedInput Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedNumberBase::typeKey: case NestedInputBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline float nestedValue() const { return m_NestedValue; } - void nestedValue(float value) { - if (m_NestedValue == value) { + void nestedValue(float value) + { + if (m_NestedValue == value) + { return; } m_NestedValue = value; @@ -39,13 +47,16 @@ } Core* clone() const override; - void copy(const NestedNumberBase& object) { + void copy(const NestedNumberBase& object) + { m_NestedValue = object.m_NestedValue; NestedInput::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case nestedValuePropertyKey: m_NestedValue = CoreDoubleType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/nested_remap_animation_base.hpp b/include/rive/generated/animation/nested_remap_animation_base.hpp index 06ce59e..5050aff 100644 --- a/include/rive/generated/animation/nested_remap_animation_base.hpp +++ b/include/rive/generated/animation/nested_remap_animation_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_REMAP_ANIMATION_BASE_HPP_ #include "rive/animation/nested_linear_animation.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class NestedRemapAnimationBase : public NestedLinearAnimation { +namespace rive +{ +class NestedRemapAnimationBase : public NestedLinearAnimation +{ protected: typedef NestedLinearAnimation Super; @@ -12,14 +14,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedRemapAnimationBase::typeKey: case NestedLinearAnimationBase::typeKey: case NestedAnimationBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline float time() const { return m_Time; } - void time(float value) { - if (m_Time == value) { + void time(float value) + { + if (m_Time == value) + { return; } m_Time = value; @@ -41,14 +49,19 @@ } Core* clone() const override; - void copy(const NestedRemapAnimationBase& object) { + void copy(const NestedRemapAnimationBase& object) + { m_Time = object.m_Time; NestedLinearAnimation::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case timePropertyKey: m_Time = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case timePropertyKey: + m_Time = CoreDoubleType::deserialize(reader); + return true; } return NestedLinearAnimation::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/nested_simple_animation_base.hpp b/include/rive/generated/animation/nested_simple_animation_base.hpp index b9896a2..e9306d9 100644 --- a/include/rive/generated/animation/nested_simple_animation_base.hpp +++ b/include/rive/generated/animation/nested_simple_animation_base.hpp
@@ -3,8 +3,10 @@ #include "rive/animation/nested_linear_animation.hpp" #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class NestedSimpleAnimationBase : public NestedLinearAnimation { +namespace rive +{ +class NestedSimpleAnimationBase : public NestedLinearAnimation +{ protected: typedef NestedLinearAnimation Super; @@ -13,14 +15,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedSimpleAnimationBase::typeKey: case NestedLinearAnimationBase::typeKey: case NestedAnimationBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -35,8 +41,10 @@ public: inline float speed() const { return m_Speed; } - void speed(float value) { - if (m_Speed == value) { + void speed(float value) + { + if (m_Speed == value) + { return; } m_Speed = value; @@ -44,8 +52,10 @@ } inline bool isPlaying() const { return m_IsPlaying; } - void isPlaying(bool value) { - if (m_IsPlaying == value) { + void isPlaying(bool value) + { + if (m_IsPlaying == value) + { return; } m_IsPlaying = value; @@ -53,16 +63,23 @@ } Core* clone() const override; - void copy(const NestedSimpleAnimationBase& object) { + void copy(const NestedSimpleAnimationBase& object) + { m_Speed = object.m_Speed; m_IsPlaying = object.m_IsPlaying; NestedLinearAnimation::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case speedPropertyKey: m_Speed = CoreDoubleType::deserialize(reader); return true; - case isPlayingPropertyKey: m_IsPlaying = CoreBoolType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case speedPropertyKey: + m_Speed = CoreDoubleType::deserialize(reader); + return true; + case isPlayingPropertyKey: + m_IsPlaying = CoreBoolType::deserialize(reader); + return true; } return NestedLinearAnimation::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/nested_state_machine_base.hpp b/include/rive/generated/animation/nested_state_machine_base.hpp index 5ab98fd..6a72d26 100644 --- a/include/rive/generated/animation/nested_state_machine_base.hpp +++ b/include/rive/generated/animation/nested_state_machine_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_NESTED_STATE_MACHINE_BASE_HPP_ #define _RIVE_NESTED_STATE_MACHINE_BASE_HPP_ #include "rive/nested_animation.hpp" -namespace rive { -class NestedStateMachineBase : public NestedAnimation { +namespace rive +{ +class NestedStateMachineBase : public NestedAnimation +{ protected: typedef NestedAnimation Super; @@ -11,13 +13,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedStateMachineBase::typeKey: case NestedAnimationBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/nested_trigger_base.hpp b/include/rive/generated/animation/nested_trigger_base.hpp index 761573e..c489415 100644 --- a/include/rive/generated/animation/nested_trigger_base.hpp +++ b/include/rive/generated/animation/nested_trigger_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_NESTED_TRIGGER_BASE_HPP_ #define _RIVE_NESTED_TRIGGER_BASE_HPP_ #include "rive/animation/nested_input.hpp" -namespace rive { -class NestedTriggerBase : public NestedInput { +namespace rive +{ +class NestedTriggerBase : public NestedInput +{ protected: typedef NestedInput Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedTriggerBase::typeKey: case NestedInputBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/state_machine_base.hpp b/include/rive/generated/animation/state_machine_base.hpp index 49f67ac..8b72ddb 100644 --- a/include/rive/generated/animation/state_machine_base.hpp +++ b/include/rive/generated/animation/state_machine_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STATE_MACHINE_BASE_HPP_ #define _RIVE_STATE_MACHINE_BASE_HPP_ #include "rive/animation/animation.hpp" -namespace rive { -class StateMachineBase : public Animation { +namespace rive +{ +class StateMachineBase : public Animation +{ protected: typedef Animation Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineBase::typeKey: - case AnimationBase::typeKey: return true; - default: return false; + case AnimationBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/state_machine_bool_base.hpp b/include/rive/generated/animation/state_machine_bool_base.hpp index a2655b5..2e08c1e 100644 --- a/include/rive/generated/animation/state_machine_bool_base.hpp +++ b/include/rive/generated/animation/state_machine_bool_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_BOOL_BASE_HPP_ #include "rive/animation/state_machine_input.hpp" #include "rive/core/field_types/core_bool_type.hpp" -namespace rive { -class StateMachineBoolBase : public StateMachineInput { +namespace rive +{ +class StateMachineBoolBase : public StateMachineInput +{ protected: typedef StateMachineInput Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineBoolBase::typeKey: case StateMachineInputBase::typeKey: - case StateMachineComponentBase::typeKey: return true; - default: return false; + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline bool value() const { return m_Value; } - void value(bool value) { - if (m_Value == value) { + void value(bool value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -39,14 +47,19 @@ } Core* clone() const override; - void copy(const StateMachineBoolBase& object) { + void copy(const StateMachineBoolBase& object) + { m_Value = object.m_Value; StateMachineInput::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreBoolType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreBoolType::deserialize(reader); + return true; } return StateMachineInput::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/state_machine_component_base.hpp b/include/rive/generated/animation/state_machine_component_base.hpp index b047698..eea14a5 100644 --- a/include/rive/generated/animation/state_machine_component_base.hpp +++ b/include/rive/generated/animation/state_machine_component_base.hpp
@@ -3,8 +3,10 @@ #include <string> #include "rive/core.hpp" #include "rive/core/field_types/core_string_type.hpp" -namespace rive { -class StateMachineComponentBase : public Core { +namespace rive +{ +class StateMachineComponentBase : public Core +{ protected: typedef Core Super; @@ -13,10 +15,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case StateMachineComponentBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline const std::string& name() const { return m_Name; } - void name(std::string value) { - if (m_Name == value) { + void name(std::string value) + { + if (m_Name == value) + { return; } m_Name = value; @@ -39,9 +47,13 @@ void copy(const StateMachineComponentBase& object) { m_Name = object.m_Name; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case namePropertyKey: m_Name = CoreStringType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case namePropertyKey: + m_Name = CoreStringType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/animation/state_machine_input_base.hpp b/include/rive/generated/animation/state_machine_input_base.hpp index 44e93a9..c78f9f1 100644 --- a/include/rive/generated/animation/state_machine_input_base.hpp +++ b/include/rive/generated/animation/state_machine_input_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STATE_MACHINE_INPUT_BASE_HPP_ #define _RIVE_STATE_MACHINE_INPUT_BASE_HPP_ #include "rive/animation/state_machine_component.hpp" -namespace rive { -class StateMachineInputBase : public StateMachineComponent { +namespace rive +{ +class StateMachineInputBase : public StateMachineComponent +{ protected: typedef StateMachineComponent Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineInputBase::typeKey: - case StateMachineComponentBase::typeKey: return true; - default: return false; + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/state_machine_layer_base.hpp b/include/rive/generated/animation/state_machine_layer_base.hpp index 85685b5..0545cd8 100644 --- a/include/rive/generated/animation/state_machine_layer_base.hpp +++ b/include/rive/generated/animation/state_machine_layer_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STATE_MACHINE_LAYER_BASE_HPP_ #define _RIVE_STATE_MACHINE_LAYER_BASE_HPP_ #include "rive/animation/state_machine_component.hpp" -namespace rive { -class StateMachineLayerBase : public StateMachineComponent { +namespace rive +{ +class StateMachineLayerBase : public StateMachineComponent +{ protected: typedef StateMachineComponent Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineLayerBase::typeKey: - case StateMachineComponentBase::typeKey: return true; - default: return false; + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/state_machine_layer_component_base.hpp b/include/rive/generated/animation/state_machine_layer_component_base.hpp index 8915d7a..f99f201 100644 --- a/include/rive/generated/animation/state_machine_layer_component_base.hpp +++ b/include/rive/generated/animation/state_machine_layer_component_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STATE_MACHINE_LAYER_COMPONENT_BASE_HPP_ #define _RIVE_STATE_MACHINE_LAYER_COMPONENT_BASE_HPP_ #include "rive/core.hpp" -namespace rive { -class StateMachineLayerComponentBase : public Core { +namespace rive +{ +class StateMachineLayerComponentBase : public Core +{ protected: typedef Core Super; @@ -11,10 +13,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/state_machine_listener_base.hpp b/include/rive/generated/animation/state_machine_listener_base.hpp index 79ad675..d4373f4 100644 --- a/include/rive/generated/animation/state_machine_listener_base.hpp +++ b/include/rive/generated/animation/state_machine_listener_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_LISTENER_BASE_HPP_ #include "rive/animation/state_machine_component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class StateMachineListenerBase : public StateMachineComponent { +namespace rive +{ +class StateMachineListenerBase : public StateMachineComponent +{ protected: typedef StateMachineComponent Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineListenerBase::typeKey: - case StateMachineComponentBase::typeKey: return true; - default: return false; + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,8 +37,10 @@ public: inline uint32_t targetId() const { return m_TargetId; } - void targetId(uint32_t value) { - if (m_TargetId == value) { + void targetId(uint32_t value) + { + if (m_TargetId == value) + { return; } m_TargetId = value; @@ -40,8 +48,10 @@ } inline uint32_t listenerTypeValue() const { return m_ListenerTypeValue; } - void listenerTypeValue(uint32_t value) { - if (m_ListenerTypeValue == value) { + void listenerTypeValue(uint32_t value) + { + if (m_ListenerTypeValue == value) + { return; } m_ListenerTypeValue = value; @@ -49,15 +59,20 @@ } Core* clone() const override; - void copy(const StateMachineListenerBase& object) { + void copy(const StateMachineListenerBase& object) + { m_TargetId = object.m_TargetId; m_ListenerTypeValue = object.m_ListenerTypeValue; StateMachineComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case targetIdPropertyKey: m_TargetId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case targetIdPropertyKey: + m_TargetId = CoreUintType::deserialize(reader); + return true; case listenerTypeValuePropertyKey: m_ListenerTypeValue = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/animation/state_machine_number_base.hpp b/include/rive/generated/animation/state_machine_number_base.hpp index 46e1cd6..73d605f 100644 --- a/include/rive/generated/animation/state_machine_number_base.hpp +++ b/include/rive/generated/animation/state_machine_number_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_MACHINE_NUMBER_BASE_HPP_ #include "rive/animation/state_machine_input.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class StateMachineNumberBase : public StateMachineInput { +namespace rive +{ +class StateMachineNumberBase : public StateMachineInput +{ protected: typedef StateMachineInput Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineNumberBase::typeKey: case StateMachineInputBase::typeKey: - case StateMachineComponentBase::typeKey: return true; - default: return false; + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline float value() const { return m_Value; } - void value(float value) { - if (m_Value == value) { + void value(float value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -39,14 +47,19 @@ } Core* clone() const override; - void copy(const StateMachineNumberBase& object) { + void copy(const StateMachineNumberBase& object) + { m_Value = object.m_Value; StateMachineInput::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreDoubleType::deserialize(reader); + return true; } return StateMachineInput::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/state_machine_trigger_base.hpp b/include/rive/generated/animation/state_machine_trigger_base.hpp index 5c34eb5..871d10e 100644 --- a/include/rive/generated/animation/state_machine_trigger_base.hpp +++ b/include/rive/generated/animation/state_machine_trigger_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STATE_MACHINE_TRIGGER_BASE_HPP_ #define _RIVE_STATE_MACHINE_TRIGGER_BASE_HPP_ #include "rive/animation/state_machine_input.hpp" -namespace rive { -class StateMachineTriggerBase : public StateMachineInput { +namespace rive +{ +class StateMachineTriggerBase : public StateMachineInput +{ protected: typedef StateMachineInput Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateMachineTriggerBase::typeKey: case StateMachineInputBase::typeKey: - case StateMachineComponentBase::typeKey: return true; - default: return false; + case StateMachineComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/state_transition_base.hpp b/include/rive/generated/animation/state_transition_base.hpp index d822d2c..d50874a 100644 --- a/include/rive/generated/animation/state_transition_base.hpp +++ b/include/rive/generated/animation/state_transition_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STATE_TRANSITION_BASE_HPP_ #include "rive/animation/state_machine_layer_component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class StateTransitionBase : public StateMachineLayerComponent { +namespace rive +{ +class StateTransitionBase : public StateMachineLayerComponent +{ protected: typedef StateMachineLayerComponent Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StateTransitionBase::typeKey: - case StateMachineLayerComponentBase::typeKey: return true; - default: return false; + case StateMachineLayerComponentBase::typeKey: + return true; + default: + return false; } } @@ -35,8 +41,10 @@ public: inline uint32_t stateToId() const { return m_StateToId; } - void stateToId(uint32_t value) { - if (m_StateToId == value) { + void stateToId(uint32_t value) + { + if (m_StateToId == value) + { return; } m_StateToId = value; @@ -44,8 +52,10 @@ } inline uint32_t flags() const { return m_Flags; } - void flags(uint32_t value) { - if (m_Flags == value) { + void flags(uint32_t value) + { + if (m_Flags == value) + { return; } m_Flags = value; @@ -53,8 +63,10 @@ } inline uint32_t duration() const { return m_Duration; } - void duration(uint32_t value) { - if (m_Duration == value) { + void duration(uint32_t value) + { + if (m_Duration == value) + { return; } m_Duration = value; @@ -62,8 +74,10 @@ } inline uint32_t exitTime() const { return m_ExitTime; } - void exitTime(uint32_t value) { - if (m_ExitTime == value) { + void exitTime(uint32_t value) + { + if (m_ExitTime == value) + { return; } m_ExitTime = value; @@ -71,7 +85,8 @@ } Core* clone() const override; - void copy(const StateTransitionBase& object) { + void copy(const StateTransitionBase& object) + { m_StateToId = object.m_StateToId; m_Flags = object.m_Flags; m_Duration = object.m_Duration; @@ -79,12 +94,22 @@ StateMachineLayerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case stateToIdPropertyKey: m_StateToId = CoreUintType::deserialize(reader); return true; - case flagsPropertyKey: m_Flags = CoreUintType::deserialize(reader); return true; - case durationPropertyKey: m_Duration = CoreUintType::deserialize(reader); return true; - case exitTimePropertyKey: m_ExitTime = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case stateToIdPropertyKey: + m_StateToId = CoreUintType::deserialize(reader); + return true; + case flagsPropertyKey: + m_Flags = CoreUintType::deserialize(reader); + return true; + case durationPropertyKey: + m_Duration = CoreUintType::deserialize(reader); + return true; + case exitTimePropertyKey: + m_ExitTime = CoreUintType::deserialize(reader); + return true; } return StateMachineLayerComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/transition_bool_condition_base.hpp b/include/rive/generated/animation/transition_bool_condition_base.hpp index 63447ca..8567f37 100644 --- a/include/rive/generated/animation/transition_bool_condition_base.hpp +++ b/include/rive/generated/animation/transition_bool_condition_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_TRANSITION_BOOL_CONDITION_BASE_HPP_ #define _RIVE_TRANSITION_BOOL_CONDITION_BASE_HPP_ #include "rive/animation/transition_value_condition.hpp" -namespace rive { -class TransitionBoolConditionBase : public TransitionValueCondition { +namespace rive +{ +class TransitionBoolConditionBase : public TransitionValueCondition +{ protected: typedef TransitionValueCondition Super; @@ -11,12 +13,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransitionBoolConditionBase::typeKey: case TransitionValueConditionBase::typeKey: - case TransitionConditionBase::typeKey: return true; - default: return false; + case TransitionConditionBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/transition_condition_base.hpp b/include/rive/generated/animation/transition_condition_base.hpp index 220e633..e0ec5da 100644 --- a/include/rive/generated/animation/transition_condition_base.hpp +++ b/include/rive/generated/animation/transition_condition_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSITION_CONDITION_BASE_HPP_ #include "rive/core.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TransitionConditionBase : public Core { +namespace rive +{ +class TransitionConditionBase : public Core +{ protected: typedef Core Super; @@ -12,10 +14,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case TransitionConditionBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case TransitionConditionBase::typeKey: + return true; + default: + return false; } } @@ -28,8 +34,10 @@ public: inline uint32_t inputId() const { return m_InputId; } - void inputId(uint32_t value) { - if (m_InputId == value) { + void inputId(uint32_t value) + { + if (m_InputId == value) + { return; } m_InputId = value; @@ -38,9 +46,13 @@ void copy(const TransitionConditionBase& object) { m_InputId = object.m_InputId; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case inputIdPropertyKey: m_InputId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case inputIdPropertyKey: + m_InputId = CoreUintType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/animation/transition_number_condition_base.hpp b/include/rive/generated/animation/transition_number_condition_base.hpp index d068e80..5d4cc79 100644 --- a/include/rive/generated/animation/transition_number_condition_base.hpp +++ b/include/rive/generated/animation/transition_number_condition_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSITION_NUMBER_CONDITION_BASE_HPP_ #include "rive/animation/transition_value_condition.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class TransitionNumberConditionBase : public TransitionValueCondition { +namespace rive +{ +class TransitionNumberConditionBase : public TransitionValueCondition +{ protected: typedef TransitionValueCondition Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransitionNumberConditionBase::typeKey: case TransitionValueConditionBase::typeKey: - case TransitionConditionBase::typeKey: return true; - default: return false; + case TransitionConditionBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline float value() const { return m_Value; } - void value(float value) { - if (m_Value == value) { + void value(float value) + { + if (m_Value == value) + { return; } m_Value = value; @@ -39,14 +47,19 @@ } Core* clone() const override; - void copy(const TransitionNumberConditionBase& object) { + void copy(const TransitionNumberConditionBase& object) + { m_Value = object.m_Value; TransitionValueCondition::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuePropertyKey: m_Value = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuePropertyKey: + m_Value = CoreDoubleType::deserialize(reader); + return true; } return TransitionValueCondition::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/animation/transition_trigger_condition_base.hpp b/include/rive/generated/animation/transition_trigger_condition_base.hpp index 13a58b3..b10c559 100644 --- a/include/rive/generated/animation/transition_trigger_condition_base.hpp +++ b/include/rive/generated/animation/transition_trigger_condition_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_TRANSITION_TRIGGER_CONDITION_BASE_HPP_ #define _RIVE_TRANSITION_TRIGGER_CONDITION_BASE_HPP_ #include "rive/animation/transition_condition.hpp" -namespace rive { -class TransitionTriggerConditionBase : public TransitionCondition { +namespace rive +{ +class TransitionTriggerConditionBase : public TransitionCondition +{ protected: typedef TransitionCondition Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransitionTriggerConditionBase::typeKey: - case TransitionConditionBase::typeKey: return true; - default: return false; + case TransitionConditionBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/animation/transition_value_condition_base.hpp b/include/rive/generated/animation/transition_value_condition_base.hpp index 91b4075..9fe2c46 100644 --- a/include/rive/generated/animation/transition_value_condition_base.hpp +++ b/include/rive/generated/animation/transition_value_condition_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSITION_VALUE_CONDITION_BASE_HPP_ #include "rive/animation/transition_condition.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TransitionValueConditionBase : public TransitionCondition { +namespace rive +{ +class TransitionValueConditionBase : public TransitionCondition +{ protected: typedef TransitionCondition Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransitionValueConditionBase::typeKey: - case TransitionConditionBase::typeKey: return true; - default: return false; + case TransitionConditionBase::typeKey: + return true; + default: + return false; } } @@ -29,22 +35,29 @@ public: inline uint32_t opValue() const { return m_OpValue; } - void opValue(uint32_t value) { - if (m_OpValue == value) { + void opValue(uint32_t value) + { + if (m_OpValue == value) + { return; } m_OpValue = value; opValueChanged(); } - void copy(const TransitionValueConditionBase& object) { + void copy(const TransitionValueConditionBase& object) + { m_OpValue = object.m_OpValue; TransitionCondition::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case opValuePropertyKey: m_OpValue = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case opValuePropertyKey: + m_OpValue = CoreUintType::deserialize(reader); + return true; } return TransitionCondition::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/artboard_base.hpp b/include/rive/generated/artboard_base.hpp index e3c4c5a..feac51f 100644 --- a/include/rive/generated/artboard_base.hpp +++ b/include/rive/generated/artboard_base.hpp
@@ -4,8 +4,10 @@ #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" #include "rive/world_transform_component.hpp" -namespace rive { -class ArtboardBase : public WorldTransformComponent { +namespace rive +{ +class ArtboardBase : public WorldTransformComponent +{ protected: typedef WorldTransformComponent Super; @@ -14,13 +16,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ArtboardBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -47,8 +53,10 @@ public: inline bool clip() const { return m_Clip; } - void clip(bool value) { - if (m_Clip == value) { + void clip(bool value) + { + if (m_Clip == value) + { return; } m_Clip = value; @@ -56,8 +64,10 @@ } inline float width() const { return m_Width; } - void width(float value) { - if (m_Width == value) { + void width(float value) + { + if (m_Width == value) + { return; } m_Width = value; @@ -65,8 +75,10 @@ } inline float height() const { return m_Height; } - void height(float value) { - if (m_Height == value) { + void height(float value) + { + if (m_Height == value) + { return; } m_Height = value; @@ -74,8 +86,10 @@ } inline float x() const { return m_X; } - void x(float value) { - if (m_X == value) { + void x(float value) + { + if (m_X == value) + { return; } m_X = value; @@ -83,8 +97,10 @@ } inline float y() const { return m_Y; } - void y(float value) { - if (m_Y == value) { + void y(float value) + { + if (m_Y == value) + { return; } m_Y = value; @@ -92,8 +108,10 @@ } inline float originX() const { return m_OriginX; } - void originX(float value) { - if (m_OriginX == value) { + void originX(float value) + { + if (m_OriginX == value) + { return; } m_OriginX = value; @@ -101,8 +119,10 @@ } inline float originY() const { return m_OriginY; } - void originY(float value) { - if (m_OriginY == value) { + void originY(float value) + { + if (m_OriginY == value) + { return; } m_OriginY = value; @@ -110,8 +130,10 @@ } inline uint32_t defaultStateMachineId() const { return m_DefaultStateMachineId; } - void defaultStateMachineId(uint32_t value) { - if (m_DefaultStateMachineId == value) { + void defaultStateMachineId(uint32_t value) + { + if (m_DefaultStateMachineId == value) + { return; } m_DefaultStateMachineId = value; @@ -119,7 +141,8 @@ } Core* clone() const override; - void copy(const ArtboardBase& object) { + void copy(const ArtboardBase& object) + { m_Clip = object.m_Clip; m_Width = object.m_Width; m_Height = object.m_Height; @@ -131,15 +154,31 @@ WorldTransformComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case clipPropertyKey: m_Clip = CoreBoolType::deserialize(reader); return true; - case widthPropertyKey: m_Width = CoreDoubleType::deserialize(reader); return true; - case heightPropertyKey: m_Height = CoreDoubleType::deserialize(reader); return true; - case xPropertyKey: m_X = CoreDoubleType::deserialize(reader); return true; - case yPropertyKey: m_Y = CoreDoubleType::deserialize(reader); return true; - case originXPropertyKey: m_OriginX = CoreDoubleType::deserialize(reader); return true; - case originYPropertyKey: m_OriginY = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case clipPropertyKey: + m_Clip = CoreBoolType::deserialize(reader); + return true; + case widthPropertyKey: + m_Width = CoreDoubleType::deserialize(reader); + return true; + case heightPropertyKey: + m_Height = CoreDoubleType::deserialize(reader); + return true; + case xPropertyKey: + m_X = CoreDoubleType::deserialize(reader); + return true; + case yPropertyKey: + m_Y = CoreDoubleType::deserialize(reader); + return true; + case originXPropertyKey: + m_OriginX = CoreDoubleType::deserialize(reader); + return true; + case originYPropertyKey: + m_OriginY = CoreDoubleType::deserialize(reader); + return true; case defaultStateMachineIdPropertyKey: m_DefaultStateMachineId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/assets/asset_base.hpp b/include/rive/generated/assets/asset_base.hpp index 4917059..794b563 100644 --- a/include/rive/generated/assets/asset_base.hpp +++ b/include/rive/generated/assets/asset_base.hpp
@@ -3,8 +3,10 @@ #include <string> #include "rive/core.hpp" #include "rive/core/field_types/core_string_type.hpp" -namespace rive { -class AssetBase : public Core { +namespace rive +{ +class AssetBase : public Core +{ protected: typedef Core Super; @@ -13,10 +15,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case AssetBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case AssetBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline const std::string& name() const { return m_Name; } - void name(std::string value) { - if (m_Name == value) { + void name(std::string value) + { + if (m_Name == value) + { return; } m_Name = value; @@ -39,9 +47,13 @@ void copy(const AssetBase& object) { m_Name = object.m_Name; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case namePropertyKey: m_Name = CoreStringType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case namePropertyKey: + m_Name = CoreStringType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/assets/drawable_asset_base.hpp b/include/rive/generated/assets/drawable_asset_base.hpp index 8723e75..22690ed 100644 --- a/include/rive/generated/assets/drawable_asset_base.hpp +++ b/include/rive/generated/assets/drawable_asset_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DRAWABLE_ASSET_BASE_HPP_ #include "rive/assets/file_asset.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class DrawableAssetBase : public FileAsset { +namespace rive +{ +class DrawableAssetBase : public FileAsset +{ protected: typedef FileAsset Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case DrawableAssetBase::typeKey: case FileAssetBase::typeKey: - case AssetBase::typeKey: return true; - default: return false; + case AssetBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline float height() const { return m_Height; } - void height(float value) { - if (m_Height == value) { + void height(float value) + { + if (m_Height == value) + { return; } m_Height = value; @@ -41,24 +49,33 @@ } inline float width() const { return m_Width; } - void width(float value) { - if (m_Width == value) { + void width(float value) + { + if (m_Width == value) + { return; } m_Width = value; widthChanged(); } - void copy(const DrawableAssetBase& object) { + void copy(const DrawableAssetBase& object) + { m_Height = object.m_Height; m_Width = object.m_Width; FileAsset::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case heightPropertyKey: m_Height = CoreDoubleType::deserialize(reader); return true; - case widthPropertyKey: m_Width = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case heightPropertyKey: + m_Height = CoreDoubleType::deserialize(reader); + return true; + case widthPropertyKey: + m_Width = CoreDoubleType::deserialize(reader); + return true; } return FileAsset::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/assets/file_asset_base.hpp b/include/rive/generated/assets/file_asset_base.hpp index 2fffb29..4856c62 100644 --- a/include/rive/generated/assets/file_asset_base.hpp +++ b/include/rive/generated/assets/file_asset_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_FILE_ASSET_BASE_HPP_ #include "rive/assets/asset.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class FileAssetBase : public Asset { +namespace rive +{ +class FileAssetBase : public Asset +{ protected: typedef Asset Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case FileAssetBase::typeKey: - case AssetBase::typeKey: return true; - default: return false; + case AssetBase::typeKey: + return true; + default: + return false; } } @@ -29,22 +35,29 @@ public: inline uint32_t assetId() const { return m_AssetId; } - void assetId(uint32_t value) { - if (m_AssetId == value) { + void assetId(uint32_t value) + { + if (m_AssetId == value) + { return; } m_AssetId = value; assetIdChanged(); } - void copy(const FileAssetBase& object) { + void copy(const FileAssetBase& object) + { m_AssetId = object.m_AssetId; Asset::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case assetIdPropertyKey: m_AssetId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case assetIdPropertyKey: + m_AssetId = CoreUintType::deserialize(reader); + return true; } return Asset::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/assets/file_asset_contents_base.hpp b/include/rive/generated/assets/file_asset_contents_base.hpp index 0bc552e..dd50e07 100644 --- a/include/rive/generated/assets/file_asset_contents_base.hpp +++ b/include/rive/generated/assets/file_asset_contents_base.hpp
@@ -3,8 +3,10 @@ #include "rive/core.hpp" #include "rive/core/field_types/core_bytes_type.hpp" #include "rive/span.hpp" -namespace rive { -class FileAssetContentsBase : public Core { +namespace rive +{ +class FileAssetContentsBase : public Core +{ protected: typedef Core Super; @@ -13,10 +15,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case FileAssetContentsBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case FileAssetContentsBase::typeKey: + return true; + default: + return false; } } @@ -31,9 +37,13 @@ Core* clone() const override; void copy(const FileAssetContentsBase& object) { copyBytes(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case bytesPropertyKey: decodeBytes(CoreBytesType::deserialize(reader)); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case bytesPropertyKey: + decodeBytes(CoreBytesType::deserialize(reader)); + return true; } return false; }
diff --git a/include/rive/generated/assets/folder_base.hpp b/include/rive/generated/assets/folder_base.hpp index afd7e8a..77f9750 100644 --- a/include/rive/generated/assets/folder_base.hpp +++ b/include/rive/generated/assets/folder_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_FOLDER_BASE_HPP_ #define _RIVE_FOLDER_BASE_HPP_ #include "rive/assets/asset.hpp" -namespace rive { -class FolderBase : public Asset { +namespace rive +{ +class FolderBase : public Asset +{ protected: typedef Asset Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case FolderBase::typeKey: - case AssetBase::typeKey: return true; - default: return false; + case AssetBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/assets/image_asset_base.hpp b/include/rive/generated/assets/image_asset_base.hpp index 091b9d9..d51220f 100644 --- a/include/rive/generated/assets/image_asset_base.hpp +++ b/include/rive/generated/assets/image_asset_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_IMAGE_ASSET_BASE_HPP_ #define _RIVE_IMAGE_ASSET_BASE_HPP_ #include "rive/assets/drawable_asset.hpp" -namespace rive { -class ImageAssetBase : public DrawableAsset { +namespace rive +{ +class ImageAssetBase : public DrawableAsset +{ protected: typedef DrawableAsset Super; @@ -11,13 +13,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ImageAssetBase::typeKey: case DrawableAssetBase::typeKey: case FileAssetBase::typeKey: - case AssetBase::typeKey: return true; - default: return false; + case AssetBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/backboard_base.hpp b/include/rive/generated/backboard_base.hpp index d0f2294..9f0cf19 100644 --- a/include/rive/generated/backboard_base.hpp +++ b/include/rive/generated/backboard_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_BACKBOARD_BASE_HPP_ #define _RIVE_BACKBOARD_BASE_HPP_ #include "rive/core.hpp" -namespace rive { -class BackboardBase : public Core { +namespace rive +{ +class BackboardBase : public Core +{ protected: typedef Core Super; @@ -11,10 +13,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case BackboardBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case BackboardBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/bones/bone_base.hpp b/include/rive/generated/bones/bone_base.hpp index ae8d2bb..a6d2a01 100644 --- a/include/rive/generated/bones/bone_base.hpp +++ b/include/rive/generated/bones/bone_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_BONE_BASE_HPP_ #include "rive/bones/skeletal_component.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class BoneBase : public SkeletalComponent { +namespace rive +{ +class BoneBase : public SkeletalComponent +{ protected: typedef SkeletalComponent Super; @@ -12,15 +14,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case BoneBase::typeKey: case SkeletalComponentBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -33,8 +39,10 @@ public: inline float length() const { return m_Length; } - void length(float value) { - if (m_Length == value) { + void length(float value) + { + if (m_Length == value) + { return; } m_Length = value; @@ -42,14 +50,19 @@ } Core* clone() const override; - void copy(const BoneBase& object) { + void copy(const BoneBase& object) + { m_Length = object.m_Length; SkeletalComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case lengthPropertyKey: m_Length = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case lengthPropertyKey: + m_Length = CoreDoubleType::deserialize(reader); + return true; } return SkeletalComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/bones/cubic_weight_base.hpp b/include/rive/generated/bones/cubic_weight_base.hpp index 85ec61e..13d016e 100644 --- a/include/rive/generated/bones/cubic_weight_base.hpp +++ b/include/rive/generated/bones/cubic_weight_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CUBIC_WEIGHT_BASE_HPP_ #include "rive/bones/weight.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class CubicWeightBase : public Weight { +namespace rive +{ +class CubicWeightBase : public Weight +{ protected: typedef Weight Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case CubicWeightBase::typeKey: case WeightBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -36,8 +42,10 @@ public: inline uint32_t inValues() const { return m_InValues; } - void inValues(uint32_t value) { - if (m_InValues == value) { + void inValues(uint32_t value) + { + if (m_InValues == value) + { return; } m_InValues = value; @@ -45,8 +53,10 @@ } inline uint32_t inIndices() const { return m_InIndices; } - void inIndices(uint32_t value) { - if (m_InIndices == value) { + void inIndices(uint32_t value) + { + if (m_InIndices == value) + { return; } m_InIndices = value; @@ -54,8 +64,10 @@ } inline uint32_t outValues() const { return m_OutValues; } - void outValues(uint32_t value) { - if (m_OutValues == value) { + void outValues(uint32_t value) + { + if (m_OutValues == value) + { return; } m_OutValues = value; @@ -63,8 +75,10 @@ } inline uint32_t outIndices() const { return m_OutIndices; } - void outIndices(uint32_t value) { - if (m_OutIndices == value) { + void outIndices(uint32_t value) + { + if (m_OutIndices == value) + { return; } m_OutIndices = value; @@ -72,7 +86,8 @@ } Core* clone() const override; - void copy(const CubicWeightBase& object) { + void copy(const CubicWeightBase& object) + { m_InValues = object.m_InValues; m_InIndices = object.m_InIndices; m_OutValues = object.m_OutValues; @@ -80,11 +95,19 @@ Weight::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case inValuesPropertyKey: m_InValues = CoreUintType::deserialize(reader); return true; - case inIndicesPropertyKey: m_InIndices = CoreUintType::deserialize(reader); return true; - case outValuesPropertyKey: m_OutValues = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case inValuesPropertyKey: + m_InValues = CoreUintType::deserialize(reader); + return true; + case inIndicesPropertyKey: + m_InIndices = CoreUintType::deserialize(reader); + return true; + case outValuesPropertyKey: + m_OutValues = CoreUintType::deserialize(reader); + return true; case outIndicesPropertyKey: m_OutIndices = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/bones/root_bone_base.hpp b/include/rive/generated/bones/root_bone_base.hpp index 552443f..6612a1d 100644 --- a/include/rive/generated/bones/root_bone_base.hpp +++ b/include/rive/generated/bones/root_bone_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_ROOT_BONE_BASE_HPP_ #include "rive/bones/bone.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class RootBoneBase : public Bone { +namespace rive +{ +class RootBoneBase : public Bone +{ protected: typedef Bone Super; @@ -12,16 +14,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case RootBoneBase::typeKey: case BoneBase::typeKey: case SkeletalComponentBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -36,8 +42,10 @@ public: inline float x() const override { return m_X; } - void x(float value) { - if (m_X == value) { + void x(float value) + { + if (m_X == value) + { return; } m_X = value; @@ -45,8 +53,10 @@ } inline float y() const override { return m_Y; } - void y(float value) { - if (m_Y == value) { + void y(float value) + { + if (m_Y == value) + { return; } m_Y = value; @@ -54,16 +64,23 @@ } Core* clone() const override; - void copy(const RootBoneBase& object) { + void copy(const RootBoneBase& object) + { m_X = object.m_X; m_Y = object.m_Y; Bone::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case xPropertyKey: m_X = CoreDoubleType::deserialize(reader); return true; - case yPropertyKey: m_Y = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case xPropertyKey: + m_X = CoreDoubleType::deserialize(reader); + return true; + case yPropertyKey: + m_Y = CoreDoubleType::deserialize(reader); + return true; } return Bone::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/bones/skeletal_component_base.hpp b/include/rive/generated/bones/skeletal_component_base.hpp index e461fe6..46bd185 100644 --- a/include/rive/generated/bones/skeletal_component_base.hpp +++ b/include/rive/generated/bones/skeletal_component_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_SKELETAL_COMPONENT_BASE_HPP_ #define _RIVE_SKELETAL_COMPONENT_BASE_HPP_ #include "rive/transform_component.hpp" -namespace rive { -class SkeletalComponentBase : public TransformComponent { +namespace rive +{ +class SkeletalComponentBase : public TransformComponent +{ protected: typedef TransformComponent Super; @@ -11,14 +13,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case SkeletalComponentBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/bones/skin_base.hpp b/include/rive/generated/bones/skin_base.hpp index 7a52c9c..2cbe0ce 100644 --- a/include/rive/generated/bones/skin_base.hpp +++ b/include/rive/generated/bones/skin_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_SKIN_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class SkinBase : public ContainerComponent { +namespace rive +{ +class SkinBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case SkinBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -40,8 +46,10 @@ public: inline float xx() const { return m_Xx; } - void xx(float value) { - if (m_Xx == value) { + void xx(float value) + { + if (m_Xx == value) + { return; } m_Xx = value; @@ -49,8 +57,10 @@ } inline float yx() const { return m_Yx; } - void yx(float value) { - if (m_Yx == value) { + void yx(float value) + { + if (m_Yx == value) + { return; } m_Yx = value; @@ -58,8 +68,10 @@ } inline float xy() const { return m_Xy; } - void xy(float value) { - if (m_Xy == value) { + void xy(float value) + { + if (m_Xy == value) + { return; } m_Xy = value; @@ -67,8 +79,10 @@ } inline float yy() const { return m_Yy; } - void yy(float value) { - if (m_Yy == value) { + void yy(float value) + { + if (m_Yy == value) + { return; } m_Yy = value; @@ -76,8 +90,10 @@ } inline float tx() const { return m_Tx; } - void tx(float value) { - if (m_Tx == value) { + void tx(float value) + { + if (m_Tx == value) + { return; } m_Tx = value; @@ -85,8 +101,10 @@ } inline float ty() const { return m_Ty; } - void ty(float value) { - if (m_Ty == value) { + void ty(float value) + { + if (m_Ty == value) + { return; } m_Ty = value; @@ -94,7 +112,8 @@ } Core* clone() const override; - void copy(const SkinBase& object) { + void copy(const SkinBase& object) + { m_Xx = object.m_Xx; m_Yx = object.m_Yx; m_Xy = object.m_Xy; @@ -104,14 +123,28 @@ ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case xxPropertyKey: m_Xx = CoreDoubleType::deserialize(reader); return true; - case yxPropertyKey: m_Yx = CoreDoubleType::deserialize(reader); return true; - case xyPropertyKey: m_Xy = CoreDoubleType::deserialize(reader); return true; - case yyPropertyKey: m_Yy = CoreDoubleType::deserialize(reader); return true; - case txPropertyKey: m_Tx = CoreDoubleType::deserialize(reader); return true; - case tyPropertyKey: m_Ty = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case xxPropertyKey: + m_Xx = CoreDoubleType::deserialize(reader); + return true; + case yxPropertyKey: + m_Yx = CoreDoubleType::deserialize(reader); + return true; + case xyPropertyKey: + m_Xy = CoreDoubleType::deserialize(reader); + return true; + case yyPropertyKey: + m_Yy = CoreDoubleType::deserialize(reader); + return true; + case txPropertyKey: + m_Tx = CoreDoubleType::deserialize(reader); + return true; + case tyPropertyKey: + m_Ty = CoreDoubleType::deserialize(reader); + return true; } return ContainerComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/bones/tendon_base.hpp b/include/rive/generated/bones/tendon_base.hpp index 6dcd1f5..5ccaed1 100644 --- a/include/rive/generated/bones/tendon_base.hpp +++ b/include/rive/generated/bones/tendon_base.hpp
@@ -3,8 +3,10 @@ #include "rive/component.hpp" #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TendonBase : public Component { +namespace rive +{ +class TendonBase : public Component +{ protected: typedef Component Super; @@ -13,11 +15,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TendonBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -42,8 +48,10 @@ public: inline uint32_t boneId() const { return m_BoneId; } - void boneId(uint32_t value) { - if (m_BoneId == value) { + void boneId(uint32_t value) + { + if (m_BoneId == value) + { return; } m_BoneId = value; @@ -51,8 +59,10 @@ } inline float xx() const { return m_Xx; } - void xx(float value) { - if (m_Xx == value) { + void xx(float value) + { + if (m_Xx == value) + { return; } m_Xx = value; @@ -60,8 +70,10 @@ } inline float yx() const { return m_Yx; } - void yx(float value) { - if (m_Yx == value) { + void yx(float value) + { + if (m_Yx == value) + { return; } m_Yx = value; @@ -69,8 +81,10 @@ } inline float xy() const { return m_Xy; } - void xy(float value) { - if (m_Xy == value) { + void xy(float value) + { + if (m_Xy == value) + { return; } m_Xy = value; @@ -78,8 +92,10 @@ } inline float yy() const { return m_Yy; } - void yy(float value) { - if (m_Yy == value) { + void yy(float value) + { + if (m_Yy == value) + { return; } m_Yy = value; @@ -87,8 +103,10 @@ } inline float tx() const { return m_Tx; } - void tx(float value) { - if (m_Tx == value) { + void tx(float value) + { + if (m_Tx == value) + { return; } m_Tx = value; @@ -96,8 +114,10 @@ } inline float ty() const { return m_Ty; } - void ty(float value) { - if (m_Ty == value) { + void ty(float value) + { + if (m_Ty == value) + { return; } m_Ty = value; @@ -105,7 +125,8 @@ } Core* clone() const override; - void copy(const TendonBase& object) { + void copy(const TendonBase& object) + { m_BoneId = object.m_BoneId; m_Xx = object.m_Xx; m_Yx = object.m_Yx; @@ -116,15 +137,31 @@ Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case boneIdPropertyKey: m_BoneId = CoreUintType::deserialize(reader); return true; - case xxPropertyKey: m_Xx = CoreDoubleType::deserialize(reader); return true; - case yxPropertyKey: m_Yx = CoreDoubleType::deserialize(reader); return true; - case xyPropertyKey: m_Xy = CoreDoubleType::deserialize(reader); return true; - case yyPropertyKey: m_Yy = CoreDoubleType::deserialize(reader); return true; - case txPropertyKey: m_Tx = CoreDoubleType::deserialize(reader); return true; - case tyPropertyKey: m_Ty = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case boneIdPropertyKey: + m_BoneId = CoreUintType::deserialize(reader); + return true; + case xxPropertyKey: + m_Xx = CoreDoubleType::deserialize(reader); + return true; + case yxPropertyKey: + m_Yx = CoreDoubleType::deserialize(reader); + return true; + case xyPropertyKey: + m_Xy = CoreDoubleType::deserialize(reader); + return true; + case yyPropertyKey: + m_Yy = CoreDoubleType::deserialize(reader); + return true; + case txPropertyKey: + m_Tx = CoreDoubleType::deserialize(reader); + return true; + case tyPropertyKey: + m_Ty = CoreDoubleType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/bones/weight_base.hpp b/include/rive/generated/bones/weight_base.hpp index 0b8c40c..a9fa235 100644 --- a/include/rive/generated/bones/weight_base.hpp +++ b/include/rive/generated/bones/weight_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_WEIGHT_BASE_HPP_ #include "rive/component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class WeightBase : public Component { +namespace rive +{ +class WeightBase : public Component +{ protected: typedef Component Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case WeightBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,8 +37,10 @@ public: inline uint32_t values() const { return m_Values; } - void values(uint32_t value) { - if (m_Values == value) { + void values(uint32_t value) + { + if (m_Values == value) + { return; } m_Values = value; @@ -40,8 +48,10 @@ } inline uint32_t indices() const { return m_Indices; } - void indices(uint32_t value) { - if (m_Indices == value) { + void indices(uint32_t value) + { + if (m_Indices == value) + { return; } m_Indices = value; @@ -49,16 +59,23 @@ } Core* clone() const override; - void copy(const WeightBase& object) { + void copy(const WeightBase& object) + { m_Values = object.m_Values; m_Indices = object.m_Indices; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case valuesPropertyKey: m_Values = CoreUintType::deserialize(reader); return true; - case indicesPropertyKey: m_Indices = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case valuesPropertyKey: + m_Values = CoreUintType::deserialize(reader); + return true; + case indicesPropertyKey: + m_Indices = CoreUintType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/component_base.hpp b/include/rive/generated/component_base.hpp index df47b60..46463bd 100644 --- a/include/rive/generated/component_base.hpp +++ b/include/rive/generated/component_base.hpp
@@ -4,8 +4,10 @@ #include "rive/core.hpp" #include "rive/core/field_types/core_string_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class ComponentBase : public Core { +namespace rive +{ +class ComponentBase : public Core +{ protected: typedef Core Super; @@ -14,10 +16,14 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { - case ComponentBase::typeKey: return true; - default: return false; + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline const std::string& name() const { return m_Name; } - void name(std::string value) { - if (m_Name == value) { + void name(std::string value) + { + if (m_Name == value) + { return; } m_Name = value; @@ -41,23 +49,32 @@ } inline uint32_t parentId() const { return m_ParentId; } - void parentId(uint32_t value) { - if (m_ParentId == value) { + void parentId(uint32_t value) + { + if (m_ParentId == value) + { return; } m_ParentId = value; parentIdChanged(); } - void copy(const ComponentBase& object) { + void copy(const ComponentBase& object) + { m_Name = object.m_Name; m_ParentId = object.m_ParentId; } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case namePropertyKey: m_Name = CoreStringType::deserialize(reader); return true; - case parentIdPropertyKey: m_ParentId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case namePropertyKey: + m_Name = CoreStringType::deserialize(reader); + return true; + case parentIdPropertyKey: + m_ParentId = CoreUintType::deserialize(reader); + return true; } return false; }
diff --git a/include/rive/generated/constraints/constraint_base.hpp b/include/rive/generated/constraints/constraint_base.hpp index 3ac36ae..148a3f0 100644 --- a/include/rive/generated/constraints/constraint_base.hpp +++ b/include/rive/generated/constraints/constraint_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CONSTRAINT_BASE_HPP_ #include "rive/component.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class ConstraintBase : public Component { +namespace rive +{ +class ConstraintBase : public Component +{ protected: typedef Component Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -29,22 +35,29 @@ public: inline float strength() const { return m_Strength; } - void strength(float value) { - if (m_Strength == value) { + void strength(float value) + { + if (m_Strength == value) + { return; } m_Strength = value; strengthChanged(); } - void copy(const ConstraintBase& object) { + void copy(const ConstraintBase& object) + { m_Strength = object.m_Strength; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case strengthPropertyKey: m_Strength = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case strengthPropertyKey: + m_Strength = CoreDoubleType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/constraints/distance_constraint_base.hpp b/include/rive/generated/constraints/distance_constraint_base.hpp index d2fdd1d..0c8b5ae 100644 --- a/include/rive/generated/constraints/distance_constraint_base.hpp +++ b/include/rive/generated/constraints/distance_constraint_base.hpp
@@ -3,8 +3,10 @@ #include "rive/constraints/targeted_constraint.hpp" #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class DistanceConstraintBase : public TargetedConstraint { +namespace rive +{ +class DistanceConstraintBase : public TargetedConstraint +{ protected: typedef TargetedConstraint Super; @@ -13,13 +15,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case DistanceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline float distance() const { return m_Distance; } - void distance(float value) { - if (m_Distance == value) { + void distance(float value) + { + if (m_Distance == value) + { return; } m_Distance = value; @@ -43,8 +51,10 @@ } inline uint32_t modeValue() const { return m_ModeValue; } - void modeValue(uint32_t value) { - if (m_ModeValue == value) { + void modeValue(uint32_t value) + { + if (m_ModeValue == value) + { return; } m_ModeValue = value; @@ -52,16 +62,23 @@ } Core* clone() const override; - void copy(const DistanceConstraintBase& object) { + void copy(const DistanceConstraintBase& object) + { m_Distance = object.m_Distance; m_ModeValue = object.m_ModeValue; TargetedConstraint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case distancePropertyKey: m_Distance = CoreDoubleType::deserialize(reader); return true; - case modeValuePropertyKey: m_ModeValue = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case distancePropertyKey: + m_Distance = CoreDoubleType::deserialize(reader); + return true; + case modeValuePropertyKey: + m_ModeValue = CoreUintType::deserialize(reader); + return true; } return TargetedConstraint::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/constraints/ik_constraint_base.hpp b/include/rive/generated/constraints/ik_constraint_base.hpp index 0aa150e..ec38ee0 100644 --- a/include/rive/generated/constraints/ik_constraint_base.hpp +++ b/include/rive/generated/constraints/ik_constraint_base.hpp
@@ -3,8 +3,10 @@ #include "rive/constraints/targeted_constraint.hpp" #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class IKConstraintBase : public TargetedConstraint { +namespace rive +{ +class IKConstraintBase : public TargetedConstraint +{ protected: typedef TargetedConstraint Super; @@ -13,13 +15,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case IKConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline bool invertDirection() const { return m_InvertDirection; } - void invertDirection(bool value) { - if (m_InvertDirection == value) { + void invertDirection(bool value) + { + if (m_InvertDirection == value) + { return; } m_InvertDirection = value; @@ -43,8 +51,10 @@ } inline uint32_t parentBoneCount() const { return m_ParentBoneCount; } - void parentBoneCount(uint32_t value) { - if (m_ParentBoneCount == value) { + void parentBoneCount(uint32_t value) + { + if (m_ParentBoneCount == value) + { return; } m_ParentBoneCount = value; @@ -52,14 +62,17 @@ } Core* clone() const override; - void copy(const IKConstraintBase& object) { + void copy(const IKConstraintBase& object) + { m_InvertDirection = object.m_InvertDirection; m_ParentBoneCount = object.m_ParentBoneCount; TargetedConstraint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case invertDirectionPropertyKey: m_InvertDirection = CoreBoolType::deserialize(reader); return true;
diff --git a/include/rive/generated/constraints/rotation_constraint_base.hpp b/include/rive/generated/constraints/rotation_constraint_base.hpp index b8dee2f..6e34fcb 100644 --- a/include/rive/generated/constraints/rotation_constraint_base.hpp +++ b/include/rive/generated/constraints/rotation_constraint_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_ROTATION_CONSTRAINT_BASE_HPP_ #define _RIVE_ROTATION_CONSTRAINT_BASE_HPP_ #include "rive/constraints/transform_component_constraint.hpp" -namespace rive { -class RotationConstraintBase : public TransformComponentConstraint { +namespace rive +{ +class RotationConstraintBase : public TransformComponentConstraint +{ protected: typedef TransformComponentConstraint Super; @@ -11,15 +13,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case RotationConstraintBase::typeKey: case TransformComponentConstraintBase::typeKey: case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/constraints/scale_constraint_base.hpp b/include/rive/generated/constraints/scale_constraint_base.hpp index 7072eae..abe8729 100644 --- a/include/rive/generated/constraints/scale_constraint_base.hpp +++ b/include/rive/generated/constraints/scale_constraint_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_SCALE_CONSTRAINT_BASE_HPP_ #define _RIVE_SCALE_CONSTRAINT_BASE_HPP_ #include "rive/constraints/transform_component_constraint_y.hpp" -namespace rive { -class ScaleConstraintBase : public TransformComponentConstraintY { +namespace rive +{ +class ScaleConstraintBase : public TransformComponentConstraintY +{ protected: typedef TransformComponentConstraintY Super; @@ -11,16 +13,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ScaleConstraintBase::typeKey: case TransformComponentConstraintYBase::typeKey: case TransformComponentConstraintBase::typeKey: case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/constraints/targeted_constraint_base.hpp b/include/rive/generated/constraints/targeted_constraint_base.hpp index e7de5a4..e236d0f 100644 --- a/include/rive/generated/constraints/targeted_constraint_base.hpp +++ b/include/rive/generated/constraints/targeted_constraint_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TARGETED_CONSTRAINT_BASE_HPP_ #include "rive/constraints/constraint.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TargetedConstraintBase : public Constraint { +namespace rive +{ +class TargetedConstraintBase : public Constraint +{ protected: typedef Constraint Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,22 +36,29 @@ public: inline uint32_t targetId() const { return m_TargetId; } - void targetId(uint32_t value) { - if (m_TargetId == value) { + void targetId(uint32_t value) + { + if (m_TargetId == value) + { return; } m_TargetId = value; targetIdChanged(); } - void copy(const TargetedConstraintBase& object) { + void copy(const TargetedConstraintBase& object) + { m_TargetId = object.m_TargetId; Constraint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case targetIdPropertyKey: m_TargetId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case targetIdPropertyKey: + m_TargetId = CoreUintType::deserialize(reader); + return true; } return Constraint::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/constraints/transform_component_constraint_base.hpp b/include/rive/generated/constraints/transform_component_constraint_base.hpp index 2cd84ad..e52573a 100644 --- a/include/rive/generated/constraints/transform_component_constraint_base.hpp +++ b/include/rive/generated/constraints/transform_component_constraint_base.hpp
@@ -4,8 +4,10 @@ #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TransformComponentConstraintBase : public TransformSpaceConstraint { +namespace rive +{ +class TransformComponentConstraintBase : public TransformSpaceConstraint +{ protected: typedef TransformSpaceConstraint Super; @@ -14,14 +16,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransformComponentConstraintBase::typeKey: case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -48,8 +54,10 @@ public: inline uint32_t minMaxSpaceValue() const { return m_MinMaxSpaceValue; } - void minMaxSpaceValue(uint32_t value) { - if (m_MinMaxSpaceValue == value) { + void minMaxSpaceValue(uint32_t value) + { + if (m_MinMaxSpaceValue == value) + { return; } m_MinMaxSpaceValue = value; @@ -57,8 +65,10 @@ } inline float copyFactor() const { return m_CopyFactor; } - void copyFactor(float value) { - if (m_CopyFactor == value) { + void copyFactor(float value) + { + if (m_CopyFactor == value) + { return; } m_CopyFactor = value; @@ -66,8 +76,10 @@ } inline float minValue() const { return m_MinValue; } - void minValue(float value) { - if (m_MinValue == value) { + void minValue(float value) + { + if (m_MinValue == value) + { return; } m_MinValue = value; @@ -75,8 +87,10 @@ } inline float maxValue() const { return m_MaxValue; } - void maxValue(float value) { - if (m_MaxValue == value) { + void maxValue(float value) + { + if (m_MaxValue == value) + { return; } m_MaxValue = value; @@ -84,8 +98,10 @@ } inline bool offset() const { return m_Offset; } - void offset(bool value) { - if (m_Offset == value) { + void offset(bool value) + { + if (m_Offset == value) + { return; } m_Offset = value; @@ -93,8 +109,10 @@ } inline bool doesCopy() const { return m_DoesCopy; } - void doesCopy(bool value) { - if (m_DoesCopy == value) { + void doesCopy(bool value) + { + if (m_DoesCopy == value) + { return; } m_DoesCopy = value; @@ -102,8 +120,10 @@ } inline bool min() const { return m_Min; } - void min(bool value) { - if (m_Min == value) { + void min(bool value) + { + if (m_Min == value) + { return; } m_Min = value; @@ -111,15 +131,18 @@ } inline bool max() const { return m_Max; } - void max(bool value) { - if (m_Max == value) { + void max(bool value) + { + if (m_Max == value) + { return; } m_Max = value; maxChanged(); } - void copy(const TransformComponentConstraintBase& object) { + void copy(const TransformComponentConstraintBase& object) + { m_MinMaxSpaceValue = object.m_MinMaxSpaceValue; m_CopyFactor = object.m_CopyFactor; m_MinValue = object.m_MinValue; @@ -131,20 +154,34 @@ TransformSpaceConstraint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case minMaxSpaceValuePropertyKey: m_MinMaxSpaceValue = CoreUintType::deserialize(reader); return true; case copyFactorPropertyKey: m_CopyFactor = CoreDoubleType::deserialize(reader); return true; - case minValuePropertyKey: m_MinValue = CoreDoubleType::deserialize(reader); return true; - case maxValuePropertyKey: m_MaxValue = CoreDoubleType::deserialize(reader); return true; - case offsetPropertyKey: m_Offset = CoreBoolType::deserialize(reader); return true; - case doesCopyPropertyKey: m_DoesCopy = CoreBoolType::deserialize(reader); return true; - case minPropertyKey: m_Min = CoreBoolType::deserialize(reader); return true; - case maxPropertyKey: m_Max = CoreBoolType::deserialize(reader); return true; + case minValuePropertyKey: + m_MinValue = CoreDoubleType::deserialize(reader); + return true; + case maxValuePropertyKey: + m_MaxValue = CoreDoubleType::deserialize(reader); + return true; + case offsetPropertyKey: + m_Offset = CoreBoolType::deserialize(reader); + return true; + case doesCopyPropertyKey: + m_DoesCopy = CoreBoolType::deserialize(reader); + return true; + case minPropertyKey: + m_Min = CoreBoolType::deserialize(reader); + return true; + case maxPropertyKey: + m_Max = CoreBoolType::deserialize(reader); + return true; } return TransformSpaceConstraint::deserialize(propertyKey, reader); }
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 1dbb2cd..eea8b04 100644 --- a/include/rive/generated/constraints/transform_component_constraint_y_base.hpp +++ b/include/rive/generated/constraints/transform_component_constraint_y_base.hpp
@@ -3,8 +3,10 @@ #include "rive/constraints/transform_component_constraint.hpp" #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class TransformComponentConstraintYBase : public TransformComponentConstraint { +namespace rive +{ +class TransformComponentConstraintYBase : public TransformComponentConstraint +{ protected: typedef TransformComponentConstraint Super; @@ -13,15 +15,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransformComponentConstraintYBase::typeKey: case TransformComponentConstraintBase::typeKey: case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -44,8 +50,10 @@ public: inline float copyFactorY() const { return m_CopyFactorY; } - void copyFactorY(float value) { - if (m_CopyFactorY == value) { + void copyFactorY(float value) + { + if (m_CopyFactorY == value) + { return; } m_CopyFactorY = value; @@ -53,8 +61,10 @@ } inline float minValueY() const { return m_MinValueY; } - void minValueY(float value) { - if (m_MinValueY == value) { + void minValueY(float value) + { + if (m_MinValueY == value) + { return; } m_MinValueY = value; @@ -62,8 +72,10 @@ } inline float maxValueY() const { return m_MaxValueY; } - void maxValueY(float value) { - if (m_MaxValueY == value) { + void maxValueY(float value) + { + if (m_MaxValueY == value) + { return; } m_MaxValueY = value; @@ -71,8 +83,10 @@ } inline bool doesCopyY() const { return m_DoesCopyY; } - void doesCopyY(bool value) { - if (m_DoesCopyY == value) { + void doesCopyY(bool value) + { + if (m_DoesCopyY == value) + { return; } m_DoesCopyY = value; @@ -80,8 +94,10 @@ } inline bool minY() const { return m_MinY; } - void minY(bool value) { - if (m_MinY == value) { + void minY(bool value) + { + if (m_MinY == value) + { return; } m_MinY = value; @@ -89,15 +105,18 @@ } inline bool maxY() const { return m_MaxY; } - void maxY(bool value) { - if (m_MaxY == value) { + void maxY(bool value) + { + if (m_MaxY == value) + { return; } m_MaxY = value; maxYChanged(); } - void copy(const TransformComponentConstraintYBase& object) { + void copy(const TransformComponentConstraintYBase& object) + { m_CopyFactorY = object.m_CopyFactorY; m_MinValueY = object.m_MinValueY; m_MaxValueY = object.m_MaxValueY; @@ -107,8 +126,10 @@ TransformComponentConstraint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case copyFactorYPropertyKey: m_CopyFactorY = CoreDoubleType::deserialize(reader); return true; @@ -118,9 +139,15 @@ case maxValueYPropertyKey: m_MaxValueY = CoreDoubleType::deserialize(reader); return true; - case doesCopyYPropertyKey: m_DoesCopyY = CoreBoolType::deserialize(reader); return true; - case minYPropertyKey: m_MinY = CoreBoolType::deserialize(reader); return true; - case maxYPropertyKey: m_MaxY = CoreBoolType::deserialize(reader); return true; + case doesCopyYPropertyKey: + m_DoesCopyY = CoreBoolType::deserialize(reader); + return true; + case minYPropertyKey: + m_MinY = CoreBoolType::deserialize(reader); + return true; + case maxYPropertyKey: + m_MaxY = CoreBoolType::deserialize(reader); + return true; } return TransformComponentConstraint::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/constraints/transform_constraint_base.hpp b/include/rive/generated/constraints/transform_constraint_base.hpp index c265ef9..80ffb0e 100644 --- a/include/rive/generated/constraints/transform_constraint_base.hpp +++ b/include/rive/generated/constraints/transform_constraint_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_TRANSFORM_CONSTRAINT_BASE_HPP_ #define _RIVE_TRANSFORM_CONSTRAINT_BASE_HPP_ #include "rive/constraints/transform_space_constraint.hpp" -namespace rive { -class TransformConstraintBase : public TransformSpaceConstraint { +namespace rive +{ +class TransformConstraintBase : public TransformSpaceConstraint +{ protected: typedef TransformSpaceConstraint Super; @@ -11,14 +13,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransformConstraintBase::typeKey: case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/constraints/transform_space_constraint_base.hpp b/include/rive/generated/constraints/transform_space_constraint_base.hpp index 159c398..29f4466 100644 --- a/include/rive/generated/constraints/transform_space_constraint_base.hpp +++ b/include/rive/generated/constraints/transform_space_constraint_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSFORM_SPACE_CONSTRAINT_BASE_HPP_ #include "rive/constraints/targeted_constraint.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TransformSpaceConstraintBase : public TargetedConstraint { +namespace rive +{ +class TransformSpaceConstraintBase : public TargetedConstraint +{ protected: typedef TargetedConstraint Super; @@ -12,13 +14,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -33,8 +39,10 @@ public: inline uint32_t sourceSpaceValue() const { return m_SourceSpaceValue; } - void sourceSpaceValue(uint32_t value) { - if (m_SourceSpaceValue == value) { + void sourceSpaceValue(uint32_t value) + { + if (m_SourceSpaceValue == value) + { return; } m_SourceSpaceValue = value; @@ -42,22 +50,27 @@ } inline uint32_t destSpaceValue() const { return m_DestSpaceValue; } - void destSpaceValue(uint32_t value) { - if (m_DestSpaceValue == value) { + void destSpaceValue(uint32_t value) + { + if (m_DestSpaceValue == value) + { return; } m_DestSpaceValue = value; destSpaceValueChanged(); } - void copy(const TransformSpaceConstraintBase& object) { + void copy(const TransformSpaceConstraintBase& object) + { m_SourceSpaceValue = object.m_SourceSpaceValue; m_DestSpaceValue = object.m_DestSpaceValue; TargetedConstraint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case sourceSpaceValuePropertyKey: m_SourceSpaceValue = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/constraints/translation_constraint_base.hpp b/include/rive/generated/constraints/translation_constraint_base.hpp index bb20d98..26c9751 100644 --- a/include/rive/generated/constraints/translation_constraint_base.hpp +++ b/include/rive/generated/constraints/translation_constraint_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_TRANSLATION_CONSTRAINT_BASE_HPP_ #define _RIVE_TRANSLATION_CONSTRAINT_BASE_HPP_ #include "rive/constraints/transform_component_constraint_y.hpp" -namespace rive { -class TranslationConstraintBase : public TransformComponentConstraintY { +namespace rive +{ +class TranslationConstraintBase : public TransformComponentConstraintY +{ protected: typedef TransformComponentConstraintY Super; @@ -11,16 +13,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TranslationConstraintBase::typeKey: case TransformComponentConstraintYBase::typeKey: case TransformComponentConstraintBase::typeKey: case TransformSpaceConstraintBase::typeKey: case TargetedConstraintBase::typeKey: case ConstraintBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/container_component_base.hpp b/include/rive/generated/container_component_base.hpp index f50a795..7bdb624 100644 --- a/include/rive/generated/container_component_base.hpp +++ b/include/rive/generated/container_component_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CONTAINER_COMPONENT_BASE_HPP_ #define _RIVE_CONTAINER_COMPONENT_BASE_HPP_ #include "rive/component.hpp" -namespace rive { -class ContainerComponentBase : public Component { +namespace rive +{ +class ContainerComponentBase : public Component +{ protected: typedef Component Super; @@ -11,11 +13,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/core_registry.hpp b/include/rive/generated/core_registry.hpp index 9e05402..73f965a 100644 --- a/include/rive/generated/core_registry.hpp +++ b/include/rive/generated/core_registry.hpp
@@ -116,108 +116,204 @@ #include "rive/shapes/vertex.hpp" #include "rive/transform_component.hpp" #include "rive/world_transform_component.hpp" -namespace rive { -class CoreRegistry { +namespace rive +{ +class CoreRegistry +{ public: - static Core* makeCoreInstance(int typeKey) { - switch (typeKey) { - case DrawTargetBase::typeKey: return new DrawTarget(); - case DistanceConstraintBase::typeKey: return new DistanceConstraint(); - case IKConstraintBase::typeKey: return new IKConstraint(); - case TranslationConstraintBase::typeKey: return new TranslationConstraint(); - case TransformConstraintBase::typeKey: return new TransformConstraint(); - case ScaleConstraintBase::typeKey: return new ScaleConstraint(); - case RotationConstraintBase::typeKey: return new RotationConstraint(); - case NodeBase::typeKey: return new Node(); - case NestedArtboardBase::typeKey: return new NestedArtboard(); - case NestedSimpleAnimationBase::typeKey: return new NestedSimpleAnimation(); - case AnimationStateBase::typeKey: return new AnimationState(); - case NestedTriggerBase::typeKey: return new NestedTrigger(); - case KeyedObjectBase::typeKey: return new KeyedObject(); - case BlendAnimationDirectBase::typeKey: return new BlendAnimationDirect(); - case StateMachineNumberBase::typeKey: return new StateMachineNumber(); - case TransitionTriggerConditionBase::typeKey: return new TransitionTriggerCondition(); - case KeyedPropertyBase::typeKey: return new KeyedProperty(); - case StateMachineListenerBase::typeKey: return new StateMachineListener(); - case KeyFrameIdBase::typeKey: return new KeyFrameId(); - case KeyFrameBoolBase::typeKey: return new KeyFrameBool(); - case ListenerBoolChangeBase::typeKey: return new ListenerBoolChange(); - case ListenerAlignTargetBase::typeKey: return new ListenerAlignTarget(); - case TransitionNumberConditionBase::typeKey: return new TransitionNumberCondition(); - case AnyStateBase::typeKey: return new AnyState(); - case StateMachineLayerBase::typeKey: return new StateMachineLayer(); - case AnimationBase::typeKey: return new Animation(); - case ListenerNumberChangeBase::typeKey: return new ListenerNumberChange(); - case CubicInterpolatorBase::typeKey: return new CubicInterpolator(); - case StateTransitionBase::typeKey: return new StateTransition(); - case NestedBoolBase::typeKey: return new NestedBool(); - case KeyFrameDoubleBase::typeKey: return new KeyFrameDouble(); - case KeyFrameColorBase::typeKey: return new KeyFrameColor(); - case StateMachineBase::typeKey: return new StateMachine(); - case EntryStateBase::typeKey: return new EntryState(); - case LinearAnimationBase::typeKey: return new LinearAnimation(); - case StateMachineTriggerBase::typeKey: return new StateMachineTrigger(); - case ListenerTriggerChangeBase::typeKey: return new ListenerTriggerChange(); - case BlendStateDirectBase::typeKey: return new BlendStateDirect(); - case NestedStateMachineBase::typeKey: return new NestedStateMachine(); - case ExitStateBase::typeKey: return new ExitState(); - case NestedNumberBase::typeKey: return new NestedNumber(); - case BlendState1DBase::typeKey: return new BlendState1D(); - case NestedRemapAnimationBase::typeKey: return new NestedRemapAnimation(); - case TransitionBoolConditionBase::typeKey: return new TransitionBoolCondition(); - case BlendStateTransitionBase::typeKey: return new BlendStateTransition(); - case StateMachineBoolBase::typeKey: return new StateMachineBool(); - case BlendAnimation1DBase::typeKey: return new BlendAnimation1D(); - case LinearGradientBase::typeKey: return new LinearGradient(); - case RadialGradientBase::typeKey: return new RadialGradient(); - case StrokeBase::typeKey: return new Stroke(); - case SolidColorBase::typeKey: return new SolidColor(); - case GradientStopBase::typeKey: return new GradientStop(); - case TrimPathBase::typeKey: return new TrimPath(); - case FillBase::typeKey: return new Fill(); - case MeshVertexBase::typeKey: return new MeshVertex(); - case ShapeBase::typeKey: return new Shape(); - case StraightVertexBase::typeKey: return new StraightVertex(); - case CubicAsymmetricVertexBase::typeKey: return new CubicAsymmetricVertex(); - case MeshBase::typeKey: return new Mesh(); - case PointsPathBase::typeKey: return new PointsPath(); - case ContourMeshVertexBase::typeKey: return new ContourMeshVertex(); - case RectangleBase::typeKey: return new Rectangle(); - case CubicMirroredVertexBase::typeKey: return new CubicMirroredVertex(); - case TriangleBase::typeKey: return new Triangle(); - case EllipseBase::typeKey: return new Ellipse(); - case ClippingShapeBase::typeKey: return new ClippingShape(); - case PolygonBase::typeKey: return new Polygon(); - case StarBase::typeKey: return new Star(); - case ImageBase::typeKey: return new Image(); - case CubicDetachedVertexBase::typeKey: return new CubicDetachedVertex(); - case DrawRulesBase::typeKey: return new DrawRules(); - case ArtboardBase::typeKey: return new Artboard(); - case BackboardBase::typeKey: return new Backboard(); - case WeightBase::typeKey: return new Weight(); - case BoneBase::typeKey: return new Bone(); - case RootBoneBase::typeKey: return new RootBone(); - case SkinBase::typeKey: return new Skin(); - case TendonBase::typeKey: return new Tendon(); - case CubicWeightBase::typeKey: return new CubicWeight(); - case FolderBase::typeKey: return new Folder(); - case ImageAssetBase::typeKey: return new ImageAsset(); - case FileAssetContentsBase::typeKey: return new FileAssetContents(); + static Core* makeCoreInstance(int typeKey) + { + switch (typeKey) + { + case DrawTargetBase::typeKey: + return new DrawTarget(); + case DistanceConstraintBase::typeKey: + return new DistanceConstraint(); + case IKConstraintBase::typeKey: + return new IKConstraint(); + case TranslationConstraintBase::typeKey: + return new TranslationConstraint(); + case TransformConstraintBase::typeKey: + return new TransformConstraint(); + case ScaleConstraintBase::typeKey: + return new ScaleConstraint(); + case RotationConstraintBase::typeKey: + return new RotationConstraint(); + case NodeBase::typeKey: + return new Node(); + case NestedArtboardBase::typeKey: + return new NestedArtboard(); + case NestedSimpleAnimationBase::typeKey: + return new NestedSimpleAnimation(); + case AnimationStateBase::typeKey: + return new AnimationState(); + case NestedTriggerBase::typeKey: + return new NestedTrigger(); + case KeyedObjectBase::typeKey: + return new KeyedObject(); + case BlendAnimationDirectBase::typeKey: + return new BlendAnimationDirect(); + case StateMachineNumberBase::typeKey: + return new StateMachineNumber(); + case TransitionTriggerConditionBase::typeKey: + return new TransitionTriggerCondition(); + case KeyedPropertyBase::typeKey: + return new KeyedProperty(); + case StateMachineListenerBase::typeKey: + return new StateMachineListener(); + case KeyFrameIdBase::typeKey: + return new KeyFrameId(); + case KeyFrameBoolBase::typeKey: + return new KeyFrameBool(); + case ListenerBoolChangeBase::typeKey: + return new ListenerBoolChange(); + case ListenerAlignTargetBase::typeKey: + return new ListenerAlignTarget(); + case TransitionNumberConditionBase::typeKey: + return new TransitionNumberCondition(); + case AnyStateBase::typeKey: + return new AnyState(); + case StateMachineLayerBase::typeKey: + return new StateMachineLayer(); + case AnimationBase::typeKey: + return new Animation(); + case ListenerNumberChangeBase::typeKey: + return new ListenerNumberChange(); + case CubicInterpolatorBase::typeKey: + return new CubicInterpolator(); + case StateTransitionBase::typeKey: + return new StateTransition(); + case NestedBoolBase::typeKey: + return new NestedBool(); + case KeyFrameDoubleBase::typeKey: + return new KeyFrameDouble(); + case KeyFrameColorBase::typeKey: + return new KeyFrameColor(); + case StateMachineBase::typeKey: + return new StateMachine(); + case EntryStateBase::typeKey: + return new EntryState(); + case LinearAnimationBase::typeKey: + return new LinearAnimation(); + case StateMachineTriggerBase::typeKey: + return new StateMachineTrigger(); + case ListenerTriggerChangeBase::typeKey: + return new ListenerTriggerChange(); + case BlendStateDirectBase::typeKey: + return new BlendStateDirect(); + case NestedStateMachineBase::typeKey: + return new NestedStateMachine(); + case ExitStateBase::typeKey: + return new ExitState(); + case NestedNumberBase::typeKey: + return new NestedNumber(); + case BlendState1DBase::typeKey: + return new BlendState1D(); + case NestedRemapAnimationBase::typeKey: + return new NestedRemapAnimation(); + case TransitionBoolConditionBase::typeKey: + return new TransitionBoolCondition(); + case BlendStateTransitionBase::typeKey: + return new BlendStateTransition(); + case StateMachineBoolBase::typeKey: + return new StateMachineBool(); + case BlendAnimation1DBase::typeKey: + return new BlendAnimation1D(); + case LinearGradientBase::typeKey: + return new LinearGradient(); + case RadialGradientBase::typeKey: + return new RadialGradient(); + case StrokeBase::typeKey: + return new Stroke(); + case SolidColorBase::typeKey: + return new SolidColor(); + case GradientStopBase::typeKey: + return new GradientStop(); + case TrimPathBase::typeKey: + return new TrimPath(); + case FillBase::typeKey: + return new Fill(); + case MeshVertexBase::typeKey: + return new MeshVertex(); + case ShapeBase::typeKey: + return new Shape(); + case StraightVertexBase::typeKey: + return new StraightVertex(); + case CubicAsymmetricVertexBase::typeKey: + return new CubicAsymmetricVertex(); + case MeshBase::typeKey: + return new Mesh(); + case PointsPathBase::typeKey: + return new PointsPath(); + case ContourMeshVertexBase::typeKey: + return new ContourMeshVertex(); + case RectangleBase::typeKey: + return new Rectangle(); + case CubicMirroredVertexBase::typeKey: + return new CubicMirroredVertex(); + case TriangleBase::typeKey: + return new Triangle(); + case EllipseBase::typeKey: + return new Ellipse(); + case ClippingShapeBase::typeKey: + return new ClippingShape(); + case PolygonBase::typeKey: + return new Polygon(); + case StarBase::typeKey: + return new Star(); + case ImageBase::typeKey: + return new Image(); + case CubicDetachedVertexBase::typeKey: + return new CubicDetachedVertex(); + case DrawRulesBase::typeKey: + return new DrawRules(); + case ArtboardBase::typeKey: + return new Artboard(); + case BackboardBase::typeKey: + return new Backboard(); + case WeightBase::typeKey: + return new Weight(); + case BoneBase::typeKey: + return new Bone(); + case RootBoneBase::typeKey: + return new RootBone(); + case SkinBase::typeKey: + return new Skin(); + case TendonBase::typeKey: + return new Tendon(); + case CubicWeightBase::typeKey: + return new CubicWeight(); + case FolderBase::typeKey: + return new Folder(); + case ImageAssetBase::typeKey: + return new ImageAsset(); + case FileAssetContentsBase::typeKey: + return new FileAssetContents(); } return nullptr; } - static void setString(Core* object, int propertyKey, std::string value) { - switch (propertyKey) { - case ComponentBase::namePropertyKey: object->as<ComponentBase>()->name(value); break; + static void setString(Core* object, int propertyKey, std::string value) + { + switch (propertyKey) + { + case ComponentBase::namePropertyKey: + object->as<ComponentBase>()->name(value); + break; case StateMachineComponentBase::namePropertyKey: object->as<StateMachineComponentBase>()->name(value); break; - case AnimationBase::namePropertyKey: object->as<AnimationBase>()->name(value); break; - case AssetBase::namePropertyKey: object->as<AssetBase>()->name(value); break; + case AnimationBase::namePropertyKey: + object->as<AnimationBase>()->name(value); + break; + case AssetBase::namePropertyKey: + object->as<AssetBase>()->name(value); + break; } } - static void setUint(Core* object, int propertyKey, uint32_t value) { - switch (propertyKey) { + static void setUint(Core* object, int propertyKey, uint32_t value) + { + switch (propertyKey) + { case ComponentBase::parentIdPropertyKey: object->as<ComponentBase>()->parentId(value); break; @@ -287,7 +383,9 @@ case StateMachineListenerBase::listenerTypeValuePropertyKey: object->as<StateMachineListenerBase>()->listenerTypeValue(value); break; - case KeyFrameBase::framePropertyKey: object->as<KeyFrameBase>()->frame(value); break; + case KeyFrameBase::framePropertyKey: + object->as<KeyFrameBase>()->frame(value); + break; case KeyFrameBase::interpolationTypePropertyKey: object->as<KeyFrameBase>()->interpolationType(value); break; @@ -339,30 +437,48 @@ case BlendStateTransitionBase::exitBlendAnimationIdPropertyKey: object->as<BlendStateTransitionBase>()->exitBlendAnimationId(value); break; - case StrokeBase::capPropertyKey: object->as<StrokeBase>()->cap(value); break; - case StrokeBase::joinPropertyKey: object->as<StrokeBase>()->join(value); break; + case StrokeBase::capPropertyKey: + object->as<StrokeBase>()->cap(value); + break; + case StrokeBase::joinPropertyKey: + object->as<StrokeBase>()->join(value); + break; case TrimPathBase::modeValuePropertyKey: object->as<TrimPathBase>()->modeValue(value); break; - case FillBase::fillRulePropertyKey: object->as<FillBase>()->fillRule(value); break; - case PathBase::pathFlagsPropertyKey: object->as<PathBase>()->pathFlags(value); break; + case FillBase::fillRulePropertyKey: + object->as<FillBase>()->fillRule(value); + break; + case PathBase::pathFlagsPropertyKey: + object->as<PathBase>()->pathFlags(value); + break; case ClippingShapeBase::sourceIdPropertyKey: object->as<ClippingShapeBase>()->sourceId(value); break; case ClippingShapeBase::fillRulePropertyKey: object->as<ClippingShapeBase>()->fillRule(value); break; - case PolygonBase::pointsPropertyKey: object->as<PolygonBase>()->points(value); break; - case ImageBase::assetIdPropertyKey: object->as<ImageBase>()->assetId(value); break; + case PolygonBase::pointsPropertyKey: + object->as<PolygonBase>()->points(value); + break; + case ImageBase::assetIdPropertyKey: + object->as<ImageBase>()->assetId(value); + break; case DrawRulesBase::drawTargetIdPropertyKey: object->as<DrawRulesBase>()->drawTargetId(value); break; case ArtboardBase::defaultStateMachineIdPropertyKey: object->as<ArtboardBase>()->defaultStateMachineId(value); break; - case WeightBase::valuesPropertyKey: object->as<WeightBase>()->values(value); break; - case WeightBase::indicesPropertyKey: object->as<WeightBase>()->indices(value); break; - case TendonBase::boneIdPropertyKey: object->as<TendonBase>()->boneId(value); break; + case WeightBase::valuesPropertyKey: + object->as<WeightBase>()->values(value); + break; + case WeightBase::indicesPropertyKey: + object->as<WeightBase>()->indices(value); + break; + case TendonBase::boneIdPropertyKey: + object->as<TendonBase>()->boneId(value); + break; case CubicWeightBase::inValuesPropertyKey: object->as<CubicWeightBase>()->inValues(value); break; @@ -380,8 +496,10 @@ break; } } - static void setDouble(Core* object, int propertyKey, float value) { - switch (propertyKey) { + static void setDouble(Core* object, int propertyKey, float value) + { + switch (propertyKey) + { case ConstraintBase::strengthPropertyKey: object->as<ConstraintBase>()->strength(value); break; @@ -418,8 +536,12 @@ case TransformComponentBase::scaleYPropertyKey: object->as<TransformComponentBase>()->scaleY(value); break; - case NodeBase::xPropertyKey: object->as<NodeBase>()->x(value); break; - case NodeBase::yPropertyKey: object->as<NodeBase>()->y(value); break; + case NodeBase::xPropertyKey: + object->as<NodeBase>()->x(value); + break; + case NodeBase::yPropertyKey: + object->as<NodeBase>()->y(value); + break; case NestedLinearAnimationBase::mixPropertyKey: object->as<NestedLinearAnimationBase>()->mix(value); break; @@ -483,13 +605,27 @@ case GradientStopBase::positionPropertyKey: object->as<GradientStopBase>()->position(value); break; - case TrimPathBase::startPropertyKey: object->as<TrimPathBase>()->start(value); break; - case TrimPathBase::endPropertyKey: object->as<TrimPathBase>()->end(value); break; - case TrimPathBase::offsetPropertyKey: object->as<TrimPathBase>()->offset(value); break; - case VertexBase::xPropertyKey: object->as<VertexBase>()->x(value); break; - case VertexBase::yPropertyKey: object->as<VertexBase>()->y(value); break; - case MeshVertexBase::uPropertyKey: object->as<MeshVertexBase>()->u(value); break; - case MeshVertexBase::vPropertyKey: object->as<MeshVertexBase>()->v(value); break; + case TrimPathBase::startPropertyKey: + object->as<TrimPathBase>()->start(value); + break; + case TrimPathBase::endPropertyKey: + object->as<TrimPathBase>()->end(value); + break; + case TrimPathBase::offsetPropertyKey: + object->as<TrimPathBase>()->offset(value); + break; + case VertexBase::xPropertyKey: + object->as<VertexBase>()->x(value); + break; + case VertexBase::yPropertyKey: + object->as<VertexBase>()->y(value); + break; + case MeshVertexBase::uPropertyKey: + object->as<MeshVertexBase>()->u(value); + break; + case MeshVertexBase::vPropertyKey: + object->as<MeshVertexBase>()->v(value); + break; case StraightVertexBase::radiusPropertyKey: object->as<StraightVertexBase>()->radius(value); break; @@ -550,31 +686,69 @@ case CubicDetachedVertexBase::outDistancePropertyKey: object->as<CubicDetachedVertexBase>()->outDistance(value); break; - case ArtboardBase::widthPropertyKey: object->as<ArtboardBase>()->width(value); break; - case ArtboardBase::heightPropertyKey: object->as<ArtboardBase>()->height(value); break; - case ArtboardBase::xPropertyKey: object->as<ArtboardBase>()->x(value); break; - case ArtboardBase::yPropertyKey: object->as<ArtboardBase>()->y(value); break; + case ArtboardBase::widthPropertyKey: + object->as<ArtboardBase>()->width(value); + break; + case ArtboardBase::heightPropertyKey: + object->as<ArtboardBase>()->height(value); + break; + case ArtboardBase::xPropertyKey: + object->as<ArtboardBase>()->x(value); + break; + case ArtboardBase::yPropertyKey: + object->as<ArtboardBase>()->y(value); + break; case ArtboardBase::originXPropertyKey: object->as<ArtboardBase>()->originX(value); break; case ArtboardBase::originYPropertyKey: object->as<ArtboardBase>()->originY(value); break; - case BoneBase::lengthPropertyKey: object->as<BoneBase>()->length(value); break; - case RootBoneBase::xPropertyKey: object->as<RootBoneBase>()->x(value); break; - case RootBoneBase::yPropertyKey: object->as<RootBoneBase>()->y(value); break; - case SkinBase::xxPropertyKey: object->as<SkinBase>()->xx(value); break; - case SkinBase::yxPropertyKey: object->as<SkinBase>()->yx(value); break; - case SkinBase::xyPropertyKey: object->as<SkinBase>()->xy(value); break; - case SkinBase::yyPropertyKey: object->as<SkinBase>()->yy(value); break; - case SkinBase::txPropertyKey: object->as<SkinBase>()->tx(value); break; - case SkinBase::tyPropertyKey: object->as<SkinBase>()->ty(value); break; - case TendonBase::xxPropertyKey: object->as<TendonBase>()->xx(value); break; - case TendonBase::yxPropertyKey: object->as<TendonBase>()->yx(value); break; - case TendonBase::xyPropertyKey: object->as<TendonBase>()->xy(value); break; - case TendonBase::yyPropertyKey: object->as<TendonBase>()->yy(value); break; - case TendonBase::txPropertyKey: object->as<TendonBase>()->tx(value); break; - case TendonBase::tyPropertyKey: object->as<TendonBase>()->ty(value); break; + case BoneBase::lengthPropertyKey: + object->as<BoneBase>()->length(value); + break; + case RootBoneBase::xPropertyKey: + object->as<RootBoneBase>()->x(value); + break; + case RootBoneBase::yPropertyKey: + object->as<RootBoneBase>()->y(value); + break; + case SkinBase::xxPropertyKey: + object->as<SkinBase>()->xx(value); + break; + case SkinBase::yxPropertyKey: + object->as<SkinBase>()->yx(value); + break; + case SkinBase::xyPropertyKey: + object->as<SkinBase>()->xy(value); + break; + case SkinBase::yyPropertyKey: + object->as<SkinBase>()->yy(value); + break; + case SkinBase::txPropertyKey: + object->as<SkinBase>()->tx(value); + break; + case SkinBase::tyPropertyKey: + object->as<SkinBase>()->ty(value); + break; + case TendonBase::xxPropertyKey: + object->as<TendonBase>()->xx(value); + break; + case TendonBase::yxPropertyKey: + object->as<TendonBase>()->yx(value); + break; + case TendonBase::xyPropertyKey: + object->as<TendonBase>()->xy(value); + break; + case TendonBase::yyPropertyKey: + object->as<TendonBase>()->yy(value); + break; + case TendonBase::txPropertyKey: + object->as<TendonBase>()->tx(value); + break; + case TendonBase::tyPropertyKey: + object->as<TendonBase>()->ty(value); + break; case DrawableAssetBase::heightPropertyKey: object->as<DrawableAssetBase>()->height(value); break; @@ -583,8 +757,10 @@ break; } } - static void setBool(Core* object, int propertyKey, bool value) { - switch (propertyKey) { + static void setBool(Core* object, int propertyKey, bool value) + { + switch (propertyKey) + { case TransformComponentConstraintBase::offsetPropertyKey: object->as<TransformComponentConstraintBase>()->offset(value); break; @@ -639,11 +815,15 @@ case ClippingShapeBase::isVisiblePropertyKey: object->as<ClippingShapeBase>()->isVisible(value); break; - case ArtboardBase::clipPropertyKey: object->as<ArtboardBase>()->clip(value); break; + case ArtboardBase::clipPropertyKey: + object->as<ArtboardBase>()->clip(value); + break; } } - static void setColor(Core* object, int propertyKey, int value) { - switch (propertyKey) { + static void setColor(Core* object, int propertyKey, int value) + { + switch (propertyKey) + { case KeyFrameColorBase::valuePropertyKey: object->as<KeyFrameColorBase>()->value(value); break; @@ -655,19 +835,27 @@ break; } } - static std::string getString(Core* object, int propertyKey) { - switch (propertyKey) { - case ComponentBase::namePropertyKey: return object->as<ComponentBase>()->name(); + static std::string getString(Core* object, int propertyKey) + { + switch (propertyKey) + { + case ComponentBase::namePropertyKey: + return object->as<ComponentBase>()->name(); case StateMachineComponentBase::namePropertyKey: return object->as<StateMachineComponentBase>()->name(); - case AnimationBase::namePropertyKey: return object->as<AnimationBase>()->name(); - case AssetBase::namePropertyKey: return object->as<AssetBase>()->name(); + case AnimationBase::namePropertyKey: + return object->as<AnimationBase>()->name(); + case AssetBase::namePropertyKey: + return object->as<AssetBase>()->name(); } return ""; } - static uint32_t getUint(Core* object, int propertyKey) { - switch (propertyKey) { - case ComponentBase::parentIdPropertyKey: return object->as<ComponentBase>()->parentId(); + static uint32_t getUint(Core* object, int propertyKey) + { + switch (propertyKey) + { + case ComponentBase::parentIdPropertyKey: + return object->as<ComponentBase>()->parentId(); case DrawTargetBase::drawableIdPropertyKey: return object->as<DrawTargetBase>()->drawableId(); case DrawTargetBase::placementValuePropertyKey: @@ -712,12 +900,14 @@ return object->as<StateMachineListenerBase>()->targetId(); case StateMachineListenerBase::listenerTypeValuePropertyKey: return object->as<StateMachineListenerBase>()->listenerTypeValue(); - case KeyFrameBase::framePropertyKey: return object->as<KeyFrameBase>()->frame(); + case KeyFrameBase::framePropertyKey: + return object->as<KeyFrameBase>()->frame(); case KeyFrameBase::interpolationTypePropertyKey: return object->as<KeyFrameBase>()->interpolationType(); case KeyFrameBase::interpolatorIdPropertyKey: return object->as<KeyFrameBase>()->interpolatorId(); - case KeyFrameIdBase::valuePropertyKey: return object->as<KeyFrameIdBase>()->value(); + case KeyFrameIdBase::valuePropertyKey: + return object->as<KeyFrameIdBase>()->value(); case ListenerBoolChangeBase::valuePropertyKey: return object->as<ListenerBoolChangeBase>()->value(); case ListenerAlignTargetBase::targetIdPropertyKey: @@ -746,24 +936,34 @@ return object->as<BlendState1DBase>()->inputId(); case BlendStateTransitionBase::exitBlendAnimationIdPropertyKey: return object->as<BlendStateTransitionBase>()->exitBlendAnimationId(); - case StrokeBase::capPropertyKey: return object->as<StrokeBase>()->cap(); - case StrokeBase::joinPropertyKey: return object->as<StrokeBase>()->join(); - case TrimPathBase::modeValuePropertyKey: return object->as<TrimPathBase>()->modeValue(); - case FillBase::fillRulePropertyKey: return object->as<FillBase>()->fillRule(); - case PathBase::pathFlagsPropertyKey: return object->as<PathBase>()->pathFlags(); + case StrokeBase::capPropertyKey: + return object->as<StrokeBase>()->cap(); + case StrokeBase::joinPropertyKey: + return object->as<StrokeBase>()->join(); + case TrimPathBase::modeValuePropertyKey: + return object->as<TrimPathBase>()->modeValue(); + case FillBase::fillRulePropertyKey: + return object->as<FillBase>()->fillRule(); + case PathBase::pathFlagsPropertyKey: + return object->as<PathBase>()->pathFlags(); case ClippingShapeBase::sourceIdPropertyKey: return object->as<ClippingShapeBase>()->sourceId(); case ClippingShapeBase::fillRulePropertyKey: return object->as<ClippingShapeBase>()->fillRule(); - case PolygonBase::pointsPropertyKey: return object->as<PolygonBase>()->points(); - case ImageBase::assetIdPropertyKey: return object->as<ImageBase>()->assetId(); + case PolygonBase::pointsPropertyKey: + return object->as<PolygonBase>()->points(); + case ImageBase::assetIdPropertyKey: + return object->as<ImageBase>()->assetId(); case DrawRulesBase::drawTargetIdPropertyKey: return object->as<DrawRulesBase>()->drawTargetId(); case ArtboardBase::defaultStateMachineIdPropertyKey: return object->as<ArtboardBase>()->defaultStateMachineId(); - case WeightBase::valuesPropertyKey: return object->as<WeightBase>()->values(); - case WeightBase::indicesPropertyKey: return object->as<WeightBase>()->indices(); - case TendonBase::boneIdPropertyKey: return object->as<TendonBase>()->boneId(); + case WeightBase::valuesPropertyKey: + return object->as<WeightBase>()->values(); + case WeightBase::indicesPropertyKey: + return object->as<WeightBase>()->indices(); + case TendonBase::boneIdPropertyKey: + return object->as<TendonBase>()->boneId(); case CubicWeightBase::inValuesPropertyKey: return object->as<CubicWeightBase>()->inValues(); case CubicWeightBase::inIndicesPropertyKey: @@ -772,12 +972,15 @@ return object->as<CubicWeightBase>()->outValues(); case CubicWeightBase::outIndicesPropertyKey: return object->as<CubicWeightBase>()->outIndices(); - case FileAssetBase::assetIdPropertyKey: return object->as<FileAssetBase>()->assetId(); + case FileAssetBase::assetIdPropertyKey: + return object->as<FileAssetBase>()->assetId(); } return 0; } - static float getDouble(Core* object, int propertyKey) { - switch (propertyKey) { + static float getDouble(Core* object, int propertyKey) + { + switch (propertyKey) + { case ConstraintBase::strengthPropertyKey: return object->as<ConstraintBase>()->strength(); case DistanceConstraintBase::distancePropertyKey: @@ -802,8 +1005,10 @@ return object->as<TransformComponentBase>()->scaleX(); case TransformComponentBase::scaleYPropertyKey: return object->as<TransformComponentBase>()->scaleY(); - case NodeBase::xPropertyKey: return object->as<NodeBase>()->x(); - case NodeBase::yPropertyKey: return object->as<NodeBase>()->y(); + case NodeBase::xPropertyKey: + return object->as<NodeBase>()->x(); + case NodeBase::yPropertyKey: + return object->as<NodeBase>()->y(); case NestedLinearAnimationBase::mixPropertyKey: return object->as<NestedLinearAnimationBase>()->mix(); case NestedSimpleAnimationBase::speedPropertyKey: @@ -842,16 +1047,24 @@ return object->as<LinearGradientBase>()->endY(); case LinearGradientBase::opacityPropertyKey: return object->as<LinearGradientBase>()->opacity(); - case StrokeBase::thicknessPropertyKey: return object->as<StrokeBase>()->thickness(); + case StrokeBase::thicknessPropertyKey: + return object->as<StrokeBase>()->thickness(); case GradientStopBase::positionPropertyKey: return object->as<GradientStopBase>()->position(); - case TrimPathBase::startPropertyKey: return object->as<TrimPathBase>()->start(); - case TrimPathBase::endPropertyKey: return object->as<TrimPathBase>()->end(); - case TrimPathBase::offsetPropertyKey: return object->as<TrimPathBase>()->offset(); - case VertexBase::xPropertyKey: return object->as<VertexBase>()->x(); - case VertexBase::yPropertyKey: return object->as<VertexBase>()->y(); - case MeshVertexBase::uPropertyKey: return object->as<MeshVertexBase>()->u(); - case MeshVertexBase::vPropertyKey: return object->as<MeshVertexBase>()->v(); + case TrimPathBase::startPropertyKey: + return object->as<TrimPathBase>()->start(); + case TrimPathBase::endPropertyKey: + return object->as<TrimPathBase>()->end(); + case TrimPathBase::offsetPropertyKey: + return object->as<TrimPathBase>()->offset(); + case VertexBase::xPropertyKey: + return object->as<VertexBase>()->x(); + case VertexBase::yPropertyKey: + return object->as<VertexBase>()->y(); + case MeshVertexBase::uPropertyKey: + return object->as<MeshVertexBase>()->u(); + case MeshVertexBase::vPropertyKey: + return object->as<MeshVertexBase>()->v(); case StraightVertexBase::radiusPropertyKey: return object->as<StraightVertexBase>()->radius(); case CubicAsymmetricVertexBase::rotationPropertyKey: @@ -882,7 +1095,8 @@ return object->as<CubicMirroredVertexBase>()->distance(); case PolygonBase::cornerRadiusPropertyKey: return object->as<PolygonBase>()->cornerRadius(); - case StarBase::innerRadiusPropertyKey: return object->as<StarBase>()->innerRadius(); + case StarBase::innerRadiusPropertyKey: + return object->as<StarBase>()->innerRadius(); case CubicDetachedVertexBase::inRotationPropertyKey: return object->as<CubicDetachedVertexBase>()->inRotation(); case CubicDetachedVertexBase::inDistancePropertyKey: @@ -891,27 +1105,48 @@ return object->as<CubicDetachedVertexBase>()->outRotation(); case CubicDetachedVertexBase::outDistancePropertyKey: return object->as<CubicDetachedVertexBase>()->outDistance(); - case ArtboardBase::widthPropertyKey: return object->as<ArtboardBase>()->width(); - case ArtboardBase::heightPropertyKey: return object->as<ArtboardBase>()->height(); - case ArtboardBase::xPropertyKey: return object->as<ArtboardBase>()->x(); - case ArtboardBase::yPropertyKey: return object->as<ArtboardBase>()->y(); - case ArtboardBase::originXPropertyKey: return object->as<ArtboardBase>()->originX(); - case ArtboardBase::originYPropertyKey: return object->as<ArtboardBase>()->originY(); - case BoneBase::lengthPropertyKey: return object->as<BoneBase>()->length(); - case RootBoneBase::xPropertyKey: return object->as<RootBoneBase>()->x(); - case RootBoneBase::yPropertyKey: return object->as<RootBoneBase>()->y(); - case SkinBase::xxPropertyKey: return object->as<SkinBase>()->xx(); - case SkinBase::yxPropertyKey: return object->as<SkinBase>()->yx(); - case SkinBase::xyPropertyKey: return object->as<SkinBase>()->xy(); - case SkinBase::yyPropertyKey: return object->as<SkinBase>()->yy(); - case SkinBase::txPropertyKey: return object->as<SkinBase>()->tx(); - case SkinBase::tyPropertyKey: return object->as<SkinBase>()->ty(); - case TendonBase::xxPropertyKey: return object->as<TendonBase>()->xx(); - case TendonBase::yxPropertyKey: return object->as<TendonBase>()->yx(); - case TendonBase::xyPropertyKey: return object->as<TendonBase>()->xy(); - case TendonBase::yyPropertyKey: return object->as<TendonBase>()->yy(); - case TendonBase::txPropertyKey: return object->as<TendonBase>()->tx(); - case TendonBase::tyPropertyKey: return object->as<TendonBase>()->ty(); + case ArtboardBase::widthPropertyKey: + return object->as<ArtboardBase>()->width(); + case ArtboardBase::heightPropertyKey: + return object->as<ArtboardBase>()->height(); + case ArtboardBase::xPropertyKey: + return object->as<ArtboardBase>()->x(); + case ArtboardBase::yPropertyKey: + return object->as<ArtboardBase>()->y(); + case ArtboardBase::originXPropertyKey: + return object->as<ArtboardBase>()->originX(); + case ArtboardBase::originYPropertyKey: + return object->as<ArtboardBase>()->originY(); + case BoneBase::lengthPropertyKey: + return object->as<BoneBase>()->length(); + case RootBoneBase::xPropertyKey: + return object->as<RootBoneBase>()->x(); + case RootBoneBase::yPropertyKey: + return object->as<RootBoneBase>()->y(); + case SkinBase::xxPropertyKey: + return object->as<SkinBase>()->xx(); + case SkinBase::yxPropertyKey: + return object->as<SkinBase>()->yx(); + case SkinBase::xyPropertyKey: + return object->as<SkinBase>()->xy(); + case SkinBase::yyPropertyKey: + return object->as<SkinBase>()->yy(); + case SkinBase::txPropertyKey: + return object->as<SkinBase>()->tx(); + case SkinBase::tyPropertyKey: + return object->as<SkinBase>()->ty(); + case TendonBase::xxPropertyKey: + return object->as<TendonBase>()->xx(); + case TendonBase::yxPropertyKey: + return object->as<TendonBase>()->yx(); + case TendonBase::xyPropertyKey: + return object->as<TendonBase>()->xy(); + case TendonBase::yyPropertyKey: + return object->as<TendonBase>()->yy(); + case TendonBase::txPropertyKey: + return object->as<TendonBase>()->tx(); + case TendonBase::tyPropertyKey: + return object->as<TendonBase>()->ty(); case DrawableAssetBase::heightPropertyKey: return object->as<DrawableAssetBase>()->height(); case DrawableAssetBase::widthPropertyKey: @@ -919,8 +1154,10 @@ } return 0.0f; } - static bool getBool(Core* object, int propertyKey) { - switch (propertyKey) { + static bool getBool(Core* object, int propertyKey) + { + switch (propertyKey) + { case TransformComponentConstraintBase::offsetPropertyKey: return object->as<TransformComponentConstraintBase>()->offset(); case TransformComponentConstraintBase::doesCopyPropertyKey: @@ -939,7 +1176,8 @@ return object->as<IKConstraintBase>()->invertDirection(); case NestedSimpleAnimationBase::isPlayingPropertyKey: return object->as<NestedSimpleAnimationBase>()->isPlaying(); - case KeyFrameBoolBase::valuePropertyKey: return object->as<KeyFrameBoolBase>()->value(); + case KeyFrameBoolBase::valuePropertyKey: + return object->as<KeyFrameBoolBase>()->value(); case NestedBoolBase::nestedValuePropertyKey: return object->as<NestedBoolBase>()->nestedValue(); case LinearAnimationBase::enableWorkAreaPropertyKey: @@ -956,12 +1194,15 @@ return object->as<RectangleBase>()->linkCornerRadius(); case ClippingShapeBase::isVisiblePropertyKey: return object->as<ClippingShapeBase>()->isVisible(); - case ArtboardBase::clipPropertyKey: return object->as<ArtboardBase>()->clip(); + case ArtboardBase::clipPropertyKey: + return object->as<ArtboardBase>()->clip(); } return false; } - static int getColor(Core* object, int propertyKey) { - switch (propertyKey) { + static int getColor(Core* object, int propertyKey) + { + switch (propertyKey) + { case KeyFrameColorBase::valuePropertyKey: return object->as<KeyFrameColorBase>()->value(); case SolidColorBase::colorValuePropertyKey: @@ -971,12 +1212,15 @@ } return 0; } - static int propertyFieldId(int propertyKey) { - switch (propertyKey) { + static int propertyFieldId(int propertyKey) + { + switch (propertyKey) + { case ComponentBase::namePropertyKey: case StateMachineComponentBase::namePropertyKey: case AnimationBase::namePropertyKey: - case AssetBase::namePropertyKey: return CoreStringType::id; + case AssetBase::namePropertyKey: + return CoreStringType::id; case ComponentBase::parentIdPropertyKey: case DrawTargetBase::drawableIdPropertyKey: case DrawTargetBase::placementValuePropertyKey: @@ -1036,7 +1280,8 @@ case CubicWeightBase::inIndicesPropertyKey: case CubicWeightBase::outValuesPropertyKey: case CubicWeightBase::outIndicesPropertyKey: - case FileAssetBase::assetIdPropertyKey: return CoreUintType::id; + case FileAssetBase::assetIdPropertyKey: + return CoreUintType::id; case ConstraintBase::strengthPropertyKey: case DistanceConstraintBase::distancePropertyKey: case TransformComponentConstraintBase::copyFactorPropertyKey: @@ -1121,7 +1366,8 @@ case TendonBase::txPropertyKey: case TendonBase::tyPropertyKey: case DrawableAssetBase::heightPropertyKey: - case DrawableAssetBase::widthPropertyKey: return CoreDoubleType::id; + case DrawableAssetBase::widthPropertyKey: + return CoreDoubleType::id; case TransformComponentConstraintBase::offsetPropertyKey: case TransformComponentConstraintBase::doesCopyPropertyKey: case TransformComponentConstraintBase::minPropertyKey: @@ -1140,13 +1386,17 @@ case PointsPathBase::isClosedPropertyKey: case RectangleBase::linkCornerRadiusPropertyKey: case ClippingShapeBase::isVisiblePropertyKey: - case ArtboardBase::clipPropertyKey: return CoreBoolType::id; + case ArtboardBase::clipPropertyKey: + return CoreBoolType::id; case KeyFrameColorBase::valuePropertyKey: case SolidColorBase::colorValuePropertyKey: - case GradientStopBase::colorValuePropertyKey: return CoreColorType::id; + case GradientStopBase::colorValuePropertyKey: + return CoreColorType::id; case MeshBase::triangleIndexBytesPropertyKey: - case FileAssetContentsBase::bytesPropertyKey: return CoreBytesType::id; - default: return -1; + case FileAssetContentsBase::bytesPropertyKey: + return CoreBytesType::id; + default: + return -1; } } };
diff --git a/include/rive/generated/draw_rules_base.hpp b/include/rive/generated/draw_rules_base.hpp index afada41..75b9cfd 100644 --- a/include/rive/generated/draw_rules_base.hpp +++ b/include/rive/generated/draw_rules_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DRAW_RULES_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class DrawRulesBase : public ContainerComponent { +namespace rive +{ +class DrawRulesBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case DrawRulesBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,8 +36,10 @@ public: inline uint32_t drawTargetId() const { return m_DrawTargetId; } - void drawTargetId(uint32_t value) { - if (m_DrawTargetId == value) { + void drawTargetId(uint32_t value) + { + if (m_DrawTargetId == value) + { return; } m_DrawTargetId = value; @@ -39,13 +47,16 @@ } Core* clone() const override; - void copy(const DrawRulesBase& object) { + void copy(const DrawRulesBase& object) + { m_DrawTargetId = object.m_DrawTargetId; ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case drawTargetIdPropertyKey: m_DrawTargetId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/draw_target_base.hpp b/include/rive/generated/draw_target_base.hpp index cee9d2c..0bc6ea4 100644 --- a/include/rive/generated/draw_target_base.hpp +++ b/include/rive/generated/draw_target_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DRAW_TARGET_BASE_HPP_ #include "rive/component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class DrawTargetBase : public Component { +namespace rive +{ +class DrawTargetBase : public Component +{ protected: typedef Component Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case DrawTargetBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,8 +37,10 @@ public: inline uint32_t drawableId() const { return m_DrawableId; } - void drawableId(uint32_t value) { - if (m_DrawableId == value) { + void drawableId(uint32_t value) + { + if (m_DrawableId == value) + { return; } m_DrawableId = value; @@ -40,8 +48,10 @@ } inline uint32_t placementValue() const { return m_PlacementValue; } - void placementValue(uint32_t value) { - if (m_PlacementValue == value) { + void placementValue(uint32_t value) + { + if (m_PlacementValue == value) + { return; } m_PlacementValue = value; @@ -49,14 +59,17 @@ } Core* clone() const override; - void copy(const DrawTargetBase& object) { + void copy(const DrawTargetBase& object) + { m_DrawableId = object.m_DrawableId; m_PlacementValue = object.m_PlacementValue; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case drawableIdPropertyKey: m_DrawableId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/drawable_base.hpp b/include/rive/generated/drawable_base.hpp index e5e8f03..0d617f5 100644 --- a/include/rive/generated/drawable_base.hpp +++ b/include/rive/generated/drawable_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_DRAWABLE_BASE_HPP_ #include "rive/core/field_types/core_uint_type.hpp" #include "rive/node.hpp" -namespace rive { -class DrawableBase : public Node { +namespace rive +{ +class DrawableBase : public Node +{ protected: typedef Node Super; @@ -12,15 +14,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case DrawableBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -35,8 +41,10 @@ public: inline uint32_t blendModeValue() const { return m_BlendModeValue; } - void blendModeValue(uint32_t value) { - if (m_BlendModeValue == value) { + void blendModeValue(uint32_t value) + { + if (m_BlendModeValue == value) + { return; } m_BlendModeValue = value; @@ -44,22 +52,27 @@ } inline uint32_t drawableFlags() const { return m_DrawableFlags; } - void drawableFlags(uint32_t value) { - if (m_DrawableFlags == value) { + void drawableFlags(uint32_t value) + { + if (m_DrawableFlags == value) + { return; } m_DrawableFlags = value; drawableFlagsChanged(); } - void copy(const DrawableBase& object) { + void copy(const DrawableBase& object) + { m_BlendModeValue = object.m_BlendModeValue; m_DrawableFlags = object.m_DrawableFlags; Node::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case blendModeValuePropertyKey: m_BlendModeValue = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/nested_animation_base.hpp b/include/rive/generated/nested_animation_base.hpp index 2277f9d..74ff2d7 100644 --- a/include/rive/generated/nested_animation_base.hpp +++ b/include/rive/generated/nested_animation_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_ANIMATION_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class NestedAnimationBase : public ContainerComponent { +namespace rive +{ +class NestedAnimationBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedAnimationBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,21 +36,26 @@ public: inline uint32_t animationId() const { return m_AnimationId; } - void animationId(uint32_t value) { - if (m_AnimationId == value) { + void animationId(uint32_t value) + { + if (m_AnimationId == value) + { return; } m_AnimationId = value; animationIdChanged(); } - void copy(const NestedAnimationBase& object) { + void copy(const NestedAnimationBase& object) + { m_AnimationId = object.m_AnimationId; ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case animationIdPropertyKey: m_AnimationId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/nested_artboard_base.hpp b/include/rive/generated/nested_artboard_base.hpp index 06e7152..ce5d874 100644 --- a/include/rive/generated/nested_artboard_base.hpp +++ b/include/rive/generated/nested_artboard_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NESTED_ARTBOARD_BASE_HPP_ #include "rive/core/field_types/core_uint_type.hpp" #include "rive/drawable.hpp" -namespace rive { -class NestedArtboardBase : public Drawable { +namespace rive +{ +class NestedArtboardBase : public Drawable +{ protected: typedef Drawable Super; @@ -12,16 +14,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NestedArtboardBase::typeKey: case DrawableBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline uint32_t artboardId() const { return m_ArtboardId; } - void artboardId(uint32_t value) { - if (m_ArtboardId == value) { + void artboardId(uint32_t value) + { + if (m_ArtboardId == value) + { return; } m_ArtboardId = value; @@ -43,13 +51,16 @@ } Core* clone() const override; - void copy(const NestedArtboardBase& object) { + void copy(const NestedArtboardBase& object) + { m_ArtboardId = object.m_ArtboardId; Drawable::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case artboardIdPropertyKey: m_ArtboardId = CoreUintType::deserialize(reader); return true;
diff --git a/include/rive/generated/node_base.hpp b/include/rive/generated/node_base.hpp index a9db1b5..f27da20 100644 --- a/include/rive/generated/node_base.hpp +++ b/include/rive/generated/node_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_NODE_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/transform_component.hpp" -namespace rive { -class NodeBase : public TransformComponent { +namespace rive +{ +class NodeBase : public TransformComponent +{ protected: typedef TransformComponent Super; @@ -12,14 +14,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline float x() const override { return m_X; } - void x(float value) { - if (m_X == value) { + void x(float value) + { + if (m_X == value) + { return; } m_X = value; @@ -43,8 +51,10 @@ } inline float y() const override { return m_Y; } - void y(float value) { - if (m_Y == value) { + void y(float value) + { + if (m_Y == value) + { return; } m_Y = value; @@ -52,16 +62,23 @@ } Core* clone() const override; - void copy(const NodeBase& object) { + void copy(const NodeBase& object) + { m_X = object.m_X; m_Y = object.m_Y; TransformComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case xPropertyKey: m_X = CoreDoubleType::deserialize(reader); return true; - case yPropertyKey: m_Y = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case xPropertyKey: + m_X = CoreDoubleType::deserialize(reader); + return true; + case yPropertyKey: + m_Y = CoreDoubleType::deserialize(reader); + return true; } return TransformComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/clipping_shape_base.hpp b/include/rive/generated/shapes/clipping_shape_base.hpp index 282b6d7..0f9a4c5 100644 --- a/include/rive/generated/shapes/clipping_shape_base.hpp +++ b/include/rive/generated/shapes/clipping_shape_base.hpp
@@ -3,8 +3,10 @@ #include "rive/component.hpp" #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class ClippingShapeBase : public Component { +namespace rive +{ +class ClippingShapeBase : public Component +{ protected: typedef Component Super; @@ -13,11 +15,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ClippingShapeBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline uint32_t sourceId() const { return m_SourceId; } - void sourceId(uint32_t value) { - if (m_SourceId == value) { + void sourceId(uint32_t value) + { + if (m_SourceId == value) + { return; } m_SourceId = value; @@ -43,8 +51,10 @@ } inline uint32_t fillRule() const { return m_FillRule; } - void fillRule(uint32_t value) { - if (m_FillRule == value) { + void fillRule(uint32_t value) + { + if (m_FillRule == value) + { return; } m_FillRule = value; @@ -52,8 +62,10 @@ } inline bool isVisible() const { return m_IsVisible; } - void isVisible(bool value) { - if (m_IsVisible == value) { + void isVisible(bool value) + { + if (m_IsVisible == value) + { return; } m_IsVisible = value; @@ -61,18 +73,27 @@ } Core* clone() const override; - void copy(const ClippingShapeBase& object) { + void copy(const ClippingShapeBase& object) + { m_SourceId = object.m_SourceId; m_FillRule = object.m_FillRule; m_IsVisible = object.m_IsVisible; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case sourceIdPropertyKey: m_SourceId = CoreUintType::deserialize(reader); return true; - case fillRulePropertyKey: m_FillRule = CoreUintType::deserialize(reader); return true; - case isVisiblePropertyKey: m_IsVisible = CoreBoolType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case sourceIdPropertyKey: + m_SourceId = CoreUintType::deserialize(reader); + return true; + case fillRulePropertyKey: + m_FillRule = CoreUintType::deserialize(reader); + return true; + case isVisiblePropertyKey: + m_IsVisible = CoreBoolType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/contour_mesh_vertex_base.hpp b/include/rive/generated/shapes/contour_mesh_vertex_base.hpp index 1cb46cb..c4674b9 100644 --- a/include/rive/generated/shapes/contour_mesh_vertex_base.hpp +++ b/include/rive/generated/shapes/contour_mesh_vertex_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CONTOUR_MESH_VERTEX_BASE_HPP_ #define _RIVE_CONTOUR_MESH_VERTEX_BASE_HPP_ #include "rive/shapes/mesh_vertex.hpp" -namespace rive { -class ContourMeshVertexBase : public MeshVertex { +namespace rive +{ +class ContourMeshVertexBase : public MeshVertex +{ protected: typedef MeshVertex Super; @@ -11,14 +13,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ContourMeshVertexBase::typeKey: case MeshVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/cubic_asymmetric_vertex_base.hpp b/include/rive/generated/shapes/cubic_asymmetric_vertex_base.hpp index 14c126f..e9b12cf 100644 --- a/include/rive/generated/shapes/cubic_asymmetric_vertex_base.hpp +++ b/include/rive/generated/shapes/cubic_asymmetric_vertex_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CUBIC_ASYMMETRIC_VERTEX_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/cubic_vertex.hpp" -namespace rive { -class CubicAsymmetricVertexBase : public CubicVertex { +namespace rive +{ +class CubicAsymmetricVertexBase : public CubicVertex +{ protected: typedef CubicVertex Super; @@ -12,15 +14,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case CubicAsymmetricVertexBase::typeKey: case CubicVertexBase::typeKey: case PathVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -37,8 +43,10 @@ public: inline float rotation() const { return m_Rotation; } - void rotation(float value) { - if (m_Rotation == value) { + void rotation(float value) + { + if (m_Rotation == value) + { return; } m_Rotation = value; @@ -46,8 +54,10 @@ } inline float inDistance() const { return m_InDistance; } - void inDistance(float value) { - if (m_InDistance == value) { + void inDistance(float value) + { + if (m_InDistance == value) + { return; } m_InDistance = value; @@ -55,8 +65,10 @@ } inline float outDistance() const { return m_OutDistance; } - void outDistance(float value) { - if (m_OutDistance == value) { + void outDistance(float value) + { + if (m_OutDistance == value) + { return; } m_OutDistance = value; @@ -64,16 +76,21 @@ } Core* clone() const override; - void copy(const CubicAsymmetricVertexBase& object) { + void copy(const CubicAsymmetricVertexBase& object) + { m_Rotation = object.m_Rotation; m_InDistance = object.m_InDistance; m_OutDistance = object.m_OutDistance; CubicVertex::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case rotationPropertyKey: m_Rotation = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case rotationPropertyKey: + m_Rotation = CoreDoubleType::deserialize(reader); + return true; case inDistancePropertyKey: m_InDistance = CoreDoubleType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/cubic_detached_vertex_base.hpp b/include/rive/generated/shapes/cubic_detached_vertex_base.hpp index 63b406e..cc0feb7 100644 --- a/include/rive/generated/shapes/cubic_detached_vertex_base.hpp +++ b/include/rive/generated/shapes/cubic_detached_vertex_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CUBIC_DETACHED_VERTEX_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/cubic_vertex.hpp" -namespace rive { -class CubicDetachedVertexBase : public CubicVertex { +namespace rive +{ +class CubicDetachedVertexBase : public CubicVertex +{ protected: typedef CubicVertex Super; @@ -12,15 +14,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case CubicDetachedVertexBase::typeKey: case CubicVertexBase::typeKey: case PathVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -39,8 +45,10 @@ public: inline float inRotation() const { return m_InRotation; } - void inRotation(float value) { - if (m_InRotation == value) { + void inRotation(float value) + { + if (m_InRotation == value) + { return; } m_InRotation = value; @@ -48,8 +56,10 @@ } inline float inDistance() const { return m_InDistance; } - void inDistance(float value) { - if (m_InDistance == value) { + void inDistance(float value) + { + if (m_InDistance == value) + { return; } m_InDistance = value; @@ -57,8 +67,10 @@ } inline float outRotation() const { return m_OutRotation; } - void outRotation(float value) { - if (m_OutRotation == value) { + void outRotation(float value) + { + if (m_OutRotation == value) + { return; } m_OutRotation = value; @@ -66,8 +78,10 @@ } inline float outDistance() const { return m_OutDistance; } - void outDistance(float value) { - if (m_OutDistance == value) { + void outDistance(float value) + { + if (m_OutDistance == value) + { return; } m_OutDistance = value; @@ -75,7 +89,8 @@ } Core* clone() const override; - void copy(const CubicDetachedVertexBase& object) { + void copy(const CubicDetachedVertexBase& object) + { m_InRotation = object.m_InRotation; m_InDistance = object.m_InDistance; m_OutRotation = object.m_OutRotation; @@ -83,8 +98,10 @@ CubicVertex::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case inRotationPropertyKey: m_InRotation = CoreDoubleType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/cubic_mirrored_vertex_base.hpp b/include/rive/generated/shapes/cubic_mirrored_vertex_base.hpp index c019cbd..e419752 100644 --- a/include/rive/generated/shapes/cubic_mirrored_vertex_base.hpp +++ b/include/rive/generated/shapes/cubic_mirrored_vertex_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CUBIC_MIRRORED_VERTEX_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/cubic_vertex.hpp" -namespace rive { -class CubicMirroredVertexBase : public CubicVertex { +namespace rive +{ +class CubicMirroredVertexBase : public CubicVertex +{ protected: typedef CubicVertex Super; @@ -12,15 +14,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case CubicMirroredVertexBase::typeKey: case CubicVertexBase::typeKey: case PathVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -35,8 +41,10 @@ public: inline float rotation() const { return m_Rotation; } - void rotation(float value) { - if (m_Rotation == value) { + void rotation(float value) + { + if (m_Rotation == value) + { return; } m_Rotation = value; @@ -44,8 +52,10 @@ } inline float distance() const { return m_Distance; } - void distance(float value) { - if (m_Distance == value) { + void distance(float value) + { + if (m_Distance == value) + { return; } m_Distance = value; @@ -53,16 +63,23 @@ } Core* clone() const override; - void copy(const CubicMirroredVertexBase& object) { + void copy(const CubicMirroredVertexBase& object) + { m_Rotation = object.m_Rotation; m_Distance = object.m_Distance; CubicVertex::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case rotationPropertyKey: m_Rotation = CoreDoubleType::deserialize(reader); return true; - case distancePropertyKey: m_Distance = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case rotationPropertyKey: + m_Rotation = CoreDoubleType::deserialize(reader); + return true; + case distancePropertyKey: + m_Distance = CoreDoubleType::deserialize(reader); + return true; } return CubicVertex::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/cubic_vertex_base.hpp b/include/rive/generated/shapes/cubic_vertex_base.hpp index 96bfe3a..4ac7241 100644 --- a/include/rive/generated/shapes/cubic_vertex_base.hpp +++ b/include/rive/generated/shapes/cubic_vertex_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CUBIC_VERTEX_BASE_HPP_ #define _RIVE_CUBIC_VERTEX_BASE_HPP_ #include "rive/shapes/path_vertex.hpp" -namespace rive { -class CubicVertexBase : public PathVertex { +namespace rive +{ +class CubicVertexBase : public PathVertex +{ protected: typedef PathVertex Super; @@ -11,14 +13,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case CubicVertexBase::typeKey: case PathVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/ellipse_base.hpp b/include/rive/generated/shapes/ellipse_base.hpp index b692653..015e763 100644 --- a/include/rive/generated/shapes/ellipse_base.hpp +++ b/include/rive/generated/shapes/ellipse_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_ELLIPSE_BASE_HPP_ #define _RIVE_ELLIPSE_BASE_HPP_ #include "rive/shapes/parametric_path.hpp" -namespace rive { -class EllipseBase : public ParametricPath { +namespace rive +{ +class EllipseBase : public ParametricPath +{ protected: typedef ParametricPath Super; @@ -11,8 +13,10 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case EllipseBase::typeKey: case ParametricPathBase::typeKey: case PathBase::typeKey: @@ -20,8 +24,10 @@ case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/image_base.hpp b/include/rive/generated/shapes/image_base.hpp index 3d9a552..ead835e 100644 --- a/include/rive/generated/shapes/image_base.hpp +++ b/include/rive/generated/shapes/image_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_IMAGE_BASE_HPP_ #include "rive/core/field_types/core_uint_type.hpp" #include "rive/drawable.hpp" -namespace rive { -class ImageBase : public Drawable { +namespace rive +{ +class ImageBase : public Drawable +{ protected: typedef Drawable Super; @@ -12,16 +14,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ImageBase::typeKey: case DrawableBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline uint32_t assetId() const { return m_AssetId; } - void assetId(uint32_t value) { - if (m_AssetId == value) { + void assetId(uint32_t value) + { + if (m_AssetId == value) + { return; } m_AssetId = value; @@ -43,14 +51,19 @@ } Core* clone() const override; - void copy(const ImageBase& object) { + void copy(const ImageBase& object) + { m_AssetId = object.m_AssetId; Drawable::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case assetIdPropertyKey: m_AssetId = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case assetIdPropertyKey: + m_AssetId = CoreUintType::deserialize(reader); + return true; } return Drawable::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/mesh_base.hpp b/include/rive/generated/shapes/mesh_base.hpp index 3cfed2d..c34e88a 100644 --- a/include/rive/generated/shapes/mesh_base.hpp +++ b/include/rive/generated/shapes/mesh_base.hpp
@@ -3,8 +3,10 @@ #include "rive/container_component.hpp" #include "rive/core/field_types/core_bytes_type.hpp" #include "rive/span.hpp" -namespace rive { -class MeshBase : public ContainerComponent { +namespace rive +{ +class MeshBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -13,12 +15,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case MeshBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,13 +37,16 @@ virtual void copyTriangleIndexBytes(const MeshBase& object) = 0; Core* clone() const override; - void copy(const MeshBase& object) { + void copy(const MeshBase& object) + { copyTriangleIndexBytes(object); ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case triangleIndexBytesPropertyKey: decodeTriangleIndexBytes(CoreBytesType::deserialize(reader)); return true;
diff --git a/include/rive/generated/shapes/mesh_vertex_base.hpp b/include/rive/generated/shapes/mesh_vertex_base.hpp index 5a1972e..196350e 100644 --- a/include/rive/generated/shapes/mesh_vertex_base.hpp +++ b/include/rive/generated/shapes/mesh_vertex_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_MESH_VERTEX_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/vertex.hpp" -namespace rive { -class MeshVertexBase : public Vertex { +namespace rive +{ +class MeshVertexBase : public Vertex +{ protected: typedef Vertex Super; @@ -12,13 +14,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case MeshVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -33,8 +39,10 @@ public: inline float u() const { return m_U; } - void u(float value) { - if (m_U == value) { + void u(float value) + { + if (m_U == value) + { return; } m_U = value; @@ -42,8 +50,10 @@ } inline float v() const { return m_V; } - void v(float value) { - if (m_V == value) { + void v(float value) + { + if (m_V == value) + { return; } m_V = value; @@ -51,16 +61,23 @@ } Core* clone() const override; - void copy(const MeshVertexBase& object) { + void copy(const MeshVertexBase& object) + { m_U = object.m_U; m_V = object.m_V; Vertex::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case uPropertyKey: m_U = CoreDoubleType::deserialize(reader); return true; - case vPropertyKey: m_V = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case uPropertyKey: + m_U = CoreDoubleType::deserialize(reader); + return true; + case vPropertyKey: + m_V = CoreDoubleType::deserialize(reader); + return true; } return Vertex::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/paint/fill_base.hpp b/include/rive/generated/shapes/paint/fill_base.hpp index 12343ca..ea1f32e 100644 --- a/include/rive/generated/shapes/paint/fill_base.hpp +++ b/include/rive/generated/shapes/paint/fill_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_FILL_BASE_HPP_ #include "rive/core/field_types/core_uint_type.hpp" #include "rive/shapes/paint/shape_paint.hpp" -namespace rive { -class FillBase : public ShapePaint { +namespace rive +{ +class FillBase : public ShapePaint +{ protected: typedef ShapePaint Super; @@ -12,13 +14,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case FillBase::typeKey: case ShapePaintBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -31,8 +37,10 @@ public: inline uint32_t fillRule() const { return m_FillRule; } - void fillRule(uint32_t value) { - if (m_FillRule == value) { + void fillRule(uint32_t value) + { + if (m_FillRule == value) + { return; } m_FillRule = value; @@ -40,14 +48,19 @@ } Core* clone() const override; - void copy(const FillBase& object) { + void copy(const FillBase& object) + { m_FillRule = object.m_FillRule; ShapePaint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case fillRulePropertyKey: m_FillRule = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case fillRulePropertyKey: + m_FillRule = CoreUintType::deserialize(reader); + return true; } return ShapePaint::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/paint/gradient_stop_base.hpp b/include/rive/generated/shapes/paint/gradient_stop_base.hpp index 2acbd41..e33431c 100644 --- a/include/rive/generated/shapes/paint/gradient_stop_base.hpp +++ b/include/rive/generated/shapes/paint/gradient_stop_base.hpp
@@ -3,8 +3,10 @@ #include "rive/component.hpp" #include "rive/core/field_types/core_color_type.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class GradientStopBase : public Component { +namespace rive +{ +class GradientStopBase : public Component +{ protected: typedef Component Super; @@ -13,11 +15,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case GradientStopBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline int colorValue() const { return m_ColorValue; } - void colorValue(int value) { - if (m_ColorValue == value) { + void colorValue(int value) + { + if (m_ColorValue == value) + { return; } m_ColorValue = value; @@ -41,8 +49,10 @@ } inline float position() const { return m_Position; } - void position(float value) { - if (m_Position == value) { + void position(float value) + { + if (m_Position == value) + { return; } m_Position = value; @@ -50,18 +60,23 @@ } Core* clone() const override; - void copy(const GradientStopBase& object) { + void copy(const GradientStopBase& object) + { m_ColorValue = object.m_ColorValue; m_Position = object.m_Position; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case colorValuePropertyKey: m_ColorValue = CoreColorType::deserialize(reader); return true; - case positionPropertyKey: m_Position = CoreDoubleType::deserialize(reader); return true; + case positionPropertyKey: + m_Position = CoreDoubleType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/paint/linear_gradient_base.hpp b/include/rive/generated/shapes/paint/linear_gradient_base.hpp index c20770c..95fd3ff 100644 --- a/include/rive/generated/shapes/paint/linear_gradient_base.hpp +++ b/include/rive/generated/shapes/paint/linear_gradient_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_LINEAR_GRADIENT_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class LinearGradientBase : public ContainerComponent { +namespace rive +{ +class LinearGradientBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case LinearGradientBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -38,8 +44,10 @@ public: inline float startX() const { return m_StartX; } - void startX(float value) { - if (m_StartX == value) { + void startX(float value) + { + if (m_StartX == value) + { return; } m_StartX = value; @@ -47,8 +55,10 @@ } inline float startY() const { return m_StartY; } - void startY(float value) { - if (m_StartY == value) { + void startY(float value) + { + if (m_StartY == value) + { return; } m_StartY = value; @@ -56,8 +66,10 @@ } inline float endX() const { return m_EndX; } - void endX(float value) { - if (m_EndX == value) { + void endX(float value) + { + if (m_EndX == value) + { return; } m_EndX = value; @@ -65,8 +77,10 @@ } inline float endY() const { return m_EndY; } - void endY(float value) { - if (m_EndY == value) { + void endY(float value) + { + if (m_EndY == value) + { return; } m_EndY = value; @@ -74,8 +88,10 @@ } inline float opacity() const { return m_Opacity; } - void opacity(float value) { - if (m_Opacity == value) { + void opacity(float value) + { + if (m_Opacity == value) + { return; } m_Opacity = value; @@ -83,7 +99,8 @@ } Core* clone() const override; - void copy(const LinearGradientBase& object) { + void copy(const LinearGradientBase& object) + { m_StartX = object.m_StartX; m_StartY = object.m_StartY; m_EndX = object.m_EndX; @@ -92,13 +109,25 @@ ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case startXPropertyKey: m_StartX = CoreDoubleType::deserialize(reader); return true; - case startYPropertyKey: m_StartY = CoreDoubleType::deserialize(reader); return true; - case endXPropertyKey: m_EndX = CoreDoubleType::deserialize(reader); return true; - case endYPropertyKey: m_EndY = CoreDoubleType::deserialize(reader); return true; - case opacityPropertyKey: m_Opacity = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case startXPropertyKey: + m_StartX = CoreDoubleType::deserialize(reader); + return true; + case startYPropertyKey: + m_StartY = CoreDoubleType::deserialize(reader); + return true; + case endXPropertyKey: + m_EndX = CoreDoubleType::deserialize(reader); + return true; + case endYPropertyKey: + m_EndY = CoreDoubleType::deserialize(reader); + return true; + case opacityPropertyKey: + m_Opacity = CoreDoubleType::deserialize(reader); + return true; } return ContainerComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/paint/radial_gradient_base.hpp b/include/rive/generated/shapes/paint/radial_gradient_base.hpp index 995f8ae..aca9673 100644 --- a/include/rive/generated/shapes/paint/radial_gradient_base.hpp +++ b/include/rive/generated/shapes/paint/radial_gradient_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_RADIAL_GRADIENT_BASE_HPP_ #define _RIVE_RADIAL_GRADIENT_BASE_HPP_ #include "rive/shapes/paint/linear_gradient.hpp" -namespace rive { -class RadialGradientBase : public LinearGradient { +namespace rive +{ +class RadialGradientBase : public LinearGradient +{ protected: typedef LinearGradient Super; @@ -11,13 +13,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case RadialGradientBase::typeKey: case LinearGradientBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/paint/shape_paint_base.hpp b/include/rive/generated/shapes/paint/shape_paint_base.hpp index 091cda6..27cdfa4 100644 --- a/include/rive/generated/shapes/paint/shape_paint_base.hpp +++ b/include/rive/generated/shapes/paint/shape_paint_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_SHAPE_PAINT_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_bool_type.hpp" -namespace rive { -class ShapePaintBase : public ContainerComponent { +namespace rive +{ +class ShapePaintBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ShapePaintBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,22 +36,29 @@ public: virtual bool isVisible() const { return m_IsVisible; } - void isVisible(bool value) { - if (m_IsVisible == value) { + void isVisible(bool value) + { + if (m_IsVisible == value) + { return; } m_IsVisible = value; isVisibleChanged(); } - void copy(const ShapePaintBase& object) { + void copy(const ShapePaintBase& object) + { m_IsVisible = object.m_IsVisible; ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case isVisiblePropertyKey: m_IsVisible = CoreBoolType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case isVisiblePropertyKey: + m_IsVisible = CoreBoolType::deserialize(reader); + return true; } return ContainerComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/paint/solid_color_base.hpp b/include/rive/generated/shapes/paint/solid_color_base.hpp index fb131c5..2ebc9d3 100644 --- a/include/rive/generated/shapes/paint/solid_color_base.hpp +++ b/include/rive/generated/shapes/paint/solid_color_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_SOLID_COLOR_BASE_HPP_ #include "rive/component.hpp" #include "rive/core/field_types/core_color_type.hpp" -namespace rive { -class SolidColorBase : public Component { +namespace rive +{ +class SolidColorBase : public Component +{ protected: typedef Component Super; @@ -12,11 +14,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case SolidColorBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -29,8 +35,10 @@ public: inline int colorValue() const { return m_ColorValue; } - void colorValue(int value) { - if (m_ColorValue == value) { + void colorValue(int value) + { + if (m_ColorValue == value) + { return; } m_ColorValue = value; @@ -38,13 +46,16 @@ } Core* clone() const override; - void copy(const SolidColorBase& object) { + void copy(const SolidColorBase& object) + { m_ColorValue = object.m_ColorValue; Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case colorValuePropertyKey: m_ColorValue = CoreColorType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/paint/stroke_base.hpp b/include/rive/generated/shapes/paint/stroke_base.hpp index e101e9d..b23107f 100644 --- a/include/rive/generated/shapes/paint/stroke_base.hpp +++ b/include/rive/generated/shapes/paint/stroke_base.hpp
@@ -4,8 +4,10 @@ #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" #include "rive/shapes/paint/shape_paint.hpp" -namespace rive { -class StrokeBase : public ShapePaint { +namespace rive +{ +class StrokeBase : public ShapePaint +{ protected: typedef ShapePaint Super; @@ -14,13 +16,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StrokeBase::typeKey: case ShapePaintBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -39,8 +45,10 @@ public: inline float thickness() const { return m_Thickness; } - void thickness(float value) { - if (m_Thickness == value) { + void thickness(float value) + { + if (m_Thickness == value) + { return; } m_Thickness = value; @@ -48,8 +56,10 @@ } inline uint32_t cap() const { return m_Cap; } - void cap(uint32_t value) { - if (m_Cap == value) { + void cap(uint32_t value) + { + if (m_Cap == value) + { return; } m_Cap = value; @@ -57,8 +67,10 @@ } inline uint32_t join() const { return m_Join; } - void join(uint32_t value) { - if (m_Join == value) { + void join(uint32_t value) + { + if (m_Join == value) + { return; } m_Join = value; @@ -66,8 +78,10 @@ } inline bool transformAffectsStroke() const { return m_TransformAffectsStroke; } - void transformAffectsStroke(bool value) { - if (m_TransformAffectsStroke == value) { + void transformAffectsStroke(bool value) + { + if (m_TransformAffectsStroke == value) + { return; } m_TransformAffectsStroke = value; @@ -75,7 +89,8 @@ } Core* clone() const override; - void copy(const StrokeBase& object) { + void copy(const StrokeBase& object) + { m_Thickness = object.m_Thickness; m_Cap = object.m_Cap; m_Join = object.m_Join; @@ -83,13 +98,19 @@ ShapePaint::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case thicknessPropertyKey: m_Thickness = CoreDoubleType::deserialize(reader); return true; - case capPropertyKey: m_Cap = CoreUintType::deserialize(reader); return true; - case joinPropertyKey: m_Join = CoreUintType::deserialize(reader); return true; + case capPropertyKey: + m_Cap = CoreUintType::deserialize(reader); + return true; + case joinPropertyKey: + m_Join = CoreUintType::deserialize(reader); + return true; case transformAffectsStrokePropertyKey: m_TransformAffectsStroke = CoreBoolType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/paint/trim_path_base.hpp b/include/rive/generated/shapes/paint/trim_path_base.hpp index 018ec4b..4838269 100644 --- a/include/rive/generated/shapes/paint/trim_path_base.hpp +++ b/include/rive/generated/shapes/paint/trim_path_base.hpp
@@ -3,8 +3,10 @@ #include "rive/component.hpp" #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" -namespace rive { -class TrimPathBase : public Component { +namespace rive +{ +class TrimPathBase : public Component +{ protected: typedef Component Super; @@ -13,11 +15,15 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TrimPathBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -36,8 +42,10 @@ public: inline float start() const { return m_Start; } - void start(float value) { - if (m_Start == value) { + void start(float value) + { + if (m_Start == value) + { return; } m_Start = value; @@ -45,8 +53,10 @@ } inline float end() const { return m_End; } - void end(float value) { - if (m_End == value) { + void end(float value) + { + if (m_End == value) + { return; } m_End = value; @@ -54,8 +64,10 @@ } inline float offset() const { return m_Offset; } - void offset(float value) { - if (m_Offset == value) { + void offset(float value) + { + if (m_Offset == value) + { return; } m_Offset = value; @@ -63,8 +75,10 @@ } inline uint32_t modeValue() const { return m_ModeValue; } - void modeValue(uint32_t value) { - if (m_ModeValue == value) { + void modeValue(uint32_t value) + { + if (m_ModeValue == value) + { return; } m_ModeValue = value; @@ -72,7 +86,8 @@ } Core* clone() const override; - void copy(const TrimPathBase& object) { + void copy(const TrimPathBase& object) + { m_Start = object.m_Start; m_End = object.m_End; m_Offset = object.m_Offset; @@ -80,12 +95,22 @@ Component::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case startPropertyKey: m_Start = CoreDoubleType::deserialize(reader); return true; - case endPropertyKey: m_End = CoreDoubleType::deserialize(reader); return true; - case offsetPropertyKey: m_Offset = CoreDoubleType::deserialize(reader); return true; - case modeValuePropertyKey: m_ModeValue = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case startPropertyKey: + m_Start = CoreDoubleType::deserialize(reader); + return true; + case endPropertyKey: + m_End = CoreDoubleType::deserialize(reader); + return true; + case offsetPropertyKey: + m_Offset = CoreDoubleType::deserialize(reader); + return true; + case modeValuePropertyKey: + m_ModeValue = CoreUintType::deserialize(reader); + return true; } return Component::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/parametric_path_base.hpp b/include/rive/generated/shapes/parametric_path_base.hpp index a38b7cb..2f87b87 100644 --- a/include/rive/generated/shapes/parametric_path_base.hpp +++ b/include/rive/generated/shapes/parametric_path_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_PARAMETRIC_PATH_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/path.hpp" -namespace rive { -class ParametricPathBase : public Path { +namespace rive +{ +class ParametricPathBase : public Path +{ protected: typedef Path Super; @@ -12,16 +14,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ParametricPathBase::typeKey: case PathBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -40,8 +46,10 @@ public: inline float width() const { return m_Width; } - void width(float value) { - if (m_Width == value) { + void width(float value) + { + if (m_Width == value) + { return; } m_Width = value; @@ -49,8 +57,10 @@ } inline float height() const { return m_Height; } - void height(float value) { - if (m_Height == value) { + void height(float value) + { + if (m_Height == value) + { return; } m_Height = value; @@ -58,8 +68,10 @@ } inline float originX() const { return m_OriginX; } - void originX(float value) { - if (m_OriginX == value) { + void originX(float value) + { + if (m_OriginX == value) + { return; } m_OriginX = value; @@ -67,15 +79,18 @@ } inline float originY() const { return m_OriginY; } - void originY(float value) { - if (m_OriginY == value) { + void originY(float value) + { + if (m_OriginY == value) + { return; } m_OriginY = value; originYChanged(); } - void copy(const ParametricPathBase& object) { + void copy(const ParametricPathBase& object) + { m_Width = object.m_Width; m_Height = object.m_Height; m_OriginX = object.m_OriginX; @@ -83,12 +98,22 @@ Path::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case widthPropertyKey: m_Width = CoreDoubleType::deserialize(reader); return true; - case heightPropertyKey: m_Height = CoreDoubleType::deserialize(reader); return true; - case originXPropertyKey: m_OriginX = CoreDoubleType::deserialize(reader); return true; - case originYPropertyKey: m_OriginY = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case widthPropertyKey: + m_Width = CoreDoubleType::deserialize(reader); + return true; + case heightPropertyKey: + m_Height = CoreDoubleType::deserialize(reader); + return true; + case originXPropertyKey: + m_OriginX = CoreDoubleType::deserialize(reader); + return true; + case originYPropertyKey: + m_OriginY = CoreDoubleType::deserialize(reader); + return true; } return Path::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/path_base.hpp b/include/rive/generated/shapes/path_base.hpp index 2cf6d74..c90d605 100644 --- a/include/rive/generated/shapes/path_base.hpp +++ b/include/rive/generated/shapes/path_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_PATH_BASE_HPP_ #include "rive/core/field_types/core_uint_type.hpp" #include "rive/node.hpp" -namespace rive { -class PathBase : public Node { +namespace rive +{ +class PathBase : public Node +{ protected: typedef Node Super; @@ -12,15 +14,19 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case PathBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -33,22 +39,29 @@ public: inline uint32_t pathFlags() const { return m_PathFlags; } - void pathFlags(uint32_t value) { - if (m_PathFlags == value) { + void pathFlags(uint32_t value) + { + if (m_PathFlags == value) + { return; } m_PathFlags = value; pathFlagsChanged(); } - void copy(const PathBase& object) { + void copy(const PathBase& object) + { m_PathFlags = object.m_PathFlags; Node::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case pathFlagsPropertyKey: m_PathFlags = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case pathFlagsPropertyKey: + m_PathFlags = CoreUintType::deserialize(reader); + return true; } return Node::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/path_vertex_base.hpp b/include/rive/generated/shapes/path_vertex_base.hpp index 6fb524c..86de3a5 100644 --- a/include/rive/generated/shapes/path_vertex_base.hpp +++ b/include/rive/generated/shapes/path_vertex_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_PATH_VERTEX_BASE_HPP_ #define _RIVE_PATH_VERTEX_BASE_HPP_ #include "rive/shapes/vertex.hpp" -namespace rive { -class PathVertexBase : public Vertex { +namespace rive +{ +class PathVertexBase : public Vertex +{ protected: typedef Vertex Super; @@ -11,13 +13,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case PathVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/points_path_base.hpp b/include/rive/generated/shapes/points_path_base.hpp index 69ef411..a999514 100644 --- a/include/rive/generated/shapes/points_path_base.hpp +++ b/include/rive/generated/shapes/points_path_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_POINTS_PATH_BASE_HPP_ #include "rive/core/field_types/core_bool_type.hpp" #include "rive/shapes/path.hpp" -namespace rive { -class PointsPathBase : public Path { +namespace rive +{ +class PointsPathBase : public Path +{ protected: typedef Path Super; @@ -12,16 +14,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case PointsPathBase::typeKey: case PathBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -34,8 +40,10 @@ public: inline bool isClosed() const { return m_IsClosed; } - void isClosed(bool value) { - if (m_IsClosed == value) { + void isClosed(bool value) + { + if (m_IsClosed == value) + { return; } m_IsClosed = value; @@ -43,14 +51,19 @@ } Core* clone() const override; - void copy(const PointsPathBase& object) { + void copy(const PointsPathBase& object) + { m_IsClosed = object.m_IsClosed; Path::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case isClosedPropertyKey: m_IsClosed = CoreBoolType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case isClosedPropertyKey: + m_IsClosed = CoreBoolType::deserialize(reader); + return true; } return Path::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/polygon_base.hpp b/include/rive/generated/shapes/polygon_base.hpp index de68236..e71f8f5 100644 --- a/include/rive/generated/shapes/polygon_base.hpp +++ b/include/rive/generated/shapes/polygon_base.hpp
@@ -3,8 +3,10 @@ #include "rive/core/field_types/core_double_type.hpp" #include "rive/core/field_types/core_uint_type.hpp" #include "rive/shapes/parametric_path.hpp" -namespace rive { -class PolygonBase : public ParametricPath { +namespace rive +{ +class PolygonBase : public ParametricPath +{ protected: typedef ParametricPath Super; @@ -13,8 +15,10 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case PolygonBase::typeKey: case ParametricPathBase::typeKey: case PathBase::typeKey: @@ -22,8 +26,10 @@ case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -38,8 +44,10 @@ public: inline uint32_t points() const { return m_Points; } - void points(uint32_t value) { - if (m_Points == value) { + void points(uint32_t value) + { + if (m_Points == value) + { return; } m_Points = value; @@ -47,8 +55,10 @@ } inline float cornerRadius() const { return m_CornerRadius; } - void cornerRadius(float value) { - if (m_CornerRadius == value) { + void cornerRadius(float value) + { + if (m_CornerRadius == value) + { return; } m_CornerRadius = value; @@ -56,15 +66,20 @@ } Core* clone() const override; - void copy(const PolygonBase& object) { + void copy(const PolygonBase& object) + { m_Points = object.m_Points; m_CornerRadius = object.m_CornerRadius; ParametricPath::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case pointsPropertyKey: m_Points = CoreUintType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case pointsPropertyKey: + m_Points = CoreUintType::deserialize(reader); + return true; case cornerRadiusPropertyKey: m_CornerRadius = CoreDoubleType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/rectangle_base.hpp b/include/rive/generated/shapes/rectangle_base.hpp index a9d8a13..c85ac93 100644 --- a/include/rive/generated/shapes/rectangle_base.hpp +++ b/include/rive/generated/shapes/rectangle_base.hpp
@@ -3,8 +3,10 @@ #include "rive/core/field_types/core_bool_type.hpp" #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/parametric_path.hpp" -namespace rive { -class RectangleBase : public ParametricPath { +namespace rive +{ +class RectangleBase : public ParametricPath +{ protected: typedef ParametricPath Super; @@ -13,8 +15,10 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case RectangleBase::typeKey: case ParametricPathBase::typeKey: case PathBase::typeKey: @@ -22,8 +26,10 @@ case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -44,8 +50,10 @@ public: inline bool linkCornerRadius() const { return m_LinkCornerRadius; } - void linkCornerRadius(bool value) { - if (m_LinkCornerRadius == value) { + void linkCornerRadius(bool value) + { + if (m_LinkCornerRadius == value) + { return; } m_LinkCornerRadius = value; @@ -53,8 +61,10 @@ } inline float cornerRadiusTL() const { return m_CornerRadiusTL; } - void cornerRadiusTL(float value) { - if (m_CornerRadiusTL == value) { + void cornerRadiusTL(float value) + { + if (m_CornerRadiusTL == value) + { return; } m_CornerRadiusTL = value; @@ -62,8 +72,10 @@ } inline float cornerRadiusTR() const { return m_CornerRadiusTR; } - void cornerRadiusTR(float value) { - if (m_CornerRadiusTR == value) { + void cornerRadiusTR(float value) + { + if (m_CornerRadiusTR == value) + { return; } m_CornerRadiusTR = value; @@ -71,8 +83,10 @@ } inline float cornerRadiusBL() const { return m_CornerRadiusBL; } - void cornerRadiusBL(float value) { - if (m_CornerRadiusBL == value) { + void cornerRadiusBL(float value) + { + if (m_CornerRadiusBL == value) + { return; } m_CornerRadiusBL = value; @@ -80,8 +94,10 @@ } inline float cornerRadiusBR() const { return m_CornerRadiusBR; } - void cornerRadiusBR(float value) { - if (m_CornerRadiusBR == value) { + void cornerRadiusBR(float value) + { + if (m_CornerRadiusBR == value) + { return; } m_CornerRadiusBR = value; @@ -89,7 +105,8 @@ } Core* clone() const override; - void copy(const RectangleBase& object) { + void copy(const RectangleBase& object) + { m_LinkCornerRadius = object.m_LinkCornerRadius; m_CornerRadiusTL = object.m_CornerRadiusTL; m_CornerRadiusTR = object.m_CornerRadiusTR; @@ -98,8 +115,10 @@ ParametricPath::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case linkCornerRadiusPropertyKey: m_LinkCornerRadius = CoreBoolType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/shape_base.hpp b/include/rive/generated/shapes/shape_base.hpp index 02b063d..c73b220 100644 --- a/include/rive/generated/shapes/shape_base.hpp +++ b/include/rive/generated/shapes/shape_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_SHAPE_BASE_HPP_ #define _RIVE_SHAPE_BASE_HPP_ #include "rive/drawable.hpp" -namespace rive { -class ShapeBase : public Drawable { +namespace rive +{ +class ShapeBase : public Drawable +{ protected: typedef Drawable Super; @@ -11,16 +13,20 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case ShapeBase::typeKey: case DrawableBase::typeKey: case NodeBase::typeKey: case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/star_base.hpp b/include/rive/generated/shapes/star_base.hpp index 3be146d..3d95448 100644 --- a/include/rive/generated/shapes/star_base.hpp +++ b/include/rive/generated/shapes/star_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STAR_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/polygon.hpp" -namespace rive { -class StarBase : public Polygon { +namespace rive +{ +class StarBase : public Polygon +{ protected: typedef Polygon Super; @@ -12,8 +14,10 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StarBase::typeKey: case PolygonBase::typeKey: case ParametricPathBase::typeKey: @@ -22,8 +26,10 @@ case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -36,8 +42,10 @@ public: inline float innerRadius() const { return m_InnerRadius; } - void innerRadius(float value) { - if (m_InnerRadius == value) { + void innerRadius(float value) + { + if (m_InnerRadius == value) + { return; } m_InnerRadius = value; @@ -45,13 +53,16 @@ } Core* clone() const override; - void copy(const StarBase& object) { + void copy(const StarBase& object) + { m_InnerRadius = object.m_InnerRadius; Polygon::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { case innerRadiusPropertyKey: m_InnerRadius = CoreDoubleType::deserialize(reader); return true;
diff --git a/include/rive/generated/shapes/straight_vertex_base.hpp b/include/rive/generated/shapes/straight_vertex_base.hpp index a8b28e4..df1f886 100644 --- a/include/rive/generated/shapes/straight_vertex_base.hpp +++ b/include/rive/generated/shapes/straight_vertex_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STRAIGHT_VERTEX_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/shapes/path_vertex.hpp" -namespace rive { -class StraightVertexBase : public PathVertex { +namespace rive +{ +class StraightVertexBase : public PathVertex +{ protected: typedef PathVertex Super; @@ -12,14 +14,18 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case StraightVertexBase::typeKey: case PathVertexBase::typeKey: case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline float radius() const { return m_Radius; } - void radius(float value) { - if (m_Radius == value) { + void radius(float value) + { + if (m_Radius == value) + { return; } m_Radius = value; @@ -41,14 +49,19 @@ } Core* clone() const override; - void copy(const StraightVertexBase& object) { + void copy(const StraightVertexBase& object) + { m_Radius = object.m_Radius; PathVertex::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case radiusPropertyKey: m_Radius = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case radiusPropertyKey: + m_Radius = CoreDoubleType::deserialize(reader); + return true; } return PathVertex::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/shapes/triangle_base.hpp b/include/rive/generated/shapes/triangle_base.hpp index 45a9c93..3b37b53 100644 --- a/include/rive/generated/shapes/triangle_base.hpp +++ b/include/rive/generated/shapes/triangle_base.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_TRIANGLE_BASE_HPP_ #define _RIVE_TRIANGLE_BASE_HPP_ #include "rive/shapes/parametric_path.hpp" -namespace rive { -class TriangleBase : public ParametricPath { +namespace rive +{ +class TriangleBase : public ParametricPath +{ protected: typedef ParametricPath Super; @@ -11,8 +13,10 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TriangleBase::typeKey: case ParametricPathBase::typeKey: case PathBase::typeKey: @@ -20,8 +24,10 @@ case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } }
diff --git a/include/rive/generated/shapes/vertex_base.hpp b/include/rive/generated/shapes/vertex_base.hpp index 75606a8..bd872c1 100644 --- a/include/rive/generated/shapes/vertex_base.hpp +++ b/include/rive/generated/shapes/vertex_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_VERTEX_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class VertexBase : public ContainerComponent { +namespace rive +{ +class VertexBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case VertexBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -32,8 +38,10 @@ public: inline float x() const { return m_X; } - void x(float value) { - if (m_X == value) { + void x(float value) + { + if (m_X == value) + { return; } m_X = value; @@ -41,24 +49,33 @@ } inline float y() const { return m_Y; } - void y(float value) { - if (m_Y == value) { + void y(float value) + { + if (m_Y == value) + { return; } m_Y = value; yChanged(); } - void copy(const VertexBase& object) { + void copy(const VertexBase& object) + { m_X = object.m_X; m_Y = object.m_Y; ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case xPropertyKey: m_X = CoreDoubleType::deserialize(reader); return true; - case yPropertyKey: m_Y = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case xPropertyKey: + m_X = CoreDoubleType::deserialize(reader); + return true; + case yPropertyKey: + m_Y = CoreDoubleType::deserialize(reader); + return true; } return ContainerComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/transform_component_base.hpp b/include/rive/generated/transform_component_base.hpp index 0eb33f1..896ab06 100644 --- a/include/rive/generated/transform_component_base.hpp +++ b/include/rive/generated/transform_component_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_TRANSFORM_COMPONENT_BASE_HPP_ #include "rive/core/field_types/core_double_type.hpp" #include "rive/world_transform_component.hpp" -namespace rive { -class TransformComponentBase : public WorldTransformComponent { +namespace rive +{ +class TransformComponentBase : public WorldTransformComponent +{ protected: typedef WorldTransformComponent Super; @@ -12,13 +14,17 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case TransformComponentBase::typeKey: case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -35,8 +41,10 @@ public: inline float rotation() const { return m_Rotation; } - void rotation(float value) { - if (m_Rotation == value) { + void rotation(float value) + { + if (m_Rotation == value) + { return; } m_Rotation = value; @@ -44,8 +52,10 @@ } inline float scaleX() const { return m_ScaleX; } - void scaleX(float value) { - if (m_ScaleX == value) { + void scaleX(float value) + { + if (m_ScaleX == value) + { return; } m_ScaleX = value; @@ -53,26 +63,37 @@ } inline float scaleY() const { return m_ScaleY; } - void scaleY(float value) { - if (m_ScaleY == value) { + void scaleY(float value) + { + if (m_ScaleY == value) + { return; } m_ScaleY = value; scaleYChanged(); } - void copy(const TransformComponentBase& object) { + void copy(const TransformComponentBase& object) + { m_Rotation = object.m_Rotation; m_ScaleX = object.m_ScaleX; m_ScaleY = object.m_ScaleY; WorldTransformComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case rotationPropertyKey: m_Rotation = CoreDoubleType::deserialize(reader); return true; - case scaleXPropertyKey: m_ScaleX = CoreDoubleType::deserialize(reader); return true; - case scaleYPropertyKey: m_ScaleY = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case rotationPropertyKey: + m_Rotation = CoreDoubleType::deserialize(reader); + return true; + case scaleXPropertyKey: + m_ScaleX = CoreDoubleType::deserialize(reader); + return true; + case scaleYPropertyKey: + m_ScaleY = CoreDoubleType::deserialize(reader); + return true; } return WorldTransformComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/generated/world_transform_component_base.hpp b/include/rive/generated/world_transform_component_base.hpp index 5331fe4..169cb4f 100644 --- a/include/rive/generated/world_transform_component_base.hpp +++ b/include/rive/generated/world_transform_component_base.hpp
@@ -2,8 +2,10 @@ #define _RIVE_WORLD_TRANSFORM_COMPONENT_BASE_HPP_ #include "rive/container_component.hpp" #include "rive/core/field_types/core_double_type.hpp" -namespace rive { -class WorldTransformComponentBase : public ContainerComponent { +namespace rive +{ +class WorldTransformComponentBase : public ContainerComponent +{ protected: typedef ContainerComponent Super; @@ -12,12 +14,16 @@ /// Helper to quickly determine if a core object extends another without RTTI /// at runtime. - bool isTypeOf(uint16_t typeKey) const override { - switch (typeKey) { + bool isTypeOf(uint16_t typeKey) const override + { + switch (typeKey) + { case WorldTransformComponentBase::typeKey: case ContainerComponentBase::typeKey: - case ComponentBase::typeKey: return true; - default: return false; + case ComponentBase::typeKey: + return true; + default: + return false; } } @@ -30,22 +36,29 @@ public: inline float opacity() const { return m_Opacity; } - void opacity(float value) { - if (m_Opacity == value) { + void opacity(float value) + { + if (m_Opacity == value) + { return; } m_Opacity = value; opacityChanged(); } - void copy(const WorldTransformComponentBase& object) { + void copy(const WorldTransformComponentBase& object) + { m_Opacity = object.m_Opacity; ContainerComponent::copy(object); } - bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { - switch (propertyKey) { - case opacityPropertyKey: m_Opacity = CoreDoubleType::deserialize(reader); return true; + bool deserialize(uint16_t propertyKey, BinaryReader& reader) override + { + switch (propertyKey) + { + case opacityPropertyKey: + m_Opacity = CoreDoubleType::deserialize(reader); + return true; } return ContainerComponent::deserialize(propertyKey, reader); }
diff --git a/include/rive/hit_info.hpp b/include/rive/hit_info.hpp index 33f32b7..efbd03a 100644 --- a/include/rive/hit_info.hpp +++ b/include/rive/hit_info.hpp
@@ -8,11 +8,13 @@ #include "rive/math/aabb.hpp" #include <vector> -namespace rive { +namespace rive +{ class NestedArtboard; -struct HitInfo { +struct HitInfo +{ IAABB area; // input std::vector<NestedArtboard*> mounts; // output };
diff --git a/include/rive/hittest_command_path.hpp b/include/rive/hittest_command_path.hpp index 7cf8cbc..4b9ca17 100644 --- a/include/rive/hittest_command_path.hpp +++ b/include/rive/hittest_command_path.hpp
@@ -8,10 +8,12 @@ #include "rive/command_path.hpp" #include "rive/math/hit_test.hpp" -namespace rive { +namespace rive +{ class HitTester; -class HitTestCommandPath : public CommandPath { +class HitTestCommandPath : public CommandPath +{ HitTester m_Tester; Mat2D m_Xform; IAABB m_Area;
diff --git a/include/rive/importers/artboard_importer.hpp b/include/rive/importers/artboard_importer.hpp index 5aeaf28..a6fc955 100644 --- a/include/rive/importers/artboard_importer.hpp +++ b/include/rive/importers/artboard_importer.hpp
@@ -3,12 +3,14 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class Core; class Artboard; class LinearAnimation; class StateMachine; -class ArtboardImporter : public ImportStackObject { +class ArtboardImporter : public ImportStackObject +{ private: Artboard* m_Artboard;
diff --git a/include/rive/importers/backboard_importer.hpp b/include/rive/importers/backboard_importer.hpp index 8ab6918..f237931 100644 --- a/include/rive/importers/backboard_importer.hpp +++ b/include/rive/importers/backboard_importer.hpp
@@ -5,13 +5,15 @@ #include <unordered_map> #include <vector> -namespace rive { +namespace rive +{ class Artboard; class NestedArtboard; class Backboard; class FileAsset; class FileAssetReferencer; -class BackboardImporter : public ImportStackObject { +class BackboardImporter : public ImportStackObject +{ private: Backboard* m_Backboard; std::unordered_map<int, Artboard*> m_ArtboardLookup;
diff --git a/include/rive/importers/file_asset_importer.hpp b/include/rive/importers/file_asset_importer.hpp index 6af9fd9..7d80612 100644 --- a/include/rive/importers/file_asset_importer.hpp +++ b/include/rive/importers/file_asset_importer.hpp
@@ -5,13 +5,15 @@ #include <unordered_map> #include <vector> -namespace rive { +namespace rive +{ class FileAsset; class FileAssetContents; class FileAssetResolver; class Factory; -class FileAssetImporter : public ImportStackObject { +class FileAssetImporter : public ImportStackObject +{ private: bool m_LoadedContents = false; FileAsset* m_FileAsset;
diff --git a/include/rive/importers/import_stack.hpp b/include/rive/importers/import_stack.hpp index 26f5b59..841adb2 100644 --- a/include/rive/importers/import_stack.hpp +++ b/include/rive/importers/import_stack.hpp
@@ -6,63 +6,78 @@ #include <vector> #include <algorithm> -namespace rive { -class ImportStackObject { +namespace rive +{ +class ImportStackObject +{ public: virtual ~ImportStackObject() {} virtual StatusCode resolve() { return StatusCode::Ok; } virtual bool readNullObject() { return false; } }; -class ImportStack { +class ImportStack +{ private: std::unordered_map<uint16_t, ImportStackObject*> m_Latests; std::vector<ImportStackObject*> m_LastAdded; public: - template <typename T = ImportStackObject> T* latest(uint16_t coreType) { + template <typename T = ImportStackObject> T* latest(uint16_t coreType) + { auto itr = m_Latests.find(coreType); - if (itr == m_Latests.end()) { + if (itr == m_Latests.end()) + { return nullptr; } return reinterpret_cast<T*>(itr->second); } - StatusCode makeLatest(uint16_t coreType, ImportStackObject* object) { + StatusCode makeLatest(uint16_t coreType, ImportStackObject* object) + { // Clean up the old object in the stack. auto itr = m_Latests.find(coreType); - if (itr != m_Latests.end()) { + if (itr != m_Latests.end()) + { auto stackObject = itr->second; // Remove it from latests. auto itr = std::find(m_LastAdded.begin(), m_LastAdded.end(), stackObject); - if (itr != m_LastAdded.end()) { + if (itr != m_LastAdded.end()) + { m_LastAdded.erase(itr); } StatusCode code = stackObject->resolve(); delete stackObject; - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { m_Latests.erase(coreType); return code; } } // Set the new one. - if (object == nullptr) { + if (object == nullptr) + { m_Latests.erase(coreType); - } else { + } + else + { m_Latests[coreType] = object; m_LastAdded.push_back(object); } return StatusCode::Ok; } - StatusCode resolve() { - for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend(); itr++) { + StatusCode resolve() + { + for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend(); itr++) + { StatusCode code = (*itr)->resolve(); delete *itr; - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } } @@ -71,15 +86,20 @@ return StatusCode::Ok; } - ~ImportStack() { - for (auto& pair : m_Latests) { + ~ImportStack() + { + for (auto& pair : m_Latests) + { delete pair.second; } } - bool readNullObject() { - for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend(); itr++) { - if ((*itr)->readNullObject()) { + bool readNullObject() + { + for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend(); itr++) + { + if ((*itr)->readNullObject()) + { return true; } }
diff --git a/include/rive/importers/keyed_object_importer.hpp b/include/rive/importers/keyed_object_importer.hpp index 1149e1c..fd7abf1 100644 --- a/include/rive/importers/keyed_object_importer.hpp +++ b/include/rive/importers/keyed_object_importer.hpp
@@ -3,11 +3,13 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class Core; class KeyedObject; class KeyedProperty; -class KeyedObjectImporter : public ImportStackObject { +class KeyedObjectImporter : public ImportStackObject +{ private: KeyedObject* m_KeyedObject;
diff --git a/include/rive/importers/keyed_property_importer.hpp b/include/rive/importers/keyed_property_importer.hpp index 7aa8410..46096a9 100644 --- a/include/rive/importers/keyed_property_importer.hpp +++ b/include/rive/importers/keyed_property_importer.hpp
@@ -3,12 +3,14 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class Core; class KeyFrame; class KeyedProperty; class LinearAnimation; -class KeyedPropertyImporter : public ImportStackObject { +class KeyedPropertyImporter : public ImportStackObject +{ private: LinearAnimation* m_Animation; KeyedProperty* m_KeyedProperty;
diff --git a/include/rive/importers/layer_state_importer.hpp b/include/rive/importers/layer_state_importer.hpp index 7836210..d11d39a 100644 --- a/include/rive/importers/layer_state_importer.hpp +++ b/include/rive/importers/layer_state_importer.hpp
@@ -3,12 +3,14 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class LayerState; class StateTransition; class BlendAnimation; -class LayerStateImporter : public ImportStackObject { +class LayerStateImporter : public ImportStackObject +{ private: LayerState* m_State;
diff --git a/include/rive/importers/linear_animation_importer.hpp b/include/rive/importers/linear_animation_importer.hpp index 0146ef6..64a27bc 100644 --- a/include/rive/importers/linear_animation_importer.hpp +++ b/include/rive/importers/linear_animation_importer.hpp
@@ -3,11 +3,13 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class Core; class LinearAnimation; class KeyedObject; -class LinearAnimationImporter : public ImportStackObject { +class LinearAnimationImporter : public ImportStackObject +{ private: LinearAnimation* m_Animation;
diff --git a/include/rive/importers/state_machine_importer.hpp b/include/rive/importers/state_machine_importer.hpp index 220f46d..f00ae45 100644 --- a/include/rive/importers/state_machine_importer.hpp +++ b/include/rive/importers/state_machine_importer.hpp
@@ -3,12 +3,14 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class StateMachineInput; class StateMachineLayer; class StateMachineListener; class StateMachine; -class StateMachineImporter : public ImportStackObject { +class StateMachineImporter : public ImportStackObject +{ private: StateMachine* m_StateMachine;
diff --git a/include/rive/importers/state_machine_layer_importer.hpp b/include/rive/importers/state_machine_layer_importer.hpp index 8bab9a2..37f4de8 100644 --- a/include/rive/importers/state_machine_layer_importer.hpp +++ b/include/rive/importers/state_machine_layer_importer.hpp
@@ -3,12 +3,14 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class StateMachineLayer; class LayerState; class Artboard; -class StateMachineLayerImporter : public ImportStackObject { +class StateMachineLayerImporter : public ImportStackObject +{ private: StateMachineLayer* m_Layer; const Artboard* m_Artboard;
diff --git a/include/rive/importers/state_machine_listener_importer.hpp b/include/rive/importers/state_machine_listener_importer.hpp index f86b31e..4d5660a 100644 --- a/include/rive/importers/state_machine_listener_importer.hpp +++ b/include/rive/importers/state_machine_listener_importer.hpp
@@ -3,11 +3,13 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class StateMachineListener; class StateMachine; class ListenerAction; -class StateMachineListenerImporter : public ImportStackObject { +class StateMachineListenerImporter : public ImportStackObject +{ private: StateMachineListener* m_StateMachineListener;
diff --git a/include/rive/importers/state_transition_importer.hpp b/include/rive/importers/state_transition_importer.hpp index f6cb68f..f683cc2 100644 --- a/include/rive/importers/state_transition_importer.hpp +++ b/include/rive/importers/state_transition_importer.hpp
@@ -3,11 +3,13 @@ #include "rive/importers/import_stack.hpp" -namespace rive { +namespace rive +{ class StateTransition; class TransitionCondition; -class StateTransitionImporter : public ImportStackObject { +class StateTransitionImporter : public ImportStackObject +{ private: StateTransition* m_Transition;
diff --git a/include/rive/layout.hpp b/include/rive/layout.hpp index 30f7922..3be95f0 100644 --- a/include/rive/layout.hpp +++ b/include/rive/layout.hpp
@@ -1,9 +1,20 @@ #ifndef _RIVE_LAYOUT_HPP_ #define _RIVE_LAYOUT_HPP_ -namespace rive { -enum class Fit : unsigned char { fill, contain, cover, fitWidth, fitHeight, none, scaleDown }; +namespace rive +{ +enum class Fit : unsigned char +{ + fill, + contain, + cover, + fitWidth, + fitHeight, + none, + scaleDown +}; -class Alignment { +class Alignment +{ private: float m_X, m_Y;
diff --git a/include/rive/listener_type.hpp b/include/rive/listener_type.hpp index df7a19e..f128b65 100644 --- a/include/rive/listener_type.hpp +++ b/include/rive/listener_type.hpp
@@ -1,7 +1,9 @@ #ifndef _RIVE_LISTENER_TYPE_HPP_ #define _RIVE_LISTENER_TYPE_HPP_ -namespace rive { -enum class ListenerType : int { +namespace rive +{ +enum class ListenerType : int +{ enter = 0, exit = 1, down = 2,
diff --git a/include/rive/math/aabb.hpp b/include/rive/math/aabb.hpp index 0cf428a..0a7c400 100644 --- a/include/rive/math/aabb.hpp +++ b/include/rive/math/aabb.hpp
@@ -7,8 +7,10 @@ #include <cstddef> #include <limits> -namespace rive { -struct IAABB { +namespace rive +{ +struct IAABB +{ int32_t left, top, right, bottom; constexpr int width() const { return right - left; } @@ -19,7 +21,8 @@ IAABB offset(int dx, int dy) const { return {left + dx, top + dy, right + dx, bottom + dy}; } }; -class AABB { +class AABB +{ public: float minX, minY, maxX, maxY; @@ -27,13 +30,15 @@ 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(Span<Vec2D>); // computes the union of all points, or 0,0,0,0 - bool operator==(const AABB& o) const { + bool operator==(const AABB& o) const + { return minX == o.minX && minY == o.minY && maxX == o.maxX && maxY == o.maxY; } bool operator!=(const AABB& o) const { return !(*this == o); } @@ -48,7 +53,8 @@ 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 inset(float dx, float dy) const + { AABB r = {minX + dx, minY + dy, maxX - dx, maxY - dy}; assert(r.width() >= 0); assert(r.height() >= 0); @@ -62,7 +68,8 @@ /// Initialize an AABB to values that represent an invalid/collapsed /// AABB that can then expand to points that are added to it. /// - inline static AABB forExpansion() { + inline static AABB forExpansion() + { return AABB(std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), -std::numeric_limits<float>::max(),
diff --git a/include/rive/math/circle_constant.hpp b/include/rive/math/circle_constant.hpp index 6e3d867..e2e9a4b 100644 --- a/include/rive/math/circle_constant.hpp +++ b/include/rive/math/circle_constant.hpp
@@ -3,7 +3,8 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ constexpr float circleConstant = 0.552284749831f; constexpr float icircleConstant = 1.0f - circleConstant; } // namespace rive
diff --git a/include/rive/math/contour_measure.hpp b/include/rive/math/contour_measure.hpp index 88d6388..d7b00f6 100644 --- a/include/rive/math/contour_measure.hpp +++ b/include/rive/math/contour_measure.hpp
@@ -10,15 +10,18 @@ #include "rive/refcnt.hpp" #include <utility> -namespace rive { +namespace rive +{ -class ContourMeasure : public RefCnt<ContourMeasure> { +class ContourMeasure : public RefCnt<ContourMeasure> +{ public: static constexpr unsigned kMaxDot30 = (1 << 30) - 1; static constexpr float kInvScaleD30 = 1.0f / (float)kMaxDot30; // Deliberately making this pack well (12 bytes) - struct Segment { + struct Segment + { float m_distance; // total distance up to this point uint32_t m_ptIndex; // index of the first point for this line/quad/cubic unsigned m_tValue : 30; // Dot30 t value for the end of this segment @@ -48,14 +51,16 @@ float length() const { return m_length; } bool isClosed() const { return m_isClosed; } - struct PosTan { + struct PosTan + { Vec2D pos, tan; }; PosTan getPosTan(float distance) const; void getSegment(float startDistance, float endDistance, RawPath* dst, bool startWithMove) const; - Vec2D warp(Vec2D src) const { + Vec2D warp(Vec2D src) const + { const auto result = this->getPosTan(src.x); return { result.pos.x - result.tan.y * src.y, @@ -66,7 +71,8 @@ void dump() const; }; -class ContourMeasureIter { +class ContourMeasureIter +{ RawPath m_optionalCopy; RawPath::Iter m_iter; RawPath::Iter m_end; @@ -89,7 +95,8 @@ // approximation for the curves actual length. static constexpr float kDefaultTolerance = 0.5f; - ContourMeasureIter(const RawPath& path, float tol = kDefaultTolerance) { + ContourMeasureIter(const RawPath& path, float tol = kDefaultTolerance) + { this->reset(path, tol); }
diff --git a/include/rive/math/cubic_utilities.hpp b/include/rive/math/cubic_utilities.hpp index 4127fed..3450300 100644 --- a/include/rive/math/cubic_utilities.hpp +++ b/include/rive/math/cubic_utilities.hpp
@@ -4,18 +4,21 @@ #include "rive/math/vec2d.hpp" #include <algorithm> -namespace rive { +namespace rive +{ /// /// Utility functions for recursively subdividing a cubic. /// -class CubicUtilities { +class CubicUtilities +{ public: static void computeHull(const Vec2D& from, const Vec2D& fromOut, const Vec2D& toIn, const Vec2D& to, float t, - Vec2D* hull) { + Vec2D* hull) + { hull[0] = Vec2D::lerp(from, fromOut, t); hull[1] = Vec2D::lerp(fromOut, toIn, t); hull[2] = Vec2D::lerp(toIn, to, t); @@ -26,7 +29,8 @@ hull[5] = Vec2D::lerp(hull[3], hull[4], t); } - static bool tooFar(const Vec2D& a, const Vec2D& b, float threshold) { + static bool tooFar(const Vec2D& a, const Vec2D& b, float threshold) + { return std::max(std::abs(a.x - b.x), std::abs(a.y - b.y)) > threshold; } @@ -34,14 +38,16 @@ const Vec2D& fromOut, const Vec2D& toIn, const Vec2D& to, - float threshold) { + float threshold) + { Vec2D oneThird = Vec2D::lerp(from, to, 1.0f / 3.0f); Vec2D twoThird = Vec2D::lerp(from, to, 2.0f / 3.0f); return tooFar(fromOut, oneThird, threshold) || tooFar(toIn, twoThird, threshold); } - static float cubicAt(float t, float a, float b, float c, float d) { + static float cubicAt(float t, float a, float b, float c, float d) + { float ti = 1.0f - t; float value = ti * ti * ti * a + 3.0f * ti * ti * t * b + 3.0f * ti * t * t * c + t * t * t * d;
diff --git a/include/rive/math/hit_test.hpp b/include/rive/math/hit_test.hpp index 243bb26..d2baeb4 100644 --- a/include/rive/math/hit_test.hpp +++ b/include/rive/math/hit_test.hpp
@@ -13,9 +13,11 @@ #include <cstdint> #include <vector> -namespace rive { +namespace rive +{ -class HitTester { +class HitTester +{ std::vector<int> m_DW; // width * height delta-windings Vec2D m_First, m_Prev; Vec2D m_offset;
diff --git a/include/rive/math/mat2d.hpp b/include/rive/math/mat2d.hpp index 02f20f1..c798987 100644 --- a/include/rive/math/mat2d.hpp +++ b/include/rive/math/mat2d.hpp
@@ -4,9 +4,11 @@ #include "rive/math/vec2d.hpp" #include <cstddef> -namespace rive { +namespace rive +{ class TransformComponents; -class Mat2D { +class Mat2D +{ private: float m_Buffer[6]; @@ -14,7 +16,8 @@ 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} {} + m_Buffer{x1, y1, x2, y2, tx, ty} + {} inline const float* values() const { return m_Buffer; } @@ -27,7 +30,8 @@ void scaleByValues(float sx, float sy); - Mat2D& operator*=(const Mat2D& rhs) { + Mat2D& operator*=(const Mat2D& rhs) + { *this = Mat2D::multiply(*this, rhs); return *this; } @@ -36,7 +40,8 @@ // If returns false, result is unchnaged. bool invert(Mat2D* result) const; - Mat2D invertOrIdentity() const { + Mat2D invertOrIdentity() const + { Mat2D inverse; // initialized to identity (void)invert(&inverse); // inverse is unchanged if invert() fails return inverse; @@ -65,7 +70,8 @@ void ty(float value) { m_Buffer[5] = value; } }; -inline Vec2D operator*(const Mat2D& m, Vec2D v) { +inline Vec2D operator*(const Mat2D& m, Vec2D v) +{ return { m[0] * v.x + m[2] * v.y + m[4], m[1] * v.x + m[3] * v.y + m[5], @@ -74,7 +80,8 @@ inline Mat2D operator*(const Mat2D& a, const Mat2D& b) { return Mat2D::multiply(a, b); } -inline bool operator==(const Mat2D& a, const Mat2D& 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]; }
diff --git a/include/rive/math/math_types.hpp b/include/rive/math/math_types.hpp index 0f3d201..4785fc9 100644 --- a/include/rive/math/math_types.hpp +++ b/include/rive/math/math_types.hpp
@@ -8,9 +8,11 @@ #include "rive/rive_types.hpp" #include <cmath> -namespace rive { +namespace rive +{ -namespace math { +namespace math +{ constexpr float PI = 3.14159265f; }
diff --git a/include/rive/math/path_types.hpp b/include/rive/math/path_types.hpp index 5be3c58..010a19d 100644 --- a/include/rive/math/path_types.hpp +++ b/include/rive/math/path_types.hpp
@@ -7,14 +7,17 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ -enum class FillRule { +enum class FillRule +{ nonZero, evenOdd, }; -enum class PathDirection { +enum class PathDirection +{ cw, ccw, // aliases @@ -22,7 +25,8 @@ counterclockwise = ccw, }; -enum class PathVerb : uint8_t { +enum class PathVerb : uint8_t +{ // These deliberately match Skia's values move = 0, line = 1,
diff --git a/include/rive/math/raw_path.hpp b/include/rive/math/raw_path.hpp index 7514e93..ee6affc 100644 --- a/include/rive/math/raw_path.hpp +++ b/include/rive/math/raw_path.hpp
@@ -16,11 +16,13 @@ #include <cstdint> #include <vector> -namespace rive { +namespace rive +{ class CommandPath; -class RawPath { +class RawPath +{ public: bool operator==(const RawPath& o) const; bool operator!=(const RawPath& o) const { return !(*this == o); } @@ -53,7 +55,8 @@ Span<const PathVerb> verbs() const { return m_Verbs; } Span<PathVerb> verbs() { return m_Verbs; } - Span<const uint8_t> verbsU8() const { + Span<const uint8_t> verbsU8() const + { const uint8_t* ptr = (const uint8_t*)m_Verbs.data(); return Span<const uint8_t>(ptr, m_Verbs.size()); } @@ -63,7 +66,8 @@ 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) { + void cubicTo(float x, float y, float x1, float y1, float x2, float y2) + { cubic({x, y}, {x1, y1}, {x2, y2}); } @@ -79,7 +83,8 @@ // // for (auto [verb, pts] : rawPath) { ... } // - class Iter { + class Iter + { public: Iter() = default; Iter(const PathVerb* verbs, const Vec2D* pts) : m_verbs(verbs), m_pts(pts) {} @@ -89,25 +94,34 @@ PathVerb peekVerb() const { return *m_verbs; } - std::tuple<const PathVerb, const Vec2D* const> operator*() const { + std::tuple<const PathVerb, const Vec2D* const> operator*() const + { PathVerb verb = peekVerb(); return {verb, m_pts + PtsBacksetForVerb(verb)}; } - Iter& operator++() { // ++iter + Iter& operator++() + { // ++iter m_pts += PtsAdvanceAfterVerb(*m_verbs++); return *this; } private: // How much should we advance pts after encountering this verb? - constexpr static int PtsAdvanceAfterVerb(PathVerb verb) { - switch (verb) { - case PathVerb::move: return 1; - case PathVerb::line: return 1; - case PathVerb::quad: return 2; - case PathVerb::cubic: return 3; - case PathVerb::close: return 0; + constexpr static int PtsAdvanceAfterVerb(PathVerb verb) + { + switch (verb) + { + case PathVerb::move: + return 1; + case PathVerb::line: + return 1; + case PathVerb::quad: + return 2; + case PathVerb::cubic: + return 3; + case PathVerb::close: + return 0; } RIVE_UNREACHABLE; } @@ -116,13 +130,20 @@ // peeking backwards from the current point, which works as long as there is always a // PathVerb::move before any geometry. (injectImplicitMoveToIfNeeded() guarantees this // to be the case.) - constexpr static int PtsBacksetForVerb(PathVerb verb) { - switch (verb) { - case PathVerb::move: return 0; - case PathVerb::line: return -1; - case PathVerb::quad: return -1; - case PathVerb::cubic: return -1; - case PathVerb::close: return -1; + constexpr static int PtsBacksetForVerb(PathVerb verb) + { + switch (verb) + { + case PathVerb::move: + return 0; + case PathVerb::line: + return -1; + case PathVerb::quad: + return -1; + case PathVerb::cubic: + return -1; + case PathVerb::close: + return -1; } RIVE_UNREACHABLE; } @@ -133,16 +154,29 @@ Iter begin() const { return {m_Verbs.data(), m_Points.data()}; } Iter end() const { return {m_Verbs.data() + m_Verbs.size(), nullptr}; } - template <typename Handler> RawPath morph(Handler proc) const { + template <typename Handler> RawPath morph(Handler proc) const + { RawPath dst; // todo: dst.reserve(src.ptCount, src.verbCount); - for (auto [verb, pts] : *this) { - switch (verb) { - case PathVerb::move: dst.move(proc(pts[0])); break; - case PathVerb::line: dst.line(proc(pts[1])); break; - case PathVerb::quad: dst.quad(proc(pts[1]), proc(pts[2])); break; - case PathVerb::cubic: dst.cubic(proc(pts[1]), proc(pts[2]), proc(pts[3])); break; - case PathVerb::close: dst.close(); break; + for (auto [verb, pts] : *this) + { + switch (verb) + { + case PathVerb::move: + dst.move(proc(pts[0])); + break; + case PathVerb::line: + dst.line(proc(pts[1])); + break; + case PathVerb::quad: + dst.quad(proc(pts[1]), proc(pts[2])); + break; + case PathVerb::cubic: + dst.cubic(proc(pts[1]), proc(pts[2]), proc(pts[3])); + break; + case PathVerb::close: + dst.close(); + break; } } return dst;
diff --git a/include/rive/math/raw_path_utils.hpp b/include/rive/math/raw_path_utils.hpp index d0da2c3..bbbae80 100644 --- a/include/rive/math/raw_path_utils.hpp +++ b/include/rive/math/raw_path_utils.hpp
@@ -7,7 +7,8 @@ #include "rive/math/vec2d.hpp" -namespace rive { +namespace rive +{ static inline Vec2D two(Vec2D v) { return v + v; } // Caches the setup to evaluate a quadratic bezier. Useful if you @@ -28,7 +29,8 @@ // Caches the setup to evaluate a cubic bezier. Useful if you // want to evaluate the save curve at multiple t values. -struct EvalCubic { +struct EvalCubic +{ const Vec2D a, b, c, d; // at^3 + bt^2 + ct + d // pts are the 4 cubic bezier control points @@ -36,7 +38,8 @@ a(pts[3] + 3 * (pts[1] - pts[2]) - pts[0]), b(3 * (pts[2] - two(pts[1]) + pts[0])), c(3 * (pts[1] - pts[0])), - d(pts[0]) {} + d(pts[0]) + {} Vec2D operator()(float t) const { return ((a * t + b) * t + c) * t + d; } };
diff --git a/include/rive/math/simd.hpp b/include/rive/math/simd.hpp index adbbd7d..3d4e5a5 100644 --- a/include/rive/math/simd.hpp +++ b/include/rive/math/simd.hpp
@@ -18,8 +18,10 @@ #define SIMD_ALWAYS_INLINE inline __attribute__((always_inline)) -namespace rive { -namespace simd { +namespace rive +{ +namespace simd +{ // The GLSL spec uses "gvec" to denote a vector of unspecified type. template <typename T, int N> @@ -29,19 +31,22 @@ // Similar to std::min(), with a noteworthy difference: // If a[i] or b[i] is NaN and the other is not, returns whichever is _not_ NaN. -template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> min(gvec<T, N> a, gvec<T, N> b) { +template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> min(gvec<T, N> a, gvec<T, N> b) +{ return __builtin_elementwise_min(a, b); } // Similar to std::max(), with a noteworthy difference: // If a[i] or b[i] is NaN and the other is not, returns whichever is _not_ NaN. -template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> max(gvec<T, N> a, gvec<T, N> b) { +template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> max(gvec<T, N> a, gvec<T, N> b) +{ return __builtin_elementwise_max(a, b); } // Returns the absolute value of x per element, with one exception: // If x[i] is an integer type and equal to the minimum representable value, returns x[i]. -template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> abs(gvec<T, N> x) { +template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> abs(gvec<T, N> x) +{ return __builtin_elementwise_abs(x); } @@ -52,10 +57,12 @@ // // Returns true if all elements in x are equal to 0. -template <int N> SIMD_ALWAYS_INLINE bool any(gvec<int32_t, N> x) { +template <int N> SIMD_ALWAYS_INLINE bool any(gvec<int32_t, N> x) +{ // This particular logic structure gets decent codegen in clang. // TODO: __builtin_reduce_or(x) once it's implemented in the compiler. - for (int i = 0; i < N; ++i) { + for (int i = 0; i < N; ++i) + { if (x[i]) return true; } @@ -63,7 +70,8 @@ } // Returns true if all elements in x are equal to ~0. -template <int N> SIMD_ALWAYS_INLINE bool all(gvec<int32_t, N> x) { +template <int N> SIMD_ALWAYS_INLINE bool all(gvec<int32_t, N> x) +{ // In vector, true is represented by -1 exactly, so we use ~x for "not". // TODO: __builtin_reduce_and(x) once it's implemented in the compiler. return !any(~x); @@ -71,7 +79,8 @@ ////// Loading and storing ////// -template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> load(const T* ptr) { +template <typename T, int N> SIMD_ALWAYS_INLINE gvec<T, N> load(const T* ptr) +{ gvec<T, N> vec; __builtin_memcpy(&vec, ptr, sizeof(vec)); return vec; @@ -83,7 +92,8 @@ SIMD_ALWAYS_INLINE gvec<uint32_t, 2> load2ui(const uint32_t* ptr) { return load<uint32_t, 2>(ptr); } SIMD_ALWAYS_INLINE gvec<uint32_t, 4> load4ui(const uint32_t* ptr) { return load<uint32_t, 4>(ptr); } -template <typename T, int N> SIMD_ALWAYS_INLINE void store(T* ptr, gvec<T, N> vec) { +template <typename T, int N> SIMD_ALWAYS_INLINE void store(T* ptr, gvec<T, N> vec) +{ __builtin_memcpy(ptr, &vec, sizeof(vec)); } @@ -92,7 +102,8 @@ #undef SIMD_ALWAYS_INLINE -namespace rive { +namespace rive +{ template <int N> using vec = simd::gvec<float, N>; using float2 = vec<2>;
diff --git a/include/rive/math/transform_components.hpp b/include/rive/math/transform_components.hpp index b6190d5..d3726da 100644 --- a/include/rive/math/transform_components.hpp +++ b/include/rive/math/transform_components.hpp
@@ -3,8 +3,10 @@ #include "rive/math/vec2d.hpp" -namespace rive { -class TransformComponents { +namespace rive +{ +class TransformComponents +{ private: float m_X; float m_Y; @@ -15,14 +17,16 @@ 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), m_ScaleX(copy.m_ScaleX), m_ScaleY(copy.m_ScaleY), m_Rotation(copy.m_Rotation), - m_Skew(copy.m_Skew) {} + m_Skew(copy.m_Skew) + {} float x() const { return m_X; } void x(float value) { m_X = value; } @@ -40,7 +44,8 @@ Vec2D translation() const { return {m_X, m_Y}; } Vec2D scale() const { return {m_ScaleX, m_ScaleY}; } - TransformComponents& operator=(const TransformComponents& a) { + TransformComponents& operator=(const TransformComponents& a) + { m_X = a.m_X; m_Y = a.m_Y; m_ScaleX = a.m_ScaleX;
diff --git a/include/rive/math/vec2d.hpp b/include/rive/math/vec2d.hpp index 58bb129..c173bd1 100644 --- a/include/rive/math/vec2d.hpp +++ b/include/rive/math/vec2d.hpp
@@ -3,9 +3,11 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ class Mat2D; -class Vec2D { +class Vec2D +{ public: float x, y; @@ -18,7 +20,8 @@ Vec2D normalized() const; // Normalize this Vec, and return its previous length - float normalizeLength() { + float normalizeLength() + { const float len = this->length(); x /= len; y /= len; @@ -27,12 +30,14 @@ Vec2D operator-() const { return {-x, -y}; } - void operator*=(float s) { + void operator*=(float s) + { x *= s; y *= s; } - void operator/=(float s) { + void operator/=(float s) + { x /= s; y /= s; } @@ -45,7 +50,8 @@ static float dot(Vec2D a, Vec2D b) { return a.x * b.x + a.y * b.y; } static float cross(Vec2D a, Vec2D b) { return a.x * b.y - a.y * b.x; } - static Vec2D scaleAndAdd(Vec2D a, Vec2D b, float scale) { + static Vec2D scaleAndAdd(Vec2D a, Vec2D b, float scale) + { return { a.x + b.x * scale, a.y + b.y * scale, @@ -54,12 +60,14 @@ 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(); } - Vec2D& operator+=(Vec2D v) { + Vec2D& operator+=(Vec2D v) + { x += v.x; y += v.y; return *this; } - Vec2D& operator-=(Vec2D v) { + Vec2D& operator-=(Vec2D v) + { x -= v.x; y -= v.y; return *this;
diff --git a/include/rive/nested_animation.hpp b/include/rive/nested_animation.hpp index 77b2906..dae7877 100644 --- a/include/rive/nested_animation.hpp +++ b/include/rive/nested_animation.hpp
@@ -2,10 +2,12 @@ #define _RIVE_NESTED_ANIMATION_HPP_ #include "rive/generated/nested_animation_base.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class ArtboardInstance; -class NestedAnimation : public NestedAnimationBase { +class NestedAnimation : public NestedAnimationBase +{ public: StatusCode onAddedDirty(CoreContext* context) override;
diff --git a/include/rive/nested_artboard.hpp b/include/rive/nested_artboard.hpp index ff70e99..befffb8 100644 --- a/include/rive/nested_artboard.hpp +++ b/include/rive/nested_artboard.hpp
@@ -6,10 +6,12 @@ #include "rive/span.hpp" #include <stdio.h> -namespace rive { +namespace rive +{ class ArtboardInstance; class NestedAnimation; -class NestedArtboard : public NestedArtboardBase { +class NestedArtboard : public NestedArtboardBase +{ private: Artboard* m_Artboard = nullptr; // might point to m_Instance, and might not
diff --git a/include/rive/node.hpp b/include/rive/node.hpp index 91df9f3..90de2fb 100644 --- a/include/rive/node.hpp +++ b/include/rive/node.hpp
@@ -2,9 +2,11 @@ #define _RIVE_NODE_HPP_ #include "rive/generated/node_base.hpp" -namespace rive { +namespace rive +{ /// A Rive Node -class Node : public NodeBase { +class Node : public NodeBase +{ protected: void xChanged() override; void yChanged() override;
diff --git a/include/rive/pointer_event.hpp b/include/rive/pointer_event.hpp index 141d830..da1bb55 100644 --- a/include/rive/pointer_event.hpp +++ b/include/rive/pointer_event.hpp
@@ -3,15 +3,18 @@ #include "rive/math/vec2d.hpp" -namespace rive { +namespace rive +{ -enum class PointerEventType { +enum class PointerEventType +{ down, // The button has gone from up to down move, // The pointer's position has changed up, // The button has gone from down to up }; -struct PointerEvent { +struct PointerEvent +{ PointerEventType m_Type; Vec2D m_Position; int m_PointerIndex;
diff --git a/include/rive/refcnt.hpp b/include/rive/refcnt.hpp index d11104c..55f0ec8 100644 --- a/include/rive/refcnt.hpp +++ b/include/rive/refcnt.hpp
@@ -27,9 +27,11 @@ * Both of these inspired by Skia's SkRefCnt and sk_sp */ -namespace rive { +namespace rive +{ -template <typename T> class RefCnt { +template <typename T> class RefCnt +{ public: RefCnt() : m_refcnt(1) {} @@ -37,8 +39,10 @@ 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); @@ -60,22 +64,27 @@ RefCnt& operator=(const RefCnt&) = delete; }; -template <typename T> static inline T* safe_ref(T* obj) { - if (obj) { +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) { +template <typename T> static inline void safe_unref(T* obj) +{ + if (obj) + { obj->unref(); } } // rcp : smart point template for holding subclasses of RefCnt -template <typename T> class rcp { +template <typename T> class rcp +{ public: constexpr rcp() : m_ptr(nullptr) {} constexpr rcp(std::nullptr_t) : m_ptr(nullptr) {} @@ -89,24 +98,29 @@ */ ~rcp() { safe_unref(m_ptr); } - rcp<T>& operator=(std::nullptr_t) { + rcp<T>& operator=(std::nullptr_t) + { this->reset(); return *this; } - rcp<T>& operator=(const rcp<T>& other) { - if (this != &other) { + rcp<T>& operator=(const rcp<T>& other) + { + if (this != &other) + { this->reset(safe_ref(other.get())); } return *this; } - rcp<T>& operator=(rcp<T>&& other) { + rcp<T>& operator=(rcp<T>&& other) + { this->reset(other.release()); return *this; } - T& operator*() const { + T& operator*() const + { assert(this->get() != nullptr); return *this->get(); } @@ -118,7 +132,8 @@ // Unrefs the current pointer, and accepts the new pointer, but // DOES NOT increment ownership of the new pointer. - void reset(T* ptr = nullptr) { + 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 @@ -129,7 +144,8 @@ // 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* release() + { T* ptr = m_ptr; m_ptr = nullptr; return ptr; @@ -143,7 +159,8 @@ template <typename T> inline void swap(rcp<T>& a, rcp<T>& b) { a.swap(b); } -template <typename T, typename... Args> rcp<T> inline make_rcp(Args&&... args) { +template <typename T, typename... Args> rcp<T> inline make_rcp(Args&&... args) +{ return rcp<T>(new T(std::forward<Args>(args)...)); } @@ -151,19 +168,23 @@ 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) { +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) { +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) { +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) { +template <typename T, typename U> inline bool operator!=(const rcp<T>& a, const rcp<U>& b) +{ return a.get() != b.get(); }
diff --git a/include/rive/relative_local_asset_resolver.hpp b/include/rive/relative_local_asset_resolver.hpp index 5679534..fb4a74e 100644 --- a/include/rive/relative_local_asset_resolver.hpp +++ b/include/rive/relative_local_asset_resolver.hpp
@@ -6,27 +6,32 @@ #include <cstdio> #include <string> -namespace rive { +namespace rive +{ class FileAsset; class Factory; /// An implementation of FileAssetResolver which finds the assets in a local /// path relative to the original .riv file looking for them. -class RelativeLocalAssetResolver : public FileAssetResolver { +class RelativeLocalAssetResolver : public FileAssetResolver +{ private: std::string m_Path; Factory* m_Factory; public: - RelativeLocalAssetResolver(std::string filename, Factory* factory) : m_Factory(factory) { + RelativeLocalAssetResolver(std::string filename, Factory* factory) : m_Factory(factory) + { std::size_t finalSlash = filename.rfind('/'); - if (finalSlash != std::string::npos) { + if (finalSlash != std::string::npos) + { m_Path = filename.substr(0, finalSlash + 1); } } - void loadContents(FileAsset& asset) override { + void loadContents(FileAsset& asset) override + { std::string filename = m_Path + asset.uniqueFilename(); FILE* fp = fopen(filename.c_str(), "rb"); @@ -34,7 +39,8 @@ const size_t length = ftell(fp); fseek(fp, 0, SEEK_SET); uint8_t* bytes = new uint8_t[length]; - if (fread(bytes, 1, length, fp) == length) { + if (fread(bytes, 1, length, fp) == length) + { asset.decode(Span<const uint8_t>(bytes, length), m_Factory); } delete[] bytes;
diff --git a/include/rive/render_text.hpp b/include/rive/render_text.hpp index b9c35a1..d7827ed 100644 --- a/include/rive/render_text.hpp +++ b/include/rive/render_text.hpp
@@ -10,7 +10,8 @@ #include "rive/span.hpp" #include "rive/simple_array.hpp" -namespace rive { +namespace rive +{ using Unichar = uint32_t; using GlyphID = uint16_t; @@ -18,11 +19,13 @@ struct RenderTextRun; struct RenderGlyphRun; -class RenderFont : public RefCnt<RenderFont> { +class RenderFont : public RefCnt<RenderFont> +{ public: virtual ~RenderFont() {} - struct LineMetrics { + struct LineMetrics + { float ascent, descent; }; @@ -32,7 +35,8 @@ // -- may only be needed by Editor // -- so it may be removed from here later // - struct Axis { + struct Axis + { uint32_t tag; float min; float def; // default value @@ -46,7 +50,8 @@ // virtual std::vector<Axis> getAxes() const = 0; - struct Coord { + struct Coord + { uint32_t axis; float value; }; @@ -80,20 +85,24 @@ const LineMetrics m_LineMetrics; }; -struct RenderTextRun { +struct RenderTextRun +{ rcp<RenderFont> font; float size; uint32_t unicharCount; }; -struct RenderGlyphRun { +struct RenderGlyphRun +{ RenderGlyphRun(size_t glyphCount = 0) : - glyphs(glyphCount), textIndices(glyphCount), xpos(glyphCount + 1) {} + glyphs(glyphCount), textIndices(glyphCount), xpos(glyphCount + 1) + {} RenderGlyphRun(rive::SimpleArray<GlyphID> glyphIds, rive::SimpleArray<uint32_t> offsets, rive::SimpleArray<float> xs) : - glyphs(glyphIds), textIndices(offsets), xpos(xs) {} + glyphs(glyphIds), textIndices(offsets), xpos(xs) + {} rcp<RenderFont> font; float size;
diff --git a/include/rive/renderer.hpp b/include/rive/renderer.hpp index b4a72eb..46afa23 100644 --- a/include/rive/renderer.hpp +++ b/include/rive/renderer.hpp
@@ -20,14 +20,16 @@ #include <stdio.h> #include <cstdint> -namespace rive { +namespace rive +{ class Vec2D; // Helper that computes a matrix to "align" content (source) to fit inside frame (destination). Mat2D computeAlignment(Fit, Alignment, const AABB& frame, const AABB& content); // A render buffer holds an immutable array of values -class RenderBuffer : public RefCnt<RenderBuffer> { +class RenderBuffer : public RefCnt<RenderBuffer> +{ const size_t m_Count; public: @@ -37,7 +39,11 @@ size_t count() const { return m_Count; } }; -enum class RenderPaintStyle { stroke, fill }; +enum class RenderPaintStyle +{ + stroke, + fill +}; /* * Base class for Render objects that specify the src colors. @@ -47,13 +53,15 @@ * It is common that a shader may be created with a 'localMatrix'. If this is * not null, then it is applied to the shader's domain before the Renderer's CTM. */ -class RenderShader : public RefCnt<RenderShader> { +class RenderShader : public RefCnt<RenderShader> +{ public: RenderShader(); virtual ~RenderShader(); }; -class RenderPaint { +class RenderPaint +{ public: RenderPaint(); virtual ~RenderPaint(); @@ -68,7 +76,8 @@ virtual void invalidateStroke() = 0; }; -class RenderImage { +class RenderImage +{ protected: int m_Width = 0; int m_Height = 0; @@ -84,20 +93,23 @@ const Mat2D& uvTransform() const { return m_uvTransform; } }; -class RenderPath : public CommandPath { +class RenderPath : public CommandPath +{ public: RenderPath(); ~RenderPath() override; RenderPath* renderPath() override { return this; } - void addPath(CommandPath* path, const Mat2D& transform) override { + void addPath(CommandPath* path, const Mat2D& transform) override + { addRenderPath(path->renderPath(), transform); } virtual void addRenderPath(RenderPath* path, const Mat2D& transform) = 0; }; -class Renderer { +class Renderer +{ public: virtual ~Renderer() {} virtual void save() = 0; @@ -119,7 +131,8 @@ void scale(float sx, float sy); void rotate(float radians); - void align(Fit fit, Alignment alignment, const AABB& frame, const AABB& content) { + void align(Fit fit, Alignment alignment, const AABB& frame, const AABB& content) + { transform(computeAlignment(fit, alignment, frame, content)); } };
diff --git a/include/rive/renderer_utils.hpp b/include/rive/renderer_utils.hpp index 47bcc9c..5850689 100644 --- a/include/rive/renderer_utils.hpp +++ b/include/rive/renderer_utils.hpp
@@ -9,20 +9,25 @@ #include "rive/core/type_conversions.hpp" #include <string> -template <size_t N, typename T> class AutoSTArray { +template <size_t N, typename T> class AutoSTArray +{ T m_storage[N]; T* m_ptr; const size_t m_count; public: - AutoSTArray(size_t n) : m_count(n) { + AutoSTArray(size_t n) : m_count(n) + { m_ptr = m_storage; - if (n > N) { + if (n > N) + { m_ptr = new T[n]; } } - ~AutoSTArray() { - if (m_ptr != m_storage) { + ~AutoSTArray() + { + if (m_ptr != m_storage) + { delete[] m_ptr; } } @@ -32,17 +37,20 @@ T* data() const { return m_ptr; } - T& operator[](size_t index) { + T& operator[](size_t index) + { assert(index < m_count); return m_ptr[index]; } }; -constexpr inline uint32_t make_tag(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { +constexpr inline uint32_t make_tag(uint8_t a, uint8_t b, uint8_t c, uint8_t d) +{ return (a << 24) | (b << 16) | (c << 8) | d; } -static inline std::string tag2str(uint32_t tag) { +static inline std::string tag2str(uint32_t tag) +{ std::string str = "abcd"; str[0] = (tag >> 24) & 0xFF; str[1] = (tag >> 16) & 0xFF;
diff --git a/include/rive/rive_counter.hpp b/include/rive/rive_counter.hpp index 09e83a0..a378924 100644 --- a/include/rive/rive_counter.hpp +++ b/include/rive/rive_counter.hpp
@@ -7,10 +7,13 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ -struct Counter { - enum Type { +struct Counter +{ + enum Type + { kFile, kArtboardInstance, kLinearAnimationInstance, @@ -28,7 +31,8 @@ static constexpr int kNumTypes = Type::kLastType + 1; static int counts[kNumTypes]; - static void update(Type ct, int delta) { + static void update(Type ct, int delta) + { assert(delta == 1 || delta == -1); counts[ct] += delta; assert(counts[ct] >= 0);
diff --git a/include/rive/runtime_header.hpp b/include/rive/runtime_header.hpp index cbe63e0..122f298 100644 --- a/include/rive/runtime_header.hpp +++ b/include/rive/runtime_header.hpp
@@ -4,13 +4,15 @@ #include "rive/core/binary_reader.hpp" #include <unordered_map> -namespace rive { +namespace rive +{ /// Rive file runtime header. The header is fonud at the beginning of every /// Rive runtime file, and begins with a specific 4-byte format: "RIVE". /// This is followed by the major and minor version of Rive used to create /// the file. Finally the owner and file ids are at the end of header; these /// unsigned integers may be zero. -class RuntimeHeader { +class RuntimeHeader +{ private: static constexpr char fingerprint[] = "RIVE"; @@ -27,9 +29,11 @@ /// @returns the file's id; may be zero int fileId() const { return m_FileId; } - int propertyFieldId(int propertyKey) const { + int propertyFieldId(int propertyKey) const + { auto itr = m_PropertyToFieldIndex.find(propertyKey); - if (itr == m_PropertyToFieldIndex.end()) { + if (itr == m_PropertyToFieldIndex.end()) + { return -1; } @@ -40,26 +44,32 @@ /// @param reader the binary reader attached to the buffer /// @param header a pointer to the header where the data will be stored. /// @returns true if the header is successfully read - static bool read(BinaryReader& reader, RuntimeHeader& header) { - for (int i = 0; i < 4; i++) { + static bool read(BinaryReader& reader, RuntimeHeader& header) + { + for (int i = 0; i < 4; i++) + { auto b = reader.readByte(); - if (fingerprint[i] != b) { + if (fingerprint[i] != b) + { return false; } } header.m_MajorVersion = reader.readVarUintAs<int>(); - if (reader.didOverflow()) { + if (reader.didOverflow()) + { return false; } header.m_MinorVersion = reader.readVarUintAs<int>(); - if (reader.didOverflow()) { + if (reader.didOverflow()) + { return false; } header.m_FileId = reader.readVarUintAs<int>(); - if (reader.didOverflow()) { + if (reader.didOverflow()) + { return false; } @@ -68,22 +78,26 @@ propertyKey = reader.readVarUintAs<int>()) { propertyKeys.push_back(propertyKey); - if (reader.didOverflow()) { + if (reader.didOverflow()) + { return false; } } int currentInt = 0; int currentBit = 8; - for (auto propertyKey : propertyKeys) { - if (currentBit == 8) { + for (auto propertyKey : propertyKeys) + { + if (currentBit == 8) + { currentInt = reader.readUint32(); currentBit = 0; } int fieldIndex = (currentInt >> currentBit) & 3; header.m_PropertyToFieldIndex[propertyKey] = fieldIndex; currentBit += 2; - if (reader.didOverflow()) { + if (reader.didOverflow()) + { return false; } }
diff --git a/include/rive/scene.hpp b/include/rive/scene.hpp index fcafc0c..20a9e6a 100644 --- a/include/rive/scene.hpp +++ b/include/rive/scene.hpp
@@ -6,7 +6,8 @@ #include "rive/math/vec2d.hpp" #include <string> -namespace rive { +namespace rive +{ class ArtboardInstance; class Renderer; @@ -15,7 +16,8 @@ class SMINumber; class SMITrigger; -class Scene { +class Scene +{ protected: ArtboardInstance* m_ArtboardInstance;
diff --git a/include/rive/shapes/clipping_shape.hpp b/include/rive/shapes/clipping_shape.hpp index e990298..3657013 100644 --- a/include/rive/shapes/clipping_shape.hpp +++ b/include/rive/shapes/clipping_shape.hpp
@@ -5,11 +5,13 @@ #include <stdio.h> #include <vector> -namespace rive { +namespace rive +{ class Shape; class Node; class RenderPath; -class ClippingShape : public ClippingShapeBase { +class ClippingShape : public ClippingShapeBase +{ private: std::vector<Shape*> m_Shapes; Node* m_Source = nullptr;
diff --git a/include/rive/shapes/contour_mesh_vertex.hpp b/include/rive/shapes/contour_mesh_vertex.hpp index 3b274de..850b4ac 100644 --- a/include/rive/shapes/contour_mesh_vertex.hpp +++ b/include/rive/shapes/contour_mesh_vertex.hpp
@@ -2,8 +2,10 @@ #define _RIVE_CONTOUR_MESH_VERTEX_HPP_ #include "rive/generated/shapes/contour_mesh_vertex_base.hpp" -namespace rive { -class ContourMeshVertex : public ContourMeshVertexBase { +namespace rive +{ +class ContourMeshVertex : public ContourMeshVertexBase +{ public: }; } // namespace rive
diff --git a/include/rive/shapes/cubic_asymmetric_vertex.hpp b/include/rive/shapes/cubic_asymmetric_vertex.hpp index 553a807..98701f0 100644 --- a/include/rive/shapes/cubic_asymmetric_vertex.hpp +++ b/include/rive/shapes/cubic_asymmetric_vertex.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CUBIC_ASYMMETRIC_VERTEX_HPP_ #define _RIVE_CUBIC_ASYMMETRIC_VERTEX_HPP_ #include "rive/generated/shapes/cubic_asymmetric_vertex_base.hpp" -namespace rive { -class CubicAsymmetricVertex : public CubicAsymmetricVertexBase { +namespace rive +{ +class CubicAsymmetricVertex : public CubicAsymmetricVertexBase +{ protected: void computeIn() override; void computeOut() override;
diff --git a/include/rive/shapes/cubic_detached_vertex.hpp b/include/rive/shapes/cubic_detached_vertex.hpp index e84d23b..14e679d 100644 --- a/include/rive/shapes/cubic_detached_vertex.hpp +++ b/include/rive/shapes/cubic_detached_vertex.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CUBIC_DETACHED_VERTEX_HPP_ #define _RIVE_CUBIC_DETACHED_VERTEX_HPP_ #include "rive/generated/shapes/cubic_detached_vertex_base.hpp" -namespace rive { -class CubicDetachedVertex : public CubicDetachedVertexBase { +namespace rive +{ +class CubicDetachedVertex : public CubicDetachedVertexBase +{ protected: void computeIn() override; void computeOut() override;
diff --git a/include/rive/shapes/cubic_mirrored_vertex.hpp b/include/rive/shapes/cubic_mirrored_vertex.hpp index 859164b..c32df04 100644 --- a/include/rive/shapes/cubic_mirrored_vertex.hpp +++ b/include/rive/shapes/cubic_mirrored_vertex.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_CUBIC_MIRRORED_VERTEX_HPP_ #define _RIVE_CUBIC_MIRRORED_VERTEX_HPP_ #include "rive/generated/shapes/cubic_mirrored_vertex_base.hpp" -namespace rive { -class CubicMirroredVertex : public CubicMirroredVertexBase { +namespace rive +{ +class CubicMirroredVertex : public CubicMirroredVertexBase +{ protected: void computeIn() override; void computeOut() override;
diff --git a/include/rive/shapes/cubic_vertex.hpp b/include/rive/shapes/cubic_vertex.hpp index 05476c5..31ae2d9 100644 --- a/include/rive/shapes/cubic_vertex.hpp +++ b/include/rive/shapes/cubic_vertex.hpp
@@ -3,9 +3,11 @@ #include "rive/generated/shapes/cubic_vertex_base.hpp" #include "rive/math/vec2d.hpp" -namespace rive { +namespace rive +{ class Vec2D; -class CubicVertex : public CubicVertexBase { +class CubicVertex : public CubicVertexBase +{ protected: bool m_InValid = false; bool m_OutValid = false;
diff --git a/include/rive/shapes/ellipse.hpp b/include/rive/shapes/ellipse.hpp index fde5a1a..750ade0 100644 --- a/include/rive/shapes/ellipse.hpp +++ b/include/rive/shapes/ellipse.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/shapes/ellipse_base.hpp" #include "rive/shapes/cubic_detached_vertex.hpp" -namespace rive { -class Ellipse : public EllipseBase { +namespace rive +{ +class Ellipse : public EllipseBase +{ CubicDetachedVertex m_Vertex1, m_Vertex2, m_Vertex3, m_Vertex4; public:
diff --git a/include/rive/shapes/image.hpp b/include/rive/shapes/image.hpp index 846476b..421a404 100644 --- a/include/rive/shapes/image.hpp +++ b/include/rive/shapes/image.hpp
@@ -5,10 +5,12 @@ #include "rive/generated/shapes/image_base.hpp" #include "rive/assets/file_asset_referencer.hpp" -namespace rive { +namespace rive +{ class ImageAsset; class Mesh; -class Image : public ImageBase, public FileAssetReferencer { +class Image : public ImageBase, public FileAssetReferencer +{ private: ImageAsset* m_ImageAsset = nullptr; Mesh* m_Mesh = nullptr;
diff --git a/include/rive/shapes/mesh.hpp b/include/rive/shapes/mesh.hpp index c7a0872..a833d0f 100644 --- a/include/rive/shapes/mesh.hpp +++ b/include/rive/shapes/mesh.hpp
@@ -6,13 +6,16 @@ #include "rive/refcnt.hpp" #include "rive/renderer.hpp" -namespace rive { +namespace rive +{ class MeshVertex; -class Mesh : public MeshBase, public Skinnable { +class Mesh : public MeshBase, public Skinnable +{ protected: - class IndexBuffer : public std::vector<uint16_t>, public RefCnt<IndexBuffer> {}; + class IndexBuffer : public std::vector<uint16_t>, public RefCnt<IndexBuffer> + {}; std::vector<MeshVertex*> m_Vertices; rcp<IndexBuffer> m_IndexBuffer;
diff --git a/include/rive/shapes/mesh_vertex.hpp b/include/rive/shapes/mesh_vertex.hpp index 69cdedd..2b8c04f 100644 --- a/include/rive/shapes/mesh_vertex.hpp +++ b/include/rive/shapes/mesh_vertex.hpp
@@ -2,8 +2,10 @@ #define _RIVE_MESH_VERTEX_HPP_ #include "rive/generated/shapes/mesh_vertex_base.hpp" #include <stdio.h> -namespace rive { -class MeshVertex : public MeshVertexBase { +namespace rive +{ +class MeshVertex : public MeshVertexBase +{ public: void markGeometryDirty() override; StatusCode onAddedDirty(CoreContext* context) override;
diff --git a/include/rive/shapes/metrics_path.hpp b/include/rive/shapes/metrics_path.hpp index 4ff43a7..c8b8e16 100644 --- a/include/rive/shapes/metrics_path.hpp +++ b/include/rive/shapes/metrics_path.hpp
@@ -7,9 +7,11 @@ #include <cassert> #include <vector> -namespace rive { +namespace rive +{ -class MetricsPath : public CommandPath { +class MetricsPath : public CommandPath +{ private: RawPath m_RawPath; // temporary, until we build m_Contour rcp<ContourMeasure> m_Contour; @@ -38,18 +40,21 @@ float computeLength(const Mat2D& transform); }; -class OnlyMetricsPath : public MetricsPath { +class OnlyMetricsPath : public MetricsPath +{ public: void fillRule(FillRule value) override {} - RenderPath* renderPath() override { + RenderPath* renderPath() override + { // Should never be used for actual rendering. assert(false); return nullptr; } }; -class RenderMetricsPath : public MetricsPath { +class RenderMetricsPath : public MetricsPath +{ private: std::unique_ptr<RenderPath> m_RenderPath;
diff --git a/include/rive/shapes/paint/blend_mode.hpp b/include/rive/shapes/paint/blend_mode.hpp index 1ebe72c..0fbc4b3 100644 --- a/include/rive/shapes/paint/blend_mode.hpp +++ b/include/rive/shapes/paint/blend_mode.hpp
@@ -1,7 +1,9 @@ #ifndef _RIVE_BLEND_MODE_HPP_ #define _RIVE_BLEND_MODE_HPP_ -namespace rive { -enum class BlendMode : unsigned int { +namespace rive +{ +enum class BlendMode : unsigned int +{ srcOver = 3, screen = 14, overlay = 15,
diff --git a/include/rive/shapes/paint/color.hpp b/include/rive/shapes/paint/color.hpp index 10f4d66..850fbb3 100644 --- a/include/rive/shapes/paint/color.hpp +++ b/include/rive/shapes/paint/color.hpp
@@ -3,7 +3,8 @@ #include <cmath> #include <cstdint> -namespace rive { +namespace rive +{ using ColorInt = uint32_t; ColorInt colorARGB(int a, int r, int g, int b);
diff --git a/include/rive/shapes/paint/fill.hpp b/include/rive/shapes/paint/fill.hpp index c8c006c..938eae1 100644 --- a/include/rive/shapes/paint/fill.hpp +++ b/include/rive/shapes/paint/fill.hpp
@@ -2,8 +2,10 @@ #define _RIVE_FILL_HPP_ #include "rive/generated/shapes/paint/fill_base.hpp" #include "rive/shapes/path_space.hpp" -namespace rive { -class Fill : public FillBase { +namespace rive +{ +class Fill : public FillBase +{ public: RenderPaint* initRenderPaint(ShapePaintMutator* mutator) override; PathSpace pathSpace() const override;
diff --git a/include/rive/shapes/paint/gradient_stop.hpp b/include/rive/shapes/paint/gradient_stop.hpp index 721489c..f0e7db8 100644 --- a/include/rive/shapes/paint/gradient_stop.hpp +++ b/include/rive/shapes/paint/gradient_stop.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_GRADIENT_STOP_HPP_ #define _RIVE_GRADIENT_STOP_HPP_ #include "rive/generated/shapes/paint/gradient_stop_base.hpp" -namespace rive { -class GradientStop : public GradientStopBase { +namespace rive +{ +class GradientStop : public GradientStopBase +{ public: StatusCode onAddedDirty(CoreContext* context) override;
diff --git a/include/rive/shapes/paint/linear_gradient.hpp b/include/rive/shapes/paint/linear_gradient.hpp index 11f9710..446997e 100644 --- a/include/rive/shapes/paint/linear_gradient.hpp +++ b/include/rive/shapes/paint/linear_gradient.hpp
@@ -6,11 +6,13 @@ #include "rive/shapes/paint/shape_paint_mutator.hpp" #include <vector> -namespace rive { +namespace rive +{ class Node; class GradientStop; -class LinearGradient : public LinearGradientBase, public ShapePaintMutator { +class LinearGradient : public LinearGradientBase, public ShapePaintMutator +{ private: std::vector<GradientStop*> m_Stops; Node* m_ShapePaintContainer = nullptr;
diff --git a/include/rive/shapes/paint/radial_gradient.hpp b/include/rive/shapes/paint/radial_gradient.hpp index 34d388c..36409f9 100644 --- a/include/rive/shapes/paint/radial_gradient.hpp +++ b/include/rive/shapes/paint/radial_gradient.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_RADIAL_GRADIENT_HPP_ #define _RIVE_RADIAL_GRADIENT_HPP_ #include "rive/generated/shapes/paint/radial_gradient_base.hpp" -namespace rive { -class RadialGradient : public RadialGradientBase { +namespace rive +{ +class RadialGradient : public RadialGradientBase +{ public: void makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count) override;
diff --git a/include/rive/shapes/paint/shape_paint.hpp b/include/rive/shapes/paint/shape_paint.hpp index de81fc4..f73ad26 100644 --- a/include/rive/shapes/paint/shape_paint.hpp +++ b/include/rive/shapes/paint/shape_paint.hpp
@@ -5,10 +5,12 @@ #include "rive/shapes/paint/blend_mode.hpp" #include "rive/shapes/paint/shape_paint_mutator.hpp" #include "rive/shapes/path_space.hpp" -namespace rive { +namespace rive +{ class RenderPaint; class ShapePaintMutator; -class ShapePaint : public ShapePaintBase { +class ShapePaint : public ShapePaintBase +{ protected: std::unique_ptr<RenderPaint> m_RenderPaint; ShapePaintMutator* m_PaintMutator = nullptr;
diff --git a/include/rive/shapes/paint/shape_paint_mutator.hpp b/include/rive/shapes/paint/shape_paint_mutator.hpp index db01e46..1ec89f0 100644 --- a/include/rive/shapes/paint/shape_paint_mutator.hpp +++ b/include/rive/shapes/paint/shape_paint_mutator.hpp
@@ -1,10 +1,12 @@ #ifndef _RIVE_SHAPE_PAINT_MUTATOR_HPP_ #define _RIVE_SHAPE_PAINT_MUTATOR_HPP_ -namespace rive { +namespace rive +{ class Component; class RenderPaint; -class ShapePaintMutator { +class ShapePaintMutator +{ private: float m_RenderOpacity = 1.0f; RenderPaint* m_RenderPaint = nullptr;
diff --git a/include/rive/shapes/paint/solid_color.hpp b/include/rive/shapes/paint/solid_color.hpp index ece47ba..1a5fd26 100644 --- a/include/rive/shapes/paint/solid_color.hpp +++ b/include/rive/shapes/paint/solid_color.hpp
@@ -2,8 +2,10 @@ #define _RIVE_SOLID_COLOR_HPP_ #include "rive/generated/shapes/paint/solid_color_base.hpp" #include "rive/shapes/paint/shape_paint_mutator.hpp" -namespace rive { -class SolidColor : public SolidColorBase, public ShapePaintMutator { +namespace rive +{ +class SolidColor : public SolidColorBase, public ShapePaintMutator +{ public: StatusCode onAddedDirty(CoreContext* context) override;
diff --git a/include/rive/shapes/paint/stroke.hpp b/include/rive/shapes/paint/stroke.hpp index f26fc27..35f671b 100644 --- a/include/rive/shapes/paint/stroke.hpp +++ b/include/rive/shapes/paint/stroke.hpp
@@ -2,9 +2,11 @@ #define _RIVE_STROKE_HPP_ #include "rive/generated/shapes/paint/stroke_base.hpp" #include "rive/shapes/path_space.hpp" -namespace rive { +namespace rive +{ class StrokeEffect; -class Stroke : public StrokeBase { +class Stroke : public StrokeBase +{ private: StrokeEffect* m_Effect = nullptr;
diff --git a/include/rive/shapes/paint/stroke_cap.hpp b/include/rive/shapes/paint/stroke_cap.hpp index 9ee81ca..243a973 100644 --- a/include/rive/shapes/paint/stroke_cap.hpp +++ b/include/rive/shapes/paint/stroke_cap.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STROKE_CAP_HPP_ #define _RIVE_STROKE_CAP_HPP_ -namespace rive { +namespace rive +{ /// Style used for stroke line endings. -enum class StrokeCap : unsigned int { +enum class StrokeCap : unsigned int +{ /// Flat edge at the start/end of the stroke. butt = 0,
diff --git a/include/rive/shapes/paint/stroke_effect.hpp b/include/rive/shapes/paint/stroke_effect.hpp index 82658cb..2276d94 100644 --- a/include/rive/shapes/paint/stroke_effect.hpp +++ b/include/rive/shapes/paint/stroke_effect.hpp
@@ -3,12 +3,14 @@ #include "rive/rive_types.hpp" -namespace rive { +namespace rive +{ class Factory; class RenderPath; class MetricsPath; -class StrokeEffect { +class StrokeEffect +{ public: virtual ~StrokeEffect() {} virtual RenderPath* effectPath(MetricsPath* source, Factory*) = 0;
diff --git a/include/rive/shapes/paint/stroke_join.hpp b/include/rive/shapes/paint/stroke_join.hpp index 68f053b..b0f3810 100644 --- a/include/rive/shapes/paint/stroke_join.hpp +++ b/include/rive/shapes/paint/stroke_join.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STROKE_JOIN_HPP_ #define _RIVE_STROKE_JOIN_HPP_ -namespace rive { +namespace rive +{ /// Style used for stroke segment joins when there is a sharp change. -enum class StrokeJoin : unsigned int { +enum class StrokeJoin : unsigned int +{ /// Makes a sharp corner at the joint. miter = 0,
diff --git a/include/rive/shapes/paint/trim_path.hpp b/include/rive/shapes/paint/trim_path.hpp index f541421..99ed5bb 100644 --- a/include/rive/shapes/paint/trim_path.hpp +++ b/include/rive/shapes/paint/trim_path.hpp
@@ -5,8 +5,10 @@ #include "rive/renderer.hpp" #include <stdio.h> -namespace rive { -class TrimPath : public TrimPathBase, public StrokeEffect { +namespace rive +{ +class TrimPath : public TrimPathBase, public StrokeEffect +{ private: std::unique_ptr<RenderPath> m_TrimmedPath; RenderPath* m_RenderPath = nullptr;
diff --git a/include/rive/shapes/parametric_path.hpp b/include/rive/shapes/parametric_path.hpp index 44a771e..03f872a 100644 --- a/include/rive/shapes/parametric_path.hpp +++ b/include/rive/shapes/parametric_path.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_PARAMETRIC_PATH_HPP_ #define _RIVE_PARAMETRIC_PATH_HPP_ #include "rive/generated/shapes/parametric_path_base.hpp" -namespace rive { -class ParametricPath : public ParametricPathBase { +namespace rive +{ +class ParametricPath : public ParametricPathBase +{ protected: void widthChanged() override; void heightChanged() override;
diff --git a/include/rive/shapes/path.hpp b/include/rive/shapes/path.hpp index 83e2996..0df5914 100644 --- a/include/rive/shapes/path.hpp +++ b/include/rive/shapes/path.hpp
@@ -5,7 +5,8 @@ #include "rive/math/mat2d.hpp" #include <vector> -namespace rive { +namespace rive +{ class Shape; class PathVertex; @@ -18,7 +19,8 @@ /// and cubic vertices. No corner vertices and it's entirely in world space. /// This is helpful for getting a close to identical representation of the /// vertices used to issue the high level path draw commands. -class FlattenedPath { +class FlattenedPath +{ private: std::vector<PathVertex*> m_Vertices; @@ -30,7 +32,8 @@ }; #endif -class Path : public PathBase { +class Path : public PathBase +{ protected: Shape* m_Shape = nullptr; std::unique_ptr<CommandPath> m_CommandPath;
diff --git a/include/rive/shapes/path_composer.hpp b/include/rive/shapes/path_composer.hpp index 7980f74..eac77cc 100644 --- a/include/rive/shapes/path_composer.hpp +++ b/include/rive/shapes/path_composer.hpp
@@ -1,11 +1,13 @@ #ifndef _RIVE_PATH_COMPOSER_HPP_ #define _RIVE_PATH_COMPOSER_HPP_ #include "rive/component.hpp" -namespace rive { +namespace rive +{ class Shape; class CommandPath; class RenderPath; -class PathComposer : public Component { +class PathComposer : public Component +{ private: Shape* m_Shape; std::unique_ptr<CommandPath> m_LocalPath;
diff --git a/include/rive/shapes/path_space.hpp b/include/rive/shapes/path_space.hpp index 8e93a0a..5b54483 100644 --- a/include/rive/shapes/path_space.hpp +++ b/include/rive/shapes/path_space.hpp
@@ -3,48 +3,57 @@ #include "rive/rive_types.hpp" -namespace rive { -enum class PathSpace : unsigned char { +namespace rive +{ +enum class PathSpace : unsigned char +{ Neither = 0, Local = 1 << 1, World = 1 << 2, Clipping = 1 << 3 }; -inline constexpr PathSpace operator&(PathSpace lhs, PathSpace 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)); } -inline constexpr PathSpace operator^(PathSpace lhs, PathSpace 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)); } -inline constexpr PathSpace operator|(PathSpace lhs, PathSpace 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)); } -inline constexpr PathSpace operator~(PathSpace rhs) { +inline constexpr PathSpace operator~(PathSpace rhs) +{ return static_cast<PathSpace>(~static_cast<std::underlying_type<PathSpace>::type>(rhs)); } -inline PathSpace& operator|=(PathSpace& lhs, PathSpace 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)); return lhs; } -inline PathSpace& operator&=(PathSpace& lhs, PathSpace 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)); return lhs; } -inline PathSpace& operator^=(PathSpace& lhs, PathSpace 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));
diff --git a/include/rive/shapes/path_vertex.hpp b/include/rive/shapes/path_vertex.hpp index a90332b..1df0872 100644 --- a/include/rive/shapes/path_vertex.hpp +++ b/include/rive/shapes/path_vertex.hpp
@@ -3,8 +3,10 @@ #include "rive/bones/weight.hpp" #include "rive/generated/shapes/path_vertex_base.hpp" #include "rive/math/mat2d.hpp" -namespace rive { -class PathVertex : public PathVertexBase { +namespace rive +{ +class PathVertex : public PathVertexBase +{ public: StatusCode onAddedDirty(CoreContext* context) override;
diff --git a/include/rive/shapes/points_path.hpp b/include/rive/shapes/points_path.hpp index 61db55d..fd91881 100644 --- a/include/rive/shapes/points_path.hpp +++ b/include/rive/shapes/points_path.hpp
@@ -2,8 +2,10 @@ #define _RIVE_POINTS_PATH_HPP_ #include "rive/bones/skinnable.hpp" #include "rive/generated/shapes/points_path_base.hpp" -namespace rive { -class PointsPath : public PointsPathBase, public Skinnable { +namespace rive +{ +class PointsPath : public PointsPathBase, public Skinnable +{ public: bool isPathClosed() const override { return isClosed(); } void buildDependencies() override;
diff --git a/include/rive/shapes/polygon.hpp b/include/rive/shapes/polygon.hpp index b3f307f..7d2ed4b 100644 --- a/include/rive/shapes/polygon.hpp +++ b/include/rive/shapes/polygon.hpp
@@ -4,8 +4,10 @@ #include "rive/shapes/path_vertex.hpp" #include "rive/shapes/straight_vertex.hpp" #include <vector> -namespace rive { -class Polygon : public PolygonBase { +namespace rive +{ +class Polygon : public PolygonBase +{ protected: std::vector<StraightVertex> m_PolygonVertices;
diff --git a/include/rive/shapes/rectangle.hpp b/include/rive/shapes/rectangle.hpp index 81426c1..26bcdc1 100644 --- a/include/rive/shapes/rectangle.hpp +++ b/include/rive/shapes/rectangle.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/shapes/rectangle_base.hpp" #include "rive/shapes/straight_vertex.hpp" -namespace rive { -class Rectangle : public RectangleBase { +namespace rive +{ +class Rectangle : public RectangleBase +{ StraightVertex m_Vertex1, m_Vertex2, m_Vertex3, m_Vertex4; public:
diff --git a/include/rive/shapes/shape.hpp b/include/rive/shapes/shape.hpp index 22840c3..ef420cf 100644 --- a/include/rive/shapes/shape.hpp +++ b/include/rive/shapes/shape.hpp
@@ -7,11 +7,13 @@ #include "rive/shapes/shape_paint_container.hpp" #include <vector> -namespace rive { +namespace rive +{ class Path; class PathComposer; class HitTester; -class Shape : public ShapeBase, public ShapePaintContainer { +class Shape : public ShapeBase, public ShapePaintContainer +{ private: PathComposer m_PathComposer; std::vector<Path*> m_Paths;
diff --git a/include/rive/shapes/shape_paint_container.hpp b/include/rive/shapes/shape_paint_container.hpp index fea2b30..6771f6b 100644 --- a/include/rive/shapes/shape_paint_container.hpp +++ b/include/rive/shapes/shape_paint_container.hpp
@@ -4,14 +4,16 @@ #include "rive/shapes/path_space.hpp" #include <vector> -namespace rive { +namespace rive +{ class Artboard; class ShapePaint; class Component; class CommandPath; -class ShapePaintContainer { +class ShapePaintContainer +{ friend class ShapePaint; protected:
diff --git a/include/rive/shapes/star.hpp b/include/rive/shapes/star.hpp index 45f4d19..903bd51 100644 --- a/include/rive/shapes/star.hpp +++ b/include/rive/shapes/star.hpp
@@ -2,8 +2,10 @@ #define _RIVE_STAR_HPP_ #include "rive/generated/shapes/star_base.hpp" #include <stdio.h> -namespace rive { -class Star : public StarBase { +namespace rive +{ +class Star : public StarBase +{ public: Star(); void update(ComponentDirt value) override;
diff --git a/include/rive/shapes/straight_vertex.hpp b/include/rive/shapes/straight_vertex.hpp index 8e40e30..ae0e4e3 100644 --- a/include/rive/shapes/straight_vertex.hpp +++ b/include/rive/shapes/straight_vertex.hpp
@@ -1,8 +1,10 @@ #ifndef _RIVE_STRAIGHT_VERTEX_HPP_ #define _RIVE_STRAIGHT_VERTEX_HPP_ #include "rive/generated/shapes/straight_vertex_base.hpp" -namespace rive { -class StraightVertex : public StraightVertexBase { +namespace rive +{ +class StraightVertex : public StraightVertexBase +{ protected: void radiusChanged() override; };
diff --git a/include/rive/shapes/triangle.hpp b/include/rive/shapes/triangle.hpp index 54fe96b..ff44a5b 100644 --- a/include/rive/shapes/triangle.hpp +++ b/include/rive/shapes/triangle.hpp
@@ -3,8 +3,10 @@ #include "rive/generated/shapes/triangle_base.hpp" #include "rive/shapes/straight_vertex.hpp" -namespace rive { -class Triangle : public TriangleBase { +namespace rive +{ +class Triangle : public TriangleBase +{ private: StraightVertex m_Vertex1, m_Vertex2, m_Vertex3;
diff --git a/include/rive/shapes/vertex.hpp b/include/rive/shapes/vertex.hpp index 1ca4282..37624e2 100644 --- a/include/rive/shapes/vertex.hpp +++ b/include/rive/shapes/vertex.hpp
@@ -3,8 +3,10 @@ #include "rive/bones/weight.hpp" #include "rive/generated/shapes/vertex_base.hpp" #include "rive/math/mat2d.hpp" -namespace rive { -class Vertex : public VertexBase { +namespace rive +{ +class Vertex : public VertexBase +{ friend class Weight; private:
diff --git a/include/rive/simple_array.hpp b/include/rive/simple_array.hpp index 48fd694..d51a5b4 100644 --- a/include/rive/simple_array.hpp +++ b/include/rive/simple_array.hpp
@@ -11,12 +11,14 @@ #include <type_traits> #include <cstring> -namespace rive { +namespace rive +{ template <typename T> class SimpleArrayBuilder; #ifdef TESTING -namespace SimpleArrayTesting { +namespace SimpleArrayTesting +{ extern int mallocCount; extern int reallocCount; extern int freeCount; @@ -32,12 +34,16 @@ /// it optimally sized for marshaling. See SimpleArrayBuilder<T> below for push /// functionality. -template <typename T> class SimpleArray { +template <typename T> class SimpleArray +{ public: SimpleArray() : m_ptr(nullptr), m_size(0) {} - SimpleArray(size_t size) : m_ptr(static_cast<T*>(malloc(size * sizeof(T)))), m_size(size) { - if constexpr (!std::is_pod<T>()) { - for (T *element = m_ptr, *end = m_ptr + m_size; element < end; element++) { + SimpleArray(size_t size) : m_ptr(static_cast<T*>(malloc(size * sizeof(T)))), m_size(size) + { + if constexpr (!std::is_pod<T>()) + { + for (T *element = m_ptr, *end = m_ptr + m_size; element < end; element++) + { new (element) T(); } } @@ -46,12 +52,17 @@ SimpleArrayTesting::mallocCount++; #endif } - SimpleArray(const T* ptr, size_t size) : SimpleArray(size) { + SimpleArray(const T* ptr, size_t size) : SimpleArray(size) + { assert(ptr <= ptr + size); - if constexpr (std::is_pod<T>()) { + if constexpr (std::is_pod<T>()) + { memcpy(m_ptr, ptr, size * sizeof(T)); - } else { - for (T *element = m_ptr, *end = m_ptr + m_size; element < end; element++) { + } + else + { + for (T *element = m_ptr, *end = m_ptr + m_size; element < end; element++) + { new (element) T(ptr++); } } @@ -59,7 +70,8 @@ constexpr SimpleArray(const SimpleArray<T>& other) : SimpleArray(other.m_ptr, other.m_size) {} - constexpr SimpleArray(SimpleArray<T>&& other) : m_ptr(other.m_ptr), m_size(other.m_size) { + constexpr SimpleArray(SimpleArray<T>&& other) : m_ptr(other.m_ptr), m_size(other.m_size) + { other.m_ptr = nullptr; other.m_size = 0; } @@ -68,7 +80,8 @@ SimpleArray<T>& operator=(const SimpleArray<T>& other) = delete; - SimpleArray<T>& operator=(SimpleArray<T>&& other) { + SimpleArray<T>& operator=(SimpleArray<T>&& other) + { this->m_ptr = other.m_ptr; this->m_size = other.m_size; other.m_ptr = nullptr; @@ -79,12 +92,16 @@ SimpleArray<T>& operator=(SimpleArrayBuilder<T>&& other); template <typename Container> - constexpr SimpleArray(Container& c) : SimpleArray(std::data(c), std::size(c)) {} - constexpr SimpleArray(std::initializer_list<T> il) : - SimpleArray(std::data(il), std::size(il)) {} - ~SimpleArray() { - if constexpr (!std::is_pod<T>()) { - for (T *element = m_ptr, *end = m_ptr + m_size; element < end; element++) { + constexpr SimpleArray(Container& c) : SimpleArray(std::data(c), std::size(c)) + {} + constexpr SimpleArray(std::initializer_list<T> il) : SimpleArray(std::data(il), std::size(il)) + {} + ~SimpleArray() + { + if constexpr (!std::is_pod<T>()) + { + for (T *element = m_ptr, *end = m_ptr + m_size; element < end; element++) + { element->~T(); } } @@ -94,7 +111,8 @@ #endif } - constexpr T& operator[](size_t index) const { + constexpr T& operator[](size_t index) const + { assert(index < m_size); return m_ptr[index]; } @@ -129,23 +147,27 @@ /// Extension of SimpleArray which can progressively expand as contents are /// pushed/added/written to it. Can be released as a simple SimpleArray. -template <typename T> class SimpleArrayBuilder : public SimpleArray<T> { +template <typename T> class SimpleArrayBuilder : public SimpleArray<T> +{ friend class SimpleArray<T>; public: - SimpleArrayBuilder(size_t reserve) : SimpleArray<T>(reserve) { + SimpleArrayBuilder(size_t reserve) : SimpleArray<T>(reserve) + { assert(this->m_ptr <= this->m_ptr + this->m_size); m_write = this->m_ptr; } SimpleArrayBuilder() : SimpleArrayBuilder(0) {} - void add(const T& value) { + void add(const T& value) + { growToFit(); *m_write++ = value; } - void add(T&& value) { + void add(T&& value) + { growToFit(); *m_write++ = std::move(value); } @@ -161,33 +183,41 @@ constexpr T& back() const { return *(m_write - 1); } private: - void growToFit() { - if (m_write == this->m_ptr + this->m_size) { + void growToFit() + { + if (m_write == this->m_ptr + this->m_size) + { auto writeOffset = m_write - this->m_ptr; this->resize(std::max((size_t)1, this->m_size * 2)); m_write = this->m_ptr + writeOffset; } } - void resize(size_t size) { - if (size == this->m_size) { + void resize(size_t size) + { + if (size == this->m_size) + { return; } #ifdef TESTING SimpleArrayTesting::reallocCount++; #endif - if constexpr (!std::is_pod<T>()) { + if constexpr (!std::is_pod<T>()) + { // Call destructor for elements when sizing down. for (T *element = this->m_ptr + size, *end = this->m_ptr + this->m_size; element < end; - element++) { + element++) + { element->~T(); } } this->m_ptr = static_cast<T*>(realloc(this->m_ptr, size * sizeof(T))); - if constexpr (!std::is_pod<T>()) { + if constexpr (!std::is_pod<T>()) + { // Call constructor for elements when sizing up. for (T *element = this->m_ptr + this->m_size, *end = this->m_ptr + size; element < end; - element++) { + element++) + { new (element) T(); } } @@ -198,7 +228,8 @@ }; template <typename T> -constexpr SimpleArray<T>::SimpleArray(SimpleArrayBuilder<T>&& other) : m_size(other.size()) { +constexpr SimpleArray<T>::SimpleArray(SimpleArrayBuilder<T>&& other) : m_size(other.size()) +{ // Bring the capacity down to the actual size (this should keep the same // ptr, but that's not guaranteed, so we copy the ptr after the realloc). other.resize(other.size()); @@ -207,7 +238,8 @@ other.m_size = 0; } -template <typename T> SimpleArray<T>& SimpleArray<T>::operator=(SimpleArrayBuilder<T>&& other) { +template <typename T> SimpleArray<T>& SimpleArray<T>::operator=(SimpleArrayBuilder<T>&& other) +{ other.resize(other.size()); this->m_ptr = other.m_ptr; this->m_size = other.m_size;
diff --git a/include/rive/span.hpp b/include/rive/span.hpp index de21bbf..bc86e3d 100644 --- a/include/rive/span.hpp +++ b/include/rive/span.hpp
@@ -16,9 +16,11 @@ * Inspired by Skia's SkSpan */ -namespace rive { +namespace rive +{ -template <typename T> class Span { +template <typename T> class Span +{ T* m_Ptr; size_t m_Size; @@ -28,13 +30,15 @@ // 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<U>& that) : Span(that.data(), that.size()) + {} constexpr Span(const Span&) = default; template <typename Container> constexpr Span(Container& c) : Span{std::data(c), std::size(c)} {} constexpr Span(std::initializer_list<T> il) : Span(std::data(il), std::size(il)) {} template <size_t N> constexpr Span(T (&a)[N]) : Span(a, N) {} - constexpr T& operator[](size_t index) const { + constexpr T& operator[](size_t index) const + { assert(index < m_Size); return m_Ptr[index]; } @@ -52,13 +56,15 @@ // returns byte-size of the entire span constexpr size_t size_bytes() const { return m_Size * sizeof(T); } - constexpr int count() const { + constexpr int count() const + { const int n = static_cast<int>(m_Size); assert(n >= 0); return n; } - constexpr Span<T> subset(size_t offset, size_t size) const { + 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};
diff --git a/include/rive/status_code.hpp b/include/rive/status_code.hpp index 788b3ba..a7967ea 100644 --- a/include/rive/status_code.hpp +++ b/include/rive/status_code.hpp
@@ -3,7 +3,14 @@ #include "rive/rive_types.hpp" -namespace rive { -enum class StatusCode : unsigned char { Ok, MissingObject, InvalidObject, FailedInversion }; +namespace rive +{ +enum class StatusCode : unsigned char +{ + Ok, + MissingObject, + InvalidObject, + FailedInversion +}; } #endif
diff --git a/include/rive/text/line_breaker.hpp b/include/rive/text/line_breaker.hpp index 37d50d0..827873d 100644 --- a/include/rive/text/line_breaker.hpp +++ b/include/rive/text/line_breaker.hpp
@@ -7,11 +7,18 @@ #include "rive/render_text.hpp" -namespace rive { +namespace rive +{ -enum class RenderTextAlign : uint8_t { left = 0, right = 1, center = 2 }; +enum class RenderTextAlign : uint8_t +{ + left = 0, + right = 1, + center = 2 +}; -struct RenderGlyphLine { +struct RenderGlyphLine +{ uint32_t startRun; uint32_t startIndex; uint32_t endRun; @@ -19,14 +26,16 @@ float startX; float top = 0, baseline = 0, bottom = 0; - bool operator==(const RenderGlyphLine& o) const { + bool operator==(const RenderGlyphLine& o) const + { return startRun == o.startRun && startIndex == o.startIndex && endRun == o.endRun && endIndex == o.endIndex; } RenderGlyphLine() : startRun(0), startIndex(0), endRun(0), endIndex(0), startX(0.0f) {} RenderGlyphLine(uint32_t run, uint32_t index) : - startRun(run), startIndex(index), endRun(run), endIndex(index), startX(0.0f) {} + startRun(run), startIndex(index), endRun(run), endIndex(index), startX(0.0f) + {} bool empty() const { return startRun == endRun && startIndex == endIndex; } static std::vector<RenderGlyphLine> BreakLines(Span<const RenderGlyphRun> runs,
diff --git a/include/rive/text/renderfont_hb.hpp b/include/rive/text/renderfont_hb.hpp index 0ebac54..865afc2 100644 --- a/include/rive/text/renderfont_hb.hpp +++ b/include/rive/text/renderfont_hb.hpp
@@ -11,7 +11,8 @@ struct hb_font_t; struct hb_draw_funcs_t; -class HBRenderFont : public rive::RenderFont { +class HBRenderFont : public rive::RenderFont +{ hb_draw_funcs_t* m_DrawFuncs; public:
diff --git a/include/rive/transform_component.hpp b/include/rive/transform_component.hpp index fc9ae02..258949e 100644 --- a/include/rive/transform_component.hpp +++ b/include/rive/transform_component.hpp
@@ -3,10 +3,12 @@ #include "rive/generated/transform_component_base.hpp" #include "rive/math/mat2d.hpp" -namespace rive { +namespace rive +{ class Constraint; class WorldTransformComponent; -class TransformComponent : public TransformComponentBase { +class TransformComponent : public TransformComponentBase +{ private: Mat2D m_Transform; float m_RenderOpacity = 0.0f;
diff --git a/include/rive/transform_space.hpp b/include/rive/transform_space.hpp index a95b58a..3e9c3c9 100644 --- a/include/rive/transform_space.hpp +++ b/include/rive/transform_space.hpp
@@ -1,6 +1,11 @@ #ifndef _RIVE_TRANSFORM_SPACE_HPP_ #define _RIVE_TRANSFORM_SPACE_HPP_ -namespace rive { -enum class TransformSpace : unsigned int { world = 0, local = 1 }; +namespace rive +{ +enum class TransformSpace : unsigned int +{ + world = 0, + local = 1 +}; } #endif \ No newline at end of file
diff --git a/include/rive/world_transform_component.hpp b/include/rive/world_transform_component.hpp index 77d1ae6..f5c97b2 100644 --- a/include/rive/world_transform_component.hpp +++ b/include/rive/world_transform_component.hpp
@@ -3,9 +3,11 @@ #include "rive/generated/world_transform_component_base.hpp" #include "rive/math/mat2d.hpp" -namespace rive { +namespace rive +{ class TransformComponent; -class WorldTransformComponent : public WorldTransformComponentBase { +class WorldTransformComponent : public WorldTransformComponentBase +{ friend class TransformComponent; protected:
diff --git a/include/utils/factory_utils.hpp b/include/utils/factory_utils.hpp index 6f31b67..bc93cf3 100644 --- a/include/utils/factory_utils.hpp +++ b/include/utils/factory_utils.hpp
@@ -7,28 +7,33 @@ #include "rive/factory.hpp" -namespace rive { +namespace rive +{ // Generic subclass of RenderBuffer that just stores the data on the cpu. // -class DataRenderBuffer : public RenderBuffer { +class DataRenderBuffer : public RenderBuffer +{ const size_t m_elemSize; std::vector<uint32_t> m_storage; // store 32bits for alignment public: DataRenderBuffer(const void* src, size_t count, size_t elemSize) : - RenderBuffer(count), m_elemSize(elemSize) { + RenderBuffer(count), m_elemSize(elemSize) + { const size_t bytes = count * elemSize; m_storage.resize((bytes + 3) >> 2); // round up to next 32bit count memcpy(m_storage.data(), src, bytes); } - const float* f32s() const { + const float* f32s() const + { assert(m_elemSize == sizeof(float)); return reinterpret_cast<const float*>(m_storage.data()); } - const uint16_t* u16s() const { + const uint16_t* u16s() const + { assert(m_elemSize == sizeof(uint16_t)); return reinterpret_cast<const uint16_t*>(m_storage.data()); } @@ -37,11 +42,13 @@ size_t elemSize() const { return m_elemSize; } - static const DataRenderBuffer* Cast(const RenderBuffer* buffer) { + static const DataRenderBuffer* Cast(const RenderBuffer* buffer) + { return static_cast<const DataRenderBuffer*>(buffer); } - template <typename T> static rcp<RenderBuffer> Make(Span<T> span) { + template <typename T> static rcp<RenderBuffer> Make(Span<T> span) + { return rcp<RenderBuffer>(new DataRenderBuffer(span.data(), span.size(), sizeof(T))); } };
diff --git a/include/utils/no_op_factory.hpp b/include/utils/no_op_factory.hpp index 2c1261c..3038738 100644 --- a/include/utils/no_op_factory.hpp +++ b/include/utils/no_op_factory.hpp
@@ -7,9 +7,11 @@ #include "rive/factory.hpp" -namespace rive { +namespace rive +{ -class NoOpFactory : public Factory { +class NoOpFactory : public Factory +{ rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override; rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override; rcp<RenderBuffer> makeBufferF32(Span<const float>) override;
diff --git a/include/utils/no_op_renderer.hpp b/include/utils/no_op_renderer.hpp index 2da6ebe..0a0396b 100644 --- a/include/utils/no_op_renderer.hpp +++ b/include/utils/no_op_renderer.hpp
@@ -7,9 +7,11 @@ #include "rive/renderer.hpp" -namespace rive { +namespace rive +{ -class NoOpRenderer : public Renderer { +class NoOpRenderer : public Renderer +{ public: void save() override {} void restore() override {} @@ -22,7 +24,8 @@ rcp<RenderBuffer>, rcp<RenderBuffer>, BlendMode, - float) override {} + float) override + {} }; } // namespace rive
diff --git a/include/utils/rive_utf.hpp b/include/utils/rive_utf.hpp index 5e64c29..780292f 100644 --- a/include/utils/rive_utf.hpp +++ b/include/utils/rive_utf.hpp
@@ -7,9 +7,11 @@ #include "rive/render_text.hpp" -namespace rive { +namespace rive +{ -class UTF { +class UTF +{ public: // returns the number of bytes needed in this sequence // For ascii, this will return 1
diff --git a/rivinfo/main.cpp b/rivinfo/main.cpp index 485d9f1..681bb7d 100644 --- a/rivinfo/main.cpp +++ b/rivinfo/main.cpp
@@ -9,44 +9,57 @@ #include "rive/animation/state_machine_input_instance.hpp" #include "utils/no_op_factory.hpp" -class JSoner { +class JSoner +{ std::vector<bool> m_IsArray; - void tab() { - for (int i = 0; i < m_IsArray.size(); ++i) { + void tab() + { + for (int i = 0; i < m_IsArray.size(); ++i) + { printf("\t"); } } - void add_c(const char key[], char c) { + void add_c(const char key[], char c) + { this->tab(); - if (key) { + if (key) + { printf("\"%s\": %c\n", key, c); - } else { + } + else + { printf("%c\n", c); } } public: JSoner() {} - ~JSoner() { - while (!m_IsArray.empty()) { + ~JSoner() + { + while (!m_IsArray.empty()) + { this->pop(); } } - void add(const char key[], const char value[]) { + void add(const char key[], const char value[]) + { this->tab(); printf("\"%s\": \"%s\"\n", key, value); } - void pushArray(const char key[] = nullptr) { + void pushArray(const char key[] = nullptr) + { this->add_c(key, '['); m_IsArray.push_back(true); } - void pushStruct(const char key[] = nullptr) { + void pushStruct(const char key[] = nullptr) + { this->add_c(key, '{'); m_IsArray.push_back(false); } - void pop() { + void pop() + { assert(!m_IsArray.empty()); char c = m_IsArray.front() ? ']' : '}'; m_IsArray.pop_back(); @@ -60,7 +73,8 @@ ////////////////////////////////////////////////// -static void dump(JSoner& js, rive::LinearAnimationInstance* anim) { +static void dump(JSoner& js, rive::LinearAnimationInstance* anim) +{ js.pushStruct(); js.add("name", anim->name().c_str()); js.add("duration", std::to_string(anim->durationSeconds()).c_str()); @@ -68,12 +82,15 @@ js.pop(); } -static void dump(JSoner& js, rive::StateMachineInstance* smi) { +static void dump(JSoner& js, rive::StateMachineInstance* smi) +{ js.pushStruct(); js.add("name", smi->name().c_str()); - if (auto count = smi->inputCount()) { + if (auto count = smi->inputCount()) + { js.pushArray("inputs"); - for (auto i = 0; i < count; ++i) { + for (auto i = 0; i < count; ++i) + { auto inp = smi->input(i); js.add("name", inp->name().c_str()); } @@ -82,19 +99,24 @@ js.pop(); } -static void dump(JSoner& js, rive::ArtboardInstance* abi) { +static void dump(JSoner& js, rive::ArtboardInstance* abi) +{ js.pushStruct(); js.add("name", abi->name().c_str()); - if (auto count = abi->animationCount()) { + if (auto count = abi->animationCount()) + { js.pushArray("animations"); - for (size_t i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) + { dump(js, abi->animationAt(i).get()); } js.pop(); } - if (auto count = abi->stateMachineCount()) { + if (auto count = abi->stateMachineCount()) + { js.pushArray("machines"); - for (size_t i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) + { dump(js, abi->stateMachineAt(i).get()); } js.pop(); @@ -102,18 +124,22 @@ js.pop(); } -static void dump(JSoner& js, rive::File* file) { +static void dump(JSoner& js, rive::File* file) +{ auto count = file->artboardCount(); js.pushArray("artboards"); - for (size_t i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) + { dump(js, file->artboardAt(i).get()); } js.pop(); } -static std::unique_ptr<rive::File> open_file(const char name[]) { +static std::unique_ptr<rive::File> open_file(const char name[]) +{ FILE* f = fopen(name, "rb"); - if (!f) { + if (!f) + { return nullptr; } @@ -123,7 +149,8 @@ std::vector<uint8_t> bytes(length); - if (fread(bytes.data(), 1, length, f) != length) { + if (fread(bytes.data(), 1, length, f) != length) + { printf("Failed to read file into bytes array\n"); return nullptr; } @@ -132,15 +159,19 @@ return rive::File::import(bytes, &gFactory); } -static bool is_arg(const char arg[], const char target[], const char alt[] = nullptr) { +static bool is_arg(const char arg[], const char target[], const char alt[] = nullptr) +{ return !strcmp(arg, target) || (arg && !strcmp(arg, alt)); } -int main(int argc, const char* argv[]) { +int main(int argc, const char* argv[]) +{ const char* filename = nullptr; - for (int i = 1; i < argc; ++i) { - if (is_arg(argv[i], "--file", "-f")) { + for (int i = 1; i < argc; ++i) + { + if (is_arg(argv[i], "--file", "-f")) + { filename = argv[++i]; continue; } @@ -148,13 +179,15 @@ return 1; } - if (!filename) { + if (!filename) + { printf("Need --file filename\n"); return 1; } auto file = open_file(filename); - if (!file) { + if (!file) + { printf("Can't open %s\n", filename); return 1; }
diff --git a/skia/font_converter/src/font.cpp b/skia/font_converter/src/font.cpp index 3f2107d..80a7eca 100644 --- a/skia/font_converter/src/font.cpp +++ b/skia/font_converter/src/font.cpp
@@ -2,21 +2,26 @@ #include "font.h" #include "include/core/SkFont.h" -uint16_t RiveFont::charToGlyph(SkUnichar u) const { - for (size_t i = 0; i < fCMap.size(); ++i) { - if (fCMap[i].fChar == u) { +uint16_t RiveFont::charToGlyph(SkUnichar u) const +{ + for (size_t i = 0; i < fCMap.size(); ++i) + { + if (fCMap[i].fChar == u) + { return fCMap[i].fGlyph; } } return 0; } -float RiveFont::advance(uint16_t glyph) const { +float RiveFont::advance(uint16_t glyph) const +{ assert(glyph < fGlyphs.size()); return fGlyphs[glyph].fAdvance; } -const SkPath* RiveFont::path(uint16_t glyph) const { +const SkPath* RiveFont::path(uint16_t glyph) const +{ assert(glyph < fGlyphs.size()); const SkPath& p = fGlyphs[glyph].fPath; return p.isEmpty() ? nullptr : &p; @@ -25,7 +30,8 @@ #define kSignature 0x23581321 #define kVersion 1 -constexpr uint32_t Tag(unsigned a, unsigned b, unsigned c, unsigned d) { +constexpr uint32_t Tag(unsigned a, unsigned b, unsigned c, unsigned d) +{ assert((a & 0xFF) == a); assert((b & 0xFF) == b); assert((c & 0xFF) == c); @@ -33,7 +39,8 @@ return (a << 24) | (b << 16) | (c << 8) | d; } -static inline void tag_to_str(uint32_t tag, char str[5]) { +static inline void tag_to_str(uint32_t tag, char str[5]) +{ str[0] = (tag >> 24) & 0xFF; str[1] = (tag >> 16) & 0xFF; str[2] = (tag >> 8) & 0xFF; @@ -47,13 +54,15 @@ constexpr uint32_t kInfo_TableTag = Tag('i', 'n', 'f', 'o'); constexpr uint32_t kAdvances_TableTag = Tag('h', 'a', 'd', 'v'); -struct TableDir { +struct TableDir +{ uint32_t tag; uint32_t offset; uint32_t length; }; -struct FontHead { +struct FontHead +{ uint32_t signature; uint32_t version; uint32_t tableCount; @@ -61,10 +70,13 @@ const TableDir* dir() const { return (const TableDir*)(this + 1); } - const void* findTable(uint32_t tag) const { + const void* findTable(uint32_t tag) const + { auto dir = this->dir(); - for (unsigned i = 0; i < this->tableCount; ++i) { - if (dir[i].tag == tag) { + for (unsigned i = 0; i < this->tableCount; ++i) + { + if (dir[i].tag == tag) + { return (char*)this + dir[i].offset; } } @@ -72,16 +84,19 @@ } }; -struct InfoTable { +struct InfoTable +{ uint16_t glyphCount; uint16_t upem; }; -struct GlyphOffsetTable { +struct GlyphOffsetTable +{ // uint32_t offsets[glyphCount+1]; // relative to the glyphdata table }; -struct GlyphRec { +struct GlyphRec +{ // uint16_t verbCount; // uint16_t pointCount; // if verbCount > 0 // uint8_t verbs; // Move, Line, Quad, Cubic, Close @@ -89,7 +104,8 @@ // uint16_t x,y x,y x,y }; -void RiveFont::load(sk_sp<SkTypeface> tf, const char str[], size_t len) { +void RiveFont::load(sk_sp<SkTypeface> tf, const char str[], size_t len) +{ this->clear(); SkFont font(std::move(tf), 1.0f); @@ -98,7 +114,8 @@ int glyphCount = font.textToGlyphs(str, len, SkTextEncoding::kUTF8, glyphIDs, len); assert(glyphCount == (int)len); - struct Rec { + struct Rec + { uint16_t charCode; uint16_t srcGlyph; uint16_t dstGlyph; @@ -106,22 +123,27 @@ std::vector<Rec> rec; uint16_t newDstGlyphID = 1; // leave room for glyphID==0 for missing glyph // build vector of unique chars - for (size_t i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) + { uint16_t code = str[i]; auto iter = std::find_if(rec.begin(), rec.end(), [code](const auto& r) { return r.charCode == code; }); - if (iter == rec.end()) { + if (iter == rec.end()) + { // gonna add code -- now see if its glyph is unique uint16_t srcGlyph = glyphIDs[i]; auto it2 = std::find_if(rec.begin(), rec.end(), [srcGlyph](const auto& r) { return r.srcGlyph == srcGlyph; }); uint16_t dstGlyph; - if (it2 == rec.end()) { + if (it2 == rec.end()) + { // srcGlyph is unique (or zero) dstGlyph = srcGlyph ? newDstGlyphID++ : 0; - } else { + } + else + { dstGlyph = it2->dstGlyph; // reuse prev dstGlyph } rec.push_back({code, srcGlyph, dstGlyph}); @@ -131,7 +153,8 @@ std::sort(rec.begin(), rec.end(), [](const Rec& a, const Rec& b) { return a.charCode < b.charCode; }); - for (const auto& r : rec) { + for (const auto& r : rec) + { printf("'%c' [%d] %d -> %d\n", r.charCode, r.charCode, r.srcGlyph, r.dstGlyph); fCMap.push_back({r.charCode, r.dstGlyph}); } @@ -150,8 +173,9 @@ fGlyphs.push_back({std::move(path), width}); }; - append_glyph(0); // missing glyph - for (int i = 1; i < newDstGlyphID; ++i) { // walk through our glyphs + append_glyph(0); // missing glyph + for (int i = 1; i < newDstGlyphID; ++i) + { // walk through our glyphs auto iter = std::find_if(rec.begin(), rec.end(), [i](const auto& r) { return r.dstGlyph == i; }); assert(iter != rec.end()); @@ -159,72 +183,86 @@ } } -struct ByteBuilder { +struct ByteBuilder +{ std::vector<uint8_t> bytes; uint32_t length() const { return bytes.size(); } - uint8_t add8(size_t x) { + uint8_t add8(size_t x) + { assert((x & 0xFF) == x); uint8_t b = (uint8_t)x; bytes.push_back(b); return b; } - int16_t addS16(ssize_t x) { + int16_t addS16(ssize_t x) + { int16_t s = (int16_t)x; assert(s == x); this->add(&s, 2); return s; } - uint16_t addU16(size_t x) { + uint16_t addU16(size_t x) + { assert((x & 0xFFFF) == x); uint16_t u = (uint16_t)x; this->add(&u, 2); return u; } - uint32_t addU32(size_t x) { + uint32_t addU32(size_t x) + { assert((x & 0xFFFFFFFF) == x); uint32_t u = (uint32_t)x; this->add(&u, 4); return u; } - void add(const void* src, size_t n) { + void add(const void* src, size_t n) + { size_t size = bytes.size(); bytes.resize(size + n); memcpy(bytes.data() + size, src, n); } - template <typename T> void add(const std::vector<T>& v) { + template <typename T> void add(const std::vector<T>& v) + { this->add(v.data(), v.size() * sizeof(T)); } void add(const ByteBuilder& bb) { this->add(bb.bytes.data(), bb.bytes.size()); } void add(sk_sp<SkData> data) { this->add(data->data(), data->size()); } - void padTo16() { - if (bytes.size() & 1) { + void padTo16() + { + if (bytes.size() & 1) + { this->add8(0); } } - void padTo32() { - while (bytes.size() & 3) { + void padTo32() + { + while (bytes.size() & 3) + { this->add8(0); } } - void set32(size_t offset, uint32_t value) { + void set32(size_t offset, uint32_t value) + { assert(offset + 4 <= bytes.size()); assert((offset & 3) == 0); memcpy(bytes.data() + offset, &value, 4); } - sk_sp<SkData> detach() { + sk_sp<SkData> detach() + { auto data = SkData::MakeWithCopy(bytes.data(), bytes.size()); bytes.clear(); return data; } }; -void encode_path(ByteBuilder* bb, const SkPath& path, float scale) { +void encode_path(ByteBuilder* bb, const SkPath& path, float scale) +{ std::vector<uint8_t> varray; std::vector<uint16_t> parray; @@ -234,16 +272,23 @@ }; SkPath::RawIter iter(path); - for (;;) { + for (;;) + { SkPoint pts[4]; auto verb = iter.next(pts); - if (verb == SkPath::kDone_Verb) { + if (verb == SkPath::kDone_Verb) + { break; } varray.push_back(verb); - switch ((SkPathVerb)verb) { - case SkPathVerb::kMove: add_point(pts[0]); break; - case SkPathVerb::kLine: add_point(pts[1]); break; + switch ((SkPathVerb)verb) + { + case SkPathVerb::kMove: + add_point(pts[0]); + break; + case SkPathVerb::kLine: + add_point(pts[1]); + break; case SkPathVerb::kQuad: add_point(pts[1]); add_point(pts[2]); @@ -253,25 +298,32 @@ add_point(pts[2]); add_point(pts[3]); break; - case SkPathVerb::kClose: break; - default: assert(false); // unsupported + case SkPathVerb::kClose: + break; + default: + assert(false); // unsupported } } assert((int)varray.size() == path.countVerbs()); assert((int)parray.size() == path.countPoints() * 2); auto no_useful_verbs = [](const std::vector<uint8_t>& verbs) { - for (auto v : verbs) { - switch ((SkPathVerb)v) { + for (auto v : verbs) + { + switch ((SkPathVerb)v) + { case SkPathVerb::kLine: case SkPathVerb::kQuad: - case SkPathVerb::kCubic: return false; - default: break; + case SkPathVerb::kCubic: + return false; + default: + break; } } return true; }; - if (no_useful_verbs(varray)) { + if (no_useful_verbs(varray)) + { return; // we signal empty paths with the offset table } @@ -284,12 +336,14 @@ bb->add(parray); } -sk_sp<SkData> RiveFont::encode() const { +sk_sp<SkData> RiveFont::encode() const +{ sk_sp<SkData> infoD, cmapD, offsetsD, pathsD; const int upem = 2048; const float scale = upem; - struct DirRec { + struct DirRec + { uint32_t tag; sk_sp<SkData> data; }; @@ -306,7 +360,8 @@ ByteBuilder cmap; // start with #pairs cmap.addU16(fCMap.size()); - for (const auto& cm : fCMap) { + for (const auto& cm : fCMap) + { cmap.addU16(cm.fChar); cmap.addU16(cm.fGlyph); } @@ -317,7 +372,8 @@ { ByteBuilder paths, advances; std::vector<uint32_t> offsets; - for (const auto& g : fGlyphs) { + for (const auto& g : fGlyphs) + { offsets.push_back(paths.length()); encode_path(&paths, g.fPath, scale); paths.padTo16(); @@ -339,14 +395,16 @@ header.addU32(kSignature); header.addU32(kVersion); header.addU32(dir.size()); - for (auto& d : dir) { + for (auto& d : dir) + { header.addU32(d.tag); header.addU32(0); // offset -- fill in later header.addU32(d.data->size()); } size_t offsetToDirEntry = sizeof(FontHead); - for (auto& d : dir) { + for (auto& d : dir) + { // +4 to skip the tag field of the dir entry header.set32(offsetToDirEntry + 4, header.length()); offsetToDirEntry += sizeof(TableDir); @@ -357,12 +415,14 @@ return header.detach(); } -struct Reader { +struct Reader +{ const char* fStart; const char* fCurr; const char* fStop; - Reader(const void* data, size_t length) { + Reader(const void* data, size_t length) + { fStart = (const char*)data; fCurr = fStart; fStop = fStart + length; @@ -371,7 +431,8 @@ bool isAvailable(size_t n) const { return fCurr + n <= fStop; } size_t available() const { return fStop - fCurr; } - template <typename T> const T* skip(size_t size) { + template <typename T> const T* skip(size_t size) + { assert(this->isAvailable(size)); const char* p = fCurr; fCurr += size; @@ -382,26 +443,30 @@ void skip(size_t size) {} - uint8_t u8() { + uint8_t u8() + { assert(this->isAvailable(1)); return *fCurr++; } - int16_t s16() { + int16_t s16() + { assert(this->isAvailable(2)); int16_t s; memcpy(&s, fCurr, 2); fCurr += 2; return s; } - uint16_t u16() { + uint16_t u16() + { assert(this->isAvailable(2)); uint16_t s; memcpy(&s, fCurr, 2); fCurr += 2; return s; } - uint32_t u32() { + uint32_t u32() + { assert(this->isAvailable(4)); uint32_t s; memcpy(&s, fCurr, 4); @@ -409,37 +474,56 @@ return s; } - void read(void* dst, size_t size) { + void read(void* dst, size_t size) + { assert(this->isAvailable(size)); memcpy(dst, fCurr, size); fCurr += size; } - void skipPad16() { + void skipPad16() + { size_t amount = fCurr - fStart; - if (amount & 1) { + if (amount & 1) + { assert(this->isAvailable(1)); fCurr += 1; } } }; -static int compute_point_count(const uint8_t verbs[], int verbCount) { +static int compute_point_count(const uint8_t verbs[], int verbCount) +{ int count = 0; - for (int i = 0; i < verbCount; ++i) { - switch ((SkPathVerb)verbs[i]) { - case SkPathVerb::kMove: count += 1; break; - case SkPathVerb::kLine: count += 1; break; - case SkPathVerb::kQuad: count += 2; break; - case SkPathVerb::kCubic: count += 3; break; - case SkPathVerb::kClose: count += 0; break; - default: assert(false); return -1; + for (int i = 0; i < verbCount; ++i) + { + switch ((SkPathVerb)verbs[i]) + { + case SkPathVerb::kMove: + count += 1; + break; + case SkPathVerb::kLine: + count += 1; + break; + case SkPathVerb::kQuad: + count += 2; + break; + case SkPathVerb::kCubic: + count += 3; + break; + case SkPathVerb::kClose: + count += 0; + break; + default: + assert(false); + return -1; } } return count; } -static SkPath decode_path(const void* data, size_t length, float scale) { +static SkPath decode_path(const void* data, size_t length, float scale) +{ Reader reader(data, length); const int verbCount = reader.u16(); @@ -455,7 +539,8 @@ assert(reader.available() == 0); SkPoint pts[pointCount]; - for (int i = 0; i < pointCount; ++i) { + for (int i = 0; i < pointCount; ++i) + { pts[i] = {pts16[0] * scale, pts16[1] * scale}; pts16 += 2; } @@ -463,7 +548,8 @@ return SkPath::Make(pts, pointCount, verbs, verbCount, nullptr, 0, SkPathFillType::kWinding); } -bool RiveFont::decode(const void* data, size_t length) { +bool RiveFont::decode(const void* data, size_t length) +{ Reader reader(data, length); auto font = reader.skip<FontHead>(); @@ -473,9 +559,11 @@ assert(reader.isAvailable(font->tableCount * sizeof(TableDir))); - if (true) { + if (true) + { auto dir = font->dir(); - for (unsigned i = 0; i < font->tableCount; ++i) { + for (unsigned i = 0; i < font->tableCount; ++i) + { char str[5]; tag_to_str(dir[i].tag, str); printf("[%d] {%0x08 %s %10d} %d %d\n", @@ -499,7 +587,8 @@ this->clear(); const int pairCount = *cmap++; - for (int i = 0; i < pairCount; ++i) { + for (int i = 0; i < pairCount; ++i) + { uint16_t c = *cmap++; uint16_t g = *cmap++; assert(g < glyphCount); @@ -509,7 +598,8 @@ const float scale = 1.0f / (float)info->upem; - for (int i = 0; i < glyphCount; ++i) { + for (int i = 0; i < glyphCount; ++i) + { float adv = advances[i] * scale; uint32_t start = offsets[i]; uint32_t end = offsets[i + 1];
diff --git a/skia/font_converter/src/font.h b/skia/font_converter/src/font.h index 52069bd..de6bd02 100644 --- a/skia/font_converter/src/font.h +++ b/skia/font_converter/src/font.h
@@ -6,14 +6,17 @@ #include "include/core/SkTypeface.h" #include <vector> -class RiveFont { - struct Pair { +class RiveFont +{ + struct Pair + { uint16_t fChar; uint16_t fGlyph; }; std::vector<Pair> fCMap; - struct Glyph { + struct Glyph + { SkPath fPath; float fAdvance; }; @@ -24,7 +27,8 @@ float advance(uint16_t glyph) const; const SkPath* path(uint16_t glyph) const; - void clear() { + void clear() + { fCMap.clear(); fGlyphs.clear(); }
diff --git a/skia/font_converter/src/font_arguments.hpp b/skia/font_converter/src/font_arguments.hpp index 65fee6a..c4f95f2 100644 --- a/skia/font_converter/src/font_arguments.hpp +++ b/skia/font_converter/src/font_arguments.hpp
@@ -7,11 +7,13 @@ #include "args.hxx" -class FontArguments { +class FontArguments +{ public: FontArguments(int argc, const char** argv) : - m_Parser("Convert a font file into the rive format.", "Experimental....") { + m_Parser("Convert a font file into the rive format.", "Experimental....") + { args::HelpFlag help(m_Parser, "help", "Display this help menu", {'h', "help"}); args::Group required(m_Parser, "required arguments:", args::Group::Validators::All); args::Group optional(m_Parser, "optional arguments:", args::Group::Validators::DontCare); @@ -27,22 +29,33 @@ {'c', "charset"}); args::CompletionFlag completion(m_Parser, {"complete"}); - try { + try + { m_Parser.ParseCLI(argc, argv); - } catch (const std::invalid_argument e) { + } + catch (const std::invalid_argument e) + { std::cout << e.what(); throw; - } catch (const args::Completion& e) { + } + catch (const args::Completion& e) + { std::cout << e.what(); throw; - } catch (const args::Help&) { + } + catch (const args::Help&) + { std::cout << m_Parser; throw; - } catch (const args::ParseError& e) { + } + catch (const args::ParseError& e) + { std::cerr << e.what() << std::endl; std::cerr << m_Parser; throw; - } catch (args::ValidationError e) { + } + catch (args::ValidationError e) + { std::cerr << e.what() << std::endl; std::cerr << m_Parser; throw;
diff --git a/skia/font_converter/src/main.cpp b/skia/font_converter/src/main.cpp index acdeeb1..32ed66e 100644 --- a/skia/font_converter/src/main.cpp +++ b/skia/font_converter/src/main.cpp
@@ -9,10 +9,12 @@ #include "include/core/SkTypeface.h" #include <vector> -static std::vector<char> readFile(const char path[]) { +static std::vector<char> readFile(const char path[]) +{ FILE* fp = fopen(path, "rb"); - if (fp == nullptr) { + if (fp == nullptr) + { fclose(fp); std::ostringstream errorStream; errorStream << "Failed to open file " << path; @@ -25,7 +27,8 @@ std::vector<char> data; data.resize(length); - if (fread(data.data(), 1, length, fp) != length) { + if (fread(data.data(), 1, length, fp) != length) + { fclose(fp); std::ostringstream errorStream; errorStream << "Failed to read file into bytes array " << path; @@ -36,38 +39,47 @@ return data; } -static void writeFile(const char path[], const void* bytes, size_t length) { +static void writeFile(const char path[], const void* bytes, size_t length) +{ FILE* pFile = fopen(path, "wb"); fwrite(bytes, sizeof(char), length, pFile); fclose(pFile); } -static std::vector<char> build_default_charset() { +static std::vector<char> build_default_charset() +{ std::vector<char> charset; - for (int i = 32; i < 127; ++i) { + for (int i = 32; i < 127; ++i) + { charset.push_back(i); } return charset; } -int main(int argc, const char* argv[]) { - try { +int main(int argc, const char* argv[]) +{ + try + { FontArguments args(argc, argv); sk_sp<SkTypeface> typeface; auto src = readFile(args.source().c_str()); auto srcData = SkData::MakeWithCopy(src.data(), src.size()); typeface = SkTypeface::MakeFromData(srcData); - if (!typeface) { + if (!typeface) + { fprintf(stderr, "Failed to convert file to SkTypeface\n"); return 1; } std::vector<char> charset; auto charsetFile = args.charset(); - if (charsetFile.size() > 0) { + if (charsetFile.size() > 0) + { charset = readFile(args.charset().c_str()); - } else { + } + else + { charset = build_default_charset(); } @@ -77,13 +89,21 @@ auto dst = font.encode(); writeFile(args.destination().c_str(), dst->data(), dst->size()); - } catch (const args::Completion& e) { + } + catch (const args::Completion& e) + { return 0; - } catch (const args::Help&) { + } + catch (const args::Help&) + { return 0; - } catch (const args::ParseError& e) { + } + catch (const args::ParseError& e) + { return 1; - } catch (args::ValidationError e) { + } + catch (args::ValidationError e) + { return 1; }
diff --git a/skia/renderer/include/cg_factory.hpp b/skia/renderer/include/cg_factory.hpp index 140a7f0..0e88428 100644 --- a/skia/renderer/include/cg_factory.hpp +++ b/skia/renderer/include/cg_factory.hpp
@@ -8,9 +8,11 @@ #include "rive/factory.hpp" #include <vector> -namespace rive { +namespace rive +{ -class CGFactory : public Factory { +class CGFactory : public Factory +{ public: rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override; rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override;
diff --git a/skia/renderer/include/cg_renderer.hpp b/skia/renderer/include/cg_renderer.hpp index a174c92..7329e4d 100644 --- a/skia/renderer/include/cg_renderer.hpp +++ b/skia/renderer/include/cg_renderer.hpp
@@ -14,8 +14,10 @@ #include <ImageIO/ImageIO.h> #endif -namespace rive { -class CGRenderer : public Renderer { +namespace rive +{ +class CGRenderer : public Renderer +{ protected: CGContextRef m_ctx;
diff --git a/skia/renderer/include/cg_skia_factory.hpp b/skia/renderer/include/cg_skia_factory.hpp index 9f0f120..cb36b91 100644 --- a/skia/renderer/include/cg_skia_factory.hpp +++ b/skia/renderer/include/cg_skia_factory.hpp
@@ -7,8 +7,10 @@ #include "skia_factory.hpp" -namespace rive { -struct CGSkiaFactory : public SkiaFactory { +namespace rive +{ +struct CGSkiaFactory : public SkiaFactory +{ std::vector<uint8_t> platformDecode(Span<const uint8_t>, SkiaFactory::ImageInfo*) override; }; } // namespace rive
diff --git a/skia/renderer/include/mac_utils.hpp b/skia/renderer/include/mac_utils.hpp index fe59ec4..13a9b3f 100644 --- a/skia/renderer/include/mac_utils.hpp +++ b/skia/renderer/include/mac_utils.hpp
@@ -14,37 +14,45 @@ #include <CoreGraphics/CGImage.h> #endif -template <size_t N, typename T> class AutoSTArray { +template <size_t N, typename T> class AutoSTArray +{ T m_storage[N]; T* m_ptr; const size_t m_count; public: - AutoSTArray(size_t n) : m_count(n) { + AutoSTArray(size_t n) : m_count(n) + { m_ptr = m_storage; - if (n > N) { + if (n > N) + { m_ptr = new T[n]; } } - ~AutoSTArray() { - if (m_ptr != m_storage) { + ~AutoSTArray() + { + if (m_ptr != m_storage) + { delete[] m_ptr; } } T* data() const { return m_ptr; } - T& operator[](size_t index) { + T& operator[](size_t index) + { assert(index < m_count); return m_ptr[index]; } }; -constexpr inline uint32_t make_tag(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { +constexpr inline uint32_t make_tag(uint8_t a, uint8_t b, uint8_t c, uint8_t d) +{ return (a << 24) | (b << 16) | (c << 8) | d; } -static inline std::string tag2str(uint32_t tag) { +static inline std::string tag2str(uint32_t tag) +{ std::string str = "abcd"; str[0] = (tag >> 24) & 0xFF; str[1] = (tag >> 16) & 0xFF; @@ -53,33 +61,43 @@ return str; } -template <typename T> class AutoCF { +template <typename T> class AutoCF +{ T m_obj; public: AutoCF(T obj = nullptr) : m_obj(obj) {} - AutoCF(const AutoCF& other) { - if (other.m_obj) { + AutoCF(const AutoCF& other) + { + if (other.m_obj) + { CFRetain(other.m_obj); } m_obj = other.m_obj; } - AutoCF(AutoCF&& other) { + AutoCF(AutoCF&& other) + { m_obj = other.m_obj; other.m_obj = nullptr; } - ~AutoCF() { - if (m_obj) { + ~AutoCF() + { + if (m_obj) + { CFRelease(m_obj); } } - AutoCF& operator=(const AutoCF& other) { - if (m_obj != other.m_obj) { - if (other.m_obj) { + AutoCF& operator=(const AutoCF& other) + { + if (m_obj != other.m_obj) + { + if (other.m_obj) + { CFRetain(other.m_obj); } - if (m_obj) { + if (m_obj) + { CFRelease(m_obj); } m_obj = other.m_obj; @@ -87,9 +105,12 @@ return *this; } - void reset(T obj) { - if (obj != m_obj) { - if (m_obj) { + void reset(T obj) + { + if (obj != m_obj) + { + if (m_obj) + { CFRelease(m_obj); } m_obj = obj; @@ -101,7 +122,8 @@ T get() const { return m_obj; } }; -static inline float find_float(CFDictionaryRef dict, const void* key) { +static inline float find_float(CFDictionaryRef dict, const void* key) +{ auto num = (CFNumberRef)CFDictionaryGetValue(dict, key); assert(num); float value = 0; @@ -109,7 +131,8 @@ return value; } -static inline uint32_t find_u32(CFDictionaryRef dict, const void* key) { +static inline uint32_t find_u32(CFDictionaryRef dict, const void* key) +{ auto num = (CFNumberRef)CFDictionaryGetValue(dict, key); assert(num); assert(!CFNumberIsFloatType(num)); @@ -118,19 +141,22 @@ return value; } -static inline uint32_t number_as_u32(CFNumberRef num) { +static inline uint32_t number_as_u32(CFNumberRef num) +{ uint32_t value; CFNumberGetValue(num, kCFNumberSInt32Type, &value); return value; } -static inline float number_as_float(CFNumberRef num) { +static inline float number_as_float(CFNumberRef num) +{ float value; CFNumberGetValue(num, kCFNumberFloat32Type, &value); return value; } -namespace rive { +namespace rive +{ AutoCF<CGImageRef> DecodeToCGImage(Span<const uint8_t>); AutoCF<CGImageRef> FlipCGImageInY(AutoCF<CGImageRef>); } // namespace rive
diff --git a/skia/renderer/include/renderfont_coretext.hpp b/skia/renderer/include/renderfont_coretext.hpp index 9f2b5cb..de13daf 100644 --- a/skia/renderer/include/renderfont_coretext.hpp +++ b/skia/renderer/include/renderfont_coretext.hpp
@@ -14,7 +14,8 @@ #include <CoreText/CoreText.h> #endif -class CoreTextRenderFont : public rive::RenderFont { +class CoreTextRenderFont : public rive::RenderFont +{ public: CTFontRef m_font; const std::vector<Axis> m_axes;
diff --git a/skia/renderer/include/skia_factory.hpp b/skia/renderer/include/skia_factory.hpp index af7f9aa..c12722c 100644 --- a/skia/renderer/include/skia_factory.hpp +++ b/skia/renderer/include/skia_factory.hpp
@@ -8,9 +8,11 @@ #include "rive/factory.hpp" #include <vector> -namespace rive { +namespace rive +{ -class SkiaFactory : public Factory { +class SkiaFactory : public Factory +{ public: rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override; rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override; @@ -43,15 +45,18 @@ // New virtual for access the platform's codecs // - enum class ColorType { + enum class ColorType + { rgba, bgra, }; - enum class AlphaType { + enum class AlphaType + { premul, opaque, }; - struct ImageInfo { + struct ImageInfo + { size_t rowBytes; // number of bytes between rows uint32_t width; // logical width in pixels uint32_t height; // logical height in pixels @@ -62,7 +67,8 @@ // Clients can override this to provide access to the platform's decoders, rather // than solely relying on the codecs built into Skia. This allows for the Skia impl // to not have to duplicate the code for codecs that the platform may already have. - virtual std::vector<uint8_t> platformDecode(Span<const uint8_t>, ImageInfo* info) { + virtual std::vector<uint8_t> platformDecode(Span<const uint8_t>, ImageInfo* info) + { return std::vector<uint8_t>(); // empty vector means decode failed } };
diff --git a/skia/renderer/include/skia_renderer.hpp b/skia/renderer/include/skia_renderer.hpp index 5afc87b..3fd557b 100644 --- a/skia/renderer/include/skia_renderer.hpp +++ b/skia/renderer/include/skia_renderer.hpp
@@ -9,8 +9,10 @@ class SkCanvas; -namespace rive { -class SkiaRenderer : public Renderer { +namespace rive +{ +class SkiaRenderer : public Renderer +{ protected: SkCanvas* m_Canvas;
diff --git a/skia/renderer/include/to_skia.hpp b/skia/renderer/include/to_skia.hpp index 06e7a43..99e7b4b 100644 --- a/skia/renderer/include/to_skia.hpp +++ b/skia/renderer/include/to_skia.hpp
@@ -19,10 +19,13 @@ #include "rive/shapes/paint/stroke_join.hpp" #include "rive/shapes/paint/blend_mode.hpp" -namespace rive { -class ToSkia { +namespace rive +{ +class ToSkia +{ public: - static SkMatrix convert(const rive::Mat2D& m) { + static SkMatrix convert(const rive::Mat2D& m) + { return SkMatrix::MakeAll(m[0], m[2], m[4], m[1], m[3], m[5], 0, 0, 1); }
diff --git a/skia/renderer/src/cg_factory.cpp b/skia/renderer/src/cg_factory.cpp index 5deea2a..c31af51 100644 --- a/skia/renderer/src/cg_factory.cpp +++ b/skia/renderer/src/cg_factory.cpp
@@ -24,16 +24,19 @@ using namespace rive; -static CGAffineTransform convert(const Mat2D& m) { +static CGAffineTransform convert(const Mat2D& m) +{ return CGAffineTransformMake(m[0], m[1], m[2], m[3], m[4], m[5]); } -static CGPathDrawingMode convert(FillRule rule) { +static CGPathDrawingMode convert(FillRule rule) +{ return (rule == FillRule::nonZero) ? CGPathDrawingMode::kCGPathFill : CGPathDrawingMode::kCGPathEOFill; } -static CGLineJoin convert(StrokeJoin j) { +static CGLineJoin convert(StrokeJoin j) +{ const CGLineJoin cg[] = { CGLineJoin::kCGLineJoinMiter, CGLineJoin::kCGLineJoinRound, @@ -42,7 +45,8 @@ return cg[(unsigned)j]; } -static CGLineCap convert(StrokeCap c) { +static CGLineCap convert(StrokeCap c) +{ const CGLineCap cg[] = { CGLineCap::kCGLineCapButt, CGLineCap::kCGLineCapRound, @@ -76,7 +80,8 @@ } // clang-format on -static void convertColor(ColorInt c, CGFloat rgba[]) { +static void convertColor(ColorInt c, CGFloat rgba[]) +{ constexpr float kByteToUnit = 1.0f / 255; rgba[0] = colorRed(c) * kByteToUnit; rgba[1] = colorGreen(c) * kByteToUnit; @@ -84,7 +89,8 @@ rgba[3] = colorAlpha(c) * kByteToUnit; } -class CGRenderPath : public RenderPath { +class CGRenderPath : public RenderPath +{ private: AutoCF<CGMutablePathRef> m_path = CGPathCreateMutable(); CGPathDrawingMode m_fillMode = CGPathDrawingMode::kCGPathFill; @@ -92,12 +98,15 @@ public: CGRenderPath() {} - CGRenderPath(Span<const Vec2D> pts, Span<const PathVerb> vbs, FillRule rule) { + CGRenderPath(Span<const Vec2D> pts, Span<const PathVerb> vbs, FillRule rule) + { m_fillMode = convert(rule); auto p = pts.data(); - for (auto v : vbs) { - switch ((PathVerb)v) { + for (auto v : vbs) + { + switch ((PathVerb)v) + { case PathVerb::move: CGPathMoveToPoint(m_path, nullptr, p[0].x, p[0].y); p += 1; @@ -121,35 +130,42 @@ p[2].y); p += 3; break; - case PathVerb::close: CGPathCloseSubpath(m_path); break; + case PathVerb::close: + CGPathCloseSubpath(m_path); + break; } } assert(p == pts.end()); } CGPathRef path() const { return m_path.get(); } - CGPathDrawingMode drawingMode(bool isStroke) const { + CGPathDrawingMode drawingMode(bool isStroke) const + { return isStroke ? CGPathDrawingMode::kCGPathStroke : m_fillMode; } void reset() override { m_path.reset(CGPathCreateMutable()); } - void addRenderPath(RenderPath* path, const Mat2D& mx) override { + void addRenderPath(RenderPath* path, const Mat2D& mx) override + { auto transform = convert(mx); CGPathAddPath(m_path, &transform, ((CGRenderPath*)path)->path()); } - void fillRule(FillRule value) override { + void fillRule(FillRule value) override + { m_fillMode = (value == FillRule::nonZero) ? CGPathDrawingMode::kCGPathFill : CGPathDrawingMode::kCGPathEOFill; } void moveTo(float x, float y) override { CGPathMoveToPoint(m_path, nullptr, x, y); } void lineTo(float x, float y) override { CGPathAddLineToPoint(m_path, nullptr, x, y); } - 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 + { CGPathAddCurveToPoint(m_path, nullptr, ox, oy, ix, iy, x, y); } void close() override { CGPathCloseSubpath(m_path); } }; -class CGRenderShader : public RenderShader { +class CGRenderShader : public RenderShader +{ public: CGRenderShader() {} @@ -159,7 +175,8 @@ virtual void draw(CGContextRef) {} }; -class CGRenderPaint : public RenderPaint { +class CGRenderPaint : public RenderPaint +{ private: bool m_isStroke = false; CGFloat m_rgba[4] = {0, 0, 0, 1}; @@ -177,19 +194,24 @@ CGRenderShader* shader() const { return static_cast<CGRenderShader*>(m_shader.get()); } - void apply(CGContextRef ctx) { - if (m_isStroke) { + void apply(CGContextRef ctx) + { + if (m_isStroke) + { CGContextSetRGBStrokeColor(ctx, m_rgba[0], m_rgba[1], m_rgba[2], m_rgba[3]); CGContextSetLineWidth(ctx, m_width); CGContextSetLineJoin(ctx, m_join); CGContextSetLineCap(ctx, m_cap); - } else { + } + else + { CGContextSetRGBFillColor(ctx, m_rgba[0], m_rgba[1], m_rgba[2], m_rgba[3]); } CGContextSetBlendMode(ctx, m_blend); } - void style(RenderPaintStyle style) override { + void style(RenderPaintStyle style) override + { m_isStroke = (style == RenderPaintStyle::stroke); } void color(ColorInt value) override { convertColor(value, m_rgba); } @@ -201,13 +223,15 @@ void invalidateStroke() override {} }; -static CGGradientRef convert(const ColorInt colors[], const float stops[], size_t count) { +static CGGradientRef convert(const ColorInt colors[], const float stops[], size_t count) +{ AutoCF space = CGColorSpaceCreateDeviceRGB(); std::vector<CGFloat> floats(count * 5); // colors[4] + stops[1] auto c = &floats[0]; auto s = &floats[count * 4]; - for (size_t i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) + { convertColor(colors[i], &c[i * 4]); // Rive wants the colors to be premultiplied *after* interpolation @@ -223,15 +247,18 @@ p[1] *= p[3]; p[2] *= p[3]; } - if (stops) { - for (size_t i = 0; i < count; ++i) { + if (stops) + { + for (size_t i = 0; i < count; ++i) + { s[i] = stops[i]; } } return CGGradientCreateWithColorComponents(space, c, s, count); } -class CGRadialGradientRenderShader : public CGRenderShader { +class CGRadialGradientRenderShader : public CGRenderShader +{ AutoCF<CGGradientRef> m_grad; CGPoint m_center; CGFloat m_radius; @@ -243,17 +270,20 @@ const ColorInt colors[], const float stops[], size_t count) : - m_grad(convert(colors, stops, count)) { + m_grad(convert(colors, stops, count)) + { m_center = CGPointMake(cx, cy); m_radius = radius; } - void draw(CGContextRef ctx) override { + void draw(CGContextRef ctx) override + { CGContextDrawRadialGradient(ctx, m_grad, m_center, 0, m_center, m_radius, clampOptions); } }; -class CGLinearGradientRenderShader : public CGRenderShader { +class CGLinearGradientRenderShader : public CGRenderShader +{ AutoCF<CGGradientRef> m_grad; CGPoint m_start, m_end; @@ -265,22 +295,27 @@ const ColorInt colors[], // [count] const float stops[], // [count] size_t count) : - m_grad(convert(colors, stops, count)) { + m_grad(convert(colors, stops, count)) + { m_start = CGPointMake(sx, sy); m_end = CGPointMake(ex, ey); } - void draw(CGContextRef ctx) override { + void draw(CGContextRef ctx) override + { CGContextDrawLinearGradient(ctx, m_grad, m_start, m_end, clampOptions); } }; -class CGRenderImage : public RenderImage { +class CGRenderImage : public RenderImage +{ public: AutoCF<CGImageRef> m_image; - CGRenderImage(const Span<const uint8_t> span) : m_image(DecodeToCGImage(span)) { - if (m_image) { + CGRenderImage(const Span<const uint8_t> span) : m_image(DecodeToCGImage(span)) + { + if (m_image) + { m_Width = rive::castTo<uint32_t>(CGImageGetWidth(m_image.get())); m_Height = rive::castTo<uint32_t>(CGImageGetHeight(m_image.get())); } @@ -288,18 +323,21 @@ Mat2D localM2D() const { return Mat2D(1, 0, 0, -1, 0, (float)m_Height); } - void applyLocalMatrix(CGContextRef ctx) const { + void applyLocalMatrix(CGContextRef ctx) const + { CGContextConcatCTM(ctx, CGAffineTransformMake(1, 0, 0, -1, 0, (float)m_Height)); } - static const CGRenderImage* Cast(const RenderImage* image) { + static const CGRenderImage* Cast(const RenderImage* image) + { return reinterpret_cast<const CGRenderImage*>(image); } }; ////////////////////////////////////////////////////////////////////////// -CGRenderer::CGRenderer(CGContextRef ctx, int width, int height) : m_ctx(ctx) { +CGRenderer::CGRenderer(CGContextRef ctx, int width, int height) : m_ctx(ctx) +{ CGContextSaveGState(ctx); Mat2D m(1, 0, 0, -1, 0, height); @@ -316,7 +354,8 @@ void CGRenderer::transform(const Mat2D& m) { CGContextConcatCTM(m_ctx, convert(m)); } -void CGRenderer::drawPath(RenderPath* path, RenderPaint* paint) { +void CGRenderer::drawPath(RenderPath* path, RenderPaint* paint) +{ auto cgpaint = reinterpret_cast<CGRenderPaint*>(paint); auto cgpath = reinterpret_cast<CGRenderPath*>(path); @@ -324,8 +363,10 @@ CGContextBeginPath(m_ctx); CGContextAddPath(m_ctx, cgpath->path()); - if (auto sh = cgpaint->shader()) { - if (cgpaint->isStroke()) { + if (auto sh = cgpaint->shader()) + { + if (cgpaint->isStroke()) + { // so we can clip against the "stroke" of the path CGContextReplacePathWithStrokedPath(m_ctx); } @@ -337,14 +378,17 @@ sh->draw(m_ctx); CGContextRestoreGState(m_ctx); - } else { + } + else + { CGContextDrawPath(m_ctx, cgpath->drawingMode(cgpaint->isStroke())); } assert(CGContextIsPathEmpty(m_ctx)); } -void CGRenderer::clipPath(RenderPath* path) { +void CGRenderer::clipPath(RenderPath* path) +{ auto cgpath = reinterpret_cast<CGRenderPath*>(path); CGContextBeginPath(m_ctx); @@ -352,7 +396,8 @@ CGContextClip(m_ctx); } -void CGRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity) { +void CGRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity) +{ auto bounds = CGRectMake(0, 0, image->width(), image->height()); CGContextSaveGState(m_ctx); @@ -364,7 +409,8 @@ CGContextRestoreGState(m_ctx); } -static Mat2D basis_matrix(Vec2D p0, Vec2D p1, Vec2D p2) { +static Mat2D basis_matrix(Vec2D p0, Vec2D p1, Vec2D p2) +{ auto e0 = p1 - p0; auto e1 = p2 - p0; return Mat2D(e0.x, e0.y, e1.x, e1.y, p0.x, p0.y); @@ -375,7 +421,8 @@ rcp<RenderBuffer> uvCoords, rcp<RenderBuffer> indices, BlendMode blendMode, - float opacity) { + float opacity) +{ auto cgimage = CGRenderImage::Cast(image); auto const localMatrix = cgimage->localM2D(); @@ -400,7 +447,8 @@ CGContextSetBlendMode(m_ctx, convert(blendMode)); CGContextSetShouldAntialias(m_ctx, false); - for (size_t i = 0; i < triangles; ++i) { + for (size_t i = 0; i < triangles; ++i) + { const auto index0 = *ndx++; const auto index1 = *ndx++; const auto index2 = *ndx++; @@ -431,15 +479,18 @@ // Factory -rcp<RenderBuffer> CGFactory::makeBufferU16(Span<const uint16_t> data) { +rcp<RenderBuffer> CGFactory::makeBufferU16(Span<const uint16_t> data) +{ return DataRenderBuffer::Make(data); } -rcp<RenderBuffer> CGFactory::makeBufferU32(Span<const uint32_t> data) { +rcp<RenderBuffer> CGFactory::makeBufferU32(Span<const uint32_t> data) +{ return DataRenderBuffer::Make(data); } -rcp<RenderBuffer> CGFactory::makeBufferF32(Span<const float> data) { +rcp<RenderBuffer> CGFactory::makeBufferF32(Span<const float> data) +{ return DataRenderBuffer::Make(data); } @@ -449,7 +500,8 @@ float ey, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ return rcp<RenderShader>( new CGLinearGradientRenderShader(sx, sy, ex, ey, colors, stops, count)); } @@ -459,24 +511,29 @@ float radius, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ return rcp<RenderShader>( new CGRadialGradientRenderShader(cx, cy, radius, colors, stops, count)); } -std::unique_ptr<RenderPath> CGFactory::makeRenderPath(RawPath& rawPath, FillRule fillRule) { +std::unique_ptr<RenderPath> CGFactory::makeRenderPath(RawPath& rawPath, FillRule fillRule) +{ return std::make_unique<CGRenderPath>(rawPath.points(), rawPath.verbs(), fillRule); } -std::unique_ptr<RenderPath> CGFactory::makeEmptyRenderPath() { +std::unique_ptr<RenderPath> CGFactory::makeEmptyRenderPath() +{ return std::make_unique<CGRenderPath>(); } -std::unique_ptr<RenderPaint> CGFactory::makeRenderPaint() { +std::unique_ptr<RenderPaint> CGFactory::makeRenderPaint() +{ return std::make_unique<CGRenderPaint>(); } -std::unique_ptr<RenderImage> CGFactory::decodeImage(Span<const uint8_t> encoded) { +std::unique_ptr<RenderImage> CGFactory::decodeImage(Span<const uint8_t> encoded) +{ return std::make_unique<CGRenderImage>(encoded); }
diff --git a/skia/renderer/src/cg_skia_factory.cpp b/skia/renderer/src/cg_skia_factory.cpp index 57352d9..5a4395a 100644 --- a/skia/renderer/src/cg_skia_factory.cpp +++ b/skia/renderer/src/cg_skia_factory.cpp
@@ -20,29 +20,38 @@ using namespace rive; std::vector<uint8_t> CGSkiaFactory::platformDecode(Span<const uint8_t> span, - SkiaFactory::ImageInfo* info) { + SkiaFactory::ImageInfo* info) +{ std::vector<uint8_t> pixels; AutoCF image = DecodeToCGImage(span); - if (!image) { + if (!image) + { return pixels; } bool isOpaque = false; - switch (CGImageGetAlphaInfo(image.get())) { + switch (CGImageGetAlphaInfo(image.get())) + { case kCGImageAlphaNone: case kCGImageAlphaNoneSkipFirst: - case kCGImageAlphaNoneSkipLast: isOpaque = true; break; - default: break; + case kCGImageAlphaNoneSkipLast: + isOpaque = true; + break; + default: + break; } // Now create a drawing context to produce RGBA pixels const size_t bitsPerComponent = 8; CGBitmapInfo cgInfo = kCGBitmapByteOrder32Big; // rgba - if (isOpaque) { + if (isOpaque) + { cgInfo |= kCGImageAlphaNoneSkipLast; - } else { + } + else + { cgInfo |= kCGImageAlphaPremultipliedLast; // premul } const size_t width = CGImageGetWidth(image); @@ -55,7 +64,8 @@ AutoCF cs = CGColorSpaceCreateDeviceRGB(); AutoCF cg = CGBitmapContextCreate(pixels.data(), width, height, bitsPerComponent, rowBytes, cs, cgInfo); - if (!cg) { + if (!cg) + { pixels.clear(); return pixels; }
diff --git a/skia/renderer/src/mac_utils.cpp b/skia/renderer/src/mac_utils.cpp index 893207c..89944d0 100644 --- a/skia/renderer/src/mac_utils.cpp +++ b/skia/renderer/src/mac_utils.cpp
@@ -11,8 +11,10 @@ #include <ImageIO/CGImageSource.h> #endif -AutoCF<CGImageRef> rive::FlipCGImageInY(AutoCF<CGImageRef> image) { - if (!image) { +AutoCF<CGImageRef> rive::FlipCGImageInY(AutoCF<CGImageRef> image) +{ + if (!image) + { return nullptr; } @@ -26,21 +28,25 @@ return CGBitmapContextCreateImage(ctx); } -AutoCF<CGImageRef> rive::DecodeToCGImage(rive::Span<const uint8_t> span) { +AutoCF<CGImageRef> rive::DecodeToCGImage(rive::Span<const uint8_t> span) +{ AutoCF data = CFDataCreate(nullptr, span.data(), span.size()); - if (!data) { + if (!data) + { printf("CFDataCreate failed\n"); return nullptr; } AutoCF source = CGImageSourceCreateWithData(data, nullptr); - if (!source) { + if (!source) + { printf("CGImageSourceCreateWithData failed\n"); return nullptr; } AutoCF image = CGImageSourceCreateImageAtIndex(source, 0, nullptr); - if (!image) { + if (!image) + { printf("CGImageSourceCreateImageAtIndex failed\n"); } return image;
diff --git a/skia/renderer/src/renderfont_coretext.cpp b/skia/renderer/src/renderfont_coretext.cpp index 8cf73e9..36771da 100644 --- a/skia/renderer/src/renderfont_coretext.cpp +++ b/skia/renderer/src/renderfont_coretext.cpp
@@ -25,14 +25,17 @@ constexpr int kStdScale = 2048; constexpr float gInvScale = 1.0f / kStdScale; -static std::vector<rive::RenderFont::Axis> compute_axes(CTFontRef font) { +static std::vector<rive::RenderFont::Axis> compute_axes(CTFontRef font) +{ std::vector<rive::RenderFont::Axis> axes; AutoCF array = CTFontCopyVariationAxes(font); - if (auto count = array.get() ? CFArrayGetCount(array.get()) : 0) { + if (auto count = array.get() ? CFArrayGetCount(array.get()) : 0) + { axes.reserve(count); - for (auto i = 0; i < count; ++i) { + for (auto i = 0; i < count; ++i) + { auto axis = (CFDictionaryRef)CFArrayGetValueAtIndex(array, i); auto tag = find_u32(axis, kCTFontVariationAxisIdentifierKey); @@ -47,19 +50,23 @@ return axes; } -static std::vector<rive::RenderFont::Coord> compute_coords(CTFontRef font) { +static std::vector<rive::RenderFont::Coord> compute_coords(CTFontRef font) +{ std::vector<rive::RenderFont::Coord> coords(0); AutoCF dict = CTFontCopyVariation(font); - if (dict) { + if (dict) + { int count = CFDictionaryGetCount(dict); - if (count > 0) { + if (count > 0) + { coords.resize(count); AutoSTArray<100, const void*> ptrs(count * 2); const void** keys = &ptrs[0]; const void** values = &ptrs[count]; CFDictionaryGetKeysAndValues(dict, keys, values); - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) + { uint32_t tag = number_as_u32((CFNumberRef)keys[i]); float value = number_as_float((CFNumberRef)values[i]); // printf("[%d] %08X %s %g\n", i, tag, tag2str(tag).c_str(), value); @@ -70,7 +77,8 @@ return coords; } -static rive::RenderFont::LineMetrics make_lmx(CTFontRef font) { +static rive::RenderFont::LineMetrics make_lmx(CTFontRef font) +{ return { (float)-CTFontGetAscent(font) * gInvScale, (float)CTFontGetDescent(font) * gInvScale, @@ -81,16 +89,19 @@ rive::RenderFont(make_lmx(font)), m_font(font), // we take ownership of font m_axes(std::move(axes)), - m_coords(compute_coords(font)) {} + m_coords(compute_coords(font)) +{} CoreTextRenderFont::~CoreTextRenderFont() { CFRelease(m_font); } -rive::rcp<rive::RenderFont> CoreTextRenderFont::makeAtCoords(rive::Span<const Coord> coords) const { +rive::rcp<rive::RenderFont> CoreTextRenderFont::makeAtCoords(rive::Span<const Coord> coords) const +{ AutoCF vars = CFDictionaryCreateMutable(kCFAllocatorDefault, coords.size(), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - for (const auto& c : coords) { + for (const auto& c : coords) + { AutoCF tagNum = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &c.axis); AutoCF valueNum = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &c.value); CFDictionaryAddValue(vars.get(), tagNum.get(), valueNum.get()); @@ -109,7 +120,8 @@ return rive::rcp<rive::RenderFont>(new CoreTextRenderFont(font, compute_axes(font))); } -static CTFontRef font_from_run(CTRunRef run) { +static CTFontRef font_from_run(CTRunRef run) +{ auto attr = CTRunGetAttributes(run); assert(attr); CTFontRef ct = (CTFontRef)CFDictionaryGetValue(attr, kCTFontAttributeName); @@ -118,23 +130,31 @@ } static rive::rcp<rive::RenderFont> convert_to_renderfont(CTFontRef ct, - rive::rcp<rive::RenderFont> rf) { + rive::rcp<rive::RenderFont> rf) +{ auto ctrf = static_cast<CoreTextRenderFont*>(rf.get()); - if (ctrf->m_font == ct) { + if (ctrf->m_font == ct) + { return rf; } CFRetain(ct); return rive::rcp<rive::RenderFont>(new CoreTextRenderFont(ct, compute_axes(ct))); } -static void apply_element(void* ctx, const CGPathElement* element) { +static void apply_element(void* ctx, const CGPathElement* element) +{ auto path = (rive::RawPath*)ctx; const CGPoint* points = element->points; - switch (element->type) { - case kCGPathElementMoveToPoint: path->moveTo(points[0].x, points[0].y); break; + switch (element->type) + { + case kCGPathElementMoveToPoint: + path->moveTo(points[0].x, points[0].y); + break; - case kCGPathElementAddLineToPoint: path->lineTo(points[0].x, points[0].y); break; + case kCGPathElementAddLineToPoint: + path->lineTo(points[0].x, points[0].y); + break; case kCGPathElementAddQuadCurveToPoint: path->quadTo(points[0].x, points[0].y, points[1].x, points[1].y); @@ -149,17 +169,23 @@ points[2].y); break; - case kCGPathElementCloseSubpath: path->close(); break; + case kCGPathElementCloseSubpath: + path->close(); + break; - default: assert(false); break; + default: + assert(false); + break; } } -rive::RawPath CoreTextRenderFont::getPath(rive::GlyphID glyph) const { +rive::RawPath CoreTextRenderFont::getPath(rive::GlyphID glyph) const +{ rive::RawPath rpath; AutoCF cgPath = CTFontCreatePathForGlyph(m_font, glyph, nullptr); - if (!cgPath) { + if (!cgPath) + { return rpath; } @@ -170,25 +196,30 @@ //////////////////////////////////////////////////////////////////////////////////// -struct AutoUTF16 { +struct AutoUTF16 +{ std::vector<uint16_t> array; - AutoUTF16(const rive::Unichar uni[], int count) { + AutoUTF16(const rive::Unichar uni[], int count) + { array.reserve(count); - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) + { uint16_t tmp[2]; int n = rive::UTF::ToUTF16(uni[i], tmp); - for (int i = 0; i < n; ++i) { + for (int i = 0; i < n; ++i) + { array.push_back(tmp[i]); } } } }; -static rive::RenderGlyphRun -add_run(CTRunRef run, uint32_t textStart, float textSize, float& startX) { - if (auto count = CTRunGetGlyphCount(run)) { +static rive::RenderGlyphRun add_run(CTRunRef run, uint32_t textStart, float textSize, float& startX) +{ + if (auto count = CTRunGetGlyphCount(run)) + { const float scale = textSize * gInvScale; rive::RenderGlyphRun gr(count); @@ -202,7 +233,8 @@ CTRunGetAdvances(run, {0, count}, advances.data()); CTRunGetStringIndices(run, {0, count}, indices.data()); - for (CFIndex i = 0; i < count; ++i) { + for (CFIndex i = 0; i < count; ++i) + { gr.xpos[i] = startX; gr.textIndices[i] = textStart + indices[i]; // utf16 offsets, will fix-up later startX += advances[i].width * scale; @@ -215,12 +247,14 @@ rive::SimpleArray<rive::RenderGlyphRun> CoreTextRenderFont::onShapeText(rive::Span<const rive::Unichar> text, - rive::Span<const rive::RenderTextRun> truns) const { + rive::Span<const rive::RenderTextRun> truns) const +{ rive::SimpleArrayBuilder<rive::RenderGlyphRun> gruns(truns.size()); uint32_t textIndex = 0; float startX = 0; - for (const auto& tr : truns) { + for (const auto& tr : truns) + { CTFontRef font = ((CoreTextRenderFont*)tr.font.get())->m_font; AutoUTF16 utf16(&text[textIndex], tr.unicharCount); @@ -246,10 +280,12 @@ CFArrayRef run_array = CTLineGetGlyphRuns(line.get()); CFIndex runCount = CFArrayGetCount(run_array); - for (CFIndex i = 0; i < runCount; ++i) { + for (CFIndex i = 0; i < runCount; ++i) + { CTRunRef runref = (CTRunRef)CFArrayGetValueAtIndex(run_array, i); rive::RenderGlyphRun grun = add_run(runref, textIndex, tr.size, startX); - if (grun.glyphs.size() > 0) { + if (grun.glyphs.size() > 0) + { auto ct = font_from_run(runref); grun.font = convert_to_renderfont(ct, tr.font); grun.size = tr.size; @@ -264,25 +300,33 @@ //////////////////////////////////////////////////////////////////////////////////////////////// -rive::rcp<rive::RenderFont> CoreTextRenderFont::FromCT(CTFontRef ctfont) { - if (!ctfont) { +rive::rcp<rive::RenderFont> CoreTextRenderFont::FromCT(CTFontRef ctfont) +{ + if (!ctfont) + { return nullptr; } // We always want the ctfont at our magic size - if (CTFontGetSize(ctfont) != kStdScale) { + if (CTFontGetSize(ctfont) != kStdScale) + { ctfont = CTFontCreateCopyWithAttributes(ctfont, kStdScale, nullptr, nullptr); - } else { + } + else + { CFRetain(ctfont); } // Apple may have secretly set the opsz axis based on the size. We want to undo this // since our stdsize isn't really the size we'll show it at. auto axes = compute_axes(ctfont); - if (axes.size() > 0) { + if (axes.size() > 0) + { constexpr uint32_t kOPSZ = make_tag('o', 'p', 's', 'z'); - for (const auto& ax : axes) { - if (ax.tag == kOPSZ) { + for (const auto& ax : axes) + { + if (ax.tag == kOPSZ) + { auto xform = CGAffineTransformMakeScale(kStdScale / ax.def, kStdScale / ax.def); // Recreate the font at this size, but with a balancing transform, // so we get the 'default' shapes w.r.t. the opsz axis @@ -297,15 +341,18 @@ return rive::rcp<rive::RenderFont>(new CoreTextRenderFont(ctfont, std::move(axes))); } -rive::rcp<rive::RenderFont> CoreTextRenderFont::Decode(rive::Span<const uint8_t> span) { +rive::rcp<rive::RenderFont> CoreTextRenderFont::Decode(rive::Span<const uint8_t> span) +{ AutoCF data = CFDataCreate(nullptr, span.data(), span.size()); // makes a copy - if (!data) { + if (!data) + { assert(false); return nullptr; } AutoCF desc = CTFontManagerCreateFontDescriptorFromData(data.get()); - if (!desc) { + if (!desc) + { assert(false); return nullptr; } @@ -314,7 +361,8 @@ AutoCF ctfont = CTFontCreateWithFontDescriptorAndOptions(desc.get(), kStdScale, nullptr, options); - if (!ctfont) { + if (!ctfont) + { assert(false); return nullptr; }
diff --git a/skia/renderer/src/skia_factory.cpp b/skia/renderer/src/skia_factory.cpp index a03ca7b..802b6f3 100644 --- a/skia/renderer/src/skia_factory.cpp +++ b/skia/renderer/src/skia_factory.cpp
@@ -24,7 +24,8 @@ // skia's has/had bugs in trilerp, so backing down to nearest mip const SkSamplingOptions gSampling(SkFilterMode::kLinear, SkMipmapMode::kNearest); -class SkiaRenderPath : public RenderPath { +class SkiaRenderPath : public RenderPath +{ private: SkPath m_Path; @@ -43,7 +44,8 @@ virtual void close() override; }; -class SkiaRenderPaint : public RenderPaint { +class SkiaRenderPaint : public RenderPaint +{ private: SkPaint m_Paint; @@ -62,7 +64,8 @@ void invalidateStroke() override {} }; -class SkiaRenderImage : public RenderImage { +class SkiaRenderImage : public RenderImage +{ private: sk_sp<SkImage> m_SkImage; @@ -72,7 +75,8 @@ sk_sp<SkImage> skImage() const { return m_SkImage; } }; -class SkiaRenderShader : public RenderShader { +class SkiaRenderShader : public RenderShader +{ public: SkiaRenderShader(sk_sp<SkShader> sh) : shader(std::move(sh)) {} @@ -82,23 +86,31 @@ void SkiaRenderPath::fillRule(FillRule value) { m_Path.setFillType(ToSkia::convert(value)); } void SkiaRenderPath::reset() { m_Path.reset(); } -void SkiaRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform) { +void SkiaRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform) +{ m_Path.addPath(reinterpret_cast<SkiaRenderPath*>(path)->m_Path, ToSkia::convert(transform)); } void SkiaRenderPath::moveTo(float x, float y) { m_Path.moveTo(x, y); } void SkiaRenderPath::lineTo(float x, float y) { m_Path.lineTo(x, y); } -void SkiaRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) { +void SkiaRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) +{ m_Path.cubicTo(ox, oy, ix, iy, x, y); } void SkiaRenderPath::close() { m_Path.close(); } SkiaRenderPaint::SkiaRenderPaint() { m_Paint.setAntiAlias(true); } -void SkiaRenderPaint::style(RenderPaintStyle style) { - switch (style) { - case RenderPaintStyle::fill: m_Paint.setStyle(SkPaint::Style::kFill_Style); break; - case RenderPaintStyle::stroke: m_Paint.setStyle(SkPaint::Style::kStroke_Style); break; +void SkiaRenderPaint::style(RenderPaintStyle style) +{ + switch (style) + { + case RenderPaintStyle::fill: + m_Paint.setStyle(SkPaint::Style::kFill_Style); + break; + case RenderPaintStyle::stroke: + m_Paint.setStyle(SkPaint::Style::kStroke_Style); + break; } } void SkiaRenderPaint::color(unsigned int value) { m_Paint.setColor(value); } @@ -108,26 +120,31 @@ void SkiaRenderPaint::blendMode(BlendMode value) { m_Paint.setBlendMode(ToSkia::convert(value)); } -void SkiaRenderPaint::shader(rcp<RenderShader> rsh) { +void SkiaRenderPaint::shader(rcp<RenderShader> rsh) +{ SkiaRenderShader* sksh = (SkiaRenderShader*)rsh.get(); m_Paint.setShader(sksh ? sksh->shader : nullptr); } void SkiaRenderer::save() { m_Canvas->save(); } void SkiaRenderer::restore() { m_Canvas->restore(); } -void SkiaRenderer::transform(const Mat2D& transform) { +void SkiaRenderer::transform(const Mat2D& transform) +{ m_Canvas->concat(ToSkia::convert(transform)); } -void SkiaRenderer::drawPath(RenderPath* path, RenderPaint* paint) { +void SkiaRenderer::drawPath(RenderPath* path, RenderPaint* paint) +{ m_Canvas->drawPath(reinterpret_cast<SkiaRenderPath*>(path)->path(), reinterpret_cast<SkiaRenderPaint*>(paint)->paint()); } -void SkiaRenderer::clipPath(RenderPath* path) { +void SkiaRenderer::clipPath(RenderPath* path) +{ m_Canvas->clipPath(reinterpret_cast<SkiaRenderPath*>(path)->path(), true); } -void SkiaRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity) { +void SkiaRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity) +{ SkPaint paint; paint.setAlphaf(opacity); paint.setBlendMode(ToSkia::convert(blendMode)); @@ -142,7 +159,8 @@ rcp<RenderBuffer> uvCoords, rcp<RenderBuffer> indices, BlendMode blendMode, - float opacity) { + float opacity) +{ // need our vertices and uvs to agree assert(vertices->count() == uvCoords->count()); // vertices and uvs are arrays of floats, so we need their counts to be @@ -159,7 +177,8 @@ // The local matrix is ignored for drawVertices, so we have to manually scale // the UVs to match Skia's convention... std::vector<SkPoint> scaledUVs(vertexCount); - for (int i = 0; i < vertexCount; ++i) { + for (int i = 0; i < vertexCount; ++i) + { scaledUVs[i] = {uvs[i].fX * image->width(), uvs[i].fY * image->height()}; } uvs = scaledUVs.data(); @@ -195,22 +214,26 @@ m_Canvas->drawVertices(vt, SkBlendMode::kModulate, paint); } -SkiaRenderImage::SkiaRenderImage(sk_sp<SkImage> image) : m_SkImage(std::move(image)) { +SkiaRenderImage::SkiaRenderImage(sk_sp<SkImage> image) : m_SkImage(std::move(image)) +{ m_Width = m_SkImage->width(); m_Height = m_SkImage->height(); } // Factory -rcp<RenderBuffer> SkiaFactory::makeBufferU16(Span<const uint16_t> data) { +rcp<RenderBuffer> SkiaFactory::makeBufferU16(Span<const uint16_t> data) +{ return DataRenderBuffer::Make(data); } -rcp<RenderBuffer> SkiaFactory::makeBufferU32(Span<const uint32_t> data) { +rcp<RenderBuffer> SkiaFactory::makeBufferU32(Span<const uint32_t> data) +{ return DataRenderBuffer::Make(data); } -rcp<RenderBuffer> SkiaFactory::makeBufferF32(Span<const float> data) { +rcp<RenderBuffer> SkiaFactory::makeBufferF32(Span<const float> data) +{ return DataRenderBuffer::Make(data); } @@ -220,7 +243,8 @@ float ey, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ const SkPoint pts[] = {{sx, sy}, {ex, ey}}; auto sh = SkGradientShader::MakeLinear(pts, (const SkColor*)colors, stops, count, SkTileMode::kClamp); @@ -232,7 +256,8 @@ float radius, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ auto sh = SkGradientShader::MakeRadial({cx, cy}, radius, (const SkColor*)colors, @@ -242,7 +267,8 @@ return rcp<RenderShader>(new SkiaRenderShader(std::move(sh))); } -std::unique_ptr<RenderPath> SkiaFactory::makeRenderPath(RawPath& rawPath, FillRule fillRule) { +std::unique_ptr<RenderPath> SkiaFactory::makeRenderPath(RawPath& rawPath, FillRule fillRule) +{ const bool isVolatile = false; // ??? const SkScalar* conicWeights = nullptr; const int conicWeightCount = 0; @@ -257,27 +283,34 @@ isVolatile)); } -std::unique_ptr<RenderPath> SkiaFactory::makeEmptyRenderPath() { +std::unique_ptr<RenderPath> SkiaFactory::makeEmptyRenderPath() +{ return std::make_unique<SkiaRenderPath>(); } -std::unique_ptr<RenderPaint> SkiaFactory::makeRenderPaint() { +std::unique_ptr<RenderPaint> SkiaFactory::makeRenderPaint() +{ return std::make_unique<SkiaRenderPaint>(); } -std::unique_ptr<RenderImage> SkiaFactory::decodeImage(Span<const uint8_t> encoded) { +std::unique_ptr<RenderImage> SkiaFactory::decodeImage(Span<const uint8_t> encoded) +{ sk_sp<SkData> data = SkData::MakeWithoutCopy(encoded.data(), encoded.size()); auto image = SkImage::MakeFromEncoded(data); - if (image) { + if (image) + { // Our optimized skia buld seems to have broken lazy-image decode. // As a work-around for now, force the image to be decoded. image = image->makeRasterImage(); - } else { + } + else + { // Skia failed, so let's try the platform ImageInfo info; auto pixels = this->platformDecode(encoded, &info); - if (pixels.size() > 0) { + if (pixels.size() > 0) + { auto ct = info.colorType == ColorType::rgba ? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType; auto at =
diff --git a/skia/thumbnail_generator/src/main.cpp b/skia/thumbnail_generator/src/main.cpp index f804338..2a6af9c 100644 --- a/skia/thumbnail_generator/src/main.cpp +++ b/skia/thumbnail_generator/src/main.cpp
@@ -12,7 +12,8 @@ #include <iostream> #include <sstream> -std::string getFileName(char* path) { +std::string getFileName(char* path) +{ std::string str(path); const size_t from = str.find_last_of("\\/"); @@ -22,21 +23,27 @@ const int DEFAULT_SIZE = 256; -int getArg(char* arg) { +int getArg(char* arg) +{ std::istringstream ss(arg); int x; - if (!(ss >> x)) { + if (!(ss >> x)) + { std::cerr << "Invalid number: " << arg << '\n'; - } else if (!ss.eof()) { + } + else if (!ss.eof()) + { std::cerr << "Trailing chars after number: " << arg << '\n'; } return x == 0 ? DEFAULT_SIZE : x; } -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ rive::SkiaFactory factory; - if (argc < 2) { + if (argc < 2) + { fprintf(stderr, "must pass source file"); return 1; } @@ -45,21 +52,26 @@ const char* outPath; std::string filename; std::string fullName; - if (argc > 2) { + if (argc > 2) + { outPath = argv[2]; - } else { + } + else + { filename = getFileName(argv[1]); fullName = filename + ".png"; outPath = fullName.c_str(); } int width = DEFAULT_SIZE, height = DEFAULT_SIZE; - if (argc == 5) { + if (argc == 5) + { width = getArg(argv[3]); height = getArg(argv[4]); } - if (fp == nullptr) { + if (fp == nullptr) + { fprintf(stderr, "Failed to open rive file.\n"); return 1; } @@ -67,7 +79,8 @@ auto length = ftell(fp); fseek(fp, 0, SEEK_SET); std::vector<uint8_t> bytes(length); - if (fread(bytes.data(), 1, length, fp) != length) { + if (fread(bytes.data(), 1, length, fp) != length) + { fprintf(stderr, "Failed to read rive file.\n"); fclose(fp); return 1; @@ -75,7 +88,8 @@ fclose(fp); auto file = rive::File::import(bytes, &factory); - if (!file) { + if (!file) + { fprintf(stderr, "Failed to read rive file.\n"); return 1; } @@ -95,11 +109,13 @@ renderer.restore(); sk_sp<SkImage> img(rasterSurface->makeImageSnapshot()); - if (!img) { + if (!img) + { return 1; } sk_sp<SkData> png(img->encodeToData()); - if (!png) { + if (!png) + { return 1; } SkFILEWStream out(outPath);
diff --git a/src/animation/animation_state.cpp b/src/animation/animation_state.cpp index b8f92d1..342ed42 100644 --- a/src/animation/animation_state.cpp +++ b/src/animation/animation_state.cpp
@@ -6,6 +6,7 @@ using namespace rive; -std::unique_ptr<StateInstance> AnimationState::makeInstance(ArtboardInstance* instance) const { +std::unique_ptr<StateInstance> AnimationState::makeInstance(ArtboardInstance* instance) const +{ return std::make_unique<AnimationStateInstance>(this, instance); }
diff --git a/src/animation/animation_state_instance.cpp b/src/animation/animation_state_instance.cpp index 6365708..e3c972d 100644 --- a/src/animation/animation_state_instance.cpp +++ b/src/animation/animation_state_instance.cpp
@@ -16,9 +16,11 @@ // cause bad casts in parts of the code where we assumed AnimationStates // would have create AnimationStateInstances. m_AnimationInstance(state->animation() ? state->animation() : &emptyAnimation, instance), - m_KeepGoing(true) {} + m_KeepGoing(true) +{} -void AnimationStateInstance::advance(float seconds, Span<SMIInput*>) { +void AnimationStateInstance::advance(float seconds, Span<SMIInput*>) +{ m_KeepGoing = m_AnimationInstance.advance(seconds); }
diff --git a/src/animation/blend_animation.cpp b/src/animation/blend_animation.cpp index 737491d..3c43ce2 100644 --- a/src/animation/blend_animation.cpp +++ b/src/animation/blend_animation.cpp
@@ -6,22 +6,28 @@ using namespace rive; -StatusCode BlendAnimation::import(ImportStack& importStack) { +StatusCode BlendAnimation::import(ImportStack& importStack) +{ auto importer = importStack.latest<LayerStateImporter>(LayerStateBase::typeKey); - if (importer == nullptr) { + if (importer == nullptr) + { return StatusCode::MissingObject; - } else if (!importer->addBlendAnimation(this)) { + } + else if (!importer->addBlendAnimation(this)) + { return StatusCode::InvalidObject; } auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey); - if (artboardImporter == nullptr) { + if (artboardImporter == nullptr) + { return StatusCode::MissingObject; } auto artboard = artboardImporter->artboard(); size_t animationCount = artboard->animationCount(); - if ((size_t)animationId() < animationCount) { + if ((size_t)animationId() < animationCount) + { m_Animation = artboardImporter->artboard()->animation(animationId()); }
diff --git a/src/animation/blend_animation_direct.cpp b/src/animation/blend_animation_direct.cpp index 0fe8e1b..98861a9 100644 --- a/src/animation/blend_animation_direct.cpp +++ b/src/animation/blend_animation_direct.cpp
@@ -9,18 +9,22 @@ StatusCode BlendAnimationDirect::onAddedClean(CoreContext* context) { return StatusCode::Ok; } -StatusCode BlendAnimationDirect::import(ImportStack& importStack) { +StatusCode BlendAnimationDirect::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey); - if (stateMachineImporter == nullptr) { + 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()); - if (input == nullptr || !input->is<StateMachineNumber>()) { + if (input == nullptr || !input->is<StateMachineNumber>()) + { return StatusCode::InvalidObject; } return Super::import(importStack);
diff --git a/src/animation/blend_state.cpp b/src/animation/blend_state.cpp index 321926b..c521d7b 100644 --- a/src/animation/blend_state.cpp +++ b/src/animation/blend_state.cpp
@@ -3,13 +3,16 @@ using namespace rive; -BlendState::~BlendState() { - for (auto anim : m_Animations) { +BlendState::~BlendState() +{ + for (auto anim : m_Animations) + { delete anim; } } -void BlendState::addAnimation(BlendAnimation* animation) { +void BlendState::addAnimation(BlendAnimation* animation) +{ // Assert it's not already contained. assert(std::find(m_Animations.begin(), m_Animations.end(), animation) == m_Animations.end()); m_Animations.push_back(animation);
diff --git a/src/animation/blend_state_1d.cpp b/src/animation/blend_state_1d.cpp index 0273fcb..b77422d 100644 --- a/src/animation/blend_state_1d.cpp +++ b/src/animation/blend_state_1d.cpp
@@ -6,23 +6,29 @@ using namespace rive; -std::unique_ptr<StateInstance> BlendState1D::makeInstance(ArtboardInstance* instance) const { +std::unique_ptr<StateInstance> BlendState1D::makeInstance(ArtboardInstance* instance) const +{ return std::make_unique<BlendState1DInstance>(this, instance); } -StatusCode BlendState1D::import(ImportStack& importStack) { +StatusCode BlendState1D::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey); - if (stateMachineImporter == nullptr) { + if (stateMachineImporter == nullptr) + { return StatusCode::MissingObject; } - if (hasValidInputId()) { + if (hasValidInputId()) + { // 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()); - if (input == nullptr || !input->is<StateMachineNumber>()) { + 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 5f3e035..235aa51 100644 --- a/src/animation/blend_state_1d_instance.cpp +++ b/src/animation/blend_state_1d_instance.cpp
@@ -5,23 +5,31 @@ BlendState1DInstance::BlendState1DInstance(const BlendState1D* blendState, ArtboardInstance* instance) : - BlendStateInstance<BlendState1D, BlendAnimation1D>(blendState, instance) {} + BlendStateInstance<BlendState1D, BlendAnimation1D>(blendState, instance) +{} -int BlendState1DInstance::animationIndex(float value) { +int BlendState1DInstance::animationIndex(float value) +{ int idx = 0; int mid = 0; float closestValue = 0; int start = 0; int end = static_cast<int>(m_AnimationInstances.size()) - 1; - while (start <= end) { + while (start <= end) + { mid = (start + end) >> 1; closestValue = m_AnimationInstances[mid].blendAnimation()->value(); - if (closestValue < value) { + if (closestValue < value) + { start = mid + 1; - } else if (closestValue > value) { + } + else if (closestValue > value) + { end = mid - 1; - } else { + } + else + { idx = start = mid; break; } @@ -31,12 +39,14 @@ return idx; } -void BlendState1DInstance::advance(float seconds, Span<SMIInput*> inputs) { +void BlendState1DInstance::advance(float seconds, Span<SMIInput*> inputs) +{ BlendStateInstance<BlendState1D, BlendAnimation1D>::advance(seconds, inputs); auto blendState = state()->as<BlendState1D>(); float value = 0.0f; - if (blendState->hasValidInputId()) { + if (blendState->hasValidInputId()) + { // TODO: https://github.com/rive-app/rive-cpp/issues/229 auto inputInstance = inputs[blendState->inputId()]; auto numberInput = reinterpret_cast<const SMINumber*>(inputInstance); @@ -52,20 +62,29 @@ auto toValue = m_To == nullptr ? 0.0f : m_To->blendAnimation()->value(); auto fromValue = m_From == nullptr ? 0.0f : m_From->blendAnimation()->value(); - if (m_To == nullptr || m_From == nullptr || toValue == fromValue) { + if (m_To == nullptr || m_From == nullptr || toValue == fromValue) + { mix = mixFrom = 1.0f; - } else { + } + else + { mix = (value - fromValue) / (toValue - fromValue); mixFrom = 1.0f - mix; } - for (auto& animation : m_AnimationInstances) { + for (auto& animation : m_AnimationInstances) + { auto animationValue = animation.blendAnimation()->value(); - if (m_To != nullptr && animationValue == toValue) { + if (m_To != nullptr && animationValue == toValue) + { animation.mix(mix); - } else if (m_From != nullptr && animationValue == fromValue) { + } + else if (m_From != nullptr && animationValue == fromValue) + { animation.mix(mixFrom); - } else { + } + else + { animation.mix(0.0f); } }
diff --git a/src/animation/blend_state_direct.cpp b/src/animation/blend_state_direct.cpp index b90ff03..92e96d4 100644 --- a/src/animation/blend_state_direct.cpp +++ b/src/animation/blend_state_direct.cpp
@@ -6,6 +6,7 @@ using namespace rive; -std::unique_ptr<StateInstance> BlendStateDirect::makeInstance(ArtboardInstance* instance) const { +std::unique_ptr<StateInstance> BlendStateDirect::makeInstance(ArtboardInstance* instance) const +{ return std::make_unique<BlendStateDirectInstance>(this, instance); } \ 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 409fd50..5323544 100644 --- a/src/animation/blend_state_direct_instance.cpp +++ b/src/animation/blend_state_direct_instance.cpp
@@ -5,11 +5,14 @@ BlendStateDirectInstance::BlendStateDirectInstance(const BlendStateDirect* blendState, ArtboardInstance* instance) : - BlendStateInstance<BlendStateDirect, BlendAnimationDirect>(blendState, instance) {} + BlendStateInstance<BlendStateDirect, BlendAnimationDirect>(blendState, instance) +{} -void BlendStateDirectInstance::advance(float seconds, Span<SMIInput*> inputs) { +void BlendStateDirectInstance::advance(float seconds, Span<SMIInput*> inputs) +{ BlendStateInstance<BlendStateDirect, BlendAnimationDirect>::advance(seconds, inputs); - for (auto& animation : m_AnimationInstances) { + for (auto& animation : m_AnimationInstances) + { auto inputInstance = inputs[animation.blendAnimation()->inputId()]; auto numberInput = reinterpret_cast<const SMINumber*>(inputInstance);
diff --git a/src/animation/blend_state_transition.cpp b/src/animation/blend_state_transition.cpp index 793cc84..3a44be3 100644 --- a/src/animation/blend_state_transition.cpp +++ b/src/animation/blend_state_transition.cpp
@@ -9,9 +9,12 @@ using namespace rive; const LinearAnimationInstance* -BlendStateTransition::exitTimeAnimationInstance(const StateInstance* from) const { - if (from != nullptr) { - switch (from->state()->coreType()) { +BlendStateTransition::exitTimeAnimationInstance(const StateInstance* from) const +{ + if (from != nullptr) + { + switch (from->state()->coreType()) + { case BlendState1D::typeKey: return static_cast<const BlendState1DInstance*>(from)->animationInstance( @@ -27,8 +30,10 @@ return nullptr; } -const LinearAnimation* BlendStateTransition::exitTimeAnimation(const LayerState* from) const { - if (m_ExitBlendAnimation != nullptr) { +const LinearAnimation* BlendStateTransition::exitTimeAnimation(const LayerState* from) const +{ + if (m_ExitBlendAnimation != nullptr) + { return m_ExitBlendAnimation->animation(); } return nullptr;
diff --git a/src/animation/cubic_interpolator.cpp b/src/animation/cubic_interpolator.cpp index 47fa860..ed655c8 100644 --- a/src/animation/cubic_interpolator.cpp +++ b/src/animation/cubic_interpolator.cpp
@@ -12,31 +12,37 @@ const int SubdivisionMaxIterations = 10; // 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) { +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 + (3.0f * aA1)) * aT; } // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2. -static float getSlope(float aT, float aA1, float aA2) { +static float getSlope(float aT, float aA1, float aA2) +{ return 3.0f * (1.0f - 3.0f * aA2 + 3.0f * aA1) * aT * aT + 2.0f * (3.0f * aA2 - 6.0f * aA1) * aT + (3.0f * aA1); } -StatusCode CubicInterpolator::onAddedDirty(CoreContext* context) { - for (int i = 0; i < SplineTableSize; ++i) { +StatusCode CubicInterpolator::onAddedDirty(CoreContext* context) +{ + for (int i = 0; i < SplineTableSize; ++i) + { m_Values[i] = calcBezier(i * SampleStepSize, x1(), x2()); } return StatusCode::Ok; } -float CubicInterpolator::getT(float x) const { +float CubicInterpolator::getT(float x) const +{ float intervalStart = 0.0f; 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; @@ -49,28 +55,39 @@ float _x1 = x1(), _x2 = x2(); float initialSlope = getSlope(guessForT, _x1, _x2); - if (initialSlope >= NewtonMinSlope) { - for (int i = 0; i < NewtonIterations; ++i) { + if (initialSlope >= NewtonMinSlope) + { + for (int i = 0; i < NewtonIterations; ++i) + { float currentSlope = getSlope(guessForT, _x1, _x2); - if (currentSlope == 0.0f) { + if (currentSlope == 0.0f) + { return guessForT; } float currentX = calcBezier(guessForT, _x1, _x2) - x; guessForT -= currentX / currentSlope; } return guessForT; - } else if (initialSlope == 0.0f) { + } + else if (initialSlope == 0.0f) + { return guessForT; - } else { + } + else + { float aB = intervalStart + SampleStepSize; float currentX, currentT; int i = 0; - do { + do + { currentT = intervalStart + (aB - intervalStart) / 2.0f; currentX = calcBezier(currentT, _x1, _x2) - x; - if (currentX > 0.0f) { + if (currentX > 0.0f) + { aB = currentT; - } else { + } + else + { intervalStart = currentT; } } while (std::abs(currentX) > SubdivisionPrecision && ++i < SubdivisionMaxIterations); @@ -80,9 +97,11 @@ float CubicInterpolator::transform(float mix) const { return calcBezier(getT(mix), y1(), y2()); } -StatusCode CubicInterpolator::import(ImportStack& importStack) { +StatusCode CubicInterpolator::import(ImportStack& importStack) +{ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey); - if (artboardImporter == nullptr) { + if (artboardImporter == nullptr) + { return StatusCode::MissingObject; } artboardImporter->addComponent(this);
diff --git a/src/animation/keyed_object.cpp b/src/animation/keyed_object.cpp index 7f04749..6866579 100644 --- a/src/animation/keyed_object.cpp +++ b/src/animation/keyed_object.cpp
@@ -9,45 +9,57 @@ KeyedObject::KeyedObject() {} KeyedObject::~KeyedObject() {} -void KeyedObject::addKeyedProperty(std::unique_ptr<KeyedProperty> property) { +void KeyedObject::addKeyedProperty(std::unique_ptr<KeyedProperty> property) +{ m_KeyedProperties.push_back(std::move(property)); } -StatusCode KeyedObject::onAddedDirty(CoreContext* context) { +StatusCode KeyedObject::onAddedDirty(CoreContext* context) +{ // Make sure we're keying a valid object. - if (context->resolve(objectId()) == nullptr) { + if (context->resolve(objectId()) == nullptr) + { return StatusCode::MissingObject; } - for (auto& property : m_KeyedProperties) { + for (auto& property : m_KeyedProperties) + { StatusCode code; - if ((code = property->onAddedDirty(context)) != StatusCode::Ok) { + if ((code = property->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode KeyedObject::onAddedClean(CoreContext* context) { - for (auto& property : m_KeyedProperties) { +StatusCode KeyedObject::onAddedClean(CoreContext* context) +{ + for (auto& property : m_KeyedProperties) + { property->onAddedClean(context); } return StatusCode::Ok; } -void KeyedObject::apply(Artboard* artboard, float time, float mix) { +void KeyedObject::apply(Artboard* artboard, float time, float mix) +{ Core* object = artboard->resolve(objectId()); - if (object == nullptr) { + if (object == nullptr) + { return; } - for (auto& property : m_KeyedProperties) { + for (auto& property : m_KeyedProperties) + { property->apply(object, time, mix); } } -StatusCode KeyedObject::import(ImportStack& importStack) { +StatusCode KeyedObject::import(ImportStack& importStack) +{ auto importer = importStack.latest<LinearAnimationImporter>(LinearAnimationBase::typeKey); - if (importer == nullptr) { + if (importer == nullptr) + { return StatusCode::MissingObject; } // we transfer ownership of ourself to the importer!
diff --git a/src/animation/keyed_property.cpp b/src/animation/keyed_property.cpp index d952451..8aa58d5 100644 --- a/src/animation/keyed_property.cpp +++ b/src/animation/keyed_property.cpp
@@ -9,11 +9,13 @@ KeyedProperty::KeyedProperty() {} KeyedProperty::~KeyedProperty() {} -void KeyedProperty::addKeyFrame(std::unique_ptr<KeyFrame> keyframe) { +void KeyedProperty::addKeyFrame(std::unique_ptr<KeyFrame> keyframe) +{ m_KeyFrames.push_back(std::move(keyframe)); } -void KeyedProperty::apply(Core* object, float seconds, float mix) { +void KeyedProperty::apply(Core* object, float seconds, float mix) +{ assert(!m_KeyFrames.empty()); int idx = 0; @@ -22,14 +24,20 @@ int start = 0; auto numKeyFrames = static_cast<int>(m_KeyFrames.size()); int end = numKeyFrames - 1; - while (start <= end) { + while (start <= end) + { mid = (start + end) >> 1; closestSeconds = m_KeyFrames[mid]->seconds(); - if (closestSeconds < seconds) { + if (closestSeconds < seconds) + { start = mid + 1; - } else if (closestSeconds > seconds) { + } + else if (closestSeconds > seconds) + { end = mid - 1; - } else { + } + else + { idx = start = mid; break; } @@ -37,50 +45,70 @@ } int pk = propertyKey(); - if (idx == 0) { + if (idx == 0) + { m_KeyFrames[0]->apply(object, pk, mix); - } else { - if (idx < numKeyFrames) { + } + else + { + if (idx < numKeyFrames) + { KeyFrame* fromFrame = m_KeyFrames[idx - 1].get(); KeyFrame* toFrame = m_KeyFrames[idx].get(); - if (seconds == toFrame->seconds()) { + if (seconds == toFrame->seconds()) + { toFrame->apply(object, pk, mix); - } else { - if (fromFrame->interpolationType() == 0) { + } + else + { + if (fromFrame->interpolationType() == 0) + { fromFrame->apply(object, pk, mix); - } else { + } + else + { fromFrame->applyInterpolation(object, pk, seconds, toFrame, mix); } } - } else { + } + else + { m_KeyFrames[idx - 1]->apply(object, pk, mix); } } } -StatusCode KeyedProperty::onAddedDirty(CoreContext* context) { +StatusCode KeyedProperty::onAddedDirty(CoreContext* context) +{ StatusCode code; - for (auto& keyframe : m_KeyFrames) { - if ((code = keyframe->onAddedDirty(context)) != StatusCode::Ok) { + for (auto& keyframe : m_KeyFrames) + { + if ((code = keyframe->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode KeyedProperty::onAddedClean(CoreContext* context) { +StatusCode KeyedProperty::onAddedClean(CoreContext* context) +{ StatusCode code; - for (auto& keyframe : m_KeyFrames) { - if ((code = keyframe->onAddedClean(context)) != StatusCode::Ok) { + for (auto& keyframe : m_KeyFrames) + { + if ((code = keyframe->onAddedClean(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode KeyedProperty::import(ImportStack& importStack) { +StatusCode KeyedProperty::import(ImportStack& importStack) +{ auto importer = importStack.latest<KeyedObjectImporter>(KeyedObjectBase::typeKey); - if (importer == nullptr) { + if (importer == nullptr) + { return StatusCode::MissingObject; } importer->addKeyedProperty(std::unique_ptr<KeyedProperty>(this));
diff --git a/src/animation/keyframe.cpp b/src/animation/keyframe.cpp index c0eaf9a..671beb8 100644 --- a/src/animation/keyframe.cpp +++ b/src/animation/keyframe.cpp
@@ -7,10 +7,13 @@ using namespace rive; -StatusCode KeyFrame::onAddedDirty(CoreContext* context) { - if (interpolatorId() != -1) { +StatusCode KeyFrame::onAddedDirty(CoreContext* context) +{ + if (interpolatorId() != -1) + { auto coreObject = context->resolve(interpolatorId()); - if (coreObject == nullptr || !coreObject->is<CubicInterpolator>()) { + if (coreObject == nullptr || !coreObject->is<CubicInterpolator>()) + { return StatusCode::MissingObject; } m_Interpolator = coreObject->as<CubicInterpolator>(); @@ -21,9 +24,11 @@ void KeyFrame::computeSeconds(int fps) { m_Seconds = frame() / (float)fps; } -StatusCode KeyFrame::import(ImportStack& importStack) { +StatusCode KeyFrame::import(ImportStack& importStack) +{ auto importer = importStack.latest<KeyedPropertyImporter>(KeyedProperty::typeKey); - if (importer == nullptr) { + if (importer == nullptr) + { return StatusCode::MissingObject; } importer->addKeyFrame(std::unique_ptr<KeyFrame>(this));
diff --git a/src/animation/keyframe_bool.cpp b/src/animation/keyframe_bool.cpp index a7eba61..401a655 100644 --- a/src/animation/keyframe_bool.cpp +++ b/src/animation/keyframe_bool.cpp
@@ -3,7 +3,8 @@ using namespace rive; -void KeyFrameBool::apply(Core* object, int propertyKey, float mix) { +void KeyFrameBool::apply(Core* object, int propertyKey, float mix) +{ CoreRegistry::setBool(object, propertyKey, value()); } @@ -11,6 +12,7 @@ int propertyKey, float currentTime, const KeyFrame* nextFrame, - float mix) { + 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 a8feea2..b9788c9 100644 --- a/src/animation/keyframe_color.cpp +++ b/src/animation/keyframe_color.cpp
@@ -4,16 +4,21 @@ using namespace rive; -static void applyColor(Core* object, int propertyKey, float mix, int value) { - if (mix == 1.0f) { +static void applyColor(Core* object, int propertyKey, float mix, int value) +{ + if (mix == 1.0f) + { CoreRegistry::setColor(object, propertyKey, value); - } else { + } + else + { auto mixedColor = colorLerp(CoreRegistry::getColor(object, propertyKey), value, mix); CoreRegistry::setColor(object, propertyKey, mixedColor); } } -void KeyFrameColor::apply(Core* object, int propertyKey, float mix) { +void KeyFrameColor::apply(Core* object, int propertyKey, float mix) +{ applyColor(object, propertyKey, mix, value()); } @@ -21,12 +26,14 @@ int propertyKey, float currentTime, const KeyFrame* nextFrame, - float mix) { + float mix) +{ auto kfc = nextFrame->as<KeyFrameColor>(); const KeyFrameColor& nextColor = *kfc; float f = (currentTime - seconds()) / (nextColor.seconds() - seconds()); - if (CubicInterpolator* cubic = interpolator()) { + if (CubicInterpolator* cubic = interpolator()) + { f = cubic->transform(f); }
diff --git a/src/animation/keyframe_double.cpp b/src/animation/keyframe_double.cpp index efefdc2..d6f63c2 100644 --- a/src/animation/keyframe_double.cpp +++ b/src/animation/keyframe_double.cpp
@@ -8,10 +8,14 @@ // floating point numbers suffice. So even though this is a "double keyframe" to // match editor names, the actual values are stored and applied in 32 bits. -static void applyDouble(Core* object, int propertyKey, float mix, float value) { - if (mix == 1.0f) { +static void applyDouble(Core* object, int propertyKey, float mix, float value) +{ + if (mix == 1.0f) + { CoreRegistry::setDouble(object, propertyKey, value); - } else { + } + else + { float mixi = 1.0f - mix; CoreRegistry::setDouble(object, propertyKey, @@ -19,7 +23,8 @@ } } -void KeyFrameDouble::apply(Core* object, int propertyKey, float mix) { +void KeyFrameDouble::apply(Core* object, int propertyKey, float mix) +{ applyDouble(object, propertyKey, mix, value()); } @@ -27,12 +32,14 @@ int propertyKey, float currentTime, const KeyFrame* nextFrame, - float mix) { + float mix) +{ auto kfd = nextFrame->as<KeyFrameDouble>(); const KeyFrameDouble& nextDouble = *kfd; float f = (currentTime - seconds()) / (nextDouble.seconds() - seconds()); - if (CubicInterpolator* cubic = interpolator()) { + if (CubicInterpolator* cubic = interpolator()) + { f = cubic->transform(f); }
diff --git a/src/animation/keyframe_id.cpp b/src/animation/keyframe_id.cpp index 00be39a..dfa8fcc 100644 --- a/src/animation/keyframe_id.cpp +++ b/src/animation/keyframe_id.cpp
@@ -3,7 +3,8 @@ using namespace rive; -void KeyFrameId::apply(Core* object, int propertyKey, float mix) { +void KeyFrameId::apply(Core* object, int propertyKey, float mix) +{ CoreRegistry::setUint(object, propertyKey, value()); } @@ -11,6 +12,7 @@ int propertyKey, float currentTime, const KeyFrame* nextFrame, - float mix) { + 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 45c0e8c..ffce4ab 100644 --- a/src/animation/layer_state.cpp +++ b/src/animation/layer_state.cpp
@@ -8,36 +8,46 @@ using namespace rive; -LayerState::~LayerState() { - for (auto transition : m_Transitions) { +LayerState::~LayerState() +{ + for (auto transition : m_Transitions) + { delete transition; } } -StatusCode LayerState::onAddedDirty(CoreContext* context) { +StatusCode LayerState::onAddedDirty(CoreContext* context) +{ StatusCode code; - for (auto transition : m_Transitions) { - if ((code = transition->onAddedDirty(context)) != StatusCode::Ok) { + for (auto transition : m_Transitions) + { + if ((code = transition->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode LayerState::onAddedClean(CoreContext* context) { +StatusCode LayerState::onAddedClean(CoreContext* context) +{ StatusCode code; - for (auto transition : m_Transitions) { - if ((code = transition->onAddedClean(context)) != StatusCode::Ok) { + for (auto transition : m_Transitions) + { + if ((code = transition->onAddedClean(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode LayerState::import(ImportStack& importStack) { +StatusCode LayerState::import(ImportStack& importStack) +{ auto layerImporter = importStack.latest<StateMachineLayerImporter>(StateMachineLayerBase::typeKey); - if (layerImporter == nullptr) { + if (layerImporter == nullptr) + { return StatusCode::MissingObject; } layerImporter->addState(this); @@ -46,6 +56,7 @@ void LayerState::addTransition(StateTransition* transition) { m_Transitions.push_back(transition); } -std::unique_ptr<StateInstance> LayerState::makeInstance(ArtboardInstance* instance) const { +std::unique_ptr<StateInstance> LayerState::makeInstance(ArtboardInstance* instance) const +{ return std::make_unique<SystemStateInstance>(this, instance); } \ No newline at end of file
diff --git a/src/animation/linear_animation.cpp b/src/animation/linear_animation.cpp index b308664..f643c7a 100644 --- a/src/animation/linear_animation.cpp +++ b/src/animation/linear_animation.cpp
@@ -12,62 +12,79 @@ LinearAnimation::LinearAnimation() {} -LinearAnimation::~LinearAnimation() { +LinearAnimation::~LinearAnimation() +{ #ifdef TESTING deleteCount++; #endif } -StatusCode LinearAnimation::onAddedDirty(CoreContext* context) { +StatusCode LinearAnimation::onAddedDirty(CoreContext* context) +{ StatusCode code; - for (const auto& object : m_KeyedObjects) { - if ((code = object->onAddedDirty(context)) != StatusCode::Ok) { + for (const auto& object : m_KeyedObjects) + { + if ((code = object->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode LinearAnimation::onAddedClean(CoreContext* context) { +StatusCode LinearAnimation::onAddedClean(CoreContext* context) +{ StatusCode code; - for (const auto& object : m_KeyedObjects) { - if ((code = object->onAddedClean(context)) != StatusCode::Ok) { + for (const auto& object : m_KeyedObjects) + { + if ((code = object->onAddedClean(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -void LinearAnimation::addKeyedObject(std::unique_ptr<KeyedObject> object) { +void LinearAnimation::addKeyedObject(std::unique_ptr<KeyedObject> object) +{ m_KeyedObjects.push_back(std::move(object)); } -void LinearAnimation::apply(Artboard* artboard, float time, float mix) const { - for (const auto& object : m_KeyedObjects) { +void LinearAnimation::apply(Artboard* artboard, float time, float mix) const +{ + for (const auto& object : m_KeyedObjects) + { object->apply(artboard, time, mix); } } -StatusCode LinearAnimation::import(ImportStack& importStack) { +StatusCode LinearAnimation::import(ImportStack& importStack) +{ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey); - if (artboardImporter == nullptr) { + if (artboardImporter == nullptr) + { return StatusCode::MissingObject; } artboardImporter->addAnimation(this); return Super::import(importStack); } -float LinearAnimation::startSeconds() const { +float LinearAnimation::startSeconds() const +{ return (enableWorkArea() ? workStart() : 0) / (float)fps(); } -float LinearAnimation::endSeconds() const { +float LinearAnimation::endSeconds() const +{ return (enableWorkArea() ? workEnd() : duration()) / (float)fps(); } float LinearAnimation::durationSeconds() const { return endSeconds() - startSeconds(); } -float LinearAnimation::globalToLocalSeconds(float seconds) const { - switch (loop()) { - case Loop::oneShot: return seconds + 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(); case Loop::pingPong:
diff --git a/src/animation/linear_animation_instance.cpp b/src/animation/linear_animation_instance.cpp index 51b0caf..3a7b1c5 100644 --- a/src/animation/linear_animation_instance.cpp +++ b/src/animation/linear_animation_instance.cpp
@@ -14,7 +14,8 @@ m_TotalTime(0.0f), m_LastTotalTime(0.0f), m_SpilledTime(0.0f), - m_Direction(1) { + m_Direction(1) +{ Counter::update(Counter::kLinearAnimationInstance, +1); } @@ -27,22 +28,26 @@ m_SpilledTime(lhs.m_SpilledTime), m_Direction(lhs.m_Direction), m_DidLoop(lhs.m_DidLoop), - m_LoopValue(lhs.m_LoopValue) { + m_LoopValue(lhs.m_LoopValue) +{ Counter::update(Counter::kLinearAnimationInstance, +1); } -LinearAnimationInstance::~LinearAnimationInstance() { +LinearAnimationInstance::~LinearAnimationInstance() +{ Counter::update(Counter::kLinearAnimationInstance, -1); } -bool LinearAnimationInstance::advanceAndApply(float seconds) { +bool LinearAnimationInstance::advanceAndApply(float seconds) +{ bool more = this->advance(seconds); this->apply(); m_ArtboardInstance->advance(seconds); return more; } -bool LinearAnimationInstance::advance(float elapsedSeconds) { +bool LinearAnimationInstance::advance(float elapsedSeconds) +{ const LinearAnimation& animation = *m_Animation; m_Time += elapsedSeconds * animation.speed() * m_Direction; m_LastTotalTime = m_TotalTime; @@ -60,15 +65,19 @@ bool didLoop = false; m_SpilledTime = 0.0f; - switch (loop()) { + switch (loop()) + { case Loop::oneShot: - if (m_Direction == 1 && frames > end) { + if (m_Direction == 1 && frames > end) + { keepGoing = false; m_SpilledTime = (frames - end) / fps; frames = (float)end; m_Time = frames / fps; didLoop = true; - } else if (m_Direction == -1 && frames < start) { + } + else if (m_Direction == -1 && frames < start) + { keepGoing = false; m_SpilledTime = (start - frames) / fps; frames = (float)start; @@ -77,14 +86,17 @@ } break; case Loop::loop: - if (m_Direction == 1 && frames >= end) { + if (m_Direction == 1 && frames >= end) + { m_SpilledTime = (frames - end) / fps; frames = m_Time * fps; frames = start + std::fmod(frames - start, (float)range); m_Time = frames / fps; didLoop = true; - } else if (m_Direction == -1 && frames <= start) { + } + else if (m_Direction == -1 && frames <= start) + { m_SpilledTime = (start - frames) / fps; frames = m_Time * fps; @@ -94,20 +106,26 @@ } break; case Loop::pingPong: - while (true) { - if (m_Direction == 1 && frames >= end) { + while (true) + { + if (m_Direction == 1 && frames >= end) + { m_SpilledTime = (frames - end) / fps; m_Direction = -1; frames = end + (end - frames); m_Time = frames / fps; didLoop = true; - } else if (m_Direction == -1 && frames < start) { + } + else if (m_Direction == -1 && frames < start) + { m_SpilledTime = (start - frames) / fps; m_Direction = 1; frames = start + (start - frames); m_Time = frames / fps; didLoop = true; - } else { + } + else + { // we're within the range, we can stop fixing. We do this in // a loop to fix conditions when time has advanced so far // that we've ping-ponged back and forth a few times in a @@ -123,8 +141,10 @@ return keepGoing; } -void LinearAnimationInstance::time(float value) { - if (m_Time == value) { +void LinearAnimationInstance::time(float value) +{ + if (m_Time == value) + { return; } m_Time = value; @@ -151,24 +171,30 @@ std::string LinearAnimationInstance::name() const { return m_Animation->name(); } -bool LinearAnimationInstance::isTranslucent() const { +bool LinearAnimationInstance::isTranslucent() const +{ return m_ArtboardInstance->isTranslucent(this); } // Returns either the animation's default or overridden loop values -int LinearAnimationInstance::loopValue() const { - if (m_LoopValue != -1) { +int LinearAnimationInstance::loopValue() const +{ + if (m_LoopValue != -1) + { return m_LoopValue; } return m_Animation->loopValue(); } // Override the animation's loop value -void LinearAnimationInstance::loopValue(int value) { - if (m_LoopValue == value) { +void LinearAnimationInstance::loopValue(int value) +{ + if (m_LoopValue == value) + { return; } - if (m_LoopValue == -1 && m_Animation->loopValue() == value) { + if (m_LoopValue == -1 && m_Animation->loopValue() == value) + { return; } m_LoopValue = value;
diff --git a/src/animation/listener_action.cpp b/src/animation/listener_action.cpp index cf0dbc3..b67fa2d 100644 --- a/src/animation/listener_action.cpp +++ b/src/animation/listener_action.cpp
@@ -7,10 +7,12 @@ using namespace rive; -StatusCode ListenerAction::import(ImportStack& importStack) { +StatusCode ListenerAction::import(ImportStack& importStack) +{ auto stateMachineListenerImporter = importStack.latest<StateMachineListenerImporter>(StateMachineListenerBase::typeKey); - if (stateMachineListenerImporter == nullptr) { + if (stateMachineListenerImporter == nullptr) + { return StatusCode::MissingObject; }
diff --git a/src/animation/listener_align_target.cpp b/src/animation/listener_align_target.cpp index 4317227..c0a573a 100644 --- a/src/animation/listener_align_target.cpp +++ b/src/animation/listener_align_target.cpp
@@ -5,16 +5,18 @@ using namespace rive; -void ListenerAlignTarget::perform(StateMachineInstance* stateMachineInstance, - Vec2D position) const { +void ListenerAlignTarget::perform(StateMachineInstance* stateMachineInstance, Vec2D position) const +{ auto coreTarget = stateMachineInstance->artboard()->resolve(targetId()); - if (coreTarget == nullptr || !coreTarget->is<Node>()) { + if (coreTarget == nullptr || !coreTarget->is<Node>()) + { return; } auto target = coreTarget->as<Node>(); Mat2D targetParentWorld = getParentWorld(*target); Mat2D inverse; - if (!targetParentWorld.invert(&inverse)) { + if (!targetParentWorld.invert(&inverse)) + { return; }
diff --git a/src/animation/listener_bool_change.cpp b/src/animation/listener_bool_change.cpp index 7c2d968..1fd24d8 100644 --- a/src/animation/listener_bool_change.cpp +++ b/src/animation/listener_bool_change.cpp
@@ -4,23 +4,33 @@ #include "rive/animation/state_machine_input_instance.hpp" using namespace rive; -bool ListenerBoolChange::validateInputType(const StateMachineInput* input) const { +bool ListenerBoolChange::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. return input == nullptr || input->is<StateMachineBool>(); } -void ListenerBoolChange::perform(StateMachineInstance* stateMachineInstance, Vec2D position) const { +void ListenerBoolChange::perform(StateMachineInstance* stateMachineInstance, Vec2D position) const +{ auto inputInstance = stateMachineInstance->input(inputId()); - if (inputInstance == nullptr) { + if (inputInstance == nullptr) + { return; } // If it's not null, it must be our correct type (why we validate at load time). auto boolInput = reinterpret_cast<SMIBool*>(inputInstance); - switch (value()) { - case 0: boolInput->value(false); break; - case 1: boolInput->value(true); break; - default: boolInput->value(!boolInput->value()); break; + switch (value()) + { + case 0: + boolInput->value(false); + break; + case 1: + boolInput->value(true); + break; + default: + boolInput->value(!boolInput->value()); + break; } } \ No newline at end of file
diff --git a/src/animation/listener_input_change.cpp b/src/animation/listener_input_change.cpp index 79c0489..c9307a0 100644 --- a/src/animation/listener_input_change.cpp +++ b/src/animation/listener_input_change.cpp
@@ -7,13 +7,16 @@ using namespace rive; -StatusCode ListenerInputChange::import(ImportStack& importStack) { +StatusCode ListenerInputChange::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey); - if (stateMachineImporter == nullptr) { + if (stateMachineImporter == nullptr) + { return StatusCode::MissingObject; } - if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) { + if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) + { return StatusCode::InvalidObject; } return Super::import(importStack);
diff --git a/src/animation/listener_number_change.cpp b/src/animation/listener_number_change.cpp index 91d9268..22ee975 100644 --- a/src/animation/listener_number_change.cpp +++ b/src/animation/listener_number_change.cpp
@@ -5,17 +5,19 @@ using namespace rive; -bool ListenerNumberChange::validateInputType(const StateMachineInput* input) const { +bool ListenerNumberChange::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. return input == nullptr || input->is<StateMachineNumber>(); } -void ListenerNumberChange::perform(StateMachineInstance* stateMachineInstance, - Vec2D position) const { +void ListenerNumberChange::perform(StateMachineInstance* stateMachineInstance, Vec2D position) const +{ auto inputInstance = stateMachineInstance->input(inputId()); - if (inputInstance == nullptr) { + if (inputInstance == nullptr) + { return; } // If it's not null, it must be our correct type (why we validate at load time).
diff --git a/src/animation/listener_trigger_change.cpp b/src/animation/listener_trigger_change.cpp index b601f04..5ad11bf 100644 --- a/src/animation/listener_trigger_change.cpp +++ b/src/animation/listener_trigger_change.cpp
@@ -5,7 +5,8 @@ using namespace rive; -bool ListenerTriggerChange::validateInputType(const StateMachineInput* input) const { +bool ListenerTriggerChange::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. @@ -13,9 +14,11 @@ } void ListenerTriggerChange::perform(StateMachineInstance* stateMachineInstance, - Vec2D position) const { + Vec2D position) const +{ auto inputInstance = stateMachineInstance->input(inputId()); - if (inputInstance == nullptr) { + if (inputInstance == nullptr) + { return; } // If it's not null, it must be our correct type (why we validate at load time).
diff --git a/src/animation/nested_animation.cpp b/src/animation/nested_animation.cpp index b1a26f0..7916e88 100644 --- a/src/animation/nested_animation.cpp +++ b/src/animation/nested_animation.cpp
@@ -4,10 +4,13 @@ using namespace rive; -StatusCode NestedAnimation::onAddedDirty(CoreContext* context) { +StatusCode NestedAnimation::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code == StatusCode::Ok) { - if (!parent()->is<NestedArtboard>()) { + if (code == StatusCode::Ok) + { + if (!parent()->is<NestedArtboard>()) + { return StatusCode::InvalidObject; } auto nestedArtboard = parent()->as<NestedArtboard>();
diff --git a/src/animation/nested_linear_animation.cpp b/src/animation/nested_linear_animation.cpp index ddc87db..069d276 100644 --- a/src/animation/nested_linear_animation.cpp +++ b/src/animation/nested_linear_animation.cpp
@@ -6,7 +6,8 @@ NestedLinearAnimation::NestedLinearAnimation() {} NestedLinearAnimation::~NestedLinearAnimation() {} -void NestedLinearAnimation::initializeAnimation(ArtboardInstance* artboard) { +void NestedLinearAnimation::initializeAnimation(ArtboardInstance* artboard) +{ m_AnimationInstance = std::make_unique<LinearAnimationInstance>(artboard->animation(animationId()), artboard); } \ No newline at end of file
diff --git a/src/animation/nested_remap_animation.cpp b/src/animation/nested_remap_animation.cpp index 2af1522..55d6b24 100644 --- a/src/animation/nested_remap_animation.cpp +++ b/src/animation/nested_remap_animation.cpp
@@ -3,20 +3,25 @@ using namespace rive; -void NestedRemapAnimation::timeChanged() { - if (m_AnimationInstance != nullptr) { +void NestedRemapAnimation::timeChanged() +{ + if (m_AnimationInstance != nullptr) + { m_AnimationInstance->time(m_AnimationInstance->animation()->globalToLocalSeconds( m_AnimationInstance->durationSeconds() * time())); } } -void NestedRemapAnimation::initializeAnimation(ArtboardInstance* artboard) { +void NestedRemapAnimation::initializeAnimation(ArtboardInstance* artboard) +{ Super::initializeAnimation(artboard); timeChanged(); } -void NestedRemapAnimation::advance(float elapsedSeconds) { - if (m_AnimationInstance != nullptr) { +void NestedRemapAnimation::advance(float elapsedSeconds) +{ + if (m_AnimationInstance != nullptr) + { m_AnimationInstance->apply(mix()); } } \ No newline at end of file
diff --git a/src/animation/nested_simple_animation.cpp b/src/animation/nested_simple_animation.cpp index 23e4ee0..50286d8 100644 --- a/src/animation/nested_simple_animation.cpp +++ b/src/animation/nested_simple_animation.cpp
@@ -3,9 +3,12 @@ using namespace rive; -void NestedSimpleAnimation::advance(float elapsedSeconds) { - if (m_AnimationInstance != nullptr) { - if (isPlaying()) { +void NestedSimpleAnimation::advance(float elapsedSeconds) +{ + if (m_AnimationInstance != nullptr) + { + if (isPlaying()) + { m_AnimationInstance->advance(elapsedSeconds * speed()); } m_AnimationInstance->apply(mix());
diff --git a/src/animation/nested_state_machine.cpp b/src/animation/nested_state_machine.cpp index c453867..8a2d1ca 100644 --- a/src/animation/nested_state_machine.cpp +++ b/src/animation/nested_state_machine.cpp
@@ -6,34 +6,44 @@ NestedStateMachine::NestedStateMachine() {} NestedStateMachine::~NestedStateMachine() {} -void NestedStateMachine::advance(float elapsedSeconds) { - if (m_StateMachineInstance != nullptr) { +void NestedStateMachine::advance(float elapsedSeconds) +{ + if (m_StateMachineInstance != nullptr) + { m_StateMachineInstance->advance(elapsedSeconds); } } -void NestedStateMachine::initializeAnimation(ArtboardInstance* artboard) { +void NestedStateMachine::initializeAnimation(ArtboardInstance* artboard) +{ m_StateMachineInstance = artboard->stateMachineAt(animationId()); } -StateMachineInstance* NestedStateMachine::stateMachineInstance() { +StateMachineInstance* NestedStateMachine::stateMachineInstance() +{ return m_StateMachineInstance.get(); } -void NestedStateMachine::pointerMove(Vec2D position) { - if (m_StateMachineInstance != nullptr) { +void NestedStateMachine::pointerMove(Vec2D position) +{ + if (m_StateMachineInstance != nullptr) + { m_StateMachineInstance->pointerMove(position); } } -void NestedStateMachine::pointerDown(Vec2D position) { - if (m_StateMachineInstance != nullptr) { +void NestedStateMachine::pointerDown(Vec2D position) +{ + if (m_StateMachineInstance != nullptr) + { m_StateMachineInstance->pointerDown(position); } } -void NestedStateMachine::pointerUp(Vec2D position) { - if (m_StateMachineInstance != nullptr) { +void NestedStateMachine::pointerUp(Vec2D position) +{ + if (m_StateMachineInstance != nullptr) + { m_StateMachineInstance->pointerUp(position); } } \ No newline at end of file
diff --git a/src/animation/state_machine.cpp b/src/animation/state_machine.cpp index 3d4a441..0450691 100644 --- a/src/animation/state_machine.cpp +++ b/src/animation/state_machine.cpp
@@ -11,101 +11,132 @@ StateMachine::~StateMachine() {} -StatusCode StateMachine::onAddedDirty(CoreContext* context) { +StatusCode StateMachine::onAddedDirty(CoreContext* context) +{ StatusCode code; - for (auto& object : m_Inputs) { - if ((code = object->onAddedDirty(context)) != StatusCode::Ok) { + for (auto& object : m_Inputs) + { + if ((code = object->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } - for (auto& object : m_Layers) { - if ((code = object->onAddedDirty(context)) != StatusCode::Ok) { + for (auto& object : m_Layers) + { + if ((code = object->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } - for (auto& object : m_Listeners) { - if ((code = object->onAddedDirty(context)) != StatusCode::Ok) { + for (auto& object : m_Listeners) + { + if ((code = object->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode StateMachine::onAddedClean(CoreContext* context) { +StatusCode StateMachine::onAddedClean(CoreContext* context) +{ StatusCode code; - for (auto& object : m_Inputs) { - if ((code = object->onAddedClean(context)) != StatusCode::Ok) { + for (auto& object : m_Inputs) + { + if ((code = object->onAddedClean(context)) != StatusCode::Ok) + { return code; } } - for (auto& object : m_Layers) { - if ((code = object->onAddedClean(context)) != StatusCode::Ok) { + for (auto& object : m_Layers) + { + if ((code = object->onAddedClean(context)) != StatusCode::Ok) + { return code; } } - for (auto& object : m_Listeners) { - if ((code = object->onAddedClean(context)) != StatusCode::Ok) { + for (auto& object : m_Listeners) + { + if ((code = object->onAddedClean(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode StateMachine::import(ImportStack& importStack) { +StatusCode StateMachine::import(ImportStack& importStack) +{ auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey); - if (artboardImporter == nullptr) { + if (artboardImporter == nullptr) + { return StatusCode::MissingObject; } artboardImporter->addStateMachine(this); return Super::import(importStack); } -void StateMachine::addLayer(std::unique_ptr<StateMachineLayer> layer) { +void StateMachine::addLayer(std::unique_ptr<StateMachineLayer> layer) +{ m_Layers.push_back(std::move(layer)); } -void StateMachine::addInput(std::unique_ptr<StateMachineInput> input) { +void StateMachine::addInput(std::unique_ptr<StateMachineInput> input) +{ m_Inputs.push_back(std::move(input)); } -void StateMachine::addListener(std::unique_ptr<StateMachineListener> listener) { +void StateMachine::addListener(std::unique_ptr<StateMachineListener> listener) +{ m_Listeners.push_back(std::move(listener)); } -const StateMachineInput* StateMachine::input(std::string name) const { - for (auto& input : m_Inputs) { - if (input->name() == name) { +const StateMachineInput* StateMachine::input(std::string name) const +{ + for (auto& input : m_Inputs) + { + if (input->name() == name) + { return input.get(); } } return nullptr; } -const StateMachineInput* StateMachine::input(size_t index) const { - if (index < m_Inputs.size()) { +const StateMachineInput* StateMachine::input(size_t index) const +{ + if (index < m_Inputs.size()) + { return m_Inputs[index].get(); } return nullptr; } -const StateMachineLayer* StateMachine::layer(std::string name) const { - for (auto& layer : m_Layers) { - if (layer->name() == name) { +const StateMachineLayer* StateMachine::layer(std::string name) const +{ + for (auto& layer : m_Layers) + { + if (layer->name() == name) + { return layer.get(); } } return nullptr; } -const StateMachineLayer* StateMachine::layer(size_t index) const { - if (index < m_Layers.size()) { +const StateMachineLayer* StateMachine::layer(size_t index) const +{ + if (index < m_Layers.size()) + { return m_Layers[index].get(); } return nullptr; } -const StateMachineListener* StateMachine::listener(size_t index) const { - if (index < m_Listeners.size()) { +const StateMachineListener* StateMachine::listener(size_t index) const +{ + if (index < m_Listeners.size()) + { return m_Listeners[index].get(); } return nullptr;
diff --git a/src/animation/state_machine_input.cpp b/src/animation/state_machine_input.cpp index 7d53c9c..981f717 100644 --- a/src/animation/state_machine_input.cpp +++ b/src/animation/state_machine_input.cpp
@@ -9,9 +9,11 @@ StatusCode StateMachineInput::onAddedClean(CoreContext* context) { return StatusCode::Ok; } -StatusCode StateMachineInput::import(ImportStack& importStack) { +StatusCode StateMachineInput::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey); - if (stateMachineImporter == nullptr) { + if (stateMachineImporter == nullptr) + { return StatusCode::MissingObject; } // WOW -- we're handing off ownership of this!
diff --git a/src/animation/state_machine_input_instance.cpp b/src/animation/state_machine_input_instance.cpp index b188d17..5c2fb33 100644 --- a/src/animation/state_machine_input_instance.cpp +++ b/src/animation/state_machine_input_instance.cpp
@@ -7,7 +7,8 @@ using namespace rive; SMIInput::SMIInput(const StateMachineInput* input, StateMachineInstance* machineInstance) : - m_MachineInstance(machineInstance), m_Input(input) {} + m_MachineInstance(machineInstance), m_Input(input) +{} uint16_t SMIInput::inputCoreType() const { return m_Input->coreType(); } @@ -18,10 +19,13 @@ // bool SMIBool::SMIBool(const StateMachineBool* input, StateMachineInstance* machineInstance) : - SMIInput(input, machineInstance), m_Value(input->value()) {} + SMIInput(input, machineInstance), m_Value(input->value()) +{} -void SMIBool::value(bool newValue) { - if (m_Value == newValue) { +void SMIBool::value(bool newValue) +{ + if (m_Value == newValue) + { return; } m_Value = newValue; @@ -30,10 +34,13 @@ // number SMINumber::SMINumber(const StateMachineNumber* input, StateMachineInstance* machineInstance) : - SMIInput(input, machineInstance), m_Value(input->value()) {} + SMIInput(input, machineInstance), m_Value(input->value()) +{} -void SMINumber::value(float newValue) { - if (m_Value == newValue) { +void SMINumber::value(float newValue) +{ + if (m_Value == newValue) + { return; } m_Value = newValue; @@ -42,10 +49,13 @@ // trigger SMITrigger::SMITrigger(const StateMachineTrigger* input, StateMachineInstance* machineInstance) : - SMIInput(input, machineInstance) {} + SMIInput(input, machineInstance) +{} -void SMITrigger::fire() { - if (m_Fired) { +void SMITrigger::fire() +{ + if (m_Fired) + { return; } m_Fired = true;
diff --git a/src/animation/state_machine_instance.cpp b/src/animation/state_machine_instance.cpp index 9f6d578..6ae9f34 100644 --- a/src/animation/state_machine_instance.cpp +++ b/src/animation/state_machine_instance.cpp
@@ -24,8 +24,10 @@ #include <unordered_map> using namespace rive; -namespace rive { -class StateMachineLayerInstance { +namespace rive +{ +class StateMachineLayerInstance +{ private: static const int maxIterations = 100; const StateMachineLayer* m_Layer = nullptr; @@ -52,13 +54,15 @@ float m_HoldTime = 0.0f; public: - ~StateMachineLayerInstance() { + ~StateMachineLayerInstance() + { delete m_AnyStateInstance; delete m_CurrentState; delete m_StateFrom; } - void init(const StateMachineLayer* layer, ArtboardInstance* instance) { + void init(const StateMachineLayer* layer, ArtboardInstance* instance) + { m_ArtboardInstance = instance; assert(m_Layer == nullptr); m_AnyStateInstance = layer->anyState()->makeInstance(instance).release(); @@ -66,35 +70,44 @@ changeState(m_Layer->entryState()); } - void updateMix(float seconds) { - if (m_Transition != nullptr && m_StateFrom != nullptr && m_Transition->duration() != 0) { + void updateMix(float seconds) + { + 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())))); - } else { + } + else + { m_Mix = 1.0f; } } - bool advance(/*Artboard* artboard, */ float seconds, Span<SMIInput*> inputs) { + bool advance(/*Artboard* artboard, */ float seconds, Span<SMIInput*> inputs) + { m_StateChangedOnAdvance = false; - if (m_CurrentState != nullptr) { + if (m_CurrentState != nullptr) + { m_CurrentState->advance(seconds, inputs); } 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); } - for (int i = 0; updateState(inputs, i != 0); i++) { + for (int i = 0; updateState(inputs, i != 0); i++) + { apply(); - if (i == maxIterations) { + if (i == maxIterations) + { fprintf(stderr, "StateMachine exceeded max iterations.\n"); return false; } @@ -106,29 +119,35 @@ (m_CurrentState != nullptr && m_CurrentState->keepGoing()); } - bool isTransitioning() { + bool isTransitioning() + { return m_Transition != nullptr && m_StateFrom != nullptr && m_Transition->duration() != 0 && m_Mix < 1.0f; } - bool updateState(Span<SMIInput*> inputs, bool ignoreTriggers) { + bool updateState(Span<SMIInput*> inputs, bool ignoreTriggers) + { // Don't allow changing state while a transition is taking place // (we're mixing one state onto another). - if (isTransitioning()) { + if (isTransitioning()) + { return false; } m_WaitingForExit = false; - if (tryChangeState(m_AnyStateInstance, inputs, ignoreTriggers)) { + if (tryChangeState(m_AnyStateInstance, inputs, ignoreTriggers)) + { return true; } return tryChangeState(m_CurrentState, inputs, ignoreTriggers); } - bool changeState(const LayerState* stateTo) { - if ((m_CurrentState == nullptr ? nullptr : m_CurrentState->state()) == stateTo) { + bool changeState(const LayerState* stateTo) + { + if ((m_CurrentState == nullptr ? nullptr : m_CurrentState->state()) == stateTo) + { return false; } m_CurrentState = @@ -138,20 +157,25 @@ bool tryChangeState(StateInstance* stateFromInstance, Span<SMIInput*> inputs, - bool ignoreTriggers) { - if (stateFromInstance == nullptr) { + 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())) { + if (allowed == AllowTransition::yes && changeState(transition->stateTo())) + { m_StateChangedOnAdvance = true; // state actually has changed m_Transition = transition; - if (m_StateFrom != m_AnyStateInstance) { + if (m_StateFrom != m_AnyStateInstance) + { // Old state from is done. delete m_StateFrom; } @@ -160,7 +184,8 @@ // 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 = @@ -172,7 +197,8 @@ m_MixFrom = m_Mix; // Keep mixing last animation that was mixed in. - if (m_Mix != 0.0f) { + if (m_Mix != 0.0f) + { m_HoldAnimationFrom = transition->pauseOnExit(); } if (m_StateFrom != nullptr && m_StateFrom->state()->is<AnimationState>() && @@ -188,35 +214,44 @@ updateMix(0.0f); m_WaitingForExit = false; return true; - } else if (allowed == AllowTransition::waitingForExit) { + } + else if (allowed == AllowTransition::waitingForExit) + { m_WaitingForExit = true; } } return false; } - void apply(/*Artboard* artboard*/) { - if (m_HoldAnimation != nullptr) { + void apply(/*Artboard* artboard*/) + { + if (m_HoldAnimation != nullptr) + { m_HoldAnimation->apply(m_ArtboardInstance, m_HoldTime, m_MixFrom); m_HoldAnimation = nullptr; } - if (m_StateFrom != nullptr && m_Mix < 1.0f) { + if (m_StateFrom != nullptr && m_Mix < 1.0f) + { m_StateFrom->apply(m_MixFrom); } - if (m_CurrentState != nullptr) { + if (m_CurrentState != nullptr) + { m_CurrentState->apply(m_Mix); } } bool stateChangedOnAdvance() const { return m_StateChangedOnAdvance; } - const LayerState* currentState() { + const LayerState* currentState() + { return m_CurrentState == nullptr ? nullptr : m_CurrentState->state(); } - const LinearAnimationInstance* currentAnimation() const { - if (m_CurrentState == nullptr || !m_CurrentState->state()->is<AnimationState>()) { + const LinearAnimationInstance* currentAnimation() const + { + if (m_CurrentState == nullptr || !m_CurrentState->state()->is<AnimationState>()) + { return nullptr; } return static_cast<AnimationStateInstance*>(m_CurrentState)->animationInstance(); @@ -226,7 +261,8 @@ /// Representation of a Shape from the Artboard Instance and all the listeners it /// triggers. Allows tracking hover and performing hit detection only once on /// shapes that trigger multiple listeners. -class HitShape { +class HitShape +{ private: Shape* m_Shape; @@ -238,8 +274,10 @@ }; } // namespace rive -void StateMachineInstance::updateListeners(Vec2D position, ListenerType hitType) { - if (m_ArtboardInstance->frameOrigin()) { +void StateMachineInstance::updateListeners(Vec2D position, ListenerType hitType) +{ + if (m_ArtboardInstance->frameOrigin()) + { position -= Vec2D(m_ArtboardInstance->originX() * m_ArtboardInstance->width(), m_ArtboardInstance->originY() * m_ArtboardInstance->height()); } @@ -251,7 +289,8 @@ position.y + hitRadius) .round(); - for (const auto& hitShape : m_HitShapes) { + for (const auto& hitShape : m_HitShapes) + { // TODO: quick reject. @@ -261,19 +300,25 @@ hitShape->isHovered = isOver; // iterate all listeners associated with this hit shape - for (auto listener : hitShape->listeners) { + for (auto listener : hitShape->listeners) + { // Always update hover states regardless of which specific listener type // we're trying to trigger. - if (hoverChange) { - if (isOver && listener->listenerType() == ListenerType::enter) { + if (hoverChange) + { + if (isOver && listener->listenerType() == ListenerType::enter) + { listener->performChanges(this, position); markNeedsAdvance(); - } else if (!isOver && listener->listenerType() == ListenerType::exit) { + } + else if (!isOver && listener->listenerType() == ListenerType::exit) + { listener->performChanges(this, position); markNeedsAdvance(); } } - if (isOver && hitType == listener->listenerType()) { + if (isOver && hitType == listener->listenerType()) + { listener->performChanges(this, position); markNeedsAdvance(); } @@ -284,51 +329,70 @@ // can be sorted by drawOrder so they can be iterated in one loop and early // out if any hit stops propagation (also require the ability to mark a hit // as able to stop propagation) - for (auto nestedArtboard : m_HitNestedArtboards) { + for (auto nestedArtboard : m_HitNestedArtboards) + { Vec2D nestedPosition; - if (!nestedArtboard->worldToLocal(position, &nestedPosition)) { + if (!nestedArtboard->worldToLocal(position, &nestedPosition)) + { // Mounted artboard isn't ready or has a 0 scale transform. continue; } - for (auto nestedAnimation : nestedArtboard->nestedAnimations()) { - if (nestedAnimation->is<NestedStateMachine>()) { + for (auto nestedAnimation : nestedArtboard->nestedAnimations()) + { + if (nestedAnimation->is<NestedStateMachine>()) + { auto nestedStateMachine = nestedAnimation->as<NestedStateMachine>(); - switch (hitType) { - case ListenerType::down: nestedStateMachine->pointerDown(nestedPosition); break; - case ListenerType::up: nestedStateMachine->pointerUp(nestedPosition); break; - case ListenerType::move: nestedStateMachine->pointerMove(nestedPosition); break; + switch (hitType) + { + case ListenerType::down: + nestedStateMachine->pointerDown(nestedPosition); + break; + case ListenerType::up: + nestedStateMachine->pointerUp(nestedPosition); + break; + case ListenerType::move: + nestedStateMachine->pointerMove(nestedPosition); + break; case ListenerType::enter: - case ListenerType::exit: break; + case ListenerType::exit: + break; } } } } } -void StateMachineInstance::pointerMove(Vec2D position) { +void StateMachineInstance::pointerMove(Vec2D position) +{ updateListeners(position, ListenerType::move); } -void StateMachineInstance::pointerDown(Vec2D position) { +void StateMachineInstance::pointerDown(Vec2D position) +{ updateListeners(position, ListenerType::down); } -void StateMachineInstance::pointerUp(Vec2D position) { +void StateMachineInstance::pointerUp(Vec2D position) +{ updateListeners(position, ListenerType::up); } StateMachineInstance::StateMachineInstance(const StateMachine* machine, ArtboardInstance* instance) : - Scene(instance), m_Machine(machine) { + Scene(instance), m_Machine(machine) +{ Counter::update(Counter::kStateMachineInstance, +1); const auto count = machine->inputCount(); m_InputInstances.resize(count); - for (size_t i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) + { auto input = machine->input(i); - if (input == nullptr) { + if (input == nullptr) + { continue; } - switch (input->coreType()) { + switch (input->coreType()) + { case StateMachineBool::typeKey: m_InputInstances[i] = new SMIBool(input->as<StateMachineBool>(), this); break; @@ -346,7 +410,8 @@ m_LayerCount = machine->layerCount(); m_Layers = new StateMachineLayerInstance[m_LayerCount]; - for (size_t i = 0; i < m_LayerCount; i++) { + for (size_t i = 0; i < m_LayerCount; i++) + { m_Layers[i].init(machine->layer(i), m_ArtboardInstance); } @@ -354,40 +419,52 @@ // representation (an object that stores all the listeners triggered by the // shape producing a listener). std::unordered_map<uint32_t, HitShape*> hitShapeLookup; - for (std::size_t i = 0; i < machine->listenerCount(); i++) { + for (std::size_t i = 0; i < machine->listenerCount(); i++) + { auto listener = machine->listener(i); // Iterate actual leaf hittable shapes tied to this listener and resolve // corresponding ones in the artboard instance. - for (auto id : listener->hitShapeIds()) { + for (auto id : listener->hitShapeIds()) + { HitShape* hitShape; auto itr = hitShapeLookup.find(id); - if (itr == hitShapeLookup.end()) { + if (itr == hitShapeLookup.end()) + { auto shape = m_ArtboardInstance->resolve(id); - if (shape != nullptr && shape->is<Shape>()) { + if (shape != nullptr && shape->is<Shape>()) + { auto hs = std::make_unique<HitShape>(shape->as<Shape>()); hitShapeLookup[id] = hitShape = hs.get(); m_HitShapes.push_back(std::move(hs)); - } else { + } + else + { // No object or not a shape... continue; } - } else { + } + else + { hitShape = itr->second; } hitShape->listeners.push_back(listener); } } - for (auto nestedArtboard : instance->nestedArtboards()) { - if (nestedArtboard->hasNestedStateMachines()) { + for (auto nestedArtboard : instance->nestedArtboards()) + { + if (nestedArtboard->hasNestedStateMachines()) + { m_HitNestedArtboards.push_back(nestedArtboard); } } } -StateMachineInstance::~StateMachineInstance() { - for (auto inst : m_InputInstances) { +StateMachineInstance::~StateMachineInstance() +{ + for (auto inst : m_InputInstances) + { delete inst; } delete[] m_Layers; @@ -395,22 +472,27 @@ Counter::update(Counter::kStateMachineInstance, -1); } -bool StateMachineInstance::advance(float seconds) { +bool StateMachineInstance::advance(float seconds) +{ m_NeedsAdvance = false; - for (size_t i = 0; i < m_LayerCount; i++) { - if (m_Layers[i].advance(seconds, m_InputInstances)) { + for (size_t i = 0; i < m_LayerCount; i++) + { + if (m_Layers[i].advance(seconds, m_InputInstances)) + { m_NeedsAdvance = true; } } - for (auto inst : m_InputInstances) { + for (auto inst : m_InputInstances) + { inst->advanced(); } return m_NeedsAdvance; } -bool StateMachineInstance::advanceAndApply(float seconds) { +bool StateMachineInstance::advanceAndApply(float seconds) +{ bool more = this->advance(seconds); m_ArtboardInstance->advance(seconds); return more; @@ -421,49 +503,64 @@ std::string StateMachineInstance::name() const { return m_Machine->name(); } -SMIInput* StateMachineInstance::input(size_t index) const { - if (index < m_InputInstances.size()) { +SMIInput* StateMachineInstance::input(size_t index) const +{ + if (index < m_InputInstances.size()) + { return m_InputInstances[index]; } return nullptr; } template <typename SMType, typename InstType> -InstType* StateMachineInstance::getNamedInput(const std::string& name) const { - for (const auto inst : m_InputInstances) { +InstType* StateMachineInstance::getNamedInput(const std::string& name) const +{ + for (const auto inst : m_InputInstances) + { auto input = inst->input(); - if (input->is<SMType>() && input->name() == name) { + if (input->is<SMType>() && input->name() == name) + { return static_cast<InstType*>(inst); } } return nullptr; } -SMIBool* StateMachineInstance::getBool(const std::string& name) const { +SMIBool* StateMachineInstance::getBool(const std::string& name) const +{ return getNamedInput<StateMachineBool, SMIBool>(name); } -SMINumber* StateMachineInstance::getNumber(const std::string& name) const { +SMINumber* StateMachineInstance::getNumber(const std::string& name) const +{ return getNamedInput<StateMachineNumber, SMINumber>(name); } -SMITrigger* StateMachineInstance::getTrigger(const std::string& name) const { +SMITrigger* StateMachineInstance::getTrigger(const std::string& name) const +{ return getNamedInput<StateMachineTrigger, SMITrigger>(name); } -size_t StateMachineInstance::stateChangedCount() const { +size_t StateMachineInstance::stateChangedCount() const +{ size_t count = 0; - for (size_t i = 0; i < m_LayerCount; i++) { - if (m_Layers[i].stateChangedOnAdvance()) { + for (size_t i = 0; i < m_LayerCount; i++) + { + if (m_Layers[i].stateChangedOnAdvance()) + { count++; } } 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()) { - if (count == index) { + for (size_t i = 0; i < m_LayerCount; i++) + { + if (m_Layers[i].stateChangedOnAdvance()) + { + if (count == index) + { return m_Layers[i].currentState(); } count++; @@ -472,21 +569,28 @@ return nullptr; } -size_t StateMachineInstance::currentAnimationCount() const { +size_t StateMachineInstance::currentAnimationCount() const +{ size_t count = 0; - for (size_t i = 0; i < m_LayerCount; i++) { - if (m_Layers[i].currentAnimation() != nullptr) { + for (size_t i = 0; i < m_LayerCount; i++) + { + if (m_Layers[i].currentAnimation() != nullptr) + { count++; } } 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) { - if (count == index) { + for (size_t i = 0; i < m_LayerCount; i++) + { + if (m_Layers[i].currentAnimation() != nullptr) + { + if (count == index) + { return m_Layers[i].currentAnimation(); } count++;
diff --git a/src/animation/state_machine_layer.cpp b/src/animation/state_machine_layer.cpp index 911ff4b..3aaec68 100644 --- a/src/animation/state_machine_layer.cpp +++ b/src/animation/state_machine_layer.cpp
@@ -8,25 +8,38 @@ using namespace rive; -StateMachineLayer::~StateMachineLayer() { - for (auto state : m_States) { +StateMachineLayer::~StateMachineLayer() +{ + for (auto state : m_States) + { delete state; } } -StatusCode StateMachineLayer::onAddedDirty(CoreContext* context) { +StatusCode StateMachineLayer::onAddedDirty(CoreContext* context) +{ StatusCode code; - for (auto state : m_States) { - if ((code = state->onAddedDirty(context)) != StatusCode::Ok) { + for (auto state : m_States) + { + if ((code = state->onAddedDirty(context)) != StatusCode::Ok) + { return code; } - switch (state->coreType()) { - case AnyState::typeKey: m_Any = state->as<AnyState>(); break; - case EntryState::typeKey: m_Entry = state->as<EntryState>(); break; - case ExitState::typeKey: m_Exit = state->as<ExitState>(); break; + switch (state->coreType()) + { + case AnyState::typeKey: + m_Any = state->as<AnyState>(); + break; + case EntryState::typeKey: + m_Entry = state->as<EntryState>(); + break; + case ExitState::typeKey: + m_Exit = state->as<ExitState>(); + break; } } - if (m_Any == nullptr || m_Entry == nullptr || m_Exit == nullptr) { + if (m_Any == nullptr || m_Entry == nullptr || m_Exit == nullptr) + { // The layer is corrupt, we must have all three of these states. return StatusCode::InvalidObject; } @@ -34,10 +47,13 @@ return StatusCode::Ok; } -StatusCode StateMachineLayer::onAddedClean(CoreContext* context) { +StatusCode StateMachineLayer::onAddedClean(CoreContext* context) +{ StatusCode code; - for (auto state : m_States) { - if ((code = state->onAddedClean(context)) != StatusCode::Ok) { + for (auto state : m_States) + { + if ((code = state->onAddedClean(context)) != StatusCode::Ok) + { return code; } } @@ -47,9 +63,11 @@ void StateMachineLayer::addState(LayerState* state) { m_States.push_back(state); } -StatusCode StateMachineLayer::import(ImportStack& importStack) { +StatusCode StateMachineLayer::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey); - if (stateMachineImporter == nullptr) { + if (stateMachineImporter == nullptr) + { return StatusCode::MissingObject; } // WOW -- we're handing off ownership of this!
diff --git a/src/animation/state_machine_listener.cpp b/src/animation/state_machine_listener.cpp index f5f7146..3e51892 100644 --- a/src/animation/state_machine_listener.cpp +++ b/src/animation/state_machine_listener.cpp
@@ -12,13 +12,16 @@ StateMachineListener::StateMachineListener() {} StateMachineListener::~StateMachineListener() {} -void StateMachineListener::addAction(std::unique_ptr<ListenerAction> action) { +void StateMachineListener::addAction(std::unique_ptr<ListenerAction> action) +{ m_Actions.push_back(std::move(action)); } -StatusCode StateMachineListener::import(ImportStack& importStack) { +StatusCode StateMachineListener::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey); - if (stateMachineImporter == nullptr) { + if (stateMachineImporter == nullptr) + { return StatusCode::MissingObject; } // Handing off ownership of this! @@ -26,31 +29,40 @@ return Super::import(importStack); } -const ListenerAction* StateMachineListener::action(size_t index) const { - if (index < m_Actions.size()) { +const ListenerAction* StateMachineListener::action(size_t index) const +{ + if (index < m_Actions.size()) + { return m_Actions[index].get(); } return nullptr; } -StatusCode StateMachineListener::onAddedClean(CoreContext* context) { +StatusCode StateMachineListener::onAddedClean(CoreContext* context) +{ auto artboard = static_cast<Artboard*>(context); auto target = artboard->resolve(targetId()); - for (auto core : artboard->objects()) { - if (core == nullptr) { + for (auto core : artboard->objects()) + { + if (core == nullptr) + { continue; } // Iterate artboard to find Shapes that are parented to the target - if (core->is<Shape>()) { + if (core->is<Shape>()) + { auto shape = core->as<Shape>(); for (ContainerComponent* component = shape; component != nullptr; - component = component->parent()) { - if (component == target) { + component = component->parent()) + { + if (component == target) + { auto index = artboard->idOf(shape); - if (index != 0) { + if (index != 0) + { m_HitShapesIds.push_back(index); } break; @@ -63,8 +75,10 @@ } void StateMachineListener::performChanges(StateMachineInstance* stateMachineInstance, - Vec2D position) const { - for (auto& action : m_Actions) { + Vec2D position) const +{ + for (auto& action : m_Actions) + { action->perform(stateMachineInstance, position); } } \ No newline at end of file
diff --git a/src/animation/state_transition.cpp b/src/animation/state_transition.cpp index a8a6f25..0de42e7 100644 --- a/src/animation/state_transition.cpp +++ b/src/animation/state_transition.cpp
@@ -12,66 +12,84 @@ using namespace rive; -StateTransition::~StateTransition() { - for (auto condition : m_Conditions) { +StateTransition::~StateTransition() +{ + for (auto condition : m_Conditions) + { delete condition; } } -StatusCode StateTransition::onAddedDirty(CoreContext* context) { +StatusCode StateTransition::onAddedDirty(CoreContext* context) +{ StatusCode code; - for (auto condition : m_Conditions) { - if ((code = condition->onAddedDirty(context)) != StatusCode::Ok) { + for (auto condition : m_Conditions) + { + if ((code = condition->onAddedDirty(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode StateTransition::onAddedClean(CoreContext* context) { +StatusCode StateTransition::onAddedClean(CoreContext* context) +{ StatusCode code; - for (auto condition : m_Conditions) { - if ((code = condition->onAddedClean(context)) != StatusCode::Ok) { + for (auto condition : m_Conditions) + { + if ((code = condition->onAddedClean(context)) != StatusCode::Ok) + { return code; } } return StatusCode::Ok; } -StatusCode StateTransition::import(ImportStack& importStack) { +StatusCode StateTransition::import(ImportStack& importStack) +{ auto stateImporter = importStack.latest<LayerStateImporter>(LayerState::typeKey); - if (stateImporter == nullptr) { + if (stateImporter == nullptr) + { return StatusCode::MissingObject; } stateImporter->addTransition(this); return Super::import(importStack); } -void StateTransition::addCondition(TransitionCondition* condition) { +void StateTransition::addCondition(TransitionCondition* condition) +{ m_Conditions.push_back(condition); } -float StateTransition::mixTime(const LayerState* stateFrom) const { - if (duration() == 0) { +float StateTransition::mixTime(const LayerState* stateFrom) const +{ + if (duration() == 0) + { return 0; } if ((transitionFlags() & StateTransitionFlags::DurationIsPercentage) == StateTransitionFlags::DurationIsPercentage) { float animationDuration = 0.0f; - if (stateFrom->is<AnimationState>()) { + if (stateFrom->is<AnimationState>()) + { auto animation = stateFrom->as<AnimationState>()->animation(); - if (animation != nullptr) { + if (animation != nullptr) + { animationDuration = animation->durationSeconds(); } } return duration() / 100.0f * animationDuration; - } else { + } + else + { return duration() / 1000.0f; } } -float StateTransition::exitTimeSeconds(const LayerState* stateFrom, bool absolute) const { +float StateTransition::exitTimeSeconds(const LayerState* stateFrom, bool absolute) const +{ if ((transitionFlags() & StateTransitionFlags::ExitTimeIsPercentage) == StateTransitionFlags::ExitTimeIsPercentage) { @@ -79,7 +97,8 @@ float start = 0.0f; auto exitAnimation = exitTimeAnimation(stateFrom); - if (exitAnimation != nullptr) { + if (exitAnimation != nullptr) + { start = absolute ? exitAnimation->startSeconds() : 0.0f; animationDuration = exitAnimation->durationSeconds(); } @@ -90,37 +109,45 @@ } const LinearAnimationInstance* -StateTransition::exitTimeAnimationInstance(const StateInstance* from) const { +StateTransition::exitTimeAnimationInstance(const StateInstance* from) const +{ return from != nullptr && from->state()->is<AnimationState>() ? static_cast<const AnimationStateInstance*>(from)->animationInstance() : nullptr; } -const LinearAnimation* StateTransition::exitTimeAnimation(const LayerState* from) const { +const LinearAnimation* StateTransition::exitTimeAnimation(const LayerState* from) const +{ return from != nullptr && from->is<AnimationState>() ? from->as<AnimationState>()->animation() : nullptr; } AllowTransition StateTransition::allowed(StateInstance* stateFrom, Span<SMIInput*> inputs, - bool ignoreTriggers) const { - if (isDisabled()) { + bool ignoreTriggers) const +{ + if (isDisabled()) + { return AllowTransition::no; } - for (auto condition : m_Conditions) { + for (auto condition : m_Conditions) + { // N.B. state machine instance sanitizes these for us... auto input = inputs[condition->inputId()]; if ((ignoreTriggers && condition->is<TransitionTriggerCondition>()) || - !condition->evaluate(input)) { + !condition->evaluate(input)) + { return AllowTransition::no; } } - if (enableExitTime()) { + if (enableExitTime()) + { auto exitAnimation = exitTimeAnimationInstance(stateFrom); - if (exitAnimation != nullptr) { + if (exitAnimation != nullptr) + { // Exit time is specified in a value less than a single loop, so we // want to allow exiting regardless of which loop we're on. To do // that we bring the exit time up to the loop our lastTime is at. @@ -143,12 +170,14 @@ // .... 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; } - if (time < exitTime) { + if (time < exitTime) + { return AllowTransition::waitingForExit; } } @@ -156,11 +185,13 @@ return AllowTransition::yes; } -bool StateTransition::applyExitCondition(StateInstance* from) const { +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>()); - if (pauseOnExit() && useExitTime) { + if (pauseOnExit() && useExitTime) + { static_cast<AnimationStateInstance*>(from)->animationInstance()->time( exitTimeSeconds(from->state(), true)); return true;
diff --git a/src/animation/system_state_instance.cpp b/src/animation/system_state_instance.cpp index 3b6da97..88e6194 100644 --- a/src/animation/system_state_instance.cpp +++ b/src/animation/system_state_instance.cpp
@@ -2,7 +2,8 @@ using namespace rive; SystemStateInstance::SystemStateInstance(const LayerState* layerState, ArtboardInstance* instance) : - StateInstance(layerState) {} + StateInstance(layerState) +{} void SystemStateInstance::advance(float seconds, Span<SMIInput*>) {} void SystemStateInstance::apply(float mix) {}
diff --git a/src/animation/transition_bool_condition.cpp b/src/animation/transition_bool_condition.cpp index 34b1292..206c3b5 100644 --- a/src/animation/transition_bool_condition.cpp +++ b/src/animation/transition_bool_condition.cpp
@@ -5,15 +5,18 @@ 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. return input == nullptr || input->is<StateMachineBool>(); } -bool TransitionBoolCondition::evaluate(const SMIInput* inputInstance) const { - if (inputInstance == nullptr) { +bool TransitionBoolCondition::evaluate(const SMIInput* inputInstance) const +{ + if (inputInstance == nullptr) + { return true; } auto boolInput = reinterpret_cast<const SMIBool*>(inputInstance);
diff --git a/src/animation/transition_condition.cpp b/src/animation/transition_condition.cpp index 39d008e..23b0fe6 100644 --- a/src/animation/transition_condition.cpp +++ b/src/animation/transition_condition.cpp
@@ -10,22 +10,27 @@ StatusCode TransitionCondition::onAddedClean(CoreContext* context) { return StatusCode::Ok; } -StatusCode TransitionCondition::import(ImportStack& importStack) { +StatusCode TransitionCondition::import(ImportStack& importStack) +{ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey); - if (stateMachineImporter == nullptr) { + 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; } - 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); - if (transitionImporter == nullptr) { + if (transitionImporter == nullptr) + { return StatusCode::MissingObject; } transitionImporter->addCondition(this);
diff --git a/src/animation/transition_number_condition.cpp b/src/animation/transition_number_condition.cpp index 6a3aa87..7c64dc2 100644 --- a/src/animation/transition_number_condition.cpp +++ b/src/animation/transition_number_condition.cpp
@@ -5,26 +5,36 @@ 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. return input == nullptr || input->is<StateMachineNumber>(); } -bool TransitionNumberCondition::evaluate(const SMIInput* inputInstance) const { - if (inputInstance == nullptr) { +bool TransitionNumberCondition::evaluate(const SMIInput* inputInstance) const +{ + if (inputInstance == nullptr) + { return true; } auto numberInput = reinterpret_cast<const SMINumber*>(inputInstance); - switch (op()) { - case TransitionConditionOp::equal: return numberInput->value() == value(); - case TransitionConditionOp::notEqual: return numberInput->value() != value(); - case TransitionConditionOp::lessThanOrEqual: return numberInput->value() <= value(); - case TransitionConditionOp::lessThan: return numberInput->value() < value(); - case TransitionConditionOp::greaterThanOrEqual: return numberInput->value() >= value(); - case TransitionConditionOp::greaterThan: return numberInput->value() > value(); + switch (op()) + { + case TransitionConditionOp::equal: + return numberInput->value() == value(); + case TransitionConditionOp::notEqual: + return numberInput->value() != value(); + case TransitionConditionOp::lessThanOrEqual: + return numberInput->value() <= value(); + case TransitionConditionOp::lessThan: + return numberInput->value() < value(); + case TransitionConditionOp::greaterThanOrEqual: + return numberInput->value() >= value(); + case TransitionConditionOp::greaterThan: + return numberInput->value() > value(); } return false; } \ No newline at end of file
diff --git a/src/animation/transition_trigger_condition.cpp b/src/animation/transition_trigger_condition.cpp index b5e8524..601e4be 100644 --- a/src/animation/transition_trigger_condition.cpp +++ b/src/animation/transition_trigger_condition.cpp
@@ -5,20 +5,24 @@ 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. return input == nullptr || input->is<StateMachineTrigger>(); } -bool TransitionTriggerCondition::evaluate(const SMIInput* inputInstance) const { - if (inputInstance == nullptr) { +bool TransitionTriggerCondition::evaluate(const SMIInput* inputInstance) const +{ + if (inputInstance == nullptr) + { return true; } auto triggerInput = reinterpret_cast<const SMITrigger*>(inputInstance); - if (triggerInput->m_Fired) { + if (triggerInput->m_Fired) + { return true; } return false;
diff --git a/src/artboard.cpp b/src/artboard.cpp index 94026da..5de0d90 100644 --- a/src/artboard.cpp +++ b/src/artboard.cpp
@@ -22,10 +22,13 @@ using namespace rive; -Artboard::~Artboard() { - for (auto object : m_Objects) { +Artboard::~Artboard() +{ + for (auto object : m_Objects) + { // First object is artboard - if (object == this) { + if (object == this) + { continue; } delete object; @@ -35,22 +38,27 @@ // machines, so don't delete them here, they'll get cleaned up when the // source is deleted. // TODO: move this logic into ArtboardInstance destructor??? - if (!m_IsInstance) { - for (auto object : m_Animations) { + if (!m_IsInstance) + { + for (auto object : m_Animations) + { delete object; } - for (auto object : m_StateMachines) { + for (auto object : m_StateMachines) + { delete object; } } } -static bool canContinue(StatusCode code) { +static bool canContinue(StatusCode code) +{ // We currently only cease loading on invalid object. return code != StatusCode::InvalidObject; } -StatusCode Artboard::initialize() { +StatusCode Artboard::initialize() +{ StatusCode code; // these will be re-built in update() -- are they needed here? @@ -60,12 +68,15 @@ // onAddedDirty guarantees that all objects are now available so they can be // looked up by index/id. This is where nodes find their parents, but they // can't assume that their parent's parent will have resolved yet. - for (auto object : m_Objects) { - if (object == nullptr) { + for (auto object : m_Objects) + { + if (object == nullptr) + { // objects can be null if they were not understood by this runtime. continue; } - if (!canContinue(code = object->onAddedDirty(this))) { + if (!canContinue(code = object->onAddedDirty(this))) + { return code; } } @@ -75,15 +86,20 @@ // running this code for instances will effectively initialize them twice. This can lead to // unpredictable behaviour. One such example was that resolved objects like listener inputs were // being added to lists twice. - if (!isInstance()) { - for (auto object : m_Animations) { - if (!canContinue(code = object->onAddedDirty(this))) { + if (!isInstance()) + { + for (auto object : m_Animations) + { + if (!canContinue(code = object->onAddedDirty(this))) + { return code; } } - for (auto object : m_StateMachines) { - if (!canContinue(code = object->onAddedDirty(this))) { + for (auto object : m_StateMachines) + { + if (!canContinue(code = object->onAddedDirty(this))) + { return code; } } @@ -98,20 +114,28 @@ // assume that they have resolved too. This is where the whole hierarchy is // linked up and we can traverse it to find other references (my parent's // parent should be type X can be checked now). - for (auto object : m_Objects) { - if (object == nullptr) { + for (auto object : m_Objects) + { + if (object == nullptr) + { continue; } - if (!canContinue(code = object->onAddedClean(this))) { + if (!canContinue(code = object->onAddedClean(this))) + { return code; } - switch (object->coreType()) { - case DrawRulesBase::typeKey: { + switch (object->coreType()) + { + case DrawRulesBase::typeKey: + { DrawRules* rules = reinterpret_cast<DrawRules*>(object); Core* component = resolve(rules->parentId()); - if (component != nullptr) { + if (component != nullptr) + { componentDrawRules[component] = rules; - } else { + } + else + { fprintf(stderr, "Artboard::initialize - Draw rule targets missing " "component width id %d\n", @@ -125,15 +149,20 @@ } } - if (!isInstance()) { - for (auto object : m_Animations) { - if (!canContinue(code = object->onAddedClean(this))) { + if (!isInstance()) + { + for (auto object : m_Animations) + { + if (!canContinue(code = object->onAddedClean(this))) + { return code; } } - for (auto object : m_StateMachines) { - if (!canContinue(code = object->onAddedClean(this))) { + for (auto object : m_StateMachines) + { + if (!canContinue(code = object->onAddedClean(this))) + { return code; } } @@ -141,21 +170,27 @@ // Multi-level references have been built up, now we can // actually mark what's dependent on what. - for (auto object : m_Objects) { - if (object == nullptr) { + for (auto object : m_Objects) + { + if (object == nullptr) + { continue; } - if (object->is<Component>()) { + if (object->is<Component>()) + { object->as<Component>()->buildDependencies(); } - if (object->is<Drawable>()) { + if (object->is<Drawable>()) + { Drawable* drawable = object->as<Drawable>(); 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()) { + if (itr != componentDrawRules.end()) + { drawable->flattenedDrawRules = itr->second; break; } @@ -168,23 +203,30 @@ DrawTarget root; // Build up the draw order. Look for draw targets and build // their dependencies. - for (auto object : m_Objects) { - if (object == nullptr) { + for (auto object : m_Objects) + { + if (object == nullptr) + { continue; } - if (object->is<DrawTarget>()) { + if (object->is<DrawTarget>()) + { DrawTarget* target = object->as<DrawTarget>(); root.addDependent(target); auto dependentRules = target->drawable()->flattenedDrawRules; - if (dependentRules != nullptr) { + if (dependentRules != nullptr) + { // Because we don't store targets on rules, we need // to find the targets that belong to this rule // here. - for (auto object : m_Objects) { - if (object != nullptr && object->is<DrawTarget>()) { + for (auto object : m_Objects) + { + if (object != nullptr && object->is<DrawTarget>()) + { DrawTarget* dependentTarget = object->as<DrawTarget>(); - if (dependentTarget->parent() == dependentRules) { + if (dependentTarget->parent() == dependentRules) + { dependentTarget->addDependent(target); } } @@ -197,70 +239,92 @@ sorter.sort(&root, drawTargetOrder); auto itr = drawTargetOrder.begin(); itr++; - while (itr != drawTargetOrder.end()) { + while (itr != drawTargetOrder.end()) + { m_DrawTargets.push_back(reinterpret_cast<DrawTarget*>(*itr++)); } return StatusCode::Ok; } -void Artboard::sortDrawOrder() { - for (auto target : m_DrawTargets) { +void Artboard::sortDrawOrder() +{ + for (auto target : m_DrawTargets) + { target->first = target->last = nullptr; } m_FirstDrawable = nullptr; Drawable* lastDrawable = nullptr; - for (auto drawable : m_Drawables) { + for (auto drawable : m_Drawables) + { auto rules = drawable->flattenedDrawRules; - if (rules != nullptr && rules->activeTarget() != nullptr) { + if (rules != nullptr && rules->activeTarget() != nullptr) + { auto target = rules->activeTarget(); - if (target->first == nullptr) { + if (target->first == nullptr) + { target->first = target->last = drawable; drawable->prev = drawable->next = nullptr; - } else { + } + else + { target->last->next = drawable; drawable->prev = target->last; target->last = drawable; drawable->next = nullptr; } - } else { + } + else + { drawable->prev = lastDrawable; drawable->next = nullptr; - if (lastDrawable == nullptr) { + if (lastDrawable == nullptr) + { lastDrawable = m_FirstDrawable = drawable; - } else { + } + else + { lastDrawable->next = drawable; lastDrawable = drawable; } } } - for (auto rule : m_DrawTargets) { - if (rule->first == nullptr) { + for (auto rule : m_DrawTargets) + { + if (rule->first == nullptr) + { continue; } auto targetDrawable = rule->drawable(); - switch (rule->placement()) { - case DrawTargetPlacement::before: { - if (targetDrawable->prev != nullptr) { + switch (rule->placement()) + { + case DrawTargetPlacement::before: + { + if (targetDrawable->prev != nullptr) + { targetDrawable->prev->next = rule->first; rule->first->prev = targetDrawable->prev; } - if (targetDrawable == m_FirstDrawable) { + if (targetDrawable == m_FirstDrawable) + { m_FirstDrawable = rule->first; } targetDrawable->prev = rule->last; rule->last->next = targetDrawable; break; } - case DrawTargetPlacement::after: { - if (targetDrawable->next != nullptr) { + case DrawTargetPlacement::after: + { + if (targetDrawable->next != nullptr) + { targetDrawable->next->prev = rule->last; rule->last->next = targetDrawable->next; } - if (targetDrawable == lastDrawable) { + if (targetDrawable == lastDrawable) + { lastDrawable = rule->last; } targetDrawable->next = rule->first; @@ -273,11 +337,13 @@ m_FirstDrawable = lastDrawable; } -void Artboard::sortDependencies() { +void Artboard::sortDependencies() +{ DependencySorter sorter; sorter.sort(this, m_DependencyOrder); unsigned int graphOrder = 0; - for (auto component : m_DependencyOrder) { + for (auto component : m_DependencyOrder) + { component->m_GraphOrder = graphOrder++; } m_Dirt |= ComponentDirt::Components; @@ -289,50 +355,65 @@ void Artboard::addStateMachine(StateMachine* object) { m_StateMachines.push_back(object); } -void Artboard::addNestedArtboard(NestedArtboard* artboard) { +void Artboard::addNestedArtboard(NestedArtboard* artboard) +{ m_NestedArtboards.push_back(artboard); } -Core* Artboard::resolve(uint32_t id) const { - if (id >= static_cast<int>(m_Objects.size())) { +Core* Artboard::resolve(uint32_t id) const +{ + if (id >= static_cast<int>(m_Objects.size())) + { return nullptr; } return m_Objects[id]; } -uint32_t Artboard::idOf(Core* object) const { +uint32_t Artboard::idOf(Core* object) const +{ auto it = std::find(m_Objects.begin(), m_Objects.end(), object); - if (it != m_Objects.end()) { + if (it != m_Objects.end()) + { return castTo<uint32_t>(it - m_Objects.begin()); - } else { + } + else + { return 0; } } -void Artboard::onComponentDirty(Component* component) { +void Artboard::onComponentDirty(Component* component) +{ m_Dirt |= ComponentDirt::Components; /// If the order of the component is less than the current dirt /// depth, update the dirt depth so that the update loop can break /// out early and re-run (something up the tree is dirty). - if (component->graphOrder() < m_DirtDepth) { + if (component->graphOrder() < m_DirtDepth) + { m_DirtDepth = component->graphOrder(); } } void Artboard::onDirty(ComponentDirt dirt) { m_Dirt |= ComponentDirt::Components; } -void Artboard::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::DrawOrder)) { +void Artboard::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::DrawOrder)) + { sortDrawOrder(); } - if (hasDirt(value, ComponentDirt::Path)) { + if (hasDirt(value, ComponentDirt::Path)) + { AABB bg = {-width() * originX(), -height() * originY(), width(), height()}; AABB clip; - if (m_FrameOrigin) { + if (m_FrameOrigin) + { clip = {0.0f, 0.0f, width(), height()}; - } else { + } + else + { clip = bg; } m_ClipPath = factory()->makeRenderPath(clip); @@ -340,21 +421,26 @@ } } -bool Artboard::updateComponents() { - if (hasDirt(ComponentDirt::Components)) { +bool Artboard::updateComponents() +{ + if (hasDirt(ComponentDirt::Components)) + { const int maxSteps = 100; int step = 0; auto count = m_DependencyOrder.size(); - while (hasDirt(ComponentDirt::Components) && step < maxSteps) { + while (hasDirt(ComponentDirt::Components) && step < maxSteps) + { m_Dirt = m_Dirt & ~ComponentDirt::Components; // Track dirt depth here so that if something else marks // dirty, we restart. - for (unsigned int i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) + { auto component = m_DependencyOrder[i]; m_DirtDepth = i; auto d = component->m_Dirt; - if (d == ComponentDirt::None) { + if (d == ComponentDirt::None) + { continue; } component->m_Dirt = ComponentDirt::None; @@ -363,7 +449,8 @@ // If the update changed the dirt depth by adding dirt // to something before us (in the DAG), early out and // re-run the update. - if (m_DirtDepth < i) { + if (m_DirtDepth < i) + { // We put this in here just to know if we need to // keep this around... assert(false); @@ -377,35 +464,45 @@ return false; } -bool Artboard::advance(double elapsedSeconds) { - for (auto nestedArtboard : m_NestedArtboards) { +bool Artboard::advance(double elapsedSeconds) +{ + for (auto nestedArtboard : m_NestedArtboards) + { nestedArtboard->advance((float)elapsedSeconds); } return updateComponents(); } -Core* Artboard::hitTest(HitInfo* hinfo, const Mat2D* xform) { - if (clip()) { +Core* Artboard::hitTest(HitInfo* hinfo, const Mat2D* xform) +{ + if (clip()) + { // TODO: can we get the rawpath for the clip? } auto mx = xform ? *xform : Mat2D(); - if (m_FrameOrigin) { + if (m_FrameOrigin) + { mx *= Mat2D::fromTranslate(width() * originX(), height() * originY()); } Drawable* last = m_FirstDrawable; - if (last) { + if (last) + { // walk to the end, so we can visit in reverse-order - while (last->prev) { + while (last->prev) + { last = last->prev; } } - for (auto drawable = last; drawable; drawable = drawable->next) { - if (drawable->isHidden()) { + for (auto drawable = last; drawable; drawable = drawable->next) + { + if (drawable->isHidden()) + { continue; } - if (auto c = drawable->hitTest(hinfo, mx)) { + if (auto c = drawable->hitTest(hinfo, mx)) + { return c; } } @@ -415,28 +512,36 @@ return nullptr; } -void Artboard::draw(Renderer* renderer, DrawOption option) { +void Artboard::draw(Renderer* renderer, DrawOption option) +{ renderer->save(); - if (clip()) { + if (clip()) + { renderer->clipPath(m_ClipPath.get()); } - if (m_FrameOrigin) { + if (m_FrameOrigin) + { Mat2D artboardTransform; artboardTransform[4] = width() * originX(); artboardTransform[5] = height() * originY(); renderer->transform(artboardTransform); } - if (option != DrawOption::kHideBG) { - for (auto shapePaint : m_ShapePaints) { + if (option != DrawOption::kHideBG) + { + for (auto shapePaint : m_ShapePaints) + { shapePaint->draw(renderer, m_BackgroundPath.get()); } } - if (option != DrawOption::kHideFG) { - for (auto drawable = m_FirstDrawable; drawable != nullptr; drawable = drawable->prev) { - if (drawable->isHidden()) { + if (option != DrawOption::kHideFG) + { + for (auto drawable = m_FirstDrawable; drawable != nullptr; drawable = drawable->prev) + { + if (drawable->isHidden()) + { continue; } drawable->draw(renderer); @@ -448,13 +553,17 @@ AABB Artboard::bounds() const { return AABB(0.0f, 0.0f, width(), height()); } -bool Artboard::isTranslucent(const LinearAnimation* anim) const { +bool Artboard::isTranslucent(const LinearAnimation* anim) const +{ // For now we're conservative/lazy -- if we see that any of our paints are // animated we assume that might make it non-opaque, so we early out - for (const auto& obj : anim->m_KeyedObjects) { + for (const auto& obj : anim->m_KeyedObjects) + { const auto ptr = this->resolve(obj->objectId()); - for (const auto sp : m_ShapePaints) { - if (ptr == sp) { + for (const auto sp : m_ShapePaints) + { + if (ptr == sp) + { return true; } } @@ -463,69 +572,87 @@ // If we get here, we have no animations, so just check our paints for // opacity - for (const auto sp : m_ShapePaints) { - if (!sp->isTranslucent()) { + for (const auto sp : m_ShapePaints) + { + if (!sp->isTranslucent()) + { return false; // one opaque fill is sufficient to be opaque } } return true; } -bool Artboard::isTranslucent(const LinearAnimationInstance* inst) const { +bool Artboard::isTranslucent(const LinearAnimationInstance* inst) const +{ return this->isTranslucent(inst->animation()); } -std::string Artboard::animationNameAt(size_t index) const { +std::string Artboard::animationNameAt(size_t index) const +{ auto la = this->animation(index); return la ? la->name() : nullptr; } -std::string Artboard::stateMachineNameAt(size_t index) const { +std::string Artboard::stateMachineNameAt(size_t index) const +{ auto sm = this->stateMachine(index); return sm ? sm->name() : nullptr; } -LinearAnimation* Artboard::animation(const std::string& name) const { - for (auto animation : m_Animations) { - if (animation->name() == name) { +LinearAnimation* Artboard::animation(const std::string& name) const +{ + for (auto animation : m_Animations) + { + if (animation->name() == name) + { return animation; } } return nullptr; } -LinearAnimation* Artboard::animation(size_t index) const { - if (index >= m_Animations.size()) { +LinearAnimation* Artboard::animation(size_t index) const +{ + if (index >= m_Animations.size()) + { return nullptr; } return m_Animations[index]; } -StateMachine* Artboard::stateMachine(const std::string& name) const { - for (auto machine : m_StateMachines) { - if (machine->name() == name) { +StateMachine* Artboard::stateMachine(const std::string& name) const +{ + for (auto machine : m_StateMachines) + { + if (machine->name() == name) + { return machine; } } return nullptr; } -StateMachine* Artboard::stateMachine(size_t index) const { - if (index >= m_StateMachines.size()) { +StateMachine* Artboard::stateMachine(size_t index) const +{ + if (index >= m_StateMachines.size()) + { return nullptr; } return m_StateMachines[index]; } -int Artboard::defaultStateMachineIndex() const { +int Artboard::defaultStateMachineIndex() const +{ int index = defaultStateMachineId(); - if ((size_t)index >= m_StateMachines.size()) { + if ((size_t)index >= m_StateMachines.size()) + { index = -1; } return index; } -std::unique_ptr<ArtboardInstance> Artboard::instance() const { +std::unique_ptr<ArtboardInstance> Artboard::instance() const +{ std::unique_ptr<ArtboardInstance> artboardClone(new ArtboardInstance); artboardClone->copy(*this); @@ -536,23 +663,28 @@ std::vector<Core*>& cloneObjects = artboardClone->m_Objects; cloneObjects.push_back(artboardClone.get()); - if (!m_Objects.empty()) { + if (!m_Objects.empty()) + { // Skip first object (artboard). auto itr = m_Objects.begin(); - while (++itr != m_Objects.end()) { + while (++itr != m_Objects.end()) + { auto object = *itr; cloneObjects.push_back(object == nullptr ? nullptr : object->clone()); } } - for (auto animation : m_Animations) { + for (auto animation : m_Animations) + { artboardClone->m_Animations.push_back(animation); } - for (auto stateMachine : m_StateMachines) { + for (auto stateMachine : m_StateMachines) + { artboardClone->m_StateMachines.push_back(stateMachine); } - if (artboardClone->initialize() != StatusCode::Ok) { + if (artboardClone->initialize() != StatusCode::Ok) + { artboardClone = nullptr; } @@ -560,24 +692,31 @@ return artboardClone; } -void Artboard::frameOrigin(bool value) { - if (value == m_FrameOrigin) { +void Artboard::frameOrigin(bool value) +{ + if (value == m_FrameOrigin) + { return; } m_FrameOrigin = value; addDirt(ComponentDirt::Path); } -StatusCode Artboard::import(ImportStack& importStack) { +StatusCode Artboard::import(ImportStack& importStack) +{ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey); - if (backboardImporter == nullptr) { + if (backboardImporter == nullptr) + { return StatusCode::MissingObject; } StatusCode result = Super::import(importStack); - if (result == StatusCode::Ok) { + if (result == StatusCode::Ok) + { backboardImporter->addArtboard(this); - } else { + } + else + { backboardImporter->addMissingArtboard(); } return result; @@ -593,37 +732,45 @@ ArtboardInstance::~ArtboardInstance() { Counter::update(Counter::kArtboardInstance, -1); } -std::unique_ptr<LinearAnimationInstance> ArtboardInstance::animationAt(size_t index) { +std::unique_ptr<LinearAnimationInstance> ArtboardInstance::animationAt(size_t index) +{ auto la = this->animation(index); return la ? std::make_unique<LinearAnimationInstance>(la, this) : nullptr; } -std::unique_ptr<LinearAnimationInstance> ArtboardInstance::animationNamed(const std::string& name) { +std::unique_ptr<LinearAnimationInstance> ArtboardInstance::animationNamed(const std::string& name) +{ auto la = this->animation(name); return la ? std::make_unique<LinearAnimationInstance>(la, this) : nullptr; } -std::unique_ptr<StateMachineInstance> ArtboardInstance::stateMachineAt(size_t index) { +std::unique_ptr<StateMachineInstance> ArtboardInstance::stateMachineAt(size_t index) +{ auto sm = this->stateMachine(index); return sm ? std::make_unique<StateMachineInstance>(sm, this) : nullptr; } -std::unique_ptr<StateMachineInstance> ArtboardInstance::stateMachineNamed(const std::string& name) { +std::unique_ptr<StateMachineInstance> ArtboardInstance::stateMachineNamed(const std::string& name) +{ auto sm = this->stateMachine(name); return sm ? std::make_unique<StateMachineInstance>(sm, this) : nullptr; } -std::unique_ptr<StateMachineInstance> ArtboardInstance::defaultStateMachine() { +std::unique_ptr<StateMachineInstance> ArtboardInstance::defaultStateMachine() +{ const int index = this->defaultStateMachineIndex(); return index >= 0 ? this->stateMachineAt(index) : nullptr; } -std::unique_ptr<Scene> ArtboardInstance::defaultScene() { +std::unique_ptr<Scene> ArtboardInstance::defaultScene() +{ std::unique_ptr<Scene> scene = this->defaultStateMachine(); - if (!scene) { + if (!scene) + { scene = this->stateMachineAt(0); } - if (!scene) { + if (!scene) + { scene = this->animationAt(0); } return scene;
diff --git a/src/assets/file_asset.cpp b/src/assets/file_asset.cpp index cdf6bb6..65f3872 100644 --- a/src/assets/file_asset.cpp +++ b/src/assets/file_asset.cpp
@@ -4,9 +4,11 @@ using namespace rive; -StatusCode FileAsset::import(ImportStack& importStack) { +StatusCode FileAsset::import(ImportStack& importStack) +{ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey); - if (backboardImporter == nullptr) { + if (backboardImporter == nullptr) + { return StatusCode::MissingObject; } backboardImporter->addFileAsset(this); @@ -14,12 +16,14 @@ return Super::import(importStack); } -std::string FileAsset::uniqueFilename() { +std::string FileAsset::uniqueFilename() +{ // remove final extension std::string uniqueFilename = name(); std::size_t finalDot = uniqueFilename.rfind('.'); - if (finalDot != std::string::npos) { + if (finalDot != std::string::npos) + { uniqueFilename = uniqueFilename.substr(0, finalDot); } return uniqueFilename + "-" + std::to_string(assetId()) + "." + fileExtension();
diff --git a/src/assets/file_asset_contents.cpp b/src/assets/file_asset_contents.cpp index 84270a9..c1e869e 100644 --- a/src/assets/file_asset_contents.cpp +++ b/src/assets/file_asset_contents.cpp
@@ -5,9 +5,11 @@ using namespace rive; -StatusCode FileAssetContents::import(ImportStack& importStack) { +StatusCode FileAssetContents::import(ImportStack& importStack) +{ auto fileAssetImporter = importStack.latest<FileAssetImporter>(FileAsset::typeKey); - if (fileAssetImporter == nullptr) { + if (fileAssetImporter == nullptr) + { return StatusCode::MissingObject; } fileAssetImporter->loadContents(std::unique_ptr<FileAssetContents>(this)); @@ -15,11 +17,13 @@ return Super::import(importStack); } -void FileAssetContents::decodeBytes(Span<const uint8_t> value) { +void FileAssetContents::decodeBytes(Span<const uint8_t> value) +{ m_Bytes = std::vector<uint8_t>(value.begin(), value.end()); } -void FileAssetContents::copyBytes(const FileAssetContentsBase& object) { +void FileAssetContents::copyBytes(const FileAssetContentsBase& object) +{ // Should never be called. assert(false); }
diff --git a/src/assets/image_asset.cpp b/src/assets/image_asset.cpp index 1d07ef3..e34f4c7 100644 --- a/src/assets/image_asset.cpp +++ b/src/assets/image_asset.cpp
@@ -6,7 +6,8 @@ ImageAsset::~ImageAsset() {} -bool ImageAsset::decode(Span<const uint8_t> data, Factory* factory) { +bool ImageAsset::decode(Span<const uint8_t> data, Factory* factory) +{ #ifdef TESTING decodedByteSize = data.size(); #endif @@ -14,7 +15,8 @@ return m_RenderImage != nullptr; } -void ImageAsset::renderImage(std::unique_ptr<RenderImage> renderImage) { +void ImageAsset::renderImage(std::unique_ptr<RenderImage> renderImage) +{ m_RenderImage = std::move(renderImage); }
diff --git a/src/bones/bone.cpp b/src/bones/bone.cpp index 6265a2c..0cb0edc 100644 --- a/src/bones/bone.cpp +++ b/src/bones/bone.cpp
@@ -6,17 +6,21 @@ void Bone::addChildBone(Bone* bone) { m_ChildBones.push_back(bone); } -StatusCode Bone::onAddedClean(CoreContext* context) { +StatusCode Bone::onAddedClean(CoreContext* context) +{ Super::onAddedClean(context); - if (!parent()->is<Bone>()) { + if (!parent()->is<Bone>()) + { return StatusCode::MissingObject; } parent()->as<Bone>()->addChildBone(this); return StatusCode::Ok; } -void Bone::lengthChanged() { - for (auto bone : m_ChildBones) { +void Bone::lengthChanged() +{ + for (auto bone : m_ChildBones) + { bone->markTransformDirty(); } } @@ -27,7 +31,8 @@ Vec2D Bone::tipWorldTranslation() const { return worldTransform() * Vec2D(length(), 0); } -void Bone::addPeerConstraint(Constraint* peer) { +void Bone::addPeerConstraint(Constraint* peer) +{ assert(std::find(m_PeerConstraints.begin(), m_PeerConstraints.end(), peer) == m_PeerConstraints.end()); m_PeerConstraints.push_back(peer);
diff --git a/src/bones/root_bone.cpp b/src/bones/root_bone.cpp index 354555b..ff592f9 100644 --- a/src/bones/root_bone.cpp +++ b/src/bones/root_bone.cpp
@@ -2,7 +2,8 @@ using namespace rive; -StatusCode RootBone::onAddedClean(CoreContext* context) { +StatusCode RootBone::onAddedClean(CoreContext* context) +{ // Intentionally doesn't call Super(Bone)::onAddedClean and goes straight to // the super.super TransformComponent as that assumes the parent must be a // Bone while a root bone is a special case Bone that can be parented to
diff --git a/src/bones/skin.cpp b/src/bones/skin.cpp index 233210a..4a67abc 100644 --- a/src/bones/skin.cpp +++ b/src/bones/skin.cpp
@@ -10,7 +10,8 @@ Skin::~Skin() { delete[] m_BoneTransforms; } -StatusCode Skin::onAddedClean(CoreContext* context) { +StatusCode Skin::onAddedClean(CoreContext* context) +{ m_WorldTransform[0] = xx(); m_WorldTransform[1] = xy(); m_WorldTransform[2] = yx(); @@ -19,7 +20,8 @@ m_WorldTransform[5] = ty(); m_Skinnable = Skinnable::from(parent()); - if (m_Skinnable == nullptr) { + if (m_Skinnable == nullptr) + { return StatusCode::MissingObject; } @@ -28,9 +30,11 @@ return StatusCode::Ok; } -void Skin::update(ComponentDirt value) { +void Skin::update(ComponentDirt value) +{ int bidx = 6; - for (auto tendon : m_Tendons) { + for (auto tendon : m_Tendons) + { auto world = tendon->bone()->worldTransform() * tendon->inverseBind(); m_BoneTransforms[bidx++] = world[0]; m_BoneTransforms[bidx++] = world[1]; @@ -41,12 +45,15 @@ } } -void Skin::buildDependencies() { +void Skin::buildDependencies() +{ // depend on bones from tendons - for (auto tendon : m_Tendons) { + for (auto tendon : m_Tendons) + { auto bone = tendon->bone(); bone->addDependent(this); - for (auto constraint : bone->peerConstraints()) { + for (auto constraint : bone->peerConstraints()) + { constraint->parent()->addDependent(this); } } @@ -64,8 +71,10 @@ m_BoneTransforms[5] = 0; } -void Skin::deform(Span<Vertex*> vertices) { - for (auto vertex : vertices) { +void Skin::deform(Span<Vertex*> vertices) +{ + for (auto vertex : vertices) + { vertex->deform(m_WorldTransform, m_BoneTransforms); } }
diff --git a/src/bones/skinnable.cpp b/src/bones/skinnable.cpp index e06a026..74b33cb 100644 --- a/src/bones/skinnable.cpp +++ b/src/bones/skinnable.cpp
@@ -4,10 +4,14 @@ using namespace rive; -Skinnable* Skinnable::from(Component* component) { - switch (component->coreType()) { - case PointsPath::typeKey: return component->as<PointsPath>(); - case Mesh::typeKey: return component->as<Mesh>(); +Skinnable* Skinnable::from(Component* component) +{ + switch (component->coreType()) + { + case PointsPath::typeKey: + return component->as<PointsPath>(); + case Mesh::typeKey: + return component->as<Mesh>(); } return nullptr; }
diff --git a/src/bones/tendon.cpp b/src/bones/tendon.cpp index 6e8d204..8f2c147 100644 --- a/src/bones/tendon.cpp +++ b/src/bones/tendon.cpp
@@ -5,7 +5,8 @@ using namespace rive; -StatusCode Tendon::onAddedDirty(CoreContext* context) { +StatusCode Tendon::onAddedDirty(CoreContext* context) +{ Mat2D bind; bind[0] = xx(); bind[1] = xy(); @@ -14,16 +15,19 @@ bind[4] = tx(); bind[5] = ty(); - if (!bind.invert(&m_InverseBind)) { + if (!bind.invert(&m_InverseBind)) + { return StatusCode::FailedInversion; } StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } auto coreObject = context->resolve(boneId()); - if (coreObject == nullptr || !coreObject->is<Bone>()) { + if (coreObject == nullptr || !coreObject->is<Bone>()) + { return StatusCode::MissingObject; } @@ -32,8 +36,10 @@ return StatusCode::Ok; } -StatusCode Tendon::onAddedClean(CoreContext* context) { - if (!parent()->is<Skin>()) { +StatusCode Tendon::onAddedClean(CoreContext* context) +{ + if (!parent()->is<Skin>()) + { return StatusCode::MissingObject; }
diff --git a/src/bones/weight.cpp b/src/bones/weight.cpp index 8d41fce..642a6e4 100644 --- a/src/bones/weight.cpp +++ b/src/bones/weight.cpp
@@ -4,12 +4,15 @@ using namespace rive; -StatusCode Weight::onAddedDirty(CoreContext* context) { +StatusCode Weight::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } - if (!parent()->is<Vertex>()) { + if (!parent()->is<Vertex>()) + { return StatusCode::MissingObject; } @@ -18,7 +21,8 @@ return StatusCode::Ok; } -static int encodedWeightValue(unsigned int index, unsigned int data) { +static int encodedWeightValue(unsigned int index, unsigned int data) +{ return (data >> (index * 8)) & 0xFF; } @@ -26,11 +30,14 @@ unsigned int indices, unsigned int weights, const Mat2D& world, - const float* boneTransforms) { + const float* boneTransforms) +{ float xx = 0, xy = 0, yx = 0, yy = 0, tx = 0, ty = 0; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) + { int weight = encodedWeightValue(i, weights); - if (weight == 0) { + if (weight == 0) + { continue; }
diff --git a/src/component.cpp b/src/component.cpp index 864768e..e39da92 100644 --- a/src/component.cpp +++ b/src/component.cpp
@@ -8,30 +8,37 @@ using namespace rive; -StatusCode Component::onAddedDirty(CoreContext* context) { +StatusCode Component::onAddedDirty(CoreContext* context) +{ m_Artboard = static_cast<Artboard*>(context); - if (this == m_Artboard) { + if (this == m_Artboard) + { // We're the artboard, don't parent to ourselves. return StatusCode::Ok; } auto coreObject = context->resolve(parentId()); - if (coreObject == nullptr || !coreObject->is<ContainerComponent>()) { + if (coreObject == nullptr || !coreObject->is<ContainerComponent>()) + { return StatusCode::MissingObject; } m_Parent = reinterpret_cast<ContainerComponent*>(coreObject); return StatusCode::Ok; } -void Component::addDependent(Component* component) { +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); } -bool Component::addDirt(ComponentDirt value, bool recurse) { - if ((m_Dirt & value) == value) { +bool Component::addDirt(ComponentDirt value, bool recurse) +{ + if ((m_Dirt & value) == value) + { // Already marked. return false; } @@ -43,18 +50,22 @@ m_Artboard->onComponentDirty(this); - if (!recurse) { + if (!recurse) + { return true; } - for (auto d : m_Dependents) { + for (auto d : m_Dependents) + { d->addDirt(value, true); } return true; } -StatusCode Component::import(ImportStack& importStack) { - if (is<Artboard>()) { +StatusCode Component::import(ImportStack& importStack) +{ + if (is<Artboard>()) + { // Artboards are always their first object. assert(as<Artboard>()->objects().size() == 0); as<Artboard>()->addObject(this); @@ -62,7 +73,8 @@ } auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey); - if (artboardImporter == nullptr) { + if (artboardImporter == nullptr) + { return StatusCode::MissingObject; } artboardImporter->addComponent(this);
diff --git a/src/constraints/constraint.cpp b/src/constraints/constraint.cpp index ed04718..a8c5e60 100644 --- a/src/constraints/constraint.cpp +++ b/src/constraints/constraint.cpp
@@ -6,8 +6,10 @@ using namespace rive; -StatusCode Constraint::onAddedClean(CoreContext* context) { - if (!parent()->is<TransformComponent>()) { +StatusCode Constraint::onAddedClean(CoreContext* context) +{ + if (!parent()->is<TransformComponent>()) + { return StatusCode::InvalidObject; } @@ -20,21 +22,25 @@ void Constraint::strengthChanged() { markConstraintDirty(); } -void Constraint::buildDependencies() { +void Constraint::buildDependencies() +{ Super::buildDependencies(); parent()->addDependent(this); } -void Constraint::onDirty(ComponentDirt dirt) { +void Constraint::onDirty(ComponentDirt dirt) +{ // Whenever the constraint gets any dirt, make sure to mark the constrained // component dirty. markConstraintDirty(); } static Mat2D identity; -const Mat2D& rive::getParentWorld(const TransformComponent& component) { +const Mat2D& rive::getParentWorld(const TransformComponent& component) +{ auto parent = component.parent(); - if (parent->is<WorldTransformComponent>()) { + if (parent->is<WorldTransformComponent>()) + { return parent->as<WorldTransformComponent>()->worldTransform(); } return identity;
diff --git a/src/constraints/distance_constraint.cpp b/src/constraints/distance_constraint.cpp index 272d49f..498b906 100644 --- a/src/constraints/distance_constraint.cpp +++ b/src/constraints/distance_constraint.cpp
@@ -5,10 +5,17 @@ using namespace rive; -enum class Mode { Closer = 0, Further = 1, Exact = 2 }; +enum class Mode +{ + Closer = 0, + Further = 1, + Exact = 2 +}; -void DistanceConstraint::constrain(TransformComponent* component) { - if (m_Target == nullptr) { +void DistanceConstraint::constrain(TransformComponent* component) +{ + if (m_Target == nullptr) + { return; } @@ -18,20 +25,25 @@ Vec2D toTarget = ourTranslation - targetTranslation; float currentDistance = toTarget.length(); - switch (static_cast<Mode>(modeValue())) { + switch (static_cast<Mode>(modeValue())) + { case Mode::Closer: - if (currentDistance < distance()) { + if (currentDistance < distance()) + { return; } break; case Mode::Further: - if (currentDistance > distance()) { + if (currentDistance > distance()) + { return; } break; - case Mode::Exact: break; + case Mode::Exact: + break; } - if (currentDistance < 0.001f) { + if (currentDistance < 0.001f) + { return; }
diff --git a/src/constraints/ik_constraint.cpp b/src/constraints/ik_constraint.cpp index 41ac37b..ce366bf 100644 --- a/src/constraints/ik_constraint.cpp +++ b/src/constraints/ik_constraint.cpp
@@ -8,19 +8,23 @@ static float atan2(Vec2D v) { return std::atan2(v.y, v.x); } -void IKConstraint::buildDependencies() { +void IKConstraint::buildDependencies() +{ Super::buildDependencies(); // IK Constraint needs to depend on the target so that world transform // changes can propagate to the bones (and they can be reset before IK // runs). - if (m_Target != nullptr) { + if (m_Target != nullptr) + { m_Target->addDependent(this); } } -StatusCode IKConstraint::onAddedClean(CoreContext* context) { - if (!parent()->is<Bone>()) { +StatusCode IKConstraint::onAddedClean(CoreContext* context) +{ + if (!parent()->is<Bone>()) + { return StatusCode::InvalidObject; } @@ -29,7 +33,8 @@ std::vector<Bone*> bones; bones.push_back(bone); // Get the reverse FK chain of bones (from tip up). - while (bone->parent()->is<Bone>() && boneCount > 0) { + while (bone->parent()->is<Bone>() && boneCount > 0) + { boneCount--; bone = bone->parent()->as<Bone>(); bone->addPeerConstraint(this); @@ -39,7 +44,8 @@ m_FkChain.resize(numBones); // Now put them in FK order (top to bottom). int idx = 0; - for (auto boneItr = bones.rbegin(); boneItr != bones.rend(); ++boneItr) { + for (auto boneItr = bones.rbegin(); boneItr != bones.rend(); ++boneItr) + { BoneChainLink& link = m_FkChain[idx]; link.index = idx++; link.bone = *boneItr; @@ -55,13 +61,16 @@ // Find all children of this bone (we don't directly build up // hierarchy at runtime, so we have to traverse everything and check // parents). - for (auto core : artboard->objects()) { - if (core == nullptr || !core->is<TransformComponent>()) { + for (auto core : artboard->objects()) + { + if (core == nullptr || !core->is<TransformComponent>()) + { continue; } auto transformComponent = core->as<TransformComponent>(); - for (int i = 1; i < numBones; i++) { + for (int i = 1; i < numBones; i++) + { auto bone = bones[i]; if (transformComponent->parent() == bone && std::find(bones.begin(), bones.end(), transformComponent) == bones.end()) @@ -73,17 +82,20 @@ return Super::onAddedClean(context); } -void IKConstraint::markConstraintDirty() { +void IKConstraint::markConstraintDirty() +{ Super::markConstraintDirty(); // We automatically propagate dirt to the parent constrained bone, but we // also need to make sure the other bones we influence above it rebuild // their transforms. - for (int i = 0, length = (int)m_FkChain.size() - 1; i < length; i++) { + for (int i = 0, length = (int)m_FkChain.size() - 1; i < length; i++) + { m_FkChain[i].bone->markTransformDirty(); } } -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(); Vec2D pBT(worldTargetTranslation); @@ -101,7 +113,8 @@ void IKConstraint::solve2(BoneChainLink* fk1, BoneChainLink* fk2, - const Vec2D& worldTargetTranslation) { + const Vec2D& worldTargetTranslation) +{ Bone* b1 = fk1->bone; Bone* b2 = fk2->bone; BoneChainLink* firstChild = &(m_FkChain[fk1->index + 1]); @@ -126,7 +139,8 @@ 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) { + if (b2->parent() != b1) + { BoneChainLink& secondChild = m_FkChain[fk1->index + 2]; const Mat2D& secondChildWorldInverse = secondChild.parentWorldInverse; @@ -137,24 +151,32 @@ Vec2D avLocal = Vec2D::transformDir(pB - pC, secondChildWorldInverse); float angleCorrection = -atan2(avLocal); - if (invertDirection()) { + if (invertDirection()) + { r1 = atan2(cv) - A; r2 = -C + math::PI + angleCorrection; - } else { + } + else + { r1 = A + atan2(cv); r2 = C - math::PI + angleCorrection; } - } else if (invertDirection()) { + } + else if (invertDirection()) + { r1 = atan2(cv) - A; r2 = -C + math::PI; - } else { + } + else + { r1 = A + atan2(cv); r2 = C - math::PI; } constrainRotation(*fk1, r1); constrainRotation(*firstChild, r2); - if (firstChild != fk2) { + if (firstChild != fk2) + { Bone* bone = fk2->bone; bone->mutableWorldTransform() = getParentWorld(*bone) * bone->transform(); } @@ -164,7 +186,8 @@ firstChild->angle = r2; } -void IKConstraint::constrainRotation(BoneChainLink& fk, float rotation) { +void IKConstraint::constrainRotation(BoneChainLink& fk, float rotation) +{ Bone* bone = fk.bone; const Mat2D& parentWorld = getParentWorld(*bone); Mat2D& transform = bone->mutableTransform(); @@ -185,7 +208,8 @@ // Skew const float skew = c.skew(); - if (skew != 0.0f) { + if (skew != 0.0f) + { transform[2] = transform[0] * skew + transform[2]; transform[3] = transform[1] * skew + transform[3]; } @@ -193,15 +217,18 @@ bone->mutableWorldTransform() = parentWorld * transform; } -void IKConstraint::constrain(TransformComponent* component) { - if (m_Target == nullptr) { +void IKConstraint::constrain(TransformComponent* component) +{ + if (m_Target == nullptr) + { return; } Vec2D worldTargetTranslation = m_Target->worldTranslation(); // Decompose the chain. - for (BoneChainLink& item : m_FkChain) { + for (BoneChainLink& item : m_FkChain) + { auto bone = item.bone; const Mat2D& parentWorld = getParentWorld(*bone); item.parentWorldInverse = parentWorld.invertOrIdentity(); @@ -212,16 +239,24 @@ } int count = (int)m_FkChain.size(); - switch (count) { - case 1: solve1(&m_FkChain[0], worldTargetTranslation); break; - case 2: solve2(&m_FkChain[0], &m_FkChain[1], worldTargetTranslation); break; - default: { + switch (count) + { + case 1: + solve1(&m_FkChain[0], worldTargetTranslation); + break; + case 2: + solve2(&m_FkChain[0], &m_FkChain[1], worldTargetTranslation); + break; + default: + { auto last = count - 1; BoneChainLink* tip = &m_FkChain[last]; - for (int i = 0; i < last; i++) { + for (int i = 0; i < last; i++) + { BoneChainLink* item = &m_FkChain[i]; solve2(item, tip, worldTargetTranslation); - for (int j = item->index + 1, end = (int)m_FkChain.size() - 1; j < end; j++) { + for (int j = item->index + 1, end = (int)m_FkChain.size() - 1; j < end; j++) + { BoneChainLink& fk = m_FkChain[j]; fk.parentWorldInverse = getParentWorld(*fk.bone).invertOrIdentity(); } @@ -230,14 +265,19 @@ } } // At the end, mix the FK angle with the IK angle by strength - if (strength() != 1.0f) { - for (BoneChainLink& fk : m_FkChain) { + if (strength() != 1.0f) + { + for (BoneChainLink& fk : m_FkChain) + { float fromAngle = std::fmod(fk.transformComponents.rotation(), math::PI * 2); float toAngle = std::fmod(fk.angle, math::PI * 2); float diff = toAngle - fromAngle; - if (diff > math::PI) { + if (diff > math::PI) + { diff -= math::PI * 2; - } else if (diff < -math::PI) { + } + else if (diff < -math::PI) + { diff += math::PI * 2; } float angle = fromAngle + diff * strength();
diff --git a/src/constraints/rotation_constraint.cpp b/src/constraints/rotation_constraint.cpp index d17dbb3..a0003f7 100644 --- a/src/constraints/rotation_constraint.cpp +++ b/src/constraints/rotation_constraint.cpp
@@ -5,19 +5,25 @@ using namespace rive; -void RotationConstraint::constrain(TransformComponent* component) { +void RotationConstraint::constrain(TransformComponent* component) +{ const Mat2D& transformA = component->worldTransform(); Mat2D transformB; m_ComponentsA = transformA.decompose(); - if (m_Target == nullptr) { + if (m_Target == nullptr) + { transformB = transformA; m_ComponentsB = m_ComponentsA; - } else { + } + else + { transformB = m_Target->worldTransform(); - if (sourceSpace() == TransformSpace::local) { + if (sourceSpace() == TransformSpace::local) + { Mat2D inverse; - if (!getParentWorld(*m_Target).invert(&inverse)) { + if (!getParentWorld(*m_Target).invert(&inverse)) + { return; } transformB = inverse * transformB; @@ -25,17 +31,22 @@ m_ComponentsB = transformB.decompose(); - if (!doesCopy()) { + if (!doesCopy()) + { m_ComponentsB.rotation(destSpace() == TransformSpace::local ? 0.0f : m_ComponentsA.rotation()); - } else { + } + else + { m_ComponentsB.rotation(m_ComponentsB.rotation() * copyFactor()); - if (offset()) { + if (offset()) + { m_ComponentsB.rotation(m_ComponentsB.rotation() + component->rotation()); } } - if (destSpace() == TransformSpace::local) { + if (destSpace() == TransformSpace::local) + { // Destination space is in parent transform coordinates. Recompose // the parent local transform and get it in world, then decompose // the world for interpolation. @@ -46,23 +57,28 @@ } } bool clampLocal = minMaxSpace() == TransformSpace::local; - if (clampLocal) { + if (clampLocal) + { // Apply min max in local space, so transform to local coordinates // first. transformB = Mat2D::compose(m_ComponentsB); Mat2D inverse; - if (!getParentWorld(*component).invert(&inverse)) { + if (!getParentWorld(*component).invert(&inverse)) + { return; } m_ComponentsB = (inverse * transformB).decompose(); } - if (max() && m_ComponentsB.rotation() > maxValue()) { + if (max() && m_ComponentsB.rotation() > maxValue()) + { m_ComponentsB.rotation(maxValue()); } - if (min() && m_ComponentsB.rotation() < minValue()) { + if (min() && m_ComponentsB.rotation() < minValue()) + { m_ComponentsB.rotation(minValue()); } - if (clampLocal) { + if (clampLocal) + { // Transform back to world. transformB = Mat2D::compose(m_ComponentsB); transformB = getParentWorld(*component) * transformB; @@ -73,9 +89,12 @@ float angleB = std::fmod(m_ComponentsB.rotation(), math::PI * 2); float diff = angleB - angleA; - if (diff > math::PI) { + if (diff > math::PI) + { diff -= math::PI * 2; - } else if (diff < -math::PI) { + } + else if (diff < -math::PI) + { diff += math::PI * 2; }
diff --git a/src/constraints/scale_constraint.cpp b/src/constraints/scale_constraint.cpp index 1396d15..e59bce2 100644 --- a/src/constraints/scale_constraint.cpp +++ b/src/constraints/scale_constraint.cpp
@@ -5,45 +5,60 @@ using namespace rive; -void ScaleConstraint::constrain(TransformComponent* component) { +void ScaleConstraint::constrain(TransformComponent* component) +{ const Mat2D& transformA = component->worldTransform(); Mat2D transformB; m_ComponentsA = transformA.decompose(); - if (m_Target == nullptr) { + if (m_Target == nullptr) + { transformB = transformA; m_ComponentsB = m_ComponentsA; - } else { + } + else + { transformB = m_Target->worldTransform(); - if (sourceSpace() == TransformSpace::local) { + if (sourceSpace() == TransformSpace::local) + { Mat2D inverse; - if (!getParentWorld(*m_Target).invert(&inverse)) { + if (!getParentWorld(*m_Target).invert(&inverse)) + { return; } transformB = inverse * transformB; } m_ComponentsB = transformB.decompose(); - if (!doesCopy()) { + if (!doesCopy()) + { m_ComponentsB.scaleX(destSpace() == TransformSpace::local ? 1.0f : m_ComponentsA.scaleX()); - } else { + } + else + { m_ComponentsB.scaleX(m_ComponentsB.scaleX() * copyFactor()); - if (offset()) { + if (offset()) + { m_ComponentsB.scaleX(m_ComponentsB.scaleX() * component->scaleX()); } } - if (!doesCopyY()) { + if (!doesCopyY()) + { m_ComponentsB.scaleY(destSpace() == TransformSpace::local ? 1.0f : m_ComponentsA.scaleY()); - } else { + } + else + { m_ComponentsB.scaleY(m_ComponentsB.scaleY() * copyFactorY()); - if (offset()) { + if (offset()) + { m_ComponentsB.scaleY(m_ComponentsB.scaleY() * component->scaleY()); } } - if (destSpace() == TransformSpace::local) { + if (destSpace() == TransformSpace::local) + { // Destination space is in parent transform coordinates. Recompose // the parent local transform and get it in world, then decompose // the world for interpolation. @@ -55,30 +70,37 @@ } bool clamplocal = minMaxSpace() == TransformSpace::local; - if (clamplocal) { + if (clamplocal) + { // Apply min max in local space, so transform to local coordinates // first. transformB = Mat2D::compose(m_ComponentsB); Mat2D inverse; - if (!getParentWorld(*component).invert(&inverse)) { + if (!getParentWorld(*component).invert(&inverse)) + { return; } transformB = inverse * transformB; m_ComponentsB = transformB.decompose(); } - if (max() && m_ComponentsB.scaleX() > maxValue()) { + if (max() && m_ComponentsB.scaleX() > maxValue()) + { m_ComponentsB.scaleX(maxValue()); } - if (min() && m_ComponentsB.scaleX() < minValue()) { + if (min() && m_ComponentsB.scaleX() < minValue()) + { m_ComponentsB.scaleX(minValue()); } - if (maxY() && m_ComponentsB.scaleY() > maxValueY()) { + if (maxY() && m_ComponentsB.scaleY() > maxValueY()) + { m_ComponentsB.scaleY(maxValueY()); } - if (minY() && m_ComponentsB.scaleY() < minValueY()) { + if (minY() && m_ComponentsB.scaleY() < minValueY()) + { m_ComponentsB.scaleY(minValueY()); } - if (clamplocal) { + if (clamplocal) + { // Transform back to world. transformB = Mat2D::compose(m_ComponentsB); transformB = getParentWorld(*component) * transformB;
diff --git a/src/constraints/targeted_constraint.cpp b/src/constraints/targeted_constraint.cpp index 9f7802e..2daaa29 100644 --- a/src/constraints/targeted_constraint.cpp +++ b/src/constraints/targeted_constraint.cpp
@@ -4,13 +4,16 @@ using namespace rive; -StatusCode TargetedConstraint::onAddedDirty(CoreContext* context) { +StatusCode TargetedConstraint::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } auto coreObject = context->resolve(targetId()); - if (coreObject == nullptr || !coreObject->is<TransformComponent>()) { + if (coreObject == nullptr || !coreObject->is<TransformComponent>()) + { return StatusCode::MissingObject; } @@ -19,10 +22,12 @@ return StatusCode::Ok; } -void TargetedConstraint::buildDependencies() { +void TargetedConstraint::buildDependencies() +{ // Targeted constraints must have their constrained component (parent) // update after the target. - if (m_Target != nullptr) { + if (m_Target != nullptr) + { m_Target->addDependent(parent()); } } \ No newline at end of file
diff --git a/src/constraints/transform_constraint.cpp b/src/constraints/transform_constraint.cpp index ffa1035..b66b61a 100644 --- a/src/constraints/transform_constraint.cpp +++ b/src/constraints/transform_constraint.cpp
@@ -5,23 +5,28 @@ using namespace rive; -void TransformConstraint::constrain(TransformComponent* component) { - if (m_Target == nullptr) { +void TransformConstraint::constrain(TransformComponent* component) +{ + if (m_Target == nullptr) + { return; } const Mat2D& transformA = component->worldTransform(); Mat2D transformB(m_Target->worldTransform()); - if (sourceSpace() == TransformSpace::local) { + if (sourceSpace() == TransformSpace::local) + { const Mat2D& targetParentWorld = getParentWorld(*m_Target); Mat2D inverse; - if (!targetParentWorld.invert(&inverse)) { + if (!targetParentWorld.invert(&inverse)) + { return; } transformB = inverse * transformB; } - if (destSpace() == TransformSpace::local) { + if (destSpace() == TransformSpace::local) + { const Mat2D& targetParentWorld = getParentWorld(*component); transformB = targetParentWorld * transformB; } @@ -32,9 +37,12 @@ float angleA = std::fmod(m_ComponentsA.rotation(), math::PI * 2); float angleB = std::fmod(m_ComponentsB.rotation(), math::PI * 2); float diff = angleB - angleA; - if (diff > math::PI) { + if (diff > math::PI) + { diff -= math::PI * 2; - } else if (diff < -math::PI) { + } + else if (diff < -math::PI) + { diff += math::PI * 2; }
diff --git a/src/constraints/translation_constraint.cpp b/src/constraints/translation_constraint.cpp index 7bc56b5..452ae3a 100644 --- a/src/constraints/translation_constraint.cpp +++ b/src/constraints/translation_constraint.cpp
@@ -6,74 +6,96 @@ using namespace rive; -void TranslationConstraint::constrain(TransformComponent* component) { +void TranslationConstraint::constrain(TransformComponent* component) +{ Mat2D& transformA = component->mutableWorldTransform(); Vec2D translationA(transformA[4], transformA[5]); Vec2D translationB; - if (m_Target == nullptr) { + if (m_Target == nullptr) + { translationB = translationA; - } else { + } + else + { Mat2D transformB(m_Target->worldTransform()); - if (sourceSpace() == TransformSpace::local) { + if (sourceSpace() == TransformSpace::local) + { const Mat2D& targetParentWorld = getParentWorld(*m_Target); Mat2D inverse; - if (!targetParentWorld.invert(&inverse)) { + if (!targetParentWorld.invert(&inverse)) + { return; } transformB = inverse * transformB; } translationB = transformB.translation(); - if (!doesCopy()) { + if (!doesCopy()) + { translationB.x = destSpace() == TransformSpace::local ? 0.0f : translationA.x; - } else { + } + else + { translationB.x *= copyFactor(); - if (offset()) { + if (offset()) + { translationB.x += component->x(); } } - if (!doesCopyY()) { + if (!doesCopyY()) + { translationB.y = destSpace() == TransformSpace::local ? 0.0f : translationA.y; - } else { + } + else + { translationB.y *= copyFactorY(); - if (offset()) { + if (offset()) + { translationB.y += component->y(); } } - if (destSpace() == TransformSpace::local) { + if (destSpace() == TransformSpace::local) + { // Destination space is in parent transform coordinates. translationB = getParentWorld(*component) * translationB; } } bool clampLocal = minMaxSpace() == TransformSpace::local; - if (clampLocal) { + if (clampLocal) + { // Apply min max in local space, so transform to local coordinates // first. Mat2D inverse; - if (!getParentWorld(*component).invert(&inverse)) { + if (!getParentWorld(*component).invert(&inverse)) + { return; } // Get our target world coordinates in parent local. translationB = inverse * translationB; } - if (max() && translationB.x > maxValue()) { + if (max() && translationB.x > maxValue()) + { translationB.x = maxValue(); } - if (min() && translationB.x < minValue()) { + if (min() && translationB.x < minValue()) + { translationB.x = minValue(); } - if (maxY() && translationB.y > maxValueY()) { + if (maxY() && translationB.y > maxValueY()) + { translationB.y = maxValueY(); } - if (minY() && translationB.y < minValueY()) { + if (minY() && translationB.y < minValueY()) + { translationB.y = minValueY(); } - if (clampLocal) { + if (clampLocal) + { // Transform back to world. translationB = getParentWorld(*component) * translationB; }
diff --git a/src/core/binary_reader.cpp b/src/core/binary_reader.cpp index 18036b5..d00413f 100644 --- a/src/core/binary_reader.cpp +++ b/src/core/binary_reader.cpp
@@ -6,9 +6,11 @@ using namespace rive; BinaryReader::BinaryReader(Span<const uint8_t> bytes) : - m_Bytes(bytes), m_Position(bytes.begin()), m_Overflowed(false), m_IntRangeError(false) {} + m_Bytes(bytes), m_Position(bytes.begin()), m_Overflowed(false), m_IntRangeError(false) +{} -bool BinaryReader::reachedEnd() const { +bool BinaryReader::reachedEnd() const +{ return m_Position == m_Bytes.end() || didOverflow() || didIntRangeError(); } @@ -19,20 +21,24 @@ bool BinaryReader::didIntRangeError() const { return m_IntRangeError; } -void BinaryReader::overflow() { +void BinaryReader::overflow() +{ m_Overflowed = true; m_Position = m_Bytes.end(); } -void BinaryReader::intRangeError() { +void BinaryReader::intRangeError() +{ m_IntRangeError = true; m_Position = m_Bytes.end(); } -uint64_t BinaryReader::readVarUint64() { +uint64_t BinaryReader::readVarUint64() +{ uint64_t value; auto readBytes = decode_uint_leb(m_Position, m_Bytes.end(), &value); - if (readBytes == 0) { + if (readBytes == 0) + { overflow(); return 0; } @@ -40,15 +46,18 @@ return value; } -std::string BinaryReader::readString() { +std::string BinaryReader::readString() +{ uint64_t length = readVarUint64(); - if (didOverflow()) { + if (didOverflow()) + { return std::string(); } std::vector<char> rawValue((size_t)length + 1); auto readBytes = decode_string(length, m_Position, m_Bytes.end(), &rawValue[0]); - if (readBytes != length) { + if (readBytes != length) + { overflow(); return std::string(); } @@ -56,9 +65,11 @@ return std::string(rawValue.data(), (size_t)length); } -Span<const uint8_t> BinaryReader::readBytes() { +Span<const uint8_t> BinaryReader::readBytes() +{ uint64_t length = readVarUint64(); - if (didOverflow()) { + if (didOverflow()) + { return Span<const uint8_t>(m_Position, 0); } @@ -67,10 +78,12 @@ return {start, (size_t)length}; } -float BinaryReader::readFloat32() { +float BinaryReader::readFloat32() +{ float value; auto readBytes = decode_float(m_Position, m_Bytes.end(), &value); - if (readBytes == 0) { + if (readBytes == 0) + { overflow(); return 0.0f; } @@ -78,18 +91,22 @@ return value; } -uint8_t BinaryReader::readByte() { - if (m_Bytes.end() - m_Position < 1) { +uint8_t BinaryReader::readByte() +{ + if (m_Bytes.end() - m_Position < 1) + { overflow(); return 0; } return *m_Position++; } -uint32_t BinaryReader::readUint32() { +uint32_t BinaryReader::readUint32() +{ uint32_t value; auto readBytes = decode_uint_32(m_Position, m_Bytes.end(), &value); - if (readBytes == 0) { + if (readBytes == 0) + { overflow(); return 0; }
diff --git a/src/core/field_types/core_uint_type.cpp b/src/core/field_types/core_uint_type.cpp index 15b19c0..4009f50 100644 --- a/src/core/field_types/core_uint_type.cpp +++ b/src/core/field_types/core_uint_type.cpp
@@ -3,6 +3,7 @@ using namespace rive; -unsigned int CoreUintType::deserialize(BinaryReader& reader) { +unsigned int CoreUintType::deserialize(BinaryReader& reader) +{ return reader.readVarUintAs<unsigned int>(); }
diff --git a/src/dependency_sorter.cpp b/src/dependency_sorter.cpp index a2f399b..1bf9f44 100644 --- a/src/dependency_sorter.cpp +++ b/src/dependency_sorter.cpp
@@ -3,16 +3,20 @@ using namespace rive; -void DependencySorter::sort(Component* root, std::vector<Component*>& order) { +void DependencySorter::sort(Component* root, std::vector<Component*>& order) +{ order.clear(); visit(root, order); } -bool DependencySorter::visit(Component* component, std::vector<Component*>& order) { - if (m_Perm.find(component) != m_Perm.end()) { +bool DependencySorter::visit(Component* component, std::vector<Component*>& order) +{ + if (m_Perm.find(component) != m_Perm.end()) + { return true; } - if (m_Temp.find(component) != m_Temp.end()) { + if (m_Temp.find(component) != m_Temp.end()) + { fprintf(stderr, "Dependency cycle!\n"); return false; } @@ -20,8 +24,10 @@ m_Temp.emplace(component); auto dependents = component->dependents(); - for (auto dependent : dependents) { - if (!visit(dependent, order)) { + for (auto dependent : dependents) + { + if (!visit(dependent, order)) + { return false; } }
diff --git a/src/draw_rules.cpp b/src/draw_rules.cpp index 4acb10f..4a733db 100644 --- a/src/draw_rules.cpp +++ b/src/draw_rules.cpp
@@ -5,13 +5,16 @@ using namespace rive; -StatusCode DrawRules::onAddedDirty(CoreContext* context) { +StatusCode DrawRules::onAddedDirty(CoreContext* context) +{ StatusCode result = Super::onAddedDirty(context); - if (result != StatusCode::Ok) { + if (result != StatusCode::Ok) + { return result; } auto coreObject = context->resolve(drawTargetId()); - if (coreObject != nullptr && coreObject->is<DrawTarget>()) { + if (coreObject != nullptr && coreObject->is<DrawTarget>()) + { m_ActiveTarget = reinterpret_cast<DrawTarget*>(coreObject); } @@ -20,11 +23,15 @@ StatusCode DrawRules::onAddedClean(CoreContext* context) { return StatusCode::Ok; } -void DrawRules::drawTargetIdChanged() { +void DrawRules::drawTargetIdChanged() +{ auto coreObject = artboard()->resolve(drawTargetId()); - if (coreObject == nullptr || !coreObject->is<DrawTarget>()) { + if (coreObject == nullptr || !coreObject->is<DrawTarget>()) + { m_ActiveTarget = nullptr; - } else { + } + else + { m_ActiveTarget = reinterpret_cast<DrawTarget*>(coreObject); } artboard()->addDirt(ComponentDirt::DrawOrder);
diff --git a/src/draw_target.cpp b/src/draw_target.cpp index 4f7ab45..bf042d8 100644 --- a/src/draw_target.cpp +++ b/src/draw_target.cpp
@@ -5,13 +5,16 @@ using namespace rive; -StatusCode DrawTarget::onAddedDirty(CoreContext* context) { +StatusCode DrawTarget::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } auto coreObject = context->resolve(drawableId()); - if (coreObject == nullptr || !coreObject->is<Drawable>()) { + if (coreObject == nullptr || !coreObject->is<Drawable>()) + { return StatusCode::MissingObject; } m_Drawable = reinterpret_cast<Drawable*>(coreObject);
diff --git a/src/drawable.cpp b/src/drawable.cpp index 9c24ca0..32b86ec 100644 --- a/src/drawable.cpp +++ b/src/drawable.cpp
@@ -8,21 +8,26 @@ void Drawable::addClippingShape(ClippingShape* shape) { m_ClippingShapes.push_back(shape); } -bool Drawable::clip(Renderer* renderer) const { - if (m_ClippingShapes.size() == 0) { +bool Drawable::clip(Renderer* renderer) const +{ + if (m_ClippingShapes.size() == 0) + { return false; } renderer->save(); - for (auto clippingShape : m_ClippingShapes) { - if (!clippingShape->isVisible()) { + for (auto clippingShape : m_ClippingShapes) + { + if (!clippingShape->isVisible()) + { continue; } RenderPath* renderPath = clippingShape->renderPath(); // Can intentionally be null if all the clipping shapes are hidden. - if (renderPath != nullptr) { + if (renderPath != nullptr) + { renderer->clipPath(renderPath); } }
diff --git a/src/factory.cpp b/src/factory.cpp index 2bf02a8..8be9edf 100644 --- a/src/factory.cpp +++ b/src/factory.cpp
@@ -8,7 +8,8 @@ using namespace rive; -std::unique_ptr<RenderPath> Factory::makeRenderPath(const AABB& r) { +std::unique_ptr<RenderPath> Factory::makeRenderPath(const AABB& r) +{ RawPath rawPath; rawPath.addRect(r); return makeRenderPath(rawPath, FillRule::nonZero);
diff --git a/src/file.cpp b/src/file.cpp index 41e4004..d7f86fb 100644 --- a/src/file.cpp +++ b/src/file.cpp
@@ -53,30 +53,37 @@ // 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.readVarUintAs<int>(); auto object = CoreRegistry::makeCoreInstance(coreObjectKey); - while (true) { + while (true) + { auto propertyKey = reader.readVarUintAs<uint16_t>(); - if (propertyKey == 0) { + if (propertyKey == 0) + { // Terminator. https://media.giphy.com/media/7TtvTUMm9mp20/giphy.gif break; } - if (reader.hasError()) { + if (reader.hasError()) + { delete object; return nullptr; } - if (object == nullptr || !object->deserialize(propertyKey, reader)) { + if (object == nullptr || !object->deserialize(propertyKey, reader)) + { // We have an unknown object or property, first see if core knows // the property type. int id = CoreRegistry::propertyFieldId(propertyKey); - if (id == -1) { + if (id == -1) + { // No, check if it's in toc. id = header.propertyFieldId(propertyKey); } - if (id == -1) { + if (id == -1) + { // Still couldn't find it, give up. fprintf(stderr, "Unknown property key %d, missing from property ToC.\n", @@ -85,15 +92,25 @@ return nullptr; } - switch (id) { - case CoreUintType::id: CoreUintType::deserialize(reader); break; - case CoreStringType::id: CoreStringType::deserialize(reader); break; - case CoreDoubleType::id: CoreDoubleType::deserialize(reader); break; - case CoreColorType::id: CoreColorType::deserialize(reader); break; + switch (id) + { + case CoreUintType::id: + CoreUintType::deserialize(reader); + break; + case CoreStringType::id: + CoreStringType::deserialize(reader); + break; + case CoreDoubleType::id: + CoreDoubleType::deserialize(reader); + break; + case CoreColorType::id: + CoreColorType::deserialize(reader); + break; } } } - if (object == nullptr) { + if (object == nullptr) + { // fprintf(stderr, // "File contains an unknown object with coreType " RIVE_FMT_U64 // ", which " "this runtime doesn't understand.\n", @@ -104,7 +121,8 @@ } File::File(Factory* factory, FileAssetResolver* assetResolver) : - m_Factory(factory), m_AssetResolver(assetResolver) { + m_Factory(factory), m_AssetResolver(assetResolver) +{ Counter::update(Counter::kFile, +1); assert(factory); @@ -115,61 +133,81 @@ std::unique_ptr<File> File::import(Span<const uint8_t> bytes, Factory* factory, ImportResult* result, - FileAssetResolver* assetResolver) { + FileAssetResolver* assetResolver) +{ BinaryReader reader(bytes); RuntimeHeader header; - if (!RuntimeHeader::read(reader, header)) { + if (!RuntimeHeader::read(reader, header)) + { fprintf(stderr, "Bad header\n"); - if (result) { + if (result) + { *result = ImportResult::malformed; } return nullptr; } - if (header.majorVersion() != majorVersion) { + if (header.majorVersion() != majorVersion) + { fprintf(stderr, "Unsupported version %u.%u expected %u.%u.\n", header.majorVersion(), header.minorVersion(), majorVersion, minorVersion); - if (result) { + if (result) + { *result = ImportResult::unsupportedVersion; } return nullptr; } auto file = std::unique_ptr<File>(new File(factory, assetResolver)); auto readResult = file->read(reader, header); - if (readResult != ImportResult::success) { + if (readResult != ImportResult::success) + { file.reset(nullptr); } - if (result) { + if (result) + { *result = ImportResult::success; } return file; } -ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header) { +ImportResult File::read(BinaryReader& reader, const RuntimeHeader& header) +{ ImportStack importStack; - while (!reader.reachedEnd()) { + while (!reader.reachedEnd()) + { auto object = readRuntimeObject(reader, header); - if (object == nullptr) { + if (object == nullptr) + { importStack.readNullObject(); continue; } - if (object->import(importStack) == StatusCode::Ok) { - switch (object->coreType()) { - case Backboard::typeKey: m_Backboard.reset(object->as<Backboard>()); break; - case Artboard::typeKey: { + if (object->import(importStack) == StatusCode::Ok) + { + switch (object->coreType()) + { + case Backboard::typeKey: + m_Backboard.reset(object->as<Backboard>()); + break; + case Artboard::typeKey: + { Artboard* ab = object->as<Artboard>(); ab->m_Factory = m_Factory; m_Artboards.push_back(std::unique_ptr<Artboard>(ab)); - } break; - case ImageAsset::typeKey: { + } + break; + case ImageAsset::typeKey: + { auto fa = object->as<FileAsset>(); m_FileAssets.push_back(std::unique_ptr<FileAsset>(fa)); - } break; + } + break; } - } else { + } + else + { fprintf(stderr, "Failed to import object of type %d\n", object->coreType()); delete object; continue; @@ -177,7 +215,8 @@ ImportStackObject* stackObject = nullptr; auto stackType = object->coreType(); - switch (stackType) { + switch (stackType) + { case Backboard::typeKey: stackObject = new BackboardImporter(object->as<Backboard>()); break; @@ -190,10 +229,12 @@ case KeyedObject::typeKey: stackObject = new KeyedObjectImporter(object->as<KeyedObject>()); break; - case KeyedProperty::typeKey: { + case KeyedProperty::typeKey: + { auto importer = importStack.latest<LinearAnimationImporter>(LinearAnimation::typeKey); - if (importer == nullptr) { + if (importer == nullptr) + { return ImportResult::malformed; } stackObject = @@ -203,9 +244,11 @@ case StateMachine::typeKey: stackObject = new StateMachineImporter(object->as<StateMachine>()); break; - case StateMachineLayer::typeKey: { + case StateMachineLayer::typeKey: + { auto artboardImporter = importStack.latest<ArtboardImporter>(ArtboardBase::typeKey); - if (artboardImporter == nullptr) { + if (artboardImporter == nullptr) + { return ImportResult::malformed; } @@ -237,7 +280,8 @@ stackType = FileAsset::typeKey; break; } - if (importStack.makeLatest(stackType, stackObject) != StatusCode::Ok) { + if (importStack.makeLatest(stackType, stackObject) != StatusCode::Ok) + { // Some previous stack item didn't resolve. return ImportResult::malformed; } @@ -247,52 +291,65 @@ : ImportResult::malformed; } -Artboard* File::artboard(std::string name) const { - for (const auto& artboard : m_Artboards) { - if (artboard->name() == name) { +Artboard* File::artboard(std::string name) const +{ + for (const auto& artboard : m_Artboards) + { + if (artboard->name() == name) + { return artboard.get(); } } return nullptr; } -Artboard* File::artboard() const { - if (m_Artboards.empty()) { +Artboard* File::artboard() const +{ + if (m_Artboards.empty()) + { return nullptr; } return m_Artboards[0].get(); } -Artboard* File::artboard(size_t index) const { - if (index >= m_Artboards.size()) { +Artboard* File::artboard(size_t index) const +{ + if (index >= m_Artboards.size()) + { return nullptr; } return m_Artboards[index].get(); } -std::string File::artboardNameAt(size_t index) const { +std::string File::artboardNameAt(size_t index) const +{ auto ab = this->artboard(index); return ab ? ab->name() : ""; } -std::unique_ptr<ArtboardInstance> File::artboardDefault() const { +std::unique_ptr<ArtboardInstance> File::artboardDefault() const +{ auto ab = this->artboard(); return ab ? ab->instance() : nullptr; } -std::unique_ptr<ArtboardInstance> File::artboardAt(size_t index) const { +std::unique_ptr<ArtboardInstance> File::artboardAt(size_t index) const +{ auto ab = this->artboard(index); return ab ? ab->instance() : nullptr; } -std::unique_ptr<ArtboardInstance> File::artboardNamed(std::string name) const { +std::unique_ptr<ArtboardInstance> File::artboardNamed(std::string name) const +{ auto ab = this->artboard(name); return ab ? ab->instance() : nullptr; } -std::vector<const FileAsset*> File::assets() const { +std::vector<const FileAsset*> File::assets() const +{ std::vector<const FileAsset*> assets; - for (auto itr = m_FileAssets.begin(); itr != m_FileAssets.end(); itr++) { + for (auto itr = m_FileAssets.begin(); itr != m_FileAssets.end(); itr++) + { assets.push_back(itr->get()); } return assets; @@ -301,35 +358,47 @@ #ifdef WITH_RIVE_TOOLS const std::vector<uint8_t> File::stripAssets(Span<const uint8_t> bytes, std::set<uint16_t> typeKeys, - ImportResult* result) { + ImportResult* result) +{ std::vector<uint8_t> strippedData; strippedData.reserve(bytes.size()); BinaryReader reader(bytes); RuntimeHeader header; - if (!RuntimeHeader::read(reader, header)) { - if (result) { + if (!RuntimeHeader::read(reader, header)) + { + if (result) + { *result = ImportResult::malformed; } - - } else if (header.majorVersion() != majorVersion) { - if (result) { + } + else if (header.majorVersion() != majorVersion) + { + if (result) + { *result = ImportResult::unsupportedVersion; } - } else { + } + else + { strippedData.insert(strippedData.end(), bytes.data(), reader.position()); const uint8_t* from = reader.position(); const uint8_t* to = reader.position(); uint16_t lastAssetType = 0; - while (!reader.reachedEnd()) { + while (!reader.reachedEnd()) + { auto object = readRuntimeObject(reader, header); - if (object == nullptr) { + if (object == nullptr) + { continue; } - if (object->is<FileAssetBase>()) { + if (object->is<FileAssetBase>()) + { lastAssetType = object->coreType(); } - if (object->is<FileAssetContents>() && typeKeys.find(lastAssetType) != typeKeys.end()) { - if (from != to) { + if (object->is<FileAssetContents>() && typeKeys.find(lastAssetType) != typeKeys.end()) + { + if (from != to) + { strippedData.insert(strippedData.end(), from, to); } from = reader.position(); @@ -337,7 +406,8 @@ delete object; to = reader.position(); } - if (from != to) { + if (from != to) + { strippedData.insert(strippedData.end(), from, to); } *result = ImportResult::success;
diff --git a/src/generated/animation/animation_base.cpp b/src/generated/animation/animation_base.cpp index 81aef8c..e832aeb 100644 --- a/src/generated/animation/animation_base.cpp +++ b/src/generated/animation/animation_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* AnimationBase::clone() const { +Core* AnimationBase::clone() const +{ auto cloned = new Animation(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/animation_state_base.cpp b/src/generated/animation/animation_state_base.cpp index 299adb6..922ea8e 100644 --- a/src/generated/animation/animation_state_base.cpp +++ b/src/generated/animation/animation_state_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* AnimationStateBase::clone() const { +Core* AnimationStateBase::clone() const +{ auto cloned = new AnimationState(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/any_state_base.cpp b/src/generated/animation/any_state_base.cpp index b590058..54b2a42 100644 --- a/src/generated/animation/any_state_base.cpp +++ b/src/generated/animation/any_state_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* AnyStateBase::clone() const { +Core* AnyStateBase::clone() const +{ auto cloned = new AnyState(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/blend_animation_1d_base.cpp b/src/generated/animation/blend_animation_1d_base.cpp index ee1a1c4..a04b71f 100644 --- a/src/generated/animation/blend_animation_1d_base.cpp +++ b/src/generated/animation/blend_animation_1d_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BlendAnimation1DBase::clone() const { +Core* BlendAnimation1DBase::clone() const +{ auto cloned = new BlendAnimation1D(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/blend_animation_direct_base.cpp b/src/generated/animation/blend_animation_direct_base.cpp index af0bec8..98bd50a 100644 --- a/src/generated/animation/blend_animation_direct_base.cpp +++ b/src/generated/animation/blend_animation_direct_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BlendAnimationDirectBase::clone() const { +Core* BlendAnimationDirectBase::clone() const +{ auto cloned = new BlendAnimationDirect(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/blend_state_1d_base.cpp b/src/generated/animation/blend_state_1d_base.cpp index b866eb4..3a287ec 100644 --- a/src/generated/animation/blend_state_1d_base.cpp +++ b/src/generated/animation/blend_state_1d_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BlendState1DBase::clone() const { +Core* BlendState1DBase::clone() const +{ auto cloned = new BlendState1D(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/blend_state_direct_base.cpp b/src/generated/animation/blend_state_direct_base.cpp index 1f2e64d..a0349bc 100644 --- a/src/generated/animation/blend_state_direct_base.cpp +++ b/src/generated/animation/blend_state_direct_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BlendStateDirectBase::clone() const { +Core* BlendStateDirectBase::clone() const +{ auto cloned = new BlendStateDirect(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/blend_state_transition_base.cpp b/src/generated/animation/blend_state_transition_base.cpp index 6b361e1..a4b74d4 100644 --- a/src/generated/animation/blend_state_transition_base.cpp +++ b/src/generated/animation/blend_state_transition_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BlendStateTransitionBase::clone() const { +Core* BlendStateTransitionBase::clone() const +{ auto cloned = new BlendStateTransition(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/cubic_interpolator_base.cpp b/src/generated/animation/cubic_interpolator_base.cpp index 75a2ceb..24eb158 100644 --- a/src/generated/animation/cubic_interpolator_base.cpp +++ b/src/generated/animation/cubic_interpolator_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* CubicInterpolatorBase::clone() const { +Core* CubicInterpolatorBase::clone() const +{ auto cloned = new CubicInterpolator(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/entry_state_base.cpp b/src/generated/animation/entry_state_base.cpp index 126024c..68ec90e 100644 --- a/src/generated/animation/entry_state_base.cpp +++ b/src/generated/animation/entry_state_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* EntryStateBase::clone() const { +Core* EntryStateBase::clone() const +{ auto cloned = new EntryState(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/exit_state_base.cpp b/src/generated/animation/exit_state_base.cpp index 3991967..12f5ad5 100644 --- a/src/generated/animation/exit_state_base.cpp +++ b/src/generated/animation/exit_state_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ExitStateBase::clone() const { +Core* ExitStateBase::clone() const +{ auto cloned = new ExitState(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/keyed_object_base.cpp b/src/generated/animation/keyed_object_base.cpp index f3c108c..57cb7a2 100644 --- a/src/generated/animation/keyed_object_base.cpp +++ b/src/generated/animation/keyed_object_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* KeyedObjectBase::clone() const { +Core* KeyedObjectBase::clone() const +{ auto cloned = new KeyedObject(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/keyed_property_base.cpp b/src/generated/animation/keyed_property_base.cpp index b649f54..fe175e5 100644 --- a/src/generated/animation/keyed_property_base.cpp +++ b/src/generated/animation/keyed_property_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* KeyedPropertyBase::clone() const { +Core* KeyedPropertyBase::clone() const +{ auto cloned = new KeyedProperty(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/keyframe_bool_base.cpp b/src/generated/animation/keyframe_bool_base.cpp index 441c542..72b141d 100644 --- a/src/generated/animation/keyframe_bool_base.cpp +++ b/src/generated/animation/keyframe_bool_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* KeyFrameBoolBase::clone() const { +Core* KeyFrameBoolBase::clone() const +{ auto cloned = new KeyFrameBool(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/keyframe_color_base.cpp b/src/generated/animation/keyframe_color_base.cpp index f601201..93d2a15 100644 --- a/src/generated/animation/keyframe_color_base.cpp +++ b/src/generated/animation/keyframe_color_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* KeyFrameColorBase::clone() const { +Core* KeyFrameColorBase::clone() const +{ auto cloned = new KeyFrameColor(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/keyframe_double_base.cpp b/src/generated/animation/keyframe_double_base.cpp index f252dc8..b991a0e 100644 --- a/src/generated/animation/keyframe_double_base.cpp +++ b/src/generated/animation/keyframe_double_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* KeyFrameDoubleBase::clone() const { +Core* KeyFrameDoubleBase::clone() const +{ auto cloned = new KeyFrameDouble(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/keyframe_id_base.cpp b/src/generated/animation/keyframe_id_base.cpp index bd5a263..a228b47 100644 --- a/src/generated/animation/keyframe_id_base.cpp +++ b/src/generated/animation/keyframe_id_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* KeyFrameIdBase::clone() const { +Core* KeyFrameIdBase::clone() const +{ auto cloned = new KeyFrameId(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/linear_animation_base.cpp b/src/generated/animation/linear_animation_base.cpp index f1d084f..b55beef 100644 --- a/src/generated/animation/linear_animation_base.cpp +++ b/src/generated/animation/linear_animation_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* LinearAnimationBase::clone() const { +Core* LinearAnimationBase::clone() const +{ auto cloned = new LinearAnimation(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/listener_align_target_base.cpp b/src/generated/animation/listener_align_target_base.cpp index 9da8b5b..f0c1c95 100644 --- a/src/generated/animation/listener_align_target_base.cpp +++ b/src/generated/animation/listener_align_target_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ListenerAlignTargetBase::clone() const { +Core* ListenerAlignTargetBase::clone() const +{ auto cloned = new ListenerAlignTarget(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/listener_bool_change_base.cpp b/src/generated/animation/listener_bool_change_base.cpp index 0b756d5..3cd4cc3 100644 --- a/src/generated/animation/listener_bool_change_base.cpp +++ b/src/generated/animation/listener_bool_change_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ListenerBoolChangeBase::clone() const { +Core* ListenerBoolChangeBase::clone() const +{ auto cloned = new ListenerBoolChange(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/listener_number_change_base.cpp b/src/generated/animation/listener_number_change_base.cpp index 8051ae2..55d6212 100644 --- a/src/generated/animation/listener_number_change_base.cpp +++ b/src/generated/animation/listener_number_change_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ListenerNumberChangeBase::clone() const { +Core* ListenerNumberChangeBase::clone() const +{ auto cloned = new ListenerNumberChange(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/listener_trigger_change_base.cpp b/src/generated/animation/listener_trigger_change_base.cpp index 732933b..4ead315 100644 --- a/src/generated/animation/listener_trigger_change_base.cpp +++ b/src/generated/animation/listener_trigger_change_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ListenerTriggerChangeBase::clone() const { +Core* ListenerTriggerChangeBase::clone() const +{ auto cloned = new ListenerTriggerChange(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/nested_bool_base.cpp b/src/generated/animation/nested_bool_base.cpp index 315ebbd..f21b56c 100644 --- a/src/generated/animation/nested_bool_base.cpp +++ b/src/generated/animation/nested_bool_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedBoolBase::clone() const { +Core* NestedBoolBase::clone() const +{ auto cloned = new NestedBool(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/nested_number_base.cpp b/src/generated/animation/nested_number_base.cpp index 4a7fa1d..6e5613c 100644 --- a/src/generated/animation/nested_number_base.cpp +++ b/src/generated/animation/nested_number_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedNumberBase::clone() const { +Core* NestedNumberBase::clone() const +{ auto cloned = new NestedNumber(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/nested_remap_animation_base.cpp b/src/generated/animation/nested_remap_animation_base.cpp index be06ba9..ff0a6c6 100644 --- a/src/generated/animation/nested_remap_animation_base.cpp +++ b/src/generated/animation/nested_remap_animation_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedRemapAnimationBase::clone() const { +Core* NestedRemapAnimationBase::clone() const +{ auto cloned = new NestedRemapAnimation(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/nested_simple_animation_base.cpp b/src/generated/animation/nested_simple_animation_base.cpp index 3d19b86..283d353 100644 --- a/src/generated/animation/nested_simple_animation_base.cpp +++ b/src/generated/animation/nested_simple_animation_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedSimpleAnimationBase::clone() const { +Core* NestedSimpleAnimationBase::clone() const +{ auto cloned = new NestedSimpleAnimation(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/nested_state_machine_base.cpp b/src/generated/animation/nested_state_machine_base.cpp index 460ad2b..ef221f1 100644 --- a/src/generated/animation/nested_state_machine_base.cpp +++ b/src/generated/animation/nested_state_machine_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedStateMachineBase::clone() const { +Core* NestedStateMachineBase::clone() const +{ auto cloned = new NestedStateMachine(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/nested_trigger_base.cpp b/src/generated/animation/nested_trigger_base.cpp index 44bb423..526737b 100644 --- a/src/generated/animation/nested_trigger_base.cpp +++ b/src/generated/animation/nested_trigger_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedTriggerBase::clone() const { +Core* NestedTriggerBase::clone() const +{ auto cloned = new NestedTrigger(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_machine_base.cpp b/src/generated/animation/state_machine_base.cpp index 48d4aa4..7d34670 100644 --- a/src/generated/animation/state_machine_base.cpp +++ b/src/generated/animation/state_machine_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateMachineBase::clone() const { +Core* StateMachineBase::clone() const +{ auto cloned = new StateMachine(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_machine_bool_base.cpp b/src/generated/animation/state_machine_bool_base.cpp index 1cb9316..3db764d 100644 --- a/src/generated/animation/state_machine_bool_base.cpp +++ b/src/generated/animation/state_machine_bool_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateMachineBoolBase::clone() const { +Core* StateMachineBoolBase::clone() const +{ auto cloned = new StateMachineBool(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_machine_layer_base.cpp b/src/generated/animation/state_machine_layer_base.cpp index cc60f49..acafe6e 100644 --- a/src/generated/animation/state_machine_layer_base.cpp +++ b/src/generated/animation/state_machine_layer_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateMachineLayerBase::clone() const { +Core* StateMachineLayerBase::clone() const +{ auto cloned = new StateMachineLayer(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_machine_listener_base.cpp b/src/generated/animation/state_machine_listener_base.cpp index a5315fc..37e95cf 100644 --- a/src/generated/animation/state_machine_listener_base.cpp +++ b/src/generated/animation/state_machine_listener_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateMachineListenerBase::clone() const { +Core* StateMachineListenerBase::clone() const +{ auto cloned = new StateMachineListener(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_machine_number_base.cpp b/src/generated/animation/state_machine_number_base.cpp index 3d8e26b..b821aa4 100644 --- a/src/generated/animation/state_machine_number_base.cpp +++ b/src/generated/animation/state_machine_number_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateMachineNumberBase::clone() const { +Core* StateMachineNumberBase::clone() const +{ auto cloned = new StateMachineNumber(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_machine_trigger_base.cpp b/src/generated/animation/state_machine_trigger_base.cpp index 6363092..d7890be 100644 --- a/src/generated/animation/state_machine_trigger_base.cpp +++ b/src/generated/animation/state_machine_trigger_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateMachineTriggerBase::clone() const { +Core* StateMachineTriggerBase::clone() const +{ auto cloned = new StateMachineTrigger(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/state_transition_base.cpp b/src/generated/animation/state_transition_base.cpp index 4267482..f535fbd 100644 --- a/src/generated/animation/state_transition_base.cpp +++ b/src/generated/animation/state_transition_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StateTransitionBase::clone() const { +Core* StateTransitionBase::clone() const +{ auto cloned = new StateTransition(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/transition_bool_condition_base.cpp b/src/generated/animation/transition_bool_condition_base.cpp index a55fa3f..3b92f3d 100644 --- a/src/generated/animation/transition_bool_condition_base.cpp +++ b/src/generated/animation/transition_bool_condition_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TransitionBoolConditionBase::clone() const { +Core* TransitionBoolConditionBase::clone() const +{ auto cloned = new TransitionBoolCondition(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/transition_number_condition_base.cpp b/src/generated/animation/transition_number_condition_base.cpp index 6861e7f..537addf 100644 --- a/src/generated/animation/transition_number_condition_base.cpp +++ b/src/generated/animation/transition_number_condition_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TransitionNumberConditionBase::clone() const { +Core* TransitionNumberConditionBase::clone() const +{ auto cloned = new TransitionNumberCondition(); cloned->copy(*this); return cloned;
diff --git a/src/generated/animation/transition_trigger_condition_base.cpp b/src/generated/animation/transition_trigger_condition_base.cpp index c8544be..31dadd3 100644 --- a/src/generated/animation/transition_trigger_condition_base.cpp +++ b/src/generated/animation/transition_trigger_condition_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TransitionTriggerConditionBase::clone() const { +Core* TransitionTriggerConditionBase::clone() const +{ auto cloned = new TransitionTriggerCondition(); cloned->copy(*this); return cloned;
diff --git a/src/generated/artboard_base.cpp b/src/generated/artboard_base.cpp index 682be5e..612c270 100644 --- a/src/generated/artboard_base.cpp +++ b/src/generated/artboard_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ArtboardBase::clone() const { +Core* ArtboardBase::clone() const +{ auto cloned = new Artboard(); cloned->copy(*this); return cloned;
diff --git a/src/generated/assets/file_asset_contents_base.cpp b/src/generated/assets/file_asset_contents_base.cpp index dd9d526..8d0e376 100644 --- a/src/generated/assets/file_asset_contents_base.cpp +++ b/src/generated/assets/file_asset_contents_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* FileAssetContentsBase::clone() const { +Core* FileAssetContentsBase::clone() const +{ auto cloned = new FileAssetContents(); cloned->copy(*this); return cloned;
diff --git a/src/generated/assets/folder_base.cpp b/src/generated/assets/folder_base.cpp index 109aa68..ba27d04 100644 --- a/src/generated/assets/folder_base.cpp +++ b/src/generated/assets/folder_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* FolderBase::clone() const { +Core* FolderBase::clone() const +{ auto cloned = new Folder(); cloned->copy(*this); return cloned;
diff --git a/src/generated/assets/image_asset_base.cpp b/src/generated/assets/image_asset_base.cpp index 87da493..6b32b1d 100644 --- a/src/generated/assets/image_asset_base.cpp +++ b/src/generated/assets/image_asset_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ImageAssetBase::clone() const { +Core* ImageAssetBase::clone() const +{ auto cloned = new ImageAsset(); cloned->copy(*this); return cloned;
diff --git a/src/generated/backboard_base.cpp b/src/generated/backboard_base.cpp index 64ff18c..c5dfd7a 100644 --- a/src/generated/backboard_base.cpp +++ b/src/generated/backboard_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BackboardBase::clone() const { +Core* BackboardBase::clone() const +{ auto cloned = new Backboard(); cloned->copy(*this); return cloned;
diff --git a/src/generated/bones/bone_base.cpp b/src/generated/bones/bone_base.cpp index 2ecaf1d..0ad594f 100644 --- a/src/generated/bones/bone_base.cpp +++ b/src/generated/bones/bone_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* BoneBase::clone() const { +Core* BoneBase::clone() const +{ auto cloned = new Bone(); cloned->copy(*this); return cloned;
diff --git a/src/generated/bones/cubic_weight_base.cpp b/src/generated/bones/cubic_weight_base.cpp index c3e4300..4192b74 100644 --- a/src/generated/bones/cubic_weight_base.cpp +++ b/src/generated/bones/cubic_weight_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* CubicWeightBase::clone() const { +Core* CubicWeightBase::clone() const +{ auto cloned = new CubicWeight(); cloned->copy(*this); return cloned;
diff --git a/src/generated/bones/root_bone_base.cpp b/src/generated/bones/root_bone_base.cpp index c4e3a1f..faf1c91 100644 --- a/src/generated/bones/root_bone_base.cpp +++ b/src/generated/bones/root_bone_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* RootBoneBase::clone() const { +Core* RootBoneBase::clone() const +{ auto cloned = new RootBone(); cloned->copy(*this); return cloned;
diff --git a/src/generated/bones/skin_base.cpp b/src/generated/bones/skin_base.cpp index 20741ea..401c65f 100644 --- a/src/generated/bones/skin_base.cpp +++ b/src/generated/bones/skin_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* SkinBase::clone() const { +Core* SkinBase::clone() const +{ auto cloned = new Skin(); cloned->copy(*this); return cloned;
diff --git a/src/generated/bones/tendon_base.cpp b/src/generated/bones/tendon_base.cpp index 5bee774..866209b 100644 --- a/src/generated/bones/tendon_base.cpp +++ b/src/generated/bones/tendon_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TendonBase::clone() const { +Core* TendonBase::clone() const +{ auto cloned = new Tendon(); cloned->copy(*this); return cloned;
diff --git a/src/generated/bones/weight_base.cpp b/src/generated/bones/weight_base.cpp index 038e3ec..f62cb02 100644 --- a/src/generated/bones/weight_base.cpp +++ b/src/generated/bones/weight_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* WeightBase::clone() const { +Core* WeightBase::clone() const +{ auto cloned = new Weight(); cloned->copy(*this); return cloned;
diff --git a/src/generated/constraints/distance_constraint_base.cpp b/src/generated/constraints/distance_constraint_base.cpp index 00161b5..457fe8c 100644 --- a/src/generated/constraints/distance_constraint_base.cpp +++ b/src/generated/constraints/distance_constraint_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* DistanceConstraintBase::clone() const { +Core* DistanceConstraintBase::clone() const +{ auto cloned = new DistanceConstraint(); cloned->copy(*this); return cloned;
diff --git a/src/generated/constraints/ik_constraint_base.cpp b/src/generated/constraints/ik_constraint_base.cpp index 71df2b2..8a16dac 100644 --- a/src/generated/constraints/ik_constraint_base.cpp +++ b/src/generated/constraints/ik_constraint_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* IKConstraintBase::clone() const { +Core* IKConstraintBase::clone() const +{ auto cloned = new IKConstraint(); cloned->copy(*this); return cloned;
diff --git a/src/generated/constraints/rotation_constraint_base.cpp b/src/generated/constraints/rotation_constraint_base.cpp index 8ca5893..870570f 100644 --- a/src/generated/constraints/rotation_constraint_base.cpp +++ b/src/generated/constraints/rotation_constraint_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* RotationConstraintBase::clone() const { +Core* RotationConstraintBase::clone() const +{ auto cloned = new RotationConstraint(); cloned->copy(*this); return cloned;
diff --git a/src/generated/constraints/scale_constraint_base.cpp b/src/generated/constraints/scale_constraint_base.cpp index 7fe8a87..612fcd4 100644 --- a/src/generated/constraints/scale_constraint_base.cpp +++ b/src/generated/constraints/scale_constraint_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ScaleConstraintBase::clone() const { +Core* ScaleConstraintBase::clone() const +{ auto cloned = new ScaleConstraint(); cloned->copy(*this); return cloned;
diff --git a/src/generated/constraints/transform_constraint_base.cpp b/src/generated/constraints/transform_constraint_base.cpp index fbf2b48..0c594f0 100644 --- a/src/generated/constraints/transform_constraint_base.cpp +++ b/src/generated/constraints/transform_constraint_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TransformConstraintBase::clone() const { +Core* TransformConstraintBase::clone() const +{ auto cloned = new TransformConstraint(); cloned->copy(*this); return cloned;
diff --git a/src/generated/constraints/translation_constraint_base.cpp b/src/generated/constraints/translation_constraint_base.cpp index 0fe62c8..3de3c2a 100644 --- a/src/generated/constraints/translation_constraint_base.cpp +++ b/src/generated/constraints/translation_constraint_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TranslationConstraintBase::clone() const { +Core* TranslationConstraintBase::clone() const +{ auto cloned = new TranslationConstraint(); cloned->copy(*this); return cloned;
diff --git a/src/generated/draw_rules_base.cpp b/src/generated/draw_rules_base.cpp index 3e9f51c..67b9c81 100644 --- a/src/generated/draw_rules_base.cpp +++ b/src/generated/draw_rules_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* DrawRulesBase::clone() const { +Core* DrawRulesBase::clone() const +{ auto cloned = new DrawRules(); cloned->copy(*this); return cloned;
diff --git a/src/generated/draw_target_base.cpp b/src/generated/draw_target_base.cpp index 1de0a4d..0578be9 100644 --- a/src/generated/draw_target_base.cpp +++ b/src/generated/draw_target_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* DrawTargetBase::clone() const { +Core* DrawTargetBase::clone() const +{ auto cloned = new DrawTarget(); cloned->copy(*this); return cloned;
diff --git a/src/generated/nested_artboard_base.cpp b/src/generated/nested_artboard_base.cpp index 4daa8c3..46a277e 100644 --- a/src/generated/nested_artboard_base.cpp +++ b/src/generated/nested_artboard_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NestedArtboardBase::clone() const { +Core* NestedArtboardBase::clone() const +{ auto cloned = new NestedArtboard(); cloned->copy(*this); return cloned;
diff --git a/src/generated/node_base.cpp b/src/generated/node_base.cpp index 160a2f8..7f144d5 100644 --- a/src/generated/node_base.cpp +++ b/src/generated/node_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* NodeBase::clone() const { +Core* NodeBase::clone() const +{ auto cloned = new Node(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/clipping_shape_base.cpp b/src/generated/shapes/clipping_shape_base.cpp index fbd7cb9..2c28b3a 100644 --- a/src/generated/shapes/clipping_shape_base.cpp +++ b/src/generated/shapes/clipping_shape_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ClippingShapeBase::clone() const { +Core* ClippingShapeBase::clone() const +{ auto cloned = new ClippingShape(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/contour_mesh_vertex_base.cpp b/src/generated/shapes/contour_mesh_vertex_base.cpp index a19d016..8ced9fd 100644 --- a/src/generated/shapes/contour_mesh_vertex_base.cpp +++ b/src/generated/shapes/contour_mesh_vertex_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ContourMeshVertexBase::clone() const { +Core* ContourMeshVertexBase::clone() const +{ auto cloned = new ContourMeshVertex(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/cubic_asymmetric_vertex_base.cpp b/src/generated/shapes/cubic_asymmetric_vertex_base.cpp index 15ade38..62b665a 100644 --- a/src/generated/shapes/cubic_asymmetric_vertex_base.cpp +++ b/src/generated/shapes/cubic_asymmetric_vertex_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* CubicAsymmetricVertexBase::clone() const { +Core* CubicAsymmetricVertexBase::clone() const +{ auto cloned = new CubicAsymmetricVertex(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/cubic_detached_vertex_base.cpp b/src/generated/shapes/cubic_detached_vertex_base.cpp index 87c799f..22f88ba 100644 --- a/src/generated/shapes/cubic_detached_vertex_base.cpp +++ b/src/generated/shapes/cubic_detached_vertex_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* CubicDetachedVertexBase::clone() const { +Core* CubicDetachedVertexBase::clone() const +{ auto cloned = new CubicDetachedVertex(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/cubic_mirrored_vertex_base.cpp b/src/generated/shapes/cubic_mirrored_vertex_base.cpp index df88cf4..fb1731b 100644 --- a/src/generated/shapes/cubic_mirrored_vertex_base.cpp +++ b/src/generated/shapes/cubic_mirrored_vertex_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* CubicMirroredVertexBase::clone() const { +Core* CubicMirroredVertexBase::clone() const +{ auto cloned = new CubicMirroredVertex(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/ellipse_base.cpp b/src/generated/shapes/ellipse_base.cpp index 7546e22..df160bb 100644 --- a/src/generated/shapes/ellipse_base.cpp +++ b/src/generated/shapes/ellipse_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* EllipseBase::clone() const { +Core* EllipseBase::clone() const +{ auto cloned = new Ellipse(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/image_base.cpp b/src/generated/shapes/image_base.cpp index ae3ed39..60bb78e 100644 --- a/src/generated/shapes/image_base.cpp +++ b/src/generated/shapes/image_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ImageBase::clone() const { +Core* ImageBase::clone() const +{ auto cloned = new Image(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/mesh_base.cpp b/src/generated/shapes/mesh_base.cpp index 5cae283..e30a683 100644 --- a/src/generated/shapes/mesh_base.cpp +++ b/src/generated/shapes/mesh_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* MeshBase::clone() const { +Core* MeshBase::clone() const +{ auto cloned = new Mesh(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/mesh_vertex_base.cpp b/src/generated/shapes/mesh_vertex_base.cpp index 45171ac..ff36262 100644 --- a/src/generated/shapes/mesh_vertex_base.cpp +++ b/src/generated/shapes/mesh_vertex_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* MeshVertexBase::clone() const { +Core* MeshVertexBase::clone() const +{ auto cloned = new MeshVertex(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/fill_base.cpp b/src/generated/shapes/paint/fill_base.cpp index 481495d..1b2dbbc 100644 --- a/src/generated/shapes/paint/fill_base.cpp +++ b/src/generated/shapes/paint/fill_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* FillBase::clone() const { +Core* FillBase::clone() const +{ auto cloned = new Fill(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/gradient_stop_base.cpp b/src/generated/shapes/paint/gradient_stop_base.cpp index d9e3a95..0ff71eb 100644 --- a/src/generated/shapes/paint/gradient_stop_base.cpp +++ b/src/generated/shapes/paint/gradient_stop_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* GradientStopBase::clone() const { +Core* GradientStopBase::clone() const +{ auto cloned = new GradientStop(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/linear_gradient_base.cpp b/src/generated/shapes/paint/linear_gradient_base.cpp index f446ddf..ad261e7 100644 --- a/src/generated/shapes/paint/linear_gradient_base.cpp +++ b/src/generated/shapes/paint/linear_gradient_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* LinearGradientBase::clone() const { +Core* LinearGradientBase::clone() const +{ auto cloned = new LinearGradient(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/radial_gradient_base.cpp b/src/generated/shapes/paint/radial_gradient_base.cpp index 42a0820..79b00d6 100644 --- a/src/generated/shapes/paint/radial_gradient_base.cpp +++ b/src/generated/shapes/paint/radial_gradient_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* RadialGradientBase::clone() const { +Core* RadialGradientBase::clone() const +{ auto cloned = new RadialGradient(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/solid_color_base.cpp b/src/generated/shapes/paint/solid_color_base.cpp index 37e350f..df57f7f 100644 --- a/src/generated/shapes/paint/solid_color_base.cpp +++ b/src/generated/shapes/paint/solid_color_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* SolidColorBase::clone() const { +Core* SolidColorBase::clone() const +{ auto cloned = new SolidColor(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/stroke_base.cpp b/src/generated/shapes/paint/stroke_base.cpp index b260e98..0c3acba 100644 --- a/src/generated/shapes/paint/stroke_base.cpp +++ b/src/generated/shapes/paint/stroke_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StrokeBase::clone() const { +Core* StrokeBase::clone() const +{ auto cloned = new Stroke(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/paint/trim_path_base.cpp b/src/generated/shapes/paint/trim_path_base.cpp index 9a145b7..fb319ca 100644 --- a/src/generated/shapes/paint/trim_path_base.cpp +++ b/src/generated/shapes/paint/trim_path_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TrimPathBase::clone() const { +Core* TrimPathBase::clone() const +{ auto cloned = new TrimPath(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/points_path_base.cpp b/src/generated/shapes/points_path_base.cpp index 4e87789..27169a8 100644 --- a/src/generated/shapes/points_path_base.cpp +++ b/src/generated/shapes/points_path_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* PointsPathBase::clone() const { +Core* PointsPathBase::clone() const +{ auto cloned = new PointsPath(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/polygon_base.cpp b/src/generated/shapes/polygon_base.cpp index 4dfa011..96214c5 100644 --- a/src/generated/shapes/polygon_base.cpp +++ b/src/generated/shapes/polygon_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* PolygonBase::clone() const { +Core* PolygonBase::clone() const +{ auto cloned = new Polygon(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/rectangle_base.cpp b/src/generated/shapes/rectangle_base.cpp index db0d78f..47a83fe 100644 --- a/src/generated/shapes/rectangle_base.cpp +++ b/src/generated/shapes/rectangle_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* RectangleBase::clone() const { +Core* RectangleBase::clone() const +{ auto cloned = new Rectangle(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/shape_base.cpp b/src/generated/shapes/shape_base.cpp index 7595b31..595afa6 100644 --- a/src/generated/shapes/shape_base.cpp +++ b/src/generated/shapes/shape_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* ShapeBase::clone() const { +Core* ShapeBase::clone() const +{ auto cloned = new Shape(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/star_base.cpp b/src/generated/shapes/star_base.cpp index 1df8368..3b753c2 100644 --- a/src/generated/shapes/star_base.cpp +++ b/src/generated/shapes/star_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StarBase::clone() const { +Core* StarBase::clone() const +{ auto cloned = new Star(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/straight_vertex_base.cpp b/src/generated/shapes/straight_vertex_base.cpp index 19ff88c..a7c99c1 100644 --- a/src/generated/shapes/straight_vertex_base.cpp +++ b/src/generated/shapes/straight_vertex_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* StraightVertexBase::clone() const { +Core* StraightVertexBase::clone() const +{ auto cloned = new StraightVertex(); cloned->copy(*this); return cloned;
diff --git a/src/generated/shapes/triangle_base.cpp b/src/generated/shapes/triangle_base.cpp index e7debc1..c4f7e95 100644 --- a/src/generated/shapes/triangle_base.cpp +++ b/src/generated/shapes/triangle_base.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Core* TriangleBase::clone() const { +Core* TriangleBase::clone() const +{ auto cloned = new Triangle(); cloned->copy(*this); return cloned;
diff --git a/src/hittest_command_path.cpp b/src/hittest_command_path.cpp index ef5a784..94fe025 100644 --- a/src/hittest_command_path.cpp +++ b/src/hittest_command_path.cpp
@@ -12,17 +12,20 @@ void HitTestCommandPath::reset() { m_Tester.reset(m_Area); } -void HitTestCommandPath::fillRule(FillRule value) { +void HitTestCommandPath::fillRule(FillRule value) +{ // remember this here, and pass it to test() m_FillRule = value; } -void HitTestCommandPath::addPath(CommandPath* path, const Mat2D& transform) { +void HitTestCommandPath::addPath(CommandPath* path, const Mat2D& transform) +{ assert(false); // not supported } -RenderPath* HitTestCommandPath::renderPath() { +RenderPath* HitTestCommandPath::renderPath() +{ assert(false); // not supported return nullptr; @@ -32,7 +35,8 @@ 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) { +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)); }
diff --git a/src/importers/artboard_importer.cpp b/src/importers/artboard_importer.cpp index c831324..db008ba 100644 --- a/src/importers/artboard_importer.cpp +++ b/src/importers/artboard_importer.cpp
@@ -10,17 +10,20 @@ void ArtboardImporter::addComponent(Core* object) { m_Artboard->addObject(object); } -void ArtboardImporter::addAnimation(LinearAnimation* animation) { +void ArtboardImporter::addAnimation(LinearAnimation* animation) +{ m_Artboard->addAnimation(animation); } -void ArtboardImporter::addStateMachine(StateMachine* stateMachine) { +void ArtboardImporter::addStateMachine(StateMachine* stateMachine) +{ m_Artboard->addStateMachine(stateMachine); } StatusCode ArtboardImporter::resolve() { return m_Artboard->initialize(); } -bool ArtboardImporter::readNullObject() { +bool ArtboardImporter::readNullObject() +{ addComponent(nullptr); return true; } \ No newline at end of file
diff --git a/src/importers/backboard_importer.cpp b/src/importers/backboard_importer.cpp index 46b3303..70eb109 100644 --- a/src/importers/backboard_importer.cpp +++ b/src/importers/backboard_importer.cpp
@@ -8,12 +8,15 @@ using namespace rive; BackboardImporter::BackboardImporter(Backboard* backboard) : - m_Backboard(backboard), m_NextArtboardId(0) {} -void BackboardImporter::addNestedArtboard(NestedArtboard* artboard) { + m_Backboard(backboard), m_NextArtboardId(0) +{} +void BackboardImporter::addNestedArtboard(NestedArtboard* artboard) +{ m_NestedArtboards.push_back(artboard); } -void BackboardImporter::addFileAsset(FileAsset* asset) { +void BackboardImporter::addFileAsset(FileAsset* asset) +{ m_FileAssets.push_back(asset); { // EDITOR BUG 4204 @@ -22,12 +25,17 @@ // https://github.com/rive-app/rive/issues/4204 std::unordered_set<uint32_t> ids; uint32_t nextId = 1; - for (auto asset : m_FileAssets) { - if (ids.count(asset->assetId())) { + for (auto asset : m_FileAssets) + { + if (ids.count(asset->assetId())) + { asset->assetId(nextId); - } else { + } + else + { ids.insert(asset->assetId()); - if (asset->assetId() >= nextId) { + if (asset->assetId() >= nextId) + { nextId = asset->assetId() + 1; } } @@ -37,28 +45,35 @@ } } -void BackboardImporter::addFileAssetReferencer(FileAssetReferencer* referencer) { +void BackboardImporter::addFileAssetReferencer(FileAssetReferencer* referencer) +{ m_FileAssetReferencers.push_back(referencer); } -void BackboardImporter::addArtboard(Artboard* artboard) { +void BackboardImporter::addArtboard(Artboard* artboard) +{ m_ArtboardLookup[m_NextArtboardId++] = artboard; } void BackboardImporter::addMissingArtboard() { m_NextArtboardId++; } -StatusCode BackboardImporter::resolve() { +StatusCode BackboardImporter::resolve() +{ - for (auto nestedArtboard : m_NestedArtboards) { + for (auto nestedArtboard : m_NestedArtboards) + { auto itr = m_ArtboardLookup.find(nestedArtboard->artboardId()); - if (itr != m_ArtboardLookup.end()) { + if (itr != m_ArtboardLookup.end()) + { auto artboard = itr->second; - if (artboard != nullptr) { + if (artboard != nullptr) + { nestedArtboard->nest(artboard); } } } - for (auto referencer : m_FileAssetReferencers) { + for (auto referencer : m_FileAssetReferencers) + { referencer->assets(m_FileAssets); }
diff --git a/src/importers/file_asset_importer.cpp b/src/importers/file_asset_importer.cpp index 7a199ff..dc4a214 100644 --- a/src/importers/file_asset_importer.cpp +++ b/src/importers/file_asset_importer.cpp
@@ -10,21 +10,26 @@ FileAssetImporter::FileAssetImporter(FileAsset* fileAsset, FileAssetResolver* assetResolver, Factory* factory) : - m_FileAsset(fileAsset), m_FileAssetResolver(assetResolver), m_Factory(factory) {} + m_FileAsset(fileAsset), m_FileAssetResolver(assetResolver), m_Factory(factory) +{} -void FileAssetImporter::loadContents(std::unique_ptr<FileAssetContents> contents) { +void FileAssetImporter::loadContents(std::unique_ptr<FileAssetContents> contents) +{ // we should only ever be called once assert(!m_Content); m_Content = std::move(contents); auto data = m_Content->bytes(); - if (m_FileAsset->decode(data, m_Factory)) { + if (m_FileAsset->decode(data, m_Factory)) + { m_LoadedContents = true; } } -StatusCode FileAssetImporter::resolve() { - if (!m_LoadedContents && m_FileAssetResolver != nullptr) { +StatusCode FileAssetImporter::resolve() +{ + if (!m_LoadedContents && m_FileAssetResolver != nullptr) + { // Contents weren't available in-band, or they couldn't be decoded. Try // to find them out of band. m_FileAssetResolver->loadContents(*m_FileAsset);
diff --git a/src/importers/keyed_object_importer.cpp b/src/importers/keyed_object_importer.cpp index c8477c3..9e93cc9 100644 --- a/src/importers/keyed_object_importer.cpp +++ b/src/importers/keyed_object_importer.cpp
@@ -7,6 +7,7 @@ KeyedObjectImporter::KeyedObjectImporter(KeyedObject* keyedObject) : m_KeyedObject(keyedObject) {} -void KeyedObjectImporter::addKeyedProperty(std::unique_ptr<KeyedProperty> property) { +void KeyedObjectImporter::addKeyedProperty(std::unique_ptr<KeyedProperty> property) +{ m_KeyedObject->addKeyedProperty(std::move(property)); } \ No newline at end of file
diff --git a/src/importers/keyed_property_importer.cpp b/src/importers/keyed_property_importer.cpp index 6789b0f..8efb275 100644 --- a/src/importers/keyed_property_importer.cpp +++ b/src/importers/keyed_property_importer.cpp
@@ -7,14 +7,17 @@ KeyedPropertyImporter::KeyedPropertyImporter(LinearAnimation* animation, KeyedProperty* keyedProperty) : - m_Animation(animation), m_KeyedProperty(keyedProperty) {} + m_Animation(animation), m_KeyedProperty(keyedProperty) +{} -void KeyedPropertyImporter::addKeyFrame(std::unique_ptr<KeyFrame> keyFrame) { +void KeyedPropertyImporter::addKeyFrame(std::unique_ptr<KeyFrame> keyFrame) +{ keyFrame->computeSeconds(m_Animation->fps()); m_KeyedProperty->addKeyFrame(std::move(keyFrame)); } -bool KeyedPropertyImporter::readNullObject() { +bool KeyedPropertyImporter::readNullObject() +{ // We don't need to add the null keyframe as nothing references them, but we // do need to not allow the null to propagate up. return true;
diff --git a/src/importers/layer_state_importer.cpp b/src/importers/layer_state_importer.cpp index 5ac3056..3dc48ee 100644 --- a/src/importers/layer_state_importer.cpp +++ b/src/importers/layer_state_importer.cpp
@@ -7,12 +7,15 @@ using namespace rive; LayerStateImporter::LayerStateImporter(LayerState* state) : m_State(state) {} -void LayerStateImporter::addTransition(StateTransition* transition) { +void LayerStateImporter::addTransition(StateTransition* transition) +{ m_State->addTransition(transition); } -bool LayerStateImporter::addBlendAnimation(BlendAnimation* animation) { - if (!m_State->is<BlendState>()) { +bool LayerStateImporter::addBlendAnimation(BlendAnimation* animation) +{ + if (!m_State->is<BlendState>()) + { return false; } auto blendState = m_State->as<BlendState>(); @@ -21,17 +24,22 @@ return true; } -StatusCode LayerStateImporter::resolve() { - if (m_State->is<BlendState>()) { +StatusCode LayerStateImporter::resolve() +{ + if (m_State->is<BlendState>()) + { auto blendState = m_State->as<BlendState>(); - for (auto transition : blendState->m_Transitions) { - if (!transition->is<BlendStateTransition>()) { + for (auto transition : blendState->m_Transitions) + { + if (!transition->is<BlendStateTransition>()) + { continue; } auto blendStateTransition = transition->as<BlendStateTransition>(); size_t exitId = blendStateTransition->exitBlendAnimationId(); - if (exitId < blendState->m_Animations.size()) { + if (exitId < blendState->m_Animations.size()) + { blendStateTransition->m_ExitBlendAnimation = blendState->m_Animations[exitId]; } }
diff --git a/src/importers/linear_animation_importer.cpp b/src/importers/linear_animation_importer.cpp index 43a9274..b6ab77f 100644 --- a/src/importers/linear_animation_importer.cpp +++ b/src/importers/linear_animation_importer.cpp
@@ -6,8 +6,10 @@ using namespace rive; LinearAnimationImporter::LinearAnimationImporter(LinearAnimation* animation) : - m_Animation(animation) {} + m_Animation(animation) +{} -void LinearAnimationImporter::addKeyedObject(std::unique_ptr<KeyedObject> object) { +void LinearAnimationImporter::addKeyedObject(std::unique_ptr<KeyedObject> object) +{ m_Animation->addKeyedObject(std::move(object)); } \ No newline at end of file
diff --git a/src/importers/state_machine_importer.cpp b/src/importers/state_machine_importer.cpp index f5aa9aa..7994c37 100644 --- a/src/importers/state_machine_importer.cpp +++ b/src/importers/state_machine_importer.cpp
@@ -8,19 +8,23 @@ StateMachineImporter::StateMachineImporter(StateMachine* machine) : m_StateMachine(machine) {} -void StateMachineImporter::addLayer(std::unique_ptr<StateMachineLayer> layer) { +void StateMachineImporter::addLayer(std::unique_ptr<StateMachineLayer> layer) +{ m_StateMachine->addLayer(std::move(layer)); } -void StateMachineImporter::addInput(std::unique_ptr<StateMachineInput> input) { +void StateMachineImporter::addInput(std::unique_ptr<StateMachineInput> input) +{ m_StateMachine->addInput(std::move(input)); } -void StateMachineImporter::addListener(std::unique_ptr<StateMachineListener> listener) { +void StateMachineImporter::addListener(std::unique_ptr<StateMachineListener> listener) +{ m_StateMachine->addListener(std::move(listener)); } -bool StateMachineImporter::readNullObject() { +bool StateMachineImporter::readNullObject() +{ // Hard assumption that we won't add new layer types... m_StateMachine->addInput(nullptr); return true;
diff --git a/src/importers/state_machine_layer_importer.cpp b/src/importers/state_machine_layer_importer.cpp index 6361884..f56899a 100644 --- a/src/importers/state_machine_layer_importer.cpp +++ b/src/importers/state_machine_layer_importer.cpp
@@ -8,27 +8,36 @@ using namespace rive; StateMachineLayerImporter::StateMachineLayerImporter(StateMachineLayer* layer, const Artboard* artboard) : - m_Layer(layer), m_Artboard(artboard) {} + m_Layer(layer), m_Artboard(artboard) +{} void StateMachineLayerImporter::addState(LayerState* state) { m_Layer->addState(state); } -StatusCode StateMachineLayerImporter::resolve() { +StatusCode StateMachineLayerImporter::resolve() +{ - for (auto state : m_Layer->m_States) { - if (state->is<AnimationState>()) { + for (auto state : m_Layer->m_States) + { + if (state->is<AnimationState>()) + { auto animationState = state->as<AnimationState>(); - if (animationState->animationId() < m_Artboard->animationCount()) { + if (animationState->animationId() < m_Artboard->animationCount()) + { animationState->m_Animation = m_Artboard->animation(animationState->animationId()); - if (animationState->m_Animation == nullptr) { + if (animationState->m_Animation == nullptr) + { return StatusCode::MissingObject; } } } - for (auto transition : state->m_Transitions) { - if ((size_t)transition->stateToId() < m_Layer->m_States.size()) { + for (auto transition : state->m_Transitions) + { + if ((size_t)transition->stateToId() < m_Layer->m_States.size()) + { transition->m_StateTo = m_Layer->m_States[transition->stateToId()]; - - } else { + } + else + { return StatusCode::InvalidObject; } } @@ -36,7 +45,8 @@ return StatusCode::Ok; } -bool StateMachineLayerImporter::readNullObject() { +bool StateMachineLayerImporter::readNullObject() +{ // Add an 'empty' generic state that can be transitioned to/from but doesn't // effectively do anything. This allows us to deal with unexpected new state // types the runtime won't be able to understand. It'll still be able to
diff --git a/src/importers/state_machine_listener_importer.cpp b/src/importers/state_machine_listener_importer.cpp index 4e31707..d2ece94 100644 --- a/src/importers/state_machine_listener_importer.cpp +++ b/src/importers/state_machine_listener_importer.cpp
@@ -5,9 +5,11 @@ using namespace rive; StateMachineListenerImporter::StateMachineListenerImporter(StateMachineListener* listener) : - m_StateMachineListener(listener) {} + m_StateMachineListener(listener) +{} -void StateMachineListenerImporter::addAction(std::unique_ptr<ListenerAction> action) { +void StateMachineListenerImporter::addAction(std::unique_ptr<ListenerAction> action) +{ m_StateMachineListener->addAction(std::move(action)); }
diff --git a/src/importers/state_transition_importer.cpp b/src/importers/state_transition_importer.cpp index d340460..beb6b45 100644 --- a/src/importers/state_transition_importer.cpp +++ b/src/importers/state_transition_importer.cpp
@@ -5,8 +5,10 @@ using namespace rive; StateTransitionImporter::StateTransitionImporter(StateTransition* transition) : - m_Transition(transition) {} -void StateTransitionImporter::addCondition(TransitionCondition* condition) { + m_Transition(transition) +{} +void StateTransitionImporter::addCondition(TransitionCondition* condition) +{ m_Transition->addCondition(condition); }
diff --git a/src/math/aabb.cpp b/src/math/aabb.cpp index 50a9797..65cb3e8 100644 --- a/src/math/aabb.cpp +++ b/src/math/aabb.cpp
@@ -4,15 +4,18 @@ using namespace rive; -AABB::AABB(Span<Vec2D> pts) { - if (pts.size() == 0) { +AABB::AABB(Span<Vec2D> pts) +{ + if (pts.size() == 0) + { minX = minY = maxX = maxY = 0; return; } float L = pts[0].x, R = L, T = pts[0].y, B = T; - for (size_t i = 1; i < pts.size(); ++i) { + for (size_t i = 1; i < pts.size(); ++i) + { L = std::min(L, pts[i].x); R = std::max(R, pts[i].x); T = std::min(T, pts[i].y); @@ -28,7 +31,8 @@ static inline int graphics_round(float x) { return (int)graphics_roundf(x); } -IAABB AABB::round() const { +IAABB AABB::round() const +{ return { graphics_round(left()), graphics_round(top()), @@ -39,22 +43,28 @@ void AABB::expandTo(AABB& out, const Vec2D& point) { expandTo(out, point.x, point.y); } -void AABB::expandTo(AABB& out, float x, float y) { - if (x < out.minX) { +void AABB::expandTo(AABB& out, float x, float y) +{ + if (x < out.minX) + { out.minX = x; } - if (x > out.maxX) { + if (x > out.maxX) + { out.maxX = x; } - if (y < out.minY) { + if (y < out.minY) + { out.minY = y; } - if (y > out.maxY) { + if (y > out.maxY) + { out.maxY = y; } } -void AABB::join(AABB& out, const AABB& a, const AABB& b) { +void AABB::join(AABB& out, const AABB& a, const AABB& b) +{ out.minX = std::min(a.minX, b.minX); out.minY = std::min(a.minY, b.minY); out.maxX = std::max(a.maxX, b.maxX);
diff --git a/src/math/contour_measure.cpp b/src/math/contour_measure.cpp index 5f4f887..5971a2d 100644 --- a/src/math/contour_measure.cpp +++ b/src/math/contour_measure.cpp
@@ -10,7 +10,8 @@ using namespace rive; -enum SegmentType { // must fit in 2 bits +enum SegmentType +{ // must fit in 2 bits kLine, kQuad, kCubic, @@ -25,11 +26,13 @@ std::vector<Vec2D>&& pts, float length, bool isClosed) : - m_segments(std::move(segs)), m_points(std::move(pts)), m_length(length), m_isClosed(isClosed) {} + m_segments(std::move(segs)), m_points(std::move(pts)), m_length(length), m_isClosed(isClosed) +{} // Return index of the segment that contains distance, // or the last segment if distance == m_distance -size_t ContourMeasure::findSegment(float distance) const { +size_t ContourMeasure::findSegment(float distance) const +{ assert(m_segments.front().m_distance > 0); assert(m_segments.back().m_distance == m_length); @@ -43,7 +46,8 @@ return iter - m_segments.begin(); } -static ContourMeasure::PosTan eval_quad(const Vec2D pts[], float t) { +static ContourMeasure::PosTan eval_quad(const Vec2D pts[], float t) +{ assert(t >= 0 && t <= 1); const EvalQuad eval(pts); @@ -58,7 +62,8 @@ }; } -static ContourMeasure::PosTan eval_cubic(const Vec2D pts[], float t) { +static ContourMeasure::PosTan eval_cubic(const Vec2D pts[], float t) +{ assert(t >= 0 && t <= 1); const EvalCubic eval(pts); @@ -74,12 +79,20 @@ }; } -void ContourMeasure::Segment::extract(RawPath* dst, const Vec2D pts[]) const { +void ContourMeasure::Segment::extract(RawPath* dst, const Vec2D pts[]) const +{ pts += m_ptIndex; - switch (m_type) { - case SegmentType::kLine: dst->line(pts[1]); break; - case SegmentType::kQuad: dst->quad(pts[1], pts[2]); break; - case SegmentType::kCubic: dst->cubic(pts[1], pts[2], pts[3]); break; + switch (m_type) + { + case SegmentType::kLine: + dst->line(pts[1]); + break; + case SegmentType::kQuad: + dst->quad(pts[1], pts[2]); + break; + case SegmentType::kCubic: + dst->cubic(pts[1], pts[2], pts[3]); + break; } } @@ -87,29 +100,34 @@ float fromT, float toT, const Vec2D pts[], - bool moveTo) const { + bool moveTo) const +{ assert(fromT <= toT); pts += m_ptIndex; Vec2D tmp[4]; - switch (m_type) { + switch (m_type) + { case SegmentType::kLine: line_extract(pts, fromT, toT, tmp); - if (moveTo) { + if (moveTo) + { dst->move(tmp[0]); } dst->line(tmp[1]); break; case SegmentType::kQuad: quad_extract(pts, fromT, toT, tmp); - if (moveTo) { + if (moveTo) + { dst->move(tmp[0]); } dst->quad(tmp[1], tmp[2]); break; case SegmentType::kCubic: cubic_extract(pts, fromT, toT, tmp); - if (moveTo) { + if (moveTo) + { dst->move(tmp[0]); } dst->cubic(tmp[1], tmp[2], tmp[3]); @@ -117,15 +135,18 @@ } } -ContourMeasure::PosTan ContourMeasure::getPosTan(float distance) const { +ContourMeasure::PosTan ContourMeasure::getPosTan(float distance) const +{ // specal-case end of the contour - if (distance >= m_length) { + if (distance >= m_length) + { size_t N = m_points.size(); assert(N > 1); return {m_points[N - 1], (m_points[N - 1] - m_points[N - 2]).normalized()}; } - if (distance < 0) { + if (distance < 0) + { distance = 0; } @@ -142,7 +163,8 @@ const float relD = (distance - prevD) / (currD - prevD); assert(relD >= 0 && relD <= 1); - if (seg.m_type == SegmentType::kLine) { + if (seg.m_type == SegmentType::kLine) + { assert(seg.m_ptIndex + 1 < m_points.size()); auto p0 = m_points[seg.m_ptIndex + 0]; auto p1 = m_points[seg.m_ptIndex + 1]; @@ -153,9 +175,11 @@ } float prevT = 0; - if (i > 0) { + if (i > 0) + { auto prev = m_segments[i - 1]; - if (prev.m_ptIndex == seg.m_ptIndex) { + if (prev.m_ptIndex == seg.m_ptIndex) + { prevT = prev.getT(); } } @@ -163,34 +187,42 @@ const float t = lerp(prevT, seg.getT(), relD); assert(t >= 0 && t <= 1); - if (seg.m_type == SegmentType::kQuad) { + if (seg.m_type == SegmentType::kQuad) + { assert(seg.m_ptIndex + 2 < m_points.size()); return eval_quad(&m_points[seg.m_ptIndex], t); - } else { + } + else + { assert(seg.m_type == SegmentType::kCubic); assert(seg.m_ptIndex + 3 < m_points.size()); return eval_cubic(&m_points[seg.m_ptIndex], t); } } -static const ContourMeasure::Segment* next_segment_beginning(const ContourMeasure::Segment* seg) { +static const ContourMeasure::Segment* next_segment_beginning(const ContourMeasure::Segment* seg) +{ auto startingPtIndex = seg->m_ptIndex; - do { + do + { seg += 1; } while (seg->m_ptIndex == startingPtIndex); return seg; } // Compute the (interpolated) t for a distance within the index'th segment -static float compute_t(Span<const ContourMeasure::Segment> segs, size_t index, float distance) { +static float compute_t(Span<const ContourMeasure::Segment> segs, size_t index, float distance) +{ const auto seg = segs[index]; assert(distance <= seg.m_distance); float prevDist = 0, prevT = 0; - if (index > 0) { + if (index > 0) + { const auto prev = segs[index - 1]; prevDist = prev.m_distance; - if (prev.m_ptIndex == seg.m_ptIndex) { + if (prev.m_ptIndex == seg.m_ptIndex) + { prevT = prev.getT(); } } @@ -203,11 +235,13 @@ void ContourMeasure::getSegment(float startDist, float endDist, RawPath* dst, - bool startWithMove) const { + bool startWithMove) const +{ // sanitize the inputs startDist = std::max(0.f, startDist); endDist = std::min(m_length, endDist); - if (startDist >= endDist) { + if (startDist >= endDist) + { return; } @@ -220,14 +254,18 @@ const auto startT = compute_t(m_segments, startIndex, startDist); const auto endT = compute_t(m_segments, endIndex, endDist); - if (start.m_ptIndex == end.m_ptIndex) { + if (start.m_ptIndex == end.m_ptIndex) + { start.extract(dst, startT, endT, m_points.data(), startWithMove); - } else { + } + else + { start.extract(dst, startT, 1, m_points.data(), startWithMove); // now scoop up all the segments after start, and before end const auto* seg = next_segment_beginning(&m_segments[startIndex]); - while (seg->m_ptIndex != end.m_ptIndex) { + while (seg->m_ptIndex != end.m_ptIndex) + { seg->extract(dst, m_points.data()); seg = next_segment_beginning(seg); } @@ -237,9 +275,11 @@ } } -void ContourMeasure::dump() const { +void ContourMeasure::dump() const +{ printf("length %g pts %zu segs %zu\n", m_length, m_points.size(), m_segments.size()); - for (const auto& s : m_segments) { + for (const auto& s : m_segments) + { printf(" %g %d %g %d\n", s.m_distance, s.m_ptIndex, s.getT(), s.m_type); } } @@ -248,18 +288,22 @@ constexpr auto kMaxDot30 = ContourMeasure::kMaxDot30; -static inline unsigned toDot30(float x) { +static inline unsigned toDot30(float x) +{ assert(x >= 0 && x < 1); return (unsigned)(x * (1 << 30)); } static void addSeg(std::vector<ContourMeasure::Segment>& array, const ContourMeasure::Segment& seg, - bool required = false) { - if (array.size() > 0) { + bool required = false) +{ + if (array.size() > 0) + { const auto& last = array.back(); assert(last.m_distance <= seg.m_distance); - if (last.m_distance == seg.m_distance) { + if (last.m_distance == seg.m_distance) + { assert(!required); return; } @@ -274,14 +318,16 @@ float ContourMeasureIter::addQuadSegs(std::vector<ContourMeasure::Segment>& segs, const Vec2D pts[], uint32_t ptIndex, - float distance) const { + float distance) const +{ const int count = computeApproximatingQuadLineSegments(pts, m_invTolerance); const float dt = 1.0f / count; const EvalQuad eval(pts); float t = dt; Vec2D prev = pts[0]; - for (int i = 1; i < count; ++i) { + for (int i = 1; i < count; ++i) + { auto next = eval(t); distance += (next - prev).length(); addSeg(segs, {distance, ptIndex, toDot30(t), SegmentType::kQuad}); @@ -296,14 +342,16 @@ float ContourMeasureIter::addCubicSegs(std::vector<ContourMeasure::Segment>& segs, const Vec2D pts[], uint32_t ptIndex, - float distance) const { + float distance) const +{ const int count = computeApproximatingCubicLineSegments(pts, m_invTolerance); const float dt = 1.0f / count; const EvalCubic eval(pts); float t = dt; Vec2D prev = pts[0]; - for (int i = 1; i < count; ++i) { + for (int i = 1; i < count; ++i) + { auto next = eval(t); distance += (next - prev).length(); addSeg(segs, {distance, ptIndex, toDot30(t), SegmentType::kCubic}); @@ -315,7 +363,8 @@ return distance; } -void ContourMeasureIter::reset(const RawPath& path, float tolerance) { +void ContourMeasureIter::reset(const RawPath& path, float tolerance) +{ m_iter = path.begin(); m_end = path.end(); m_srcPoints = path.points().data(); @@ -327,16 +376,20 @@ // Can return null if either it encountered an empty contour (length == 0) // or the iterator is exhausted. // -rcp<ContourMeasure> ContourMeasureIter::tryNext() { +rcp<ContourMeasure> ContourMeasureIter::tryNext() +{ std::vector<ContourMeasure::Segment> segs; std::vector<Vec2D> pts; float distance = 0; bool isClosed = false; - for (; m_iter != m_end; ++m_iter) { + for (; m_iter != m_end; ++m_iter) + { auto [verb, iterPts] = *m_iter; - if (verb == PathVerb::move) { - if (!pts.empty()) { + if (verb == PathVerb::move) + { + if (!pts.empty()) + { break; // We've alredy seen a move. Save this one for next time. } pts.push_back(iterPts[0]); @@ -346,56 +399,69 @@ assert(!isClosed); // PathVerb::close is always followed by a move or nothing. float prevDistance = distance; const uint32_t ptIndex = castTo<uint32_t>(pts.size() - 1); - switch (verb) { + switch (verb) + { case PathVerb::line: distance += (iterPts[1] - iterPts[0]).length(); - if (distance > prevDistance) { + if (distance > prevDistance) + { addSeg(segs, {distance, ptIndex, kMaxDot30, SegmentType::kLine}, true); pts.push_back(iterPts[1]); } break; case PathVerb::quad: distance = this->addQuadSegs(segs, iterPts, ptIndex, distance); - if (distance > prevDistance) { + if (distance > prevDistance) + { pts.push_back(iterPts[1]); pts.push_back(iterPts[2]); } break; case PathVerb::cubic: distance = this->addCubicSegs(segs, iterPts, ptIndex, distance); - if (distance > prevDistance) { + if (distance > prevDistance) + { pts.push_back(iterPts[1]); pts.push_back(iterPts[2]); pts.push_back(iterPts[3]); } break; - case PathVerb::close: { + case PathVerb::close: + { auto first = pts.front(); distance += (first - iterPts[0]).length(); - if (distance > prevDistance) { + if (distance > prevDistance) + { addSeg(segs, {distance, ptIndex, kMaxDot30, SegmentType::kLine}, true); pts.push_back(first); } isClosed = true; - } break; - case PathVerb::move: RIVE_UNREACHABLE; // Handled above. + } + break; + case PathVerb::move: + RIVE_UNREACHABLE; // Handled above. } } - if (distance == 0 || pts.size() < 2) { + if (distance == 0 || pts.size() < 2) + { return nullptr; } return rcp<ContourMeasure>( new ContourMeasure(std::move(segs), std::move(pts), distance, isClosed)); } -rcp<ContourMeasure> ContourMeasureIter::next() { +rcp<ContourMeasure> ContourMeasureIter::next() +{ rcp<ContourMeasure> cm; - for (;;) { - if ((cm = this->tryNext())) { + for (;;) + { + if ((cm = this->tryNext())) + { break; } - if (m_iter == m_end) { + if (m_iter == m_end) + { break; } }
diff --git a/src/math/hit_test.cpp b/src/math/hit_test.cpp index 8dc2fa6..b803242 100644 --- a/src/math/hit_test.cpp +++ b/src/math/hit_test.cpp
@@ -17,7 +17,8 @@ static inline int graphics_round(float x) { return (int)graphics_roundf(x); } -struct Point { +struct Point +{ float x, y; Point() {} @@ -27,11 +28,13 @@ 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) { + Point& operator+=(Point v) + { *this = *this + v; return *this; } - Point& operator-=(Point v) { + Point& operator-=(Point v) + { *this = *this - v; return *this; } @@ -45,12 +48,14 @@ 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) { +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); int bottom = graphics_round(p1.y); - if (top == bottom) { + if (top == bottom) + { return; } @@ -62,9 +67,11 @@ float x = p0.x + m * (top - p0.y + 0.5f) + 0.5f; int* row = delta + top * iwidth; - for (int y = top; y < bottom; ++y) { + for (int y = top; y < bottom; ++y) + { int ix = (int)std::max(x, 0.0f); - if (ix < iwidth) { + if (ix < iwidth) + { row[ix] += winding; } x += m; @@ -72,27 +79,33 @@ } } -static void clip_line(const float height, Point p0, Point p1, int delta[], const int iwidth) { - if (p0.y == p1.y) { +static void clip_line(const float height, Point p0, Point p1, int delta[], const int iwidth) +{ + if (p0.y == p1.y) + { return; } int winding = 1; - if (p0.y > p1.y) { + if (p0.y > p1.y) + { winding = -1; std::swap(p0, p1); } // now we're monotonic in Y: p0 <= p1 - if (p1.y <= 0 || p0.y >= height) { + if (p1.y <= 0 || p0.y >= height) + { return; } const float m = (float)(p1.x - p0.x) / (p1.y - p0.y); - if (p0.y < 0) { + if (p0.y < 0) + { p0.x += m * (0 - p0.y); p0.y = 0; } - if (p1.y > height) { + if (p1.y > height) + { p1.x += m * (height - p1.y); p1.y = height; } @@ -106,7 +119,8 @@ #define MAX_CURVE_SEGMENTS (1 << 8) -static int compute_cubic_segments(Point a, Point b, Point c, Point d) { +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)); @@ -123,7 +137,8 @@ // becomes // At^3 + Bt^2 + Ct + D // -struct CubicCoeff { +struct CubicCoeff +{ Point A, B, C, D; // a(1-t)^3 + 3bt(1-t)^2 + 3ct^2(1-t) + dt^3 @@ -134,7 +149,8 @@ // ... // D + Ct + Bt^2 + At^3 // - CubicCoeff(Point a, Point b, Point c, Point d) { + 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); @@ -148,29 +164,34 @@ void HitTester::reset() { m_DW.clear(); } -void HitTester::reset(const IAABB& clip) { +void HitTester::reset(const IAABB& clip) +{ m_offset = Vec2D{(float)clip.left, (float)clip.top}; m_height = (float)clip.height(); m_IWidth = clip.width(); m_IHeight = clip.height(); m_DW.resize(m_IWidth * m_IHeight); - for (size_t i = 0; i < m_DW.size(); ++i) { + for (size_t i = 0; i < m_DW.size(); ++i) + { m_DW[i] = 0; } m_ExpectsMove = true; } -void HitTester::move(Vec2D v) { - if (!m_ExpectsMove) { +void HitTester::move(Vec2D v) +{ + if (!m_ExpectsMove) + { this->close(); } m_First = m_Prev = v - m_offset; m_ExpectsMove = false; } -void HitTester::line(Vec2D v) { +void HitTester::line(Vec2D v) +{ assert(!m_ExpectsMove); v = v - m_offset; @@ -178,22 +199,26 @@ m_Prev = v; } -void HitTester::quad(Vec2D b, Vec2D c) { +void HitTester::quad(Vec2D b, Vec2D c) +{ assert(!m_ExpectsMove); m_Prev = c; } -static bool quickRejectCubic(float height, Point a, Point b, Point c, Point d) { +static bool quickRejectCubic(float height, Point a, Point b, Point c, Point d) +{ const float h = height; return (a.y <= 0 && b.y <= 0 && c.y <= 0 && d.y <= 0) || (a.y >= h && b.y >= h && c.y >= h && d.y >= h); } -struct CubicChop { +struct CubicChop +{ Vec2D storage[7]; - CubicChop(Vec2D a, Vec2D b, Vec2D c, Vec2D d) { + CubicChop(Vec2D a, Vec2D b, Vec2D c, Vec2D d) + { auto ab = ave(a, b); auto bc = ave(b, c); auto cd = ave(c, d); @@ -209,7 +234,8 @@ storage[6] = d; } - Vec2D operator[](unsigned index) const { + Vec2D operator[](unsigned index) const + { assert(index < 7); return storage[index]; } @@ -226,26 +252,32 @@ // #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)) { +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) { + if (count > MAX_LOCAL_SEGMENTS) + { CubicChop chop(m_Prev, b, c, d); const int newCount = (count + 1) >> 1; assert(newCount < count); this->recurse_cubic(chop[1], chop[2], chop[3], newCount); this->recurse_cubic(chop[4], chop[5], chop[6], newCount); - } else { + } + else + { const float dt = 1.0f / (float)count; float t = dt; CubicCoeff cube(m_Prev, b, c, d); // we don't need the first point eval(0) or the last eval(1) Point prev = m_Prev; - for (int i = 1; i < count - 1; ++i) { + for (int i = 1; i < count - 1; ++i) + { auto next = cube.eval(t); clip_line(m_height, prev, next, m_DW.data(), m_IWidth); prev = next; @@ -255,14 +287,16 @@ m_Prev = d; } } -void HitTester::cubic(Vec2D b, Vec2D c, Vec2D d) { +void HitTester::cubic(Vec2D b, Vec2D c, Vec2D d) +{ assert(!m_ExpectsMove); b = b - m_offset; c = c - m_offset; d = d - m_offset; - if (quickRejectCubic(m_height, m_Prev, b, c, d)) { + if (quickRejectCubic(m_height, m_Prev, b, c, d)) + { m_Prev = d; return; } @@ -272,14 +306,16 @@ this->recurse_cubic(b, c, d, count); } -void HitTester::close() { +void HitTester::close() +{ assert(!m_ExpectsMove); clip_line(m_height, m_Prev, m_First, m_DW.data(), m_IWidth); m_ExpectsMove = true; } -void HitTester::addRect(const AABB& rect, const Mat2D& xform, PathDirection dir) { +void HitTester::addRect(const AABB& rect, const Mat2D& xform, PathDirection dir) +{ const Vec2D pts[] = { xform * Vec2D{rect.left(), rect.top()}, xform * Vec2D{rect.right(), rect.top()}, @@ -288,11 +324,14 @@ }; move(pts[0]); - if (dir == PathDirection::clockwise) { + if (dir == PathDirection::clockwise) + { line(pts[1]); line(pts[2]); line(pts[3]); - } else { + } + else + { line(pts[3]); line(pts[2]); line(pts[1]); @@ -300,15 +339,18 @@ close(); } -bool HitTester::test(FillRule rule) { - if (!m_ExpectsMove) { +bool HitTester::test(FillRule rule) +{ + if (!m_ExpectsMove) + { this->close(); } const int mask = (rule == rive::FillRule::nonZero) ? -1 : 1; int nonzero = 0; - for (auto m : m_DW) { + for (auto m : m_DW) + { nonzero |= (m & mask); } return nonzero != 0; @@ -318,23 +360,28 @@ static bool cross_lt(Vec2D a, Vec2D b) { return a.x * b.y < a.y * b.x; } -bool HitTester::testMesh(Vec2D pt, Span<Vec2D> verts, Span<uint16_t> indices) { - if (verts.size() < 3) { +bool HitTester::testMesh(Vec2D pt, Span<Vec2D> verts, Span<uint16_t> indices) +{ + if (verts.size() < 3) + { return false; } // Test against the bounds of the entire mesh // Make this optional? - if (CULL_BOUNDS) { + if (CULL_BOUNDS) + { const auto bounds = AABB(verts); if (bounds.bottom() < pt.y || pt.y < bounds.top() || bounds.right() < pt.x || - pt.x < bounds.left()) { + pt.x < bounds.left()) + { return false; } } - for (size_t i = 0; i < indices.size(); i += 3) { + for (size_t i = 0; i < indices.size(); i += 3) + { const auto a = verts[indices[i + 0]]; const auto b = verts[indices[i + 1]]; const auto c = verts[indices[i + 2]]; @@ -347,27 +394,32 @@ auto bc = cross_lt(pb, pc); auto ca = cross_lt(pc, pa); - if (ab == bc && ab == ca) { + if (ab == bc && ab == ca) + { return true; } } return false; } -bool HitTester::testMesh(const IAABB& area, Span<Vec2D> verts, Span<uint16_t> indices) { +bool HitTester::testMesh(const IAABB& area, Span<Vec2D> verts, Span<uint16_t> indices) +{ // this version can give slightly different results, so perhaps we should do this // automatically, ... its just much faster if we do. - if (area.width() * area.height() == 1) { + if (area.width() * area.height() == 1) + { return testMesh(Vec2D((float)area.left, (float)area.top), verts, indices); } - if (verts.size() < 3) { + if (verts.size() < 3) + { return false; } // Test against the bounds of the entire mesh // Make this optional? - if (CULL_BOUNDS) { + if (CULL_BOUNDS) + { const auto bounds = AABB(verts); if (bounds.bottom() <= area.top || area.bottom <= bounds.top() || @@ -381,7 +433,8 @@ const auto offset = Vec2D((float)area.left, (float)area.top); int* deltas = windings.data(); - for (size_t i = 0; i < indices.size(); i += 3) { + for (size_t i = 0; i < indices.size(); i += 3) + { const auto a = verts[indices[i + 0]] - offset; const auto b = verts[indices[i + 1]] - offset; const auto c = verts[indices[i + 2]] - offset; @@ -391,10 +444,12 @@ clip_line((float)area.height(), c, a, deltas, area.width()); int nonzero = 0; - for (auto w : windings) { + for (auto w : windings) + { nonzero |= w; } - if (nonzero) { + if (nonzero) + { return true; } }
diff --git a/src/math/mat2d.cpp b/src/math/mat2d.cpp index 395dd7f..a623ae7 100644 --- a/src/math/mat2d.cpp +++ b/src/math/mat2d.cpp
@@ -5,16 +5,19 @@ using namespace rive; -Mat2D Mat2D::fromRotation(float rad) { +Mat2D Mat2D::fromRotation(float rad) +{ float s = 0, c = 1; - if (rad != 0) { + if (rad != 0) + { s = sin(rad); c = cos(rad); } return {c, s, -s, c, 0, 0}; } -Mat2D Mat2D::scale(Vec2D vec) const { +Mat2D Mat2D::scale(Vec2D vec) const +{ return { m_Buffer[0] * vec.x, m_Buffer[1] * vec.x, @@ -25,7 +28,8 @@ }; } -Mat2D Mat2D::multiply(const Mat2D& a, const Mat2D& b) { +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]; return { @@ -38,12 +42,14 @@ }; } -bool Mat2D::invert(Mat2D* result) const { +bool Mat2D::invert(Mat2D* result) const +{ float aa = m_Buffer[0], ab = m_Buffer[1], ac = m_Buffer[2], ad = m_Buffer[3], atx = m_Buffer[4], aty = m_Buffer[5]; float det = aa * ad - ab * ac; - if (det == 0.0f) { + if (det == 0.0f) + { return false; } det = 1.0f / det; @@ -59,7 +65,8 @@ return true; } -TransformComponents Mat2D::decompose() const { +TransformComponents Mat2D::decompose() const +{ float m0 = m_Buffer[0], m1 = m_Buffer[1], m2 = m_Buffer[2], m3 = m_Buffer[3]; float rotation = (float)std::atan2(m1, m0); @@ -78,21 +85,24 @@ return result; } -Mat2D Mat2D::compose(const TransformComponents& components) { +Mat2D Mat2D::compose(const TransformComponents& components) +{ auto result = Mat2D::fromRotation(components.rotation()); result[4] = components.x(); result[5] = components.y(); result = result.scale(components.scale()); float sk = components.skew(); - if (sk != 0.0f) { + if (sk != 0.0f) + { result[2] = result[0] * sk + result[2]; result[3] = result[1] * sk + result[3]; } return result; } -void Mat2D::scaleByValues(float sx, float sy) { +void Mat2D::scaleByValues(float sx, float sy) +{ m_Buffer[0] *= sx; m_Buffer[1] *= sx; m_Buffer[2] *= sy;
diff --git a/src/math/raw_path.cpp b/src/math/raw_path.cpp index 1fa9381..8ac9bde 100644 --- a/src/math/raw_path.cpp +++ b/src/math/raw_path.cpp
@@ -10,23 +10,30 @@ #include <cstring> #include <algorithm> -namespace rive { +namespace rive +{ -bool RawPath::operator==(const RawPath& o) const { +bool RawPath::operator==(const RawPath& o) const +{ return m_Points == o.m_Points && m_Verbs == o.m_Verbs; } -AABB RawPath::bounds() const { +AABB RawPath::bounds() const +{ float4 mins, maxes; size_t i; - if (m_Points.size() & 1) { + if (m_Points.size() & 1) + { mins = maxes = simd::load2f(&m_Points[0].x).xyxy; i = 1; - } else { + } + else + { mins = maxes = m_Points.empty() ? float4{0, 0, 0, 0} : simd::load4f(&m_Points[0].x); i = 2; } - for (; i < m_Points.size(); i += 2) { + for (; i < m_Points.size(); i += 2) + { float4 pts = simd::load4f(&m_Points[i].x); mins = simd::min(mins, pts); maxes = simd::max(maxes, pts); @@ -37,33 +44,39 @@ return bounds; } -void RawPath::injectImplicitMoveIfNeeded() { - if (!m_contourIsOpen) { +void RawPath::injectImplicitMoveIfNeeded() +{ + if (!m_contourIsOpen) + { move(m_Points.empty() ? Vec2D{0, 0} : m_Points[m_lastMoveIdx]); } } -void RawPath::move(Vec2D a) { +void RawPath::move(Vec2D a) +{ m_contourIsOpen = true; m_lastMoveIdx = m_Points.size(); m_Points.push_back(a); m_Verbs.push_back(PathVerb::move); } -void RawPath::line(Vec2D a) { +void RawPath::line(Vec2D a) +{ injectImplicitMoveIfNeeded(); m_Points.push_back(a); m_Verbs.push_back(PathVerb::line); } -void RawPath::quad(Vec2D a, Vec2D b) { +void RawPath::quad(Vec2D a, Vec2D b) +{ injectImplicitMoveIfNeeded(); m_Points.push_back(a); m_Points.push_back(b); m_Verbs.push_back(PathVerb::quad); } -void RawPath::cubic(Vec2D a, Vec2D b, Vec2D c) { +void RawPath::cubic(Vec2D a, Vec2D b, Vec2D c) +{ injectImplicitMoveIfNeeded(); m_Points.push_back(a); m_Points.push_back(b); @@ -71,32 +84,39 @@ m_Verbs.push_back(PathVerb::cubic); } -void RawPath::close() { - if (m_contourIsOpen) { +void RawPath::close() +{ + if (m_contourIsOpen) + { m_Verbs.push_back(PathVerb::close); m_contourIsOpen = false; } } -RawPath RawPath::transform(const Mat2D& m) const { +RawPath RawPath::transform(const Mat2D& m) const +{ RawPath path; path.m_Verbs = m_Verbs; path.m_Points.resize(m_Points.size()); - for (size_t i = 0; i < m_Points.size(); ++i) { + for (size_t i = 0; i < m_Points.size(); ++i) + { path.m_Points[i] = m * m_Points[i]; } return path; } -void RawPath::transformInPlace(const Mat2D& m) { - for (auto& p : m_Points) { +void RawPath::transformInPlace(const Mat2D& m) +{ + for (auto& p : m_Points) + { p = m * p; } } -void RawPath::addRect(const AABB& r, PathDirection dir) { +void RawPath::addRect(const AABB& r, PathDirection dir) +{ // We manually close the rectangle, in case we want to stroke // this path. We also call close() so we get proper joins // (and not caps). @@ -105,11 +125,14 @@ m_Verbs.reserve(6); moveTo(r.left(), r.top()); - if (dir == PathDirection::clockwise) { + if (dir == PathDirection::clockwise) + { lineTo(r.right(), r.top()); lineTo(r.right(), r.bottom()); lineTo(r.left(), r.bottom()); - } else { + } + else + { lineTo(r.left(), r.bottom()); lineTo(r.right(), r.bottom()); lineTo(r.right(), r.top()); @@ -117,7 +140,8 @@ close(); } -void RawPath::addOval(const AABB& r, PathDirection dir) { +void RawPath::addOval(const AABB& r, PathDirection dir) +{ // see https://spencermortensen.com/articles/bezier-circle/ constexpr float C = 0.5519150244935105707435627f; // precompute clockwise unit circle, starting and ending at {1, 0} @@ -150,22 +174,29 @@ m_Points.reserve(13); m_Verbs.reserve(6); - if (dir == PathDirection::clockwise) { + if (dir == PathDirection::clockwise) + { move(map(unit[0])); - for (int i = 1; i <= 12; i += 3) { + for (int i = 1; i <= 12; i += 3) + { cubic(map(unit[i + 0]), map(unit[i + 1]), map(unit[i + 2])); } - } else { + } + else + { move(map(unit[12])); - for (int i = 11; i >= 0; i -= 3) { + for (int i = 11; i >= 0; i -= 3) + { cubic(map(unit[i - 0]), map(unit[i - 1]), map(unit[i - 2])); } } close(); } -void RawPath::addPoly(Span<const Vec2D> span, bool isClosed) { - if (span.size() == 0) { +void RawPath::addPoly(Span<const Vec2D> span, bool isClosed) +{ + if (span.size() == 0) + { return; } @@ -175,32 +206,40 @@ m_Verbs.reserve(span.size() + isClosed); move(span[0]); - for (size_t i = 1; i < span.size(); ++i) { + for (size_t i = 1; i < span.size(); ++i) + { line(span[i]); } - if (isClosed) { + if (isClosed) + { close(); } } -void RawPath::addPath(const RawPath& src, const Mat2D* mat) { +void RawPath::addPath(const RawPath& src, const Mat2D* mat) +{ m_Verbs.insert(m_Verbs.end(), src.m_Verbs.cbegin(), src.m_Verbs.cend()); - if (mat) { + if (mat) + { const auto oldPointCount = m_Points.size(); m_Points.resize(oldPointCount + src.m_Points.size()); Vec2D* dst = m_Points.data() + oldPointCount; - for (auto i = 0; i < src.m_Points.size(); ++i) { + for (auto i = 0; i < src.m_Points.size(); ++i) + { dst[i] = *mat * src.m_Points[i]; } - } else { + } + else + { m_Points.insert(m_Points.end(), src.m_Points.cbegin(), src.m_Points.cend()); } } ////////////////////////////////////////////////////////////////////////// -int path_verb_to_point_count(PathVerb v) { +int path_verb_to_point_count(PathVerb v) +{ static uint8_t ptCounts[] = { 1, // move 1, // line @@ -214,12 +253,14 @@ return ptCounts[index]; } -void RawPath::swap(RawPath& rawPath) { +void RawPath::swap(RawPath& rawPath) +{ m_Points.swap(rawPath.m_Points); m_Verbs.swap(rawPath.m_Verbs); } -void RawPath::reset() { +void RawPath::reset() +{ m_Points.clear(); m_Points.shrink_to_fit(); m_Verbs.clear(); @@ -227,7 +268,8 @@ m_contourIsOpen = false; } -void RawPath::rewind() { +void RawPath::rewind() +{ m_Points.clear(); m_Verbs.clear(); m_contourIsOpen = false; @@ -235,14 +277,26 @@ /////////////////////////////////// -void RawPath::addTo(CommandPath* result) const { - for (auto [verb, pts] : *this) { - switch (verb) { - case PathVerb::move: result->move(pts[0]); break; - case PathVerb::line: result->line(pts[1]); break; - case PathVerb::cubic: result->cubic(pts[1], pts[2], pts[3]); break; - case PathVerb::close: result->close(); break; - case PathVerb::quad: RIVE_UNREACHABLE; +void RawPath::addTo(CommandPath* result) const +{ + for (auto [verb, pts] : *this) + { + switch (verb) + { + case PathVerb::move: + result->move(pts[0]); + break; + case PathVerb::line: + result->line(pts[1]); + break; + case PathVerb::cubic: + result->cubic(pts[1], pts[2], pts[3]); + break; + case PathVerb::close: + result->close(); + break; + case PathVerb::quad: + RIVE_UNREACHABLE; } } }
diff --git a/src/math/raw_path_utils.cpp b/src/math/raw_path_utils.cpp index 6f40268..1c457d3 100644 --- a/src/math/raw_path_utils.cpp +++ b/src/math/raw_path_utils.cpp
@@ -14,14 +14,16 @@ // d = |a - 2b + c|/4 // count = sqrt(d / tol) // -int rive::computeApproximatingQuadLineSegments(const rive::Vec2D pts[3], float invTolerance) { +int rive::computeApproximatingQuadLineSegments(const rive::Vec2D pts[3], float invTolerance) +{ auto diff = pts[0] - rive::two(pts[1]) + pts[2]; float d = diff.length(); float count = sqrtf(d * invTolerance * 0.25f); return std::max(1, std::min((int)std::ceil(count), MAX_LINE_SEGMENTS)); } -int rive::computeApproximatingCubicLineSegments(const rive::Vec2D pts[4], float invTolerance) { +int rive::computeApproximatingCubicLineSegments(const rive::Vec2D pts[4], float invTolerance) +{ auto abc = pts[0] - pts[1] - pts[1] + pts[2]; auto bcd = pts[1] - pts[2] - pts[2] + pts[3]; float dx = std::max(std::abs(abc.x), std::abs(bcd.x)); @@ -34,7 +36,8 @@ // Extract subsets -void rive::quad_subdivide(const rive::Vec2D src[3], float t, rive::Vec2D dst[5]) { +void rive::quad_subdivide(const rive::Vec2D src[3], float t, rive::Vec2D dst[5]) +{ assert(t >= 0 && t <= 1); auto ab = lerp(src[0], src[1], t); auto bc = lerp(src[1], src[2], t); @@ -45,7 +48,8 @@ dst[4] = src[2]; } -void rive::cubic_subdivide(const rive::Vec2D src[4], float t, rive::Vec2D dst[7]) { +void rive::cubic_subdivide(const rive::Vec2D src[4], float t, rive::Vec2D dst[7]) +{ assert(t >= 0 && t <= 1); auto ab = lerp(src[0], src[1], t); auto bc = lerp(src[1], src[2], t); @@ -61,7 +65,8 @@ dst[6] = src[3]; } -void rive::line_extract(const rive::Vec2D src[2], float startT, float endT, rive::Vec2D dst[2]) { +void rive::line_extract(const rive::Vec2D src[2], float startT, float endT, rive::Vec2D dst[2]) +{ assert(startT <= endT); assert(startT >= 0 && endT <= 1); @@ -69,20 +74,28 @@ dst[1] = lerp(src[0], src[1], endT); } -void rive::quad_extract(const rive::Vec2D src[3], float startT, float endT, rive::Vec2D dst[3]) { +void rive::quad_extract(const rive::Vec2D src[3], float startT, float endT, rive::Vec2D dst[3]) +{ assert(startT <= endT); assert(startT >= 0 && endT <= 1); rive::Vec2D tmp[5]; - if (startT == 0 && endT == 1) { + if (startT == 0 && endT == 1) + { std::copy(src, src + 3, dst); - } else if (startT == 0) { + } + else if (startT == 0) + { rive::quad_subdivide(src, endT, tmp); std::copy(tmp, tmp + 3, dst); - } else if (endT == 1) { + } + else if (endT == 1) + { rive::quad_subdivide(src, startT, tmp); std::copy(tmp + 2, tmp + 5, dst); - } else { + } + else + { assert(endT > 0); rive::quad_subdivide(src, endT, tmp); rive::Vec2D tmp2[5]; @@ -91,20 +104,28 @@ } } -void rive::cubic_extract(const rive::Vec2D src[4], float startT, float endT, rive::Vec2D dst[4]) { +void rive::cubic_extract(const rive::Vec2D src[4], float startT, float endT, rive::Vec2D dst[4]) +{ assert(startT <= endT); assert(startT >= 0 && endT <= 1); rive::Vec2D tmp[7]; - if (startT == 0 && endT == 1) { + if (startT == 0 && endT == 1) + { std::copy(src, src + 4, dst); - } else if (startT == 0) { + } + else if (startT == 0) + { rive::cubic_subdivide(src, endT, tmp); std::copy(tmp, tmp + 4, dst); - } else if (endT == 1) { + } + else if (endT == 1) + { rive::cubic_subdivide(src, startT, tmp); std::copy(tmp + 3, tmp + 7, dst); - } else { + } + else + { assert(endT > 0); rive::cubic_subdivide(src, endT, tmp); rive::Vec2D tmp2[7];
diff --git a/src/math/vec2d.cpp b/src/math/vec2d.cpp index f8b2f90..6433973 100644 --- a/src/math/vec2d.cpp +++ b/src/math/vec2d.cpp
@@ -4,7 +4,8 @@ using namespace rive; -Vec2D Vec2D::transformDir(const Vec2D& a, const Mat2D& m) { +Vec2D Vec2D::transformDir(const Vec2D& a, const Mat2D& m) +{ return { m[0] * a.x + m[2] * a.y, m[1] * a.x + m[3] * a.y, @@ -12,7 +13,8 @@ } float Vec2D::length() const { return std::sqrt(lengthSquared()); } -Vec2D Vec2D::normalized() const { +Vec2D Vec2D::normalized() const +{ auto len2 = lengthSquared(); auto scale = len2 > 0 ? (1 / std::sqrt(len2)) : 1; return *this * scale;
diff --git a/src/nested_artboard.cpp b/src/nested_artboard.cpp index f9b3834..f4ab1c3 100644 --- a/src/nested_artboard.cpp +++ b/src/nested_artboard.cpp
@@ -12,9 +12,11 @@ NestedArtboard::NestedArtboard() {} NestedArtboard::~NestedArtboard() {} -Core* NestedArtboard::clone() const { +Core* NestedArtboard::clone() const +{ NestedArtboard* nestedArtboard = static_cast<NestedArtboard*>(NestedArtboardBase::clone()); - if (m_Artboard == nullptr) { + if (m_Artboard == nullptr) + { return nestedArtboard; } auto ni = m_Artboard->instance(); @@ -22,11 +24,13 @@ return nestedArtboard; } -void NestedArtboard::nest(Artboard* artboard) { +void NestedArtboard::nest(Artboard* artboard) +{ assert(artboard != nullptr); m_Artboard = artboard; - if (!m_Artboard->isInstance()) { + if (!m_Artboard->isInstance()) + { // We're just marking the source artboard so we can later instance from // it. No need to advance it or change any of its properties. return; @@ -34,22 +38,27 @@ m_Artboard->frameOrigin(false); m_Artboard->opacity(renderOpacity()); m_Instance = nullptr; - if (artboard->isInstance()) { + if (artboard->isInstance()) + { m_Instance.reset(static_cast<ArtboardInstance*>(artboard)); // take ownership } m_Artboard->advance(0.0f); } -static Mat2D makeTranslate(const Artboard* artboard) { +static Mat2D makeTranslate(const Artboard* artboard) +{ return Mat2D::fromTranslate(-artboard->originX() * artboard->width(), -artboard->originY() * artboard->height()); } -void NestedArtboard::draw(Renderer* renderer) { - if (m_Artboard == nullptr) { +void NestedArtboard::draw(Renderer* renderer) +{ + if (m_Artboard == nullptr) + { return; } - if (!clip(renderer)) { + if (!clip(renderer)) + { // We didn't clip, so make sure to save as we'll be doing some // transformations. renderer->save(); @@ -59,22 +68,27 @@ renderer->restore(); } -Core* NestedArtboard::hitTest(HitInfo* hinfo, const Mat2D& xform) { - if (m_Artboard == nullptr) { +Core* NestedArtboard::hitTest(HitInfo* hinfo, const Mat2D& xform) +{ + if (m_Artboard == nullptr) + { return nullptr; } hinfo->mounts.push_back(this); auto mx = xform * worldTransform() * makeTranslate(m_Artboard); - if (auto c = m_Artboard->hitTest(hinfo, &mx)) { + if (auto c = m_Artboard->hitTest(hinfo, &mx)) + { return c; } hinfo->mounts.pop_back(); return nullptr; } -StatusCode NestedArtboard::import(ImportStack& importStack) { +StatusCode NestedArtboard::import(ImportStack& importStack) +{ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey); - if (backboardImporter == nullptr) { + if (backboardImporter == nullptr) + { return StatusCode::MissingObject; } backboardImporter->addNestedArtboard(this); @@ -82,11 +96,13 @@ return Super::import(importStack); } -void NestedArtboard::addNestedAnimation(NestedAnimation* nestedAnimation) { +void NestedArtboard::addNestedAnimation(NestedAnimation* nestedAnimation) +{ m_NestedAnimations.push_back(nestedAnimation); } -StatusCode NestedArtboard::onAddedClean(CoreContext* context) { +StatusCode NestedArtboard::onAddedClean(CoreContext* context) +{ // N.B. The nested instance will be null here for the source artboards. // Instances will have a nestedInstance available. This is a good thing as // it ensures that we only instance animations in artboard instances. It @@ -95,34 +111,44 @@ // practice for any loaded Rive file. assert(m_Artboard == nullptr || m_Artboard == m_Instance.get()); - if (m_Instance) { - for (auto animation : m_NestedAnimations) { + if (m_Instance) + { + for (auto animation : m_NestedAnimations) + { animation->initializeAnimation(m_Instance.get()); } } return Super::onAddedClean(context); } -bool NestedArtboard::advance(float elapsedSeconds) { - if (m_Artboard == nullptr) { +bool NestedArtboard::advance(float elapsedSeconds) +{ + if (m_Artboard == nullptr) + { return false; } - for (auto animation : m_NestedAnimations) { + for (auto animation : m_NestedAnimations) + { animation->advance(elapsedSeconds); } return m_Artboard->advance(elapsedSeconds); } -void NestedArtboard::update(ComponentDirt value) { +void NestedArtboard::update(ComponentDirt value) +{ Super::update(value); - if (hasDirt(value, ComponentDirt::RenderOpacity) && m_Artboard != nullptr) { + if (hasDirt(value, ComponentDirt::RenderOpacity) && m_Artboard != nullptr) + { m_Artboard->opacity(renderOpacity()); } } -bool NestedArtboard::hasNestedStateMachines() const { - for (auto animation : m_NestedAnimations) { - if (animation->is<NestedStateMachine>()) { +bool NestedArtboard::hasNestedStateMachines() const +{ + for (auto animation : m_NestedAnimations) + { + if (animation->is<NestedStateMachine>()) + { return true; } } @@ -131,13 +157,16 @@ Span<NestedAnimation*> NestedArtboard::nestedAnimations() { return m_NestedAnimations; } -bool NestedArtboard::worldToLocal(Vec2D world, Vec2D* local) { +bool NestedArtboard::worldToLocal(Vec2D world, Vec2D* local) +{ assert(local != nullptr); - if (m_Artboard == nullptr) { + if (m_Artboard == nullptr) + { return false; } Mat2D toMountedArtboard; - if (!worldTransform().invert(&toMountedArtboard)) { + if (!worldTransform().invert(&toMountedArtboard)) + { return false; }
diff --git a/src/renderer.cpp b/src/renderer.cpp index 6fb5c17..ebcabb1 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp
@@ -4,7 +4,8 @@ using namespace rive; -Mat2D rive::computeAlignment(Fit fit, Alignment alignment, const AABB& frame, const AABB& content) { +Mat2D rive::computeAlignment(Fit fit, Alignment alignment, const AABB& frame, const AABB& content) +{ float contentWidth = content.width(); float contentHeight = content.height(); float x = -content.left() - contentWidth * 0.5f - (alignment.x() * contentWidth * 0.5f); @@ -12,39 +13,47 @@ float scaleX = 1.0f, scaleY = 1.0f; - switch (fit) { - case Fit::fill: { + switch (fit) + { + case Fit::fill: + { scaleX = frame.width() / contentWidth; scaleY = frame.height() / contentHeight; break; } - case Fit::contain: { + case Fit::contain: + { float minScale = std::fmin(frame.width() / contentWidth, frame.height() / contentHeight); scaleX = scaleY = minScale; break; } - case Fit::cover: { + case Fit::cover: + { float maxScale = std::fmax(frame.width() / contentWidth, frame.height() / contentHeight); scaleX = scaleY = maxScale; break; } - case Fit::fitHeight: { + case Fit::fitHeight: + { float minScale = frame.height() / contentHeight; scaleX = scaleY = minScale; break; } - case Fit::fitWidth: { + case Fit::fitWidth: + { float minScale = frame.width() / contentWidth; scaleX = scaleY = minScale; break; } - case Fit::none: { + case Fit::none: + { scaleX = scaleY = 1.0f; break; } - case Fit::scaleDown: { + case Fit::scaleDown: + { float minScale = std::fmin(frame.width() / contentWidth, frame.height() / contentHeight); scaleX = scaleY = minScale < 1.0f ? minScale : 1.0f; @@ -63,7 +72,8 @@ void Renderer::scale(float sx, float sy) { this->transform(Mat2D(sx, 0, 0, sy, 0, 0)); } -void Renderer::rotate(float radians) { +void Renderer::rotate(float radians) +{ const float s = std::sin(radians); const float c = std::cos(radians); this->transform(Mat2D(c, s, -s, c, 0, 0)); @@ -79,7 +89,8 @@ RenderPaint::RenderPaint() { Counter::update(Counter::kPaint, 1); } RenderPaint::~RenderPaint() { Counter::update(Counter::kPaint, -1); } -RenderImage::RenderImage(const Mat2D& uvTransform) : m_uvTransform(uvTransform) { +RenderImage::RenderImage(const Mat2D& uvTransform) : m_uvTransform(uvTransform) +{ Counter::update(Counter::kImage, 1); } RenderImage::RenderImage() { Counter::update(Counter::kImage, 1); } @@ -94,10 +105,12 @@ rive::SimpleArray<RenderGlyphRun> RenderFont::shapeText(rive::Span<const rive::Unichar> text, - rive::Span<const rive::RenderTextRun> runs) const { + rive::Span<const rive::RenderTextRun> runs) const +{ #ifdef DEBUG size_t count = 0; - for (const auto& tr : runs) { + for (const auto& tr : runs) + { assert(tr.unicharCount > 0); count += tr.unicharCount; } @@ -110,21 +123,26 @@ rive::RenderGlyphRun* lastRun = nullptr; size_t reserveSize = text.size() / 4; rive::SimpleArrayBuilder<uint32_t> breakBuilder(reserveSize); - for (auto& gr : gruns) { - if (lastRun != nullptr) { + for (auto& gr : gruns) + { + if (lastRun != nullptr) + { lastRun->breaks = std::move(breakBuilder); // Reset the builder. breakBuilder = rive::SimpleArrayBuilder<uint32_t>(reserveSize); } uint32_t glyphIndex = 0; - for (auto offset : gr.textIndices) { + for (auto offset : gr.textIndices) + { auto unicode = text[offset]; - if (unicode == '\n') { + if (unicode == '\n') + { breakBuilder.add(glyphIndex); breakBuilder.add(glyphIndex); } - if (wantWhiteSpace == isWhiteSpace(unicode)) { + if (wantWhiteSpace == isWhiteSpace(unicode)) + { breakBuilder.add(glyphIndex); wantWhiteSpace = !wantWhiteSpace; } @@ -133,15 +151,18 @@ lastRun = &gr; } - if (lastRun != nullptr) { - if (wantWhiteSpace) { + if (lastRun != nullptr) + { + if (wantWhiteSpace) + { breakBuilder.add((uint32_t)lastRun->glyphs.size()); } lastRun->breaks = std::move(breakBuilder); } #ifdef DEBUG - for (const auto& gr : gruns) { + for (const auto& gr : gruns) + { assert(gr.glyphs.size() > 0); assert(gr.glyphs.size() == gr.textIndices.size()); assert(gr.glyphs.size() + 1 == gr.xpos.size());
diff --git a/src/scene.cpp b/src/scene.cpp index 0551684..b5f6467 100644 --- a/src/scene.cpp +++ b/src/scene.cpp
@@ -3,7 +3,8 @@ using namespace rive; -Scene::Scene(ArtboardInstance* abi) : m_ArtboardInstance(abi) { +Scene::Scene(ArtboardInstance* abi) : m_ArtboardInstance(abi) +{ assert(m_ArtboardInstance->isInstance()); }
diff --git a/src/shapes/clipping_shape.cpp b/src/shapes/clipping_shape.cpp index c9b4c97..103ed65 100644 --- a/src/shapes/clipping_shape.cpp +++ b/src/shapes/clipping_shape.cpp
@@ -9,22 +9,27 @@ using namespace rive; -StatusCode ClippingShape::onAddedClean(CoreContext* context) { +StatusCode ClippingShape::onAddedClean(CoreContext* context) +{ auto clippingHolder = parent(); auto artboard = static_cast<Artboard*>(context); - for (auto core : artboard->objects()) { - if (core == nullptr) { + for (auto core : artboard->objects()) + { + if (core == nullptr) + { continue; } // Iterate artboard to find drawables that are parented to this clipping // shape, they need to know they'll be clipped by this shape. - if (core->is<Drawable>()) { + if (core->is<Drawable>()) + { auto drawable = core->as<Drawable>(); for (ContainerComponent* component = drawable; component != nullptr; component = component->parent()) { - if (component == clippingHolder) { + if (component == clippingHolder) + { drawable->addClippingShape(this); break; } @@ -34,10 +39,13 @@ // Iterate artboard to find shapes that are parented to the source, // their paths will need to be RenderPaths in order to be used for // clipping operations. - if (core->is<Shape>() && core != clippingHolder) { + if (core->is<Shape>() && core != clippingHolder) + { auto component = core->as<ContainerComponent>(); - while (component != nullptr) { - if (component == m_Source) { + while (component != nullptr) + { + if (component == m_Source) + { auto shape = core->as<Shape>(); shape->addDefaultPathSpace(PathSpace::World | PathSpace::Clipping); m_Shapes.push_back(shape); @@ -49,20 +57,24 @@ } // We only need a render path if we have more than 1 clip path as we join them. - if (m_Shapes.size() > 1) { + if (m_Shapes.size() > 1) + { m_RenderPath = artboard->factory()->makeEmptyRenderPath(); } return StatusCode::Ok; } -StatusCode ClippingShape::onAddedDirty(CoreContext* context) { +StatusCode ClippingShape::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } auto coreObject = context->resolve(sourceId()); - if (coreObject == nullptr || !coreObject->is<Node>()) { + if (coreObject == nullptr || !coreObject->is<Node>()) + { return StatusCode::MissingObject; } @@ -71,31 +83,43 @@ return StatusCode::Ok; } -void ClippingShape::buildDependencies() { - for (auto shape : m_Shapes) { +void ClippingShape::buildDependencies() +{ + for (auto shape : m_Shapes) + { shape->pathComposer()->addDependent(this); } } static Mat2D identity; -void ClippingShape::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path | ComponentDirt::WorldTransform)) { - if (m_RenderPath) { +void ClippingShape::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path | ComponentDirt::WorldTransform)) + { + if (m_RenderPath) + { m_RenderPath->reset(); m_RenderPath->fillRule((FillRule)fillRule()); m_ClipRenderPath = nullptr; - for (auto shape : m_Shapes) { - if (!shape->isHidden()) { + for (auto shape : m_Shapes) + { + if (!shape->isHidden()) + { m_RenderPath->addPath(shape->pathComposer()->worldPath(), identity); m_ClipRenderPath = m_RenderPath.get(); } } - } else { + } + else + { auto first = m_Shapes.front(); - if (first->isHidden()) { + if (first->isHidden()) + { m_ClipRenderPath = nullptr; - } else { + } + else + { m_ClipRenderPath = static_cast<RenderPath*>(first->pathComposer()->worldPath()); } }
diff --git a/src/shapes/cubic_asymmetric_vertex.cpp b/src/shapes/cubic_asymmetric_vertex.cpp index 703c104..2901adf 100644 --- a/src/shapes/cubic_asymmetric_vertex.cpp +++ b/src/shapes/cubic_asymmetric_vertex.cpp
@@ -6,11 +6,13 @@ static Vec2D get_point(const CubicAsymmetricVertex& v) { return Vec2D(v.x(), v.y()); } -static Vec2D in_vector(const CubicAsymmetricVertex& v) { +static Vec2D in_vector(const CubicAsymmetricVertex& v) +{ return Vec2D(cos(v.rotation()) * v.inDistance(), sin(v.rotation()) * v.inDistance()); } -static Vec2D out_vector(const CubicAsymmetricVertex& v) { +static Vec2D out_vector(const CubicAsymmetricVertex& v) +{ return Vec2D(cos(v.rotation()) * v.outDistance(), sin(v.rotation()) * v.outDistance()); } @@ -18,16 +20,19 @@ void CubicAsymmetricVertex::computeOut() { m_OutPoint = get_point(*this) + out_vector(*this); } -void CubicAsymmetricVertex::rotationChanged() { +void CubicAsymmetricVertex::rotationChanged() +{ m_InValid = false; m_OutValid = false; markGeometryDirty(); } -void CubicAsymmetricVertex::inDistanceChanged() { +void CubicAsymmetricVertex::inDistanceChanged() +{ m_InValid = false; markGeometryDirty(); } -void CubicAsymmetricVertex::outDistanceChanged() { +void CubicAsymmetricVertex::outDistanceChanged() +{ m_OutValid = false; markGeometryDirty(); }
diff --git a/src/shapes/cubic_detached_vertex.cpp b/src/shapes/cubic_detached_vertex.cpp index 8a93166..3706f08 100644 --- a/src/shapes/cubic_detached_vertex.cpp +++ b/src/shapes/cubic_detached_vertex.cpp
@@ -6,11 +6,13 @@ static Vec2D get_point(const CubicDetachedVertex& v) { return Vec2D(v.x(), v.y()); } -static Vec2D in_vector(const CubicDetachedVertex& v) { +static Vec2D in_vector(const CubicDetachedVertex& v) +{ return Vec2D(cos(v.inRotation()) * v.inDistance(), sin(v.inRotation()) * v.inDistance()); } -static Vec2D out_vector(const CubicDetachedVertex& v) { +static Vec2D out_vector(const CubicDetachedVertex& v) +{ return Vec2D(cos(v.outRotation()) * v.outDistance(), sin(v.outRotation()) * v.outDistance()); } @@ -18,19 +20,23 @@ void CubicDetachedVertex::computeOut() { m_OutPoint = get_point(*this) + out_vector(*this); } -void CubicDetachedVertex::inRotationChanged() { +void CubicDetachedVertex::inRotationChanged() +{ m_InValid = false; markGeometryDirty(); } -void CubicDetachedVertex::inDistanceChanged() { +void CubicDetachedVertex::inDistanceChanged() +{ m_InValid = false; markGeometryDirty(); } -void CubicDetachedVertex::outRotationChanged() { +void CubicDetachedVertex::outRotationChanged() +{ m_OutValid = false; markGeometryDirty(); } -void CubicDetachedVertex::outDistanceChanged() { +void CubicDetachedVertex::outDistanceChanged() +{ m_OutValid = false; markGeometryDirty(); }
diff --git a/src/shapes/cubic_mirrored_vertex.cpp b/src/shapes/cubic_mirrored_vertex.cpp index 5656622..0a23c44 100644 --- a/src/shapes/cubic_mirrored_vertex.cpp +++ b/src/shapes/cubic_mirrored_vertex.cpp
@@ -6,7 +6,8 @@ static Vec2D get_point(const CubicMirroredVertex& v) { return Vec2D(v.x(), v.y()); } -static Vec2D get_vector(const CubicMirroredVertex& v) { +static Vec2D get_vector(const CubicMirroredVertex& v) +{ return Vec2D(cos(v.rotation()) * v.distance(), sin(v.rotation()) * v.distance()); } @@ -14,11 +15,13 @@ void CubicMirroredVertex::computeOut() { m_OutPoint = get_point(*this) + get_vector(*this); } -void CubicMirroredVertex::rotationChanged() { +void CubicMirroredVertex::rotationChanged() +{ m_InValid = m_OutValid = false; markGeometryDirty(); } -void CubicMirroredVertex::distanceChanged() { +void CubicMirroredVertex::distanceChanged() +{ m_InValid = m_OutValid = false; markGeometryDirty(); }
diff --git a/src/shapes/cubic_vertex.cpp b/src/shapes/cubic_vertex.cpp index 5964ede..7fe7eca 100644 --- a/src/shapes/cubic_vertex.cpp +++ b/src/shapes/cubic_vertex.cpp
@@ -2,58 +2,75 @@ #include "rive/bones/cubic_weight.hpp" using namespace rive; -const Vec2D& CubicVertex::renderIn() { - if (hasWeight()) { +const Vec2D& CubicVertex::renderIn() +{ + if (hasWeight()) + { return weight<CubicWeight>()->inTranslation(); - } else { + } + else + { return inPoint(); } } -const Vec2D& CubicVertex::renderOut() { - if (hasWeight()) { +const Vec2D& CubicVertex::renderOut() +{ + if (hasWeight()) + { return weight<CubicWeight>()->outTranslation(); - } else { + } + else + { return outPoint(); } } -const Vec2D& CubicVertex::inPoint() { - if (!m_InValid) { +const Vec2D& CubicVertex::inPoint() +{ + if (!m_InValid) + { computeIn(); m_InValid = true; } return m_InPoint; } -const Vec2D& CubicVertex::outPoint() { - if (!m_OutValid) { +const Vec2D& CubicVertex::outPoint() +{ + if (!m_OutValid) + { computeOut(); m_OutValid = true; } return m_OutPoint; } -void CubicVertex::outPoint(const Vec2D& value) { +void CubicVertex::outPoint(const Vec2D& value) +{ m_OutPoint = value; m_OutValid = true; } -void CubicVertex::inPoint(const Vec2D& value) { +void CubicVertex::inPoint(const Vec2D& value) +{ m_InPoint = value; m_InValid = true; } -void CubicVertex::xChanged() { +void CubicVertex::xChanged() +{ Super::xChanged(); m_InValid = m_OutValid = false; } -void CubicVertex::yChanged() { +void CubicVertex::yChanged() +{ Super::yChanged(); 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/ellipse.cpp b/src/shapes/ellipse.cpp index 474068a..06489e6 100644 --- a/src/shapes/ellipse.cpp +++ b/src/shapes/ellipse.cpp
@@ -4,15 +4,18 @@ using namespace rive; -Ellipse::Ellipse() { +Ellipse::Ellipse() +{ addVertex(&m_Vertex1); addVertex(&m_Vertex2); addVertex(&m_Vertex3); addVertex(&m_Vertex4); } -void Ellipse::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path)) { +void Ellipse::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path)) + { auto radiusX = width() / 2.0f; auto radiusY = height() / 2.0f;
diff --git a/src/shapes/image.cpp b/src/shapes/image.cpp index 04d90a5..bc00c82 100644 --- a/src/shapes/image.cpp +++ b/src/shapes/image.cpp
@@ -9,7 +9,8 @@ using namespace rive; -void Image::draw(Renderer* renderer) { +void Image::draw(Renderer* renderer) +{ rive::RenderImage* renderImage; if (m_ImageAsset == nullptr || renderOpacity() == 0.0f || (renderImage = m_ImageAsset->renderImage()) == nullptr) @@ -17,7 +18,8 @@ return; } - if (!clip(renderer)) { + if (!clip(renderer)) + { // We didn't clip, so make sure to save as we'll be doing some // transformations. renderer->save(); @@ -26,9 +28,12 @@ auto width = renderImage->width(); auto height = renderImage->height(); - if (m_Mesh != nullptr) { + if (m_Mesh != nullptr) + { m_Mesh->draw(renderer, renderImage, blendMode(), renderOpacity()); - } else { + } + else + { renderer->transform(worldTransform()); renderer->translate(-width / 2.0f, -height / 2.0f); renderer->drawImage(renderImage, blendMode(), renderOpacity()); @@ -37,30 +42,37 @@ renderer->restore(); } -Core* Image::hitTest(HitInfo* hinfo, const Mat2D& xform) { +Core* Image::hitTest(HitInfo* hinfo, const Mat2D& xform) +{ // TODO: handle clip? auto renderImage = m_ImageAsset->renderImage(); int width = renderImage->width(); int height = renderImage->height(); - if (m_Mesh) { + if (m_Mesh) + { printf("Missing mesh\n"); // TODO: hittest mesh - } else { + } + else + { auto mx = xform * worldTransform() * Mat2D::fromTranslate(-width * 0.5f, -height * 0.5f); HitTester tester(hinfo->area); tester.addRect(AABB(0, 0, (float)width, (float)height), mx); - if (tester.test()) { + if (tester.test()) + { return this; } } return nullptr; } -StatusCode Image::import(ImportStack& importStack) { +StatusCode Image::import(ImportStack& importStack) +{ auto backboardImporter = importStack.latest<BackboardImporter>(Backboard::typeKey); - if (backboardImporter == nullptr) { + if (backboardImporter == nullptr) + { return StatusCode::MissingObject; } backboardImporter->addFileAssetReferencer(this); @@ -68,23 +80,28 @@ return Super::import(importStack); } -void Image::assets(const std::vector<FileAsset*>& assets) { - if ((size_t)assetId() >= assets.size()) { +void Image::assets(const std::vector<FileAsset*>& assets) +{ + if ((size_t)assetId() >= assets.size()) + { return; } auto asset = assets[assetId()]; - if (asset->is<ImageAsset>()) { + if (asset->is<ImageAsset>()) + { m_ImageAsset = asset->as<ImageAsset>(); // If we have a mesh and we're in the source artboard, let's initialize // the mesh buffers. - if (m_Mesh != nullptr && !artboard()->isInstance()) { + if (m_Mesh != nullptr && !artboard()->isInstance()) + { m_Mesh->initializeSharedBuffers(m_ImageAsset->renderImage()); } } } -Core* Image::clone() const { +Core* Image::clone() const +{ Image* twin = ImageBase::clone()->as<Image>(); twin->m_ImageAsset = m_ImageAsset; return twin;
diff --git a/src/shapes/mesh.cpp b/src/shapes/mesh.cpp index 5c843d9..50ec298 100644 --- a/src/shapes/mesh.cpp +++ b/src/shapes/mesh.cpp
@@ -12,8 +12,10 @@ using namespace rive; /// Called whenever a vertex moves (x/y change). -void Mesh::markDrawableDirty() { - if (skin() != nullptr) { +void Mesh::markDrawableDirty() +{ + if (skin() != nullptr) + { skin()->addDirt(ComponentDirt::Skin); } @@ -22,13 +24,16 @@ void Mesh::addVertex(MeshVertex* vertex) { m_Vertices.push_back(vertex); } -StatusCode Mesh::onAddedDirty(CoreContext* context) { +StatusCode Mesh::onAddedDirty(CoreContext* context) +{ StatusCode result = Super::onAddedDirty(context); - if (result != StatusCode::Ok) { + if (result != StatusCode::Ok) + { return result; } - if (!parent()->is<Image>()) { + if (!parent()->is<Image>()) + { return StatusCode::MissingObject; } @@ -38,54 +43,64 @@ return StatusCode::Ok; } -StatusCode Mesh::onAddedClean(CoreContext* context) { +StatusCode Mesh::onAddedClean(CoreContext* context) +{ // Make sure Core found indices in the file for this Mesh. - if (m_IndexBuffer == nullptr) { + if (m_IndexBuffer == nullptr) + { return StatusCode::InvalidObject; } // Check the indices are all in range. We should consider having a better // error reporting system to the implementor. - for (auto index : *m_IndexBuffer) { - if (index >= m_Vertices.size()) { + for (auto index : *m_IndexBuffer) + { + if (index >= m_Vertices.size()) + { return StatusCode::InvalidObject; } } return Super::onAddedClean(context); } -void Mesh::decodeTriangleIndexBytes(Span<const uint8_t> value) { +void Mesh::decodeTriangleIndexBytes(Span<const uint8_t> value) +{ // decode the triangle index bytes rcp<IndexBuffer> buffer = rcp<IndexBuffer>(new IndexBuffer()); BinaryReader reader(value); - while (!reader.reachedEnd()) { + while (!reader.reachedEnd()) + { buffer->push_back(reader.readVarUintAs<uint16_t>()); } m_IndexBuffer = buffer; } -void Mesh::copyTriangleIndexBytes(const MeshBase& object) { +void Mesh::copyTriangleIndexBytes(const MeshBase& object) +{ m_IndexBuffer = object.as<Mesh>()->m_IndexBuffer; } /// Called whenever a bone moves that is connected to the skin. void Mesh::markSkinDirty() { addDirt(ComponentDirt::Vertices); } -Core* Mesh::clone() const { +Core* Mesh::clone() const +{ auto clone = static_cast<Mesh*>(MeshBase::clone()); clone->m_UVRenderBuffer = m_UVRenderBuffer; clone->m_IndexRenderBuffer = m_IndexRenderBuffer; return clone; } -void Mesh::initializeSharedBuffers(RenderImage* renderImage) { +void Mesh::initializeSharedBuffers(RenderImage* renderImage) +{ Mat2D uvTransform = renderImage != nullptr ? renderImage->uvTransform() : Mat2D(); std::vector<float> uv = std::vector<float>(m_Vertices.size() * 2); std::size_t index = 0; - for (auto vertex : m_Vertices) { + for (auto vertex : m_Vertices) + { Vec2D xformedUV = uvTransform * Vec2D(vertex->u(), vertex->v()); uv[index++] = xformedUV.x; uv[index++] = xformedUV.y; @@ -96,17 +111,22 @@ m_IndexRenderBuffer = factory->makeBufferU16(*m_IndexBuffer); } -void Mesh::buildDependencies() { +void Mesh::buildDependencies() +{ Super::buildDependencies(); - if (skin() != nullptr) { + if (skin() != nullptr) + { skin()->addDependent(this); } parent()->addDependent(this); } -void Mesh::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Vertices)) { - if (skin() != nullptr) { +void Mesh::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Vertices)) + { + if (skin() != nullptr) + { skin()->deform({(Vertex**)m_Vertices.data(), m_Vertices.size()}); } m_VertexRenderBuffer = nullptr; @@ -114,12 +134,15 @@ Super::update(value); } -void Mesh::draw(Renderer* renderer, const RenderImage* image, BlendMode blendMode, float opacity) { - if (m_VertexRenderBuffer == nullptr) { +void Mesh::draw(Renderer* renderer, const RenderImage* image, BlendMode blendMode, float opacity) +{ + if (m_VertexRenderBuffer == nullptr) + { std::vector<float> vertices(m_Vertices.size() * 2); std::size_t index = 0; - for (auto vertex : m_Vertices) { + for (auto vertex : m_Vertices) + { auto translation = vertex->renderTranslation(); vertices[index++] = translation.x; vertices[index++] = translation.y; @@ -129,7 +152,8 @@ m_VertexRenderBuffer = factory->makeBufferF32(vertices); } - if (skin() == nullptr) { + if (skin() == nullptr) + { renderer->transform(parent()->as<WorldTransformComponent>()->worldTransform()); } renderer->drawImageMesh(image,
diff --git a/src/shapes/mesh_vertex.cpp b/src/shapes/mesh_vertex.cpp index d381f17..818ac22 100644 --- a/src/shapes/mesh_vertex.cpp +++ b/src/shapes/mesh_vertex.cpp
@@ -4,12 +4,15 @@ using namespace rive; void MeshVertex::markGeometryDirty() { parent()->as<Mesh>()->markDrawableDirty(); } -StatusCode MeshVertex::onAddedDirty(CoreContext* context) { +StatusCode MeshVertex::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } - if (!parent()->is<Mesh>()) { + if (!parent()->is<Mesh>()) + { return StatusCode::MissingObject; } parent()->as<Mesh>()->addVertex(this);
diff --git a/src/shapes/metrics_path.cpp b/src/shapes/metrics_path.cpp index 5082f6d..ec84676 100644 --- a/src/shapes/metrics_path.cpp +++ b/src/shapes/metrics_path.cpp
@@ -7,7 +7,8 @@ using namespace rive; -void MetricsPath::reset() { +void MetricsPath::reset() +{ m_Paths.clear(); m_Contour.reset(nullptr); m_RawPath = RawPath(); @@ -15,30 +16,36 @@ m_ComputedLength = 0; } -void MetricsPath::addPath(CommandPath* path, const Mat2D& transform) { +void MetricsPath::addPath(CommandPath* path, const Mat2D& transform) +{ MetricsPath* metricsPath = reinterpret_cast<MetricsPath*>(path); m_ComputedLength += metricsPath->computeLength(transform); m_Paths.emplace_back(metricsPath); } -void MetricsPath::moveTo(float x, float y) { +void MetricsPath::moveTo(float x, float y) +{ assert(m_RawPath.points().size() == 0); m_RawPath.move({x, y}); } void MetricsPath::lineTo(float x, float y) { m_RawPath.line({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_RawPath.cubic({ox, oy}, {ix, iy}, {x, y}); } -void MetricsPath::close() { +void MetricsPath::close() +{ // Should we pass the close() to our m_RawPath ??? } -float MetricsPath::computeLength(const Mat2D& transform) { +float MetricsPath::computeLength(const Mat2D& transform) +{ // Only compute if our pre-computed length is not valid - if (!m_Contour || transform != m_ComputedLengthTransform) { + if (!m_Contour || transform != m_ComputedLengthTransform) + { m_ComputedLengthTransform = transform; m_Contour = ContourMeasureIter(m_RawPath * transform).next(); m_ComputedLength = m_Contour ? m_Contour->length() : 0; @@ -46,9 +53,11 @@ return m_ComputedLength; } -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()) { + if (!m_Paths.empty()) + { m_Paths.front()->trim(startLength, endLength, moveTo, result); return; } @@ -62,34 +71,41 @@ } RenderMetricsPath::RenderMetricsPath(std::unique_ptr<RenderPath> path) : - m_RenderPath(std::move(path)) {} + m_RenderPath(std::move(path)) +{} -void RenderMetricsPath::addPath(CommandPath* path, const Mat2D& transform) { +void RenderMetricsPath::addPath(CommandPath* path, const Mat2D& transform) +{ MetricsPath::addPath(path, transform); m_RenderPath->addPath(path->renderPath(), transform); } -void RenderMetricsPath::reset() { +void RenderMetricsPath::reset() +{ MetricsPath::reset(); m_RenderPath->reset(); } -void RenderMetricsPath::moveTo(float x, float y) { +void RenderMetricsPath::moveTo(float x, float y) +{ MetricsPath::moveTo(x, y); m_RenderPath->moveTo(x, y); } -void RenderMetricsPath::lineTo(float x, float y) { +void RenderMetricsPath::lineTo(float x, float y) +{ MetricsPath::lineTo(x, y); 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); } -void RenderMetricsPath::close() { +void RenderMetricsPath::close() +{ MetricsPath::close(); m_RenderPath->close(); }
diff --git a/src/shapes/paint/color.cpp b/src/shapes/paint/color.cpp index 8e5c98f..059d524 100644 --- a/src/shapes/paint/color.cpp +++ b/src/shapes/paint/color.cpp
@@ -1,8 +1,10 @@ #include "rive/shapes/paint/color.hpp" #include <stdio.h> -namespace rive { -unsigned int colorARGB(int a, int r, int g, int b) { +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)) & 0xFFFFFFFF; } @@ -17,23 +19,28 @@ float colorOpacity(ColorInt value) { return (float)colorAlpha(value) / 0xFF; } -ColorInt colorWithAlpha(ColorInt value, unsigned int a) { +ColorInt colorWithAlpha(ColorInt value, unsigned int a) +{ return colorARGB(a, colorRed(value), colorGreen(value), colorBlue(value)); } -ColorInt colorWithOpacity(ColorInt value, float opacity) { +ColorInt colorWithOpacity(ColorInt value, float opacity) +{ return colorWithAlpha(value, std::lround(255.f * opacity)); } -ColorInt colorModulateOpacity(ColorInt value, float opacity) { +ColorInt colorModulateOpacity(ColorInt value, float opacity) +{ return colorWithAlpha(value, std::lround(255.f * colorOpacity(value) * opacity)); } -static unsigned int lerp(unsigned int a, unsigned int b, float mix) { +static unsigned int lerp(unsigned int a, unsigned int b, float mix) +{ return std::lround(a * (1.0f - mix) + b * mix); } -ColorInt colorLerp(ColorInt from, ColorInt to, float mix) { +ColorInt colorLerp(ColorInt from, ColorInt to, float mix) +{ return colorARGB(lerp(colorAlpha(from), colorAlpha(to), mix), lerp(colorRed(from), colorRed(to), mix), lerp(colorGreen(from), colorGreen(to), mix),
diff --git a/src/shapes/paint/fill.cpp b/src/shapes/paint/fill.cpp index d451982..5d40346 100644 --- a/src/shapes/paint/fill.cpp +++ b/src/shapes/paint/fill.cpp
@@ -4,14 +4,17 @@ PathSpace Fill::pathSpace() const { return PathSpace::Local; } -RenderPaint* Fill::initRenderPaint(ShapePaintMutator* mutator) { +RenderPaint* Fill::initRenderPaint(ShapePaintMutator* mutator) +{ auto renderPaint = Super::initRenderPaint(mutator); renderPaint->style(RenderPaintStyle::fill); return renderPaint; } -void Fill::draw(Renderer* renderer, CommandPath* path) { - if (!isVisible()) { +void Fill::draw(Renderer* renderer, CommandPath* path) +{ + if (!isVisible()) + { return; } auto renderPath = path->renderPath();
diff --git a/src/shapes/paint/gradient_stop.cpp b/src/shapes/paint/gradient_stop.cpp index 7a026e0..fa616df 100644 --- a/src/shapes/paint/gradient_stop.cpp +++ b/src/shapes/paint/gradient_stop.cpp
@@ -3,13 +3,16 @@ using namespace rive; -StatusCode GradientStop::onAddedDirty(CoreContext* context) { +StatusCode GradientStop::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } - if (!parent()->is<LinearGradient>()) { + if (!parent()->is<LinearGradient>()) + { return StatusCode::MissingObject; } parent()->as<LinearGradient>()->addStop(this);
diff --git a/src/shapes/paint/linear_gradient.cpp b/src/shapes/paint/linear_gradient.cpp index 850c4eb..cc68efa 100644 --- a/src/shapes/paint/linear_gradient.cpp +++ b/src/shapes/paint/linear_gradient.cpp
@@ -12,21 +12,26 @@ using namespace rive; -StatusCode LinearGradient::onAddedDirty(CoreContext* context) { +StatusCode LinearGradient::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } - if (!initPaintMutator(this)) { + if (!initPaintMutator(this)) + { return StatusCode::MissingObject; } return StatusCode::Ok; } -void LinearGradient::buildDependencies() { +void LinearGradient::buildDependencies() +{ auto p = parent(); - if (p != nullptr && p->parent() != nullptr) { + if (p != nullptr && p->parent() != nullptr) + { auto parentsParent = p->parent(); // Parent's parent must be a shape paint container. assert(ShapePaintContainer::from(parentsParent) != nullptr); @@ -42,14 +47,17 @@ void LinearGradient::addStop(GradientStop* stop) { m_Stops.push_back(stop); } -static bool stopsComparer(GradientStop* a, GradientStop* b) { +static bool stopsComparer(GradientStop* a, GradientStop* b) +{ return a->position() < b->position(); } -void LinearGradient::update(ComponentDirt value) { +void LinearGradient::update(ComponentDirt value) +{ // Do the stops need to be re-ordered? bool stopsChanged = hasDirt(value, ComponentDirt::Stops); - if (stopsChanged) { + if (stopsChanged) + { std::sort(m_Stops.begin(), m_Stops.end(), stopsComparer); } @@ -63,13 +71,15 @@ hasDirt(value, ComponentDirt::Paint | ComponentDirt::RenderOpacity | ComponentDirt::Transform) || (paintsInWorldSpace && worldTransformed); - if (rebuildGradient) { + if (rebuildGradient) + { Vec2D start(startX(), startY()); Vec2D end(endX(), endY()); // Check if we need to update the world space gradient (if there's no // shape container, presumably it's the artboard and we're already in // world). - if (paintsInWorldSpace && m_ShapePaintContainer != nullptr) { + if (paintsInWorldSpace && m_ShapePaintContainer != nullptr) + { // Get the start and end of the gradient in world coordinates (world // transform of the shape). const Mat2D& world = m_ShapePaintContainer->worldTransform(); @@ -87,7 +97,8 @@ ColorInt* colors = storage.data(); float* stops = (float*)colors + count; - for (size_t i = 0; i < count; ++i) { + for (size_t i = 0; i < count; ++i) + { colors[i] = colorModulateOpacity(m_Stops[i]->colorValue(), ro); stops[i] = m_Stops[i]->position(); } @@ -100,7 +111,8 @@ Vec2D end, const ColorInt colors[], const float stops[], - size_t count) { + size_t count) +{ auto factory = artboard()->factory(); renderPaint()->shader( factory->makeLinearGradient(start.x, start.y, end.x, end.y, colors, stops, count)); @@ -117,12 +129,16 @@ void LinearGradient::endYChanged() { addDirt(ComponentDirt::Transform); } void LinearGradient::opacityChanged() { markGradientDirty(); } -bool LinearGradient::internalIsTranslucent() const { - if (opacity() < 1) { +bool LinearGradient::internalIsTranslucent() const +{ + if (opacity() < 1) + { return true; } - for (const auto stop : m_Stops) { - if (colorAlpha(stop->colorValue()) != 0xFF) { + for (const auto stop : m_Stops) + { + if (colorAlpha(stop->colorValue()) != 0xFF) + { return true; } }
diff --git a/src/shapes/paint/radial_gradient.cpp b/src/shapes/paint/radial_gradient.cpp index 46ae43f..8a1abad 100644 --- a/src/shapes/paint/radial_gradient.cpp +++ b/src/shapes/paint/radial_gradient.cpp
@@ -8,7 +8,8 @@ Vec2D end, const ColorInt colors[], const float stops[], - size_t count) { + size_t count) +{ auto factory = artboard()->factory(); renderPaint()->shader(factory->makeRadialGradient(start.x, start.y,
diff --git a/src/shapes/paint/shape_paint.cpp b/src/shapes/paint/shape_paint.cpp index b1d2890..bdc50c9 100644 --- a/src/shapes/paint/shape_paint.cpp +++ b/src/shapes/paint/shape_paint.cpp
@@ -6,16 +6,19 @@ using namespace rive; -StatusCode ShapePaint::onAddedClean(CoreContext* context) { +StatusCode ShapePaint::onAddedClean(CoreContext* context) +{ auto container = ShapePaintContainer::from(parent()); - if (container == nullptr) { + if (container == nullptr) + { return StatusCode::MissingObject; } container->addPaint(this); return StatusCode::Ok; } -RenderPaint* ShapePaint::initRenderPaint(ShapePaintMutator* mutator) { +RenderPaint* ShapePaint::initRenderPaint(ShapePaintMutator* mutator) +{ assert(m_RenderPaint == nullptr); m_PaintMutator = mutator; @@ -24,7 +27,8 @@ return m_RenderPaint.get(); } -void ShapePaint::blendMode(BlendMode value) { +void ShapePaint::blendMode(BlendMode value) +{ assert(m_RenderPaint != nullptr); m_RenderPaint->blendMode(value); } \ No newline at end of file
diff --git a/src/shapes/paint/shape_paint_mutator.cpp b/src/shapes/paint/shape_paint_mutator.cpp index 534f744..093e71b 100644 --- a/src/shapes/paint/shape_paint_mutator.cpp +++ b/src/shapes/paint/shape_paint_mutator.cpp
@@ -4,10 +4,12 @@ using namespace rive; -bool ShapePaintMutator::initPaintMutator(Component* component) { +bool ShapePaintMutator::initPaintMutator(Component* component) +{ auto parent = component->parent(); m_Component = component; - if (parent->is<ShapePaint>()) { + if (parent->is<ShapePaint>()) + { // Set this object as the mutator for the shape paint and get a // reference to the paint we'll be mutating. m_RenderPaint = parent->as<ShapePaint>()->initRenderPaint(this); @@ -16,8 +18,10 @@ return false; } -void ShapePaintMutator::renderOpacity(float value) { - if (m_RenderOpacity == value) { +void ShapePaintMutator::renderOpacity(float value) +{ + if (m_RenderOpacity == value) + { return; } m_RenderOpacity = value;
diff --git a/src/shapes/paint/solid_color.cpp b/src/shapes/paint/solid_color.cpp index b9fd08e..d6f05c6 100644 --- a/src/shapes/paint/solid_color.cpp +++ b/src/shapes/paint/solid_color.cpp
@@ -5,20 +5,25 @@ using namespace rive; -StatusCode SolidColor::onAddedDirty(CoreContext* context) { +StatusCode SolidColor::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } - if (!initPaintMutator(this)) { + if (!initPaintMutator(this)) + { return StatusCode::MissingObject; } renderOpacityChanged(); return StatusCode::Ok; } -void SolidColor::renderOpacityChanged() { - if (renderPaint() == nullptr) { +void SolidColor::renderOpacityChanged() +{ + if (renderPaint() == nullptr) + { return; } renderPaint()->color(colorModulateOpacity(colorValue(), renderOpacity()));
diff --git a/src/shapes/paint/stroke.cpp b/src/shapes/paint/stroke.cpp index ac8d196..ff31194 100644 --- a/src/shapes/paint/stroke.cpp +++ b/src/shapes/paint/stroke.cpp
@@ -6,11 +6,13 @@ using namespace rive; -PathSpace Stroke::pathSpace() const { +PathSpace Stroke::pathSpace() const +{ return transformAffectsStroke() ? PathSpace::Local : PathSpace::World; } -RenderPaint* Stroke::initRenderPaint(ShapePaintMutator* mutator) { +RenderPaint* Stroke::initRenderPaint(ShapePaintMutator* mutator) +{ auto renderPaint = Super::initRenderPaint(mutator); renderPaint->style(RenderPaintStyle::stroke); renderPaint->thickness(thickness()); @@ -21,12 +23,15 @@ bool Stroke::isVisible() const { return Super::isVisible() && thickness() > 0.0f; } -void Stroke::draw(Renderer* renderer, CommandPath* path) { - if (!isVisible()) { +void Stroke::draw(Renderer* renderer, CommandPath* path) +{ + if (!isVisible()) + { return; } - if (m_Effect != nullptr) { + if (m_Effect != nullptr) + { /// We're guaranteed to get a metrics path here if we have an effect. auto factory = artboard()->factory(); path = m_Effect->effectPath(reinterpret_cast<MetricsPath*>(path), factory); @@ -35,31 +40,37 @@ renderer->drawPath(path->renderPath(), renderPaint()); } -void Stroke::thicknessChanged() { +void Stroke::thicknessChanged() +{ assert(m_RenderPaint != nullptr); m_RenderPaint->thickness(thickness()); } -void Stroke::capChanged() { +void Stroke::capChanged() +{ assert(m_RenderPaint != nullptr); m_RenderPaint->cap((StrokeCap)cap()); } -void Stroke::joinChanged() { +void Stroke::joinChanged() +{ assert(m_RenderPaint != nullptr); m_RenderPaint->join((StrokeJoin)join()); } void Stroke::addStrokeEffect(StrokeEffect* effect) { m_Effect = effect; } -void Stroke::invalidateEffects() { - if (m_Effect != nullptr) { +void Stroke::invalidateEffects() +{ + if (m_Effect != nullptr) + { m_Effect->invalidateEffect(); } invalidateRendering(); } -void Stroke::invalidateRendering() { +void Stroke::invalidateRendering() +{ assert(m_RenderPaint != nullptr); m_RenderPaint->invalidateStroke(); } \ No newline at end of file
diff --git a/src/shapes/paint/trim_path.cpp b/src/shapes/paint/trim_path.cpp index 079c021..32c5d01 100644 --- a/src/shapes/paint/trim_path.cpp +++ b/src/shapes/paint/trim_path.cpp
@@ -5,8 +5,10 @@ using namespace rive; -StatusCode TrimPath::onAddedClean(CoreContext* context) { - if (!parent()->is<Stroke>()) { +StatusCode TrimPath::onAddedClean(CoreContext* context) +{ + if (!parent()->is<Stroke>()) + { return StatusCode::InvalidObject; } @@ -15,85 +17,106 @@ return StatusCode::Ok; } -RenderPath* TrimPath::effectPath(MetricsPath* source, Factory* factory) { - if (m_RenderPath != nullptr) { +RenderPath* TrimPath::effectPath(MetricsPath* source, Factory* factory) +{ + if (m_RenderPath != nullptr) + { return m_RenderPath; } // Source is always a containing (shape) path. const std::vector<MetricsPath*>& subPaths = source->paths(); - if (!m_TrimmedPath) { + if (!m_TrimmedPath) + { m_TrimmedPath = factory->makeEmptyRenderPath(); - } else { + } + else + { m_TrimmedPath->reset(); } auto renderOffset = std::fmod(std::fmod(offset(), 1.0f) + 1.0f, 1.0f); - switch (modeValue()) { - case 1: { + switch (modeValue()) + { + case 1: + { float totalLength = source->length(); auto startLength = totalLength * (start() + renderOffset); auto endLength = totalLength * (end() + renderOffset); - if (endLength < startLength) { + if (endLength < startLength) + { float swap = startLength; startLength = endLength; endLength = swap; } - if (startLength > totalLength) { + if (startLength > totalLength) + { startLength -= totalLength; endLength -= totalLength; } int i = 0, subPathCount = (int)subPaths.size(); - while (endLength > 0) { + while (endLength > 0) + { auto path = subPaths[i % subPathCount]; auto pathLength = path->length(); - if (startLength < pathLength) { + if (startLength < pathLength) + { path->trim(startLength, endLength, true, m_TrimmedPath.get()); endLength -= pathLength; startLength = 0; - } else { + } + else + { startLength -= pathLength; endLength -= pathLength; } i++; } - } break; + } + break; - case 2: { - for (auto path : subPaths) { + case 2: + { + for (auto path : subPaths) + { auto pathLength = path->length(); auto startLength = pathLength * (start() + renderOffset); auto endLength = pathLength * (end() + renderOffset); - if (endLength < startLength) { + if (endLength < startLength) + { auto length = startLength; startLength = endLength; endLength = length; } - if (startLength > pathLength) { + if (startLength > pathLength) + { startLength -= pathLength; endLength -= pathLength; } path->trim(startLength, endLength, true, m_TrimmedPath.get()); - while (endLength > pathLength) { + while (endLength > pathLength) + { startLength = 0; endLength -= pathLength; path->trim(startLength, endLength, true, m_TrimmedPath.get()); } } - } break; + } + break; } m_RenderPath = m_TrimmedPath.get(); return m_RenderPath; } -void TrimPath::invalidateEffect() { +void TrimPath::invalidateEffect() +{ m_RenderPath = nullptr; auto stroke = parent()->as<Stroke>(); stroke->parent()->addDirt(ComponentDirt::Paint);
diff --git a/src/shapes/path.cpp b/src/shapes/path.cpp index 6ef2c0f..bcb4aca 100644 --- a/src/shapes/path.cpp +++ b/src/shapes/path.cpp
@@ -14,7 +14,8 @@ /// radius. Based on "natural rounding" https://observablehq.com/@daformat/rounding-polygon-corners static float computeIdealControlPointDistance(const Vec2D& toPrev, const Vec2D& toNext, - float radius) { + float radius) +{ // Get the angle between next and prev float angle = fabs(atan2(Vec2D::cross(toPrev, toNext), Vec2D::dot(toPrev, toNext))); @@ -23,9 +24,11 @@ (angle < math::PI / 2 ? 1 + cos(angle) : 2.0f - sin(angle))); } -StatusCode Path::onAddedClean(CoreContext* context) { +StatusCode Path::onAddedClean(CoreContext* context) +{ StatusCode code = Super::onAddedClean(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } @@ -33,7 +36,8 @@ for (auto currentParent = parent(); currentParent != nullptr; currentParent = currentParent->parent()) { - if (currentParent->is<Shape>()) { + if (currentParent->is<Shape>()) + { m_Shape = currentParent->as<Shape>(); m_Shape->addPath(this); return StatusCode::Ok; @@ -43,7 +47,8 @@ return StatusCode::MissingObject; } -void Path::buildDependencies() { +void Path::buildDependencies() +{ Super::buildDependencies(); // Make sure this is called once the shape has all of the paints added // (paints get added during the added cycle so buildDependencies is a good @@ -55,13 +60,15 @@ const Mat2D& Path::pathTransform() const { return worldTransform(); } -void Path::buildPath(CommandPath& commandPath) const { +void Path::buildPath(CommandPath& commandPath) const +{ const bool isClosed = isPathClosed(); const std::vector<PathVertex*>& vertices = m_Vertices; auto length = vertices.size(); - if (length < 2) { + if (length < 2) + { return; } auto firstPoint = vertices[0]; @@ -73,18 +80,22 @@ Vec2D start, startIn; bool startIsCubic; - if (firstPoint->is<CubicVertex>()) { + if (firstPoint->is<CubicVertex>()) + { auto cubic = firstPoint->as<CubicVertex>(); startIsCubic = prevIsCubic = true; startIn = cubic->renderIn(); out = cubic->renderOut(); start = cubic->renderTranslation(); commandPath.move(start); - } else { + } + else + { startIsCubic = prevIsCubic = false; auto point = *firstPoint->as<StraightVertex>(); auto radius = point.radius(); - if (radius > 0.0f) { + if (radius > 0.0f) + { auto prev = vertices[length - 1]; Vec2D pos = point.renderTranslation(); @@ -114,16 +125,20 @@ out = Vec2D::scaleAndAdd(pos, toNext, renderRadius); commandPath.cubic(outPoint, inPoint, out); prevIsCubic = false; - } else { + } + else + { startIn = start = out = point.renderTranslation(); commandPath.move(out); } } - for (size_t i = 1; i < length; i++) { + for (size_t i = 1; i < length; i++) + { auto vertex = vertices[i]; - if (vertex->is<CubicVertex>()) { + if (vertex->is<CubicVertex>()) + { auto cubic = vertex->as<CubicVertex>(); auto inPoint = cubic->renderIn(); auto translation = cubic->renderTranslation(); @@ -132,11 +147,14 @@ prevIsCubic = true; out = cubic->renderOut(); - } else { + } + else + { auto point = *vertex->as<StraightVertex>(); Vec2D pos = point.renderTranslation(); auto radius = point.radius(); - if (radius > 0.0f) { + if (radius > 0.0f) + { auto prev = vertices[i - 1]; Vec2D toPrev = (prev->is<CubicVertex>() ? prev->as<CubicVertex>()->renderOut() : prev->renderTranslation()) - @@ -156,9 +174,12 @@ computeIdealControlPointDistance(toPrev, toNext, renderRadius); Vec2D translation = Vec2D::scaleAndAdd(pos, toPrev, renderRadius); - if (prevIsCubic) { + if (prevIsCubic) + { commandPath.cubic(out, translation, translation); - } else { + } + else + { commandPath.line(translation); } @@ -167,45 +188,59 @@ out = Vec2D::scaleAndAdd(pos, toNext, renderRadius); commandPath.cubic(outPoint, inPoint, out); prevIsCubic = false; - } else if (prevIsCubic) { + } + else if (prevIsCubic) + { commandPath.cubic(out, pos, pos); prevIsCubic = false; out = pos; - } else { + } + else + { out = pos; commandPath.line(out); } } } - if (isClosed) { - if (prevIsCubic || startIsCubic) { + if (isClosed) + { + if (prevIsCubic || startIsCubic) + { commandPath.cubic(out, startIn, start); - } else { + } + else + { commandPath.line(start); } commandPath.close(); } } -void Path::markPathDirty() { +void Path::markPathDirty() +{ addDirt(ComponentDirt::Path); - if (m_Shape != nullptr) { + if (m_Shape != nullptr) + { m_Shape->pathChanged(); } } -void Path::onDirty(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::WorldTransform) && m_Shape != nullptr) { +void Path::onDirty(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::WorldTransform) && m_Shape != nullptr) + { m_Shape->pathChanged(); } } -void Path::update(ComponentDirt value) { +void Path::update(ComponentDirt value) +{ Super::update(value); assert(m_CommandPath != nullptr); - if (hasDirt(value, ComponentDirt::Path)) { + if (hasDirt(value, ComponentDirt::Path)) + { // Build path doesn't explicitly reset because we use it to concatenate // multiple built paths into a single command path (like the hit // tester). @@ -223,7 +258,8 @@ #ifdef ENABLE_QUERY_FLAT_VERTICES -class DisplayCubicVertex : public CubicVertex { +class DisplayCubicVertex : public CubicVertex +{ public: DisplayCubicVertex(const Vec2D& in, const Vec2D& out, const Vec2D& translation) @@ -240,15 +276,18 @@ void computeOut() override {} }; -FlattenedPath* Path::makeFlat(bool transformToParent) { - if (m_Vertices.empty()) { +FlattenedPath* Path::makeFlat(bool transformToParent) +{ + if (m_Vertices.empty()) + { return nullptr; } // Path transform always puts the path into world space. auto transform = pathTransform(); - if (transformToParent && parent()->is<TransformComponent>()) { + if (transformToParent && parent()->is<TransformComponent>()) + { // Put the transform in parent space. auto world = parent()->as<TransformComponent>()->worldTransform(); transform = world.invertOrIdentity() * transform; @@ -258,13 +297,17 @@ auto length = m_Vertices.size(); PathVertex* previous = isPathClosed() ? m_Vertices[length - 1] : nullptr; bool deletePrevious = false; - for (size_t i = 0; i < length; i++) { + for (size_t i = 0; i < length; i++) + { auto vertex = m_Vertices[i]; - switch (vertex->coreType()) { - case StraightVertex::typeKey: { + 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>() @@ -300,7 +343,8 @@ auto v2 = new DisplayCubicVertex(in, translation, translation); flat->addVertex(v2, transform); - if (deletePrevious) { + if (deletePrevious) + { delete previous; } previous = v2; @@ -310,7 +354,8 @@ [[fallthrough]]; } default: - if (deletePrevious) { + if (deletePrevious) + { delete previous; } previous = vertex; @@ -319,16 +364,19 @@ break; } } - if (deletePrevious) { + if (deletePrevious) + { delete previous; } return flat; } -void FlattenedPath::addVertex(PathVertex* vertex, const Mat2D& transform) { +void FlattenedPath::addVertex(PathVertex* vertex, const Mat2D& transform) +{ // To make this easy and relatively clean we just transform the vertices. // Requires the vertex to be passed in as a clone. - if (vertex->is<CubicVertex>()) { + if (vertex->is<CubicVertex>()) + { auto cubic = vertex->as<CubicVertex>(); // Cubics need to be transformed so we create a Display version which @@ -339,7 +387,9 @@ auto displayCubic = new DisplayCubicVertex(in, out, translation); m_Vertices.push_back(displayCubic); - } else { + } + else + { auto point = new PathVertex(); Vec2D translation = transform * vertex->renderTranslation(); point->x(translation.x); @@ -348,8 +398,10 @@ } } -FlattenedPath::~FlattenedPath() { - for (auto vertex : m_Vertices) { +FlattenedPath::~FlattenedPath() +{ + for (auto vertex : m_Vertices) + { delete vertex; } }
diff --git a/src/shapes/path_composer.cpp b/src/shapes/path_composer.cpp index 7c2d20d..e10373e 100644 --- a/src/shapes/path_composer.cpp +++ b/src/shapes/path_composer.cpp
@@ -10,38 +10,52 @@ PathComposer::PathComposer(Shape* shape) : m_Shape(shape) {} -void PathComposer::buildDependencies() { +void PathComposer::buildDependencies() +{ assert(m_Shape != nullptr); m_Shape->addDependent(this); - for (auto path : m_Shape->paths()) { + for (auto path : m_Shape->paths()) + { path->addDependent(this); } } -void PathComposer::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path)) { +void PathComposer::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path)) + { auto space = m_Shape->pathSpace(); - if ((space & PathSpace::Local) == PathSpace::Local) { - if (m_LocalPath == nullptr) { + if ((space & PathSpace::Local) == PathSpace::Local) + { + if (m_LocalPath == nullptr) + { m_LocalPath = m_Shape->makeCommandPath(PathSpace::Local); - } else { + } + else + { m_LocalPath->reset(); } auto world = m_Shape->worldTransform(); Mat2D inverseWorld = world.invertOrIdentity(); // Get all the paths into local shape space. - for (auto path : m_Shape->paths()) { + for (auto path : m_Shape->paths()) + { const auto localTransform = inverseWorld * path->pathTransform(); m_LocalPath->addPath(path->commandPath(), localTransform); } } - if ((space & PathSpace::World) == PathSpace::World) { - if (m_WorldPath == nullptr) { + if ((space & PathSpace::World) == PathSpace::World) + { + if (m_WorldPath == nullptr) + { m_WorldPath = m_Shape->makeCommandPath(PathSpace::World); - } else { + } + else + { m_WorldPath->reset(); } - for (auto path : m_Shape->paths()) { + for (auto path : m_Shape->paths()) + { const Mat2D& transform = path->pathTransform(); m_WorldPath->addPath(path->commandPath(), transform); }
diff --git a/src/shapes/path_vertex.cpp b/src/shapes/path_vertex.cpp index 6e070b3..637ec0a 100644 --- a/src/shapes/path_vertex.cpp +++ b/src/shapes/path_vertex.cpp
@@ -3,20 +3,25 @@ using namespace rive; -StatusCode PathVertex::onAddedDirty(CoreContext* context) { +StatusCode PathVertex::onAddedDirty(CoreContext* context) +{ StatusCode code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } - if (!parent()->is<Path>()) { + if (!parent()->is<Path>()) + { return StatusCode::MissingObject; } parent()->as<Path>()->addVertex(this); return StatusCode::Ok; } -void PathVertex::markGeometryDirty() { - if (parent() == nullptr) { +void PathVertex::markGeometryDirty() +{ + if (parent() == nullptr) + { // This is an acceptable condition as the parametric paths create points // that are not part of the core context. return;
diff --git a/src/shapes/points_path.cpp b/src/shapes/points_path.cpp index a902f5a..1d20b03 100644 --- a/src/shapes/points_path.cpp +++ b/src/shapes/points_path.cpp
@@ -6,30 +6,38 @@ using namespace rive; -void PointsPath::buildDependencies() { +void PointsPath::buildDependencies() +{ Super::buildDependencies(); - if (skin() != nullptr) { + if (skin() != nullptr) + { skin()->addDependent(this); } } -const Mat2D& PointsPath::pathTransform() const { - if (skin() != nullptr) { +const Mat2D& PointsPath::pathTransform() const +{ + if (skin() != nullptr) + { static Mat2D identity; return identity; } return worldTransform(); } -void PointsPath::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path) && skin() != nullptr) { +void PointsPath::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path) && skin() != nullptr) + { skin()->deform(Span<Vertex*>((Vertex**)m_Vertices.data(), m_Vertices.size())); } Super::update(value); } -void PointsPath::markPathDirty() { - if (skin() != nullptr) { +void PointsPath::markPathDirty() +{ + if (skin() != nullptr) + { skin()->addDirt(ComponentDirt::Skin); } Super::markPathDirty();
diff --git a/src/shapes/polygon.cpp b/src/shapes/polygon.cpp index aabfef4..1bb12f6 100644 --- a/src/shapes/polygon.cpp +++ b/src/shapes/polygon.cpp
@@ -16,7 +16,8 @@ std::size_t Polygon::vertexCount() { return points(); } -void Polygon::buildPolygon() { +void Polygon::buildPolygon() +{ auto halfWidth = width() / 2; auto halfHeight = height() / 2; @@ -26,7 +27,8 @@ auto angle = -math::PI / 2; auto inc = 2 * -math::PI / points(); - for (StraightVertex& vertex : m_PolygonVertices) { + for (StraightVertex& vertex : m_PolygonVertices) + { vertex.x(ox + cos(angle) * halfWidth); vertex.y(oy + sin(angle) * halfHeight); vertex.radius(cornerRadius()); @@ -34,12 +36,16 @@ } } -void Polygon::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path)) { - if (m_PolygonVertices.size() != vertexCount()) { +void Polygon::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path)) + { + if (m_PolygonVertices.size() != vertexCount()) + { m_PolygonVertices.resize(vertexCount()); m_Vertices.clear(); - for (StraightVertex& vertex : m_PolygonVertices) { + for (StraightVertex& vertex : m_PolygonVertices) + { m_Vertices.push_back(&vertex); } }
diff --git a/src/shapes/rectangle.cpp b/src/shapes/rectangle.cpp index 84eed38..e70cb0e 100644 --- a/src/shapes/rectangle.cpp +++ b/src/shapes/rectangle.cpp
@@ -2,7 +2,8 @@ using namespace rive; -Rectangle::Rectangle() { +Rectangle::Rectangle() +{ addVertex(&m_Vertex1); addVertex(&m_Vertex2); addVertex(&m_Vertex3); @@ -14,8 +15,10 @@ void Rectangle::cornerRadiusBLChanged() { markPathDirty(); } void Rectangle::cornerRadiusBRChanged() { markPathDirty(); } -void Rectangle::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path)) { +void Rectangle::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path)) + { auto radius = cornerRadiusTL(); auto link = linkCornerRadius();
diff --git a/src/shapes/shape.cpp b/src/shapes/shape.cpp index 6851c73..cdcc59b 100644 --- a/src/shapes/shape.cpp +++ b/src/shapes/shape.cpp
@@ -11,40 +11,50 @@ Shape::Shape() : m_PathComposer(this) {} -void Shape::addPath(Path* path) { +void Shape::addPath(Path* path) +{ // Make sure the path is not already in the shape. assert(std::find(m_Paths.begin(), m_Paths.end(), path) == m_Paths.end()); m_Paths.push_back(path); } -void Shape::update(ComponentDirt value) { +void Shape::update(ComponentDirt value) +{ Super::update(value); - if (hasDirt(value, ComponentDirt::RenderOpacity)) { - for (auto shapePaint : m_ShapePaints) { + if (hasDirt(value, ComponentDirt::RenderOpacity)) + { + for (auto shapePaint : m_ShapePaints) + { shapePaint->renderOpacity(renderOpacity()); } } } -void Shape::pathChanged() { +void Shape::pathChanged() +{ m_PathComposer.addDirt(ComponentDirt::Path, true); invalidateStrokeEffects(); } -void Shape::draw(Renderer* renderer) { - if (renderOpacity() == 0.0f) { +void Shape::draw(Renderer* renderer) +{ + if (renderOpacity() == 0.0f) + { return; } auto shouldRestore = clip(renderer); - for (auto shapePaint : m_ShapePaints) { - if (!shapePaint->isVisible()) { + for (auto shapePaint : m_ShapePaints) + { + if (!shapePaint->isVisible()) + { continue; } renderer->save(); bool paintsInLocal = (shapePaint->pathSpace() & PathSpace::Local) == PathSpace::Local; - if (paintsInLocal) { + if (paintsInLocal) + { renderer->transform(worldTransform()); } shapePaint->draw(renderer, @@ -52,23 +62,28 @@ renderer->restore(); } - if (shouldRestore) { + if (shouldRestore) + { renderer->restore(); } } -bool Shape::hitTest(const IAABB& area) const { +bool Shape::hitTest(const IAABB& area) const +{ HitTestCommandPath tester(area); - for (auto path : m_Paths) { + for (auto path : m_Paths) + { tester.setXform(path->pathTransform()); path->buildPath(tester); } return tester.wasHit(); } -Core* Shape::hitTest(HitInfo* hinfo, const Mat2D& xform) { - if (renderOpacity() == 0.0f) { +Core* Shape::hitTest(HitInfo* hinfo, const Mat2D& xform) +{ + if (renderOpacity() == 0.0f) + { return nullptr; } @@ -76,40 +91,50 @@ const bool shapeIsLocal = (pathSpace() & PathSpace::Local) == PathSpace::Local; - for (auto rit = m_ShapePaints.rbegin(); rit != m_ShapePaints.rend(); ++rit) { + for (auto rit = m_ShapePaints.rbegin(); rit != m_ShapePaints.rend(); ++rit) + { auto shapePaint = *rit; - if (shapePaint->isTranslucent()) { + if (shapePaint->isTranslucent()) + { continue; } - if (!shapePaint->isVisible()) { + if (!shapePaint->isVisible()) + { continue; } auto paintIsLocal = (shapePaint->pathSpace() & PathSpace::Local) == PathSpace::Local; auto mx = xform; - if (paintIsLocal) { + if (paintIsLocal) + { mx *= worldTransform(); } HitTestCommandPath tester(hinfo->area); - for (auto path : m_Paths) { - if (shapeIsLocal) { + for (auto path : m_Paths) + { + if (shapeIsLocal) + { tester.setXform(xform * path->pathTransform()); - } else { + } + else + { tester.setXform(mx * path->pathTransform()); } path->buildPath(tester); } - if (tester.wasHit()) { + if (tester.wasHit()) + { return this; } } return nullptr; } -void Shape::buildDependencies() { +void Shape::buildDependencies() +{ // Make sure to propagate the call to PathComposer as it's no longer part of // Core and owned only by the Shape. m_PathComposer.buildDependencies(); @@ -119,16 +144,19 @@ // Set the blend mode on all the shape paints. If we ever animate this // property, we'll need to update it in the update cycle/mark dirty when the // blend mode changes. - for (auto paint : m_ShapePaints) { + for (auto paint : m_ShapePaints) + { paint->blendMode(blendMode()); } } void Shape::addDefaultPathSpace(PathSpace space) { m_DefaultPathSpace |= space; } -StatusCode Shape::onAddedDirty(CoreContext* context) { +StatusCode Shape::onAddedDirty(CoreContext* context) +{ auto code = Super::onAddedDirty(context); - if (code != StatusCode::Ok) { + if (code != StatusCode::Ok) + { return code; } // This ensures context propagates to path composer too.
diff --git a/src/shapes/shape_paint_container.cpp b/src/shapes/shape_paint_container.cpp index 0f22230..bb8d5c5 100644 --- a/src/shapes/shape_paint_container.cpp +++ b/src/shapes/shape_paint_container.cpp
@@ -10,33 +10,43 @@ using namespace rive; -ShapePaintContainer* ShapePaintContainer::from(Component* component) { - switch (component->coreType()) { - case Artboard::typeKey: return component->as<Artboard>(); - case Shape::typeKey: return component->as<Shape>(); +ShapePaintContainer* ShapePaintContainer::from(Component* component) +{ + switch (component->coreType()) + { + case Artboard::typeKey: + return component->as<Artboard>(); + case Shape::typeKey: + return component->as<Shape>(); } return nullptr; } void ShapePaintContainer::addPaint(ShapePaint* paint) { m_ShapePaints.push_back(paint); } -PathSpace ShapePaintContainer::pathSpace() const { +PathSpace ShapePaintContainer::pathSpace() const +{ PathSpace space = m_DefaultPathSpace; - for (auto paint : m_ShapePaints) { + for (auto paint : m_ShapePaints) + { space |= paint->pathSpace(); } return space; } -void ShapePaintContainer::invalidateStrokeEffects() { - for (auto paint : m_ShapePaints) { - if (paint->is<Stroke>()) { +void ShapePaintContainer::invalidateStrokeEffects() +{ + for (auto paint : m_ShapePaints) + { + if (paint->is<Stroke>()) + { paint->as<Stroke>()->invalidateEffects(); } } } -std::unique_ptr<CommandPath> ShapePaintContainer::makeCommandPath(PathSpace space) { +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 = @@ -44,24 +54,34 @@ bool needForEffects = false; - for (auto paint : m_ShapePaints) { - if (space != PathSpace::Neither && (space & paint->pathSpace()) != space) { + for (auto paint : m_ShapePaints) + { + if (space != PathSpace::Neither && (space & paint->pathSpace()) != space) + { continue; } - if (paint->is<Stroke>() && paint->as<Stroke>()->hasStrokeEffect()) { + if (paint->is<Stroke>() && paint->as<Stroke>()->hasStrokeEffect()) + { needForEffects = true; - } else { + } + else + { needForRender = true; } } auto factory = getArtboard()->factory(); - if (needForEffects && needForRender) { + if (needForEffects && needForRender) + { return std::unique_ptr<CommandPath>(new RenderMetricsPath(factory->makeEmptyRenderPath())); - } else if (needForEffects) { + } + else if (needForEffects) + { return std::unique_ptr<CommandPath>(new OnlyMetricsPath()); - } else { + } + else + { return std::unique_ptr<CommandPath>(factory->makeEmptyRenderPath()); } }
diff --git a/src/shapes/star.cpp b/src/shapes/star.cpp index 2705eb1..20723d8 100644 --- a/src/shapes/star.cpp +++ b/src/shapes/star.cpp
@@ -12,7 +12,8 @@ std::size_t Star::vertexCount() { return points() * 2; } -void Star::buildPolygon() { +void Star::buildPolygon() +{ auto halfWidth = width() / 2; auto halfHeight = height() / 2; auto innerHalfWidth = width() * innerRadius() / 2; @@ -24,7 +25,8 @@ auto angle = -math::PI / 2; auto inc = 2 * math::PI / length; - for (std::size_t i = 0; i < length; i += 2) { + for (std::size_t i = 0; i < length; i += 2) + { { StraightVertex& vertex = m_PolygonVertices[i]; vertex.x(ox + cos(angle) * halfWidth);
diff --git a/src/shapes/triangle.cpp b/src/shapes/triangle.cpp index 5c9553d..6b9ca51 100644 --- a/src/shapes/triangle.cpp +++ b/src/shapes/triangle.cpp
@@ -4,14 +4,17 @@ using namespace rive; -Triangle::Triangle() { +Triangle::Triangle() +{ addVertex(&m_Vertex1); addVertex(&m_Vertex2); addVertex(&m_Vertex3); } -void Triangle::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Path)) { +void Triangle::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Path)) + { auto ox = -originX() * width(); auto oy = -originY() * height();
diff --git a/src/shapes/vertex.cpp b/src/shapes/vertex.cpp index a7c6890..477122d 100644 --- a/src/shapes/vertex.cpp +++ b/src/shapes/vertex.cpp
@@ -2,8 +2,10 @@ using namespace rive; -Vec2D Vertex::renderTranslation() { - if (hasWeight()) { +Vec2D Vertex::renderTranslation() +{ + if (hasWeight()) + { return m_Weight->translation(); } return Vec2D(x(), y()); @@ -12,7 +14,8 @@ void Vertex::xChanged() { markGeometryDirty(); } void Vertex::yChanged() { markGeometryDirty(); } -void Vertex::deform(const Mat2D& worldTransform, const float* boneTransforms) { +void Vertex::deform(const Mat2D& worldTransform, const float* boneTransforms) +{ m_Weight->translation() = Weight::deform(Vec2D(x(), y()), m_Weight->indices(), m_Weight->values(),
diff --git a/src/simple_array.cpp b/src/simple_array.cpp index cd4ecfc..095ee22 100644 --- a/src/simple_array.cpp +++ b/src/simple_array.cpp
@@ -1,11 +1,14 @@ #ifdef TESTING #include "rive/simple_array.hpp" -namespace rive { -namespace SimpleArrayTesting { +namespace rive +{ +namespace SimpleArrayTesting +{ int mallocCount = 0; int reallocCount = 0; int freeCount = 0; -void resetCounters() { +void resetCounters() +{ mallocCount = 0; reallocCount = 0; freeCount = 0;
diff --git a/src/text/line_breaker.cpp b/src/text/line_breaker.cpp index d862e41..190cac0 100644 --- a/src/text/line_breaker.cpp +++ b/src/text/line_breaker.cpp
@@ -10,25 +10,33 @@ void RenderGlyphLine::ComputeLineSpacing(Span<RenderGlyphLine> lines, Span<const RenderGlyphRun> runs, float width, - RenderTextAlign align) { + RenderTextAlign align) +{ float maxLineWidth = 0.0f; - if (autowidth(width)) { - for (auto& line : lines) { + if (autowidth(width)) + { + for (auto& line : lines) + { auto lineWidth = runs[line.endRun].xpos[line.endIndex] - runs[line.startRun].xpos[line.startIndex]; - if (lineWidth > maxLineWidth) { + if (lineWidth > maxLineWidth) + { maxLineWidth = lineWidth; } } - } else { + } + else + { maxLineWidth = width; } float Y = 0; // top of our frame - for (auto& line : lines) { + for (auto& line : lines) + { float asc = 0; float des = 0; - for (int i = line.startRun; i <= line.endRun; ++i) { + for (int i = line.startRun; i <= line.endRun; ++i) + { const auto& run = runs[i]; asc = std::min(asc, run.font->lineMetrics().ascent * run.size); @@ -41,9 +49,14 @@ line.bottom = Y; auto lineWidth = runs[line.endRun].xpos[line.endIndex] - runs[line.startRun].xpos[line.startIndex]; - switch (align) { - case RenderTextAlign::right: line.startX = maxLineWidth - lineWidth; break; - case RenderTextAlign::left: line.startX = 0; break; + switch (align) + { + case RenderTextAlign::right: + line.startX = maxLineWidth - lineWidth; + break; + case RenderTextAlign::left: + line.startX = 0; + break; case RenderTextAlign::center: line.startX = maxLineWidth / 2.0f - lineWidth / 2.0f; break; @@ -51,17 +64,21 @@ } } -struct WordMarker { +struct WordMarker +{ const RenderGlyphRun* run; uint32_t index; - bool next(Span<const RenderGlyphRun> runs) { + bool next(Span<const RenderGlyphRun> runs) + { index += 2; - while (index >= run->breaks.size()) { + while (index >= run->breaks.size()) + { index -= run->breaks.size(); run++; - if (run == runs.end()) { + if (run == runs.end()) + { return false; } } @@ -69,44 +86,60 @@ } }; -class RunIterator { +class RunIterator +{ Span<const RenderGlyphRun> m_runs; const RenderGlyphRun* m_run; uint32_t m_index; public: RunIterator(Span<const RenderGlyphRun> runs, const RenderGlyphRun* run, uint32_t index) : - m_runs(runs), m_run(run), m_index(index) {} + m_runs(runs), m_run(run), m_index(index) + {} - bool back() { - if (m_index == 0) { - if (m_run == m_runs.begin()) { + bool back() + { + if (m_index == 0) + { + if (m_run == m_runs.begin()) + { return false; } m_run--; - if (m_run->glyphs.size() == 0) { + if (m_run->glyphs.size() == 0) + { m_index = 0; return back(); - } else { + } + else + { m_index = m_run->glyphs.size() == 0 ? 0 : (uint32_t)m_run->glyphs.size() - 1; } - } else { + } + else + { m_index--; } return true; } - bool forward() { - if (m_index == m_run->glyphs.size()) { - if (m_run == m_runs.end()) { + bool forward() + { + if (m_index == m_run->glyphs.size()) + { + if (m_run == m_runs.end()) + { return false; } m_run++; m_index = 0; - if (m_index == m_run->glyphs.size()) { + if (m_index == m_run->glyphs.size()) + { return forward(); } - } else { + } + else + { m_index++; } return true; @@ -122,13 +155,15 @@ std::vector<RenderGlyphLine> RenderGlyphLine::BreakLines(Span<const RenderGlyphRun> runs, float width, - RenderTextAlign align) { + RenderTextAlign align) +{ float maxLineWidth = autowidth(width) ? std::numeric_limits<float>::max() : width; std::vector<RenderGlyphLine> lines; - if (runs.empty()) { + if (runs.empty()) + { return lines; } @@ -144,14 +179,18 @@ uint32_t lastEndIndex = end.index; uint32_t startBreakIndex = start.run->breaks[start.index]; float x = end.run->xpos[breakIndex]; - while (true) { - if (advanceWord) { + while (true) + { + if (advanceWord) + { lastEndIndex = end.index; - if (!start.next(runs)) { + if (!start.next(runs)) + { break; } - if (!end.next(runs)) { + if (!end.next(runs)) + { break; } @@ -162,42 +201,54 @@ x = end.run->xpos[breakIndex]; } - if (breakIndex != startBreakIndex && x > limit) { + if (breakIndex != startBreakIndex && x > limit) + { uint32_t startRun = (uint32_t)(start.run - runs.begin()); // A whole word overflowed, break until we can no longer break (or // it fits). - if (line.startRun == startRun && line.startIndex == startBreakIndex) { + if (line.startRun == startRun && line.startIndex == startBreakIndex) + { bool canBreakMore = true; - while (canBreakMore && x > limit) { + while (canBreakMore && x > limit) + { RunIterator lineStart = RunIterator(runs, runs.begin() + line.startRun, line.startIndex); RunIterator lineEnd = RunIterator(runs, end.run, end.run->breaks[end.index]); // Look for the next character that doesn't overflow. - while (true) { - if (!lineEnd.back()) { + while (true) + { + if (!lineEnd.back()) + { // Hit the start of the text, can't go back. canBreakMore = false; break; - } else if (lineEnd.x() <= limit) { - if (lineStart == lineEnd && !lineEnd.forward()) { + } + else if (lineEnd.x() <= limit) + { + if (lineStart == lineEnd && !lineEnd.forward()) + { // Hit the start of the line and could not // go forward to consume a single character. // We can't break any further. canBreakMore = false; - } else { + } + else + { line.endRun = (uint32_t)(lineEnd.run() - runs.begin()); line.endIndex = lineEnd.index(); } break; } } - if (canBreakMore) { + if (canBreakMore) + { // Add the line and push the limit out. limit = lineEnd.x() + maxLineWidth; - if (!line.empty()) { + if (!line.empty()) + { lines.push_back(line); } // Setup the next line. @@ -205,23 +256,29 @@ lineEnd.index()); } } - } else { + } + else + { // word overflowed, knock it to a new line auto startX = start.run->xpos[start.run->breaks[start.index]]; limit = startX + maxLineWidth; - if (!line.empty() || start.index - lastEndIndex > 1) { + if (!line.empty() || start.index - lastEndIndex > 1) + { lines.push_back(line); } line = RenderGlyphLine(startRun, startBreakIndex); } - } else { + } + else + { line.endRun = (uint32_t)(end.run - runs.begin()); line.endIndex = end.run->breaks[end.index]; advanceWord = true; // Forced BR. - if (breakIndex == startBreakIndex) { + if (breakIndex == startBreakIndex) + { lines.push_back(line); auto startX = start.run->xpos[start.run->breaks[start.index]]; limit = startX + maxLineWidth; @@ -230,7 +287,8 @@ } } // Don't add a line that starts/ends at the same spot. - if (!line.empty()) { + if (!line.empty()) + { lines.push_back(line); }
diff --git a/src/text/renderfont_hb.cpp b/src/text/renderfont_hb.cpp index 7e97f2a..5b536aa 100644 --- a/src/text/renderfont_hb.cpp +++ b/src/text/renderfont_hb.cpp
@@ -16,19 +16,23 @@ // Initialized to null. Client can set this to a callback. HBRenderFont::FallbackProc HBRenderFont::gFallbackProc; -rive::rcp<rive::RenderFont> HBRenderFont::Decode(rive::Span<const uint8_t> span) { +rive::rcp<rive::RenderFont> HBRenderFont::Decode(rive::Span<const uint8_t> span) +{ auto blob = hb_blob_create_or_fail((const char*)span.data(), (unsigned)span.size(), HB_MEMORY_MODE_DUPLICATE, nullptr, nullptr); - if (blob) { + if (blob) + { auto face = hb_face_create(blob, 0); hb_blob_destroy(blob); - if (face) { + if (face) + { auto font = hb_font_create(face); hb_face_destroy(face); - if (font) { + if (font) + { return rive::rcp<rive::RenderFont>(new HBRenderFont(font)); } } @@ -41,50 +45,57 @@ constexpr int kStdScale = 2048; constexpr float gInvScale = 1.0f / kStdScale; -extern "C" { -static void -rpath_move_to(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, float x, float y, void*) { - ((rive::RawPath*)rpath)->moveTo(x * gInvScale, -y * gInvScale); -} -static void -rpath_line_to(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, float x1, float y1, void*) { - ((rive::RawPath*)rpath)->lineTo(x1 * gInvScale, -y1 * gInvScale); -} -static void rpath_quad_to(hb_draw_funcs_t*, - void* rpath, - hb_draw_state_t*, - float x1, - float y1, - float x2, - float y2, - void*) { - ((rive::RawPath*)rpath) - ->quadTo(x1 * gInvScale, -y1 * gInvScale, x2 * gInvScale, -y2 * gInvScale); -} -static void rpath_cubic_to(hb_draw_funcs_t*, - void* rpath, - hb_draw_state_t*, - float x1, - float y1, - float x2, - float y2, - float x3, - float y3, - void*) { - ((rive::RawPath*)rpath) - ->cubicTo(x1 * gInvScale, - -y1 * gInvScale, - x2 * gInvScale, - -y2 * gInvScale, - x3 * gInvScale, - -y3 * gInvScale); -} -static void rpath_close(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, void*) { - ((rive::RawPath*)rpath)->close(); -} +extern "C" +{ + static void + rpath_move_to(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, float x, float y, void*) + { + ((rive::RawPath*)rpath)->moveTo(x * gInvScale, -y * gInvScale); + } + static void + rpath_line_to(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, float x1, float y1, void*) + { + ((rive::RawPath*)rpath)->lineTo(x1 * gInvScale, -y1 * gInvScale); + } + static void rpath_quad_to(hb_draw_funcs_t*, + void* rpath, + hb_draw_state_t*, + float x1, + float y1, + float x2, + float y2, + void*) + { + ((rive::RawPath*)rpath) + ->quadTo(x1 * gInvScale, -y1 * gInvScale, x2 * gInvScale, -y2 * gInvScale); + } + static void rpath_cubic_to(hb_draw_funcs_t*, + void* rpath, + hb_draw_state_t*, + float x1, + float y1, + float x2, + float y2, + float x3, + float y3, + void*) + { + ((rive::RawPath*)rpath) + ->cubicTo(x1 * gInvScale, + -y1 * gInvScale, + x2 * gInvScale, + -y2 * gInvScale, + x3 * gInvScale, + -y3 * gInvScale); + } + static void rpath_close(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, void*) + { + ((rive::RawPath*)rpath)->close(); + } } -static rive::RenderFont::LineMetrics make_lmx(hb_font_t* font) { +static rive::RenderFont::LineMetrics make_lmx(hb_font_t* font) +{ // premable on font... hb_ot_font_set_funcs(font); hb_font_set_scale(font, kStdScale, kStdScale); @@ -95,8 +106,7 @@ } HBRenderFont::HBRenderFont(hb_font_t* font) : - RenderFont(make_lmx(font)), - m_Font(font) // we just take ownership, no need to call reference() + RenderFont(make_lmx(font)), m_Font(font) // we just take ownership, no need to call reference() { m_DrawFuncs = hb_draw_funcs_create(); hb_draw_funcs_set_move_to_func(m_DrawFuncs, rpath_move_to, nullptr, nullptr); @@ -107,21 +117,25 @@ hb_draw_funcs_make_immutable(m_DrawFuncs); } -HBRenderFont::~HBRenderFont() { +HBRenderFont::~HBRenderFont() +{ hb_draw_funcs_destroy(m_DrawFuncs); hb_font_destroy(m_Font); } -std::vector<rive::RenderFont::Axis> HBRenderFont::getAxes() const { +std::vector<rive::RenderFont::Axis> HBRenderFont::getAxes() const +{ auto face = hb_font_get_face(m_Font); std::vector<rive::RenderFont::Axis> axes; const int count = hb_ot_var_get_axis_count(face); - if (count > 0) { + if (count > 0) + { axes.resize(count); hb_ot_var_axis_info_t info; - for (int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) + { unsigned n = 1; hb_ot_var_get_axis_infos(face, i, &n, &info); assert(n == 1); @@ -133,7 +147,8 @@ return axes; } -std::vector<rive::RenderFont::Coord> HBRenderFont::getCoords() const { +std::vector<rive::RenderFont::Coord> HBRenderFont::getCoords() const +{ auto axes = this->getAxes(); // const int count = (int)axes.size(); @@ -141,15 +156,18 @@ const float* values = hb_font_get_var_coords_design(m_Font, &length); std::vector<rive::RenderFont::Coord> coords(length); - for (unsigned i = 0; i < length; ++i) { + for (unsigned i = 0; i < length; ++i) + { coords[i] = {axes[i].tag, values[i]}; } return coords; } -rive::rcp<rive::RenderFont> HBRenderFont::makeAtCoords(rive::Span<const Coord> coords) const { +rive::rcp<rive::RenderFont> HBRenderFont::makeAtCoords(rive::Span<const Coord> coords) const +{ AutoSTArray<16, hb_variation_t> vars(coords.size()); - for (size_t i = 0; i < coords.size(); ++i) { + for (size_t i = 0; i < coords.size(); ++i) + { vars[i] = {coords[i].axis, coords[i].value}; } auto font = hb_font_create_sub_font(m_Font); @@ -157,7 +175,8 @@ return rive::rcp<rive::RenderFont>(new HBRenderFont(font)); } -rive::RawPath HBRenderFont::getPath(rive::GlyphID glyph) const { +rive::RawPath HBRenderFont::getPath(rive::GlyphID glyph) const +{ rive::RawPath rpath; hb_font_get_glyph_shape(m_Font, glyph, m_DrawFuncs, &rpath); return rpath; @@ -174,7 +193,8 @@ static rive::RenderGlyphRun shape_run(const rive::Unichar text[], const rive::RenderTextRun& tr, - unsigned textOffset) { + unsigned textOffset) +{ hb_buffer_t* buf = hb_buffer_create(); hb_buffer_add_utf32(buf, text, tr.unicharCount, 0, tr.unicharCount); @@ -196,7 +216,8 @@ gr.size = tr.size; const float scale = tr.size / kStdScale; - for (unsigned int i = 0; i < glyph_count; i++) { + for (unsigned int i = 0; i < glyph_count; i++) + { // hb_position_t x_offset = glyph_pos[i].x_offset; // hb_position_t y_offset = glyph_pos[i].y_offset; @@ -211,7 +232,8 @@ static rive::RenderGlyphRun extract_subset(const rive::RenderGlyphRun& orig, size_t start, - size_t end) { + size_t end) +{ auto count = end - start; rive::RenderGlyphRun subset(rive::SimpleArray<rive::GlyphID>(&orig.glyphs[start], count), rive::SimpleArray<uint32_t>(&orig.textIndices[start], count), @@ -226,23 +248,30 @@ static void perform_fallback(rive::rcp<rive::RenderFont> fallbackFont, rive::SimpleArrayBuilder<rive::RenderGlyphRun>& gruns, const rive::Unichar text[], - const rive::RenderGlyphRun& orig) { + const rive::RenderGlyphRun& orig) +{ assert(orig.glyphs.size() > 0); const size_t count = orig.glyphs.size(); size_t startI = 0; - while (startI < count) { + while (startI < count) + { size_t endI = startI + 1; - if (orig.glyphs[startI] == 0) { - while (endI < count && orig.glyphs[endI] == 0) { + if (orig.glyphs[startI] == 0) + { + while (endI < count && orig.glyphs[endI] == 0) + { ++endI; } auto textStart = orig.textIndices[startI]; auto textCount = orig.textIndices[endI - 1] - textStart + 1; auto tr = rive::RenderTextRun{fallbackFont, orig.size, textCount}; gruns.add(shape_run(&text[textStart], tr, textStart)); - } else { - while (endI < count && orig.glyphs[endI] != 0) { + } + else + { + while (endI < count && orig.glyphs[endI] != 0) + { ++endI; } gruns.add(extract_subset(orig, startI, endI)); @@ -253,29 +282,37 @@ rive::SimpleArray<rive::RenderGlyphRun> HBRenderFont::onShapeText(rive::Span<const rive::Unichar> text, - rive::Span<const rive::RenderTextRun> truns) const { + rive::Span<const rive::RenderTextRun> truns) const +{ rive::SimpleArrayBuilder<rive::RenderGlyphRun> gruns(truns.size()); ///////////////// uint32_t unicharIndex = 0; - for (const auto& tr : truns) { + for (const auto& tr : truns) + { auto gr = shape_run(&text[unicharIndex], tr, unicharIndex); unicharIndex += tr.unicharCount; auto end = gr.glyphs.end(); auto iter = std::find(gr.glyphs.begin(), end, 0); - if (!gFallbackProc || iter == end) { + if (!gFallbackProc || iter == end) + { gruns.add(std::move(gr)); - } else { + } + else + { // found at least 1 zero in glyphs, so need to perform font-fallback size_t index = iter - gr.glyphs.begin(); rive::Unichar missing = text[gr.textIndices[index]]; // todo: consider sending more chars if that helps choose a font auto fallback = gFallbackProc({&missing, 1}); - if (fallback) { + if (fallback) + { perform_fallback(fallback, gruns, text.data(), gr); - } else { + } + else + { gruns.add(std::move(gr)); // oh well, just keep the missing glyphs } } @@ -283,8 +320,10 @@ // now turn the advances (widths) we stored in xpos[] into actual x-positions float pos = 0; - for (auto& gr : gruns) { - for (auto& xp : gr.xpos) { + for (auto& gr : gruns) + { + for (auto& xp : gr.xpos) + { float adv = xp; xp = pos; pos += adv;
diff --git a/src/transform_component.cpp b/src/transform_component.cpp index 4c62c54..5f52169 100644 --- a/src/transform_component.cpp +++ b/src/transform_component.cpp
@@ -6,55 +6,71 @@ using namespace rive; -StatusCode TransformComponent::onAddedClean(CoreContext* context) { +StatusCode TransformComponent::onAddedClean(CoreContext* context) +{ m_ParentTransformComponent = parent() != nullptr && parent()->is<WorldTransformComponent>() ? parent()->as<WorldTransformComponent>() : nullptr; return StatusCode::Ok; } -void TransformComponent::buildDependencies() { - if (parent() != nullptr) { +void TransformComponent::buildDependencies() +{ + if (parent() != nullptr) + { parent()->addDependent(this); } } -void TransformComponent::markTransformDirty() { - if (!addDirt(ComponentDirt::Transform)) { +void TransformComponent::markTransformDirty() +{ + if (!addDirt(ComponentDirt::Transform)) + { return; } markWorldTransformDirty(); } -void TransformComponent::updateTransform() { +void TransformComponent::updateTransform() +{ m_Transform = Mat2D::fromRotation(rotation()); m_Transform[4] = x(); m_Transform[5] = y(); m_Transform.scaleByValues(scaleX(), scaleY()); } -void TransformComponent::updateWorldTransform() { - if (m_ParentTransformComponent != nullptr) { +void TransformComponent::updateWorldTransform() +{ + if (m_ParentTransformComponent != nullptr) + { m_WorldTransform = m_ParentTransformComponent->m_WorldTransform * m_Transform; - } else { + } + else + { m_WorldTransform = m_Transform; } - for (auto constraint : m_Constraints) { + for (auto constraint : m_Constraints) + { constraint->constrain(this); } } -void TransformComponent::update(ComponentDirt value) { - if (hasDirt(value, ComponentDirt::Transform)) { +void TransformComponent::update(ComponentDirt value) +{ + if (hasDirt(value, ComponentDirt::Transform)) + { updateTransform(); } - if (hasDirt(value, ComponentDirt::WorldTransform)) { + if (hasDirt(value, ComponentDirt::WorldTransform)) + { updateWorldTransform(); } - if (hasDirt(value, ComponentDirt::RenderOpacity)) { + if (hasDirt(value, ComponentDirt::RenderOpacity)) + { m_RenderOpacity = opacity(); - if (m_ParentTransformComponent != nullptr) { + if (m_ParentTransformComponent != nullptr) + { m_RenderOpacity *= m_ParentTransformComponent->childOpacity(); } } @@ -68,6 +84,7 @@ void TransformComponent::scaleXChanged() { markTransformDirty(); } void TransformComponent::scaleYChanged() { markTransformDirty(); } -void TransformComponent::addConstraint(Constraint* constraint) { +void TransformComponent::addConstraint(Constraint* constraint) +{ m_Constraints.push_back(constraint); }
diff --git a/src/world_transform_component.cpp b/src/world_transform_component.cpp index 0a0ea78..a132577 100644 --- a/src/world_transform_component.cpp +++ b/src/world_transform_component.cpp
@@ -7,7 +7,8 @@ float WorldTransformComponent::childOpacity() { return opacity(); } -void WorldTransformComponent::markWorldTransformDirty() { +void WorldTransformComponent::markWorldTransformDirty() +{ addDirt(ComponentDirt::WorldTransform, true); }
diff --git a/tess/include/rive/math/mat4.hpp b/tess/include/rive/math/mat4.hpp index 83ecb5e..e8b7066 100644 --- a/tess/include/rive/math/mat4.hpp +++ b/tess/include/rive/math/mat4.hpp
@@ -3,9 +3,11 @@ #include <cstddef> -namespace rive { +namespace rive +{ class Mat2D; -class Mat4 { +class Mat4 +{ private: float m_Buffer[16]; @@ -18,7 +20,8 @@ 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, // clang-format on - } {} + } + {} Mat4(const Mat4& copy) = default; // Construct a 4x4 Matrix with the provided elements stored in row-major @@ -38,7 +41,8 @@ x3, y3, z3, w3, tx, ty, tz, tw, // clang-format on - } {} + } + {} Mat4(const Mat2D& mat2d); @@ -47,12 +51,14 @@ float& operator[](std::size_t idx) { return m_Buffer[idx]; } const float& operator[](std::size_t idx) const { return m_Buffer[idx]; } - Mat4& operator*=(const Mat4& rhs) { + Mat4& operator*=(const Mat4& rhs) + { *this = Mat4::multiply(*this, rhs); return *this; } - Mat4& operator*=(const Mat2D& rhs) { + Mat4& operator*=(const Mat2D& rhs) + { *this = Mat4::multiply(*this, rhs); return *this; }
diff --git a/tess/include/rive/tess/contour_stroke.hpp b/tess/include/rive/tess/contour_stroke.hpp index 915f7d2..3f70413 100644 --- a/tess/include/rive/tess/contour_stroke.hpp +++ b/tess/include/rive/tess/contour_stroke.hpp
@@ -7,13 +7,15 @@ #include <vector> #include <cstdint> -namespace rive { +namespace rive +{ class SegmentedContour; /// /// Builds a triangle strip vertex buffer from a SegmentedContour. /// -class ContourStroke { +class ContourStroke +{ protected: std::vector<Vec2D> m_TriangleStrip; std::vector<std::size_t> m_Offsets;
diff --git a/tess/include/rive/tess/segmented_contour.hpp b/tess/include/rive/tess/segmented_contour.hpp index 07b4657..4195cb1 100644 --- a/tess/include/rive/tess/segmented_contour.hpp +++ b/tess/include/rive/tess/segmented_contour.hpp
@@ -6,11 +6,13 @@ #include "rive/math/aabb.hpp" #include <vector> -namespace rive { +namespace rive +{ class RawPath; /// Utilty for converting a RawPath into a contour segments. -class SegmentedContour { +class SegmentedContour +{ private: std::vector<Vec2D> m_contourPoints;
diff --git a/tess/include/rive/tess/sokol/sokol_factory.hpp b/tess/include/rive/tess/sokol/sokol_factory.hpp index 93b8b27..2d9812a 100644 --- a/tess/include/rive/tess/sokol/sokol_factory.hpp +++ b/tess/include/rive/tess/sokol/sokol_factory.hpp
@@ -7,9 +7,11 @@ #include "rive/factory.hpp" -namespace rive { +namespace rive +{ -class SokolFactory : public Factory { +class SokolFactory : public Factory +{ public: SokolFactory();
diff --git a/tess/include/rive/tess/sokol/sokol_tess_renderer.hpp b/tess/include/rive/tess/sokol/sokol_tess_renderer.hpp index eddf07c..4a6f0d8 100644 --- a/tess/include/rive/tess/sokol/sokol_tess_renderer.hpp +++ b/tess/include/rive/tess/sokol/sokol_tess_renderer.hpp
@@ -8,10 +8,12 @@ #include "rive/tess/tess_renderer.hpp" #include "sokol_gfx.h" -namespace rive { +namespace rive +{ // The actual graphics device image. -class SokolRenderImageResource : public RefCnt<SokolRenderImageResource> { +class SokolRenderImageResource : public RefCnt<SokolRenderImageResource> +{ private: sg_image m_gpuResource; @@ -25,7 +27,8 @@ // The unique render image associated with a given source Rive asset. Can be stored in sub-region of // an actual graphics device image (SokolRenderImageResource). -class SokolRenderImage : public RenderImage { +class SokolRenderImage : public RenderImage +{ private: rcp<SokolRenderImageResource> m_gpuImage; sg_buffer m_vertexBuffer; @@ -47,7 +50,8 @@ sg_buffer uvBuffer() const { return m_uvBuffer; } }; -class SokolTessRenderer : public TessRenderer { +class SokolTessRenderer : public TessRenderer +{ private: static const std::size_t maxClippingPaths = 16; sg_pipeline m_meshPipeline;
diff --git a/tess/include/rive/tess/sub_path.hpp b/tess/include/rive/tess/sub_path.hpp index 31a4cc3..7c9259a 100644 --- a/tess/include/rive/tess/sub_path.hpp +++ b/tess/include/rive/tess/sub_path.hpp
@@ -4,12 +4,14 @@ #include "rive/renderer.hpp" #include "rive/math/mat2d.hpp" -namespace rive { +namespace rive +{ /// /// A reference to a sub-path added to a TessRenderPath with its relative /// transform. /// -class SubPath { +class SubPath +{ private: RenderPath* m_Path; Mat2D m_Transform;
diff --git a/tess/include/rive/tess/tess_render_path.hpp b/tess/include/rive/tess/tess_render_path.hpp index a3e24ec..c831de7 100644 --- a/tess/include/rive/tess/tess_render_path.hpp +++ b/tess/include/rive/tess/tess_render_path.hpp
@@ -8,10 +8,12 @@ #include "rive/tess/sub_path.hpp" #include "earcut.hpp" -namespace rive { +namespace rive +{ class ContourStroke; -class TessRenderPath : public RenderPath { +class TessRenderPath : public RenderPath +{ private: // TessRenderPath stores a RawPath so that it can use utility classes // that will work off of RawPath (like segmenting the contour and then
diff --git a/tess/include/rive/tess/tess_renderer.hpp b/tess/include/rive/tess/tess_renderer.hpp index 0771656..1122527 100644 --- a/tess/include/rive/tess/tess_renderer.hpp +++ b/tess/include/rive/tess/tess_renderer.hpp
@@ -12,14 +12,17 @@ #include <vector> #include <list> -namespace rive { +namespace rive +{ -struct RenderState { +struct RenderState +{ Mat2D transform; std::vector<SubPath> clipPaths; }; -class TessRenderer : public Renderer { +class TessRenderer : public Renderer +{ protected: Mat4 m_Projection; std::list<RenderState> m_Stack;
diff --git a/tess/src/contour_stroke.cpp b/tess/src/contour_stroke.cpp index 6711804..0a782b3 100644 --- a/tess/src/contour_stroke.cpp +++ b/tess/src/contour_stroke.cpp
@@ -9,15 +9,18 @@ static const int subdivisionArcLength = 4.0f; -void ContourStroke::reset() { +void ContourStroke::reset() +{ m_TriangleStrip.clear(); m_Offsets.clear(); } void ContourStroke::resetRenderOffset() { m_RenderOffset = 0; } -bool ContourStroke::nextRenderOffset(std::size_t& start, std::size_t& end) { - if (m_RenderOffset == m_Offsets.size()) { +bool ContourStroke::nextRenderOffset(std::size_t& start, std::size_t& end) +{ + if (m_RenderOffset == m_Offsets.size()) + { return false; } start = m_RenderOffset == 0 ? 0 : m_Offsets[m_RenderOffset - 1]; @@ -29,12 +32,14 @@ bool isClosed, StrokeJoin join, StrokeCap cap, - float strokeWidth) { + float strokeWidth) +{ auto contourPoints = contour->contourPoints(); std::vector<Vec2D> points(contourPoints.begin(), contourPoints.end()); auto pointCount = points.size(); - if (pointCount < 2) { + if (pointCount < 2) + { return; } auto startOffset = m_TriangleStrip.size(); @@ -49,9 +54,12 @@ Vec2D lastA = lastPoint + perpendicularStrokeDiff; Vec2D lastB = lastPoint - perpendicularStrokeDiff; - if (!isClosed) { - switch (cap) { - case StrokeCap::square: { + if (!isClosed) + { + switch (cap) + { + case StrokeCap::square: + { Vec2D strokeDiff = lastDiffNormalized * strokeWidth; Vec2D squareA = lastA - strokeDiff; Vec2D squareB = lastB - strokeDiff; @@ -59,7 +67,8 @@ m_TriangleStrip.push_back(squareB); break; } - case StrokeCap::round: { + case StrokeCap::round: + { Vec2D capDirection = Vec2D(-lastDiffNormalized.y, lastDiffNormalized.x); float arcLength = std::abs(math::PI * strokeWidth); int steps = (int)std::ceil(arcLength / subdivisionArcLength); @@ -67,7 +76,8 @@ float inc = math::PI / steps; float angle = angleTo; // make sure to draw the full cap due triangle strip - for (int j = 0; j <= steps; j++) { + for (int j = 0; j <= steps; j++) + { m_TriangleStrip.push_back(lastPoint); m_TriangleStrip.push_back(Vec2D(lastPoint.x + std::cos(angle) * strokeWidth, lastPoint.y + std::sin(angle) * strokeWidth)); @@ -75,7 +85,8 @@ } break; } - default: break; + default: + break; } } m_TriangleStrip.push_back(lastA); @@ -84,15 +95,19 @@ pointCount -= isClosed ? 1 : 0; std::size_t adjustedPointCount = isClosed ? pointCount + 1 : pointCount; - for (std::size_t i = 1; i < adjustedPointCount; i++) { + for (std::size_t i = 1; i < adjustedPointCount; i++) + { const Vec2D& point = points[i % pointCount]; Vec2D diff, diffNormalized, next; float length; - if (i < adjustedPointCount - 1 || isClosed) { + if (i < adjustedPointCount - 1 || isClosed) + { diff = (next = points[(i + 1) % pointCount]) - point; length = diff.length(); diffNormalized = diff / length; - } else { + } + else + { diff = lastDiff; next = point; length = lastLength; @@ -116,26 +131,34 @@ bool bevel = join == StrokeJoin::miter ? dot < 0.1f : dot < 0.999f; // Scale bisector to match stroke size. - if (dot > 0.000001f) { + if (dot > 0.000001f) + { float scale = 1.0f / dot * strokeWidth; float limit = lengthLimit / strokeWidth; - if (dot * limit * limit < 1.0f) { + if (dot * limit * limit < 1.0f) + { bevelInner = true; } bisector *= scale; - } else { + } + else + { bisector *= strokeWidth; } - if (!bevel) { + if (!bevel) + { Vec2D c = point + bisector; Vec2D d = point - bisector; - if (!bevelInner) { + if (!bevelInner) + { // Normal mitered edge. m_TriangleStrip.push_back(c); m_TriangleStrip.push_back(d); - } else if (cross <= 0) { + } + else if (cross <= 0) + { // Overlap the inner (in this case right) edge (sometimes called // miter inner). Vec2D c1 = point + Vec2D(lastDiffNormalized.y * -strokeWidth, @@ -147,7 +170,9 @@ m_TriangleStrip.push_back(d); m_TriangleStrip.push_back(c2); m_TriangleStrip.push_back(d); - } else { + } + else + { // Overlap the inner (in this case left) edge (sometimes called // miter inner). Vec2D d1 = point - Vec2D(lastDiffNormalized.y * -strokeWidth, @@ -160,19 +185,25 @@ m_TriangleStrip.push_back(c); m_TriangleStrip.push_back(d2); } - } else { + } + else + { Vec2D ldPStroke = Vec2D(lastDiffNormalized.y * -strokeWidth, lastDiffNormalized.x * strokeWidth); Vec2D dPStroke = Vec2D(diffNormalized.y * -strokeWidth, diffNormalized.x * strokeWidth); - if (cross <= 0) { + if (cross <= 0) + { // Bevel the outer (left in this case) edge. Vec2D a1; Vec2D a2; - if (bevelInner) { + if (bevelInner) + { a1 = point + ldPStroke; a2 = point + dPStroke; - } else { + } + else + { a1 = point + bisector; a2 = a1; } @@ -182,13 +213,15 @@ m_TriangleStrip.push_back(a1); m_TriangleStrip.push_back(b); - if (join == StrokeJoin::round) { + if (join == StrokeJoin::round) + { const Vec2D& pivot = bevelInner ? point : a1; Vec2D toPrev = bn - point; Vec2D toNext = b - point; float angleFrom = std::atan2(toPrev.y, toPrev.x); float angleTo = std::atan2(toNext.y, toNext.x); - if (angleTo > angleFrom) { + if (angleTo > angleFrom) + { angleTo -= math::PI * 2.0f; } float range = angleTo - angleFrom; @@ -197,7 +230,8 @@ float inc = range / steps; float angle = angleTo - inc; - for (int j = 0; j < steps - 1; j++) { + for (int j = 0; j < steps - 1; j++) + { m_TriangleStrip.push_back(pivot); m_TriangleStrip.emplace_back( Vec2D(point.x + std::cos(angle) * strokeWidth, @@ -208,14 +242,19 @@ } m_TriangleStrip.push_back(a2); m_TriangleStrip.push_back(bn); - } else { + } + else + { // Bevel the outer (right in this case) edge. Vec2D b1; Vec2D b2; - if (bevelInner) { + if (bevelInner) + { b1 = point - ldPStroke; b2 = point - dPStroke; - } else { + } + else + { b1 = point - bisector; b2 = b1; } @@ -226,13 +265,15 @@ m_TriangleStrip.push_back(a); m_TriangleStrip.push_back(b1); - if (join == StrokeJoin::round) { + if (join == StrokeJoin::round) + { const Vec2D& pivot = bevelInner ? point : b1; Vec2D toPrev = a - point; Vec2D toNext = an - point; float angleFrom = std::atan2(toPrev.y, toPrev.x); float angleTo = std::atan2(toNext.y, toNext.x); - if (angleTo > angleFrom) { + if (angleTo > angleFrom) + { angleTo -= math::PI * 2.0f; } @@ -242,7 +283,8 @@ float inc = range / steps; float angle = angleFrom + inc; - for (int j = 0; j < steps - 1; j++) { + for (int j = 0; j < steps - 1; j++) + { m_TriangleStrip.emplace_back( Vec2D(point.x + std::cos(angle) * strokeWidth, point.y + std::sin(angle) * strokeWidth)); @@ -260,13 +302,18 @@ lastDiffNormalized = diffNormalized; } - if (isClosed) { + if (isClosed) + { auto last = m_TriangleStrip.size() - 1; m_TriangleStrip[startOffset] = m_TriangleStrip[last - 1]; m_TriangleStrip[startOffset + 1] = m_TriangleStrip[last]; - } else { - switch (cap) { - case StrokeCap::square: { + } + else + { + switch (cap) + { + case StrokeCap::square: + { auto l = m_TriangleStrip.size(); Vec2D strokeDiff = lastDiffNormalized * strokeWidth; @@ -277,7 +324,8 @@ m_TriangleStrip.push_back(squareB); break; } - case StrokeCap::round: { + case StrokeCap::round: + { Vec2D capDirection = Vec2D(-lastDiffNormalized.y, lastDiffNormalized.x); float arcLength = std::abs(math::PI * strokeWidth); int steps = (int)std::ceil(arcLength / subdivisionArcLength); @@ -285,7 +333,8 @@ float inc = math::PI / steps; float angle = angleTo; // make sure to draw the full cap due triangle strip - for (int j = 0; j <= steps; j++) { + for (int j = 0; j <= steps; j++) + { m_TriangleStrip.push_back(lastPoint); m_TriangleStrip.push_back(Vec2D(lastPoint.x + std::cos(angle) * strokeWidth, lastPoint.y + std::sin(angle) * strokeWidth)); @@ -293,7 +342,8 @@ } break; } - default: break; + default: + break; } }
diff --git a/tess/src/math/mat4.cpp b/tess/src/math/mat4.cpp index 8f54dad..6e1da14 100644 --- a/tess/src/math/mat4.cpp +++ b/tess/src/math/mat4.cpp
@@ -12,9 +12,11 @@ 0.0f, 0.0f, 1.0f, 0.0f, mat2d[4], mat2d[5], 0.0f, 1.0f, // clang-format on - } {} + } +{} -Mat4 Mat4::multiply(const Mat4& a, const Mat4& b) { +Mat4 Mat4::multiply(const Mat4& a, const Mat4& b) +{ return { // clang-format off b[0] * a[0] + b[1] * a[4] + b[2] * a[8] + b[3] * a[12], @@ -40,7 +42,8 @@ }; } -Mat4 Mat4::multiply(const Mat4& a, const Mat2D& b) { +Mat4 Mat4::multiply(const Mat4& a, const Mat2D& b) +{ return { // clang-format off b[0] * a[0] + b[1] * a[4],
diff --git a/tess/src/segmented_contour.cpp b/tess/src/segmented_contour.cpp index c47dc53..00110ac 100644 --- a/tess/src/segmented_contour.cpp +++ b/tess/src/segmented_contour.cpp
@@ -7,22 +7,26 @@ SegmentedContour::SegmentedContour(float threshold) : m_bounds(AABB::forExpansion()), m_threshold(threshold), - m_thresholdSquared(threshold * threshold) {} + m_thresholdSquared(threshold * threshold) +{} float SegmentedContour::threshold() const { return m_threshold; } -void SegmentedContour::threshold(float value) { +void SegmentedContour::threshold(float value) +{ m_threshold = value; m_thresholdSquared = value * value; } const AABB& SegmentedContour::bounds() const { return m_bounds; } -void SegmentedContour::addVertex(Vec2D vertex) { +void SegmentedContour::addVertex(Vec2D vertex) +{ m_contourPoints.push_back(vertex); AABB::expandTo(m_bounds, vertex); } const std::size_t SegmentedContour::contourSize() const { return m_contourPoints.size(); } -const Span<const Vec2D> SegmentedContour::contourPoints(uint32_t endOffset) const { +const Span<const Vec2D> SegmentedContour::contourPoints(uint32_t endOffset) const +{ assert(endOffset <= m_contourPoints.size()); return Span<const Vec2D>(m_contourPoints.data(), m_contourPoints.size() - endOffset); } @@ -32,8 +36,10 @@ const Vec2D& toIn, const Vec2D& to, float t1, - float t2) { - if (CubicUtilities::shouldSplitCubic(from, fromOut, toIn, to, m_threshold)) { + float t2) +{ + if (CubicUtilities::shouldSplitCubic(from, fromOut, toIn, to, m_threshold)) + { float halfT = (t1 + t2) / 2.0f; Vec2D hull[6]; @@ -42,23 +48,33 @@ segmentCubic(from, hull[0], hull[3], hull[5], t1, halfT); segmentCubic(hull[5], hull[4], hull[2], to, halfT, t2); - } else { - if (Vec2D::distanceSquared(from, to) > m_thresholdSquared) { + } + else + { + if (Vec2D::distanceSquared(from, to) > m_thresholdSquared) + { addVertex(Vec2D(CubicUtilities::cubicAt(t2, from.x, fromOut.x, toIn.x, to.x), CubicUtilities::cubicAt(t2, from.y, fromOut.y, toIn.y, to.y))); } } } -void SegmentedContour::contour(const RawPath& rawPath, const Mat2D& transform) { +void SegmentedContour::contour(const RawPath& rawPath, const Mat2D& transform) +{ m_contourPoints.clear(); // Possible perf consideration: could add second path that doesn't transform // if transform is the identity. - for (const auto [verb, pts] : rawPath) { - switch (verb) { - case PathVerb::move: addVertex(transform * pts[0]); break; - case PathVerb::line: addVertex(transform * pts[1]); break; + for (const auto [verb, pts] : rawPath) + { + switch (verb) + { + case PathVerb::move: + addVertex(transform * pts[0]); + break; + case PathVerb::line: + addVertex(transform * pts[1]); + break; case PathVerb::cubic: segmentCubic(transform * pts[0], transform * pts[1], @@ -67,7 +83,8 @@ 0.0f, 1.0f); break; - case PathVerb::close: break; + case PathVerb::close: + break; case PathVerb::quad: // TODO: not currently used by render paths, however might be // necessary for fonts.
diff --git a/tess/src/sokol/sokol_factory.cpp b/tess/src/sokol/sokol_factory.cpp index af87e34..0b990dc 100644 --- a/tess/src/sokol/sokol_factory.cpp +++ b/tess/src/sokol/sokol_factory.cpp
@@ -2,7 +2,8 @@ using namespace rive; -class NoOpRenderPaint : public RenderPaint { +class NoOpRenderPaint : public RenderPaint +{ public: void color(unsigned int value) override {} void style(RenderPaintStyle value) override {} @@ -14,7 +15,8 @@ void invalidateStroke() override {} }; -class NoOpRenderPath : public RenderPath { +class NoOpRenderPath : public RenderPath +{ public: void reset() override {}
diff --git a/tess/src/sokol/sokol_tess_renderer.cpp b/tess/src/sokol/sokol_tess_renderer.cpp index f37539e..d1e3166 100644 --- a/tess/src/sokol/sokol_tess_renderer.cpp +++ b/tess/src/sokol/sokol_tess_renderer.cpp
@@ -7,19 +7,22 @@ using namespace rive; -static void fillColorBuffer(float* buffer, ColorInt value) { +static void fillColorBuffer(float* buffer, ColorInt value) +{ buffer[0] = (float)colorRed(value) / 0xFF; buffer[1] = (float)colorGreen(value) / 0xFF; buffer[2] = (float)colorBlue(value) / 0xFF; buffer[3] = colorOpacity(value); } -class SokolRenderPath : public TessRenderPath { +class SokolRenderPath : public TessRenderPath +{ public: SokolRenderPath() {} SokolRenderPath(RawPath& rawPath, FillRule fillRule) : TessRenderPath(rawPath, fillRule) {} - ~SokolRenderPath() { + ~SokolRenderPath() + { sg_destroy_buffer(m_vertexBuffer); sg_destroy_buffer(m_indexBuffer); } @@ -34,12 +37,14 @@ std::size_t m_boundsIndex = 0; protected: - void addTriangles(rive::Span<const rive::Vec2D> vts, rive::Span<const uint16_t> idx) override { + void addTriangles(rive::Span<const rive::Vec2D> vts, rive::Span<const uint16_t> idx) override + { m_vertices.insert(m_vertices.end(), vts.begin(), vts.end()); m_indices.insert(m_indices.end(), idx.begin(), idx.end()); } - void setTriangulatedBounds(const AABB& value) override { + void setTriangulatedBounds(const AABB& value) override + { m_boundsIndex = m_vertices.size(); m_vertices.emplace_back(Vec2D(value.minX, value.minY)); m_vertices.emplace_back(Vec2D(value.maxX, value.minY)); @@ -48,15 +53,19 @@ } public: - void reset() override { + void reset() override + { TessRenderPath::reset(); m_vertices.clear(); m_indices.clear(); } - void drawStroke(ContourStroke* stroke) { - if (isContainer()) { - for (auto& subPath : m_subPaths) { + void drawStroke(ContourStroke* stroke) + { + if (isContainer()) + { + for (auto& subPath : m_subPaths) + { reinterpret_cast<SokolRenderPath*>(subPath.path())->drawStroke(stroke); } return; @@ -66,11 +75,14 @@ sg_draw(start < 2 ? 0 : (start - 2) * 3, end - start < 2 ? 0 : (end - start - 2) * 3, 1); } - void drawFill() { - if (triangulate()) { + void drawFill() + { + if (triangulate()) + { sg_destroy_buffer(m_vertexBuffer); sg_destroy_buffer(m_indexBuffer); - if (m_indices.size() == 0 || m_vertices.size() == 0) { + if (m_indices.size() == 0 || m_vertices.size() == 0) + { m_vertexBuffer = {0}; m_indexBuffer = {0}; return; @@ -95,7 +107,8 @@ }); } - if (m_vertexBuffer.id == 0) { + if (m_vertexBuffer.id == 0) + { return; } @@ -108,8 +121,10 @@ sg_draw(0, m_indices.size(), 1); } - void drawBounds(const sg_buffer& boundsIndexBuffer) { - if (m_vertexBuffer.id == 0) { + void drawBounds(const sg_buffer& boundsIndexBuffer) + { + if (m_vertexBuffer.id == 0) + { return; } sg_bindings bind = { @@ -124,27 +139,32 @@ }; // Returns a full-formed RenderPath -- can be treated as immutable -std::unique_ptr<RenderPath> SokolFactory::makeRenderPath(RawPath& rawPath, FillRule rule) { +std::unique_ptr<RenderPath> SokolFactory::makeRenderPath(RawPath& rawPath, FillRule rule) +{ return std::make_unique<SokolRenderPath>(rawPath, rule); } -std::unique_ptr<RenderPath> SokolFactory::makeEmptyRenderPath() { +std::unique_ptr<RenderPath> SokolFactory::makeEmptyRenderPath() +{ return std::make_unique<SokolRenderPath>(); } -class SokolBuffer : public RenderBuffer { +class SokolBuffer : public RenderBuffer +{ private: sg_buffer m_Buffer; public: SokolBuffer(size_t count, const sg_buffer_desc& desc) : - RenderBuffer(count), m_Buffer(sg_make_buffer(desc)) {} + RenderBuffer(count), m_Buffer(sg_make_buffer(desc)) + {} ~SokolBuffer() { sg_destroy_buffer(m_Buffer); } sg_buffer buffer() { return m_Buffer; } }; -rcp<RenderBuffer> SokolFactory::makeBufferU16(Span<const uint16_t> span) { +rcp<RenderBuffer> SokolFactory::makeBufferU16(Span<const uint16_t> span) +{ return rcp<RenderBuffer>(new SokolBuffer(span.size(), (sg_buffer_desc){ .type = SG_BUFFERTYPE_INDEXBUFFER, @@ -156,7 +176,8 @@ })); } -rcp<RenderBuffer> SokolFactory::makeBufferU32(Span<const uint32_t> span) { +rcp<RenderBuffer> SokolFactory::makeBufferU32(Span<const uint32_t> span) +{ return rcp<RenderBuffer>(new SokolBuffer(span.size(), (sg_buffer_desc){ .type = SG_BUFFERTYPE_INDEXBUFFER, @@ -167,7 +188,8 @@ }, })); } -rcp<RenderBuffer> SokolFactory::makeBufferF32(Span<const float> span) { +rcp<RenderBuffer> SokolFactory::makeBufferF32(Span<const float> span) +{ return rcp<RenderBuffer>(new SokolBuffer(span.size(), (sg_buffer_desc){ .type = SG_BUFFERTYPE_VERTEXBUFFER, @@ -182,7 +204,8 @@ sg_pipeline vectorPipeline(sg_shader shader, sg_blend_state blend, sg_stencil_state stencil, - sg_color_mask colorMask = SG_COLORMASK_RGBA) { + sg_color_mask colorMask = SG_COLORMASK_RGBA) +{ return sg_make_pipeline((sg_pipeline_desc){ .layout = { @@ -216,7 +239,8 @@ }); } -SokolTessRenderer::SokolTessRenderer() { +SokolTessRenderer::SokolTessRenderer() +{ m_meshPipeline = sg_make_pipeline((sg_pipeline_desc){ .layout = { @@ -266,7 +290,8 @@ .enabled = false, }); - for (std::size_t i = 1; i <= maxClippingPaths; i++) { + for (std::size_t i = 1; i <= maxClippingPaths; i++) + { m_pathPipeline[i] = vectorPipeline(uberShader, { @@ -306,7 +331,8 @@ .enabled = false, }); - for (std::size_t i = 1; i <= maxClippingPaths; i++) { + for (std::size_t i = 1; i <= maxClippingPaths; i++) + { m_pathScreenPipeline[i] = vectorPipeline(uberShader, { @@ -345,7 +371,8 @@ .enabled = false, }); - for (std::size_t i = 1; i <= maxClippingPaths; i++) { + for (std::size_t i = 1; i <= maxClippingPaths; i++) + { m_pathAdditivePipeline[i] = vectorPipeline(uberShader, { @@ -383,7 +410,8 @@ .enabled = false, }); - for (std::size_t i = 1; i <= maxClippingPaths; i++) { + for (std::size_t i = 1; i <= maxClippingPaths; i++) + { m_pathMultiplyPipeline[i] = vectorPipeline(uberShader, { @@ -466,12 +494,14 @@ }); } -SokolTessRenderer::~SokolTessRenderer() { +SokolTessRenderer::~SokolTessRenderer() +{ sg_destroy_buffer(m_boundsIndices); sg_destroy_pipeline(m_meshPipeline); sg_destroy_pipeline(m_incClipPipeline); sg_destroy_pipeline(m_decClipPipeline); - for (std::size_t i = 0; i <= maxClippingPaths; i++) { + for (std::size_t i = 0; i <= maxClippingPaths; i++) + { sg_destroy_pipeline(m_pathPipeline[i]); sg_destroy_pipeline(m_pathScreenPipeline[i]); } @@ -482,7 +512,8 @@ float bottom, float top, float near, - float far) { + float far) +{ m_Projection[0] = 2.0f / (right - left); m_Projection[1] = 0.0f; m_Projection[2] = 0.0f; @@ -526,7 +557,8 @@ // } } -void SokolTessRenderer::drawImage(const RenderImage* image, BlendMode, float opacity) { +void SokolTessRenderer::drawImage(const RenderImage* image, BlendMode, float opacity) +{ vs_params_t vs_params; const Mat2D& world = transform(); @@ -551,7 +583,8 @@ rcp<RenderBuffer> uvCoords_f32, rcp<RenderBuffer> indices_u16, BlendMode blendMode, - float opacity) { + float opacity) +{ vs_params_t vs_params; const Mat2D& world = transform(); @@ -570,7 +603,8 @@ sg_draw(0, indices_u16->count(), 1); } -class SokolGradient : public RenderShader { +class SokolGradient : public RenderShader +{ private: Vec2D m_start; Vec2D m_end; @@ -582,13 +616,16 @@ private: // General gradient SokolGradient(int type, const ColorInt colors[], const float stops[], size_t count) : - m_type(type) { + m_type(type) + { m_stops.resize(count); m_colors.resize(count * 4); - for (int i = 0, colorIndex = 0; i < count; i++, colorIndex += 4) { + for (int i = 0, colorIndex = 0; i < count; i++, colorIndex += 4) + { fillColorBuffer(&m_colors[colorIndex], colors[i]); m_stops[i] = stops[i]; - if (m_colors[colorIndex + 3] > 0.0f) { + if (m_colors[colorIndex + 3] > 0.0f) + { m_isVisible = true; } } @@ -603,7 +640,8 @@ const ColorInt colors[], const float stops[], size_t count) : - SokolGradient(1, colors, stops, count) { + SokolGradient(1, colors, stops, count) + { m_start = Vec2D(sx, sy); m_end = Vec2D(ex, ey); } @@ -614,20 +652,24 @@ const ColorInt colors[], // [count] const float stops[], // [count] size_t count) : - SokolGradient(2, colors, stops, count) { + SokolGradient(2, colors, stops, count) + { m_start = Vec2D(cx, cy); m_end = Vec2D(cx + radius, cy); } - void bind(vs_path_params_t& vertexUniforms, fs_path_uniforms_t& fragmentUniforms) { + void bind(vs_path_params_t& vertexUniforms, fs_path_uniforms_t& fragmentUniforms) + { auto stopCount = m_stops.size(); vertexUniforms.fillType = fragmentUniforms.fillType = m_type; vertexUniforms.gradientStart = m_start; vertexUniforms.gradientEnd = m_end; fragmentUniforms.stopCount = stopCount; - for (int i = 0; i < stopCount; i++) { + for (int i = 0; i < stopCount; i++) + { auto colorBufferIndex = i * 4; - for (int j = 0; j < 4; j++) { + for (int j = 0; j < 4; j++) + { fragmentUniforms.colors[i][j] = m_colors[colorBufferIndex + j]; } fragmentUniforms.stops[i / 4][i % 4] = m_stops[i]; @@ -641,7 +683,8 @@ float ey, const ColorInt colors[], const float stops[], - size_t count) { + size_t count) +{ return rcp<RenderShader>(new SokolGradient(sx, sy, ex, ey, colors, stops, count)); } @@ -650,11 +693,13 @@ float radius, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ return rcp<RenderShader>(new SokolGradient(cx, cy, radius, colors, stops, count)); } -class SokolRenderPaint : public RenderPaint { +class SokolRenderPaint : public RenderPaint +{ private: fs_path_uniforms_t m_uniforms = {0}; rcp<RenderShader> m_shader; @@ -672,20 +717,24 @@ BlendMode m_blendMode = BlendMode::srcOver; public: - ~SokolRenderPaint() override { + ~SokolRenderPaint() override + { sg_destroy_buffer(m_strokeVertexBuffer); sg_destroy_buffer(m_strokeIndexBuffer); } - void color(ColorInt value) override { + void color(ColorInt value) override + { fillColorBuffer(m_uniforms.colors[0], value); m_uniforms.fillType = 0; } - void style(RenderPaintStyle value) override { + void style(RenderPaintStyle value) override + { m_style = value; - switch (m_style) { + switch (m_style) + { case RenderPaintStyle::fill: m_stroke = nullptr; m_strokeDirty = false; @@ -699,23 +748,28 @@ RenderPaintStyle style() const { return m_style; } - void thickness(float value) override { + void thickness(float value) override + { m_strokeThickness = value; m_strokeDirty = true; } - void join(StrokeJoin value) override { + void join(StrokeJoin value) override + { m_strokeJoin = value; m_strokeDirty = true; } - void cap(StrokeCap value) override { + void cap(StrokeCap value) override + { m_strokeCap = value; m_strokeDirty = true; } - void invalidateStroke() override { - if (m_stroke) { + void invalidateStroke() override + { + if (m_stroke) + { m_strokeDirty = true; } } @@ -725,15 +779,19 @@ void shader(rcp<RenderShader> shader) override { m_shader = shader; } - void draw(vs_path_params_t& vertexUniforms, SokolRenderPath* path) { - if (m_shader) { + void draw(vs_path_params_t& vertexUniforms, SokolRenderPath* path) + { + if (m_shader) + { static_cast<SokolGradient*>(m_shader.get())->bind(vertexUniforms, m_uniforms); } sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_path_params, SG_RANGE_REF(vertexUniforms)); sg_apply_uniforms(SG_SHADERSTAGE_FS, SLOT_fs_path_uniforms, SG_RANGE_REF(m_uniforms)); - if (m_stroke != nullptr) { - if (m_strokeDirty) { + if (m_stroke != nullptr) + { + if (m_strokeDirty) + { static Mat2D identity; m_stroke->reset(); path->extrudeStroke(m_stroke.get(), @@ -748,7 +806,8 @@ sg_destroy_buffer(m_strokeVertexBuffer); sg_destroy_buffer(m_strokeIndexBuffer); auto size = strip.size(); - if (size <= 2) { + if (size <= 2) + { m_strokeVertexBuffer = {0}; m_strokeIndexBuffer = {0}; return; @@ -770,19 +829,26 @@ // to) m_stroke->resetRenderOffset(); m_StrokeOffsets.clear(); - while (true) { + while (true) + { std::size_t strokeStart, strokeEnd; - if (!m_stroke->nextRenderOffset(strokeStart, strokeEnd)) { + if (!m_stroke->nextRenderOffset(strokeStart, strokeEnd)) + { break; } std::size_t length = strokeEnd - strokeStart; - if (length > 2) { - for (std::size_t i = 0, end = length - 2; i < end; i++) { - if ((i % 2) == 1) { + if (length > 2) + { + for (std::size_t i = 0, end = length - 2; i < end; i++) + { + if ((i % 2) == 1) + { indices.push_back(i + strokeStart); indices.push_back(i + 1 + strokeStart); indices.push_back(i + 2 + strokeStart); - } else { + } + else + { indices.push_back(i + strokeStart); indices.push_back(i + 2 + strokeStart); indices.push_back(i + 1 + strokeStart); @@ -801,7 +867,8 @@ }, }); } - if (m_strokeVertexBuffer.id == 0) { + if (m_strokeVertexBuffer.id == 0) + { return; } @@ -815,48 +882,59 @@ m_stroke->resetRenderOffset(); // path->drawStroke(m_stroke.get()); std::size_t start = 0; - for (auto end : m_StrokeOffsets) { + for (auto end : m_StrokeOffsets) + { sg_draw(start, end - start, 1); start = end; } - - } else { + } + else + { path->drawFill(); } } }; -std::unique_ptr<RenderPaint> SokolFactory::makeRenderPaint() { +std::unique_ptr<RenderPaint> SokolFactory::makeRenderPaint() +{ return std::make_unique<SokolRenderPaint>(); } -void SokolTessRenderer::restore() { +void SokolTessRenderer::restore() +{ TessRenderer::restore(); - if (m_Stack.size() == 1) { + if (m_Stack.size() == 1) + { // When we've fully restored, immediately update clip to not wait for next draw. applyClipping(); m_currentPipeline = {0}; } } -void SokolTessRenderer::applyClipping() { - if (!m_IsClippingDirty) { +void SokolTessRenderer::applyClipping() +{ + if (!m_IsClippingDirty) + { return; } m_IsClippingDirty = false; RenderState& state = m_Stack.back(); auto currentClipLength = m_ClipPaths.size(); - if (currentClipLength == state.clipPaths.size()) { + if (currentClipLength == state.clipPaths.size()) + { // Same length so now check if they're all the same. bool allSame = true; - for (std::size_t i = 0; i < currentClipLength; i++) { - if (state.clipPaths[i].path() != m_ClipPaths[i].path()) { + for (std::size_t i = 0; i < currentClipLength; i++) + { + if (state.clipPaths[i].path() != m_ClipPaths[i].path()) + { allSame = false; break; } } - if (allSame) { + if (allSame) + { return; } } @@ -867,16 +945,20 @@ // Decr any paths from the last clip that are gone. std::unordered_set<RenderPath*> alreadyApplied; - for (auto appliedPath : m_ClipPaths) { + for (auto appliedPath : m_ClipPaths) + { bool decr = true; - for (auto nextClipPath : state.clipPaths) { - if (nextClipPath.path() == appliedPath.path()) { + for (auto nextClipPath : state.clipPaths) + { + if (nextClipPath.path() == appliedPath.path()) + { decr = false; alreadyApplied.insert(appliedPath.path()); break; } } - if (decr) { + if (decr) + { // Draw appliedPath.path() with decr pipeline setPipeline(m_decClipPipeline); vs_params.mvp = m_Projection * appliedPath.transform(); @@ -888,8 +970,10 @@ } // Incr any paths that are added. - for (auto nextClipPath : state.clipPaths) { - if (alreadyApplied.count(nextClipPath.path())) { + for (auto nextClipPath : state.clipPaths) + { + if (alreadyApplied.count(nextClipPath.path())) + { // Already applied. continue; } @@ -910,15 +994,18 @@ } void SokolTessRenderer::reset() { m_currentPipeline = {0}; } -void SokolTessRenderer::setPipeline(sg_pipeline pipeline) { - if (m_currentPipeline.id == pipeline.id) { +void SokolTessRenderer::setPipeline(sg_pipeline pipeline) +{ + if (m_currentPipeline.id == pipeline.id) + { return; } m_currentPipeline = pipeline; sg_apply_pipeline(pipeline); } -void SokolTessRenderer::drawPath(RenderPath* path, RenderPaint* paint) { +void SokolTessRenderer::drawPath(RenderPath* path, RenderPaint* paint) +{ auto sokolPaint = static_cast<SokolRenderPaint*>(paint); applyClipping(); @@ -926,12 +1013,23 @@ const Mat2D& world = transform(); vs_params.mvp = m_Projection * world; - switch (sokolPaint->blendMode()) { - case BlendMode::srcOver: setPipeline(m_pathPipeline[m_clipCount]); break; - case BlendMode::screen: setPipeline(m_pathScreenPipeline[m_clipCount]); break; - case BlendMode::colorDodge: setPipeline(m_pathAdditivePipeline[m_clipCount]); break; - case BlendMode::multiply: setPipeline(m_pathMultiplyPipeline[m_clipCount]); break; - default: setPipeline(m_pathScreenPipeline[m_clipCount]); break; + switch (sokolPaint->blendMode()) + { + case BlendMode::srcOver: + setPipeline(m_pathPipeline[m_clipCount]); + break; + case BlendMode::screen: + setPipeline(m_pathScreenPipeline[m_clipCount]); + break; + case BlendMode::colorDodge: + setPipeline(m_pathAdditivePipeline[m_clipCount]); + break; + case BlendMode::multiply: + setPipeline(m_pathMultiplyPipeline[m_clipCount]); + break; + default: + setPipeline(m_pathScreenPipeline[m_clipCount]); + break; } static_cast<SokolRenderPaint*>(paint)->draw(vs_params, static_cast<SokolRenderPath*>(path)); @@ -945,7 +1043,8 @@ .height = (int)height, .data.subimage[0][0] = {bytes, width * height * 4}, .pixel_format = SG_PIXELFORMAT_RGBA8, - })) {} + })) +{} SokolRenderImageResource::~SokolRenderImageResource() { sg_destroy_image(m_gpuResource); } SokolRenderImage::SokolRenderImage(rcp<SokolRenderImageResource> image, @@ -953,8 +1052,7 @@ uint32_t height, const Mat2D& uvTransform) : - RenderImage(uvTransform), - m_gpuImage(image) + RenderImage(uvTransform), m_gpuImage(image) { float halfWidth = width / 2.0f; @@ -983,7 +1081,8 @@ }); } -SokolRenderImage::~SokolRenderImage() { +SokolRenderImage::~SokolRenderImage() +{ sg_destroy_buffer(m_vertexBuffer); sg_destroy_buffer(m_uvBuffer); }
diff --git a/tess/src/tess_render_path.cpp b/tess/src/tess_render_path.cpp index 0ed6c45..af16728 100644 --- a/tess/src/tess_render_path.cpp +++ b/tess/src/tess_render_path.cpp
@@ -7,13 +7,15 @@ using namespace rive; TessRenderPath::TessRenderPath() : m_segmentedContour(contourThreshold) {} TessRenderPath::TessRenderPath(RawPath& rawPath, FillRule fillRule) : - m_fillRule(fillRule), m_segmentedContour(contourThreshold) { + m_fillRule(fillRule), m_segmentedContour(contourThreshold) +{ m_rawPath.swap(rawPath); } TessRenderPath::~TessRenderPath() {} -void TessRenderPath::reset() { +void TessRenderPath::reset() +{ m_rawPath.rewind(); m_subPaths.clear(); m_isContourDirty = m_isTriangulationDirty = true; @@ -23,28 +25,35 @@ void TessRenderPath::moveTo(float x, float y) { m_rawPath.moveTo(x, y); } void TessRenderPath::lineTo(float x, float y) { m_rawPath.lineTo(x, y); } -void TessRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) { +void TessRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y) +{ m_rawPath.cubicTo(ox, oy, ix, iy, x, y); } -void TessRenderPath::close() { +void TessRenderPath::close() +{ m_rawPath.close(); m_isClosed = true; } -void TessRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform) { +void TessRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform) +{ m_subPaths.emplace_back(SubPath(path, transform)); } const SegmentedContour& TessRenderPath::segmentedContour() const { return m_segmentedContour; } // Helper for earcut to understand Vec2D -namespace mapbox { -namespace util { +namespace mapbox +{ +namespace util +{ -template <> struct nth<0, Vec2D> { +template <> struct nth<0, Vec2D> +{ inline static auto get(const Vec2D& t) { return t.x; }; }; -template <> struct nth<1, Vec2D> { +template <> struct nth<1, Vec2D> +{ inline static auto get(const Vec2D& t) { return t.y; }; }; @@ -53,20 +62,24 @@ const RawPath& TessRenderPath::rawPath() const { return m_rawPath; } -void* stdAlloc(void* userData, unsigned int size) { +void* stdAlloc(void* userData, unsigned int size) +{ int* allocated = (int*)userData; TESS_NOTUSED(userData); *allocated += (int)size; return malloc(size); } -void stdFree(void* userData, void* ptr) { +void stdFree(void* userData, void* ptr) +{ TESS_NOTUSED(userData); free(ptr); } -bool TessRenderPath::triangulate() { - if (!m_isTriangulationDirty) { +bool TessRenderPath::triangulate() +{ + if (!m_isTriangulationDirty) + { return false; } m_isTriangulationDirty = false; @@ -74,13 +87,16 @@ return true; } -void TessRenderPath::triangulate(TessRenderPath* containerPath) { +void TessRenderPath::triangulate(TessRenderPath* containerPath) +{ AABB bounds = AABB::forExpansion(); // If there's a single path, we're going to try to assume the user isn't // doing any funky self overlapping winding and we'll try to triangulate it // quickly as a single polygon. - if (m_subPaths.size() == 0) { - if (!empty()) { + if (m_subPaths.size() == 0) + { + if (!empty()) + { Mat2D identity; contour(identity); @@ -92,15 +108,20 @@ containerPath->addTriangles(contour, m_earcut.indices); } - } else if (m_subPaths.size() == 1) { + } + else if (m_subPaths.size() == 1) + { // We're a container but we only have 1 path, let's see if we can use // our fast triangulator. SubPath& subPath = m_subPaths.front(); auto subRenderPath = static_cast<TessRenderPath*>(subPath.path()); - if (subRenderPath->isContainer()) { + if (subRenderPath->isContainer()) + { // Nope, subpath is also a container, keep going. subRenderPath->triangulate(containerPath); - } else if (!subRenderPath->empty()) { + } + else if (!subRenderPath->empty()) + { // Yes, it's a single path with commands, triangulate it. subRenderPath->contour(subPath.transform()); const SegmentedContour& segmentedContour = subRenderPath->segmentedContour(); @@ -110,15 +131,22 @@ containerPath->addTriangles(contour, m_earcut.indices); } - } else { + } + else + { // We're a container with multiple sub-paths. TESStesselator* tess = nullptr; - for (SubPath& subPath : m_subPaths) { + for (SubPath& subPath : m_subPaths) + { auto subRenderPath = static_cast<TessRenderPath*>(subPath.path()); - if (subRenderPath->isContainer()) { + if (subRenderPath->isContainer()) + { subRenderPath->triangulate(containerPath); - } else if (!subRenderPath->empty()) { - if (tess == nullptr) { + } + else if (!subRenderPath->empty()) + { + if (tess == nullptr) + { tess = tessNewTess(nullptr); } subRenderPath->contour(subPath.transform()); @@ -128,8 +156,10 @@ bounds.expand(segmentedContour.bounds()); } } - if (tess != nullptr) { - if (tessTesselate(tess, TESS_WINDING_POSITIVE, TESS_POLYGONS, 3, 2, 0)) { + if (tess != nullptr) + { + if (tessTesselate(tess, TESS_WINDING_POSITIVE, TESS_POLYGONS, 3, 2, 0)) + { auto verts = tessGetVertices(tess); // const int* vinds = tessGetVertexIndices(tess); auto nverts = tessGetVertexCount(tess); @@ -137,7 +167,8 @@ auto nelems = tessGetElementCount(tess); std::vector<uint16_t> indices; - for (int i = 0; i < nelems * 3; i++) { + for (int i = 0; i < nelems * 3; i++) + { indices.push_back(elems[i]); } @@ -151,8 +182,10 @@ containerPath->setTriangulatedBounds(bounds); } -void TessRenderPath::contour(const Mat2D& transform) { - if (!m_isContourDirty && transform == m_contourTransform) { +void TessRenderPath::contour(const Mat2D& transform) +{ + if (!m_isContourDirty && transform == m_contourTransform) + { return; } @@ -165,9 +198,12 @@ StrokeJoin join, StrokeCap cap, float strokeWidth, - const Mat2D& transform) { - if (isContainer()) { - for (auto& subPath : m_subPaths) { + const Mat2D& transform) +{ + if (isContainer()) + { + for (auto& subPath : m_subPaths) + { static_cast<TessRenderPath*>(subPath.path()) ->extrudeStroke(stroke, join, cap, strokeWidth, subPath.transform()); }
diff --git a/tess/src/tess_renderer.cpp b/tess/src/tess_renderer.cpp index 7dac821..773717d 100644 --- a/tess/src/tess_renderer.cpp +++ b/tess/src/tess_renderer.cpp
@@ -8,24 +8,28 @@ void TessRenderer::projection(const Mat4& value) { m_Projection = value; } void TessRenderer::save() { m_Stack.push_back(m_Stack.back()); } -void TessRenderer::restore() { +void TessRenderer::restore() +{ assert(m_Stack.size() > 1); RenderState& state = m_Stack.back(); m_Stack.pop_back(); // We can only add clipping paths so if they're still the same, nothing has // changed. - if (state.clipPaths.size() != m_Stack.back().clipPaths.size()) { + if (state.clipPaths.size() != m_Stack.back().clipPaths.size()) + { m_IsClippingDirty = true; } } -void TessRenderer::transform(const Mat2D& transform) { +void TessRenderer::transform(const Mat2D& transform) +{ Mat2D& stackMat = m_Stack.back().transform; stackMat = stackMat * transform; } -void TessRenderer::clipPath(RenderPath* path) { +void TessRenderer::clipPath(RenderPath* path) +{ RenderState& state = m_Stack.back(); state.clipPaths.emplace_back(SubPath(path, state.transform)); @@ -38,4 +42,5 @@ rcp<RenderBuffer> uvCoords_f32, rcp<RenderBuffer> indices_u16, BlendMode, - float opacity) {} \ No newline at end of file + float opacity) +{} \ No newline at end of file
diff --git a/tess/test/mat4_test.cpp b/tess/test/mat4_test.cpp index 1e4f580..782ca3b 100644 --- a/tess/test/mat4_test.cpp +++ b/tess/test/mat4_test.cpp
@@ -2,7 +2,8 @@ #include "rive/math/mat4.hpp" #include "rive/math/mat2d.hpp" -TEST_CASE("Mat2D to Mat4 works", "[mat4]") { +TEST_CASE("Mat2D to Mat4 works", "[mat4]") +{ rive::Mat2D matrix2D(0.1f, 0.2f, 0.0f, 2.0f, 22.0f, 33.0f); rive::Mat4 matrix4x4 = matrix2D; REQUIRE(matrix4x4[0] == 0.1f); @@ -13,7 +14,8 @@ REQUIRE(matrix4x4[13] == 33.0f); } -TEST_CASE("Mat4 times Mat2 works", "[mat4]") { +TEST_CASE("Mat4 times Mat2 works", "[mat4]") +{ rive::Mat2D matrix2D(0.1f, 0.2f, 0.0f, 2.0f, 22.0f, 33.0f); rive::Mat4 identity4x4; rive::Mat4 matrix4x4 = identity4x4 * matrix2D; @@ -25,7 +27,8 @@ REQUIRE(matrix4x4[13] == 33.0f); } -TEST_CASE("Mat4 times Mat4 works", "[mat4]") { +TEST_CASE("Mat4 times Mat4 works", "[mat4]") +{ rive::Mat4 a( // clang-format off 5.0f, 7.0f, 9.0f, 10.0f,
diff --git a/tess/test/triangulation_test.cpp b/tess/test/triangulation_test.cpp index 756745b..5837635 100644 --- a/tess/test/triangulation_test.cpp +++ b/tess/test/triangulation_test.cpp
@@ -3,14 +3,16 @@ #include "rive/tess/tess_render_path.hpp" #include "rive_file_reader.hpp" -class TestRenderPath : public rive::TessRenderPath { +class TestRenderPath : public rive::TessRenderPath +{ public: std::vector<rive::Vec2D> vertices; std::vector<uint16_t> indices; protected: virtual void addTriangles(rive::Span<const rive::Vec2D> vts, - rive::Span<const uint16_t> idx) override { + rive::Span<const uint16_t> idx) override + { vertices.insert(vertices.end(), vts.begin(), vts.end()); indices.insert(indices.end(), idx.begin(), idx.end()); } @@ -18,7 +20,8 @@ void setTriangulatedBounds(const rive::AABB& value) override {} }; -TEST_CASE("simple triangle path triangulates as expected", "[file]") { +TEST_CASE("simple triangle path triangulates as expected", "[file]") +{ auto file = ReadRiveFile("../test/assets/triangle.riv"); auto artboard = file->artboard(); artboard->advance(0.0f);
diff --git a/test/binary_reader_test.cpp b/test/binary_reader_test.cpp index 80db713..bb43a84 100644 --- a/test/binary_reader_test.cpp +++ b/test/binary_reader_test.cpp
@@ -1,7 +1,8 @@ #include <catch.hpp> #include <rive/core/binary_reader.hpp> -template <typename T> void checkFits() { +template <typename T> void checkFits() +{ int64_t min = std::numeric_limits<T>::min(); int64_t max = std::numeric_limits<T>::max(); REQUIRE(rive::fitsIn<T>(max + 0)); @@ -10,7 +11,8 @@ REQUIRE(!rive::fitsIn<T>(min - 1)); } -TEST_CASE("fitsIn checks", "[type_conversions]") { +TEST_CASE("fitsIn checks", "[type_conversions]") +{ checkFits<int8_t>(); checkFits<uint8_t>(); @@ -21,8 +23,10 @@ checkFits<uint32_t>(); } -static uint8_t* packvarint(uint8_t array[], uint64_t value) { - while (value > 127) { +static uint8_t* packvarint(uint8_t array[], uint64_t value) +{ + while (value > 127) + { *array++ = static_cast<uint8_t>(0x80 | (value & 0x7F)); value >>= 7; } @@ -30,7 +34,8 @@ return array; } -template <typename T> bool checkAs(uint64_t value) { +template <typename T> bool checkAs(uint64_t value) +{ uint8_t storage[16]; uint8_t* p = storage; @@ -39,14 +44,16 @@ auto newValue = reader.readVarUintAs<T>(); - if (reader.hasError()) { + if (reader.hasError()) + { REQUIRE(newValue == 0); } return !reader.hasError() && value == newValue; } -TEST_CASE("range checks", "[binary_reader]") { +TEST_CASE("range checks", "[binary_reader]") +{ REQUIRE(checkAs<uint8_t>(100)); REQUIRE(checkAs<uint16_t>(100)); REQUIRE(checkAs<uint32_t>(100));
diff --git a/test/bound_bones_test.cpp b/test/bound_bones_test.cpp index 004f8c7..9362d38 100644 --- a/test/bound_bones_test.cpp +++ b/test/bound_bones_test.cpp
@@ -12,7 +12,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("bound bones load correctly", "[bones]") { +TEST_CASE("bound bones load correctly", "[bones]") +{ auto file = ReadRiveFile("../../test/assets/off_road_car.riv"); auto node = file->artboard()->find("transmission_front_testing"); @@ -27,7 +28,8 @@ REQUIRE(pointsPath->skin()->tendons()[0]->bone() != nullptr); REQUIRE(pointsPath->skin()->tendons()[1]->bone() != nullptr); - for (auto vertex : path->vertices()) { + for (auto vertex : path->vertices()) + { REQUIRE(vertex->weight() != nullptr); }
diff --git a/test/clip_test.cpp b/test/clip_test.cpp index 6d8bada..f0e4331 100644 --- a/test/clip_test.cpp +++ b/test/clip_test.cpp
@@ -8,7 +8,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("clipping loads correctly", "[clipping]") { +TEST_CASE("clipping loads correctly", "[clipping]") +{ auto file = ReadRiveFile("../../test/assets/circle_clips.riv"); auto node = file->artboard()->find("TopEllipse");
diff --git a/test/contour_measure_test.cpp b/test/contour_measure_test.cpp index a5061a1..aa6c77c 100644 --- a/test/contour_measure_test.cpp +++ b/test/contour_measure_test.cpp
@@ -12,23 +12,27 @@ using namespace rive; -static bool nearly_eq(float a, float b, float tolerance) { +static bool nearly_eq(float a, float b, float tolerance) +{ assert(tolerance >= 0); const float diff = std::abs(a - b); const float max = std::max(std::abs(a), std::abs(b)); const float allowed = tolerance * max; - if (diff > allowed) { + if (diff > allowed) + { printf("%g %g delta %g allowed %g\n", a, b, diff, allowed); return false; } return true; } -static bool nearly_eq(Vec2D a, Vec2D b, float tol) { +static bool nearly_eq(Vec2D a, Vec2D b, float tol) +{ return nearly_eq(a.x, b.x, tol) && nearly_eq(a.y, b.y, tol); } -TEST_CASE("contour-basics", "[contourmeasure]") { +TEST_CASE("contour-basics", "[contourmeasure]") +{ const float tol = 0.000001f; RawPath path; @@ -67,7 +71,8 @@ {{w / 2, h}, {-1, 0}}, {{0, h / 2}, {0, -1}}, }; - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < 4; ++i) + { auto rec = cm->getPosTan(midDistances[i]); REQUIRE(nearly_eq(rec.pos, midPoints[i].pos, tol)); REQUIRE(nearly_eq(rec.tan, midPoints[i].tan, tol)); @@ -75,7 +80,8 @@ REQUIRE(iter.next() == nullptr); } -TEST_CASE("multi-contours", "[contourmeasure]") { +TEST_CASE("multi-contours", "[contourmeasure]") +{ const Vec2D pts[] = { {0, 0}, {3, 0}, @@ -120,7 +126,8 @@ REQUIRE(!cm); } -TEST_CASE("contour-oval", "[contourmeasure]") { +TEST_CASE("contour-oval", "[contourmeasure]") +{ const float tol = 0.0075f; const float r = 10;
diff --git a/test/default_state_machine_test.cpp b/test/default_state_machine_test.cpp index 6da2b4e..1983b7c 100644 --- a/test/default_state_machine_test.cpp +++ b/test/default_state_machine_test.cpp
@@ -10,7 +10,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("default state machine is detected at load", "[file]") { +TEST_CASE("default state machine is detected at load", "[file]") +{ auto file = ReadRiveFile("../../test/assets/entry.riv"); auto abi = file->artboardAt(0);
diff --git a/test/distance_constraint_test.cpp b/test/distance_constraint_test.cpp index ece41f0..62b97f5 100644 --- a/test/distance_constraint_test.cpp +++ b/test/distance_constraint_test.cpp
@@ -7,7 +7,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("distance constraints moves items as expected", "[file]") { +TEST_CASE("distance constraints moves items as expected", "[file]") +{ auto file = ReadRiveFile("../../test/assets/distance_constraint.riv"); auto artboard = file->artboard();
diff --git a/test/draw_order_test.cpp b/test/draw_order_test.cpp index be3a122..8567648 100644 --- a/test/draw_order_test.cpp +++ b/test/draw_order_test.cpp
@@ -8,7 +8,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("draw rules load and sort correctly", "[draw rules]") { +TEST_CASE("draw rules load and sort correctly", "[draw rules]") +{ auto file = ReadRiveFile("../../test/assets/draw_rule_cycle.riv"); // auto file = reader.file();
diff --git a/test/file_test.cpp b/test/file_test.cpp index 8cb589f..cb6fb59 100644 --- a/test/file_test.cpp +++ b/test/file_test.cpp
@@ -9,7 +9,8 @@ #include <cstdio> #include <cstring> -TEST_CASE("file can be read", "[file]") { +TEST_CASE("file can be read", "[file]") +{ RenderObjectLeakChecker checker; auto file = ReadRiveFile("../../test/assets/two_artboards.riv"); @@ -20,7 +21,8 @@ REQUIRE(file->artboard("One") != nullptr); } -TEST_CASE("file with animation can be read", "[file]") { +TEST_CASE("file with animation can be read", "[file]") +{ RenderObjectLeakChecker checker; auto file = ReadRiveFile("../../test/assets/juice.riv"); @@ -45,7 +47,8 @@ REQUIRE(walkAnimation->numKeyedObjects() == 22); } -TEST_CASE("artboards can be counted and accessed via index or name", "[file]") { +TEST_CASE("artboards can be counted and accessed via index or name", "[file]") +{ RenderObjectLeakChecker checker; auto file = ReadRiveFile("../../test/assets/dependency_test.riv"); @@ -59,7 +62,8 @@ REQUIRE(file->artboard("Blue") != nullptr); } -TEST_CASE("dependencies are as expected", "[file]") { +TEST_CASE("dependencies are as expected", "[file]") +{ RenderObjectLeakChecker checker; // ┌────┐ // │Blue│ @@ -117,7 +121,8 @@ REQUIRE(world[5] == 29.535156f); } -TEST_CASE("long name in object is parsed correctly", "[file]") { +TEST_CASE("long name in object is parsed correctly", "[file]") +{ RenderObjectLeakChecker checker; auto file = ReadRiveFile("../../test/assets/long_name.riv"); auto artboard = file->artboard(); @@ -126,7 +131,8 @@ REQUIRE(artboard->objects().size() == 7); } -TEST_CASE("file with in-band images can have the stripped", "[file]") { +TEST_CASE("file with in-band images can have the stripped", "[file]") +{ RenderObjectLeakChecker checker; FILE* fp = fopen("../../test/assets/jellyfish_test.riv", "rb"); REQUIRE(fp != nullptr);
diff --git a/test/hittest_test.cpp b/test/hittest_test.cpp index d0bff8a..73417d8 100644 --- a/test/hittest_test.cpp +++ b/test/hittest_test.cpp
@@ -10,7 +10,8 @@ using namespace rive; -TEST_CASE("hittest-basics", "[hittest]") { +TEST_CASE("hittest-basics", "[hittest]") +{ HitTester tester; tester.reset({10, 10, 12, 12}); tester.move({0, 0}); @@ -31,14 +32,16 @@ tester.reset(area); tester.move(pts[0]); - for (int i = 1; i < 4; ++i) { + for (int i = 1; i < 4; ++i) + { tester.line(pts[i]); } tester.close(); REQUIRE(tester.test()); } -TEST_CASE("hittest-mesh", "[hittest]") { +TEST_CASE("hittest-mesh", "[hittest]") +{ const IAABB area{10, 10, 12, 12};
diff --git a/test/ik_constraint_test.cpp b/test/ik_constraint_test.cpp index b373818..04ddebd 100644 --- a/test/ik_constraint_test.cpp +++ b/test/ik_constraint_test.cpp
@@ -9,7 +9,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("ik with skinned bones orders correctly", "[file]") { +TEST_CASE("ik with skinned bones orders correctly", "[file]") +{ auto file = ReadRiveFile("../../test/assets/complex_ik_dependency.riv"); auto artboard = file->artboard(); @@ -20,8 +21,10 @@ REQUIRE(artboard->find<rive::Bone>("Two") != nullptr); auto two = artboard->find<rive::Bone>("Two"); rive::Skin* skin = nullptr; - for (auto object : artboard->objects()) { - if (object->is<rive::Skin>()) { + for (auto object : artboard->objects()) + { + if (object->is<rive::Skin>()) + { skin = object->as<rive::Skin>(); break; }
diff --git a/test/ik_test.cpp b/test/ik_test.cpp index f02aef0..874a063 100644 --- a/test/ik_test.cpp +++ b/test/ik_test.cpp
@@ -6,7 +6,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("two bone ik places bones correctly", "[file]") { +TEST_CASE("two bone ik places bones correctly", "[file]") +{ auto file = ReadRiveFile("../../test/assets/two_bone_ik.riv"); auto artboard = file->artboard(); @@ -78,7 +79,8 @@ 225.07647705078125f))); } -TEST_CASE("ik keeps working after a lot of iterations", "[file]") { +TEST_CASE("ik keeps working after a lot of iterations", "[file]") +{ auto file = ReadRiveFile("../../test/assets/two_bone_ik.riv"); auto artboard = file->artboard(); @@ -109,7 +111,8 @@ REQUIRE(std::find(boneB->dependents().begin(), boneB->dependents().end(), circleB) != boneB->dependents().end()); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 1000; i++) + { animation->apply(artboard, 0.0f, 1.0f); artboard->advance(0.0f); REQUIRE(target->x() == 296.0f);
diff --git a/test/image_asset_test.cpp b/test/image_asset_test.cpp index 4eb4a3d..2ec140e 100644 --- a/test/image_asset_test.cpp +++ b/test/image_asset_test.cpp
@@ -11,7 +11,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("image assets loads correctly", "[assets]") { +TEST_CASE("image assets loads correctly", "[assets]") +{ RenderObjectLeakChecker checker; auto file = ReadRiveFile("../../test/assets/walle.riv"); @@ -42,7 +43,8 @@ file->artboard()->draw(&renderer); } -TEST_CASE("out of band image assets loads correctly", "[assets]") { +TEST_CASE("out of band image assets loads correctly", "[assets]") +{ RenderObjectLeakChecker checker; rive::NoOpFactory gEmptyFactory;
diff --git a/test/image_mesh_test.cpp b/test/image_mesh_test.cpp index e04b7b2..eb3beb5 100644 --- a/test/image_mesh_test.cpp +++ b/test/image_mesh_test.cpp
@@ -11,7 +11,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("image with mesh loads correctly", "[mesh]") { +TEST_CASE("image with mesh loads correctly", "[mesh]") +{ auto file = ReadRiveFile("../../test/assets/tape.riv"); auto node = file->artboard()->find("Tape body.png"); @@ -25,7 +26,8 @@ REQUIRE(tape->mesh()->indices()->size() == 31 * 3); // Expect 31 triangles. } -TEST_CASE("duplicating a mesh shares the indices", "[mesh]") { +TEST_CASE("duplicating a mesh shares the indices", "[mesh]") +{ auto file = ReadRiveFile("../../test/assets/tape.riv"); auto instance1 = file->artboardDefault();
diff --git a/test/instancing_test.cpp b/test/instancing_test.cpp index d182928..4100951 100644 --- a/test/instancing_test.cpp +++ b/test/instancing_test.cpp
@@ -9,7 +9,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("cloning an ellipse works", "[instancing]") { +TEST_CASE("cloning an ellipse works", "[instancing]") +{ auto file = ReadRiveFile("../../test/assets/circle_clips.riv"); auto node = file->artboard()->find<rive::Shape>("TopEllipse"); @@ -22,7 +23,8 @@ delete clonedNode; } -TEST_CASE("instancing artboard clones clipped properties", "[instancing]") { +TEST_CASE("instancing artboard clones clipped properties", "[instancing]") +{ auto file = ReadRiveFile("../../test/assets/circle_clips.riv"); REQUIRE(!file->artboard()->isInstance()); @@ -46,7 +48,8 @@ artboard->draw(&renderer); } -TEST_CASE("instancing artboard doesn't clone animations", "[instancing]") { +TEST_CASE("instancing artboard doesn't clone animations", "[instancing]") +{ auto file = ReadRiveFile("../../test/assets/juice.riv"); auto artboard = file->artboardDefault();
diff --git a/test/line_break_test.cpp b/test/line_break_test.cpp index c56b831..da18244 100644 --- a/test/line_break_test.cpp +++ b/test/line_break_test.cpp
@@ -14,17 +14,20 @@ static rive::RenderTextRun append(std::vector<rive::Unichar>* unichars, rive::rcp<rive::RenderFont> font, float size, - const char text[]) { + const char text[]) +{ const uint8_t* ptr = (const uint8_t*)text; uint32_t n = 0; - while (*ptr) { + while (*ptr) + { unichars->push_back(rive::UTF::NextUTF8(&ptr)); n += 1; } return {std::move(font), size, n}; } -static rcp<RenderFont> loadFont(const char* filename) { +static rcp<RenderFont> loadFont(const char* filename) +{ FILE* fp = fopen("../../test/assets/RobotoFlex.ttf", "rb"); REQUIRE(fp != nullptr); @@ -38,7 +41,8 @@ return HBRenderFont::Decode(bytes); } -TEST_CASE("line breaker separates words", "[line break]") { +TEST_CASE("line breaker separates words", "[line break]") +{ auto font = loadFont("../../test/assets/RobotoFlex.ttf"); REQUIRE(font != nullptr); @@ -59,7 +63,8 @@ REQUIRE(run.breaks[5] == 13); } -TEST_CASE("line breaker handles multiple runs", "[line break]") { +TEST_CASE("line breaker handles multiple runs", "[line break]") +{ auto font = loadFont("../../test/assets/RobotoFlex.ttf"); REQUIRE(font != nullptr); @@ -88,7 +93,8 @@ } } -TEST_CASE("line breaker handles returns", "[line break]") { +TEST_CASE("line breaker handles returns", "[line break]") +{ auto font = loadFont("../../test/assets/RobotoFlex.ttf"); REQUIRE(font != nullptr); @@ -119,7 +125,8 @@ } } -TEST_CASE("line breaker builds lines", "[line break]") { +TEST_CASE("line breaker builds lines", "[line break]") +{ auto font = loadFont("../../test/assets/RobotoFlex.ttf"); REQUIRE(font != nullptr); @@ -164,7 +171,8 @@ } } -TEST_CASE("line breaker deals with extremes", "[line break]") { +TEST_CASE("line breaker deals with extremes", "[line break]") +{ auto font = loadFont("../../test/assets/RobotoFlex.ttf"); REQUIRE(font != nullptr); @@ -218,7 +226,8 @@ } } -TEST_CASE("line breaker breaks return characters", "[line break]") { +TEST_CASE("line breaker breaks return characters", "[line break]") +{ auto font = loadFont("../../test/assets/RobotoFlex.ttf"); REQUIRE(font != nullptr);
diff --git a/test/linear_animation_instance_test.cpp b/test/linear_animation_instance_test.cpp index fa24fb0..d9b0519 100644 --- a/test/linear_animation_instance_test.cpp +++ b/test/linear_animation_instance_test.cpp
@@ -5,7 +5,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("LinearAnimationInstance oneShot", "[animation]") { +TEST_CASE("LinearAnimationInstance oneShot", "[animation]") +{ rive::NoOpFactory emptyFactory; // For each of these tests, we cons up a dummy artboard/instance // just to make the animations happy. @@ -39,7 +40,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance oneShot <-", "[animation]") { +TEST_CASE("LinearAnimationInstance oneShot <-", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance(); @@ -87,7 +89,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance loop ->", "[animation]") { +TEST_CASE("LinearAnimationInstance loop ->", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance(); @@ -119,7 +122,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance loop <-", "[animation]") { +TEST_CASE("LinearAnimationInstance loop <-", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance(); @@ -161,7 +165,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance loop <- work area", "[animation]") { +TEST_CASE("LinearAnimationInstance loop <- work area", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance(); @@ -216,7 +221,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance pingpong ->", "[animation]") { +TEST_CASE("LinearAnimationInstance pingpong ->", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance(); @@ -249,7 +255,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance pingpong <-", "[animation]") { +TEST_CASE("LinearAnimationInstance pingpong <-", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance(); @@ -294,7 +301,8 @@ delete linearAnimation; } -TEST_CASE("LinearAnimationInstance override loop", "[animation]") { +TEST_CASE("LinearAnimationInstance override loop", "[animation]") +{ rive::NoOpFactory emptyFactory; rive::Artboard ab(&emptyFactory); auto abi = ab.instance();
diff --git a/test/metrics_path_test.cpp b/test/metrics_path_test.cpp index 6e6bf4b..44efab7 100644 --- a/test/metrics_path_test.cpp +++ b/test/metrics_path_test.cpp
@@ -1,7 +1,8 @@ #include <catch.hpp> #include <rive/shapes/metrics_path.hpp> -TEST_CASE("path metrics compute correctly", "[bezier]") { +TEST_CASE("path metrics compute correctly", "[bezier]") +{ // TODO: fix these based on new logic // Make a square with sides length 10. // rive::OnlyMetricsPath path;
diff --git a/test/node_test.cpp b/test/node_test.cpp index 36f371d..0fecbad 100644 --- a/test/node_test.cpp +++ b/test/node_test.cpp
@@ -3,7 +3,8 @@ TEST_CASE("Node instances", "[core]") { REQUIRE(rive::Node().x() == 0.0f); } -TEST_CASE("nodeX function return x value", "[node]") { +TEST_CASE("nodeX function return x value", "[node]") +{ rive::Node* node = new rive::Node(); REQUIRE(node->x() == 0.0f); node->x(2.0f);
diff --git a/test/path_test.cpp b/test/path_test.cpp index 5201c79..7d0839d 100644 --- a/test/path_test.cpp +++ b/test/path_test.cpp
@@ -13,10 +13,19 @@ // Need a specialized "noop" factory that does make an inspectable Path -namespace { -enum class TestPathCommandType { MoveTo, LineTo, CubicTo, Reset, Close }; +namespace +{ +enum class TestPathCommandType +{ + MoveTo, + LineTo, + CubicTo, + Reset, + Close +}; -struct TestPathCommand { +struct TestPathCommand +{ TestPathCommandType command; float x; float y; @@ -26,10 +35,12 @@ float outY; }; -class TestRenderPath : public rive::RenderPath { +class TestRenderPath : public rive::RenderPath +{ public: std::vector<TestPathCommand> commands; - void reset() override { + void reset() override + { commands.emplace_back( (TestPathCommand){TestPathCommandType::Reset, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}); } @@ -38,33 +49,40 @@ void addPath(rive::CommandPath* path, const rive::Mat2D& transform) override {} void addRenderPath(rive::RenderPath* path, const rive::Mat2D& transform) override {} - void moveTo(float x, float y) override { + void moveTo(float x, float y) override + { commands.emplace_back( (TestPathCommand){TestPathCommandType::MoveTo, x, y, 0.0f, 0.0f, 0.0f, 0.0f}); } - void lineTo(float x, float y) override { + void lineTo(float x, float y) override + { commands.emplace_back( (TestPathCommand){TestPathCommandType::LineTo, x, y, 0.0f, 0.0f, 0.0f, 0.0f}); } - 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 + { commands.emplace_back( (TestPathCommand){TestPathCommandType::CubicTo, x, y, ix, iy, ox, oy}); } - void close() override { + void close() override + { commands.emplace_back( (TestPathCommand){TestPathCommandType::Close, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}); } }; -class TestNoOpFactory : public rive::NoOpFactory { +class TestNoOpFactory : public rive::NoOpFactory +{ public: - std::unique_ptr<rive::RenderPath> makeEmptyRenderPath() override { + std::unique_ptr<rive::RenderPath> makeEmptyRenderPath() override + { return std::make_unique<TestRenderPath>(); } }; } // namespace -TEST_CASE("rectangle path builds expected commands", "[path]") { +TEST_CASE("rectangle path builds expected commands", "[path]") +{ TestNoOpFactory emptyFactory; rive::Artboard artboard(&emptyFactory); rive::Shape* shape = new rive::Shape(); @@ -99,7 +117,8 @@ REQUIRE(path->commands[6].command == TestPathCommandType::Close); } -TEST_CASE("rounded rectangle path builds expected commands", "[path]") { +TEST_CASE("rounded rectangle path builds expected commands", "[path]") +{ TestNoOpFactory emptyFactory; rive::Artboard artboard(&emptyFactory); rive::Shape* shape = new rive::Shape(); @@ -161,7 +180,8 @@ REQUIRE(path->commands[10].command == TestPathCommandType::Close); } -TEST_CASE("ellipse path builds expected commands", "[path]") { +TEST_CASE("ellipse path builds expected commands", "[path]") +{ TestNoOpFactory emptyFactory; rive::Artboard artboard(&emptyFactory); rive::Ellipse* ellipse = new rive::Ellipse();
diff --git a/test/raw_path_test.cpp b/test/raw_path_test.cpp index 460542b..0eca6c3 100644 --- a/test/raw_path_test.cpp +++ b/test/raw_path_test.cpp
@@ -12,7 +12,8 @@ using namespace rive; -TEST_CASE("rawpath-basics", "[rawpath]") { +TEST_CASE("rawpath-basics", "[rawpath]") +{ RawPath path; REQUIRE(path.empty()); @@ -33,7 +34,8 @@ REQUIRE(path.bounds() == AABB{-1, -2, 3, 5}); } -TEST_CASE("rawpath-add-helpers", "[rawpath]") { +TEST_CASE("rawpath-add-helpers", "[rawpath]") +{ RawPath path; path.addRect({1, 1, 5, 6}); @@ -57,21 +59,25 @@ }; constexpr auto size = sizeof(pts) / sizeof(pts[0]); - for (auto isClosed : {false, true}) { + for (auto isClosed : {false, true}) + { path = RawPath(); path.addPoly({pts, size}, isClosed); REQUIRE(path.bounds() == AABB{1, -100, 100, 5}); REQUIRE(path.points().size() == size); REQUIRE(path.verbs().size() == size + isClosed); - for (size_t i = 0; i < size; ++i) { + for (size_t i = 0; i < size; ++i) + { REQUIRE(path.points()[i] == pts[i]); } REQUIRE(path.verbs()[0] == PathVerb::move); - for (size_t i = 1; i < size; ++i) { + for (size_t i = 1; i < size; ++i) + { REQUIRE(path.verbs()[i] == PathVerb::line); } - if (isClosed) { + if (isClosed) + { REQUIRE(path.verbs()[size] == PathVerb::close); } } @@ -82,17 +88,20 @@ static void check_iter(RawPath::Iter& iter, const RawPath::Iter& end, PathVerb expectedVerb, - std::vector<Vec2D> expectedPts) { + std::vector<Vec2D> expectedPts) +{ REQUIRE(iter != end); auto [verb, pts] = *iter; REQUIRE(verb == expectedVerb); - for (size_t i = 0; i < expectedPts.size(); ++i) { + for (size_t i = 0; i < expectedPts.size(); ++i) + { CHECK(pts[i] == expectedPts[i]); } ++iter; } -TEST_CASE("rawpath-iter", "[rawpath]") { +TEST_CASE("rawpath-iter", "[rawpath]") +{ { RawPath rp; REQUIRE(rp.begin() == rp.end()); @@ -156,7 +165,8 @@ } } -TEST_CASE("addPath", "[rawpath]") { +TEST_CASE("addPath", "[rawpath]") +{ using PathMaker = void (*)(RawPath * sink); const PathMaker makers[] = { @@ -184,7 +194,8 @@ RawPath p; m0(&p); m1(&p); - if (mx) { + if (mx) + { p.transformInPlace(*mx); } return p; @@ -202,8 +213,10 @@ return p; }; - for (auto i = 0; i < N; ++i) { - for (auto j = 0; j < N; ++j) { + for (auto i = 0; i < N; ++i) + { + for (auto j = 0; j < N; ++j) + { RawPath p0, p1; p0 = direct(makers[i], makers[j], nullptr); @@ -218,7 +231,8 @@ } } -TEST_CASE("bounds", "[rawpath]") { +TEST_CASE("bounds", "[rawpath]") +{ RawPath path; AABB bounds; srand(0); @@ -230,32 +244,42 @@ bounds.maxY = std::max(bounds.maxY, pt.y); return pt; }; - for (int numVerbs = 1; numVerbs < 1 << 16; numVerbs <<= 1) { + for (int numVerbs = 1; numVerbs < 1 << 16; numVerbs <<= 1) + { path.rewind(); bounds.minX = bounds.minY = std::numeric_limits<float>::infinity(); bounds.maxX = bounds.maxY = -std::numeric_limits<float>::infinity(); - for (int i = 0; i < numVerbs; ++i) { - switch (rand() % 5) { - case 0: path.move(randPt()); break; + for (int i = 0; i < numVerbs; ++i) + { + switch (rand() % 5) + { + case 0: + path.move(randPt()); + break; case 1: - if (path.empty()) { // Account for the implicit moveTo(0). + if (path.empty()) + { // Account for the implicit moveTo(0). bounds = {}; } path.line(randPt()); break; case 2: - if (path.empty()) { // Account for the implicit moveTo(0). + if (path.empty()) + { // Account for the implicit moveTo(0). bounds = {}; } path.quad(randPt(), randPt()); break; case 3: - if (path.empty()) { // Account for the implicit moveTo(0). + if (path.empty()) + { // Account for the implicit moveTo(0). bounds = {}; } path.cubic(randPt(), randPt(), randPt()); break; - case 4: path.close(); break; + case 4: + path.close(); + break; } } AABB pathBounds = path.bounds();
diff --git a/test/reader_test.cpp b/test/reader_test.cpp index 9178cd3..deea9c7 100644 --- a/test/reader_test.cpp +++ b/test/reader_test.cpp
@@ -1,7 +1,8 @@ #include <catch.hpp> #include <rive/core/reader.h> -TEST_CASE("uint leb decoder", "[reader]") { +TEST_CASE("uint leb decoder", "[reader]") +{ uint64_t result; uint8_t encoded1[] = {0x01}; @@ -17,7 +18,8 @@ REQUIRE(result == 624485); } -TEST_CASE("string decoder", "[reader]") { +TEST_CASE("string decoder", "[reader]") +{ char* str = strdup("New Artboard"); uint8_t str_bytes[] = {0x4E, 0x65, 0x77, 0x20, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72, 0x64}; // Length of string + 1 is needed to add the null terminator @@ -32,7 +34,8 @@ delete decoded_str; } -TEST_CASE("float decoder", "[reader]") { +TEST_CASE("float decoder", "[reader]") +{ float decoded_num; uint64_t bytes_read; @@ -55,7 +58,8 @@ REQUIRE(bytes_read == 0); } -TEST_CASE("byte decoder", "[reader") { +TEST_CASE("byte decoder", "[reader") +{ uint8_t decoded_byte; // luigi: commented this out as it was giving a warning (I added -Wall to // the compiler flags). Warning was:
diff --git a/test/refcnt_test.cpp b/test/refcnt_test.cpp index 211825a..c62363b 100644 --- a/test/refcnt_test.cpp +++ b/test/refcnt_test.cpp
@@ -8,7 +8,8 @@ using namespace rive; -class MyRefCnt : public RefCnt<MyRefCnt> { +class MyRefCnt : public RefCnt<MyRefCnt> +{ public: MyRefCnt() {} MyRefCnt(int, float, bool) {} @@ -16,7 +17,8 @@ void require_count(int value) { REQUIRE(this->debugging_refcnt() == value); } }; -TEST_CASE("refcnt", "[basics]") { +TEST_CASE("refcnt", "[basics]") +{ MyRefCnt my; REQUIRE(my.debugging_refcnt() == 1); my.ref(); @@ -34,7 +36,8 @@ safe_unref((MyRefCnt*)nullptr); } -TEST_CASE("rcp", "[basics]") { +TEST_CASE("rcp", "[basics]") +{ rcp<MyRefCnt> r0(nullptr); REQUIRE(r0.get() == nullptr);
diff --git a/test/rive_file_reader.hpp b/test/rive_file_reader.hpp index bf01652..9fe969e 100644 --- a/test/rive_file_reader.hpp +++ b/test/rive_file_reader.hpp
@@ -9,11 +9,12 @@ static rive::NoOpFactory gNoOpFactory; -static inline std::unique_ptr<rive::File> -ReadRiveFile(const char path[], - rive::Factory* factory = nullptr, - rive::FileAssetResolver* resolver = nullptr) { - if (!factory) { +static inline std::unique_ptr<rive::File> ReadRiveFile(const char path[], + rive::Factory* factory = nullptr, + rive::FileAssetResolver* resolver = nullptr) +{ + if (!factory) + { factory = &gNoOpFactory; } @@ -36,19 +37,24 @@ return file; } -class RenderObjectLeakChecker { +class RenderObjectLeakChecker +{ int m_before[rive::Counter::kNumTypes]; public: - RenderObjectLeakChecker() { + RenderObjectLeakChecker() + { std::copy(rive::Counter::counts, rive::Counter::counts + rive::Counter::kNumTypes, m_before); } - ~RenderObjectLeakChecker() { + ~RenderObjectLeakChecker() + { const int* after = rive::Counter::counts; - for (int i = 0; i < rive::Counter::kNumTypes; ++i) { - if (rive::Counter::counts[i] != m_before[i]) { + for (int i = 0; i < rive::Counter::kNumTypes; ++i) + { + if (rive::Counter::counts[i] != m_before[i]) + { printf("[%d] before:%d after:%d\n", i, m_before[i], after[i]); REQUIRE(false); }
diff --git a/test/rive_testing.cpp b/test/rive_testing.cpp index ac27630..aa7691e 100644 --- a/test/rive_testing.cpp +++ b/test/rive_testing.cpp
@@ -1,9 +1,12 @@ #include "rive_testing.hpp" -bool aboutEqual(const rive::Mat2D& a, const rive::Mat2D& b) { +bool aboutEqual(const rive::Mat2D& a, const rive::Mat2D& b) +{ const float epsilon = 0.0001f; - for (int i = 0; i < 6; i++) { - if (std::fabs(a[i] - b[i]) > epsilon) { + for (int i = 0; i < 6; i++) + { + if (std::fabs(a[i] - b[i]) > epsilon) + { return false; } }
diff --git a/test/rive_testing.hpp b/test/rive_testing.hpp index db1308f..f790280 100644 --- a/test/rive_testing.hpp +++ b/test/rive_testing.hpp
@@ -7,9 +7,12 @@ bool aboutEqual(const rive::Mat2D& a, const rive::Mat2D& b); -namespace Catch { -template <> struct StringMaker<rive::Mat2D> { - static std::string convert(rive::Mat2D const& value) { +namespace Catch +{ +template <> struct StringMaker<rive::Mat2D> +{ + static std::string convert(rive::Mat2D const& value) + { std::ostringstream os; os << value[0] << ", " << value[1] << ", " << value[2] << ", " << value[3] << ", " << value[4] << ", " << value[5];
diff --git a/test/rotation_constraint_test.cpp b/test/rotation_constraint_test.cpp index 5419e87..3acd28b 100644 --- a/test/rotation_constraint_test.cpp +++ b/test/rotation_constraint_test.cpp
@@ -8,7 +8,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("rotation constraint updates world transform", "[file]") { +TEST_CASE("rotation constraint updates world transform", "[file]") +{ auto file = ReadRiveFile("../../test/assets/rotation_constraint.riv"); auto artboard = file->artboard();
diff --git a/test/scale_constraint_test.cpp b/test/scale_constraint_test.cpp index efe76ac..f5d2333 100644 --- a/test/scale_constraint_test.cpp +++ b/test/scale_constraint_test.cpp
@@ -8,7 +8,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("scale constraint updates world transform", "[file]") { +TEST_CASE("scale constraint updates world transform", "[file]") +{ auto file = ReadRiveFile("../../test/assets/scale_constraint.riv"); auto artboard = file->artboard();
diff --git a/test/simd_test.cpp b/test/simd_test.cpp index 1c45b54..66199e7 100644 --- a/test/simd_test.cpp +++ b/test/simd_test.cpp
@@ -7,13 +7,15 @@ #include "rive/math/simd.hpp" #include <limits> -namespace rive { +namespace rive +{ constexpr float kInf = std::numeric_limits<float>::infinity(); constexpr float kNaN = std::numeric_limits<float>::quiet_NaN(); // Verify the simd float types are IEEE 754 compliant for infinity and NaN. -TEST_CASE("ieee-compliance", "[simd]") { +TEST_CASE("ieee-compliance", "[simd]") +{ float4 test = float4{1, -kInf, 1, 4} / float4{0, 2, kInf, 4}; CHECK(simd::all(test == float4{kInf, -kInf, 0, 1})); @@ -30,7 +32,8 @@ test.xy /= float2{kInf, 0}; test.z *= kInf; test.w -= kInf; - for (int i = 0; i < 4; ++i) { + for (int i = 0; i < 4; ++i) + { CHECK(std::isnan(test[i])); } // NaN always fails comparisons. @@ -48,7 +51,8 @@ } // Check that ?: works on vector and scalar conditions. -TEST_CASE("ternary-operator", "[simd]") { +TEST_CASE("ternary-operator", "[simd]") +{ // Vector condition. float4 f4 = int4{1, 2, 3, 4} < int4{4, 3, 2, 1} ? float4(-1) : 1.f; CHECK(simd::all(f4 == float4{-1, -1, 1, 1})); @@ -63,7 +67,8 @@ } // Check simd::min/max compliance. -TEST_CASE("min-max", "[simd]") { +TEST_CASE("min-max", "[simd]") +{ float4 f4 = simd::min(float4{1, 2, 3, 4}, float4{4, 3, 2}); CHECK(simd::all(f4 == float4{1, 2, 2, 0})); f4 = simd::max(float4{1, 2, 3, 4}, float4{4, 3, 2}); @@ -100,7 +105,8 @@ } // Check simd::abs. -TEST_CASE("abs", "[simd]") { +TEST_CASE("abs", "[simd]") +{ CHECK(simd::all(simd::abs(float4{-1, 2, -3, 4}) == float4{1, 2, 3, 4})); CHECK(simd::all(simd::abs(float2{-5, 6}) == float2{5, 6}));
diff --git a/test/simple_array_test.cpp b/test/simple_array_test.cpp index cdfd3f2..78e7463 100644 --- a/test/simple_array_test.cpp +++ b/test/simple_array_test.cpp
@@ -8,7 +8,8 @@ using namespace rive; -TEST_CASE("array initializes as expected", "[simple array]") { +TEST_CASE("array initializes as expected", "[simple array]") +{ SimpleArray<int> array; REQUIRE(array.empty()); REQUIRE(array.size() == 0); @@ -16,7 +17,8 @@ REQUIRE(array.begin() == array.end()); } -TEST_CASE("simple array can be created", "[simple array]") { +TEST_CASE("simple array can be created", "[simple array]") +{ SimpleArray<int> array({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); REQUIRE(!array.empty()); @@ -26,7 +28,8 @@ int counter = 0; int sum = 0; - for (auto s : array) { + for (auto s : array) + { counter += 1; sum += s; } @@ -34,17 +37,20 @@ REQUIRE(sum == 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9); } -TEST_CASE("can iterate simple array", "[simple array]") { +TEST_CASE("can iterate simple array", "[simple array]") +{ const int carray[] = {2, 4, 8, 16}; SimpleArray<int> array(carray); int expect = 2; - for (auto value : array) { + for (auto value : array) + { REQUIRE(value == expect); expect *= 2; } } -TEST_CASE("can build up a simple array", "[simple array]") { +TEST_CASE("can build up a simple array", "[simple array]") +{ SimpleArrayBuilder<int> builder; builder.add(1); builder.add(2); @@ -57,7 +63,8 @@ int iterationCount = 0; int expect = 1; - for (auto value : builder) { + for (auto value : builder) + { REQUIRE(value == expect++); iterationCount++; } @@ -73,11 +80,13 @@ REQUIRE(SimpleArrayTesting::reallocCount == reallocCountBeforeMove + 1); } -struct StructA { +struct StructA +{ rive::SimpleArray<uint32_t> numbers; }; -static SimpleArray<StructA> buildStructs() { +static SimpleArray<StructA> buildStructs() +{ SimpleArrayTesting::resetCounters(); SimpleArray<uint32_t> numbersA({33, 22, 44, 66}); @@ -109,7 +118,8 @@ return structs; } -TEST_CASE("arrays of arrays work", "[simple array]") { +TEST_CASE("arrays of arrays work", "[simple array]") +{ auto structs = buildStructs(); REQUIRE(SimpleArrayTesting::mallocCount == 3); REQUIRE(SimpleArrayTesting::reallocCount == 0); @@ -118,11 +128,13 @@ REQUIRE(structs[1].numbers.size() == 3); } -static SimpleArray<StructA> buildStructsWithBuilder() { +static SimpleArray<StructA> buildStructsWithBuilder() +{ SimpleArrayTesting::resetCounters(); SimpleArrayBuilder<StructA> structs(2); REQUIRE(SimpleArrayTesting::mallocCount == 1); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) + { SimpleArray<uint32_t> numbers({33, 22, 44, 66}); StructA data = {.numbers = std::move(numbers)}; structs.add(std::move(data)); @@ -133,7 +145,8 @@ return std::move(structs); } -TEST_CASE("builder arrays of arrays work", "[simple array]") { +TEST_CASE("builder arrays of arrays work", "[simple array]") +{ auto structs = buildStructsWithBuilder(); // alloc counters should still be the same REQUIRE(SimpleArrayTesting::mallocCount == 4); @@ -141,7 +154,8 @@ REQUIRE(SimpleArrayTesting::reallocCount == 2); } -TEST_CASE("builders can be reset", "[simple array]") { +TEST_CASE("builders can be reset", "[simple array]") +{ SimpleArrayTesting::resetCounters(); SimpleArrayBuilder<uint32_t> builder(3); builder.add(1);
diff --git a/test/span_test.cpp b/test/span_test.cpp index a4c6ae5..a2ddfb6 100644 --- a/test/span_test.cpp +++ b/test/span_test.cpp
@@ -9,7 +9,8 @@ using namespace rive; -TEST_CASE("basics", "[span]") { +TEST_CASE("basics", "[span]") +{ Span<int> span; REQUIRE(span.empty()); REQUIRE(span.size() == 0); @@ -27,7 +28,8 @@ int counter = 0; int sum = 0; - for (auto s : span) { + for (auto s : span) + { counter += 1; sum += s; } @@ -47,7 +49,8 @@ static void funca(Span<int> span) {} static void funcb(Span<const int> span) {} -TEST_CASE("const-and-containers", "[span]") { +TEST_CASE("const-and-containers", "[span]") +{ const int carray[] = {1, 2, 3, 4}; funcb({carray, 4}); @@ -62,12 +65,14 @@ funcb(v); } -TEST_CASE("can iterate span", "[span]") { +TEST_CASE("can iterate span", "[span]") +{ const int carray[] = {2, 4, 8, 16}; auto span = Span(carray); int expect = 2; - for (auto value : span) { + for (auto value : span) + { REQUIRE(value == expect); expect *= 2; }
diff --git a/test/state_machine_event_test.cpp b/test/state_machine_event_test.cpp index 01e77ae..00586c0 100644 --- a/test/state_machine_event_test.cpp +++ b/test/state_machine_event_test.cpp
@@ -18,7 +18,8 @@ #include "rive_file_reader.hpp" #include <cstdio> -TEST_CASE("file with state machine listeners be read", "[file]") { +TEST_CASE("file with state machine listeners be read", "[file]") +{ auto file = ReadRiveFile("../../test/assets/bullet_man.riv"); auto artboard = file->artboard("Bullet Man"); @@ -63,7 +64,8 @@ REQUIRE(inputChange3->as<rive::ListenerInputChange>()->inputId() == 2); } -TEST_CASE("hit testing via a state machine works", "[file]") { +TEST_CASE("hit testing via a state machine works", "[file]") +{ auto file = ReadRiveFile("../../test/assets/bullet_man.riv"); auto artboard = file->artboard("Bullet Man")->instance(); @@ -85,7 +87,8 @@ REQUIRE(trigger->didFire()); } -TEST_CASE("hit a toggle boolean listener", "[file]") { +TEST_CASE("hit a toggle boolean listener", "[file]") +{ auto file = ReadRiveFile("../../test/assets/light_switch.riv"); auto artboard = file->artboard()->instance();
diff --git a/test/state_machine_test.cpp b/test/state_machine_test.cpp index 3424c5f..7f20e6d 100644 --- a/test/state_machine_test.cpp +++ b/test/state_machine_test.cpp
@@ -14,7 +14,8 @@ #include "rive_file_reader.hpp" #include <cstdio> -TEST_CASE("file with state machine be read", "[file]") { +TEST_CASE("file with state machine be read", "[file]") +{ auto file = ReadRiveFile("../../test/assets/rocket.riv"); auto artboard = file->artboard(); @@ -44,9 +45,11 @@ REQUIRE(layer->exitState() != nullptr); int foundAnimationStates = 0; - for (int i = 0; i < layer->stateCount(); i++) { + for (int i = 0; i < layer->stateCount(); i++) + { auto state = layer->state(i); - if (state->is<rive::AnimationState>()) { + if (state->is<rive::AnimationState>()) + { foundAnimationStates++; REQUIRE(state->as<rive::AnimationState>()->animation() != nullptr); } @@ -63,9 +66,11 @@ auto idleState = stateTo->as<rive::AnimationState>(); REQUIRE(idleState->transitionCount() == 2); - for (int i = 0; i < idleState->transitionCount(); i++) { + for (int i = 0; i < idleState->transitionCount(); i++) + { auto transition = idleState->transition(i); - if (transition->stateTo()->as<rive::AnimationState>()->animation()->name() == "Roll_over") { + if (transition->stateTo()->as<rive::AnimationState>()->animation()->name() == "Roll_over") + { // Check the condition REQUIRE(transition->conditionCount() == 1); } @@ -82,7 +87,8 @@ REQUIRE(smi.currentAnimationCount() == 0); } -TEST_CASE("file with blend states loads correctly", "[file]") { +TEST_CASE("file with blend states loads correctly", "[file]") +{ auto file = ReadRiveFile("../../test/assets/blend_test.riv"); auto artboard = file->artboard(); @@ -137,7 +143,8 @@ nullptr); } -TEST_CASE("animation state with no animation doesn't crash", "[file]") { +TEST_CASE("animation state with no animation doesn't crash", "[file]") +{ auto file = ReadRiveFile("../../test/assets/multiple_state_machines.riv"); auto artboard = file->artboard();
diff --git a/test/stroke_test.cpp b/test/stroke_test.cpp index ed47ee1..392c836 100644 --- a/test/stroke_test.cpp +++ b/test/stroke_test.cpp
@@ -10,7 +10,8 @@ #include <catch.hpp> #include <cstdio> -TEST_CASE("stroke can be looked up at runtime", "[file]") { +TEST_CASE("stroke can be looked up at runtime", "[file]") +{ auto file = ReadRiveFile("../../test/assets/stroke_name_test.riv"); auto artboard = file->artboard();
diff --git a/test/transform_constraint_test.cpp b/test/transform_constraint_test.cpp index 64f1f75..315a3c4 100644 --- a/test/transform_constraint_test.cpp +++ b/test/transform_constraint_test.cpp
@@ -7,7 +7,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("transform constraint updates world transform", "[file]") { +TEST_CASE("transform constraint updates world transform", "[file]") +{ auto file = ReadRiveFile("../../test/assets/transform_constraint.riv"); auto artboard = file->artboard();
diff --git a/test/translation_constraint_test.cpp b/test/translation_constraint_test.cpp index 5452019..b38af62 100644 --- a/test/translation_constraint_test.cpp +++ b/test/translation_constraint_test.cpp
@@ -8,7 +8,8 @@ #include "rive_testing.hpp" #include <cstdio> -TEST_CASE("translation constraint updates world transform", "[file]") { +TEST_CASE("translation constraint updates world transform", "[file]") +{ auto file = ReadRiveFile("../../test/assets/translation_constraint.riv"); auto artboard = file->artboard();
diff --git a/utils/no_op_factory.cpp b/utils/no_op_factory.cpp index c187a46..9058301 100644 --- a/utils/no_op_factory.cpp +++ b/utils/no_op_factory.cpp
@@ -3,12 +3,15 @@ using namespace rive; -namespace { -class NoOpRenderImage : public RenderImage { +namespace +{ +class NoOpRenderImage : public RenderImage +{ public: }; -class NoOpRenderPaint : public RenderPaint { +class NoOpRenderPaint : public RenderPaint +{ public: void color(unsigned int value) override {} void style(RenderPaintStyle value) override {} @@ -20,7 +23,8 @@ void invalidateStroke() override {} }; -class NoOpRenderPath : public RenderPath { +class NoOpRenderPath : public RenderPath +{ public: void reset() override {} @@ -45,7 +49,8 @@ float ey, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ return nullptr; } @@ -54,22 +59,27 @@ float radius, const ColorInt colors[], // [count] const float stops[], // [count] - size_t count) { + size_t count) +{ return nullptr; } -std::unique_ptr<RenderPath> NoOpFactory::makeRenderPath(RawPath&, FillRule) { +std::unique_ptr<RenderPath> NoOpFactory::makeRenderPath(RawPath&, FillRule) +{ return std::make_unique<NoOpRenderPath>(); } -std::unique_ptr<RenderPath> NoOpFactory::makeEmptyRenderPath() { +std::unique_ptr<RenderPath> NoOpFactory::makeEmptyRenderPath() +{ return std::make_unique<NoOpRenderPath>(); } -std::unique_ptr<RenderPaint> NoOpFactory::makeRenderPaint() { +std::unique_ptr<RenderPaint> NoOpFactory::makeRenderPaint() +{ return std::make_unique<NoOpRenderPaint>(); } -std::unique_ptr<RenderImage> NoOpFactory::decodeImage(Span<const uint8_t>) { +std::unique_ptr<RenderImage> NoOpFactory::decodeImage(Span<const uint8_t>) +{ return std::unique_ptr<NoOpRenderImage>(); }
diff --git a/utils/rive_utf.cpp b/utils/rive_utf.cpp index 6be3dee..3ff6fdf 100644 --- a/utils/rive_utf.cpp +++ b/utils/rive_utf.cpp
@@ -7,16 +7,19 @@ using namespace rive; -int UTF::CountUTF8Length(const uint8_t utf8[]) { +int UTF::CountUTF8Length(const uint8_t utf8[]) +{ unsigned lead = *utf8; assert(lead != 0xFF); assert((lead & 0xC0) != 0x80); // 10xxxxxx is not a legal lead byte - if ((lead & 0x80) == 0) { + if ((lead & 0x80) == 0) + { return 1; } int n = 1; lead <<= 1; - while (lead & 0x80) { + while (lead & 0x80) + { n += 1; lead <<= 1; } @@ -26,7 +29,8 @@ // Return the unichar pointed to by the utf8 pointer, and then // update the pointer to point to the next sequence. -Unichar UTF::NextUTF8(const uint8_t** utf8Ptr) { +Unichar UTF::NextUTF8(const uint8_t** utf8Ptr) +{ const uint8_t* text = *utf8Ptr; uint32_t c = 0; @@ -34,12 +38,16 @@ assert(n >= 1 && n <= 4); unsigned first = *text++; - if (n == 1) { + if (n == 1) + { c = first; - } else { + } + else + { c = first & ((unsigned)0xFF >> n); --n; - do { + do + { c = (c << 6) | (*text++ & 0x3F); } while (--n); } @@ -47,8 +55,10 @@ return c; } -int UTF::ToUTF16(Unichar uni, uint16_t utf16[]) { - if (uni > 0xFFFF) { +int UTF::ToUTF16(Unichar uni, uint16_t utf16[]) +{ + if (uni > 0xFFFF) + { utf16[0] = castTo<uint16_t>((0xD800 - 64) | (uni >> 10)); utf16[1] = castTo<uint16_t>(0xDC00 | (uni & 0x3FF)); return 2;
diff --git a/viewer/include/viewer/sample_tools/sample_atlas_packer.hpp b/viewer/include/viewer/sample_tools/sample_atlas_packer.hpp index c131e3f..8c1a34b 100644 --- a/viewer/include/viewer/sample_tools/sample_atlas_packer.hpp +++ b/viewer/include/viewer/sample_tools/sample_atlas_packer.hpp
@@ -9,11 +9,13 @@ #include <vector> #include <unordered_map> -namespace rive { +namespace rive +{ class ImageAsset; class SokolRenderImageResource; /// A single atlas image generated by the packer. -class SampleAtlas { +class SampleAtlas +{ private: uint32_t m_width; uint32_t m_height; @@ -33,7 +35,8 @@ Span<const uint8_t> pixels() const { return m_pixels; } }; -struct SampleAtlasLocation { +struct SampleAtlasLocation +{ std::size_t atlasIndex; Mat2D transform; // Original width & height of the image, so we can make vertex buffers for the "default renderer @@ -44,7 +47,8 @@ /// An Atlas packer which will create multiple atlas images (SampleAtles) as /// necessary. -class SampleAtlasPacker { +class SampleAtlasPacker +{ private: uint32_t m_maxWidth; uint32_t m_maxHeight; @@ -61,7 +65,8 @@ SampleAtlas* atlas(std::size_t index); }; -class SampleAtlasResolver : public FileAssetResolver { +class SampleAtlasResolver : public FileAssetResolver +{ private: SampleAtlasPacker* m_packer; std::unordered_map<uint32_t, rive::rcp<rive::SokolRenderImageResource>> m_sharedImageResources;
diff --git a/viewer/include/viewer/tess/bitmap_decoder.hpp b/viewer/include/viewer/tess/bitmap_decoder.hpp index 115c6da..0213a71 100644 --- a/viewer/include/viewer/tess/bitmap_decoder.hpp +++ b/viewer/include/viewer/tess/bitmap_decoder.hpp
@@ -5,9 +5,15 @@ #include "rive/span.hpp" /// Bitmap will always take ownership of the bytes it is constructed with. -class Bitmap { +class Bitmap +{ public: - enum class PixelFormat : uint8_t { R, RGB, RGBA }; + enum class PixelFormat : uint8_t + { + R, + RGB, + RGBA + }; Bitmap(uint32_t width, uint32_t height,
diff --git a/viewer/include/viewer/tess/viewer_sokol_factory.hpp b/viewer/include/viewer/tess/viewer_sokol_factory.hpp index cc4c811..e48517a 100644 --- a/viewer/include/viewer/tess/viewer_sokol_factory.hpp +++ b/viewer/include/viewer/tess/viewer_sokol_factory.hpp
@@ -3,7 +3,8 @@ #include "rive/tess/sokol/sokol_factory.hpp" -class ViewerSokolFactory : public rive::SokolFactory { +class ViewerSokolFactory : public rive::SokolFactory +{ public: std::unique_ptr<rive::RenderImage> decodeImage(rive::Span<const uint8_t>) override; };
diff --git a/viewer/include/viewer/viewer_content.hpp b/viewer/include/viewer/viewer_content.hpp index 229c670..e607929 100644 --- a/viewer/include/viewer/viewer_content.hpp +++ b/viewer/include/viewer/viewer_content.hpp
@@ -10,13 +10,15 @@ #include "imgui.h" -namespace rive { +namespace rive +{ class Renderer; class Factory; class RenderFont; } // namespace rive -class ViewerContent { +class ViewerContent +{ public: virtual ~ViewerContent(); @@ -31,15 +33,18 @@ using Factory = std::unique_ptr<ViewerContent> (*)(const char filename[]); // Searches all handlers and returns a content if it is found. - static std::unique_ptr<ViewerContent> findHandler(const char filename[]) { + static std::unique_ptr<ViewerContent> findHandler(const char filename[]) + { Factory factories[] = { Scene, Image, Text, TextPath, }; - for (auto f : factories) { - if (auto content = f(filename)) { + for (auto f : factories) + { + if (auto content = f(filename)) + { return content; } }
diff --git a/viewer/include/viewer/viewer_host.hpp b/viewer/include/viewer/viewer_host.hpp index cbf0ddc..bf64439 100644 --- a/viewer/include/viewer/viewer_host.hpp +++ b/viewer/include/viewer/viewer_host.hpp
@@ -13,7 +13,8 @@ class ViewerContent; -class ViewerHost { +class ViewerHost +{ public: virtual ~ViewerHost() {}
diff --git a/viewer/src/sample_tools/sample_atlas_packer.cpp b/viewer/src/sample_tools/sample_atlas_packer.cpp index cc06ffd..b9a6f88 100644 --- a/viewer/src/sample_tools/sample_atlas_packer.cpp +++ b/viewer/src/sample_tools/sample_atlas_packer.cpp
@@ -9,13 +9,15 @@ using namespace rive; -class AtlasRenderImage : public RenderImage { +class AtlasRenderImage : public RenderImage +{ private: std::vector<uint8_t> m_Pixels; public: AtlasRenderImage(const uint8_t* pixels, uint32_t width, uint32_t height) : - m_Pixels(pixels, pixels + (width * height * 4)) { + m_Pixels(pixels, pixels + (width * height * 4)) + { m_Width = width; m_Height = height; } @@ -23,14 +25,18 @@ Span<const uint8_t> pixels() { return m_Pixels; } }; -class AtlasPackerFactory : public NoOpFactory { - std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t> bytes) override { +class AtlasPackerFactory : public NoOpFactory +{ + std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t> bytes) override + { auto bitmap = Bitmap::decode(bytes); - if (bitmap) { + if (bitmap) + { // We have a bitmap, let's make an image. // For now only deal with RGBA. - if (bitmap->pixelFormat() != Bitmap::PixelFormat::RGBA) { + if (bitmap->pixelFormat() != Bitmap::PixelFormat::RGBA) + { bitmap->pixelFormat(Bitmap::PixelFormat::RGBA); } @@ -43,19 +49,25 @@ }; SampleAtlasPacker::SampleAtlasPacker(uint32_t maxWidth, uint32_t maxHeight) : - m_maxWidth(maxWidth), m_maxHeight(maxHeight) {} + m_maxWidth(maxWidth), m_maxHeight(maxHeight) +{} -void SampleAtlasPacker::pack(Span<const uint8_t> rivBytes) { +void SampleAtlasPacker::pack(Span<const uint8_t> rivBytes) +{ AtlasPackerFactory factory; - if (auto file = rive::File::import(rivBytes, &factory)) { - for (auto asset : file->assets()) { - if (asset->is<ImageAsset>()) { + if (auto file = rive::File::import(rivBytes, &factory)) + { + for (auto asset : file->assets()) + { + if (asset->is<ImageAsset>()) + { Mat2D uvTransform; auto imageAsset = asset->as<ImageAsset>(); auto renderImage = static_cast<AtlasRenderImage*>(imageAsset->renderImage()); - if (m_atlases.empty()) { + if (m_atlases.empty()) + { // Make the first atlas. m_atlases.push_back(new SampleAtlas(m_maxWidth, m_maxHeight)); } @@ -83,7 +95,9 @@ // Clean up unused next atlas. delete nextAtlas; - } else { + } + else + { m_atlases.push_back(nextAtlas); } } @@ -101,40 +115,51 @@ } } -SampleAtlasPacker::~SampleAtlasPacker() { - for (auto atlas : m_atlases) { +SampleAtlasPacker::~SampleAtlasPacker() +{ + for (auto atlas : m_atlases) + { delete atlas; } } -SampleAtlas* SampleAtlasPacker::atlas(std::size_t index) { +SampleAtlas* SampleAtlasPacker::atlas(std::size_t index) +{ assert(index < m_atlases.size()); return m_atlases[index]; } SampleAtlas::SampleAtlas(const uint8_t* pixels, uint32_t width, uint32_t height) : - m_width(width), m_height(height), m_pixels(pixels, pixels + width * height * 4) {} + m_width(width), m_height(height), m_pixels(pixels, pixels + width * height * 4) +{} SampleAtlas::SampleAtlas(uint32_t width, uint32_t height) : - m_width(width), m_height(height), m_pixels(width * height * 4) {} + m_width(width), m_height(height), m_pixels(width * height * 4) +{} bool SampleAtlas::pack(const uint8_t* sourcePixels, uint32_t width, uint32_t height, - Mat2D& packTransform) { - if (m_x + width >= m_width) { + Mat2D& packTransform) +{ + if (m_x + width >= m_width) + { m_x = 0; m_y = m_nextY; } // Check if we overflow vertically, we're done. - if (m_y + height >= m_height) { + if (m_y + height >= m_height) + { return false; } // We fit, pack into m_x, m_y. - for (uint32_t sy = 0; sy < height; sy++) { - for (uint32_t sx = 0; sx < width; sx++) { - for (uint8_t channel = 0; channel < 4; channel++) { + for (uint32_t sy = 0; sy < height; sy++) + { + for (uint32_t sx = 0; sx < width; sx++) + { + for (uint8_t channel = 0; channel < 4; channel++) + { m_pixels[((m_y + sy) * m_width + (m_x + sx)) * 4 + channel] = sourcePixels[(sy * width + sx) * 4 + channel]; } @@ -153,17 +178,20 @@ // Increment internal positions. m_x += width; - if (m_y + height > m_nextY) { + if (m_y + height > m_nextY) + { m_nextY = m_y + height; } return true; } -bool SampleAtlasPacker::find(const ImageAsset& asset, SampleAtlasLocation* location) { +bool SampleAtlasPacker::find(const ImageAsset& asset, SampleAtlasLocation* location) +{ auto assetId = asset.assetId(); auto result = m_lookup.find(assetId); - if (result != m_lookup.end()) { + if (result != m_lookup.end()) + { *location = result->second; return true; } @@ -172,20 +200,26 @@ SampleAtlasResolver::SampleAtlasResolver(SampleAtlasPacker* packer) : m_packer(packer) {} -void SampleAtlasResolver::loadContents(FileAsset& asset) { - if (asset.is<ImageAsset>()) { +void SampleAtlasResolver::loadContents(FileAsset& asset) +{ + if (asset.is<ImageAsset>()) + { SampleAtlasLocation location; auto imageAsset = asset.as<ImageAsset>(); // Find which location this image got packed into. - if (m_packer->find(*imageAsset, &location)) { + if (m_packer->find(*imageAsset, &location)) + { // Determine if we've already loaded the a render image. auto sharedItr = m_sharedImageResources.find(location.atlasIndex); rive::rcp<rive::SokolRenderImageResource> imageResource; - if (sharedItr != m_sharedImageResources.end()) { + if (sharedItr != m_sharedImageResources.end()) + { imageResource = sharedItr->second; - } else { + } + else + { auto atlas = m_packer->atlas(location.atlasIndex); imageResource = rive::rcp<rive::SokolRenderImageResource>( new SokolRenderImageResource(atlas->pixels().data(),
diff --git a/viewer/src/skia/skia_host.cpp b/viewer/src/skia/skia_host.cpp index e88e82e..2c44b6b 100644 --- a/viewer/src/skia/skia_host.cpp +++ b/viewer/src/skia/skia_host.cpp
@@ -35,7 +35,8 @@ #include "cg_factory.hpp" #include "cg_renderer.hpp" #include "mac_utils.hpp" -static void render_with_cg(SkCanvas* canvas, int w, int h, ViewerContent* content, double elapsed) { +static void render_with_cg(SkCanvas* canvas, int w, int h, ViewerContent* content, double elapsed) +{ // cons up a CGContext auto pixels = SkData::MakeUninitialized(w * h * 4); auto bytes = (uint8_t*)pixels->writable_data(); @@ -55,12 +56,14 @@ } #endif -class SkiaViewerHost : public ViewerHost { +class SkiaViewerHost : public ViewerHost +{ public: sk_sp<GrDirectContext> m_context; SkISize m_dimensions; - bool init(sg_pass_action* action, int width, int height) override { + bool init(sg_pass_action* action, int width, int height) override + { m_dimensions = {width, height}; #if defined(SK_METAL) @@ -86,7 +89,8 @@ void handleResize(int width, int height) override { m_dimensions = {width, height}; } - void beforeDefaultPass(ViewerContent* content, double elapsed) override { + void beforeDefaultPass(ViewerContent* content, double elapsed) override + { m_context->resetContext(); auto surf = makeSkiaSurface(m_context.get(), m_dimensions.width(), m_dimensions.height()); SkCanvas* canvas = surf->getCanvas(); @@ -94,7 +98,8 @@ paint.setColor(0xFF161616); canvas->drawPaint(paint); - if (content) { + if (content) + { #ifdef TEST_CG_RENDERER render_with_cg(canvas, m_dimensions.width(), m_dimensions.height(), content, elapsed); #elif defined(SW_SKIA_MODE) @@ -118,7 +123,8 @@ std::unique_ptr<ViewerHost> ViewerHost::Make() { return std::make_unique<SkiaViewerHost>(); } -rive::Factory* ViewerHost::Factory() { +rive::Factory* ViewerHost::Factory() +{ #ifdef TEST_CG_RENDERER static rive::CGFactory gFactory; return &gFactory;
diff --git a/viewer/src/skia/viewer_skia_gl.cpp b/viewer/src/skia/viewer_skia_gl.cpp index 3258fc9..b42a5ed 100644 --- a/viewer/src/skia/viewer_skia_gl.cpp +++ b/viewer/src/skia/viewer_skia_gl.cpp
@@ -7,7 +7,8 @@ sk_sp<GrDirectContext> makeSkiaContext() { return GrDirectContext::MakeGL(); } -sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height) { +sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height) +{ GrGLFramebufferInfo framebufferInfo; framebufferInfo.fFBOID = 0; framebufferInfo.fFormat = 0x8058; // GL_RGBA8;
diff --git a/viewer/src/stats.cpp b/viewer/src/stats.cpp index 4faf138..679f19f 100644 --- a/viewer/src/stats.cpp +++ b/viewer/src/stats.cpp
@@ -1,14 +1,16 @@ #include "sokol_app.h" #include "imgui.h" -void displayStats() { +void displayStats() +{ bool isOpen = true; ImGuiStyle& style = ImGui::GetStyle(); style.WindowBorderSize = 0.0f; ImGui::Begin("stats", &isOpen, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove); - if (ImGui::BeginTable("table2", 2)) { + if (ImGui::BeginTable("table2", 2)) + { ImGui::TableNextRow(); ImGui::TableNextColumn();
diff --git a/viewer/src/tess/bitmap_decoder.cpp b/viewer/src/tess/bitmap_decoder.cpp index 0168883..112f9d1 100644 --- a/viewer/src/tess/bitmap_decoder.cpp +++ b/viewer/src/tess/bitmap_decoder.cpp
@@ -6,20 +6,28 @@ uint32_t height, PixelFormat pixelFormat, std::unique_ptr<const uint8_t[]> bytes) : - m_Width(width), m_Height(height), m_PixelFormat(pixelFormat), m_Bytes(std::move(bytes)) {} + m_Width(width), m_Height(height), m_PixelFormat(pixelFormat), m_Bytes(std::move(bytes)) +{} Bitmap::Bitmap(uint32_t width, uint32_t height, PixelFormat pixelFormat, const uint8_t* bytes) : - Bitmap(width, height, pixelFormat, std::unique_ptr<const uint8_t[]>(bytes)) {} + Bitmap(width, height, pixelFormat, std::unique_ptr<const uint8_t[]>(bytes)) +{} -size_t Bitmap::bytesPerPixel(PixelFormat format) const { - switch (format) { - case PixelFormat::R: return 1; - case PixelFormat::RGB: return 3; - case PixelFormat::RGBA: return 4; +size_t Bitmap::bytesPerPixel(PixelFormat format) const +{ + switch (format) + { + case PixelFormat::R: + return 1; + case PixelFormat::RGB: + return 3; + case PixelFormat::RGBA: + return 4; } } -size_t Bitmap::byteSize(PixelFormat format) const { +size_t Bitmap::byteSize(PixelFormat format) const +{ return m_Width * m_Height * bytesPerPixel(format); } @@ -30,13 +38,15 @@ std::unique_ptr<Bitmap> DecodeWebP(rive::Span<const uint8_t> bytes) { return nullptr; } using BitmapDecoder = std::unique_ptr<Bitmap> (*)(rive::Span<const uint8_t> bytes); -struct ImageFormat { +struct ImageFormat +{ const char* name; std::vector<const uint8_t> fingerprint; BitmapDecoder decodeImage; }; -std::unique_ptr<Bitmap> Bitmap::decode(rive::Span<const uint8_t> bytes) { +std::unique_ptr<Bitmap> Bitmap::decode(rive::Span<const uint8_t> bytes) +{ static ImageFormat decoders[] = { { "png", @@ -55,23 +65,27 @@ }, }; - for (auto recognizer : decoders) { + for (auto recognizer : decoders) + { auto& fingerprint = recognizer.fingerprint; // Immediately discard decoders with fingerprints that are longer than // the file buffer. - if (recognizer.fingerprint.size() > bytes.size()) { + if (recognizer.fingerprint.size() > bytes.size()) + { continue; } // If the fingerprint doesn't match, discrd this decoder. These are all bytes so .size() is // fine here. - if (std::memcmp(fingerprint.data(), bytes.data(), fingerprint.size()) != 0) { + if (std::memcmp(fingerprint.data(), bytes.data(), fingerprint.size()) != 0) + { continue; } auto bitmap = recognizer.decodeImage(bytes); - if (!bitmap) { + if (!bitmap) + { fprintf(stderr, "Bitmap::decode - failed to decode a %s.\n", recognizer.name); } return bitmap; @@ -79,8 +93,10 @@ return nullptr; } -void Bitmap::pixelFormat(PixelFormat format) { - if (format == m_PixelFormat) { +void Bitmap::pixelFormat(PixelFormat format) +{ + if (format == m_PixelFormat) + { return; } auto nextByteSize = byteSize(format); @@ -90,8 +106,10 @@ auto toBytesPerPixel = bytesPerPixel(format); int writeIndex = 0; int readIndex = 0; - for (int i = 0; i < m_Width * m_Height; i++) { - for (int j = 0; j < toBytesPerPixel; j++) { + for (int i = 0; i < m_Width * m_Height; i++) + { + for (int j = 0; j < toBytesPerPixel; j++) + { nextBytes[writeIndex++] = j < fromBytesPerPixel ? m_Bytes[readIndex++] : 255; } }
diff --git a/viewer/src/tess/decode_png.cpp b/viewer/src/tess/decode_png.cpp index 65b4ae9..1a7a6b0 100644 --- a/viewer/src/tess/decode_png.cpp +++ b/viewer/src/tess/decode_png.cpp
@@ -2,17 +2,18 @@ #include "viewer/tess/bitmap_decoder.hpp" #include "png.h" -struct EncodedImageBuffer { +struct EncodedImageBuffer +{ const uint8_t* bytes; size_t position; size_t size; }; -static void ReadDataFromMemory(png_structp png_ptr, - png_bytep outBytes, - png_size_t byteCountToRead) { +static void ReadDataFromMemory(png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead) +{ png_voidp a = png_get_io_ptr(png_ptr); - if (a == nullptr) { + if (a == nullptr) + { return; } EncodedImageBuffer& stream = *(EncodedImageBuffer*)a; @@ -21,12 +22,14 @@ memcpy(outBytes, stream.bytes + stream.position, bytesRead); stream.position += bytesRead; - if ((png_size_t)bytesRead != byteCountToRead) { + if ((png_size_t)bytesRead != byteCountToRead) + { // Report image error? } } -std::unique_ptr<Bitmap> DecodePng(rive::Span<const uint8_t> bytes) { +std::unique_ptr<Bitmap> DecodePng(rive::Span<const uint8_t> bytes) +{ png_structp png_ptr; png_infop info_ptr; png_uint_32 width, height; @@ -34,13 +37,15 @@ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); - if (png_ptr == nullptr) { + if (png_ptr == nullptr) + { printf("DecodePng - libpng failed (png_create_read_struct)."); return nullptr; } info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) { + if (info_ptr == NULL) + { png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); printf("DecodePng - libpng failed (png_create_info_struct)."); return nullptr; @@ -69,21 +74,29 @@ png_set_strip_16(png_ptr); int bitDepth = 0; - if (color_type == PNG_COLOR_TYPE_PALETTE || color_type == PNG_COLOR_TYPE_RGB) { + if (color_type == PNG_COLOR_TYPE_PALETTE || color_type == PNG_COLOR_TYPE_RGB) + { png_set_expand(png_ptr); bitDepth = 24; - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) + { png_set_expand(png_ptr); bitDepth += 8; } - } else if (color_type == PNG_COLOR_TYPE_GRAY) { + } + else if (color_type == PNG_COLOR_TYPE_GRAY) + { png_set_expand(png_ptr); bitDepth = 8; - } else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + } + else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + { png_set_expand(png_ptr); png_set_gray_to_rgb(png_ptr); bitDepth = 32; - } else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) { + } + else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + { png_set_expand(png_ptr); bitDepth = 32; } @@ -93,7 +106,8 @@ png_bytep* row_pointers = new png_bytep[height]; - for (unsigned row = 0; row < height; row++) { + for (unsigned row = 0; row < height; row++) + { unsigned int rIndex = row; // if (flipY) { // rIndex = height - row - 1; @@ -109,10 +123,17 @@ Bitmap::PixelFormat pixelFormat; assert(bitDepth == 32 || bitDepth == 24 || bitDepth == 8); - switch (bitDepth) { - case 32: pixelFormat = Bitmap::PixelFormat::RGBA; break; - case 24: pixelFormat = Bitmap::PixelFormat::RGB; break; - case 8: pixelFormat = Bitmap::PixelFormat::R; break; + switch (bitDepth) + { + case 32: + pixelFormat = Bitmap::PixelFormat::RGBA; + break; + case 24: + pixelFormat = Bitmap::PixelFormat::RGB; + break; + case 8: + pixelFormat = Bitmap::PixelFormat::R; + break; } return std::make_unique<Bitmap>(width, height, pixelFormat, pixelBuffer); }
diff --git a/viewer/src/tess/tess_host.cpp b/viewer/src/tess/tess_host.cpp index 6767514..b25a345 100644 --- a/viewer/src/tess/tess_host.cpp +++ b/viewer/src/tess/tess_host.cpp
@@ -10,23 +10,28 @@ #include "rive/tess/sokol/sokol_tess_renderer.hpp" #include "viewer/tess/viewer_sokol_factory.hpp" -class TessViewerHost : public ViewerHost { +class TessViewerHost : public ViewerHost +{ public: std::unique_ptr<rive::SokolTessRenderer> m_renderer; - bool init(sg_pass_action*, int width, int height) override { + bool init(sg_pass_action*, int width, int height) override + { m_renderer = std::make_unique<rive::SokolTessRenderer>(); m_renderer->orthographicProjection(0.0f, width, height, 0.0f, 0.0f, 1.0f); return true; } - void handleResize(int width, int height) override { + void handleResize(int width, int height) override + { m_renderer->orthographicProjection(0.0f, width, height, 0.0f, 0.0f, 1.0f); } - void afterDefaultPass(ViewerContent* content, double elapsed) override { + void afterDefaultPass(ViewerContent* content, double elapsed) override + { m_renderer->reset(); - if (content) { + if (content) + { content->handleDraw(m_renderer.get(), elapsed); } } @@ -34,7 +39,8 @@ std::unique_ptr<ViewerHost> ViewerHost::Make() { return std::make_unique<TessViewerHost>(); } -rive::Factory* ViewerHost::Factory() { +rive::Factory* ViewerHost::Factory() +{ static ViewerSokolFactory sokolFactory; return &sokolFactory; }
diff --git a/viewer/src/tess/viewer_sokol_factory.cpp b/viewer/src/tess/viewer_sokol_factory.cpp index f36b4aa..bc0b6fb 100644 --- a/viewer/src/tess/viewer_sokol_factory.cpp +++ b/viewer/src/tess/viewer_sokol_factory.cpp
@@ -4,14 +4,16 @@ #include "rive/tess/sokol/sokol_tess_renderer.hpp" #include "sokol_gfx.h" -std::unique_ptr<rive::RenderImage> -ViewerSokolFactory::decodeImage(rive::Span<const uint8_t> bytes) { +std::unique_ptr<rive::RenderImage> ViewerSokolFactory::decodeImage(rive::Span<const uint8_t> bytes) +{ auto bitmap = Bitmap::decode(bytes); - if (bitmap) { + if (bitmap) + { // We have a bitmap, let's make an image. // For now our SokolRenderImage only works with RGBA. - if (bitmap->pixelFormat() != Bitmap::PixelFormat::RGBA) { + if (bitmap->pixelFormat() != Bitmap::PixelFormat::RGBA) + { bitmap->pixelFormat(Bitmap::PixelFormat::RGBA); }
diff --git a/viewer/src/viewer.cpp b/viewer/src/viewer.cpp index 5fc7bf1..fd62f51 100644 --- a/viewer/src/viewer.cpp +++ b/viewer/src/viewer.cpp
@@ -17,13 +17,17 @@ std::unique_ptr<ViewerHost> g_Host = ViewerHost::Make(); std::unique_ptr<ViewerContent> g_Content = ViewerContent::TrimPath(""); -static struct { sg_pass_action pass_action; } state; +static struct +{ + sg_pass_action pass_action; +} state; void displayStats(); static const int backgroundColor = rive::colorARGB(255, 22, 22, 22); -static void init(void) { +static void init(void) +{ sg_desc descriptor = { .context = sapp_sgcontext(), .buffer_pool_size = 1024, @@ -55,13 +59,15 @@ }, }; - if (!g_Host->init(&state.pass_action, sapp_width(), sapp_height())) { + if (!g_Host->init(&state.pass_action, sapp_width(), sapp_height())) + { fprintf(stderr, "failed to initialize host\n"); sapp_quit(); } } -static void frame(void) { +static void frame(void) +{ auto dur = sapp_frame_duration(); g_Host->beforeDefaultPass(g_Content.get(), dur); @@ -80,7 +86,8 @@ displayStats(); - if (g_Content) { + if (g_Content) + { g_Content->handleImgui(); } simgui_render(); @@ -89,7 +96,8 @@ sg_commit(); } -static void cleanup(void) { +static void cleanup(void) +{ g_Content = nullptr; g_Host = nullptr; @@ -97,29 +105,37 @@ sg_shutdown(); } -static void event(const sapp_event* ev) { +static void event(const sapp_event* ev) +{ simgui_handle_event(ev); - switch (ev->type) { + switch (ev->type) + { case SAPP_EVENTTYPE_RESIZED: - if (g_Content) { + if (g_Content) + { g_Content->handleResize(ev->framebuffer_width, ev->framebuffer_height); } g_Host->handleResize(ev->framebuffer_width, ev->framebuffer_height); break; - case SAPP_EVENTTYPE_FILES_DROPPED: { + case SAPP_EVENTTYPE_FILES_DROPPED: + { // Do this to make sure the graphics is bound. bindGraphicsContext(); // get the number of files and their paths like this: const int numDroppedFiles = sapp_get_num_dropped_files(); - if (numDroppedFiles != 0) { + if (numDroppedFiles != 0) + { const char* filename = sapp_get_dropped_file_path(numDroppedFiles - 1); auto newContent = ViewerContent::findHandler(filename); - if (newContent) { + if (newContent) + { g_Content = std::move(newContent); g_Content->handleResize(ev->framebuffer_width, ev->framebuffer_height); - } else { + } + else + { fprintf(stderr, "No handler found for %s\n", filename); } } @@ -127,39 +143,53 @@ } case SAPP_EVENTTYPE_MOUSE_DOWN: case SAPP_EVENTTYPE_TOUCHES_BEGAN: - if (g_Content) { + if (g_Content) + { g_Content->handlePointerDown(ev->mouse_x, ev->mouse_y); } break; case SAPP_EVENTTYPE_MOUSE_UP: case SAPP_EVENTTYPE_TOUCHES_ENDED: - if (g_Content) { + if (g_Content) + { g_Content->handlePointerUp(ev->mouse_x, ev->mouse_y); break; } case SAPP_EVENTTYPE_MOUSE_MOVE: case SAPP_EVENTTYPE_TOUCHES_MOVED: - if (g_Content) { + if (g_Content) + { g_Content->handlePointerMove(ev->mouse_x, ev->mouse_y); } break; case SAPP_EVENTTYPE_KEY_UP: - switch (ev->key_code) { - case SAPP_KEYCODE_ESCAPE: sapp_quit(); break; - case SAPP_KEYCODE_T: g_Content = ViewerContent::Text(".svg"); break; - case SAPP_KEYCODE_P: g_Content = ViewerContent::TextPath(""); break; - default: break; + switch (ev->key_code) + { + case SAPP_KEYCODE_ESCAPE: + sapp_quit(); + break; + case SAPP_KEYCODE_T: + g_Content = ViewerContent::Text(".svg"); + break; + case SAPP_KEYCODE_P: + g_Content = ViewerContent::TextPath(""); + break; + default: + break; } break; - default: break; + default: + break; } } -sapp_desc sokol_main(int argc, char* argv[]) { +sapp_desc sokol_main(int argc, char* argv[]) +{ (void)argc; (void)argv; - return (sapp_desc) { + return (sapp_desc) + { .init_cb = init, .frame_cb = frame, .cleanup_cb = cleanup, .event_cb = event, .enable_dragndrop = true, .high_dpi = true, .window_title = "Rive Viewer "
diff --git a/viewer/src/viewer_content/image_content.cpp b/viewer/src/viewer_content/image_content.cpp index e9a18f7..055c038 100644 --- a/viewer/src/viewer_content/image_content.cpp +++ b/viewer/src/viewer_content/image_content.cpp
@@ -6,13 +6,15 @@ #include "rive/factory.hpp" #include "rive/renderer.hpp" -class ImageContent : public ViewerContent { +class ImageContent : public ViewerContent +{ std::unique_ptr<rive::RenderImage> m_image; public: ImageContent(std::unique_ptr<rive::RenderImage> image) : m_image(std::move(image)) {} - void handleDraw(rive::Renderer* renderer, double) override { + void handleDraw(rive::Renderer* renderer, double) override + { renderer->drawImage(m_image.get(), rive::BlendMode::srcOver, 1); } @@ -20,10 +22,12 @@ void handleImgui() override {} }; -std::unique_ptr<ViewerContent> ViewerContent::Image(const char filename[]) { +std::unique_ptr<ViewerContent> ViewerContent::Image(const char filename[]) +{ auto bytes = LoadFile(filename); auto image = RiveFactory()->decodeImage(bytes); - if (image) { + if (image) + { return std::make_unique<ImageContent>(std::move(image)); } return nullptr;
diff --git a/viewer/src/viewer_content/scene_content.cpp b/viewer/src/viewer_content/scene_content.cpp index 6eab70d..6bd1129 100644 --- a/viewer/src/viewer_content/scene_content.cpp +++ b/viewer/src/viewer_content/scene_content.cpp
@@ -20,7 +20,8 @@ constexpr int REQUEST_DEFAULT_SCENE = -1; -class SceneContent : public ViewerContent { +class SceneContent : public ViewerContent +{ // ImGui wants raw pointers to names, but our public API returns // names as strings (by value), so we cache these names each time we // load a file @@ -28,26 +29,33 @@ std::vector<std::string> animationNames; std::vector<std::string> stateMachineNames; - void loadArtboardNames() { - if (m_File) { + void loadArtboardNames() + { + if (m_File) + { artboardNames.clear(); auto abCnt = m_File->artboardCount(); - for (int i = 0; i < abCnt; i++) { + for (int i = 0; i < abCnt; i++) + { auto abName = m_File->artboardNameAt(i); artboardNames.push_back(abName); } } } - void loadNames(const rive::Artboard* ab) { + void loadNames(const rive::Artboard* ab) + { animationNames.clear(); stateMachineNames.clear(); - if (ab) { - for (size_t i = 0; i < ab->animationCount(); ++i) { + if (ab) + { + for (size_t i = 0; i < ab->animationCount(); ++i) + { animationNames.push_back(ab->animationNameAt(i)); } - for (size_t i = 0; i < ab->stateMachineCount(); ++i) { + for (size_t i = 0; i < ab->stateMachineCount(); ++i) + { stateMachineNames.push_back(ab->stateMachineNameAt(i)); } } @@ -65,7 +73,8 @@ int m_width = 0, m_height = 0; rive::Mat2D m_InverseViewTransform; - void initArtboard(int index) { + void initArtboard(int index) + { if (!m_File) return; loadArtboardNames(); @@ -80,45 +89,53 @@ initStateMachine(REQUEST_DEFAULT_SCENE); } - void initStateMachine(int index) { + void initStateMachine(int index) + { m_StateMachineIndex = -1; m_AnimationIndex = -1; m_CurrentScene = nullptr; m_ArtboardInstance->advance(0.0f); - if (index < 0) { + if (index < 0) + { m_CurrentScene = m_ArtboardInstance->defaultStateMachine(); index = m_ArtboardInstance->defaultStateMachineIndex(); } - if (!m_CurrentScene) { - if (index >= m_ArtboardInstance->stateMachineCount()) { + if (!m_CurrentScene) + { + if (index >= m_ArtboardInstance->stateMachineCount()) + { index = 0; } m_CurrentScene = m_ArtboardInstance->stateMachineAt(index); } - if (!m_CurrentScene) { + if (!m_CurrentScene) + { index = -1; m_CurrentScene = m_ArtboardInstance->animationAt(0); m_AnimationIndex = 0; } m_StateMachineIndex = index; - if (m_CurrentScene) { + if (m_CurrentScene) + { m_CurrentScene->inputCount(); } DumpCounters("After loading file"); } - void initAnimation(int index) { + void initAnimation(int index) + { m_StateMachineIndex = -1; m_AnimationIndex = -1; m_CurrentScene = nullptr; m_ArtboardInstance->advance(0.0f); - if (index >= 0 && index < m_ArtboardInstance->animationCount()) { + if (index >= 0 && index < m_ArtboardInstance->animationCount()) + { m_AnimationIndex = index; m_CurrentScene = m_ArtboardInstance->animationAt(index); m_CurrentScene->inputCount(); @@ -129,37 +146,46 @@ public: SceneContent(const char filename[], std::unique_ptr<rive::File> file) : - m_Filename(filename), m_File(std::move(file)) { + m_Filename(filename), m_File(std::move(file)) + { initArtboard(REQUEST_DEFAULT_SCENE); } - void handlePointerMove(float x, float y) override { + void handlePointerMove(float x, float y) override + { auto pointer = m_InverseViewTransform * rive::Vec2D(x, y); - if (m_CurrentScene) { + if (m_CurrentScene) + { m_CurrentScene->pointerMove(pointer); } } - void handlePointerDown(float x, float y) override { + void handlePointerDown(float x, float y) override + { auto pointer = m_InverseViewTransform * rive::Vec2D(x, y); - if (m_CurrentScene) { + if (m_CurrentScene) + { m_CurrentScene->pointerDown(pointer); } } - void handlePointerUp(float x, float y) override { + void handlePointerUp(float x, float y) override + { auto pointer = m_InverseViewTransform * rive::Vec2D(x, y); - if (m_CurrentScene) { + if (m_CurrentScene) + { m_CurrentScene->pointerUp(pointer); } } - void handleResize(int width, int height) override { + void handleResize(int width, int height) override + { m_width = width; m_height = height; } - void handleDraw(rive::Renderer* renderer, double elapsed) override { + void handleDraw(rive::Renderer* renderer, double elapsed) override + { renderer->save(); auto viewTransform = rive::computeAlignment(rive::Fit::contain, @@ -170,23 +196,30 @@ // Store the inverse view so we can later go from screen to world. m_InverseViewTransform = viewTransform.invertOrIdentity(); - if (m_CurrentScene) { + if (m_CurrentScene) + { m_CurrentScene->advanceAndApply(elapsed); m_CurrentScene->draw(renderer); - } else { + } + else + { m_ArtboardInstance->draw(renderer); // we're just a still-frame file/artboard } renderer->restore(); } - void handleImgui() override { + void handleImgui() override + { // For now the atlas packer only works with tess as it compiles in our // Bitmap decoder. #ifdef RIVE_RENDERER_TESS - if (ImGui::BeginMainMenuBar()) { - if (ImGui::BeginMenu("Tools")) { - if (ImGui::MenuItem("Build Atlas")) { + if (ImGui::BeginMainMenuBar()) + { + if (ImGui::BeginMenu("Tools")) + { + if (ImGui::MenuItem("Build Atlas")) + { // Create an atlas packer. rive::SampleAtlasPacker atlasPacker(2048, 2048); @@ -211,7 +244,8 @@ auto strippedBytes = rive::File::stripAssets(rivFileBytes, {rive::ImageAsset::typeKey}, &stripResult); - if (stripResult != rive::ImportResult::success) { + if (stripResult != rive::ImportResult::success) + { printf("Failed to strip images\n"); return; } @@ -225,7 +259,8 @@ if (auto file = rive::File::import(strippedBytes, RiveFactory(), &loadAtlasedResult, - &resolver)) { + &resolver)) + { m_File = std::move(file); initArtboard(REQUEST_DEFAULT_SCENE); } @@ -235,7 +270,8 @@ ImGui::EndMainMenuBar(); } #endif - if (m_ArtboardInstance != nullptr) { + if (m_ArtboardInstance != nullptr) + { ImGui::Begin(m_Filename.c_str(), nullptr); if (ImGui::ListBox( "Artboard", @@ -281,15 +317,18 @@ m_AnimationIndex = -1; initStateMachine(m_StateMachineIndex); } - if (m_CurrentScene != nullptr) { + if (m_CurrentScene != nullptr) + { ImGui::Columns(2); ImGui::SetColumnWidth(0, ImGui::GetWindowWidth() * 0.6666); - for (int i = 0; i < m_CurrentScene->inputCount(); i++) { + for (int i = 0; i < m_CurrentScene->inputCount(); i++) + { auto inputInstance = m_CurrentScene->input(i); - if (inputInstance->input()->is<rive::StateMachineNumber>()) { + if (inputInstance->input()->is<rive::StateMachineNumber>()) + { // ImGui requires names as id's, use ## to hide the // label but still give it an id. char label[256]; @@ -300,17 +339,22 @@ ImGui::InputFloat(label, &v, 1.0f, 2.0f, "%.3f"); number->value(v); ImGui::NextColumn(); - } else if (inputInstance->input()->is<rive::StateMachineTrigger>()) { + } + else if (inputInstance->input()->is<rive::StateMachineTrigger>()) + { // ImGui requires names as id's, use ## to hide the // label but still give it an id. char label[256]; snprintf(label, 256, "Fire##%u", i); - if (ImGui::Button(label)) { + if (ImGui::Button(label)) + { auto trigger = static_cast<rive::SMITrigger*>(inputInstance); trigger->fire(); } ImGui::NextColumn(); - } else if (inputInstance->input()->is<rive::StateMachineBool>()) { + } + else if (inputInstance->input()->is<rive::StateMachineBool>()) + { // ImGui requires names as id's, use ## to hide the // label but still give it an id. char label[256]; @@ -329,16 +373,19 @@ ImGui::Columns(1); } ImGui::End(); - - } else { + } + else + { ImGui::Text("Drop a .riv file to preview."); } } }; -std::unique_ptr<ViewerContent> ViewerContent::Scene(const char filename[]) { +std::unique_ptr<ViewerContent> ViewerContent::Scene(const char filename[]) +{ auto bytes = LoadFile(filename); - if (auto file = rive::File::import(bytes, RiveFactory())) { + if (auto file = rive::File::import(bytes, RiveFactory())) + { return std::make_unique<SceneContent>(filename, std::move(file)); } return nullptr;
diff --git a/viewer/src/viewer_content/text_content.cpp b/viewer/src/viewer_content/text_content.cpp index 1897700..44e70f4 100644 --- a/viewer/src/viewer_content/text_content.cpp +++ b/viewer/src/viewer_content/text_content.cpp
@@ -17,18 +17,22 @@ static bool ws(rive::Unichar c) { return c <= ' '; } -std::vector<int> compute_word_breaks(rive::Span<rive::Unichar> chars) { +std::vector<int> compute_word_breaks(rive::Span<rive::Unichar> chars) +{ std::vector<int> breaks; const unsigned len = chars.size(); - for (unsigned i = 0; i < len;) { + for (unsigned i = 0; i < len;) + { // skip ws - while (i < len && ws(chars[i])) { + while (i < len && ws(chars[i])) + { ++i; } breaks.push_back(i); // word start // skip non-ws - while (i < len && !ws(chars[i])) { + while (i < len && !ws(chars[i])) + { ++i; } breaks.push_back(i); // word end @@ -42,14 +46,16 @@ const rive::RenderGlyphRun& run, unsigned startIndex, unsigned endIndex, - rive::Vec2D origin) { + rive::Vec2D origin) +{ auto font = run.font.get(); const auto scale = rive::Mat2D::fromScale(run.size, run.size); auto paint = factory->makeRenderPaint(); paint->color(0xFFFFFFFF); assert(startIndex >= 0 && endIndex <= run.glyphs.size()); - for (size_t i = startIndex; i < endIndex; ++i) { + for (size_t i = startIndex; i < endIndex; ++i) + { auto trans = rive::Mat2D::fromTranslate(origin.x + run.xpos[i], origin.y); auto rawpath = font->getPath(run.glyphs[i]); rawpath.transformInPlace(trans * scale); @@ -62,11 +68,14 @@ rive::Renderer* renderer, rive::Span<const rive::RenderGlyphLine> lines, rive::Span<const rive::RenderGlyphRun> runs, - rive::Vec2D origin) { - for (const auto& line : lines) { + rive::Vec2D origin) +{ + for (const auto& line : lines) + { const float x0 = runs[line.startRun].xpos[line.startIndex]; int startGIndex = line.startIndex; - for (int runIndex = line.startRun; runIndex <= line.endRun; ++runIndex) { + for (int runIndex = line.startRun; runIndex <= line.endRun; ++runIndex) + { const auto& run = runs[runIndex]; int endGIndex = runIndex == line.endRun ? line.endIndex : run.glyphs.size(); drawrun(factory, @@ -83,19 +92,23 @@ //////////////////////////////////////////////////////////////////////////////////// #ifdef RIVE_USING_HAFBUZZ_FONTS -static rive::rcp<rive::RenderFont> load_fallback_font(rive::Span<const rive::Unichar> missing) { +static rive::rcp<rive::RenderFont> load_fallback_font(rive::Span<const rive::Unichar> missing) +{ static rive::rcp<rive::RenderFont> gFallbackFont; printf("missing chars:"); - for (auto m : missing) { + for (auto m : missing) + { printf(" %X", m); } printf("\n"); - if (!gFallbackFont) { + if (!gFallbackFont) + { // TODO: make this more sharable for our test apps FILE* fp = fopen("/Users/mike/fonts/Arial Unicode.ttf", "rb"); - if (!fp) { + if (!fp) + { return nullptr; } @@ -116,14 +129,16 @@ static std::unique_ptr<rive::RenderPath> make_line(rive::Factory* factory, rive::Vec2D a, - rive::Vec2D b) { + rive::Vec2D b) +{ rive::RawPath rawPath; rawPath.move(a); rawPath.line(b); return factory->makeRenderPath(rawPath, rive::FillRule::nonZero); } -static void draw_line(rive::Factory* factory, rive::Renderer* renderer, float x) { +static void draw_line(rive::Factory* factory, rive::Renderer* renderer, float x) +{ auto paint = factory->makeRenderPaint(); paint->style(rive::RenderPaintStyle::stroke); paint->thickness(1); @@ -135,17 +150,20 @@ static rive::RenderTextRun append(std::vector<rive::Unichar>* unichars, rive::rcp<rive::RenderFont> font, float size, - const char text[]) { + const char text[]) +{ const uint8_t* ptr = (const uint8_t*)text; uint32_t n = 0; - while (*ptr) { + while (*ptr) + { unichars->push_back(rive::UTF::NextUTF8(&ptr)); n += 1; } return {std::move(font), size, n}; } -class TextContent : public ViewerContent { +class TextContent : public ViewerContent +{ std::vector<rive::Unichar> m_unichars; std::vector<int> m_breaks; @@ -155,10 +173,12 @@ bool m_autoWidth = false; int m_align = 0; - RenderFontTextRuns make_truns(RenderFontFactory fact) { + RenderFontTextRuns make_truns(RenderFontFactory fact) + { auto loader = [fact](const char filename[]) -> rive::rcp<rive::RenderFont> { auto bytes = ViewerContent::LoadFile(filename); - if (bytes.size() == 0) { + if (bytes.size() == 0) + { assert(false); return nullptr; } @@ -201,14 +221,16 @@ } public: - TextContent() { + TextContent() + { auto truns = this->make_truns(ViewerContent::DecodeFont); m_gruns.push_back(truns[0].font->shapeText(m_unichars, truns)); m_xform = rive::Mat2D::fromTranslate(10, 0) * rive::Mat2D::fromScale(3, 3); } - void draw(rive::Renderer* renderer, float width, const RenderFontGlyphRuns& gruns) { + void draw(rive::Renderer* renderer, float width, const RenderFontGlyphRuns& gruns) + { renderer->save(); renderer->transform(m_xform); @@ -217,22 +239,26 @@ (rive::RenderTextAlign)m_align); drawpara(RiveFactory(), renderer, lines, gruns, {0, 0}); - if (!m_autoWidth) { + if (!m_autoWidth) + { draw_line(RiveFactory(), renderer, width); } renderer->restore(); } - void handleDraw(rive::Renderer* renderer, double) override { - for (auto& grun : m_gruns) { + void handleDraw(rive::Renderer* renderer, double) override + { + for (auto& grun : m_gruns) + { this->draw(renderer, m_width, grun); renderer->translate(1200, 0); } } void handleResize(int width, int height) override {} - void handleImgui() override { + void handleImgui() override + { const char* alignOptions[] = {"left", "right", "center"}; ImGui::Begin("text", nullptr); ImGui::SliderFloat("Width", &m_width, 1, 400); @@ -242,22 +268,28 @@ } }; -static bool ends_width(const char str[], const char suffix[]) { +static bool ends_width(const char str[], const char suffix[]) +{ size_t ln = strlen(str); size_t lx = strlen(suffix); - if (lx > ln) { + if (lx > ln) + { return false; } - for (size_t i = 0; i < lx; ++i) { - if (str[ln - lx + i] != suffix[i]) { + for (size_t i = 0; i < lx; ++i) + { + if (str[ln - lx + i] != suffix[i]) + { return false; } } return true; } -std::unique_ptr<ViewerContent> ViewerContent::Text(const char filename[]) { - if (ends_width(filename, ".svg")) { +std::unique_ptr<ViewerContent> ViewerContent::Text(const char filename[]) +{ + if (ends_width(filename, ".svg")) + { return std::make_unique<TextContent>(); } return nullptr;
diff --git a/viewer/src/viewer_content/textpath_content.cpp b/viewer/src/viewer_content/textpath_content.cpp index 2870bbd..f511a63 100644 --- a/viewer/src/viewer_content/textpath_content.cpp +++ b/viewer/src/viewer_content/textpath_content.cpp
@@ -19,9 +19,12 @@ using RenderFontFactory = rcp<RenderFont> (*)(const Span<const uint8_t>); template <typename Handler> -void visit(const Span<RenderGlyphRun>& gruns, Vec2D origin, Handler proc) { - for (const auto& gr : gruns) { - for (size_t i = 0; i < gr.glyphs.size(); ++i) { +void visit(const Span<RenderGlyphRun>& gruns, Vec2D origin, Handler proc) +{ + for (const auto& gr : gruns) + { + for (size_t i = 0; i < gr.glyphs.size(); ++i) + { auto path = gr.font->getPath(gr.glyphs[i]); auto mx = Mat2D::fromTranslate(origin.x + gr.xpos[i], origin.y) * Mat2D::fromScale(gr.size, gr.size); @@ -33,17 +36,25 @@ static Vec2D ave(Vec2D a, Vec2D b) { return (a + b) * 0.5f; } -static RawPath make_quad_path(Span<const Vec2D> pts) { +static RawPath make_quad_path(Span<const Vec2D> pts) +{ const int N = pts.size(); RawPath path; - if (N >= 2) { + if (N >= 2) + { path.move(pts[0]); - if (N == 2) { + if (N == 2) + { path.line(pts[1]); - } else if (N == 3) { + } + else if (N == 3) + { path.quad(pts[1], pts[2]); - } else { - for (int i = 1; i < N - 2; ++i) { + } + else + { + for (int i = 1; i < N - 2; ++i) + { path.quad(pts[i], ave(pts[i], pts[i + 1])); } path.quad(pts[N - 2], pts[N - 1]); @@ -52,19 +63,23 @@ return path; } -static void warp_in_place(ContourMeasure* meas, RawPath* path) { - for (auto& pt : path->points()) { +static void warp_in_place(ContourMeasure* meas, RawPath* path) +{ + for (auto& pt : path->points()) + { pt = meas->warp(pt); } } //////////////////////////////////////////////////////////////////////////////////// -static std::unique_ptr<RenderPath> make_rpath(RawPath& path) { +static std::unique_ptr<RenderPath> make_rpath(RawPath& path) +{ return ViewerContent::RiveFactory()->makeRenderPath(path, FillRule::nonZero); } -static void stroke_path(Renderer* renderer, RawPath& path, float size, ColorInt color) { +static void stroke_path(Renderer* renderer, RawPath& path, float size, ColorInt color) +{ auto paint = ViewerContent::RiveFactory()->makeRenderPaint(); paint->color(color); paint->thickness(size); @@ -72,28 +87,33 @@ renderer->drawPath(make_rpath(path).get(), paint.get()); } -static void fill_rect(Renderer* renderer, const AABB& r, RenderPaint* paint) { +static void fill_rect(Renderer* renderer, const AABB& r, RenderPaint* paint) +{ RawPath rp; rp.addRect(r); renderer->drawPath(make_rpath(rp).get(), paint); } -static void fill_point(Renderer* renderer, Vec2D p, float r, RenderPaint* paint) { +static void fill_point(Renderer* renderer, Vec2D p, float r, RenderPaint* paint) +{ fill_rect(renderer, {p.x - r, p.y - r, p.x + r, p.y + r}, paint); } static RenderTextRun -append(std::vector<Unichar>* unichars, rcp<RenderFont> font, float size, const char text[]) { +append(std::vector<Unichar>* unichars, rcp<RenderFont> font, float size, const char text[]) +{ const uint8_t* ptr = (const uint8_t*)text; uint32_t n = 0; - while (*ptr) { + while (*ptr) + { unichars->push_back(rive::UTF::NextUTF8(&ptr)); n += 1; } return {std::move(font), size, n}; } -class TextPathContent : public ViewerContent { +class TextPathContent : public ViewerContent +{ std::vector<Unichar> m_unichars; RenderFontGlyphRuns m_gruns; std::unique_ptr<RenderPaint> m_paint; @@ -113,10 +133,12 @@ m_windowWidth = 1, // % m_windowOffset = 0; // % - RenderFontTextRuns make_truns(RenderFontFactory fact) { + RenderFontTextRuns make_truns(RenderFontFactory fact) + { auto loader = [fact](const char filename[]) -> rcp<RenderFont> { auto bytes = ViewerContent::LoadFile(filename); - if (bytes.size() == 0) { + if (bytes.size() == 0) + { assert(false); return nullptr; } @@ -147,10 +169,12 @@ } public: - TextPathContent() { + TextPathContent() + { auto compute_bounds = [](const rive::SimpleArray<RenderGlyphRun>& gruns) { AABB bounds = {}; - for (const auto& gr : gruns) { + for (const auto& gr : gruns) + { bounds.minY = std::min(bounds.minY, gr.font->lineMetrics().ascent * gr.size); bounds.maxY = std::max(bounds.maxY, gr.font->lineMetrics().descent * gr.size); } @@ -179,20 +203,24 @@ m_trans = Mat2D::fromTranslate(200, 200) * Mat2D::fromScale(2, 2); } - void draw_warp(Renderer* renderer, RawPath& warp) { + void draw_warp(Renderer* renderer, RawPath& warp) + { stroke_path(renderer, warp, 0.5, 0xFF00FF00); auto paint = ViewerContent::RiveFactory()->makeRenderPaint(); paint->color(0xFF008800); const float r = 4; - for (auto p : m_pathpts) { + for (auto p : m_pathpts) + { fill_point(renderer, p, r, paint.get()); } } - static size_t count_glyphs(const RenderFontGlyphRuns& gruns) { + static size_t count_glyphs(const RenderFontGlyphRuns& gruns) + { size_t n = 0; - for (const auto& gr : gruns) { + for (const auto& gr : gruns) + { n += gr.glyphs.size(); } return n; @@ -200,7 +228,8 @@ void modify(float amount) { m_paint->color(0xFFFFFFFF); } - void draw(Renderer* renderer, const RenderFontGlyphRuns& gruns) { + void draw(Renderer* renderer, const RenderFontGlyphRuns& gruns) + { auto get_path = [this](const RenderGlyphRun& run, int index, float dx) { auto path = run.font->getPath(run.glyphs[index]); path.transformInPlace(Mat2D::fromTranslate(run.xpos[index] + dx, m_offsetY) * @@ -224,15 +253,18 @@ size_t glyphIndex = 0; float windowEnd = m_windowOffset + m_windowWidth; - for (const auto& gr : gruns) { - for (size_t i = 0; i < gr.glyphs.size(); ++i) { + for (const auto& gr : gruns) + { + for (size_t i = 0; i < gr.glyphs.size(); ++i) + { float percent = glyphIndex / (float)(glyphCount - 1); float amount = (percent >= m_windowOffset && percent <= windowEnd); float scaleY = m_scaleY; m_paint->color(0xFF666666); m_paint->style(RenderPaintStyle::fill); - if (amount > 0) { + if (amount > 0) + { this->modify(amount); } @@ -246,11 +278,13 @@ renderer->restore(); } - void drawOneLine(Renderer* renderer) { + void drawOneLine(Renderer* renderer) + { auto paint = ViewerContent::RiveFactory()->makeRenderPaint(); paint->color(0xFF88FFFF); - if (m_trackingOneLine) { + if (m_trackingOneLine) + { float mx = m_oneLineX / m_gbounds.width(); const ColorInt colors[] = {0xFF88FFFF, 0xFF88FFFF, 0xFFFFFFFF, 0xFF88FFFF, 0xFF88FFFF}; const float stops[] = {0, mx / 2, mx, (1 + mx) / 2, 1}; @@ -263,12 +297,15 @@ 5)); } - struct EaseWindow { + struct EaseWindow + { float center, radius; - float map(float x) const { + float map(float x) const + { float dist = std::abs(center - x); - if (dist > radius) { + if (dist > radius) + { return 0; } float t = (radius - dist) / radius; @@ -289,7 +326,8 @@ visit(m_gruns, {0, 0}, [&](RawPath& rp) { RawPath* ptr = &rp; RawPath storage; - if (m_trackingOneLine) { + if (m_trackingOneLine) + { storage = wrap_path(rp, m_oneLineX, m_flareRadius); ptr = &storage; } @@ -297,7 +335,8 @@ }); } - void handleDraw(rive::Renderer* renderer, double) override { + void handleDraw(rive::Renderer* renderer, double) override + { renderer->save(); this->draw(renderer, m_gruns); renderer->restore(); @@ -308,7 +347,8 @@ renderer->restore(); } - void handlePointerMove(float x, float y) override { + void handlePointerMove(float x, float y) override + { auto contains = [](const AABB& r, Vec2D p) { return r.left() <= p.x && p.x < r.right() && r.top() <= p.y && p.y < r.bottom(); }; @@ -317,7 +357,8 @@ { m_trackingOneLine = false; auto pos = m_oneLineXform.invertOrIdentity() * Vec2D{x, y}; - if (contains(m_gbounds.inset(-8, 0), pos)) { + if (contains(m_gbounds.inset(-8, 0), pos)) + { m_trackingOneLine = true; m_oneLineX = pos.x; return; @@ -326,14 +367,18 @@ // are we on the path? m_lastPt = m_trans.invertOrIdentity() * Vec2D{x, y}; - if (m_trackingIndex >= 0) { + if (m_trackingIndex >= 0) + { m_pathpts[m_trackingIndex] = m_lastPt; } } - void handlePointerDown(float x, float y) override { + void handlePointerDown(float x, float y) override + { auto close_to = [](Vec2D a, Vec2D b) { return Vec2D::distance(a, b) <= 10; }; - for (size_t i = 0; i < m_pathpts.size(); ++i) { - if (close_to(m_lastPt, m_pathpts[i])) { + for (size_t i = 0; i < m_pathpts.size(); ++i) + { + if (close_to(m_lastPt, m_pathpts[i])) + { m_trackingIndex = i; break; } @@ -344,7 +389,8 @@ void handleResize(int width, int height) override {} - void handleImgui() override { + void handleImgui() override + { ImGui::Begin("path", nullptr); ImGui::SliderFloat("Alignment", &m_alignment, -3, 4); ImGui::SliderFloat("Scale Y", &m_scaleY, 0.25f, 3.0f); @@ -356,6 +402,7 @@ } }; -std::unique_ptr<ViewerContent> ViewerContent::TextPath(const char filename[]) { +std::unique_ptr<ViewerContent> ViewerContent::TextPath(const char filename[]) +{ return std::make_unique<TextPathContent>(); }
diff --git a/viewer/src/viewer_content/trimpath_content.cpp b/viewer/src/viewer_content/trimpath_content.cpp index 760bb9c..f72bd4a 100644 --- a/viewer/src/viewer_content/trimpath_content.cpp +++ b/viewer/src/viewer_content/trimpath_content.cpp
@@ -11,17 +11,25 @@ static Vec2D ave(Vec2D a, Vec2D b) { return (a + b) * 0.5f; } -static RawPath make_quad_path(Span<const Vec2D> pts) { +static RawPath make_quad_path(Span<const Vec2D> pts) +{ const int N = pts.size(); RawPath path; - if (N >= 2) { + if (N >= 2) + { path.move(pts[0]); - if (N == 2) { + if (N == 2) + { path.line(pts[1]); - } else if (N == 3) { + } + else if (N == 3) + { path.quad(pts[1], pts[2]); - } else { - for (int i = 1; i < N - 2; ++i) { + } + else + { + for (int i = 1; i < N - 2; ++i) + { path.quad(pts[i], ave(pts[i], pts[i + 1])); } path.quad(pts[N - 2], pts[N - 1]); @@ -32,11 +40,13 @@ //////////////////////////////////////////////////////////////////////////////////// -static std::unique_ptr<RenderPath> make_rpath(RawPath& path) { +static std::unique_ptr<RenderPath> make_rpath(RawPath& path) +{ return ViewerContent::RiveFactory()->makeRenderPath(path, FillRule::nonZero); } -static void stroke_path(Renderer* renderer, RawPath& path, float size, ColorInt color) { +static void stroke_path(Renderer* renderer, RawPath& path, float size, ColorInt color) +{ auto paint = ViewerContent::RiveFactory()->makeRenderPaint(); paint->color(color); paint->thickness(size); @@ -44,21 +54,25 @@ renderer->drawPath(make_rpath(path).get(), paint.get()); } -static void fill_rect(Renderer* renderer, const AABB& r, RenderPaint* paint) { +static void fill_rect(Renderer* renderer, const AABB& r, RenderPaint* paint) +{ RawPath rp; rp.addRect(r); renderer->drawPath(make_rpath(rp).get(), paint); } -static void fill_point(Renderer* renderer, Vec2D p, float r, RenderPaint* paint) { +static void fill_point(Renderer* renderer, Vec2D p, float r, RenderPaint* paint) +{ fill_rect(renderer, {p.x - r, p.y - r, p.x + r, p.y + r}, paint); } -static RawPath trim(ContourMeasure* cm, float startT, float endT) { +static RawPath trim(ContourMeasure* cm, float startT, float endT) +{ // start and end are 0...1 auto startD = startT * cm->length(); auto endD = endT * cm->length(); - if (startD > endD) { + if (startD > endD) + { std::swap(startD, endD); } @@ -67,14 +81,16 @@ return path; } -class TrimPathContent : public ViewerContent { +class TrimPathContent : public ViewerContent +{ std::vector<Vec2D> m_pathpts; int m_trackingIndex = -1; float m_trimFrom = 0, m_trimTo = 1; public: - TrimPathContent() { + TrimPathContent() + { m_pathpts.push_back({20, 300}); m_pathpts.push_back({220, 100}); m_pathpts.push_back({420, 500}); @@ -82,7 +98,8 @@ m_pathpts.push_back({820, 300}); } - void handleDraw(rive::Renderer* renderer, double) override { + void handleDraw(rive::Renderer* renderer, double) override + { auto path = make_quad_path(m_pathpts); RawPath cubicpath; @@ -93,7 +110,8 @@ RawPath* ps[] = {&path, &cubicpath}; renderer->save(); - for (auto p : ps) { + for (auto p : ps) + { renderer->save(); auto cm = ContourMeasureIter(*p, false).next(); @@ -110,21 +128,27 @@ auto paint = ViewerContent::RiveFactory()->makeRenderPaint(); paint->color(0xFF008800); const float r = 6; - for (auto p : m_pathpts) { + for (auto p : m_pathpts) + { fill_point(renderer, p, r, paint.get()); } } - void handlePointerMove(float x, float y) override { - if (m_trackingIndex >= 0) { + void handlePointerMove(float x, float y) override + { + if (m_trackingIndex >= 0) + { m_pathpts[m_trackingIndex] = Vec2D{x, y}; } } - void handlePointerDown(float x, float y) override { + void handlePointerDown(float x, float y) override + { auto pt = Vec2D{x, y}; auto close_to = [](Vec2D a, Vec2D b) { return Vec2D::distance(a, b) <= 10; }; - for (size_t i = 0; i < m_pathpts.size(); ++i) { - if (close_to(pt, m_pathpts[i])) { + for (size_t i = 0; i < m_pathpts.size(); ++i) + { + if (close_to(pt, m_pathpts[i])) + { m_trackingIndex = i; break; } @@ -135,7 +159,8 @@ void handleResize(int width, int height) override {} - void handleImgui() override { + void handleImgui() override + { ImGui::Begin("trim", nullptr); ImGui::SliderFloat("From", &m_trimFrom, 0, 1); ImGui::SliderFloat("To", &m_trimTo, 0, 1); @@ -143,6 +168,7 @@ } }; -std::unique_ptr<ViewerContent> ViewerContent::TrimPath(const char[]) { +std::unique_ptr<ViewerContent> ViewerContent::TrimPath(const char[]) +{ return std::make_unique<TrimPathContent>(); }
diff --git a/viewer/src/viewer_content/viewer_content.cpp b/viewer/src/viewer_content/viewer_content.cpp index 3ecc6fb..e60dfd2 100644 --- a/viewer/src/viewer_content/viewer_content.cpp +++ b/viewer/src/viewer_content/viewer_content.cpp
@@ -20,11 +20,13 @@ "image", }; -std::vector<uint8_t> ViewerContent::LoadFile(const char filename[]) { +std::vector<uint8_t> ViewerContent::LoadFile(const char filename[]) +{ std::vector<uint8_t> bytes; FILE* fp = fopen(filename, "rb"); - if (!fp) { + if (!fp) + { fprintf(stderr, "Can't find file: %s\n", filename); return bytes; } @@ -37,21 +39,25 @@ size_t bytesRead = fread(bytes.data(), 1, size, fp); fclose(fp); - if (bytesRead != size) { + if (bytesRead != size) + { fprintf(stderr, "Failed to read all of %s\n", filename); bytes.resize(0); } return bytes; } -void ViewerContent::DumpCounters(const char label[]) { +void ViewerContent::DumpCounters(const char label[]) +{ assert(sizeof(gCounterNames) / sizeof(gCounterNames[0]) == rive::Counter::kLastType + 1); - if (label == nullptr) { + if (label == nullptr) + { label = "Counters"; } printf("%s:", label); - for (int i = 0; i <= rive::Counter::kLastType; ++i) { + for (int i = 0; i <= rive::Counter::kLastType; ++i) + { printf(" [%s]:%d", gCounterNames[i], rive::Counter::counts[i]); } printf("\n"); @@ -64,12 +70,14 @@ #ifdef RIVE_BUILD_FOR_APPLE // note: we can use harfbuzz even on apple ... (if we want) #include "renderfont_coretext.hpp" -rive::rcp<rive::RenderFont> ViewerContent::DecodeFont(rive::Span<const uint8_t> span) { +rive::rcp<rive::RenderFont> ViewerContent::DecodeFont(rive::Span<const uint8_t> span) +{ return CoreTextRenderFont::Decode(span); } #else #include "renderfont_hb.hpp" -rive::rcp<rive::RenderFont> ViewerContent::DecodeFont(rive::Span<const uint8_t> span) { +rive::rcp<rive::RenderFont> ViewerContent::DecodeFont(rive::Span<const uint8_t> span) +{ return HBRenderFont::Decode(span); } #endif