-/*
- * Copyright 2022 Rive
- */
-
#ifndef _RIVE_SKIA_FACTORY_HPP_
#define _RIVE_SKIA_FACTORY_HPP_
#include "rive/factory.hpp"
-#include <vector>
namespace rive {
class SkiaFactory : public Factory {
-public:
rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override;
rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override;
rcp<RenderBuffer> makeBufferF32(Span<const float>) override;
- rcp<RenderShader> makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- rcp<RenderShader> makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
+ rcp<RenderShader> makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) override;
+
+ rcp<RenderShader> makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) override;
std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
+ Span<const uint8_t> verbs,
FillRule) override;
std::unique_ptr<RenderPath> makeEmptyRenderPath() override;
std::unique_ptr<RenderPaint> makeRenderPaint() override;
std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) override;
-
- //
- // New virtual for access the platform's codecs
- //
-
- enum class ColorType {
- rgba,
- bgra,
- };
- enum class AlphaType {
- premul,
- opaque,
- };
- struct ImageInfo {
- size_t rowBytes; // number of bytes between rows
- uint32_t width; // logical width in pixels
- uint32_t height; // logical height in pixels
- ColorType colorType;
- AlphaType alphaType;
- };
-
- // 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) {
- return std::vector<uint8_t>(); // empty vector means decode failed
- }
};
} // namespace rive
-#endif
+#endif
\ No newline at end of file
-/*
- * Copyright 2022 Rive
- */
-
#ifndef _RIVE_SKIA_RENDERER_HPP_
#define _RIVE_SKIA_RENDERER_HPP_
class SkCanvas;
namespace rive {
-class SkiaRenderer : public Renderer {
-protected:
- SkCanvas* m_Canvas;
+ class SkiaRenderer : public Renderer {
+ protected:
+ SkCanvas* m_Canvas;
-public:
- SkiaRenderer(SkCanvas* canvas) : m_Canvas(canvas) {}
- void save() override;
- void restore() override;
- void transform(const Mat2D& transform) override;
- void clipPath(RenderPath* path) override;
- void drawPath(RenderPath* path, RenderPaint* paint) override;
- void drawImage(const RenderImage*, BlendMode, float opacity) override;
- void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) override;
-};
+ public:
+ SkiaRenderer(SkCanvas* canvas) : m_Canvas(canvas) {}
+ void save() override;
+ void restore() override;
+ void transform(const Mat2D& transform) override;
+ void clipPath(RenderPath* path) override;
+ void drawPath(RenderPath* path, RenderPaint* paint) override;
+ void drawImage(const RenderImage*, BlendMode, float opacity) override;
+ void drawImageMesh(const RenderImage*,
+ rcp<RenderBuffer> vertices_f32,
+ rcp<RenderBuffer> uvCoords_f32,
+ rcp<RenderBuffer> indices_u16,
+ BlendMode,
+ float opacity) override;
+ };
} // namespace rive
-#endif
+#endif
\ No newline at end of file
-/*
- * Copyright 2022 Rive
- */
-
#ifndef _RIVE_TO_SKIA_HPP_
#define _RIVE_TO_SKIA_HPP_
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
-#include "include/core/SkPath.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkTileMode.h"
#include "rive/math/mat2d.hpp"
-#include "rive/math/raw_path.hpp"
#include "rive/math/vec2d.hpp"
#include "rive/renderer.hpp"
#include "rive/shapes/paint/stroke_cap.hpp"
#include "rive/shapes/paint/blend_mode.hpp"
namespace rive {
-class ToSkia {
-public:
- 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);
- }
+ class ToSkia {
+ public:
+ 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);
+ }
- static SkPoint convert(rive::Vec2D point) { return SkPoint::Make(point.x, point.y); }
+ static SkPoint convert(rive::Vec2D point) {
+ return SkPoint::Make(point.x, point.y);
+ }
+
+ // clang-format off
+ static SkTileMode convert(RenderTileMode rtm) {
+ switch (rtm) {
+ case RenderTileMode::clamp: return SkTileMode::kClamp;
+ case RenderTileMode::repeat: return SkTileMode::kRepeat;
+ case RenderTileMode::mirror: return SkTileMode::kMirror;
+ case RenderTileMode::decal: return SkTileMode::kDecal;
+ }
+ assert(false);
+ return SkTileMode::kClamp;
+ }
- // clang-format off
static SkPathFillType convert(FillRule value) {
switch (value) {
case FillRule::evenOdd: return SkPathFillType::kEvenOdd;
assert(false);
return SkBlendMode::kSrcOver;
}
-
- static SkPath convert(const RawPath& rp) {
- const auto pts = rp.points();
- const auto vbs = rp.verbsU8();
- return SkPath::Make((const SkPoint*)pts.data(), pts.size(),
- vbs.data(), vbs.size(),
- nullptr, 0, SkPathFillType::kWinding);
- }
// clang-format off
};
} // namespace rive
-#endif
+#endif
\ No newline at end of file
config_h.set10('USE_GL', true)
endif
-install_headers([
- 'submodule/rive-cpp/include/rive/artboard.hpp',
- 'submodule/rive-cpp/include/rive/backboard.hpp',
- 'submodule/rive-cpp/include/rive/command_path.hpp',
- 'submodule/rive-cpp/include/rive/component_dirt.hpp',
- 'submodule/rive-cpp/include/rive/component.hpp',
- 'submodule/rive-cpp/include/rive/container_component.hpp',
- 'submodule/rive-cpp/include/rive/core_context.hpp',
- 'submodule/rive-cpp/include/rive/core.hpp',
- 'submodule/rive-cpp/include/rive/dependency_sorter.hpp',
- 'submodule/rive-cpp/include/rive/draw_rules.hpp',
- 'submodule/rive-cpp/include/rive/draw_target_placement.hpp',
- 'submodule/rive-cpp/include/rive/draw_target.hpp',
- 'submodule/rive-cpp/include/rive/drawable.hpp',
- 'submodule/rive-cpp/include/rive/factory.hpp',
- 'submodule/rive-cpp/include/rive/file_asset_resolver.hpp',
- 'submodule/rive-cpp/include/rive/file.hpp',
- 'submodule/rive-cpp/include/rive/hit_info.hpp',
- 'submodule/rive-cpp/include/rive/hittest_command_path.hpp',
- 'submodule/rive-cpp/include/rive/layout.hpp',
- 'submodule/rive-cpp/include/rive/listener_type.hpp',
- 'submodule/rive-cpp/include/rive/nested_animation.hpp',
- 'submodule/rive-cpp/include/rive/nested_artboard.hpp',
- 'submodule/rive-cpp/include/rive/node.hpp',
- 'submodule/rive-cpp/include/rive/pointer_event.hpp',
- 'submodule/rive-cpp/include/rive/refcnt.hpp',
- 'submodule/rive-cpp/include/rive/relative_local_asset_resolver.hpp',
- 'submodule/rive-cpp/include/rive/render_text.hpp',
- 'submodule/rive-cpp/include/rive/renderer.hpp',
- 'submodule/rive-cpp/include/rive/rive_counter.hpp',
- 'submodule/rive-cpp/include/rive/rive_types.hpp',
- 'submodule/rive-cpp/include/rive/runtime_header.hpp',
- 'submodule/rive-cpp/include/rive/scene.hpp',
- 'submodule/rive-cpp/include/rive/span.hpp',
- 'submodule/rive-cpp/include/rive/status_code.hpp',
- 'submodule/rive-cpp/include/rive/transform_component.hpp',
- 'submodule/rive-cpp/include/rive/transform_space.hpp',
- 'submodule/rive-cpp/include/rive/world_transform_component.hpp',
-], subdir: 'rive')
install_headers([
'submodule/rive-cpp/include/rive/animation/animation_state_instance.hpp',
'submodule/rive-cpp/include/rive/animation/animation_state.hpp',
'submodule/rive-cpp/include/rive/animation/blend_state.hpp',
'submodule/rive-cpp/include/rive/animation/cubic_interpolator.hpp',
'submodule/rive-cpp/include/rive/animation/entry_state.hpp',
+ 'submodule/rive-cpp/include/rive/animation/event_bool_change.hpp',
+ 'submodule/rive-cpp/include/rive/animation/event_input_change.hpp',
+ 'submodule/rive-cpp/include/rive/animation/event_number_change.hpp',
+ 'submodule/rive-cpp/include/rive/animation/event_trigger_change.hpp',
'submodule/rive-cpp/include/rive/animation/exit_state.hpp',
'submodule/rive-cpp/include/rive/animation/keyed_object.hpp',
'submodule/rive-cpp/include/rive/animation/keyed_property.hpp',
'submodule/rive-cpp/include/rive/animation/layer_state.hpp',
'submodule/rive-cpp/include/rive/animation/linear_animation_instance.hpp',
'submodule/rive-cpp/include/rive/animation/linear_animation.hpp',
- 'submodule/rive-cpp/include/rive/animation/listener_action.hpp',
- 'submodule/rive-cpp/include/rive/animation/listener_align_target.hpp',
- 'submodule/rive-cpp/include/rive/animation/listener_bool_change.hpp',
- 'submodule/rive-cpp/include/rive/animation/listener_input_change.hpp',
- 'submodule/rive-cpp/include/rive/animation/listener_number_change.hpp',
- 'submodule/rive-cpp/include/rive/animation/listener_trigger_change.hpp',
'submodule/rive-cpp/include/rive/animation/loop.hpp',
- 'submodule/rive-cpp/include/rive/animation/nested_bool.hpp',
- 'submodule/rive-cpp/include/rive/animation/nested_input.hpp',
'submodule/rive-cpp/include/rive/animation/nested_linear_animation.hpp',
- 'submodule/rive-cpp/include/rive/animation/nested_number.hpp',
'submodule/rive-cpp/include/rive/animation/nested_remap_animation.hpp',
'submodule/rive-cpp/include/rive/animation/nested_simple_animation.hpp',
'submodule/rive-cpp/include/rive/animation/nested_state_machine.hpp',
- 'submodule/rive-cpp/include/rive/animation/nested_trigger.hpp',
'submodule/rive-cpp/include/rive/animation/state_instance.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_bool.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_component.hpp',
+ 'submodule/rive-cpp/include/rive/animation/state_machine_event.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_input_instance.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_input.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_instance.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_layer_component.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_layer.hpp',
- 'submodule/rive-cpp/include/rive/animation/state_machine_listener.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_number.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine_trigger.hpp',
'submodule/rive-cpp/include/rive/animation/state_machine.hpp',
'submodule/rive-cpp/include/rive/core/field_types/core_string_type.hpp',
'submodule/rive-cpp/include/rive/core/field_types/core_uint_type.hpp',
], subdir: 'rive/core/field_types')
-install_headers([
- 'submodule/rive-cpp/include/rive/generated/artboard_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/backboard_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/component_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/container_component_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/core_registry.hpp',
- 'submodule/rive-cpp/include/rive/generated/draw_rules_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/draw_target_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/drawable_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/nested_animation_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/nested_artboard_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/node_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/transform_component_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/world_transform_component_base.hpp',
-], subdir: 'rive/generated')
install_headers([
'submodule/rive-cpp/include/rive/generated/animation/animation_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/animation_state_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/blend_state_transition_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/cubic_interpolator_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/entry_state_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/animation/event_bool_change_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/animation/event_input_change_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/animation/event_number_change_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/animation/event_trigger_change_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/exit_state_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/keyed_object_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/keyed_property_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/keyframe_id_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/layer_state_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/linear_animation_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/listener_action_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/listener_align_target_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/listener_bool_change_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/listener_input_change_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/listener_number_change_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/listener_trigger_change_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/nested_bool_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/nested_input_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/nested_linear_animation_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/nested_number_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/nested_remap_animation_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/nested_simple_animation_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/nested_state_machine_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/nested_trigger_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_bool_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_component_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/animation/state_machine_event_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_input_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_layer_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_layer_component_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/animation/state_machine_listener_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_number_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_machine_trigger_base.hpp',
'submodule/rive-cpp/include/rive/generated/animation/state_transition_base.hpp',
'submodule/rive-cpp/include/rive/generated/constraints/transform_space_constraint_base.hpp',
'submodule/rive-cpp/include/rive/generated/constraints/translation_constraint_base.hpp',
], subdir: 'rive/generated/constraints')
+install_headers([
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/fill_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/gradient_stop_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/linear_gradient_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/radial_gradient_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/shape_paint_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/solid_color_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/stroke_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/shapes/paint/trim_path_base.hpp',
+], subdir: 'rive/generated/shapes/paint')
install_headers([
'submodule/rive-cpp/include/rive/generated/shapes/clipping_shape_base.hpp',
'submodule/rive-cpp/include/rive/generated/shapes/contour_mesh_vertex_base.hpp',
'submodule/rive-cpp/include/rive/generated/shapes/vertex_base.hpp',
], subdir: 'rive/generated/shapes')
install_headers([
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/fill_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/gradient_stop_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/linear_gradient_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/radial_gradient_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/shape_paint_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/solid_color_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/stroke_base.hpp',
- 'submodule/rive-cpp/include/rive/generated/shapes/paint/trim_path_base.hpp',
-], subdir: 'rive/generated/shapes/paint')
+ 'submodule/rive-cpp/include/rive/generated/artboard_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/backboard_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/component_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/container_component_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/core_registry.hpp',
+ 'submodule/rive-cpp/include/rive/generated/draw_rules_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/draw_target_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/drawable_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/nested_animation_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/nested_artboard_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/node_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/transform_component_base.hpp',
+ 'submodule/rive-cpp/include/rive/generated/world_transform_component_base.hpp',
+], subdir: 'rive/generated')
install_headers([
'submodule/rive-cpp/include/rive/importers/artboard_importer.hpp',
'submodule/rive-cpp/include/rive/importers/backboard_importer.hpp',
'submodule/rive-cpp/include/rive/importers/keyed_property_importer.hpp',
'submodule/rive-cpp/include/rive/importers/layer_state_importer.hpp',
'submodule/rive-cpp/include/rive/importers/linear_animation_importer.hpp',
+ 'submodule/rive-cpp/include/rive/importers/state_machine_event_importer.hpp',
'submodule/rive-cpp/include/rive/importers/state_machine_importer.hpp',
'submodule/rive-cpp/include/rive/importers/state_machine_layer_importer.hpp',
- 'submodule/rive-cpp/include/rive/importers/state_machine_listener_importer.hpp',
'submodule/rive-cpp/include/rive/importers/state_transition_importer.hpp',
], subdir: 'rive/importers')
install_headers([
'submodule/rive-cpp/include/rive/math/aabb.hpp',
'submodule/rive-cpp/include/rive/math/circle_constant.hpp',
- 'submodule/rive-cpp/include/rive/math/contour_measure.hpp',
- 'submodule/rive-cpp/include/rive/math/cubic_utilities.hpp',
+ 'submodule/rive-cpp/include/rive/math/color.hpp',
'submodule/rive-cpp/include/rive/math/hit_test.hpp',
'submodule/rive-cpp/include/rive/math/mat2d.hpp',
'submodule/rive-cpp/include/rive/math/math_types.hpp',
'submodule/rive-cpp/include/rive/math/path_types.hpp',
- 'submodule/rive-cpp/include/rive/math/raw_path_utils.hpp',
'submodule/rive-cpp/include/rive/math/raw_path.hpp',
'submodule/rive-cpp/include/rive/math/transform_components.hpp',
'submodule/rive-cpp/include/rive/math/vec2d.hpp',
'submodule/rive-cpp/include/rive/shapes/paint/trim_path.hpp',
], subdir: 'rive/shapes/paint')
install_headers([
- 'submodule/rive-cpp/include/rive/text/line_breaker.hpp',
-], subdir: 'rive/text')
-install_headers([
- 'submodule/rive-cpp/include/utils/factory_utils.hpp',
- 'submodule/rive-cpp/include/utils/no_op_factory.hpp',
- 'submodule/rive-cpp/include/utils/no_op_renderer.hpp',
- 'submodule/rive-cpp/include/utils/rive_utf.hpp',
-], subdir: 'rive/utils')
+ 'submodule/rive-cpp/include/rive/artboard.hpp',
+ 'submodule/rive-cpp/include/rive/backboard.hpp',
+ 'submodule/rive-cpp/include/rive/command_path.hpp',
+ 'submodule/rive-cpp/include/rive/component_dirt.hpp',
+ 'submodule/rive-cpp/include/rive/component.hpp',
+ 'submodule/rive-cpp/include/rive/container_component.hpp',
+ 'submodule/rive-cpp/include/rive/core_context.hpp',
+ 'submodule/rive-cpp/include/rive/core.hpp',
+ 'submodule/rive-cpp/include/rive/dependency_sorter.hpp',
+ 'submodule/rive-cpp/include/rive/draw_rules.hpp',
+ 'submodule/rive-cpp/include/rive/draw_target_placement.hpp',
+ 'submodule/rive-cpp/include/rive/draw_target.hpp',
+ 'submodule/rive-cpp/include/rive/drawable.hpp',
+ 'submodule/rive-cpp/include/rive/event_type.hpp',
+ 'submodule/rive-cpp/include/rive/factory.hpp',
+ 'submodule/rive-cpp/include/rive/file_asset_resolver.hpp',
+ 'submodule/rive-cpp/include/rive/file.hpp',
+ 'submodule/rive-cpp/include/rive/hit_info.hpp',
+ 'submodule/rive-cpp/include/rive/hittest_command_path.hpp',
+ 'submodule/rive-cpp/include/rive/layout.hpp',
+ 'submodule/rive-cpp/include/rive/nested_animation.hpp',
+ 'submodule/rive-cpp/include/rive/nested_artboard.hpp',
+ 'submodule/rive-cpp/include/rive/node.hpp',
+ 'submodule/rive-cpp/include/rive/pointer_event.hpp',
+ 'submodule/rive-cpp/include/rive/refcnt.hpp',
+ 'submodule/rive-cpp/include/rive/relative_local_asset_resolver.hpp',
+ 'submodule/rive-cpp/include/rive/renderer.hpp',
+ 'submodule/rive-cpp/include/rive/rive_types.hpp',
+ 'submodule/rive-cpp/include/rive/runtime_header.hpp',
+ 'submodule/rive-cpp/include/rive/scene.hpp',
+ 'submodule/rive-cpp/include/rive/span.hpp',
+ 'submodule/rive-cpp/include/rive/status_code.hpp',
+ 'submodule/rive-cpp/include/rive/transform_component.hpp',
+ 'submodule/rive-cpp/include/rive/transform_space.hpp',
+ 'submodule/rive-cpp/include/rive/world_transform_component.hpp',
+], subdir: 'rive')
install_headers([
'submodule/skia/include/core/SkCanvas.h',
], subdir: 'skia/gpu/gl')
rive_cpp_src = [
- 'submodule/rive-cpp/src/draw_target.cpp',
- 'submodule/rive-cpp/src/assets/file_asset_contents.cpp',
- 'submodule/rive-cpp/src/assets/file_asset.cpp',
- 'submodule/rive-cpp/src/assets/image_asset.cpp',
- 'submodule/rive-cpp/src/core/binary_reader.cpp',
- 'submodule/rive-cpp/src/core/field_types/core_color_type.cpp',
- 'submodule/rive-cpp/src/core/field_types/core_string_type.cpp',
- 'submodule/rive-cpp/src/core/field_types/core_double_type.cpp',
- 'submodule/rive-cpp/src/core/field_types/core_uint_type.cpp',
- 'submodule/rive-cpp/src/core/field_types/core_bool_type.cpp',
- 'submodule/rive-cpp/src/core/field_types/core_bytes_type.cpp',
- 'submodule/rive-cpp/src/scene.cpp',
- 'submodule/rive-cpp/src/factory.cpp',
- 'submodule/rive-cpp/src/importers/state_machine_listener_importer.cpp',
- 'submodule/rive-cpp/src/importers/artboard_importer.cpp',
- 'submodule/rive-cpp/src/importers/state_transition_importer.cpp',
- 'submodule/rive-cpp/src/importers/layer_state_importer.cpp',
- 'submodule/rive-cpp/src/importers/keyed_object_importer.cpp',
- 'submodule/rive-cpp/src/importers/file_asset_importer.cpp',
- 'submodule/rive-cpp/src/importers/state_machine_layer_importer.cpp',
- 'submodule/rive-cpp/src/importers/keyed_property_importer.cpp',
- 'submodule/rive-cpp/src/importers/state_machine_importer.cpp',
- 'submodule/rive-cpp/src/importers/linear_animation_importer.cpp',
- 'submodule/rive-cpp/src/importers/backboard_importer.cpp',
- 'submodule/rive-cpp/src/file.cpp',
- 'submodule/rive-cpp/src/artboard.cpp',
- 'submodule/rive-cpp/src/draw_rules.cpp',
- 'submodule/rive-cpp/src/animation/listener_align_target.cpp',
- 'submodule/rive-cpp/src/animation/transition_bool_condition.cpp',
- 'submodule/rive-cpp/src/animation/blend_animation_direct.cpp',
- 'submodule/rive-cpp/src/animation/transition_number_condition.cpp',
- 'submodule/rive-cpp/src/animation/state_machine_layer.cpp',
- 'submodule/rive-cpp/src/animation/animation_state.cpp',
- 'submodule/rive-cpp/src/animation/state_machine_input_instance.cpp',
- 'submodule/rive-cpp/src/animation/state_machine.cpp',
- 'submodule/rive-cpp/src/animation/keyed_object.cpp',
- 'submodule/rive-cpp/src/animation/state_transition.cpp',
'submodule/rive-cpp/src/animation/animation_state_instance.cpp',
- 'submodule/rive-cpp/src/animation/linear_animation_instance.cpp',
- 'submodule/rive-cpp/src/animation/blend_state_transition.cpp',
- 'submodule/rive-cpp/src/animation/blend_state_direct.cpp',
- 'submodule/rive-cpp/src/animation/transition_condition.cpp',
+ 'submodule/rive-cpp/src/animation/animation_state.cpp',
'submodule/rive-cpp/src/animation/blend_animation_1d.cpp',
+ 'submodule/rive-cpp/src/animation/blend_animation_direct.cpp',
'submodule/rive-cpp/src/animation/blend_animation.cpp',
- 'submodule/rive-cpp/src/animation/state_instance.cpp',
- 'submodule/rive-cpp/src/animation/listener_action.cpp',
- 'submodule/rive-cpp/src/animation/nested_state_machine.cpp',
- 'submodule/rive-cpp/src/animation/listener_number_change.cpp',
- 'submodule/rive-cpp/src/animation/blend_state.cpp',
- 'submodule/rive-cpp/src/animation/state_machine_input.cpp',
- 'submodule/rive-cpp/src/animation/linear_animation.cpp',
- 'submodule/rive-cpp/src/animation/listener_trigger_change.cpp',
- 'submodule/rive-cpp/src/animation/system_state_instance.cpp',
- 'submodule/rive-cpp/src/animation/keyframe_id.cpp',
- 'submodule/rive-cpp/src/animation/keyframe_color.cpp',
+ 'submodule/rive-cpp/src/animation/blend_state_1d_instance.cpp',
+ 'submodule/rive-cpp/src/animation/blend_state_1d.cpp',
'submodule/rive-cpp/src/animation/blend_state_direct_instance.cpp',
- 'submodule/rive-cpp/src/animation/listener_input_change.cpp',
- 'submodule/rive-cpp/src/animation/transition_trigger_condition.cpp',
- 'submodule/rive-cpp/src/animation/nested_remap_animation.cpp',
- 'submodule/rive-cpp/src/animation/listener_bool_change.cpp',
- 'submodule/rive-cpp/src/animation/state_machine_instance.cpp',
- 'submodule/rive-cpp/src/animation/keyframe.cpp',
- 'submodule/rive-cpp/src/animation/keyframe_double.cpp',
+ 'submodule/rive-cpp/src/animation/blend_state_direct.cpp',
+ 'submodule/rive-cpp/src/animation/blend_state_transition.cpp',
+ 'submodule/rive-cpp/src/animation/blend_state.cpp',
'submodule/rive-cpp/src/animation/cubic_interpolator.cpp',
- 'submodule/rive-cpp/src/animation/blend_state_1d.cpp',
- 'submodule/rive-cpp/src/animation/nested_simple_animation.cpp',
- 'submodule/rive-cpp/src/animation/state_machine_listener.cpp',
+ 'submodule/rive-cpp/src/animation/event_bool_change.cpp',
+ 'submodule/rive-cpp/src/animation/event_input_change.cpp',
+ 'submodule/rive-cpp/src/animation/event_number_change.cpp',
+ 'submodule/rive-cpp/src/animation/event_trigger_change.cpp',
+ 'submodule/rive-cpp/src/animation/keyed_object.cpp',
'submodule/rive-cpp/src/animation/keyed_property.cpp',
- 'submodule/rive-cpp/src/animation/layer_state.cpp',
'submodule/rive-cpp/src/animation/keyframe_bool.cpp',
- 'submodule/rive-cpp/src/animation/blend_state_1d_instance.cpp',
- 'submodule/rive-cpp/src/animation/nested_linear_animation.cpp',
+ 'submodule/rive-cpp/src/animation/keyframe_color.cpp',
+ 'submodule/rive-cpp/src/animation/keyframe_double.cpp',
+ 'submodule/rive-cpp/src/animation/keyframe_id.cpp',
+ 'submodule/rive-cpp/src/animation/keyframe.cpp',
+ 'submodule/rive-cpp/src/animation/layer_state.cpp',
+ 'submodule/rive-cpp/src/animation/linear_animation_instance.cpp',
+ 'submodule/rive-cpp/src/animation/linear_animation.cpp',
'submodule/rive-cpp/src/animation/nested_animation.cpp',
- 'submodule/rive-cpp/src/rive_counter.cpp',
- 'submodule/rive-cpp/src/hittest_command_path.cpp',
- 'submodule/rive-cpp/src/drawable.cpp',
- 'submodule/rive-cpp/src/dependency_sorter.cpp',
- 'submodule/rive-cpp/src/layout.cpp',
- 'submodule/rive-cpp/src/shapes/paint/stroke.cpp',
- 'submodule/rive-cpp/src/shapes/paint/radial_gradient.cpp',
- 'submodule/rive-cpp/src/shapes/paint/shape_paint.cpp',
- 'submodule/rive-cpp/src/shapes/paint/trim_path.cpp',
- 'submodule/rive-cpp/src/shapes/paint/gradient_stop.cpp',
- 'submodule/rive-cpp/src/shapes/paint/linear_gradient.cpp',
- 'submodule/rive-cpp/src/shapes/paint/color.cpp',
- 'submodule/rive-cpp/src/shapes/paint/fill.cpp',
- 'submodule/rive-cpp/src/shapes/paint/shape_paint_mutator.cpp',
- 'submodule/rive-cpp/src/shapes/paint/solid_color.cpp',
- 'submodule/rive-cpp/src/shapes/mesh.cpp',
- 'submodule/rive-cpp/src/shapes/cubic_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/parametric_path.cpp',
- 'submodule/rive-cpp/src/shapes/mesh_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/path_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/rectangle.cpp',
- 'submodule/rive-cpp/src/shapes/cubic_mirrored_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/triangle.cpp',
- 'submodule/rive-cpp/src/shapes/cubic_asymmetric_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/image.cpp',
- 'submodule/rive-cpp/src/shapes/polygon.cpp',
- 'submodule/rive-cpp/src/shapes/straight_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/cubic_detached_vertex.cpp',
- 'submodule/rive-cpp/src/shapes/path.cpp',
- 'submodule/rive-cpp/src/shapes/shape.cpp',
- 'submodule/rive-cpp/src/shapes/path_composer.cpp',
- 'submodule/rive-cpp/src/shapes/star.cpp',
- 'submodule/rive-cpp/src/shapes/clipping_shape.cpp',
- 'submodule/rive-cpp/src/shapes/metrics_path.cpp',
- 'submodule/rive-cpp/src/shapes/points_path.cpp',
- 'submodule/rive-cpp/src/shapes/ellipse.cpp',
- 'submodule/rive-cpp/src/shapes/shape_paint_container.cpp',
- 'submodule/rive-cpp/src/shapes/vertex.cpp',
- 'submodule/rive-cpp/src/text/line_breaker.cpp',
- 'submodule/rive-cpp/src/nested_artboard.cpp',
+ 'submodule/rive-cpp/src/animation/nested_linear_animation.cpp',
+ 'submodule/rive-cpp/src/animation/nested_remap_animation.cpp',
+ 'submodule/rive-cpp/src/animation/nested_simple_animation.cpp',
+ 'submodule/rive-cpp/src/animation/nested_state_machine.cpp',
+ 'submodule/rive-cpp/src/animation/state_instance.cpp',
+ 'submodule/rive-cpp/src/animation/state_machine_event.cpp',
+ 'submodule/rive-cpp/src/animation/state_machine_input_instance.cpp',
+ 'submodule/rive-cpp/src/animation/state_machine_input.cpp',
+ 'submodule/rive-cpp/src/animation/state_machine_instance.cpp',
+ 'submodule/rive-cpp/src/animation/state_machine_layer.cpp',
+ 'submodule/rive-cpp/src/animation/state_machine.cpp',
+ 'submodule/rive-cpp/src/animation/state_transition.cpp',
+ 'submodule/rive-cpp/src/animation/system_state_instance.cpp',
+ 'submodule/rive-cpp/src/animation/transition_bool_condition.cpp',
+ 'submodule/rive-cpp/src/animation/transition_condition.cpp',
+ 'submodule/rive-cpp/src/animation/transition_number_condition.cpp',
+ 'submodule/rive-cpp/src/animation/transition_trigger_condition.cpp',
+ 'submodule/rive-cpp/src/artboard.cpp',
+ 'submodule/rive-cpp/src/assets/file_asset_contents.cpp',
+ 'submodule/rive-cpp/src/assets/file_asset.cpp',
+ 'submodule/rive-cpp/src/assets/image_asset.cpp',
+ 'submodule/rive-cpp/src/bones/bone.cpp',
+ 'submodule/rive-cpp/src/bones/root_bone.cpp',
+ 'submodule/rive-cpp/src/bones/skin.cpp',
+ 'submodule/rive-cpp/src/bones/skinnable.cpp',
+ 'submodule/rive-cpp/src/bones/tendon.cpp',
+ 'submodule/rive-cpp/src/bones/weight.cpp',
'submodule/rive-cpp/src/component.cpp',
- 'submodule/rive-cpp/src/node.cpp',
- 'submodule/rive-cpp/src/math/hit_test.cpp',
- 'submodule/rive-cpp/src/math/contour_measure.cpp',
- 'submodule/rive-cpp/src/math/aabb.cpp',
- 'submodule/rive-cpp/src/math/raw_path.cpp',
- 'submodule/rive-cpp/src/math/vec2d.cpp',
- 'submodule/rive-cpp/src/math/raw_path_utils.cpp',
- 'submodule/rive-cpp/src/math/mat2d.cpp',
- 'submodule/rive-cpp/src/generated/assets/folder_base.cpp',
- 'submodule/rive-cpp/src/generated/assets/file_asset_contents_base.cpp',
- 'submodule/rive-cpp/src/generated/assets/image_asset_base.cpp',
- 'submodule/rive-cpp/src/generated/artboard_base.cpp',
- 'submodule/rive-cpp/src/generated/node_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/listener_number_change_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/transition_trigger_condition_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/nested_simple_animation_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/keyframe_double_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_machine_trigger_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/transition_bool_condition_base.cpp',
+ 'submodule/rive-cpp/src/constraints/constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/distance_constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/ik_constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/rotation_constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/scale_constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/targeted_constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/transform_constraint.cpp',
+ 'submodule/rive-cpp/src/constraints/translation_constraint.cpp',
+ 'submodule/rive-cpp/src/core/binary_reader.cpp',
+ 'submodule/rive-cpp/src/core/field_types/core_bool_type.cpp',
+ 'submodule/rive-cpp/src/core/field_types/core_bytes_type.cpp',
+ 'submodule/rive-cpp/src/core/field_types/core_color_type.cpp',
+ 'submodule/rive-cpp/src/core/field_types/core_double_type.cpp',
+ 'submodule/rive-cpp/src/core/field_types/core_string_type.cpp',
+ 'submodule/rive-cpp/src/core/field_types/core_uint_type.cpp',
+ 'submodule/rive-cpp/src/dependency_sorter.cpp',
+ 'submodule/rive-cpp/src/draw_rules.cpp',
+ 'submodule/rive-cpp/src/draw_target.cpp',
+ 'submodule/rive-cpp/src/drawable.cpp',
+ 'submodule/rive-cpp/src/file.cpp',
'submodule/rive-cpp/src/generated/animation/animation_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_transition_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/keyframe_id_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/keyed_property_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/animation_state_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/any_state_base.cpp',
'submodule/rive-cpp/src/generated/animation/blend_animation_1d_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_machine_bool_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/blend_animation_direct_base.cpp',
'submodule/rive-cpp/src/generated/animation/blend_state_1d_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/blend_state_direct_base.cpp',
'submodule/rive-cpp/src/generated/animation/blend_state_transition_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/nested_number_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/nested_trigger_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/transition_number_condition_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/listener_bool_change_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/keyed_object_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/animation_state_base.cpp',
'submodule/rive-cpp/src/generated/animation/cubic_interpolator_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/linear_animation_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/entry_state_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/event_bool_change_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/event_number_change_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/event_trigger_change_base.cpp',
'submodule/rive-cpp/src/generated/animation/exit_state_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/any_state_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/keyed_object_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/keyed_property_base.cpp',
'submodule/rive-cpp/src/generated/animation/keyframe_bool_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/blend_state_direct_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/entry_state_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/listener_trigger_change_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_machine_listener_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_machine_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_machine_number_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/blend_animation_direct_base.cpp',
'submodule/rive-cpp/src/generated/animation/keyframe_color_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/listener_align_target_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/state_machine_layer_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/keyframe_double_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/keyframe_id_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/linear_animation_base.cpp',
'submodule/rive-cpp/src/generated/animation/nested_remap_animation_base.cpp',
- 'submodule/rive-cpp/src/generated/animation/nested_bool_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/nested_simple_animation_base.cpp',
'submodule/rive-cpp/src/generated/animation/nested_state_machine_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_machine_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_machine_bool_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_machine_event_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_machine_layer_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_machine_number_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_machine_trigger_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/state_transition_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/transition_bool_condition_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/transition_number_condition_base.cpp',
+ 'submodule/rive-cpp/src/generated/animation/transition_trigger_condition_base.cpp',
+ 'submodule/rive-cpp/src/generated/artboard_base.cpp',
+ 'submodule/rive-cpp/src/generated/assets/file_asset_contents_base.cpp',
+ 'submodule/rive-cpp/src/generated/assets/folder_base.cpp',
+ 'submodule/rive-cpp/src/generated/assets/image_asset_base.cpp',
+ 'submodule/rive-cpp/src/generated/backboard_base.cpp',
+ 'submodule/rive-cpp/src/generated/bones/bone_base.cpp',
+ 'submodule/rive-cpp/src/generated/bones/cubic_weight_base.cpp',
+ 'submodule/rive-cpp/src/generated/bones/root_bone_base.cpp',
+ 'submodule/rive-cpp/src/generated/bones/skin_base.cpp',
+ 'submodule/rive-cpp/src/generated/bones/tendon_base.cpp',
+ 'submodule/rive-cpp/src/generated/bones/weight_base.cpp',
+ 'submodule/rive-cpp/src/generated/constraints/distance_constraint_base.cpp',
+ 'submodule/rive-cpp/src/generated/constraints/ik_constraint_base.cpp',
+ 'submodule/rive-cpp/src/generated/constraints/rotation_constraint_base.cpp',
+ 'submodule/rive-cpp/src/generated/constraints/scale_constraint_base.cpp',
+ 'submodule/rive-cpp/src/generated/constraints/transform_constraint_base.cpp',
+ 'submodule/rive-cpp/src/generated/constraints/translation_constraint_base.cpp',
'submodule/rive-cpp/src/generated/draw_rules_base.cpp',
+ 'submodule/rive-cpp/src/generated/draw_target_base.cpp',
'submodule/rive-cpp/src/generated/nested_artboard_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/paint/stroke_base.cpp',
+ 'submodule/rive-cpp/src/generated/node_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/clipping_shape_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/contour_mesh_vertex_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/cubic_asymmetric_vertex_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/cubic_detached_vertex_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/cubic_mirrored_vertex_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/ellipse_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/image_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/mesh_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/mesh_vertex_base.cpp',
'submodule/rive-cpp/src/generated/shapes/paint/fill_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/paint/radial_gradient_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/paint/linear_gradient_base.cpp',
'submodule/rive-cpp/src/generated/shapes/paint/gradient_stop_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/paint/trim_path_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/paint/linear_gradient_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/paint/radial_gradient_base.cpp',
'submodule/rive-cpp/src/generated/shapes/paint/solid_color_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/paint/stroke_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/paint/trim_path_base.cpp',
'submodule/rive-cpp/src/generated/shapes/points_path_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/cubic_asymmetric_vertex_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/straight_vertex_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/image_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/ellipse_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/cubic_mirrored_vertex_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/mesh_vertex_base.cpp',
'submodule/rive-cpp/src/generated/shapes/polygon_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/mesh_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/contour_mesh_vertex_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/cubic_detached_vertex_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/clipping_shape_base.cpp',
- 'submodule/rive-cpp/src/generated/shapes/shape_base.cpp',
'submodule/rive-cpp/src/generated/shapes/rectangle_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/shape_base.cpp',
'submodule/rive-cpp/src/generated/shapes/star_base.cpp',
+ 'submodule/rive-cpp/src/generated/shapes/straight_vertex_base.cpp',
'submodule/rive-cpp/src/generated/shapes/triangle_base.cpp',
- 'submodule/rive-cpp/src/generated/draw_target_base.cpp',
- 'submodule/rive-cpp/src/generated/bones/skin_base.cpp',
- 'submodule/rive-cpp/src/generated/bones/weight_base.cpp',
- 'submodule/rive-cpp/src/generated/bones/bone_base.cpp',
- 'submodule/rive-cpp/src/generated/bones/tendon_base.cpp',
- 'submodule/rive-cpp/src/generated/bones/cubic_weight_base.cpp',
- 'submodule/rive-cpp/src/generated/bones/root_bone_base.cpp',
- 'submodule/rive-cpp/src/generated/constraints/scale_constraint_base.cpp',
- 'submodule/rive-cpp/src/generated/constraints/transform_constraint_base.cpp',
- 'submodule/rive-cpp/src/generated/constraints/rotation_constraint_base.cpp',
- 'submodule/rive-cpp/src/generated/constraints/translation_constraint_base.cpp',
- 'submodule/rive-cpp/src/generated/constraints/ik_constraint_base.cpp',
- 'submodule/rive-cpp/src/generated/constraints/distance_constraint_base.cpp',
- 'submodule/rive-cpp/src/generated/backboard_base.cpp',
- 'submodule/rive-cpp/src/world_transform_component.cpp',
+ 'submodule/rive-cpp/src/hittest_command_path.cpp',
+ 'submodule/rive-cpp/src/importers/artboard_importer.cpp',
+ 'submodule/rive-cpp/src/importers/backboard_importer.cpp',
+ 'submodule/rive-cpp/src/importers/file_asset_importer.cpp',
+ 'submodule/rive-cpp/src/importers/keyed_object_importer.cpp',
+ 'submodule/rive-cpp/src/importers/keyed_property_importer.cpp',
+ 'submodule/rive-cpp/src/importers/layer_state_importer.cpp',
+ 'submodule/rive-cpp/src/importers/linear_animation_importer.cpp',
+ 'submodule/rive-cpp/src/importers/state_machine_event_importer.cpp',
+ 'submodule/rive-cpp/src/importers/state_machine_importer.cpp',
+ 'submodule/rive-cpp/src/importers/state_machine_layer_importer.cpp',
+ 'submodule/rive-cpp/src/importers/state_transition_importer.cpp',
+ 'submodule/rive-cpp/src/layout.cpp',
+ 'submodule/rive-cpp/src/math/aabb.cpp',
+ 'submodule/rive-cpp/src/math/hit_test.cpp',
+ 'submodule/rive-cpp/src/math/mat2d.cpp',
+ 'submodule/rive-cpp/src/math/raw_path.cpp',
+ 'submodule/rive-cpp/src/math/vec2d.cpp',
+ 'submodule/rive-cpp/src/nested_artboard.cpp',
+ 'submodule/rive-cpp/src/node.cpp',
'submodule/rive-cpp/src/renderer.cpp',
- 'submodule/rive-cpp/src/bones/weight.cpp',
- 'submodule/rive-cpp/src/bones/skinnable.cpp',
- 'submodule/rive-cpp/src/bones/root_bone.cpp',
- 'submodule/rive-cpp/src/bones/skin.cpp',
- 'submodule/rive-cpp/src/bones/tendon.cpp',
- 'submodule/rive-cpp/src/bones/bone.cpp',
- 'submodule/rive-cpp/src/constraints/transform_constraint.cpp',
- 'submodule/rive-cpp/src/constraints/scale_constraint.cpp',
- 'submodule/rive-cpp/src/constraints/translation_constraint.cpp',
- 'submodule/rive-cpp/src/constraints/ik_constraint.cpp',
- 'submodule/rive-cpp/src/constraints/constraint.cpp',
- 'submodule/rive-cpp/src/constraints/rotation_constraint.cpp',
- 'submodule/rive-cpp/src/constraints/distance_constraint.cpp',
- 'submodule/rive-cpp/src/constraints/targeted_constraint.cpp',
- 'submodule/rive-cpp/src/transform_component.cpp'
+ 'submodule/rive-cpp/src/scene.cpp',
+ 'submodule/rive-cpp/src/shapes/clipping_shape.cpp',
+ 'submodule/rive-cpp/src/shapes/cubic_asymmetric_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/cubic_detached_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/cubic_mirrored_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/cubic_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/ellipse.cpp',
+ 'submodule/rive-cpp/src/shapes/image.cpp',
+ 'submodule/rive-cpp/src/shapes/mesh_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/mesh.cpp',
+ 'submodule/rive-cpp/src/shapes/metrics_path.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/color.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/fill.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/gradient_stop.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/linear_gradient.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/radial_gradient.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/shape_paint_mutator.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/shape_paint.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/solid_color.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/stroke.cpp',
+ 'submodule/rive-cpp/src/shapes/paint/trim_path.cpp',
+ 'submodule/rive-cpp/src/shapes/parametric_path.cpp',
+ 'submodule/rive-cpp/src/shapes/path_composer.cpp',
+ 'submodule/rive-cpp/src/shapes/path_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/path.cpp',
+ 'submodule/rive-cpp/src/shapes/points_path.cpp',
+ 'submodule/rive-cpp/src/shapes/polygon.cpp',
+ 'submodule/rive-cpp/src/shapes/rectangle.cpp',
+ 'submodule/rive-cpp/src/shapes/shape_paint_container.cpp',
+ 'submodule/rive-cpp/src/shapes/shape.cpp',
+ 'submodule/rive-cpp/src/shapes/star.cpp',
+ 'submodule/rive-cpp/src/shapes/straight_vertex.cpp',
+ 'submodule/rive-cpp/src/shapes/triangle.cpp',
+ 'submodule/rive-cpp/src/shapes/vertex.cpp',
+ 'submodule/rive-cpp/src/transform_component.cpp',
+ 'submodule/rive-cpp/src/world_transform_component.cpp'
]
rive_cpp_inc = include_directories('submodule/rive-cpp/include')
-/*
- * Copyright 2022 Rive
- */
-
#include "skia_factory.hpp"
#include "skia_renderer.hpp"
#include "to_skia.hpp"
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkImage.h"
-#include "include/core/SkPixmap.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkVertices.h"
#include "rive/math/vec2d.hpp"
#include "rive/shapes/paint/color.hpp"
-#include "utils/factory_utils.hpp"
using namespace rive;
-// skia's has/had bugs in trilerp, so backing down to nearest mip
-const SkSamplingOptions gSampling(SkFilterMode::kLinear, SkMipmapMode::kNearest);
-
class SkiaRenderPath : public RenderPath {
private:
SkPath m_Path;
void cap(StrokeCap value) override;
void blendMode(BlendMode value) override;
void shader(rcp<RenderShader>) override;
- void invalidateStroke() override {}
};
class SkiaRenderImage : public RenderImage {
SkiaRenderImage(sk_sp<SkImage> image);
sk_sp<SkImage> skImage() const { return m_SkImage; }
+
+ rcp<RenderShader>
+ makeShader(RenderTileMode tx, RenderTileMode ty, const Mat2D* localMatrix) const override;
+};
+
+class SkiaBuffer : public RenderBuffer {
+ const size_t m_ElemSize;
+ void* m_Buffer;
+
+public:
+ SkiaBuffer(const void* src, size_t count, size_t elemSize) :
+ RenderBuffer(count), m_ElemSize(elemSize) {
+ size_t bytes = count * elemSize;
+ m_Buffer = malloc(bytes);
+ memcpy(m_Buffer, src, bytes);
+ }
+
+ ~SkiaBuffer() override { free(m_Buffer); }
+
+ const float* f32s() const {
+ assert(m_ElemSize == sizeof(float));
+ return static_cast<const float*>(m_Buffer);
+ }
+
+ const uint16_t* u16s() const {
+ assert(m_ElemSize == sizeof(uint16_t));
+ return static_cast<const uint16_t*>(m_Buffer);
+ }
+
+ const SkPoint* points() const { return reinterpret_cast<const SkPoint*>(this->f32s()); }
+
+ static const SkiaBuffer* Cast(const RenderBuffer* buffer) {
+ return reinterpret_cast<const SkiaBuffer*>(buffer);
+ }
};
+template <typename T> rcp<RenderBuffer> make_buffer(Span<T> span) {
+ return rcp<RenderBuffer>(new SkiaBuffer(span.data(), span.size(), sizeof(T)));
+}
+
class SkiaRenderShader : public RenderShader {
public:
SkiaRenderShader(sk_sp<SkShader> sh) : shader(std::move(sh)) {}
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;
+ 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); }
paint.setAlphaf(opacity);
paint.setBlendMode(ToSkia::convert(blendMode));
auto skiaImage = reinterpret_cast<const SkiaRenderImage*>(image);
- m_Canvas->drawImage(skiaImage->skImage(), 0.0f, 0.0f, gSampling, &paint);
+ SkSamplingOptions sampling(SkFilterMode::kLinear);
+ m_Canvas->drawImage(skiaImage->skImage(), 0.0f, 0.0f, sampling, &paint);
}
#define SKIA_BUG_13047
SkMatrix scaleM;
- auto uvs = (const SkPoint*)DataRenderBuffer::Cast(uvCoords.get())->vecs();
+ const SkPoint* uvs = SkiaBuffer::Cast(uvCoords.get())->points();
#ifdef SKIA_BUG_13047
// The local matrix is ignored for drawVertices, so we have to manually scale
#endif
auto skiaImage = reinterpret_cast<const SkiaRenderImage*>(image)->skImage();
- auto shader = skiaImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, gSampling, &scaleM);
+ const SkSamplingOptions sampling(SkFilterMode::kLinear);
+ auto shader = skiaImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, &scaleM);
SkPaint paint;
paint.setAlphaf(opacity);
// clang-format off
auto vt = SkVertices::MakeCopy(vertexMode,
vertexCount,
- (const SkPoint*)DataRenderBuffer::Cast(vertices.get())->vecs(),
+ SkiaBuffer::Cast(vertices.get())->points(),
uvs,
no_colors,
indices->count(),
- DataRenderBuffer::Cast(indices.get())->u16s());
+ SkiaBuffer::Cast(indices.get())->u16s());
// clang-format on
// The blend mode is ignored if we don't have colors && uvs
m_Height = m_SkImage->height();
}
+rcp<RenderShader>
+SkiaRenderImage::makeShader(RenderTileMode tx, RenderTileMode ty, const Mat2D* localMatrix) const {
+ const SkMatrix lm = localMatrix ? ToSkia::convert(*localMatrix) : SkMatrix();
+ const SkSamplingOptions options(SkFilterMode::kLinear);
+ auto sh = m_SkImage->makeShader(ToSkia::convert(tx), ToSkia::convert(ty), options, &lm);
+ return rcp<RenderShader>(new SkiaRenderShader(std::move(sh)));
+}
+
// Factory
rcp<RenderBuffer> SkiaFactory::makeBufferU16(Span<const uint16_t> data) {
- return DataRenderBuffer::Make(data);
+ return make_buffer(data);
}
rcp<RenderBuffer> SkiaFactory::makeBufferU32(Span<const uint32_t> data) {
- return DataRenderBuffer::Make(data);
+ return make_buffer(data);
}
rcp<RenderBuffer> SkiaFactory::makeBufferF32(Span<const float> data) {
- return DataRenderBuffer::Make(data);
+ return make_buffer(data);
}
-rcp<RenderShader> SkiaFactory::makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
+rcp<RenderShader> SkiaFactory::makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode mode,
+ const Mat2D* localMatrix) {
const SkPoint pts[] = {{sx, sy}, {ex, ey}};
- auto sh =
- SkGradientShader::MakeLinear(pts, (const SkColor*)colors, stops, count, SkTileMode::kClamp);
+ const SkMatrix lm = localMatrix ? ToSkia::convert(*localMatrix) : SkMatrix();
+ auto sh = SkGradientShader::MakeLinear(
+ pts, (const SkColor*)colors, stops, count, ToSkia::convert(mode), 0, &lm);
return rcp<RenderShader>(new SkiaRenderShader(std::move(sh)));
}
-rcp<RenderShader> SkiaFactory::makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- auto sh = SkGradientShader::MakeRadial({cx, cy},
- radius,
- (const SkColor*)colors,
- stops,
- count,
- SkTileMode::kClamp);
+rcp<RenderShader> SkiaFactory::makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode mode,
+ const Mat2D* localMatrix) {
+ const SkMatrix lm = localMatrix ? ToSkia::convert(*localMatrix) : SkMatrix();
+ auto sh = SkGradientShader::MakeRadial(
+ {cx, cy}, radius, (const SkColor*)colors, stops, count, ToSkia::convert(mode), 0, &lm);
return rcp<RenderShader>(new SkiaRenderShader(std::move(sh)));
}
std::unique_ptr<RenderPath> SkiaFactory::makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
+ Span<const uint8_t> verbs,
FillRule fillRule) {
- const bool isVolatile = false; // ???
+ const bool isVolatile = false; // ???
const SkScalar* conicWeights = nullptr;
const int conicWeightCount = 0;
- return std::make_unique<SkiaRenderPath>(
- SkPath::Make(reinterpret_cast<const SkPoint*>(points.data()),
- points.count(),
- (uint8_t*)verbs.data(),
- verbs.count(),
- conicWeights,
- conicWeightCount,
- ToSkia::convert(fillRule),
- isVolatile));
+ return std::make_unique<SkiaRenderPath>(SkPath::Make(reinterpret_cast<const SkPoint*>(points.data()),
+ points.count(),
+ verbs.data(),
+ verbs.count(),
+ conicWeights,
+ conicWeightCount,
+ ToSkia::convert(fillRule),
+ isVolatile));
}
std::unique_ptr<RenderPath> SkiaFactory::makeEmptyRenderPath() {
sk_sp<SkData> data = SkData::MakeWithoutCopy(encoded.data(), encoded.size());
auto image = SkImage::MakeFromEncoded(data);
+ // Our optimized skia buld seems to have broken lazy-image decode.
+ // As a work-around for now, force the image to be decoded.
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 {
- // Skia failed, so let's try the platform
- ImageInfo info;
- auto pixels = this->platformDecode(encoded, &info);
- if (pixels.size() > 0) {
- auto ct =
- info.colorType == ColorType::rgba ? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType;
- auto at =
- info.alphaType == AlphaType::premul ? kPremul_SkAlphaType : kOpaque_SkAlphaType;
- auto skinfo = SkImageInfo::Make(info.width, info.height, ct, at);
- image = SkImage::MakeRasterCopy({skinfo, pixels.data(), info.rowBytes});
- }
}
return image ? std::make_unique<SkiaRenderImage>(std::move(image)) : nullptr;
-}
+}
\ No newline at end of file
echo build.sh clean - clean the build
echo build.sh release - build release library
echo build.sh -p ios release - build release ios library
- echo build.sh -p ios_sim release - build release ios simulator library
echo build.sh -p android release - build release android library
exit 1
}
echo "Building for iOS"
export IOS_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)
build "--os=ios"
- if [ "$OPTION" = "clean" ]; then
- exit
- fi
- ;;
- ios_sim)
export IOS_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
build "--os=ios --variant=emulator"
if [ "$OPTION" = "clean" ]; then
WINDOWS_CLANG_CL_SUPPRESSED_WARNINGS = {
"-Wno-c++98-compat",
"-Wno-c++98-compat-pedantic",
+ "-Wno-reserved-macro-identifier",
+ "-Wno-newline-eof",
+ "-Wno-old-style-cast",
+ "-Wno-unused-parameter",
+ "-Wno-float-equal",
+ "-Wno-implicit-float-conversion",
+ "-Wno-shadow",
+ "-Wno-sign-conversion",
+ "-Wno-inconsistent-missing-destructor-override",
+ "-Wno-nested-anon-types",
+ "-Wno-suggest-destructor-override",
+ "-Wno-non-virtual-dtor",
+ "-Wno-unknown-argument",
+ "-Wno-gnu-anonymous-struct",
+ "-Wno-extra-semi",
+ "-Wno-cast-qual",
+ "-Wno-ignored-qualifiers",
+ "-Wno-double-promotion",
+ "-Wno-tautological-unsigned-zero-compare",
+ "-Wno-unreachable-code-break",
+ "-Wno-global-constructors",
+ "-Wno-switch-enum",
+ "-Wno-shorten-64-to-32",
+ "-Wno-missing-prototypes",
+ "-Wno-implicit-int-conversion",
+ "-Wno-unused-macros",
"-Wno-deprecated-copy-with-user-provided-dtor",
+ "-Wno-missing-variable-declarations",
+ "-Wno-ctad-maybe-unsupported",
+ "-Wno-vla-extension",
+ "-Wno-float-conversion",
+ "-Wno-gnu-zero-variadic-macro-arguments",
+ "-Wno-undef",
"-Wno-documentation",
"-Wno-documentation-pedantic",
"-Wno-documentation-unknown-command",
- "-Wno-double-promotion",
- "-Wno-exit-time-destructors",
- "-Wno-float-equal",
- "-Wno-global-constructors",
- "-Wno-implicit-float-conversion",
- "-Wno-newline-eof",
- "-Wno-old-style-cast",
+ "-Wno-suggest-override",
+ "-Wno-unused-exception-parameter",
+ "-Wno-cast-align",
+ "-Wno-deprecated-declarations",
+ "-Wno-shadow-field",
+ "-Wno-nonportable-system-include-path",
"-Wno-reserved-identifier",
- "-Wno-shadow",
+ "-Wno-thread-safety-negative",
+ "-Wno-exit-time-destructors",
+ "-Wno-unreachable-code",
+ "-Wno-zero-as-null-pointer-constant",
+ "-Wno-pedantic",
"-Wno-sign-compare",
- "-Wno-sign-conversion",
- "-Wno-unused-macros",
- "-Wno-unused-parameter",
}
project "rive"
filter "system:windows"
architecture "x64"
defines {"_USE_MATH_DEFINES"}
- flags { "FatalCompileWarnings" }
buildoptions {WINDOWS_CLANG_CL_SUPPRESSED_WARNINGS}
staticruntime "on" -- Match Skia's /MT flag for link compatibility
runtime "Release" -- Use /MT even in debug (/MTd is incompatible with Skia)
- removebuildoptions {
- "-fno-exceptions",
- "-fno-rtti",
- }
filter {"system:ios", "options:variant=system" }
buildoptions {"-mios-version-min=10.0 -fembed-bitcode -arch armv7 -arch arm64 -arch arm64e -isysroot " .. (os.getenv("IOS_SYSROOT") or "")}
defines {"NDEBUG"}
optimize "On"
- filter {"options:with_rive_tools" }
- defines {"WITH_RIVE_TOOLS"}
-
newoption {
trigger = "variant",
value = "type",
}
}
-
-newoption {
- trigger = "with_rive_tools",
- description = "Enables tools usually not necessary for runtime."
-}
\ No newline at end of file
+++ /dev/null
-SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
-export DEPENDENCIES_SCRIPTS=$SCRIPT_DIR
-export DEPENDENCIES=$SCRIPT_DIR/cache
-mkdir -p $DEPENDENCIES
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-
-pushd $DEPENDENCIES
-EARCUT_REPO=https://github.com/mapbox/earcut.hpp
-EARCUT_STABLE_BRANCH=master
-
-if [ ! -d earcut.hpp ]; then
- echo "Cloning earcut."
- git clone $EARCUT_REPO
-fi
-
-pushd earcut.hpp
-git checkout $EARCUT_STABLE_BRANCH && git fetch && git pull
-popd
-
-popd
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-pushd $DEPENDENCIES
-IMGUI_REPO=https://github.com/ocornut/imgui
-IMGUI_STABLE_BRANCH=master
-
-if [ ! -d imgui ]; then
- echo "Cloning ImGui."
- git clone $IMGUI_REPO
-fi
-
-cd imgui && git checkout $IMGUI_STABLE_BRANCH && git fetch && git pull
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-
-pushd $DEPENDENCIES
-LIBPNG_REPO=https://github.com/glennrp/libpng
-LIBPNG_STABLE_BRANCH=libpng16
-
-if [ ! -d libpng ]; then
- echo "Cloning libpng."
- git clone $LIBPNG_REPO
-fi
-
-pushd libpng
-git checkout $LIBPNG_STABLE_BRANCH && git fetch && git pull
-popd
-
-ZLIB_REPO=https://github.com/madler/zlib
-ZLIB_STABLE_BRANCH=master
-
-if [ ! -d zlib ]; then
- echo "Cloning zlib."
- git clone $ZLIB_REPO
-fi
-
-pushd zlib
-git checkout $ZLIB_STABLE_BRANCH && git fetch && git pull
-popd
-
-popd
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-
-pushd $DEPENDENCIES
-LIBTESS2_REPO=https://github.com/memononen/libtess2
-LIBTESS2_STABLE_BRANCH=master
-
-if [ ! -d libtess2 ]; then
- echo "Cloning libtess2."
- git clone $LIBTESS2_REPO
-fi
-
-pushd libtess2
-git checkout $LIBTESS2_STABLE_BRANCH && git fetch && git pull
-popd
-
-popd
+++ /dev/null
-#!/bin/sh
-set -e
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-
-mkdir -p $DEPENDENCIES/bin
-echo Downloading Premake5
-curl https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-macosx.tar.gz -L -o $DEPENDENCIES//bin/premake_macosx.tar.gz
-cd $DEPENDENCIES/bin
-# Export premake5 into bin
-tar -xvf premake_macosx.tar.gz 2>/dev/null
-# Delete downloaded archive
-rm premake_macosx.tar.gz
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-
-pushd $DEPENDENCIES
-SOKOL_REPO=https://github.com/luigi-rosso/sokol
-SOKOL_STABLE_BRANCH=support_transparent_framebuffer
-
-if [ ! -d sokol ]; then
- echo "Cloning sokol."
- git clone $SOKOL_REPO
-
- if [ $(arch) == arm64 ]; then
- SOKOL_SHDC=https://github.com/floooh/sokol-tools-bin/raw/master/bin/osx_arm64/sokol-shdc
- else
- SOKOL_SHDC=https://github.com/floooh/sokol-tools-bin/raw/master/bin/osx/sokol-shdc
- fi
- curl $SOKOL_SHDC -L -o ./bin/sokol-shdc
- chmod +x ./bin/sokol-shdc
-fi
-
-cd sokol && git checkout $SOKOL_STABLE_BRANCH && git fetch && git pull
-popd
+++ /dev/null
-#!/bin/sh
-
-set -e
-
-if [[ -z "${DEPENDENCIES}" ]]; then
- echo "DEPENDENCIES env variable must be set. This script is usually called by other scripts."
- exit 1
-fi
-
-pushd $DEPENDENCIES
-
-if [ ! -d skia ]; then
- git clone https://github.com/google/skia skia
- cd skia
- git checkout chrome/m99
-else
- cd skia
-fi
-
-python tools/git-sync-deps
-
-CONFIG=debug
-RENDERER=
-SKIA_USE_GL=false
-SKIA_USE_METAL=false
-
-for var in "$@"; do
- if [[ $var = "release" ]]; then
- CONFIG=release
- fi
- if [[ $var = "gl" ]]; then
- SKIA_USE_GL=true
- RENDERER=gl
- fi
- if [[ $var = "metal" ]]; then
- SKIA_USE_METAL=true
- RENDERER=metal
- fi
-done
-
-if [[ $CONFIG = "debug" ]]; then
- bin/gn gen out/$RENDERER/debug --type=static_library --args=" \
- extra_cflags=[\"-fno-rtti\", \"-DSK_DISABLE_SKPICTURE\", \"-DSK_DISABLE_TEXT\", \"-DRIVE_OPTIMIZED\", \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \"-DSK_DISABLE_AAA\", \"-DSK_DISABLE_EFFECT_DESERIALIZATION\"] \
-
- is_official_build=false \
- skia_use_gl=$SKIA_USE_GL \
- skia_use_zlib=true \
- skia_enable_gpu=true \
- skia_enable_fontmgr_empty=false \
- skia_use_libpng_encode=true \
- skia_use_libpng_decode=true \
- skia_enable_skgpu_v1=true \
-
- skia_use_dng_sdk=false \
- skia_use_egl=false \
- skia_use_expat=false \
- skia_use_fontconfig=false \
- skia_use_freetype=false \
- skia_use_icu=false \
- skia_use_libheif=false \
- skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
- skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
- skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
- skia_use_lua=false \
- skia_use_piex=false \
- skia_use_vulkan=false \
- skia_use_metal=$SKIA_USE_METAL \
- skia_use_angle=false \
- skia_use_system_zlib=false \
- skia_enable_spirv_validation=false \
- skia_enable_pdf=false \
- skia_enable_skottie=false \
- skia_enable_tools=false \
- "
- ninja -C out/$RENDERER/debug
- du -hs out/$RENDERER/debug/libskia.a
-fi
-
-if [[ $CONFIG = "release" ]]; then
- bin/gn gen out/$RENDERER/release --type=static_library --args=" \
- extra_cflags=[\"-fno-rtti\", \"-flto=full\", \"-DSK_DISABLE_SKPICTURE\", \"-DSK_DISABLE_TEXT\", \"-DRIVE_OPTIMIZED\", \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \"-DSK_DISABLE_AAA\", \"-DSK_DISABLE_EFFECT_DESERIALIZATION\"] \
-
- is_official_build=true \
- skia_use_gl=true \
- skia_use_zlib=true \
- skia_enable_gpu=true \
- skia_enable_fontmgr_empty=false \
- skia_use_libpng_encode=true \
- skia_use_libpng_decode=true \
- skia_enable_skgpu_v1=true \
-
- skia_use_dng_sdk=false \
- skia_use_egl=false \
- skia_use_expat=false \
- skia_use_fontconfig=false \
- skia_use_freetype=false \
- skia_use_icu=false \
- skia_use_libheif=false \
- skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
- skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
- skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
- skia_use_lua=false \
- skia_use_piex=false \
- skia_use_vulkan=false \
- skia_use_metal=true \
- skia_use_angle=false \
- skia_use_system_zlib=false \
- skia_enable_spirv_validation=false \
- skia_enable_pdf=false \
- skia_enable_skottie=false \
- skia_enable_tools=false \
- "
- ninja -C out/$RENDERER/release
- du -hs out/$RENDERER/release/libskia.a
-fi
--- /dev/null
+{
+ "name": "EventBoolChange",
+ "key": {
+ "int": 117,
+ "string": "event_bool_change"
+ },
+ "extends": "animation/event_input_change.json",
+ "properties": {
+ "value": {
+ "type": "uint",
+ "initialValue": "1",
+ "key": {
+ "int": 228,
+ "string": "value"
+ },
+ "description": "Value to set the input to when the event occurs."
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "EventInputChange",
+ "key": {
+ "int": 116,
+ "string": "event_input_change"
+ },
+ "abstract": true,
+ "properties": {
+ "eventId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "0",
+ "key": {
+ "int": 226,
+ "string": "eventid"
+ },
+ "description": "Identifier used to track the StateMachineEvent this result belongs to.",
+ "runtime": false
+ },
+ "inputId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "-1",
+ "key": {
+ "int": 227,
+ "string": "inputid"
+ },
+ "description": "Id of the StateMachineInput referenced."
+ },
+ "order": {
+ "type": "FractionalIndex",
+ "initialValue": "FractionalIndex.invalid",
+ "initialValueRuntime": "0",
+ "key": {
+ "int": 230,
+ "string": "order"
+ },
+ "description": "Order value for condition in a transition.",
+ "runtime": false
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "EventNumberChange",
+ "key": {
+ "int": 118,
+ "string": "event_number_change"
+ },
+ "extends": "animation/event_input_change.json",
+ "properties": {
+ "value": {
+ "type": "double",
+ "initialValue": "0",
+ "key": {
+ "int": 229,
+ "string": "value"
+ },
+ "description": "Value to set the input to when the event occurs."
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "EventTriggerChange",
+ "key": {
+ "int": 115,
+ "string": "event_trigger_change"
+ },
+ "extends": "animation/event_input_change.json"
+}
\ No newline at end of file
+++ /dev/null
-{
- "name": "ListenerAction",
- "key": {
- "int": 125,
- "string": "listener_action"
- },
- "abstract": true,
- "properties": {
- "listenerId": {
- "type": "Id",
- "typeRuntime": "uint",
- "initialValue": "Core.missingId",
- "initialValueRuntime": "0",
- "key": {
- "int": 226,
- "string": "listenerId"
- },
- "description": "Identifier used to track the StateMachineListener this result belongs to.",
- "runtime": false
- },
- "order": {
- "type": "FractionalIndex",
- "initialValue": "FractionalIndex.invalid",
- "initialValueRuntime": "0",
- "key": {
- "int": 230,
- "string": "order"
- },
- "description": "Order value for condition in a transition.",
- "runtime": false
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "ListenerAlignTarget",
- "key": {
- "int": 126,
- "string": "listeneraligntarget"
- },
- "extends": "animation/listener_action.json",
- "properties": {
- "targetId": {
- "type": "Id",
- "typeRuntime": "uint",
- "initialValue": "Core.missingId",
- "initialValueRuntime": "0",
- "key": {
- "int": 240,
- "string": "targetid"
- },
- "description": "Identifier used to track the object use as a target fo this listener action."
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "ListenerBoolChange",
- "key": {
- "int": 117,
- "string": "listener_bool_change"
- },
- "extends": "animation/listener_input_change.json",
- "properties": {
- "value": {
- "type": "uint",
- "initialValue": "1",
- "key": {
- "int": 228,
- "string": "value"
- },
- "description": "Value to set the input to when the listener occurs."
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "ListenerInputChange",
- "key": {
- "int": 116,
- "string": "listener_input_change"
- },
- "abstract": true,
- "extends": "animation/listener_action.json",
- "properties": {
- "inputId": {
- "type": "Id",
- "typeRuntime": "uint",
- "initialValue": "Core.missingId",
- "initialValueRuntime": "-1",
- "key": {
- "int": 227,
- "string": "inputid"
- },
- "description": "Id of the StateMachineInput referenced."
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "ListenerNumberChange",
- "key": {
- "int": 118,
- "string": "listener_number_change"
- },
- "extends": "animation/listener_input_change.json",
- "properties": {
- "value": {
- "type": "double",
- "initialValue": "0",
- "key": {
- "int": 229,
- "string": "value"
- },
- "description": "Value to set the input to when the listener occurs."
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "ListenerTriggerChange",
- "key": {
- "int": 115,
- "string": "listener_trigger_change"
- },
- "extends": "animation/listener_input_change.json"
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "NestedBool",
- "key": {
- "int": 123,
- "string": "nestedBool"
- },
- "extends": "animation/nested_input.json",
- "properties": {
- "nestedValue": {
- "type": "bool",
- "initialValue": "false",
- "animates": true,
- "key": {
- "int": 238,
- "string": "value"
- }
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "NestedInput",
- "key": {
- "int": 121,
- "string": "nestedinput"
- },
- "abstract": true,
- "extends": "component.json",
- "properties": {
- "inputId": {
- "type": "Id",
- "typeRuntime": "uint",
- "initialValue": "Core.missingId",
- "initialValueRuntime": "-1",
- "key": {
- "int": 237,
- "string": "inputid"
- },
- "description": "Identifier used to track the actual backing state machine input."
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-{
- "name": "NestedNumber",
- "key": {
- "int": 124,
- "string": "nestedNumber"
- },
- "extends": "animation/nested_input.json",
- "properties": {
- "nestedValue": {
- "type": "double",
- "initialValue": "0",
- "animates": true,
- "key": {
- "int": 239,
- "string": "nestedValue"
- }
- }
- }
-}
\ No newline at end of file
"name": "NestedStateMachine",
"key": {
"int": 95,
- "string": "nestedStateMachine"
+ "string": "nestedstatemachine"
},
"extends": "nested_animation.json",
"generic": "animation/state_machine.json"
+++ /dev/null
-{
- "name": "NestedTrigger",
- "key": {
- "int": 122,
- "string": "nestedTrigger"
- },
- "extends": "animation/nested_input.json"
-}
\ No newline at end of file
},
"extends": "animation/animation.json",
"properties": {
+ "editingListValue": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 136,
+ "string": "editinglistvalue"
+ },
+ "description": "Backing value for enum representing which list being edited.",
+ "runtime": false,
+ "coop": false
+ },
"editingLayerId": {
"type": "Id",
"initialValue": "Core.missingId",
--- /dev/null
+{
+ "name": "StateMachineEvent",
+ "key": {
+ "int": 114,
+ "string": "statemachineevent"
+ },
+ "extends": "animation/state_machine_component.json",
+ "properties": {
+ "targetId": {
+ "type": "Id",
+ "typeRuntime": "uint",
+ "initialValue": "Core.missingId",
+ "initialValueRuntime": "0",
+ "key": {
+ "int": 224,
+ "string": "targetid"
+ },
+ "description": "Identifier used to track the object use as a target fo this event."
+ },
+ "eventTypeValue": {
+ "type": "uint",
+ "initialValue": "0",
+ "key": {
+ "int": 225,
+ "string": "eventtypevalue"
+ },
+ "description": "Event type (hover, click, etc)."
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-{
- "name": "StateMachineListener",
- "key": {
- "int": 114,
- "string": "stateMachineListener"
- },
- "extends": "animation/state_machine_component.json",
- "properties": {
- "targetId": {
- "type": "Id",
- "typeRuntime": "uint",
- "initialValue": "Core.missingId",
- "initialValueRuntime": "0",
- "key": {
- "int": 224,
- "string": "targetid"
- },
- "description": "Identifier used to track the object use as a target fo this listener."
- },
- "listenerTypeValue": {
- "type": "uint",
- "initialValue": "0",
- "key": {
- "int": 225,
- "string": "listenertypevalue"
- },
- "description": "Listener type (hover, click, etc)."
- }
- }
-}
\ No newline at end of file
"int": 119,
"string": "layeredasset"
},
- "extends": "assets/drawable_asset.json",
- "runtime": false
+ "runtime": false,
+ "extends": "assets/drawable_asset.json"
}
\ No newline at end of file
},
"colorValue": {
"type": "Color",
- "initialValue": "0xFF1D1D1D",
+ "initialValue": "0xFF222222",
"key": {
"int": 45,
"string": "colorValue"
"string": "nestedanimation"
},
"abstract": true,
- "extends": "container_component.json",
+ "extends": "component.json",
"properties": {
"animationId": {
"type": "Id",
-// clang-format off
/*
* Catch v2.13.7
* Generated: 2021-07-28 20:29:27.753164
// end catch_reenable_warnings.h
// end catch.hpp
-#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
\ No newline at end of file
+#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
WINDOWS_CLANG_CL_SUPPRESSED_WARNINGS = {
"-Wno-c++98-compat",
"-Wno-c++98-compat-pedantic",
- "-Wno-c99-extensions",
- "-Wno-ctad-maybe-unsupported",
+ "-Wno-reserved-macro-identifier",
+ "-Wno-newline-eof",
+ "-Wno-old-style-cast",
+ "-Wno-unused-parameter",
+ "-Wno-float-equal",
+ "-Wno-implicit-float-conversion",
+ "-Wno-shadow",
+ "-Wno-sign-conversion",
+ "-Wno-inconsistent-missing-destructor-override",
+ "-Wno-nested-anon-types",
+ "-Wno-suggest-destructor-override",
+ "-Wno-non-virtual-dtor",
+ "-Wno-unknown-argument",
+ "-Wno-gnu-anonymous-struct",
+ "-Wno-extra-semi",
+ "-Wno-cast-qual",
+ "-Wno-ignored-qualifiers",
+ "-Wno-double-promotion",
+ "-Wno-tautological-unsigned-zero-compare",
+ "-Wno-unreachable-code-break",
+ "-Wno-global-constructors",
+ "-Wno-switch-enum",
+ "-Wno-shorten-64-to-32",
+ "-Wno-missing-prototypes",
+ "-Wno-implicit-int-conversion",
+ "-Wno-unused-macros",
"-Wno-deprecated-copy-with-user-provided-dtor",
- "-Wno-deprecated-declarations",
+ "-Wno-missing-variable-declarations",
+ "-Wno-ctad-maybe-unsupported",
+ "-Wno-vla-extension",
+ "-Wno-float-conversion",
+ "-Wno-gnu-zero-variadic-macro-arguments",
+ "-Wno-undef",
"-Wno-documentation",
"-Wno-documentation-pedantic",
"-Wno-documentation-unknown-command",
- "-Wno-double-promotion",
- "-Wno-exit-time-destructors",
- "-Wno-float-equal",
- "-Wno-global-constructors",
- "-Wno-implicit-float-conversion",
- "-Wno-newline-eof",
- "-Wno-old-style-cast",
+ "-Wno-suggest-override",
+ "-Wno-unused-exception-parameter",
+ "-Wno-cast-align",
+ "-Wno-deprecated-declarations",
+ "-Wno-shadow-field",
+ "-Wno-nonportable-system-include-path",
"-Wno-reserved-identifier",
- "-Wno-shadow",
+ "-Wno-thread-safety-negative",
+ "-Wno-exit-time-destructors",
+ "-Wno-unreachable-code",
+ "-Wno-zero-as-null-pointer-constant",
+ "-Wno-pedantic",
"-Wno-sign-compare",
- "-Wno-sign-conversion",
- "-Wno-unused-macros",
- "-Wno-unused-parameter",
}
includedirs {"./include", "../../include"}
-files {
- "../../src/**.cpp", -- the Rive runtime source
- "../../test/**.cpp", -- the tests
- "../../utils/**.cpp", -- no_op utils
+files {"../../src/**.cpp", -- the Rive runtime source
+"../../test/**.cpp" -- the tests
}
-defines {"TESTING", "ENABLE_QUERY_FLAT_VERTICES", "WITH_RIVE_TOOLS"}
+defines {"TESTING", "ENABLE_QUERY_FLAT_VERTICES"}
filter "configurations:debug"
defines {"DEBUG"}
symbols "On"
filter "system:windows"
- flags { "FatalWarnings" }
- removebuildoptions {
- -- vs clang doesn't recognize these on windows
- "-fno-exceptions",
- "-fno-rtti",
- }
architecture "x64"
- defines {
- "_USE_MATH_DEFINES",
- "_CRT_SECURE_NO_WARNINGS"
- }
- buildoptions {WINDOWS_CLANG_CL_SUPPRESSED_WARNINGS}
+ defines {"_USE_MATH_DEFINES"}
+ buildoptions {WINDOWS_CLANG_CL_SUPPRESSED_WARNINGS}
\ No newline at end of file
#define _RIVE_ANIMATION_HPP_
#include "rive/generated/animation/animation_base.hpp"
namespace rive {
-class Animation : public AnimationBase {};
+ class Animation : public AnimationBase {};
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/animation_state_base.hpp"
#include <stdio.h>
namespace rive {
-class LinearAnimation;
-class ArtboardInstance;
-class StateMachineLayerImporter;
+ class LinearAnimation;
+ class ArtboardInstance;
+ class StateMachineLayerImporter;
-class AnimationState : public AnimationStateBase {
- friend class StateMachineLayerImporter;
+ class AnimationState : public AnimationStateBase {
+ friend class StateMachineLayerImporter;
-private:
- LinearAnimation* m_Animation = nullptr;
+ private:
+ LinearAnimation* m_Animation = nullptr;
-public:
- const LinearAnimation* animation() const { return m_Animation; }
-
- std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override;
-};
+ public:
+ const LinearAnimation* animation() const { return m_Animation; }
+ std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/linear_animation_instance.hpp"
namespace rive {
-class AnimationState;
+ class AnimationState;
-/// Represents an instance of an animation state.
-class AnimationStateInstance : public StateInstance {
-private:
- LinearAnimationInstance m_AnimationInstance;
- bool m_KeepGoing;
+ /// Represents an instance of an animation state.
+ class AnimationStateInstance : public StateInstance {
+ private:
+ LinearAnimationInstance m_AnimationInstance;
+ bool m_KeepGoing;
-public:
- AnimationStateInstance(const AnimationState* animationState, ArtboardInstance* instance);
+ public:
+ AnimationStateInstance(const AnimationState* animationState, ArtboardInstance* instance);
- void advance(float seconds, Span<SMIInput*>) override;
- void apply(float mix) override;
+ void advance(float seconds, Span<SMIInput*>) override;
+ void apply(float mix) override;
- bool keepGoing() const override;
+ bool keepGoing() const override;
- const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; }
+ const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; }
- LinearAnimationInstance* animationInstance() { return &m_AnimationInstance; }
-};
+ LinearAnimationInstance* animationInstance() { return &m_AnimationInstance; }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/any_state_base.hpp"
#include <stdio.h>
namespace rive {
-class AnyState : public AnyStateBase {
-public:
-};
+ class AnyState : public AnyStateBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_BLEND_ANIMATION_HPP_
#include "rive/generated/animation/blend_animation_base.hpp"
namespace rive {
-class LinearAnimation;
-class BlendAnimation : public BlendAnimationBase {
-private:
- LinearAnimation* m_Animation = nullptr;
+ class LinearAnimation;
+ class BlendAnimation : public BlendAnimationBase {
+ private:
+ LinearAnimation* m_Animation = nullptr;
-public:
- const LinearAnimation* animation() const { return m_Animation; }
- StatusCode import(ImportStack& importStack) override;
-};
+ public:
+ const LinearAnimation* animation() const { return m_Animation; }
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/blend_animation_1d_base.hpp"
#include <stdio.h>
namespace rive {
-class BlendAnimation1D : public BlendAnimation1DBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
-};
+ class BlendAnimation1D : public BlendAnimation1DBase {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/blend_animation_direct_base.hpp"
#include <stdio.h>
namespace rive {
-class BlendAnimationDirect : public BlendAnimationDirectBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
- StatusCode import(ImportStack& importStack) override;
-};
+ class BlendAnimationDirect : public BlendAnimationDirectBase {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <algorithm>
namespace rive {
-class BlendAnimation;
-class LayerStateImporter;
+ class BlendAnimation;
+ class LayerStateImporter;
-class BlendState : public BlendStateBase {
- friend class LayerStateImporter;
+ class BlendState : public BlendStateBase {
+ friend class LayerStateImporter;
-private:
- std::vector<BlendAnimation*> m_Animations;
- void addAnimation(BlendAnimation* animation);
+ private:
+ std::vector<BlendAnimation*> m_Animations;
+ void addAnimation(BlendAnimation* animation);
-public:
- ~BlendState() override;
- inline const std::vector<BlendAnimation*>& animations() const { return m_Animations; }
+ public:
+ ~BlendState();
+ inline const std::vector<BlendAnimation*>& animations() const { return m_Animations; }
#ifdef TESTING
- size_t animationCount() { return m_Animations.size(); }
- BlendAnimation* animation(size_t index) { return m_Animations[index]; }
+ size_t animationCount() { return m_Animations.size(); }
+ BlendAnimation* animation(size_t index) { return m_Animations[index]; }
#endif
-};
+ };
} // namespace rive
#endif
#include "rive/generated/animation/blend_state_1d_base.hpp"
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.
- const uint32_t noInputSpecified = -1;
- bool hasValidInputId() const { return inputId() != noInputSpecified; }
+ class BlendState1D : public BlendState1DBase {
+ public:
+ // -1 (4294967295) is our flag value for input not set. It means it wasn't set at edit
+ // time.
+ const uint32_t noInputSpecified = -1;
+ bool hasValidInputId() const { return inputId() != noInputSpecified; }
- StatusCode import(ImportStack& importStack) override;
+ StatusCode import(ImportStack& importStack) override;
- std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override;
-};
+ std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/blend_animation_1d.hpp"
namespace rive {
-class BlendState1DInstance : public BlendStateInstance<BlendState1D, BlendAnimation1D> {
-private:
- BlendStateAnimationInstance<BlendAnimation1D>* m_From = nullptr;
- BlendStateAnimationInstance<BlendAnimation1D>* m_To = nullptr;
- int animationIndex(float value);
+ class BlendState1DInstance : public BlendStateInstance<BlendState1D, BlendAnimation1D> {
+ private:
+ BlendStateAnimationInstance<BlendAnimation1D>* m_From = nullptr;
+ BlendStateAnimationInstance<BlendAnimation1D>* m_To = nullptr;
+ int animationIndex(float value);
-public:
- BlendState1DInstance(const BlendState1D* blendState, ArtboardInstance* instance);
- void advance(float seconds, Span<SMIInput*> inputs) override;
-};
+ public:
+ BlendState1DInstance(const BlendState1D* blendState, ArtboardInstance* instance);
+ void advance(float seconds, Span<SMIInput*> inputs) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/blend_state_direct_base.hpp"
#include <stdio.h>
namespace rive {
-class BlendStateDirect : public BlendStateDirectBase {
-public:
- std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override;
-};
+ class BlendStateDirect : public BlendStateDirectBase {
+ public:
+ std::unique_ptr<StateInstance> makeInstance(ArtboardInstance*) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/blend_animation_direct.hpp"
namespace rive {
-class BlendStateDirectInstance : public BlendStateInstance<BlendStateDirect, BlendAnimationDirect> {
-public:
- BlendStateDirectInstance(const BlendStateDirect* blendState, ArtboardInstance* instance);
- void advance(float seconds, Span<SMIInput*> inputs) override;
-};
+ class BlendStateDirectInstance
+ : public BlendStateInstance<BlendStateDirect, BlendAnimationDirect> {
+ public:
+ BlendStateDirectInstance(const BlendStateDirect* blendState, ArtboardInstance* instance);
+ void advance(float seconds, Span<SMIInput*> inputs) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/linear_animation_instance.hpp"
namespace rive {
-class AnimationState;
+ class AnimationState;
-template <class K, class T> class BlendStateInstance;
-template <class T> class BlendStateAnimationInstance {
- template <class A, class B> friend class BlendStateInstance;
+ template <class K, class T> class BlendStateInstance;
+ template <class T> class BlendStateAnimationInstance {
+ template <class A, class B> friend class BlendStateInstance;
-private:
- const T* m_BlendAnimation;
- LinearAnimationInstance m_AnimationInstance;
- float m_Mix = 0.0f;
+ private:
+ const T* m_BlendAnimation;
+ LinearAnimationInstance m_AnimationInstance;
+ float m_Mix = 0.0f;
-public:
- const T* blendAnimation() const { return m_BlendAnimation; }
- const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; }
+ public:
+ const T* blendAnimation() const { return m_BlendAnimation; }
+ const LinearAnimationInstance* animationInstance() const { return &m_AnimationInstance; }
- BlendStateAnimationInstance(const T* blendAnimation, ArtboardInstance* instance) :
- m_BlendAnimation(blendAnimation),
- m_AnimationInstance(blendAnimation->animation(), instance) {}
+ BlendStateAnimationInstance(const T* blendAnimation, ArtboardInstance* instance) :
+ m_BlendAnimation(blendAnimation),
+ m_AnimationInstance(blendAnimation->animation(), instance)
+ {}
- void mix(float value) { m_Mix = value; }
-};
+ void mix(float value) { m_Mix = value; }
+ };
-template <class K, class T> class BlendStateInstance : public StateInstance {
-protected:
- std::vector<BlendStateAnimationInstance<T>> m_AnimationInstances;
- bool m_KeepGoing = true;
+ 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) {
- m_AnimationInstances.reserve(blendState->animations().size());
-
- for (auto blendAnimation : blendState->animations()) {
- m_AnimationInstances.emplace_back(
- BlendStateAnimationInstance<T>(static_cast<T*>(blendAnimation), instance));
+ public:
+ BlendStateInstance(const K* blendState, ArtboardInstance* instance) : StateInstance(blendState) {
+ for (auto blendAnimation : blendState->animations()) {
+ m_AnimationInstances.emplace_back(
+ BlendStateAnimationInstance<T>(static_cast<T*>(blendAnimation), instance));
+ }
}
- }
- bool keepGoing() const override { return m_KeepGoing; }
+ bool keepGoing() const override { return m_KeepGoing; }
- void advance(float seconds, Span<SMIInput*>) override {
- m_KeepGoing = false;
- for (auto& animation : m_AnimationInstances) {
- if (animation.m_AnimationInstance.advance(seconds)) {
- m_KeepGoing = true;
+ void advance(float seconds, Span<SMIInput*>) override {
+ m_KeepGoing = false;
+ for (auto& animation : m_AnimationInstances) {
+ if (animation.m_AnimationInstance.advance(seconds)) {
+ m_KeepGoing = true;
+ }
}
}
- }
- void apply(float mix) override {
- for (auto& animation : m_AnimationInstances) {
- float m = mix * animation.m_Mix;
- animation.m_AnimationInstance.apply(m);
+ 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) {
- return animation.animationInstance();
+ // 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) {
+ return animation.animationInstance();
+ }
}
+ return nullptr;
}
- return nullptr;
- }
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/blend_state_transition_base.hpp"
#include <stdio.h>
namespace rive {
-class BlendAnimation;
-class LayerStateImporter;
-class BlendStateTransition : public BlendStateTransitionBase {
- friend class LayerStateImporter;
+ class BlendAnimation;
+ class LayerStateImporter;
+ class BlendStateTransition : public BlendStateTransitionBase {
+ friend class LayerStateImporter;
-private:
- BlendAnimation* m_ExitBlendAnimation = nullptr;
+ private:
+ BlendAnimation* m_ExitBlendAnimation = nullptr;
-public:
- BlendAnimation* exitBlendAnimation() const { return m_ExitBlendAnimation; }
+ public:
+ BlendAnimation* exitBlendAnimation() const { return m_ExitBlendAnimation; }
- const LinearAnimationInstance*
- exitTimeAnimationInstance(const StateInstance* from) const override;
+ const LinearAnimationInstance*
+ exitTimeAnimationInstance(const StateInstance* from) const override;
- const LinearAnimation* exitTimeAnimation(const LayerState* from) const override;
-};
+ const LinearAnimation* exitTimeAnimation(const LayerState* from) const override;
+ };
} // namespace rive
#define _RIVE_CUBIC_INTERPOLATOR_HPP_
#include "rive/generated/animation/cubic_interpolator_base.hpp"
namespace rive {
-class CubicInterpolator : public CubicInterpolatorBase {
-private:
- static constexpr int SplineTableSize = 11;
- static constexpr float SampleStepSize = 1.0f / (SplineTableSize - 1.0f);
- float m_Values[SplineTableSize];
+ class CubicInterpolator : public CubicInterpolatorBase {
+ private:
+ static constexpr int SplineTableSize = 11;
+ static constexpr float SampleStepSize = 1.0f / (SplineTableSize - 1.0f);
+ float m_Values[SplineTableSize];
- float getT(float x) const;
+ float getT(float x) const;
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
- /// Convert a linear interpolation factor to an eased one.
- float transform(float value) const;
+ /// Convert a linear interpolation factor to an eased one.
+ float transform(float value) const;
- StatusCode import(ImportStack& importStack) override;
-};
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/entry_state_base.hpp"
#include <stdio.h>
namespace rive {
-class EntryState : public EntryStateBase {
-public:
-};
+ class EntryState : public EntryStateBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_BOOL_CHANGE_HPP_
+#define _RIVE_EVENT_BOOL_CHANGE_HPP_
+#include "rive/generated/animation/event_bool_change_base.hpp"
+
+namespace rive {
+ class EventBoolChange : public EventBoolChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance) const override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_INPUT_CHANGE_HPP_
+#define _RIVE_EVENT_INPUT_CHANGE_HPP_
+#include "rive/generated/animation/event_input_change_base.hpp"
+
+namespace rive {
+ class StateMachineInstance;
+ class StateMachineInput;
+ class EventInputChange : public EventInputChangeBase {
+ public:
+ StatusCode import(ImportStack& importStack) override;
+ virtual void perform(StateMachineInstance* stateMachineInstance) const = 0;
+ virtual bool validateInputType(const StateMachineInput* input) const { return true; }
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_NUMBER_CHANGE_HPP_
+#define _RIVE_EVENT_NUMBER_CHANGE_HPP_
+#include "rive/generated/animation/event_number_change_base.hpp"
+
+namespace rive {
+ class EventNumberChange : public EventNumberChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance) const override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_TRIGGER_CHANGE_HPP_
+#define _RIVE_EVENT_TRIGGER_CHANGE_HPP_
+#include "rive/generated/animation/event_trigger_change_base.hpp"
+
+namespace rive {
+ class EventTriggerChange : public EventTriggerChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance) const override;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
#include "rive/generated/animation/exit_state_base.hpp"
#include <stdio.h>
namespace rive {
-class ExitState : public ExitStateBase {
-public:
-};
+ class ExitState : public ExitStateBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/keyed_object_base.hpp"
#include <vector>
namespace rive {
-class Artboard;
-class KeyedProperty;
-class KeyedObject : public KeyedObjectBase {
-private:
- std::vector<std::unique_ptr<KeyedProperty>> m_KeyedProperties;
+ class Artboard;
+ class KeyedProperty;
+ class KeyedObject : public KeyedObjectBase {
+ private:
+ std::vector<std::unique_ptr<KeyedProperty>> m_KeyedProperties;
-public:
- KeyedObject();
- ~KeyedObject() override;
- void addKeyedProperty(std::unique_ptr<KeyedProperty>);
+ public:
+ KeyedObject();
+ ~KeyedObject();
+ void addKeyedProperty(std::unique_ptr<KeyedProperty>);
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
- void apply(Artboard* coreContext, float time, float mix);
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ void apply(Artboard* coreContext, float time, float mix);
- StatusCode import(ImportStack& importStack) override;
-};
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/keyed_property_base.hpp"
#include <vector>
namespace rive {
-class KeyFrame;
-class KeyedProperty : public KeyedPropertyBase {
-private:
- std::vector<std::unique_ptr<KeyFrame>> m_KeyFrames;
+ class KeyFrame;
+ class KeyedProperty : public KeyedPropertyBase {
+ private:
+ std::vector<std::unique_ptr<KeyFrame>> m_KeyFrames;
-public:
- KeyedProperty();
- ~KeyedProperty() override;
- void addKeyFrame(std::unique_ptr<KeyFrame>);
- StatusCode onAddedClean(CoreContext* context) override;
- StatusCode onAddedDirty(CoreContext* context) override;
+ public:
+ KeyedProperty();
+ ~KeyedProperty();
+ void addKeyFrame(std::unique_ptr<KeyFrame>);
+ StatusCode onAddedClean(CoreContext* context) override;
+ StatusCode onAddedDirty(CoreContext* context) override;
- void apply(Core* object, float time, float mix);
+ void apply(Core* object, float time, float mix);
- StatusCode import(ImportStack& importStack) override;
-};
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_KEY_FRAME_HPP_
#include "rive/generated/animation/keyframe_base.hpp"
namespace rive {
-class CubicInterpolator;
+ class CubicInterpolator;
-class KeyFrame : public KeyFrameBase {
-private:
- CubicInterpolator* m_Interpolator = nullptr;
- float m_Seconds;
+ class KeyFrame : public KeyFrameBase {
+ private:
+ CubicInterpolator* m_Interpolator = nullptr;
+ float m_Seconds;
-public:
- inline float seconds() const { return m_Seconds; }
- inline CubicInterpolator* interpolator() const { return m_Interpolator; }
+ public:
+ inline float seconds() const { return m_Seconds; }
+ inline CubicInterpolator* interpolator() const { return m_Interpolator; }
- void computeSeconds(int fps);
+ void computeSeconds(int fps);
- StatusCode onAddedDirty(CoreContext* context) override;
- virtual void apply(Core* object, int propertyKey, float mix) = 0;
- virtual void applyInterpolation(Core* object,
- int propertyKey,
- float seconds,
- const KeyFrame* nextFrame,
- float mix) = 0;
+ StatusCode onAddedDirty(CoreContext* context) override;
+ virtual void apply(Core* object, int propertyKey, float mix) = 0;
+ virtual void applyInterpolation(
+ Core* object, int propertyKey, float seconds, const KeyFrame* nextFrame, float mix) = 0;
- StatusCode import(ImportStack& importStack) override;
-};
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/keyframe_bool_base.hpp"
#include <stdio.h>
namespace rive {
-class KeyFrameBool : public KeyFrameBoolBase {
-public:
- void apply(Core* object, int propertyKey, float mix) override;
- void applyInterpolation(Core* object,
- int propertyKey,
- float seconds,
- const KeyFrame* nextFrame,
- float mix) override;
-};
+ class KeyFrameBool : public KeyFrameBoolBase {
+ public:
+ void apply(Core* object, int propertyKey, float mix) override;
+ void applyInterpolation(Core* object,
+ int propertyKey,
+ float seconds,
+ const KeyFrame* nextFrame,
+ float mix) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_KEY_FRAME_COLOR_HPP_
#include "rive/generated/animation/keyframe_color_base.hpp"
namespace rive {
-class KeyFrameColor : public KeyFrameColorBase {
-public:
- void apply(Core* object, int propertyKey, float mix) override;
- void applyInterpolation(Core* object,
- int propertyKey,
- float seconds,
- const KeyFrame* nextFrame,
- float mix) override;
-};
+ class KeyFrameColor : public KeyFrameColorBase {
+ public:
+ void apply(Core* object, int propertyKey, float mix) override;
+ void applyInterpolation(Core* object,
+ int propertyKey,
+ float seconds,
+ const KeyFrame* nextFrame,
+ float mix) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_KEY_FRAME_DOUBLE_HPP_
#include "rive/generated/animation/keyframe_double_base.hpp"
namespace rive {
-class KeyFrameDouble : public KeyFrameDoubleBase {
-public:
- void apply(Core* object, int propertyKey, float mix) override;
- void applyInterpolation(Core* object,
- int propertyKey,
- float seconds,
- const KeyFrame* nextFrame,
- float mix) override;
-};
+ class KeyFrameDouble : public KeyFrameDoubleBase {
+ public:
+ void apply(Core* object, int propertyKey, float mix) override;
+ void applyInterpolation(Core* object,
+ int propertyKey,
+ float seconds,
+ const KeyFrame* nextFrame,
+ float mix) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/keyframe_id_base.hpp"
#include <stdio.h>
namespace rive {
-class KeyFrameId : public KeyFrameIdBase {
-public:
- void apply(Core* object, int propertyKey, float mix) override;
- void applyInterpolation(Core* object,
- int propertyKey,
- float seconds,
- const KeyFrame* nextFrame,
- float mix) override;
-};
+ class KeyFrameId : public KeyFrameIdBase {
+ public:
+ void apply(Core* object, int propertyKey, float mix) override;
+ void applyInterpolation(Core* object,
+ int propertyKey,
+ float seconds,
+ const KeyFrame* nextFrame,
+ float mix) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class ArtboardInstance;
-class StateTransition;
-class LayerStateImporter;
-class StateMachineLayerImporter;
-class StateInstance;
-
-class LayerState : public LayerStateBase {
- friend class LayerStateImporter;
- friend class StateMachineLayerImporter;
-
-private:
- std::vector<StateTransition*> m_Transitions;
- void addTransition(StateTransition* transition);
-
-public:
- ~LayerState() override;
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
-
- StatusCode import(ImportStack& importStack) override;
-
- size_t transitionCount() const { return m_Transitions.size(); }
- StateTransition* transition(size_t index) const {
- if (index < m_Transitions.size()) {
- return m_Transitions[index];
+ class ArtboardInstance;
+ class StateTransition;
+ class LayerStateImporter;
+ class StateMachineLayerImporter;
+ class StateInstance;
+
+ class LayerState : public LayerStateBase {
+ friend class LayerStateImporter;
+ friend class StateMachineLayerImporter;
+
+ private:
+ std::vector<StateTransition*> m_Transitions;
+ void addTransition(StateTransition* transition);
+
+ public:
+ ~LayerState();
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+
+ StatusCode import(ImportStack& importStack) override;
+
+ size_t transitionCount() const { return m_Transitions.size(); }
+ StateTransition* transition(size_t index) const {
+ if (index < m_Transitions.size()) {
+ return m_Transitions[index];
+ }
+ return nullptr;
}
- return nullptr;
- }
- /// Make an instance of this state that can be advanced and applied by
- /// the state machine when it is active or being transitioned from.
- virtual std::unique_ptr<StateInstance> makeInstance(ArtboardInstance* instance) const;
-};
+ /// Make an instance of this state that can be advanced and applied by
+ /// the state machine when it is active or being transitioned from.
+ virtual std::unique_ptr<StateInstance> makeInstance(ArtboardInstance* instance) const;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/linear_animation_base.hpp"
#include <vector>
namespace rive {
-class Artboard;
-class KeyedObject;
+ class Artboard;
+ class KeyedObject;
-class LinearAnimation : public LinearAnimationBase {
-private:
- std::vector<std::unique_ptr<KeyedObject>> m_KeyedObjects;
+ class LinearAnimation : public LinearAnimationBase {
+ private:
+ std::vector< std::unique_ptr<KeyedObject> > m_KeyedObjects;
- friend class Artboard;
+ friend class Artboard;
-public:
- LinearAnimation();
- ~LinearAnimation() override;
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
- void addKeyedObject(std::unique_ptr<KeyedObject>);
- void apply(Artboard* artboard, float time, float mix = 1.0f) const;
+ public:
+ LinearAnimation();
+ ~LinearAnimation() override;
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ void addKeyedObject(std::unique_ptr<KeyedObject>);
+ void apply(Artboard* artboard, float time, float mix = 1.0f) const;
- Loop loop() const { return (Loop)loopValue(); }
+ Loop loop() const { return (Loop)loopValue(); }
- StatusCode import(ImportStack& importStack) override;
+ StatusCode import(ImportStack& importStack) override;
- float startSeconds() const;
- float endSeconds() const;
- float durationSeconds() const;
+ float startSeconds() const;
+ float endSeconds() const;
+ float durationSeconds() const;
- /// Convert a global clock to local seconds (takes into consideration
- /// work area start/end, speed, looping).
- float globalToLocalSeconds(float seconds) const;
+ /// Convert a global clock to local seconds (takes into consideration
+ /// work area start/end, speed, looping).
+ float globalToLocalSeconds(float seconds) const;
#ifdef TESTING
- size_t numKeyedObjects() { return m_KeyedObjects.size(); }
- // Used in testing to check how many animations gets deleted.
- static int deleteCount;
+ size_t numKeyedObjects() { return m_KeyedObjects.size(); }
+ // Used in testing to check how many animations gets deleted.
+ static int deleteCount;
#endif
-};
+ };
} // namespace rive
#endif
#include "rive/scene.hpp"
namespace rive {
-class LinearAnimation;
-
-class LinearAnimationInstance : public Scene {
-private:
- const LinearAnimation* m_Animation = nullptr;
- float m_Time;
- float m_TotalTime;
- float m_LastTotalTime;
- float m_SpilledTime;
- int m_Direction;
- bool m_DidLoop;
- int m_LoopValue = -1;
-
-public:
- LinearAnimationInstance(const LinearAnimation*, ArtboardInstance*);
- LinearAnimationInstance(LinearAnimationInstance const&);
- ~LinearAnimationInstance() override;
-
- // Advance the animation by the specified time. Returns true if the
- // animation will continue to animate after this advance.
- bool advance(float seconds);
-
- // Returns a pointer to the instance's animation
- const LinearAnimation* animation() const { return m_Animation; }
-
- // Returns the current point in time at which this instance has advance
- // to
- float time() const { return m_Time; }
-
- // Returns the direction that we are currently playing in
- int direction() const { return m_Direction; }
-
- // Update the direction of the animation instance, positive value for
- // forwards Negative for backwards
- void direction(int direction) {
- if (direction > 0) {
- m_Direction = 1;
- } else {
- m_Direction = -1;
+ class LinearAnimation;
+
+ class LinearAnimationInstance : public Scene {
+ private:
+ const LinearAnimation* m_Animation = nullptr;
+ float m_Time;
+ float m_TotalTime;
+ float m_LastTotalTime;
+ float m_SpilledTime;
+ int m_Direction;
+ bool m_DidLoop;
+ int m_LoopValue = -1;
+
+ public:
+ LinearAnimationInstance(const LinearAnimation*, ArtboardInstance*);
+
+ // Advance the animation by the specified time. Returns true if the
+ // animation will continue to animate after this advance.
+ bool advance(float seconds);
+
+ // Returns a pointer to the instance's animation
+ const LinearAnimation* animation() const { return m_Animation; }
+
+ // Returns the current point in time at which this instance has advance
+ // to
+ float time() const { return m_Time; }
+
+ // Returns the direction that we are currently playing in
+ float direction() const { return m_Direction; }
+
+ // Update the direction of the animation instance, positive value for
+ // forwards Negative for backwards
+ void direction(int direction) {
+ if (direction > 0) {
+ m_Direction = 1;
+ } else {
+ m_Direction = -1;
+ }
}
- }
-
- // Sets the animation's point in time.
- void time(float value);
-
- // Applies the animation instance to its artboard instance. The mix (a value
- // between 0 and 1) is the strength at which the animation is mixed with
- // other animations applied to the artboard.
- void apply(float mix = 1.0f) const { m_Animation->apply(m_ArtboardInstance, m_Time, mix); }
- // Set when the animation is advanced, true if the animation has stopped
- // (oneShot), reached the end (loop), or changed direction (pingPong)
- bool didLoop() const { return m_DidLoop; }
+ // Sets the animation's point in time.
+ void time(float value);
- float totalTime() const { return m_TotalTime; }
- float lastTotalTime() const { return m_LastTotalTime; }
- float spilledTime() const { return m_SpilledTime; }
- float durationSeconds() const override;
-
- // Forwarded from animation
- uint32_t fps() const;
- uint32_t duration() const;
- float speed() const;
- float startSeconds() const;
-
- // Returns either the animation's default or overridden loop values
- Loop loop() const override { return (Loop)loopValue(); }
- int loopValue() const;
- // Override the animation's default loop
- void loopValue(int value);
+ // Applies the animation instance to its artboard instance. The mix (a value
+ // between 0 and 1) is the strength at which the animation is mixed with
+ // other animations applied to the artboard.
+ void apply(float mix = 1.0f) const {
+ m_Animation->apply(m_ArtboardInstance, m_Time, mix);
+ }
- bool isTranslucent() const override;
- bool advanceAndApply(float seconds) override;
- std::string name() const override;
-};
+ // Set when the animation is advanced, true if the animation has stopped
+ // (oneShot), reached the end (loop), or changed direction (pingPong)
+ bool didLoop() const { return m_DidLoop; }
+
+ float totalTime() const { return m_TotalTime; }
+ float lastTotalTime() const { return m_LastTotalTime; }
+ float spilledTime() const { return m_SpilledTime; }
+ float durationSeconds() const override;
+
+ // Forwarded from animation
+ uint32_t fps() const;
+ uint32_t duration() const;
+ float speed() const;
+ float startSeconds() const;
+
+ // Returns either the animation's default or overridden loop values
+ Loop loop() const override { return (Loop)loopValue(); }
+ int loopValue() const;
+ // Override the animation's default loop
+ void loopValue(int value);
+
+ bool isTranslucent() const override;
+ bool advanceAndApply(float seconds) override;
+ std::string name() const override;
+ };
} // namespace rive
-#endif
+#endif
\ No newline at end of file
#include "rive/math/vec2d.hpp"
namespace rive {
-class StateMachineInstance;
-class ListenerAction : public ListenerActionBase {
-public:
- StatusCode import(ImportStack& importStack) override;
- virtual void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const = 0;
-};
+ class StateMachineInstance;
+ class ListenerAction : public ListenerActionBase {
+ public:
+ StatusCode import(ImportStack& importStack) override;
+ virtual void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const = 0;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/listener_align_target_base.hpp"
#include <stdio.h>
namespace rive {
-class ListenerAlignTarget : public ListenerAlignTargetBase {
-public:
- void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
-};
+ class ListenerAlignTarget : public ListenerAlignTargetBase {
+ public:
+ void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/listener_bool_change_base.hpp"
namespace rive {
-class ListenerBoolChange : public ListenerBoolChangeBase {
-public:
- bool validateInputType(const StateMachineInput* input) const override;
- void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
-};
+ class ListenerBoolChange : public ListenerBoolChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/listener_input_change_base.hpp"
namespace rive {
-class StateMachineInput;
-class ListenerInputChange : public ListenerInputChangeBase {
-public:
- StatusCode import(ImportStack& importStack) override;
- virtual bool validateInputType(const StateMachineInput* input) const { return true; }
-};
+ class StateMachineInput;
+ class ListenerInputChange : public ListenerInputChangeBase {
+ public:
+ StatusCode import(ImportStack& importStack) override;
+ virtual bool validateInputType(const StateMachineInput* input) const { return true; }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/listener_number_change_base.hpp"
namespace rive {
-class ListenerNumberChange : public ListenerNumberChangeBase {
-public:
- bool validateInputType(const StateMachineInput* input) const override;
- void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
-};
+ class ListenerNumberChange : public ListenerNumberChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/listener_trigger_change_base.hpp"
namespace rive {
-class ListenerTriggerChange : public ListenerTriggerChangeBase {
-public:
- bool validateInputType(const StateMachineInput* input) const override;
- void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
-};
+ class ListenerTriggerChange : public ListenerTriggerChangeBase {
+ public:
+ bool validateInputType(const StateMachineInput* input) const override;
+ void perform(StateMachineInstance* stateMachineInstance, Vec2D position) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_LOOP_HPP_
#define _RIVE_LOOP_HPP_
namespace rive {
-/// Loop options for linear animations.
-enum class Loop : unsigned int {
- /// Play until the duration or end of work area of the animation.
- oneShot = 0,
+ /// Loop options for linear animations.
+ enum class Loop : unsigned int {
+ /// Play until the duration or end of work area of the animation.
+ oneShot = 0,
- /// Play until the duration or end of work area of the animation and
- /// then go back to the start (0 seconds).
- loop = 1,
+ /// Play until the duration or end of work area of the animation and
+ /// then go back to the start (0 seconds).
+ loop = 1,
- /// Play to the end of the duration/work area and then play back.
- pingPong = 2
-};
+ /// Play to the end of the duration/work area and then play back.
+ pingPong = 2
+ };
} // namespace rive
#endif
#include "rive/generated/animation/nested_bool_base.hpp"
#include <stdio.h>
namespace rive {
-class NestedBool : public NestedBoolBase {
-public:
-};
+ class NestedBool : public NestedBoolBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/nested_input_base.hpp"
#include <stdio.h>
namespace rive {
-class NestedInput : public NestedInputBase {
-public:
-};
+ class NestedInput : public NestedInputBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/nested_linear_animation_base.hpp"
#include <stdio.h>
namespace rive {
-class LinearAnimationInstance;
-class NestedLinearAnimation : public NestedLinearAnimationBase {
-protected:
- std::unique_ptr<LinearAnimationInstance> m_AnimationInstance;
+ class LinearAnimationInstance;
+ class NestedLinearAnimation : public NestedLinearAnimationBase {
+ protected:
+ std::unique_ptr<LinearAnimationInstance> m_AnimationInstance;
-public:
- NestedLinearAnimation();
- ~NestedLinearAnimation() override;
+ public:
+ NestedLinearAnimation();
+ ~NestedLinearAnimation() override;
- void initializeAnimation(ArtboardInstance*) override;
-};
+ void initializeAnimation(ArtboardInstance*) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/nested_number_base.hpp"
#include <stdio.h>
namespace rive {
-class NestedNumber : public NestedNumberBase {
-public:
-};
+ class NestedNumber : public NestedNumberBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/nested_remap_animation_base.hpp"
#include <stdio.h>
namespace rive {
-class NestedRemapAnimation : public NestedRemapAnimationBase {
-public:
- void timeChanged() override;
- void advance(float elapsedSeconds) override;
- void initializeAnimation(ArtboardInstance*) override;
-};
+ class NestedRemapAnimation : public NestedRemapAnimationBase {
+ public:
+ void timeChanged() override;
+ void advance(float elapsedSeconds) override;
+ void initializeAnimation(ArtboardInstance*) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/nested_simple_animation_base.hpp"
#include <stdio.h>
namespace rive {
-class NestedSimpleAnimation : public NestedSimpleAnimationBase {
-public:
- void advance(float elapsedSeconds) override;
-};
+ class NestedSimpleAnimation : public NestedSimpleAnimationBase {
+ public:
+ void advance(float elapsedSeconds) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_NESTED_STATE_MACHINE_HPP_
#define _RIVE_NESTED_STATE_MACHINE_HPP_
#include "rive/generated/animation/nested_state_machine_base.hpp"
-#include "rive/math/vec2d.hpp"
-#include <memory>
-
+#include <stdio.h>
namespace rive {
-class ArtboardInstance;
-class StateMachineInstance;
-class NestedStateMachine : public NestedStateMachineBase {
-private:
- std::unique_ptr<StateMachineInstance> m_StateMachineInstance;
-
-public:
- NestedStateMachine();
- ~NestedStateMachine() override;
- void advance(float elapsedSeconds) override;
- void initializeAnimation(ArtboardInstance*) override;
- StateMachineInstance* stateMachineInstance();
+ class ArtboardInstance;
- void pointerMove(Vec2D position);
- void pointerDown(Vec2D position);
- void pointerUp(Vec2D position);
-};
+ class NestedStateMachine : public NestedStateMachineBase {
+ public:
+ void advance(float elapsedSeconds) override;
+ void initializeAnimation(ArtboardInstance*) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/nested_trigger_base.hpp"
#include <stdio.h>
namespace rive {
-class NestedTrigger : public NestedTriggerBase {
-public:
-};
+ class NestedTrigger : public NestedTriggerBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/span.hpp"
namespace rive {
-class LayerState;
-class SMIInput;
-class ArtboardInstance;
+ class LayerState;
+ class SMIInput;
+ class ArtboardInstance;
-/// Represents an instance of a state tracked by the State Machine.
-class StateInstance {
-private:
- const LayerState* m_LayerState;
+ /// Represents an instance of a state tracked by the State Machine.
+ class StateInstance {
+ private:
+ const LayerState* m_LayerState;
-public:
- StateInstance(const LayerState* layerState);
- virtual ~StateInstance();
- virtual void advance(float seconds, Span<SMIInput*> inputs) = 0;
- virtual void apply(float mix) = 0;
+ public:
+ StateInstance(const LayerState* layerState);
+ virtual ~StateInstance();
+ virtual void advance(float seconds, Span<SMIInput*> inputs) = 0;
+ virtual void apply(float mix) = 0;
- /// Returns true when the State Machine needs to keep advancing this
- /// state.
- virtual bool keepGoing() const = 0;
+ /// Returns true when the State Machine needs to keep advancing this
+ /// state.
+ virtual bool keepGoing() const = 0;
- const LayerState* state() const;
-};
+ const LayerState* state() const;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class StateMachineLayer;
-class StateMachineInput;
-class StateMachineListener;
-class StateMachineImporter;
-class StateMachine : public StateMachineBase {
- friend class StateMachineImporter;
-
-private:
- std::vector<std::unique_ptr<StateMachineLayer>> m_Layers;
- std::vector<std::unique_ptr<StateMachineInput>> m_Inputs;
- std::vector<std::unique_ptr<StateMachineListener>> m_Listeners;
-
- void addLayer(std::unique_ptr<StateMachineLayer>);
- void addInput(std::unique_ptr<StateMachineInput>);
- void addListener(std::unique_ptr<StateMachineListener>);
-
-public:
- StateMachine();
- ~StateMachine() override;
-
- StatusCode import(ImportStack& importStack) override;
-
- size_t layerCount() const { return m_Layers.size(); }
- size_t inputCount() const { return m_Inputs.size(); }
- size_t listenerCount() const { return m_Listeners.size(); }
-
- const StateMachineInput* input(std::string name) const;
- const StateMachineInput* input(size_t index) const;
- const StateMachineLayer* layer(std::string name) const;
- const StateMachineLayer* layer(size_t index) const;
- const StateMachineListener* listener(size_t index) const;
-
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
-};
+ class StateMachineLayer;
+ class StateMachineInput;
+ class StateMachineEvent;
+ class StateMachineImporter;
+ class StateMachine : public StateMachineBase {
+ friend class StateMachineImporter;
+
+ private:
+ std::vector<std::unique_ptr<StateMachineLayer>> m_Layers;
+ std::vector<std::unique_ptr<StateMachineInput>> m_Inputs;
+ std::vector<std::unique_ptr<StateMachineEvent>> m_Events;
+
+ void addLayer(std::unique_ptr<StateMachineLayer>);
+ void addInput(std::unique_ptr<StateMachineInput>);
+ void addEvent(std::unique_ptr<StateMachineEvent>);
+
+ public:
+ StateMachine();
+ ~StateMachine();
+
+ StatusCode import(ImportStack& importStack) override;
+
+ size_t layerCount() const { return m_Layers.size(); }
+ size_t inputCount() const { return m_Inputs.size(); }
+ size_t eventCount() const { return m_Events.size(); }
+
+ const StateMachineInput* input(std::string name) const;
+ const StateMachineInput* input(size_t index) const;
+ const StateMachineLayer* layer(std::string name) const;
+ const StateMachineLayer* layer(size_t index) const;
+ const StateMachineEvent* event(size_t index) const;
+
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/state_machine_bool_base.hpp"
#include <stdio.h>
namespace rive {
-class StateMachineBool : public StateMachineBoolBase {
-public:
-};
+ class StateMachineBool : public StateMachineBoolBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/state_machine_component_base.hpp"
#include <stdio.h>
namespace rive {
-class StateMachineComponent : public StateMachineComponentBase {
-public:
-};
+ class StateMachineComponent : public StateMachineComponentBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_EVENT_HPP_
+#define _RIVE_STATE_MACHINE_EVENT_HPP_
+#include "rive/generated/animation/state_machine_event_base.hpp"
+#include "rive/event_type.hpp"
+
+namespace rive {
+ class Shape;
+ class StateMachineEventImporter;
+ class EventInputChange;
+ class StateMachineInstance;
+ class StateMachineEvent : public StateMachineEventBase {
+ friend class StateMachineEventImporter;
+
+ private:
+ std::vector<uint32_t> m_HitShapesIds;
+ std::vector<EventInputChange*> m_InputChanges;
+ void addInputChange(EventInputChange* inputChange);
+
+ public:
+ EventType eventType() const { return (EventType)eventTypeValue(); }
+ size_t inputChangeCount() const { return m_InputChanges.size(); }
+ const EventInputChange* inputChange(size_t index) const;
+ StatusCode import(ImportStack& importStack) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+
+ const std::vector<uint32_t>& hitShapeIds() const { return m_HitShapesIds; }
+ void performChanges(StateMachineInstance* stateMachineInstance) const;
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
#include "rive/generated/animation/state_machine_input_base.hpp"
#include <stdio.h>
namespace rive {
-class StateMachineInput : public StateMachineInputBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
- StatusCode import(ImportStack& importStack) override;
-};
+ class StateMachineInput : public StateMachineInputBase {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <stdint.h>
namespace rive {
-class StateMachineInstance;
-class StateMachineInput;
-class StateMachineBool;
-class StateMachineNumber;
-class StateMachineTrigger;
-class TransitionTriggerCondition;
-class StateMachineLayerInstance;
+ class StateMachineInstance;
+ class StateMachineInput;
+ class StateMachineBool;
+ class StateMachineNumber;
+ class StateMachineTrigger;
+ class TransitionTriggerCondition;
+ class StateMachineLayerInstance;
-class SMIInput {
- friend class StateMachineInstance;
- friend class StateMachineLayerInstance;
+ class SMIInput {
+ friend class StateMachineInstance;
+ friend class StateMachineLayerInstance;
-private:
- StateMachineInstance* m_MachineInstance;
- const StateMachineInput* m_Input;
+ private:
+ StateMachineInstance* m_MachineInstance;
+ const StateMachineInput* m_Input;
- virtual void advanced() {}
+ virtual void advanced() {}
-protected:
- void valueChanged();
+ protected:
+ void valueChanged();
- SMIInput(const StateMachineInput* input, StateMachineInstance* machineInstance);
+ SMIInput(const StateMachineInput* input, StateMachineInstance* machineInstance);
-public:
- virtual ~SMIInput() {}
- const StateMachineInput* input() const { return m_Input; }
+ public:
+ virtual ~SMIInput() {}
+ const StateMachineInput* input() const { return m_Input; }
- const std::string& name() const;
- uint16_t inputCoreType() const;
-};
+ const std::string& name() const;
+ uint16_t inputCoreType() const;
+ };
-class SMIBool : public SMIInput {
- friend class StateMachineInstance;
+ class SMIBool : public SMIInput {
+ friend class StateMachineInstance;
-private:
- bool m_Value;
+ private:
+ bool m_Value;
- SMIBool(const StateMachineBool* input, StateMachineInstance* machineInstance);
+ SMIBool(const StateMachineBool* input, StateMachineInstance* machineInstance);
-public:
- bool value() const { return m_Value; }
- void value(bool newValue);
-};
+ public:
+ bool value() const { return m_Value; }
+ void value(bool newValue);
+ };
-class SMINumber : public SMIInput {
- friend class StateMachineInstance;
+ class SMINumber : public SMIInput {
+ friend class StateMachineInstance;
-private:
- float m_Value;
+ private:
+ float m_Value;
- SMINumber(const StateMachineNumber* input, StateMachineInstance* machineInstance);
+ SMINumber(const StateMachineNumber* input, StateMachineInstance* machineInstance);
-public:
- float value() const { return m_Value; }
- void value(float newValue);
-};
+ public:
+ float value() const { return m_Value; }
+ void value(float newValue);
+ };
-class SMITrigger : public SMIInput {
- friend class StateMachineInstance;
- friend class TransitionTriggerCondition;
+ class SMITrigger : public SMIInput {
+ friend class StateMachineInstance;
+ friend class TransitionTriggerCondition;
-private:
- bool m_Fired = false;
+ private:
+ bool m_Fired = false;
- SMITrigger(const StateMachineTrigger* input, StateMachineInstance* machineInstance);
- void advanced() override { m_Fired = false; }
+ SMITrigger(const StateMachineTrigger* input, StateMachineInstance* machineInstance);
+ void advanced() override { m_Fired = false; }
-public:
- void fire();
+ public:
+ void fire();
#ifdef TESTING
- bool didFire() { return m_Fired; }
+ bool didFire() { return m_Fired; }
#endif
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <stddef.h>
#include <vector>
#include "rive/animation/linear_animation_instance.hpp"
-#include "rive/listener_type.hpp"
+#include "rive/event_type.hpp"
#include "rive/scene.hpp"
namespace rive {
-class StateMachine;
-class LayerState;
-class SMIInput;
-class ArtboardInstance;
-class SMIBool;
-class SMINumber;
-class SMITrigger;
-class Shape;
-class StateMachineLayerInstance;
-class HitShape;
-class NestedArtboard;
-
-class StateMachineInstance : public Scene {
- friend class SMIInput;
-
-private:
- const StateMachine* m_Machine;
- bool m_NeedsAdvance = false;
-
- std::vector<SMIInput*> m_InputInstances; // we own each pointer
- size_t m_LayerCount;
- StateMachineLayerInstance* m_Layers;
-
- void markNeedsAdvance();
-
- std::vector<std::unique_ptr<HitShape>> m_HitShapes;
- std::vector<NestedArtboard*> m_HitNestedArtboards;
-
- /// Provide a hitListener if you want to process a down or an up for the pointer position
- /// too.
- void updateListeners(Vec2D position, ListenerType hitListener);
-
- template <typename SMType, typename InstType>
- InstType* getNamedInput(const std::string& name) const;
-
-public:
- StateMachineInstance(const StateMachine* machine, ArtboardInstance* instance);
- StateMachineInstance(StateMachineInstance const&) = delete;
- ~StateMachineInstance() override;
-
- // Advance the state machine by the specified time. Returns true if the
- // state machine will continue to animate after this advance.
- bool advance(float seconds);
-
- // Returns true when the StateMachineInstance has more data to process.
- bool needsAdvance() const;
-
- // Returns a pointer to the instance's stateMachine
- const StateMachine* stateMachine() const { return m_Machine; }
-
- size_t inputCount() const override { return m_InputInstances.size(); }
- SMIInput* input(size_t index) const override;
- SMIBool* getBool(const std::string& name) const override;
- SMINumber* getNumber(const std::string& name) const override;
- SMITrigger* getTrigger(const std::string& name) const override;
-
- size_t currentAnimationCount() const;
- const LinearAnimationInstance* currentAnimationByIndex(size_t index) const;
-
- // The number of state changes that occurred across all layers on the
- // previous advance.
- size_t stateChangedCount() const;
-
- // Returns the state name for states that changed in layers on the
- // previously called advance. If the index of out of range, it returns
- // the empty string.
- const LayerState* stateChangedByIndex(size_t index) const;
-
- bool advanceAndApply(float secs) override;
- std::string name() const override;
- void pointerMove(Vec2D position) override;
- void pointerDown(Vec2D position) override;
- void pointerUp(Vec2D position) override;
-
- float durationSeconds() const override { return -1; }
- Loop loop() const override { return Loop::oneShot; }
- bool isTranslucent() const override { return true; }
-
- /// Allow anything referencing a concrete StateMachineInstace access to
- /// the backing artboard (explicitly not allowed on Scenes).
- Artboard* artboard() { return m_ArtboardInstance; }
-};
+ class StateMachine;
+ class LayerState;
+ class SMIInput;
+ class ArtboardInstance;
+ class SMIBool;
+ class SMINumber;
+ class SMITrigger;
+ class Shape;
+ class StateMachineLayerInstance;
+ class HitShape;
+
+ class StateMachineInstance : public Scene {
+ friend class SMIInput;
+
+ private:
+ const StateMachine* m_Machine;
+ bool m_NeedsAdvance = false;
+
+ std::vector<SMIInput*> m_InputInstances; // we own each pointer
+ size_t m_LayerCount;
+ StateMachineLayerInstance* m_Layers;
+
+ void markNeedsAdvance();
+
+ std::vector<std::unique_ptr<HitShape>> m_HitShapes;
+ /// Provide a hitEvent if you want to process a down or an up for the pointer position too.
+ void processEvent(Vec2D position, EventType hitEvent = EventType::updateHover);
+
+ template <typename SMType, typename InstType>
+ InstType* getNamedInput(const std::string& name) const;
+
+ public:
+ StateMachineInstance(const StateMachine* machine, ArtboardInstance* instance);
+ ~StateMachineInstance() override;
+
+ // Advance the state machine by the specified time. Returns true if the
+ // state machine will continue to animate after this advance.
+ bool advance(float seconds);
+
+ // Returns true when the StateMachineInstance has more data to process.
+ bool needsAdvance() const;
+
+ // Returns a pointer to the instance's stateMachine
+ const StateMachine* stateMachine() const { return m_Machine; }
+
+ size_t inputCount() const override { return m_InputInstances.size(); }
+ SMIInput* input(size_t index) const override;
+ SMIBool* getBool(const std::string& name) const override;
+ SMINumber* getNumber(const std::string& name) const override;
+ SMITrigger* getTrigger(const std::string& name) const override;
+
+ const size_t currentAnimationCount() const;
+ const LinearAnimationInstance* currentAnimationByIndex(size_t index) const;
+
+ // The number of state changes that occurred across all layers on the
+ // previous advance.
+ size_t stateChangedCount() const;
+
+ // Returns the state name for states that changed in layers on the
+ // previously called advance. If the index of out of range, it returns
+ // the empty string.
+ const LayerState* stateChangedByIndex(size_t index) const;
+
+ bool advanceAndApply(float secs) override;
+ std::string name() const override;
+ void pointerMove(Vec2D position) override;
+ void pointerDown(Vec2D position) override;
+ void pointerUp(Vec2D position) override;
+
+ float durationSeconds() const override { return -1; }
+ Loop loop() const override { return Loop::oneShot; }
+ bool isTranslucent() const override { return true; }
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class LayerState;
-class StateMachineLayerImporter;
-class AnyState;
-class EntryState;
-class ExitState;
-class StateMachineLayer : public StateMachineLayerBase {
- friend class StateMachineLayerImporter;
+ class LayerState;
+ class StateMachineLayerImporter;
+ class AnyState;
+ class EntryState;
+ class ExitState;
+ class StateMachineLayer : public StateMachineLayerBase {
+ friend class StateMachineLayerImporter;
-private:
- std::vector<LayerState*> m_States;
- AnyState* m_Any = nullptr;
- EntryState* m_Entry = nullptr;
- ExitState* m_Exit = nullptr;
+ private:
+ std::vector<LayerState*> m_States;
+ AnyState* m_Any = nullptr;
+ EntryState* m_Entry = nullptr;
+ ExitState* m_Exit = nullptr;
- void addState(LayerState* state);
+ void addState(LayerState* state);
-public:
- ~StateMachineLayer() override;
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
+ public:
+ ~StateMachineLayer();
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
- StatusCode import(ImportStack& importStack) override;
+ StatusCode import(ImportStack& importStack) override;
- const AnyState* anyState() const { return m_Any; }
- const EntryState* entryState() const { return m_Entry; }
- const ExitState* exitState() const { return m_Exit; }
+ const AnyState* anyState() const { return m_Any; }
+ const EntryState* entryState() const { return m_Entry; }
+ const ExitState* exitState() const { return m_Exit; }
#ifdef TESTING
- size_t stateCount() const { return m_States.size(); }
- LayerState* state(size_t index) const {
- if (index < m_States.size()) {
- return m_States[index];
+ size_t stateCount() const { return m_States.size(); }
+ LayerState* state(size_t index) const {
+ if (index < m_States.size()) {
+ return m_States[index];
+ }
+ return nullptr;
}
- return nullptr;
- }
#endif
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/state_machine_layer_component_base.hpp"
#include <stdio.h>
namespace rive {
-class StateMachineLayerComponent : public StateMachineLayerComponentBase {
-public:
-};
+ class StateMachineLayerComponent : public StateMachineLayerComponentBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/math/vec2d.hpp"
namespace rive {
-class Shape;
-class StateMachineListenerImporter;
-class ListenerAction;
-class StateMachineInstance;
-class StateMachineListener : public StateMachineListenerBase {
- friend class StateMachineListenerImporter;
+ class Shape;
+ class StateMachineListenerImporter;
+ class ListenerAction;
+ class StateMachineInstance;
+ class StateMachineListener : public StateMachineListenerBase {
+ friend class StateMachineListenerImporter;
-private:
- std::vector<uint32_t> m_HitShapesIds;
- std::vector<std::unique_ptr<ListenerAction>> m_Actions;
- void addAction(std::unique_ptr<ListenerAction>);
+ private:
+ std::vector<uint32_t> m_HitShapesIds;
+ std::vector<std::unique_ptr<ListenerAction>> m_Actions;
+ void addAction(std::unique_ptr<ListenerAction>);
-public:
- StateMachineListener();
- ~StateMachineListener() override;
+ public:
+ StateMachineListener();
+ ~StateMachineListener() override;
- ListenerType listenerType() const { return (ListenerType)listenerTypeValue(); }
- size_t actionCount() const { return m_Actions.size(); }
+ ListenerType listenerType() const { return (ListenerType)listenerTypeValue(); }
+ size_t actionCount() const { return m_Actions.size(); }
- const ListenerAction* action(size_t index) const;
- StatusCode import(ImportStack& importStack) override;
- StatusCode onAddedClean(CoreContext* context) override;
+ const ListenerAction* action(size_t index) const;
+ StatusCode import(ImportStack& importStack) override;
+ StatusCode onAddedClean(CoreContext* context) override;
- const std::vector<uint32_t>& hitShapeIds() const { return m_HitShapesIds; }
- void performChanges(StateMachineInstance* stateMachineInstance, Vec2D position) const;
-};
+ const std::vector<uint32_t>& hitShapeIds() const { return m_HitShapesIds; }
+ void performChanges(StateMachineInstance* stateMachineInstance, Vec2D position) const;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/state_machine_number_base.hpp"
#include <stdio.h>
namespace rive {
-class StateMachineNumber : public StateMachineNumberBase {
-public:
-};
+ class StateMachineNumber : public StateMachineNumberBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/state_machine_trigger_base.hpp"
#include <stdio.h>
namespace rive {
-class StateMachineTrigger : public StateMachineTriggerBase {};
+ class StateMachineTrigger : public StateMachineTriggerBase {};
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class LayerState;
-class StateMachineLayerImporter;
-class StateTransitionImporter;
-class TransitionCondition;
-class StateInstance;
-class SMIInput;
-class LinearAnimation;
-class LinearAnimationInstance;
-
-enum class AllowTransition : unsigned char { no, waitingForExit, yes };
-
-class StateTransition : public StateTransitionBase {
- friend class StateMachineLayerImporter;
- friend class StateTransitionImporter;
-
-private:
- StateTransitionFlags transitionFlags() const {
- return static_cast<StateTransitionFlags>(flags());
- }
- LayerState* m_StateTo = nullptr;
-
- std::vector<TransitionCondition*> m_Conditions;
- void addCondition(TransitionCondition* condition);
-
-public:
- ~StateTransition() override;
- const LayerState* stateTo() const { return m_StateTo; }
-
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
-
- /// Whether the transition is marked disabled (usually done in the
- /// editor).
- bool isDisabled() const {
- return (transitionFlags() & StateTransitionFlags::Disabled) ==
- StateTransitionFlags::Disabled;
- }
-
- /// Returns AllowTransition::yes when this transition can be taken from
- /// stateFrom with the given inputs.
- AllowTransition allowed(StateInstance* stateFrom,
- Span<SMIInput*> inputs,
- bool ignoreTriggers) const;
-
- /// Whether the animation is held at exit or if it keeps advancing
- /// during mixing.
- 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 {
- return (transitionFlags() & StateTransitionFlags::EnableExitTime) ==
- StateTransitionFlags::EnableExitTime;
- }
-
- StatusCode import(ImportStack& importStack) override;
-
- size_t conditionCount() const { return m_Conditions.size(); }
- TransitionCondition* condition(size_t index) const {
- if (index < m_Conditions.size()) {
- return m_Conditions[index];
+ class LayerState;
+ class StateMachineLayerImporter;
+ class StateTransitionImporter;
+ class TransitionCondition;
+ class StateInstance;
+ class SMIInput;
+ class LinearAnimation;
+ class LinearAnimationInstance;
+
+ enum class AllowTransition : unsigned char { no, waitingForExit, yes };
+
+ class StateTransition : public StateTransitionBase {
+ friend class StateMachineLayerImporter;
+ friend class StateTransitionImporter;
+
+ private:
+ StateTransitionFlags transitionFlags() const {
+ return static_cast<StateTransitionFlags>(flags());
}
- return nullptr;
- }
-
- /// The amount of time to mix the outgoing animation onto the incoming
- /// one when changing state. Only applies when going out from an
- /// AnimationState.
- float mixTime(const LayerState* stateFrom) const;
-
- /// Computes the exit time in seconds of the stateFrom. Set absolute to
- /// true if you want the returned time to be relative to the entire
- /// animation. Set absolute to false if you want it relative to the work
- /// area.
- float exitTimeSeconds(const LayerState* stateFrom, bool absolute = false) const;
-
- /// Provide the animation instance to use for computing percentage
- /// durations for exit time.
- virtual const LinearAnimationInstance*
- exitTimeAnimationInstance(const StateInstance* from) const;
-
- /// Provide the animation to use for computing percentage durations for
- /// exit time.
- virtual const LinearAnimation* exitTimeAnimation(const LayerState* from) const;
-
- /// Retruns true when we need to hold the exit time, also applies the
- /// correct time to the animation instance in the stateFrom, when
- /// applicable (when it's an AnimationState).
- bool applyExitCondition(StateInstance* stateFrom) const;
-};
+ LayerState* m_StateTo = nullptr;
+
+ std::vector<TransitionCondition*> m_Conditions;
+ void addCondition(TransitionCondition* condition);
+
+ public:
+ ~StateTransition();
+ const LayerState* stateTo() const { return m_StateTo; }
+
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+
+ /// Whether the transition is marked disabled (usually done in the
+ /// editor).
+ bool isDisabled() const {
+ return (transitionFlags() & StateTransitionFlags::Disabled) ==
+ StateTransitionFlags::Disabled;
+ }
+
+ /// Returns AllowTransition::yes when this transition can be taken from
+ /// stateFrom with the given inputs.
+ AllowTransition
+ allowed(StateInstance* stateFrom, Span<SMIInput*> inputs, bool ignoreTriggers) const;
+
+ /// Whether the animation is held at exit or if it keeps advancing
+ /// during mixing.
+ 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 {
+ return (transitionFlags() & StateTransitionFlags::EnableExitTime) ==
+ StateTransitionFlags::EnableExitTime;
+ }
+
+ StatusCode import(ImportStack& importStack) override;
+
+ size_t conditionCount() const { return m_Conditions.size(); }
+ TransitionCondition* condition(size_t index) const {
+ if (index < m_Conditions.size()) {
+ return m_Conditions[index];
+ }
+ return nullptr;
+ }
+
+ /// The amount of time to mix the outgoing animation onto the incoming
+ /// one when changing state. Only applies when going out from an
+ /// AnimationState.
+ float mixTime(const LayerState* stateFrom) const;
+
+ /// Computes the exit time in seconds of the stateFrom. Set absolute to
+ /// true if you want the returned time to be relative to the entire
+ /// animation. Set absolute to false if you want it relative to the work
+ /// area.
+ float exitTimeSeconds(const LayerState* stateFrom, bool absolute = false) const;
+
+ /// Provide the animation instance to use for computing percentage
+ /// durations for exit time.
+ virtual const LinearAnimationInstance*
+ exitTimeAnimationInstance(const StateInstance* from) const;
+
+ /// Provide the animation to use for computing percentage durations for
+ /// exit time.
+ virtual const LinearAnimation* exitTimeAnimation(const LayerState* from) const;
+
+ /// Retruns true when we need to hold the exit time, also applies the
+ /// correct time to the animation instance in the stateFrom, when
+ /// applicable (when it's an AnimationState).
+ bool applyExitCondition(StateInstance* stateFrom) const;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <type_traits>
namespace rive {
-enum class StateTransitionFlags : unsigned char {
- None = 0,
-
- /// Whether the transition is disabled.
- Disabled = 1 << 0,
-
- /// Whether the transition duration is a percentage or time in ms.
- DurationIsPercentage = 1 << 1,
-
- /// Whether exit time is enabled.
- EnableExitTime = 1 << 2,
-
- /// Whether the exit time is a percentage or time in ms.
- ExitTimeIsPercentage = 1 << 3,
-
- /// Whether the animation is held at exit or if it keeps advancing
- /// during mixing.
- PauseOnExit = 1 << 4
-
-};
-
-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) {
- 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) {
- 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) {
- return static_cast<StateTransitionFlags>(
- ~static_cast<std::underlying_type<StateTransitionFlags>::type>(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));
-
- return lhs;
-}
-
-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));
-
- return lhs;
-}
-
-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));
-
- return lhs;
-}
+ enum class StateTransitionFlags : unsigned char {
+ None = 0,
+
+ /// Whether the transition is disabled.
+ Disabled = 1 << 0,
+
+ /// Whether the transition duration is a percentage or time in ms.
+ DurationIsPercentage = 1 << 1,
+
+ /// Whether exit time is enabled.
+ EnableExitTime = 1 << 2,
+
+ /// Whether the exit time is a percentage or time in ms.
+ ExitTimeIsPercentage = 1 << 3,
+
+ /// Whether the animation is held at exit or if it keeps advancing
+ /// during mixing.
+ PauseOnExit = 1 << 4
+
+ };
+
+ 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) {
+ 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) {
+ 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) {
+ return static_cast<StateTransitionFlags>(
+ ~static_cast<std::underlying_type<StateTransitionFlags>::type>(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));
+
+ return lhs;
+ }
+
+ 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));
+
+ return lhs;
+ }
+
+ 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));
+
+ return lhs;
+ }
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/state_instance.hpp"
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 {
-public:
- SystemStateInstance(const LayerState* layerState, ArtboardInstance* instance);
+ /// 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 {
+ public:
+ SystemStateInstance(const LayerState* layerState, ArtboardInstance* instance);
- void advance(float seconds, Span<SMIInput*> inputs) override;
- void apply(float mix) override;
+ void advance(float seconds, Span<SMIInput*> inputs) override;
+ void apply(float mix) override;
- bool keepGoing() const override;
-};
+ bool keepGoing() const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/transition_bool_condition_base.hpp"
#include <stdio.h>
namespace rive {
-class TransitionBoolCondition : public TransitionBoolConditionBase {
-public:
- bool evaluate(const SMIInput* inputInstance) const override;
+ class TransitionBoolCondition : public TransitionBoolConditionBase {
+ public:
+ bool evaluate(const SMIInput* inputInstance) const override;
-protected:
- bool validateInputType(const StateMachineInput* input) const override;
-};
+ protected:
+ bool validateInputType(const StateMachineInput* input) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/transition_condition_base.hpp"
namespace rive {
-class StateMachineInput;
-class SMIInput;
+ class StateMachineInput;
+ class SMIInput;
-class TransitionCondition : public TransitionConditionBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
+ class TransitionCondition : public TransitionConditionBase {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
- StatusCode import(ImportStack& importStack) override;
+ StatusCode import(ImportStack& importStack) override;
- virtual bool evaluate(const SMIInput* inputInstance) const { return true; }
+ virtual bool evaluate(const SMIInput* inputInstance) const { return true; }
-protected:
- virtual bool validateInputType(const StateMachineInput* input) const { return true; }
-};
+ protected:
+ virtual bool validateInputType(const StateMachineInput* input) const { return true; }
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_TRANSITION_CONDITION_OP_HPP_
namespace rive {
-enum class TransitionConditionOp : int {
- equal = 0,
- notEqual = 1,
- lessThanOrEqual = 2,
- greaterThanOrEqual = 3,
- lessThan = 4,
- greaterThan = 5
-};
+ enum class TransitionConditionOp : int {
+ equal = 0,
+ notEqual = 1,
+ lessThanOrEqual = 2,
+ greaterThanOrEqual = 3,
+ lessThan = 4,
+ greaterThan = 5
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/transition_number_condition_base.hpp"
#include <stdio.h>
namespace rive {
-class TransitionNumberCondition : public TransitionNumberConditionBase {
-protected:
- bool validateInputType(const StateMachineInput* input) const override;
+ class TransitionNumberCondition : public TransitionNumberConditionBase {
+ protected:
+ bool validateInputType(const StateMachineInput* input) const override;
-public:
- bool evaluate(const SMIInput* inputInstance) const override;
-};
+ public:
+ bool evaluate(const SMIInput* inputInstance) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/animation/transition_trigger_condition_base.hpp"
#include <stdio.h>
namespace rive {
-class TransitionTriggerCondition : public TransitionTriggerConditionBase {
-public:
- bool evaluate(const SMIInput* inputInstance) const override;
+ class TransitionTriggerCondition : public TransitionTriggerConditionBase {
+ public:
+ bool evaluate(const SMIInput* inputInstance) const override;
-protected:
- bool validateInputType(const StateMachineInput* input) const override;
-};
+ protected:
+ bool validateInputType(const StateMachineInput* input) const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/transition_condition_op.hpp"
namespace rive {
-class TransitionValueCondition : public TransitionValueConditionBase {
-public:
- TransitionConditionOp op() const { return (TransitionConditionOp)opValue(); }
-};
+ class TransitionValueCondition : public TransitionValueConditionBase {
+ public:
+ TransitionConditionOp op() const { return (TransitionConditionOp)opValue(); }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class File;
-class Drawable;
-class Factory;
-class Node;
-class DrawTarget;
-class ArtboardImporter;
-class NestedArtboard;
-class ArtboardInstance;
-class LinearAnimationInstance;
-class Scene;
-class StateMachineInstance;
-
-class Artboard : public ArtboardBase, public CoreContext, public ShapePaintContainer {
- friend class File;
- friend class ArtboardImporter;
- friend class Component;
-
-private:
- std::vector<Core*> m_Objects;
- std::vector<LinearAnimation*> m_Animations;
- std::vector<StateMachine*> m_StateMachines;
- std::vector<Component*> m_DependencyOrder;
- std::vector<Drawable*> m_Drawables;
- std::vector<DrawTarget*> m_DrawTargets;
- std::vector<NestedArtboard*> m_NestedArtboards;
-
- unsigned int m_DirtDepth = 0;
- std::unique_ptr<RenderPath> m_BackgroundPath;
- std::unique_ptr<RenderPath> m_ClipPath;
- Factory* m_Factory = nullptr;
- Drawable* m_FirstDrawable = nullptr;
- bool m_IsInstance = false;
- bool m_FrameOrigin = true;
-
- void sortDependencies();
- void sortDrawOrder();
-
- Artboard* getArtboard() override { return this; }
+ class File;
+ class Drawable;
+ class Factory;
+ class Node;
+ class DrawTarget;
+ class ArtboardImporter;
+ class NestedArtboard;
+ class ArtboardInstance;
+ class LinearAnimationInstance;
+ class Scene;
+ class StateMachineInstance;
+
+ class Artboard : public ArtboardBase, public CoreContext, public ShapePaintContainer {
+ friend class File;
+ friend class ArtboardImporter;
+ friend class Component;
+
+ private:
+ std::vector<Core*> m_Objects;
+ std::vector<LinearAnimation*> m_Animations;
+ std::vector<StateMachine*> m_StateMachines;
+ std::vector<Component*> m_DependencyOrder;
+ std::vector<Drawable*> m_Drawables;
+ std::vector<DrawTarget*> m_DrawTargets;
+ std::vector<NestedArtboard*> m_NestedArtboards;
+
+ unsigned int m_DirtDepth = 0;
+ std::unique_ptr<CommandPath> m_BackgroundPath;
+ std::unique_ptr<CommandPath> m_ClipPath;
+ Factory* m_Factory = nullptr;
+ Drawable* m_FirstDrawable = nullptr;
+ bool m_IsInstance = false;
+ bool m_FrameOrigin = true;
+
+ void sortDependencies();
+ void sortDrawOrder();
+
+ Artboard* getArtboard() override { return this; }
#ifdef TESTING
-public:
- Artboard(Factory* factory) : m_Factory(factory) {}
+ public:
+ Artboard(Factory* factory) : m_Factory(factory) {}
#endif
- void addObject(Core* object);
- void addAnimation(LinearAnimation* object);
- void addStateMachine(StateMachine* object);
- void addNestedArtboard(NestedArtboard* object);
+ void addObject(Core* object);
+ void addAnimation(LinearAnimation* object);
+ void addStateMachine(StateMachine* object);
+ void addNestedArtboard(NestedArtboard* object);
-public:
- Artboard() {}
- ~Artboard() override;
- StatusCode initialize();
+ public:
+ Artboard() {}
+ ~Artboard();
+ StatusCode initialize();
- Core* resolve(uint32_t id) const override;
+ Core* resolve(uint32_t id) const override;
- /// Find the id of a component in the artboard the object in the artboard. The artboard
- /// itself has id 0 so we use that as a flag for not found.
- uint32_t idOf(Core* object) const;
+ /// Find the id of a component in the artboard the object in the artboard. The artboard
+ /// itself has id 0 so we use that as a flag for not found.
+ uint32_t idOf(Core* object) const;
- Factory* factory() const { return m_Factory; }
+ Factory* factory() const { return m_Factory; }
- // EXPERIMENTAL -- for internal testing only for now.
- // DO NOT RELY ON THIS as it may change/disappear in the future.
- Core* hitTest(HitInfo*, const Mat2D* = nullptr);
+ // EXPERIMENTAL -- for internal testing only for now.
+ // DO NOT RELY ON THIS as it may change/disappear in the future.
+ Core* hitTest(HitInfo*, const Mat2D* = nullptr);
- void onComponentDirty(Component* component);
+ void onComponentDirty(Component* component);
- /// Update components that depend on each other in DAG order.
- bool updateComponents();
- void update(ComponentDirt value) override;
- void onDirty(ComponentDirt dirt) override;
+ /// Update components that depend on each other in DAG order.
+ bool updateComponents();
+ void update(ComponentDirt value) override;
+ void onDirty(ComponentDirt dirt) override;
- bool advance(double elapsedSeconds);
+ bool advance(double elapsedSeconds);
- enum class DrawOption {
- kNormal,
- kHideBG,
- kHideFG,
- };
- void draw(Renderer* renderer, DrawOption = DrawOption::kNormal);
+ enum class DrawOption {
+ kNormal,
+ kHideBG,
+ kHideFG,
+ };
+ void draw(Renderer* renderer, DrawOption = DrawOption::kNormal);
- // TODO: can we remove these getters? Who is calling them?
- RenderPath* clipPath() const { return m_ClipPath.get(); }
- RenderPath* backgroundPath() const { return m_BackgroundPath.get(); }
+ CommandPath* clipPath() const { return m_ClipPath.get(); }
+ CommandPath* backgroundPath() const { return m_BackgroundPath.get(); }
- const std::vector<Core*>& objects() const { return m_Objects; }
- const std::vector<NestedArtboard*> nestedArtboards() const { return m_NestedArtboards; }
+ const std::vector<Core*>& objects() const { return m_Objects; }
- AABB bounds() const;
+ AABB bounds() const;
- // Can we hide these from the public? (they use playable)
- bool isTranslucent(const LinearAnimation*) const;
- bool isTranslucent(const LinearAnimationInstance*) const;
+ // Can we hide these from the public? (they use playable)
+ 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) {
- return reinterpret_cast<T*>(object);
+ 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);
+ }
}
+ return nullptr;
}
- return nullptr;
- }
-
- size_t animationCount() const { return m_Animations.size(); }
- std::string animationNameAt(size_t index) const;
-
- size_t stateMachineCount() const { return m_StateMachines.size(); }
- std::string stateMachineNameAt(size_t index) const;
-
- LinearAnimation* firstAnimation() const { return animation(0); }
- LinearAnimation* animation(const std::string& name) const;
- LinearAnimation* animation(size_t index) const;
-
- StateMachine* firstStateMachine() const { return stateMachine(0); }
- StateMachine* stateMachine(const std::string& name) const;
- StateMachine* stateMachine(size_t index) const;
-
- /// When provided, the designer has specified that this artboard should
- /// always autoplay this StateMachine. Returns -1 if it was not
- // provided.
- int defaultStateMachineIndex() const;
-
- /// Make an instance of this artboard, must be explictly deleted when no
- /// longer needed.
- // Deprecated...
- std::unique_ptr<ArtboardInstance> instance() const;
-
- /// Returns true if the artboard is an instance of another
- bool isInstance() const { return m_IsInstance; }
-
- /// Returns true when the artboard will shift the origin from the top
- /// left to the relative width/height of the artboard itself. This is
- /// what the editor does visually when you change the origin value to
- /// give context as to where the origin lies within the framed bounds.
- bool frameOrigin() const { return m_FrameOrigin; }
- /// When composing multiple artboards together in a common world-space,
- /// it may be desireable to have them share the same space regardless of
- /// origin offset from the bounding artboard. Set frameOrigin to false
- /// to move the bounds relative to the origin instead of the origin
- /// relative to the bounds.
- void frameOrigin(bool value);
-
- StatusCode import(ImportStack& importStack) override;
-};
-
-class ArtboardInstance : public Artboard {
-public:
- ArtboardInstance();
- ~ArtboardInstance() override;
-
- std::unique_ptr<LinearAnimationInstance> animationAt(size_t index);
- std::unique_ptr<LinearAnimationInstance> animationNamed(const std::string& name);
-
- std::unique_ptr<StateMachineInstance> stateMachineAt(size_t index);
- std::unique_ptr<StateMachineInstance> stateMachineNamed(const std::string& name);
-
- /// When provided, the designer has specified that this artboard should
- /// always autoplay this StateMachine instance. If it was not specified,
- /// this returns nullptr.
- std::unique_ptr<StateMachineInstance> defaultStateMachine();
-
- // This attemps to always return *something*, in this search order:
- // 1. default statemachine instance
- // 2. first statemachine instance
- // 3. first animation instance
- // 4. nullptr
- std::unique_ptr<Scene> defaultScene();
-};
+
+ size_t animationCount() const { return m_Animations.size(); }
+ std::string animationNameAt(size_t index) const;
+
+ size_t stateMachineCount() const { return m_StateMachines.size(); }
+ std::string stateMachineNameAt(size_t index) const;
+
+ LinearAnimation* firstAnimation() const { return animation(0); }
+ LinearAnimation* animation(const std::string& name) const;
+ LinearAnimation* animation(size_t index) const;
+
+ StateMachine* firstStateMachine() const { return stateMachine(0); }
+ StateMachine* stateMachine(const std::string& name) const;
+ StateMachine* stateMachine(size_t index) const;
+
+ /// When provided, the designer has specified that this artboard should
+ /// always autoplay this StateMachine. Returns -1 if it was not
+ // provided.
+ int defaultStateMachineIndex() const;
+
+ /// Make an instance of this artboard, must be explictly deleted when no
+ /// longer needed.
+ // Deprecated...
+ std::unique_ptr<ArtboardInstance> instance() const;
+
+ /// Returns true if the artboard is an instance of another
+ bool isInstance() const { return m_IsInstance; }
+
+ /// Returns true when the artboard will shift the origin from the top
+ /// left to the relative width/height of the artboard itself. This is
+ /// what the editor does visually when you change the origin value to
+ /// give context as to where the origin lies within the framed bounds.
+ bool frameOrigin() const { return m_FrameOrigin; }
+ /// When composing multiple artboards together in a common world-space,
+ /// it may be desireable to have them share the same space regardless of
+ /// origin offset from the bounding artboard. Set frameOrigin to false
+ /// to move the bounds relative to the origin instead of the origin
+ /// relative to the bounds.
+ void frameOrigin(bool value);
+
+ StatusCode import(ImportStack& importStack) override;
+ };
+
+ class ArtboardInstance : public Artboard {
+ public:
+ ArtboardInstance() {}
+
+ std::unique_ptr<LinearAnimationInstance> animationAt(size_t index);
+ std::unique_ptr<LinearAnimationInstance> animationNamed(const std::string& name);
+
+ std::unique_ptr<StateMachineInstance> stateMachineAt(size_t index);
+ std::unique_ptr<StateMachineInstance> stateMachineNamed(const std::string& name);
+
+ /// When provided, the designer has specified that this artboard should
+ /// always autoplay this StateMachine instance. If it was not specified,
+ /// this returns nullptr.
+ std::unique_ptr<StateMachineInstance> defaultStateMachine();
+
+ // This attemps to always return *something*, in this search order:
+ // 1. default statemachine instance
+ // 2. first statemachine instance
+ // 3. first animation instance
+ // 4. nullptr
+ std::unique_ptr<Scene> defaultScene();
+ };
} // namespace rive
#endif
#include "rive/generated/assets/asset_base.hpp"
#include <stdio.h>
namespace rive {
-class Asset : public AssetBase {
-public:
-};
+ class Asset : public AssetBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/assets/drawable_asset_base.hpp"
#include <stdio.h>
namespace rive {
-class DrawableAsset : public DrawableAssetBase {
-public:
-};
+ class DrawableAsset : public DrawableAssetBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <string>
namespace rive {
-class Factory;
-class FileAsset : public FileAssetBase {
-public:
- virtual bool decode(Span<const uint8_t>, Factory*) = 0;
- virtual std::string fileExtension() = 0;
- StatusCode import(ImportStack& importStack) override;
+ class Factory;
+ class FileAsset : public FileAssetBase {
+ public:
+ virtual bool decode(Span<const uint8_t>, Factory*) = 0;
+ virtual std::string fileExtension() = 0;
+ StatusCode import(ImportStack& importStack) override;
- std::string uniqueFilename();
-};
+ std::string uniqueFilename();
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <cstdint>
namespace rive {
-class FileAssetContents : public FileAssetContentsBase {
-private:
- std::vector<uint8_t> m_Bytes;
+ class FileAssetContents : public FileAssetContentsBase {
+ private:
+ std::vector<uint8_t> m_Bytes;
-public:
- Span<const uint8_t> bytes() const;
- StatusCode import(ImportStack& importStack) override;
- void decodeBytes(Span<const uint8_t> value) override;
- void copyBytes(const FileAssetContentsBase& object) override;
-};
+ public:
+ Span<const uint8_t> bytes() const;
+ StatusCode import(ImportStack& importStack) override;
+ void decodeBytes(Span<const uint8_t> value) override;
+ void copyBytes(const FileAssetContentsBase& object) override;
+ };
} // namespace rive
#endif
#define _RIVE_FILE_ASSET_REFERENCER_HPP_
namespace rive {
-class FileAsset;
-class FileAssetReferencer {
-public:
- virtual ~FileAssetReferencer() {}
- virtual void assets(const std::vector<FileAsset*>& assets) = 0;
-};
+ class FileAsset;
+ class FileAssetReferencer {
+ public:
+ virtual void assets(const std::vector<FileAsset*>& assets) = 0;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/assets/folder_base.hpp"
#include <stdio.h>
namespace rive {
-class Folder : public FolderBase {
-public:
-};
+ class Folder : public FolderBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <string>
namespace rive {
-class ImageAsset : public ImageAssetBase {
-private:
- std::unique_ptr<RenderImage> m_RenderImage;
+ class ImageAsset : public ImageAssetBase {
+ private:
+ std::unique_ptr<RenderImage> m_RenderImage;
-public:
- ImageAsset() {}
- ~ImageAsset() override;
+ public:
+ ImageAsset() {}
+ ~ImageAsset();
#ifdef TESTING
- std::size_t decodedByteSize = 0;
+ std::size_t decodedByteSize = 0;
#endif
- bool decode(Span<const uint8_t>, Factory*) override;
- std::string fileExtension() override;
- RenderImage* renderImage() const { return m_RenderImage.get(); }
-};
+ bool decode(Span<const uint8_t>, Factory*) override;
+ std::string fileExtension() override;
+ RenderImage* renderImage() const { return m_RenderImage.get(); }
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_BACKBOARD_HPP_
#include "rive/generated/backboard_base.hpp"
namespace rive {
-class Backboard : public BackboardBase {};
+ class Backboard : public BackboardBase {};
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class Constraint;
-class Bone : public BoneBase {
+ class Constraint;
+ class Bone : public BoneBase {
-private:
- std::vector<Bone*> m_ChildBones;
- std::vector<Constraint*> m_PeerConstraints;
+ private:
+ std::vector<Bone*> m_ChildBones;
+ std::vector<Constraint*> m_PeerConstraints;
-public:
- StatusCode onAddedClean(CoreContext* context) override;
- float x() const override;
- float y() const override;
+ public:
+ StatusCode onAddedClean(CoreContext* context) override;
+ float x() const override;
+ float y() const override;
- inline const std::vector<Bone*> childBones() { return m_ChildBones; }
+ inline const std::vector<Bone*> childBones() { return m_ChildBones; }
- void addChildBone(Bone* bone);
- Vec2D tipWorldTranslation() const;
- void addPeerConstraint(Constraint* peer);
- const std::vector<Constraint*>& peerConstraints() const { return m_PeerConstraints; }
+ void addChildBone(Bone* bone);
+ Vec2D tipWorldTranslation() const;
+ void addPeerConstraint(Constraint* peer);
+ const std::vector<Constraint*>& peerConstraints() const { return m_PeerConstraints; }
-private:
- void lengthChanged() override;
-};
+ private:
+ void lengthChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/bones/cubic_weight_base.hpp"
#include <stdio.h>
namespace rive {
-class CubicWeight : public CubicWeightBase {
-private:
- Vec2D m_InTranslation;
- Vec2D m_OutTranslation;
+ class CubicWeight : public CubicWeightBase {
+ private:
+ Vec2D m_InTranslation;
+ Vec2D m_OutTranslation;
-public:
- Vec2D& inTranslation() { return m_InTranslation; }
- Vec2D& outTranslation() { return m_OutTranslation; }
-};
+ public:
+ Vec2D& inTranslation() { return m_InTranslation; }
+ Vec2D& outTranslation() { return m_OutTranslation; }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/bones/root_bone_base.hpp"
#include <stdio.h>
namespace rive {
-class RootBone : public RootBoneBase {
-public:
- StatusCode onAddedClean(CoreContext* context) override;
+ class RootBone : public RootBoneBase {
+ public:
+ StatusCode onAddedClean(CoreContext* context) override;
-protected:
- void xChanged() override;
- void yChanged() override;
-};
+ protected:
+ void xChanged() override;
+ void yChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/bones/skeletal_component_base.hpp"
#include <stdio.h>
namespace rive {
-class SkeletalComponent : public SkeletalComponentBase {
-public:
-};
+ class SkeletalComponent : public SkeletalComponentBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class Tendon;
-class Vertex;
-class Skinnable;
+ class Tendon;
+ class Vertex;
+ class Skinnable;
-class Skin : public SkinBase {
- friend class Tendon;
+ class Skin : public SkinBase {
+ friend class Tendon;
-public:
- ~Skin() override;
+ public:
+ ~Skin();
-private:
- Mat2D m_WorldTransform;
- std::vector<Tendon*> m_Tendons;
- float* m_BoneTransforms = nullptr;
- Skinnable* m_Skinnable;
+ private:
+ Mat2D m_WorldTransform;
+ std::vector<Tendon*> m_Tendons;
+ float* m_BoneTransforms = nullptr;
+ Skinnable* m_Skinnable;
-protected:
- void addTendon(Tendon* tendon);
+ protected:
+ void addTendon(Tendon* tendon);
-public:
- StatusCode onAddedClean(CoreContext* context) override;
- void buildDependencies() override;
- void deform(Span<Vertex*> vertices);
- void onDirty(ComponentDirt dirt) override;
- void update(ComponentDirt value) override;
+ public:
+ StatusCode onAddedClean(CoreContext* context) override;
+ void buildDependencies() override;
+ void deform(Span<Vertex*> vertices);
+ void onDirty(ComponentDirt dirt) override;
+ void update(ComponentDirt value) override;
#ifdef TESTING
- std::vector<Tendon*>& tendons() { return m_Tendons; }
+ std::vector<Tendon*>& tendons() { return m_Tendons; }
#endif
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/rive_types.hpp"
namespace rive {
-class Skin;
-class Component;
+ class Skin;
+ class Component;
-class Skinnable {
- friend class Skin;
+ class Skinnable {
+ friend class Skin;
-private:
- Skin* m_Skin = nullptr;
+ private:
+ Skin* m_Skin = nullptr;
-protected:
- void skin(Skin* skin);
+ protected:
+ void skin(Skin* skin);
-public:
- virtual ~Skinnable() {}
+ public:
+ Skin* skin() const { return m_Skin; }
+ virtual void markSkinDirty() = 0;
- Skin* skin() const { return m_Skin; }
- virtual void markSkinDirty() = 0;
-
- static Skinnable* from(Component* component);
-};
+ static Skinnable* from(Component* component);
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <stdio.h>
namespace rive {
-class Bone;
-class Tendon : public TendonBase {
-private:
- Mat2D m_InverseBind;
- Bone* m_Bone = nullptr;
+ class Bone;
+ class Tendon : public TendonBase {
+ private:
+ Mat2D m_InverseBind;
+ Bone* m_Bone = nullptr;
-public:
- Bone* bone() const { return m_Bone; }
- const Mat2D& inverseBind() const { return m_InverseBind; }
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
-};
+ public:
+ Bone* bone() const { return m_Bone; }
+ const Mat2D& inverseBind() const { return m_InverseBind; }
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <stdio.h>
namespace rive {
-class Weight : public WeightBase {
-private:
- Vec2D m_Translation;
+ class Weight : public WeightBase {
+ private:
+ Vec2D m_Translation;
-public:
- Vec2D& translation() { return m_Translation; }
+ public:
+ Vec2D& translation() { return m_Translation; }
- StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedDirty(CoreContext* context) override;
- static Vec2D deform(Vec2D inPoint,
- unsigned int indices,
- unsigned int weights,
- const Mat2D& world,
- const float* boneTransforms);
-};
+ static Vec2D deform(Vec2D inPoint,
+ unsigned int indices,
+ unsigned int weights,
+ const Mat2D& world,
+ const float* boneTransforms);
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/math/path_types.hpp"
namespace rive {
-class RenderPath;
-
-/// Abstract path used to build up commands used for rendering.
-class CommandPath {
-public:
- virtual ~CommandPath() {}
- virtual void reset() = 0;
- virtual void fillRule(FillRule value) = 0;
- virtual void addPath(CommandPath* path, const Mat2D& transform) = 0;
-
- virtual void moveTo(float x, float y) = 0;
- virtual void lineTo(float x, float y) = 0;
- virtual void cubicTo(float ox, float oy, float ix, float iy, float x, float y) = 0;
- virtual void close() = 0;
-
- virtual RenderPath* renderPath() = 0;
-
- // non-virtual helpers
-
- void addRect(float x, float y, float width, float height) {
- moveTo(x, y);
- lineTo(x + width, y);
- lineTo(x + width, y + height);
- lineTo(x, y + height);
- close();
- }
-
- void move(Vec2D v) { this->moveTo(v.x, v.y); }
- void line(Vec2D v) { this->lineTo(v.x, v.y); }
- void cubic(Vec2D a, Vec2D b, Vec2D c) { this->cubicTo(a.x, a.y, b.x, b.y, c.x, c.y); }
-};
+ class RenderPath;
+
+ /// Abstract path used to build up commands used for rendering.
+ class CommandPath {
+ public:
+ virtual ~CommandPath() {}
+ virtual void reset() = 0;
+ virtual void fillRule(FillRule value) = 0;
+ virtual void addPath(CommandPath* path, const Mat2D& transform) = 0;
+
+ virtual void moveTo(float x, float y) = 0;
+ virtual void lineTo(float x, float y) = 0;
+ virtual void cubicTo(float ox, float oy, float ix, float iy, float x, float y) = 0;
+ virtual void close() = 0;
+
+ virtual RenderPath* renderPath() = 0;
+
+ // non-virtual helpers
+
+ void addRect(float x, float y, float width, float height) {
+ moveTo(x, y);
+ lineTo(x + width, y);
+ lineTo(x + width, y + height);
+ lineTo(x, y + height);
+ close();
+ }
+
+ void move(Vec2D v) { this->moveTo(v.x, v.y); }
+ void line(Vec2D v) { this->lineTo(v.x, v.y); }
+ void cubic(Vec2D a, Vec2D b, Vec2D c) {
+ this->cubicTo(a.x, a.y, b.x, b.y, c.x, c.y);
+ }
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class ContainerComponent;
-class Artboard;
-
-class Component : public ComponentBase {
- friend class Artboard;
-
-private:
- ContainerComponent* m_Parent = nullptr;
- std::vector<Component*> m_Dependents;
-
- unsigned int m_GraphOrder;
- Artboard* m_Artboard = nullptr;
-
-protected:
- ComponentDirt m_Dirt = ComponentDirt::Filthy;
-
-public:
- inline Artboard* artboard() const { return m_Artboard; }
- StatusCode onAddedDirty(CoreContext* context) override;
- inline ContainerComponent* parent() const { return m_Parent; }
- const std::vector<Component*>& dependents() const { return m_Dependents; }
- void addDependent(Component* component);
-
- // TODO: re-evaluate when more of the lib is complete...
- // These could be pure virtual but we define them empty here to avoid
- // having to implement them in a bunch of concrete classes that
- // currently don't use this logic.
- virtual void buildDependencies() {}
- virtual void onDirty(ComponentDirt dirt) {}
- virtual void update(ComponentDirt value) {}
-
- 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) {
- return (value & flag) != ComponentDirt::None;
- }
-
- StatusCode import(ImportStack& importStack) override;
-};
+ class ContainerComponent;
+ class Artboard;
+
+ class Component : public ComponentBase {
+ friend class Artboard;
+
+ private:
+ ContainerComponent* m_Parent = nullptr;
+ std::vector<Component*> m_Dependents;
+
+ unsigned int m_GraphOrder;
+ Artboard* m_Artboard = nullptr;
+
+ protected:
+ ComponentDirt m_Dirt = ComponentDirt::Filthy;
+
+ public:
+ inline Artboard* artboard() const { return m_Artboard; }
+ StatusCode onAddedDirty(CoreContext* context) override;
+ inline ContainerComponent* parent() const { return m_Parent; }
+ const std::vector<Component*>& dependents() const { return m_Dependents; }
+ void addDependent(Component* component);
+
+ // TODO: re-evaluate when more of the lib is complete...
+ // These could be pure virtual but we define them empty here to avoid
+ // having to implement them in a bunch of concrete classes that
+ // currently don't use this logic.
+ virtual void buildDependencies() {}
+ virtual void onDirty(ComponentDirt dirt) {}
+ virtual void update(ComponentDirt value) {}
+
+ 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) {
+ return (value & flag) != ComponentDirt::None;
+ }
+
+ StatusCode import(ImportStack& importStack) override;
+ };
} // namespace rive
#endif
#include <type_traits>
namespace rive {
-enum class ComponentDirt : unsigned short {
- None = 0,
+ enum class ComponentDirt : unsigned short {
+ None = 0,
- Dependents = 1 << 0,
+ Dependents = 1 << 0,
- /// General flag for components are dirty (if this is up, the update
- /// cycle runs). It gets automatically applied with any other dirt.
- Components = 1 << 1,
+ /// General flag for components are dirty (if this is up, the update
+ /// cycle runs). It gets automatically applied with any other dirt.
+ Components = 1 << 1,
- /// Draw order needs to be re-computed.
- DrawOrder = 1 << 2,
+ /// Draw order needs to be re-computed.
+ DrawOrder = 1 << 2,
- /// Path is dirty and needs to be rebuilt.
- Path = 1 << 3,
+ /// Path is dirty and needs to be rebuilt.
+ Path = 1 << 3,
- /// Skin needs to recompute bone transformations.
- Skin = 1 << 3,
+ /// Skin needs to recompute bone transformations.
+ Skin = 1 << 3,
- /// Vertices have changed, re-order cached lists.
- Vertices = 1 << 4,
+ /// Vertices have changed, re-order cached lists.
+ Vertices = 1 << 4,
- /// Used by any component that needs to recompute their local transform.
- /// Usually components that have their transform dirty will also have
- /// their worldTransform dirty.
- Transform = 1 << 5,
+ /// Used by any component that needs to recompute their local transform.
+ /// Usually components that have their transform dirty will also have
+ /// their worldTransform dirty.
+ Transform = 1 << 5,
- /// Used by any component that needs to update its world transform.
- WorldTransform = 1 << 6,
+ /// Used by any component that needs to update its world transform.
+ WorldTransform = 1 << 6,
- /// Marked when the stored render opacity needs to be updated.
- RenderOpacity = 1 << 7,
+ /// Marked when the stored render opacity needs to be updated.
+ RenderOpacity = 1 << 7,
- /// Dirt used to mark some stored paint needs to be rebuilt or that we
- /// just want to trigger an update cycle so painting occurs.
- Paint = 1 << 8,
+ /// Dirt used to mark some stored paint needs to be rebuilt or that we
+ /// just want to trigger an update cycle so painting occurs.
+ Paint = 1 << 8,
- /// Used by the gradients track when the stops need to be re-ordered.
- Stops = 1 << 9,
+ /// Used by the gradients track when the stops need to be re-ordered.
+ Stops = 1 << 9,
- /// Blend modes need to be updated
- // TODO: do we need this?
- // BlendMode = 1 << 9,
+ /// Blend modes need to be updated
+ // TODO: do we need this?
+ // BlendMode = 1 << 9,
- // Everything is dirty.
- Filthy = 0xFFFF
-};
+ // Everything is dirty.
+ Filthy = 0xFFFF
+ };
-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) {
+ 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) {
- 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) {
+ 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) {
- 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) {
+ 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) {
- return static_cast<ComponentDirt>(~static_cast<std::underlying_type<ComponentDirt>::type>(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) {
- lhs = static_cast<ComponentDirt>(static_cast<std::underlying_type<ComponentDirt>::type>(lhs) |
- static_cast<std::underlying_type<ComponentDirt>::type>(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;
-}
+ return lhs;
+ }
-inline ComponentDirt& operator&=(ComponentDirt& lhs, ComponentDirt rhs) {
- lhs = static_cast<ComponentDirt>(static_cast<std::underlying_type<ComponentDirt>::type>(lhs) &
- static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
+ 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;
-}
+ return lhs;
+ }
-inline ComponentDirt& operator^=(ComponentDirt& lhs, ComponentDirt rhs) {
- lhs = static_cast<ComponentDirt>(static_cast<std::underlying_type<ComponentDirt>::type>(lhs) ^
- static_cast<std::underlying_type<ComponentDirt>::type>(rhs));
+ 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;
-}
+ return lhs;
+ }
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/constraints/constraint_base.hpp"
#include <stdio.h>
namespace rive {
-class TransformComponent;
-class Mat2D;
+ class TransformComponent;
+ class Mat2D;
-class Constraint : public ConstraintBase {
-public:
- void strengthChanged() override;
- StatusCode onAddedClean(CoreContext* context) override;
- virtual void markConstraintDirty();
- virtual void constrain(TransformComponent* component) = 0;
- void buildDependencies() override;
- void onDirty(ComponentDirt dirt) override;
-};
+ class Constraint : public ConstraintBase {
+ public:
+ void strengthChanged() override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ virtual void markConstraintDirty();
+ virtual void constrain(TransformComponent* component) = 0;
+ void buildDependencies() override;
+ void onDirty(ComponentDirt dirt) override;
+ };
-const Mat2D& getParentWorld(const TransformComponent& component);
+ const Mat2D& getParentWorld(const TransformComponent& component);
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/constraints/distance_constraint_base.hpp"
#include <stdio.h>
namespace rive {
-class DistanceConstraint : public DistanceConstraintBase {
-public:
- void constrain(TransformComponent* component) override;
-};
+ class DistanceConstraint : public DistanceConstraintBase {
+ public:
+ void constrain(TransformComponent* component) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class Bone;
-class IKConstraint : public IKConstraintBase {
-private:
- struct BoneChainLink {
- int index;
- Bone* bone;
- float angle;
- TransformComponents transformComponents;
- Mat2D parentWorldInverse;
- };
- std::vector<BoneChainLink> m_FkChain;
- void solve1(BoneChainLink* fk1, const Vec2D& worldTargetTranslation);
- void solve2(BoneChainLink* fk1, BoneChainLink* fk2, const Vec2D& worldTargetTranslation);
- void constrainRotation(BoneChainLink& fk, float rotation);
+ class Bone;
+ class IKConstraint : public IKConstraintBase {
+ private:
+ struct BoneChainLink {
+ int index;
+ Bone* bone;
+ float angle;
+ TransformComponents transformComponents;
+ Mat2D parentWorldInverse;
+ };
+ std::vector<BoneChainLink> m_FkChain;
+ void solve1(BoneChainLink* fk1, const Vec2D& worldTargetTranslation);
+ void solve2(BoneChainLink* fk1, BoneChainLink* fk2, const Vec2D& worldTargetTranslation);
+ void constrainRotation(BoneChainLink& fk, float rotation);
-public:
- void markConstraintDirty() override;
- StatusCode onAddedClean(CoreContext* context) override;
- void constrain(TransformComponent* component) override;
- void buildDependencies() override;
-};
+ public:
+ void markConstraintDirty() override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ void constrain(TransformComponent* component) override;
+ void buildDependencies() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/math/transform_components.hpp"
#include <stdio.h>
namespace rive {
-class RotationConstraint : public RotationConstraintBase {
-private:
- TransformComponents m_ComponentsA;
- TransformComponents m_ComponentsB;
+ class RotationConstraint : public RotationConstraintBase {
+ private:
+ TransformComponents m_ComponentsA;
+ TransformComponents m_ComponentsB;
-public:
- void constrain(TransformComponent* component) override;
-};
+ public:
+ void constrain(TransformComponent* component) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/math/transform_components.hpp"
#include <stdio.h>
namespace rive {
-class ScaleConstraint : public ScaleConstraintBase {
-private:
- TransformComponents m_ComponentsA;
- TransformComponents m_ComponentsB;
+ class ScaleConstraint : public ScaleConstraintBase {
+ private:
+ TransformComponents m_ComponentsA;
+ TransformComponents m_ComponentsB;
-public:
- void constrain(TransformComponent* component) override;
-};
+ public:
+ void constrain(TransformComponent* component) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/constraints/targeted_constraint_base.hpp"
#include <stdio.h>
namespace rive {
-class TransformComponent;
-class TargetedConstraint : public TargetedConstraintBase {
-protected:
- TransformComponent* m_Target = nullptr;
+ class TransformComponent;
+ class TargetedConstraint : public TargetedConstraintBase {
+ protected:
+ TransformComponent* m_Target = nullptr;
-public:
- void buildDependencies() override;
- StatusCode onAddedDirty(CoreContext* context) override;
-};
+ public:
+ void buildDependencies() override;
+ StatusCode onAddedDirty(CoreContext* context) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/transform_space.hpp"
#include <stdio.h>
namespace rive {
-class TransformComponentConstraint : public TransformComponentConstraintBase {
-public:
- TransformSpace minMaxSpace() const { return (TransformSpace)minMaxSpaceValue(); }
-};
+ class TransformComponentConstraint : public TransformComponentConstraintBase {
+ public:
+ TransformSpace minMaxSpace() const { return (TransformSpace)minMaxSpaceValue(); }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/constraints/transform_component_constraint_y_base.hpp"
#include <stdio.h>
namespace rive {
-class TransformComponentConstraintY : public TransformComponentConstraintYBase {
-public:
-};
+ class TransformComponentConstraintY : public TransformComponentConstraintYBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <stdio.h>
namespace rive {
-class TransformConstraint : public TransformConstraintBase {
-private:
- TransformComponents m_ComponentsA;
- TransformComponents m_ComponentsB;
+ class TransformConstraint : public TransformConstraintBase {
+ private:
+ TransformComponents m_ComponentsA;
+ TransformComponents m_ComponentsB;
-public:
- void constrain(TransformComponent* component) override;
-};
+ public:
+ void constrain(TransformComponent* component) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/transform_space.hpp"
#include <stdio.h>
namespace rive {
-class TransformSpaceConstraint : public TransformSpaceConstraintBase {
-public:
- TransformSpace sourceSpace() const { return (TransformSpace)sourceSpaceValue(); }
- TransformSpace destSpace() const { return (TransformSpace)destSpaceValue(); }
-};
+ class TransformSpaceConstraint : public TransformSpaceConstraintBase {
+ public:
+ TransformSpace sourceSpace() const { return (TransformSpace)sourceSpaceValue(); }
+ TransformSpace destSpace() const { return (TransformSpace)destSpaceValue(); }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/constraints/translation_constraint_base.hpp"
#include <stdio.h>
namespace rive {
-class TranslationConstraint : public TranslationConstraintBase {
-public:
- void constrain(TransformComponent* component) override;
-};
+ class TranslationConstraint : public TranslationConstraintBase {
+ public:
+ void constrain(TransformComponent* component) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/container_component_base.hpp"
#include <vector>
namespace rive {
-class ContainerComponent : public ContainerComponentBase {};
+ class ContainerComponent : public ContainerComponentBase {};
} // namespace rive
#endif
\ No newline at end of file
#include "rive/status_code.hpp"
namespace rive {
-class CoreContext;
-class ImportStack;
-class Core {
-public:
- static const int invalidPropertyKey = 0;
- virtual ~Core() {}
- virtual uint16_t coreType() const = 0;
- virtual bool isTypeOf(uint16_t typeKey) const = 0;
- virtual bool deserialize(uint16_t propertyKey, BinaryReader& reader) = 0;
-
- template <typename T> inline bool is() const { return isTypeOf(T::typeKey); }
- template <typename T> inline T* as() {
- assert(is<T>());
- return reinterpret_cast<T*>(this);
- }
-
- /// Make a shallow copy of the object.
- virtual Core* clone() const { return nullptr; }
-
- template <typename T> inline const T* as() const {
- assert(is<T>());
- return reinterpret_cast<const T*>(this);
- }
-
- /// Called when the object is first added to the context, other objects
- /// may not have resolved their dependencies yet. This is an opportunity
- /// to look up objects referenced by id, but not assume that they in
- /// turn have resolved their references yet. Called during
- /// load/instance.
- virtual StatusCode onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
-
- /// Called when all the objects in the context have had onAddedDirty
- /// called. This is an opportunity to reference things referenced by
- /// dependencies. (A path should be able to find a Shape somewhere in
- /// its hierarchy, which may be multiple levels up).
- virtual StatusCode onAddedClean(CoreContext* context) { return StatusCode::Ok; }
-
- virtual StatusCode import(ImportStack& importStack) { return StatusCode::Ok; }
-};
+ class CoreContext;
+ class ImportStack;
+ class Core {
+ public:
+ static const int invalidPropertyKey = 0;
+ virtual ~Core() {}
+ virtual uint16_t coreType() const = 0;
+ virtual bool isTypeOf(uint16_t typeKey) const = 0;
+ virtual bool deserialize(uint16_t propertyKey, BinaryReader& reader) = 0;
+
+ template <typename T> inline bool is() const { return isTypeOf(T::typeKey); }
+ template <typename T> inline T* as() {
+ assert(is<T>());
+ return reinterpret_cast<T*>(this);
+ }
+
+ /// Make a shallow copy of the object.
+ virtual Core* clone() const { return nullptr; }
+
+ template <typename T> inline const T* as() const {
+ assert(is<T>());
+ return reinterpret_cast<const T*>(this);
+ }
+
+ /// Called when the object is first added to the context, other objects
+ /// may not have resolved their dependencies yet. This is an opportunity
+ /// to look up objects referenced by id, but not assume that they in
+ /// turn have resolved their references yet. Called during
+ /// load/instance.
+ virtual StatusCode onAddedDirty(CoreContext* context) { return StatusCode::Ok; }
+
+ /// Called when all the objects in the context have had onAddedDirty
+ /// called. This is an opportunity to reference things referenced by
+ /// dependencies. (A path should be able to find a Shape somewhere in
+ /// its hierarchy, which may be multiple levels up).
+ virtual StatusCode onAddedClean(CoreContext* context) { return StatusCode::Ok; }
+
+ virtual StatusCode import(ImportStack& importStack) { return StatusCode::Ok; }
+ };
} // namespace rive
#endif
#include "rive/core/type_conversions.hpp"
namespace rive {
-class BinaryReader {
-private:
- Span<const uint8_t> m_Bytes;
- const uint8_t* m_Position;
- bool m_Overflowed;
- bool m_IntRangeError;
-
- void overflow();
- void intRangeError();
-
-public:
- explicit BinaryReader(Span<const uint8_t>);
- bool didOverflow() const;
- bool didIntRangeError() const;
- bool hasError() const { return m_Overflowed || m_IntRangeError; }
- bool reachedEnd() const;
-
- size_t lengthInBytes() const;
- const uint8_t* position() const;
-
- std::string readString();
- Span<const uint8_t> readBytes();
- float readFloat32();
- uint8_t readByte();
- uint32_t readUint32();
- uint64_t readVarUint64(); // Reads a LEB128 encoded uint64_t
-
- // 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() {
- auto value = this->readVarUint64();
- if (!fitsIn<T>(value)) {
- value = 0;
- this->intRangeError();
+ class BinaryReader {
+ private:
+ Span<const uint8_t> m_Bytes;
+ const uint8_t* m_Position;
+ bool m_Overflowed;
+ bool m_IntRangeError;
+
+ void overflow();
+ void intRangeError();
+
+ public:
+ explicit BinaryReader(Span<const uint8_t>);
+ bool didOverflow() const;
+ bool didIntRangeError() const;
+ bool hasError() const { return m_Overflowed || m_IntRangeError; }
+ bool reachedEnd() const;
+
+ size_t lengthInBytes() const;
+
+ std::string readString();
+ Span<const uint8_t> readBytes();
+ float readFloat32();
+ uint8_t readByte();
+ uint32_t readUint32();
+ uint64_t readVarUint64(); // Reads a LEB128 encoded uint64_t
+
+ // 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() {
+ auto value = this->readVarUint64();
+ if (!fitsIn<T>(value)) {
+ value = 0;
+ this->intRangeError();
+ }
+ return static_cast<T>(value);
}
- return static_cast<T>(value);
- }
-};
+ };
} // namespace rive
#endif
#define _RIVE_CORE_BOOL_TYPE_HPP_
namespace rive {
-class BinaryReader;
-class CoreBoolType {
-public:
- static const int id = 0;
- static bool deserialize(BinaryReader& reader);
-};
+ class BinaryReader;
+ class CoreBoolType {
+ public:
+ static const int id = 0;
+ static bool deserialize(BinaryReader& reader);
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <cstdint>
namespace rive {
-class BinaryReader;
-class CoreBytesType {
-public:
- static const int id = 1;
- static Span<const uint8_t> deserialize(BinaryReader& reader);
-};
+ class BinaryReader;
+ class CoreBytesType {
+ public:
+ static const int id = 1;
+ static Span<const uint8_t> deserialize(BinaryReader& reader);
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CORE_COLOR_TYPE_HPP_
namespace rive {
-class BinaryReader;
-class CoreColorType {
-public:
- static const int id = 3;
- static int deserialize(BinaryReader& reader);
-};
+ class BinaryReader;
+ class CoreColorType {
+ public:
+ static const int id = 3;
+ static int deserialize(BinaryReader& reader);
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CORE_DOUBLE_TYPE_HPP_
namespace rive {
-class BinaryReader;
-class CoreDoubleType {
-public:
- static const int id = 2;
- static float deserialize(BinaryReader& reader);
-};
+ class BinaryReader;
+ class CoreDoubleType {
+ public:
+ static const int id = 2;
+ static float deserialize(BinaryReader& reader);
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <string>
namespace rive {
-class BinaryReader;
-class CoreStringType {
-public:
- static const int id = 1;
- static std::string deserialize(BinaryReader& reader);
-};
+ class BinaryReader;
+ class CoreStringType {
+ public:
+ static const int id = 1;
+ static std::string deserialize(BinaryReader& reader);
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CORE_UINT_TYPE_HPP_
namespace rive {
-class BinaryReader;
-class CoreUintType {
-public:
- static const int id = 0;
- static unsigned int deserialize(BinaryReader& reader);
-};
+ class BinaryReader;
+ class CoreUintType {
+ public:
+ static const int id = 0;
+ static unsigned int deserialize(BinaryReader& reader);
+ };
} // namespace rive
#endif
\ No newline at end of file
/* Decodes a string
*/
-inline uint64_t
+inline size_t
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;
namespace rive {
template <typename T> bool fitsIn(intmax_t x) {
- return x >= std::numeric_limits<T>::min() && x <= std::numeric_limits<T>::max();
+ return x >= std::numeric_limits<T>::min() &&
+ x <= std::numeric_limits<T>::max();
}
template <typename T> T castTo(intmax_t x) {
- assert(sizeof(T) <= 4); // don't cast to 64bit types
+ assert(sizeof(T) <= 4); // don't cast to 64bit types
assert(fitsIn<T>(x));
return static_cast<T>(x);
}
-} // namespace rive
+} // namespace
#endif
#include "rive/rive_types.hpp"
namespace rive {
-class Artboard;
-class Core;
-class CoreContext {
-public:
- virtual ~CoreContext() {}
- virtual Core* resolve(uint32_t id) const = 0;
-};
+ class Artboard;
+ class Core;
+ class CoreContext {
+ public:
+ virtual Core* resolve(uint32_t id) const = 0;
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class Component;
-class DependencySorter {
-private:
- std::unordered_set<Component*> m_Perm;
- std::unordered_set<Component*> m_Temp;
+ class Component;
+ class DependencySorter {
+ private:
+ std::unordered_set<Component*> m_Perm;
+ std::unordered_set<Component*> m_Temp;
-public:
- void sort(Component* root, std::vector<Component*>& order);
- bool visit(Component* component, std::vector<Component*>& order);
-};
+ public:
+ void sort(Component* root, std::vector<Component*>& order);
+ bool visit(Component* component, std::vector<Component*>& order);
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/draw_rules_base.hpp"
#include <stdio.h>
namespace rive {
-class DrawTarget;
-class DrawRules : public DrawRulesBase {
-private:
- DrawTarget* m_ActiveTarget = nullptr;
+ class DrawTarget;
+ class DrawRules : public DrawRulesBase {
+ private:
+ DrawTarget* m_ActiveTarget = nullptr;
-public:
- DrawTarget* activeTarget() const { return m_ActiveTarget; }
+ public:
+ DrawTarget* activeTarget() const { return m_ActiveTarget; }
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
-protected:
- void drawTargetIdChanged() override;
-};
+ protected:
+ void drawTargetIdChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <stdio.h>
namespace rive {
-class Drawable;
-class Artboard;
-class DrawTarget : public DrawTargetBase {
- friend class Artboard;
+ class Drawable;
+ class Artboard;
+ class DrawTarget : public DrawTargetBase {
+ friend class Artboard;
-private:
- Drawable* m_Drawable = nullptr;
+ private:
+ Drawable* m_Drawable = nullptr;
- // Controlled by the artboard.
- Drawable* first = nullptr;
- Drawable* last = nullptr;
+ // Controlled by the artboard.
+ Drawable* first = nullptr;
+ Drawable* last = nullptr;
-public:
- Drawable* drawable() const { return m_Drawable; }
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
+ public:
+ Drawable* drawable() const { return m_Drawable; }
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
- DrawTargetPlacement placement() const { return (DrawTargetPlacement)placementValue(); }
+ DrawTargetPlacement placement() const { return (DrawTargetPlacement)placementValue(); }
-protected:
- void placementValueChanged() override;
-};
+ protected:
+ void placementValueChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_DRAW_TARGET_PLACEMENT_HPP_
#define _RIVE_DRAW_TARGET_PLACEMENT_HPP_
namespace rive {
-enum class DrawTargetPlacement : unsigned char { before = 0, after = 1 };
+ enum class DrawTargetPlacement : unsigned char { before = 0, after = 1 };
}
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class ClippingShape;
-class Artboard;
-class DrawRules;
+ class ClippingShape;
+ class Artboard;
+ class DrawRules;
-class Drawable : public DrawableBase {
- friend class Artboard;
+ class Drawable : public DrawableBase {
+ friend class Artboard;
-private:
- std::vector<ClippingShape*> m_ClippingShapes;
+ private:
+ std::vector<ClippingShape*> m_ClippingShapes;
- /// Used exclusively by the artboard;
- DrawRules* flattenedDrawRules = nullptr;
- Drawable* prev = nullptr;
- Drawable* next = nullptr;
+ /// Used exclusively by the artboard;
+ DrawRules* flattenedDrawRules = nullptr;
+ Drawable* prev = nullptr;
+ Drawable* next = nullptr;
-public:
- BlendMode blendMode() const { return (BlendMode)blendModeValue(); }
- bool clip(Renderer* renderer) const;
- virtual void draw(Renderer* renderer) = 0;
- virtual Core* hitTest(HitInfo*, const Mat2D&) = 0;
- void addClippingShape(ClippingShape* shape);
- inline const std::vector<ClippingShape*>& clippingShapes() const { return m_ClippingShapes; }
+ public:
+ BlendMode blendMode() const { return (BlendMode)blendModeValue(); }
+ bool clip(Renderer* renderer) const;
+ virtual void draw(Renderer* renderer) = 0;
+ virtual Core* hitTest(HitInfo*, const Mat2D&) = 0;
+ void addClippingShape(ClippingShape* shape);
+ inline const std::vector<ClippingShape*>& clippingShapes() const {
+ return m_ClippingShapes;
+ }
- 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;
- }
-};
+ 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;
+ }
+ };
} // namespace rive
#endif
--- /dev/null
+#ifndef _RIVE_EVENT_TYPE_HPP_
+#define _RIVE_EVENT_TYPE_HPP_
+namespace rive {
+ enum class EventType : int {
+ updateHover = -1,
+ enter = 0,
+ exit = 1,
+ down = 2,
+ up = 3,
+ };
+}
+#endif
\ No newline at end of file
#define _RIVE_FACTORY_HPP_
#include "rive/renderer.hpp"
-#include "rive/render_text.hpp"
#include "rive/refcnt.hpp"
#include "rive/span.hpp"
#include "rive/math/aabb.hpp"
namespace rive {
-class Factory {
-public:
- Factory() {}
- virtual ~Factory() {}
-
- virtual rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) = 0;
- virtual rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) = 0;
- virtual rcp<RenderBuffer> makeBufferF32(Span<const float>) = 0;
-
- virtual rcp<RenderShader> makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) = 0;
-
- virtual rcp<RenderShader> makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) = 0;
-
- // Returns a full-formed RenderPath -- can be treated as immutable
- virtual std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule) = 0;
-
- // Deprecated -- working to make RenderPath's immutable
- virtual std::unique_ptr<RenderPath> makeEmptyRenderPath() = 0;
-
- virtual std::unique_ptr<RenderPaint> makeRenderPaint() = 0;
-
- virtual std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) = 0;
-
- virtual rcp<RenderFont> decodeFont(Span<const uint8_t>) { return nullptr; }
-
- // Non-virtual helpers
-
- std::unique_ptr<RenderPath> makeRenderPath(const AABB&);
- std::unique_ptr<RenderPath> makeRenderPath(const RawPath&, FillRule);
-};
+ class Factory {
+ public:
+ Factory() {}
+ virtual ~Factory() {}
+
+ virtual rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) = 0;
+ virtual rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) = 0;
+ virtual rcp<RenderBuffer> makeBufferF32(Span<const float>) = 0;
+
+ virtual rcp<RenderShader> makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) = 0;
+
+ virtual rcp<RenderShader> makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) = 0;
+
+ // Returns a full-formed RenderPath -- can be treated as immutable
+ virtual std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
+ Span<const uint8_t> verbs,
+ FillRule) = 0;
+
+ virtual std::unique_ptr<RenderPath> makeEmptyRenderPath() = 0;
+
+ virtual std::unique_ptr<RenderPaint> makeRenderPaint() = 0;
+
+ virtual std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) = 0;
+ };
} // namespace rive
#endif
#include "rive/factory.hpp"
#include "rive/file_asset_resolver.hpp"
#include <vector>
-#include <set>
///
/// Default namespace for Rive Cpp runtime code.
///
namespace rive {
-class BinaryReader;
-class RuntimeHeader;
-class Factory;
-
-///
-/// Tracks the success/failure result when importing a Rive file.
-///
-enum class ImportResult {
- /// Indicates that a file's been successfully imported.
- success,
- /// Indicates that the Rive file is not supported by this runtime.
- unsupportedVersion,
- /// Indicates that the there is a formatting problem in the file itself.
- malformed
-};
-
-///
-/// A Rive file.
-///
-class File {
-public:
- /// Major version number supported by the runtime.
- static const int majorVersion = 7;
- /// Minor version number supported by the runtime.
- static const int minorVersion = 0;
-
-private:
- /// The file's backboard. All Rive files have a single backboard
- /// where the artboards live.
- std::unique_ptr<Backboard> m_Backboard;
-
- /// We just keep these alive for the life of this File
- std::vector<std::unique_ptr<FileAsset>> m_FileAssets;
-
- /// List of artboards in the file. Each artboard encapsulates a set of
- /// Rive components and animations.
- std::vector<std::unique_ptr<Artboard>> m_Artboards;
-
- Factory* m_Factory;
-
- /// The helper used to resolve assets when they're not provided in-band
- /// with the file.
- FileAssetResolver* m_AssetResolver;
-
- File(Factory*, FileAssetResolver*);
-
-public:
- ~File();
+ class BinaryReader;
+ class RuntimeHeader;
+ class Factory;
///
- /// Imports a Rive file from a binary buffer.
- /// @param data the raw date of the file.
- /// @param result is an optional status result.
- /// @param assetResolver is an optional helper to resolve assets which
- /// cannot be found in-band.
- /// @returns a pointer to the file, or null on failure.
- static std::unique_ptr<File> import(Span<const uint8_t> data,
- Factory*,
- ImportResult* result = nullptr,
- FileAssetResolver* assetResolver = nullptr);
-
- /// @returns the file's backboard. All files have exactly one backboard.
- Backboard* backboard() const { return m_Backboard.get(); }
-
- /// @returns the number of artboards in the file.
- size_t artboardCount() const { return m_Artboards.size(); }
- std::string artboardNameAt(size_t index) const;
-
- // Instances
- std::unique_ptr<ArtboardInstance> artboardDefault() const;
- std::unique_ptr<ArtboardInstance> artboardAt(size_t index) const;
- std::unique_ptr<ArtboardInstance> artboardNamed(std::string name) const;
-
- Artboard* artboard() const;
-
- /// @returns the named artboard. If no artboard is found with that name,
- /// the null pointer is returned.
- Artboard* artboard(std::string name) const;
-
- /// @returns the artboard at the specified index, or the nullptr if the
- /// index is out of range.
- Artboard* artboard(size_t index) const;
-
-#ifdef WITH_RIVE_TOOLS
- /// Strips FileAssetContents for FileAssets of given typeKeys.
- /// @param data the raw data of the file.
- /// @param result is an optional status result.
- /// @returns the data buffer of the file with the FileAssetContents objects
- /// stripped out.
- static const std::vector<uint8_t> stripAssets(Span<const uint8_t> data,
- std::set<uint16_t> typeKeys,
- ImportResult* result = nullptr);
-#endif
+ /// Tracks the success/failure result when importing a Rive file.
+ ///
+ enum class ImportResult {
+ /// Indicates that a file's been successfully imported.
+ success,
+ /// Indicates that the Rive file is not supported by this runtime.
+ unsupportedVersion,
+ /// Indicates that the there is a formatting problem in the file itself.
+ malformed
+ };
-private:
- ImportResult read(BinaryReader&, const RuntimeHeader&);
-};
+ ///
+ /// A Rive file.
+ ///
+ class File {
+ public:
+ /// Major version number supported by the runtime.
+ static const int majorVersion = 7;
+ /// Minor version number supported by the runtime.
+ static const int minorVersion = 0;
+
+ private:
+ /// The file's backboard. All Rive files have a single backboard
+ /// where the artboards live.
+ std::unique_ptr<Backboard> m_Backboard;
+
+ /// List of artboards in the file. Each artboard encapsulates a set of
+ /// Rive components and animations.
+ std::vector<std::unique_ptr<Artboard>> m_Artboards;
+
+ Factory* m_Factory;
+
+ /// The helper used to resolve assets when they're not provided in-band
+ /// with the file.
+ FileAssetResolver* m_AssetResolver;
+
+ File(Factory*, FileAssetResolver*);
+
+ public:
+ ~File();
+
+ ///
+ /// Imports a Rive file from a binary buffer.
+ /// @param data the raw date of the file.
+ /// @param result is an optional status result.
+ /// @param assetResolver is an optional helper to resolve assets which
+ /// cannot be found in-band.
+ /// @returns a pointer to the file, or null on failure.
+ static std::unique_ptr<File> import(Span<const uint8_t> data,
+ Factory*,
+ ImportResult* result = nullptr,
+ FileAssetResolver* assetResolver = nullptr);
+
+ /// @returns the file's backboard. All files have exactly one backboard.
+ Backboard* backboard() const { return m_Backboard.get(); }
+
+ /// @returns the number of artboards in the file.
+ size_t artboardCount() const { return m_Artboards.size(); }
+ std::string artboardNameAt(size_t index) const;
+
+ // Instances
+ std::unique_ptr<ArtboardInstance> artboardDefault() const;
+ std::unique_ptr<ArtboardInstance> artboardAt(size_t index) const;
+ std::unique_ptr<ArtboardInstance> artboardNamed(std::string name) const;
+
+ Artboard* artboard() const;
+
+ /// @returns the named artboard. If no artboard is found with that name,
+ /// the null pointer is returned.
+ Artboard* artboard(std::string name) const;
+
+ /// @returns the artboard at the specified index, or the nullptr if the
+ /// index is out of range.
+ Artboard* artboard(size_t index) const;
+
+ private:
+ ImportResult read(BinaryReader&, const RuntimeHeader&);
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class FileAsset;
-class FileAssetResolver {
-public:
- virtual ~FileAssetResolver() {}
-
- /// Expected to be overridden to find asset contents when not provided
- /// in band.
- /// @param asset describes the asset that Rive is looking for the
- /// contents of.
- virtual void loadContents(FileAsset& asset) = 0;
-};
+ class FileAsset;
+ class FileAssetResolver {
+ public:
+ /// Expected to be overridden to find asset contents when not provided
+ /// in band.
+ /// @param asset describes the asset that Rive is looking for the
+ /// contents of.
+ virtual void loadContents(FileAsset& asset) = 0;
+ };
} // namespace rive
#endif
#include "rive/core.hpp"
#include "rive/core/field_types/core_string_type.hpp"
namespace rive {
-class AnimationBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 27;
-
- /// 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;
+ class AnimationBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 27;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t namePropertyKey = 55;
+ static const uint16_t namePropertyKey = 55;
-private:
- std::string m_Name = "";
+ private:
+ std::string m_Name = "";
-public:
- inline const std::string& name() const { return m_Name; }
- void name(std::string value) {
- if (m_Name == value) {
- return;
+ public:
+ inline const std::string& name() const { return m_Name; }
+ void name(std::string value) {
+ if (m_Name == value) {
+ return;
+ }
+ m_Name = value;
+ nameChanged();
}
- m_Name = value;
- nameChanged();
- }
- Core* clone() const override;
- void copy(const AnimationBase& object) { m_Name = object.m_Name; }
+ 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;
}
- return false;
- }
-protected:
- virtual void nameChanged() {}
-};
+ protected:
+ virtual void nameChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/layer_state.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class AnimationStateBase : public LayerState {
-protected:
- typedef LayerState Super;
-
-public:
- static const uint16_t typeKey = 61;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case AnimationStateBase::typeKey:
- case LayerStateBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ class AnimationStateBase : public LayerState {
+ protected:
+ typedef LayerState Super;
+
+ public:
+ static const uint16_t typeKey = 61;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case AnimationStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t animationIdPropertyKey = 149;
+ static const uint16_t animationIdPropertyKey = 149;
-private:
- uint32_t m_AnimationId = -1;
+ private:
+ uint32_t m_AnimationId = -1;
-public:
- inline uint32_t animationId() const { return m_AnimationId; }
- void animationId(uint32_t value) {
- if (m_AnimationId == value) {
- return;
+ public:
+ inline uint32_t animationId() const { return m_AnimationId; }
+ void animationId(uint32_t value) {
+ if (m_AnimationId == value) {
+ return;
+ }
+ m_AnimationId = value;
+ animationIdChanged();
}
- m_AnimationId = value;
- animationIdChanged();
- }
-
- Core* clone() const override;
- void copy(const AnimationStateBase& object) {
- m_AnimationId = object.m_AnimationId;
- LayerState::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case animationIdPropertyKey:
- m_AnimationId = CoreUintType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const AnimationStateBase& object) {
+ m_AnimationId = object.m_AnimationId;
+ LayerState::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case animationIdPropertyKey:
+ m_AnimationId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return LayerState::deserialize(propertyKey, reader);
}
- return LayerState::deserialize(propertyKey, reader);
- }
-protected:
- virtual void animationIdChanged() {}
-};
+ protected:
+ virtual void animationIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_ANY_STATE_BASE_HPP_
#include "rive/animation/layer_state.hpp"
namespace rive {
-class AnyStateBase : public LayerState {
-protected:
- typedef LayerState Super;
+ class AnyStateBase : public LayerState {
+ protected:
+ typedef LayerState Super;
-public:
- static const uint16_t typeKey = 62;
+ public:
+ static const uint16_t typeKey = 62;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case AnyStateBase::typeKey:
- case LayerStateBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case AnyStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/blend_animation.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class BlendAnimation1DBase : public BlendAnimation {
-protected:
- typedef BlendAnimation Super;
-
-public:
- static const uint16_t typeKey = 75;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case BlendAnimation1DBase::typeKey:
- case BlendAnimationBase::typeKey: return true;
- default: return false;
+ class BlendAnimation1DBase : public BlendAnimation {
+ protected:
+ typedef BlendAnimation Super;
+
+ public:
+ static const uint16_t typeKey = 75;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case BlendAnimation1DBase::typeKey:
+ case BlendAnimationBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 166;
+ static const uint16_t valuePropertyKey = 166;
-private:
- float m_Value = 0.0f;
+ private:
+ float m_Value = 0.0f;
-public:
- inline float value() const { return m_Value; }
- void value(float value) {
- if (m_Value == value) {
- return;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return BlendAnimation::deserialize(propertyKey, reader);
}
- return BlendAnimation::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class BlendAnimationBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 74;
-
- /// 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;
+ class BlendAnimationBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 74;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t animationIdPropertyKey = 165;
+ static const uint16_t animationIdPropertyKey = 165;
-private:
- uint32_t m_AnimationId = -1;
+ private:
+ uint32_t m_AnimationId = -1;
-public:
- inline uint32_t animationId() const { return m_AnimationId; }
- void animationId(uint32_t value) {
- if (m_AnimationId == value) {
- return;
+ public:
+ inline uint32_t animationId() const { return m_AnimationId; }
+ void animationId(uint32_t value) {
+ if (m_AnimationId == value) {
+ return;
+ }
+ m_AnimationId = value;
+ animationIdChanged();
}
- m_AnimationId = value;
- animationIdChanged();
- }
- void copy(const BlendAnimationBase& object) { m_AnimationId = object.m_AnimationId; }
+ void copy(const BlendAnimationBase& object) { m_AnimationId = object.m_AnimationId; }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case animationIdPropertyKey:
- m_AnimationId = CoreUintType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case animationIdPropertyKey:
+ m_AnimationId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return false;
}
- return false;
- }
-protected:
- virtual void animationIdChanged() {}
-};
+ protected:
+ virtual void animationIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/blend_animation.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class BlendAnimationDirectBase : public BlendAnimation {
-protected:
- typedef BlendAnimation Super;
-
-public:
- static const uint16_t typeKey = 77;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case BlendAnimationDirectBase::typeKey:
- case BlendAnimationBase::typeKey: return true;
- default: return false;
+ class BlendAnimationDirectBase : public BlendAnimation {
+ protected:
+ typedef BlendAnimation Super;
+
+ public:
+ static const uint16_t typeKey = 77;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case BlendAnimationDirectBase::typeKey:
+ case BlendAnimationBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inputIdPropertyKey = 168;
+ static const uint16_t inputIdPropertyKey = 168;
-private:
- uint32_t m_InputId = -1;
+ private:
+ uint32_t m_InputId = -1;
-public:
- inline uint32_t inputId() const { return m_InputId; }
- void inputId(uint32_t value) {
- if (m_InputId == value) {
- return;
+ public:
+ inline uint32_t inputId() const { return m_InputId; }
+ void inputId(uint32_t value) {
+ if (m_InputId == value) {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
}
- m_InputId = value;
- inputIdChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return BlendAnimation::deserialize(propertyKey, reader);
}
- return BlendAnimation::deserialize(propertyKey, reader);
- }
-protected:
- virtual void inputIdChanged() {}
-};
+ protected:
+ virtual void inputIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/blend_state.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class BlendState1DBase : public BlendState {
-protected:
- typedef BlendState Super;
-
-public:
- static const uint16_t typeKey = 76;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class BlendState1DBase : public BlendState {
+ protected:
+ typedef BlendState Super;
+
+ public:
+ static const uint16_t typeKey = 76;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inputIdPropertyKey = 167;
+ static const uint16_t inputIdPropertyKey = 167;
-private:
- uint32_t m_InputId = -1;
+ private:
+ uint32_t m_InputId = -1;
-public:
- inline uint32_t inputId() const { return m_InputId; }
- void inputId(uint32_t value) {
- if (m_InputId == value) {
- return;
+ public:
+ inline uint32_t inputId() const { return m_InputId; }
+ void inputId(uint32_t value) {
+ if (m_InputId == value) {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
}
- m_InputId = value;
- inputIdChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return BlendState::deserialize(propertyKey, reader);
}
- return BlendState::deserialize(propertyKey, reader);
- }
-protected:
- virtual void inputIdChanged() {}
-};
+ protected:
+ virtual void inputIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_BLEND_STATE_BASE_HPP_
#include "rive/animation/layer_state.hpp"
namespace rive {
-class BlendStateBase : public LayerState {
-protected:
- typedef LayerState Super;
+ class BlendStateBase : public LayerState {
+ protected:
+ typedef LayerState Super;
-public:
- static const uint16_t typeKey = 72;
+ public:
+ static const uint16_t typeKey = 72;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case BlendStateBase::typeKey:
- case LayerStateBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case BlendStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_BLEND_STATE_DIRECT_BASE_HPP_
#include "rive/animation/blend_state.hpp"
namespace rive {
-class BlendStateDirectBase : public BlendState {
-protected:
- typedef BlendState Super;
+ class BlendStateDirectBase : public BlendState {
+ protected:
+ typedef BlendState Super;
-public:
- static const uint16_t typeKey = 73;
+ public:
+ static const uint16_t typeKey = 73;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/state_transition.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class BlendStateTransitionBase : public StateTransition {
-protected:
- typedef StateTransition Super;
-
-public:
- static const uint16_t typeKey = 78;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case BlendStateTransitionBase::typeKey:
- case StateTransitionBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ class BlendStateTransitionBase : public StateTransition {
+ protected:
+ typedef StateTransition Super;
+
+ public:
+ static const uint16_t typeKey = 78;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case BlendStateTransitionBase::typeKey:
+ case StateTransitionBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t exitBlendAnimationIdPropertyKey = 171;
+ static const uint16_t exitBlendAnimationIdPropertyKey = 171;
-private:
- uint32_t m_ExitBlendAnimationId = -1;
+ private:
+ uint32_t m_ExitBlendAnimationId = -1;
-public:
- inline uint32_t exitBlendAnimationId() const { return m_ExitBlendAnimationId; }
- void exitBlendAnimationId(uint32_t value) {
- if (m_ExitBlendAnimationId == value) {
- return;
+ public:
+ inline uint32_t exitBlendAnimationId() const { return m_ExitBlendAnimationId; }
+ void exitBlendAnimationId(uint32_t value) {
+ if (m_ExitBlendAnimationId == value) {
+ return;
+ }
+ m_ExitBlendAnimationId = value;
+ exitBlendAnimationIdChanged();
}
- m_ExitBlendAnimationId = value;
- exitBlendAnimationIdChanged();
- }
-
- Core* clone() const override;
- void copy(const BlendStateTransitionBase& object) {
- m_ExitBlendAnimationId = object.m_ExitBlendAnimationId;
- StateTransition::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case exitBlendAnimationIdPropertyKey:
- m_ExitBlendAnimationId = CoreUintType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const BlendStateTransitionBase& object) {
+ m_ExitBlendAnimationId = object.m_ExitBlendAnimationId;
+ StateTransition::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case exitBlendAnimationIdPropertyKey:
+ m_ExitBlendAnimationId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return StateTransition::deserialize(propertyKey, reader);
}
- return StateTransition::deserialize(propertyKey, reader);
- }
-protected:
- virtual void exitBlendAnimationIdChanged() {}
-};
+ protected:
+ virtual void exitBlendAnimationIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class CubicInterpolatorBase : public Core {
-protected:
- typedef Core Super;
+ class CubicInterpolatorBase : public Core {
+ protected:
+ typedef Core Super;
-public:
- static const uint16_t typeKey = 28;
+ public:
+ static const uint16_t typeKey = 28;
- /// 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;
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t x1PropertyKey = 63;
- static const uint16_t y1PropertyKey = 64;
- static const uint16_t x2PropertyKey = 65;
- static const uint16_t y2PropertyKey = 66;
+ static const uint16_t x1PropertyKey = 63;
+ static const uint16_t y1PropertyKey = 64;
+ static const uint16_t x2PropertyKey = 65;
+ static const uint16_t y2PropertyKey = 66;
-private:
- float m_X1 = 0.42f;
- float m_Y1 = 0.0f;
- float m_X2 = 0.58f;
- float m_Y2 = 1.0f;
+ private:
+ float m_X1 = 0.42f;
+ float m_Y1 = 0.0f;
+ float m_X2 = 0.58f;
+ float m_Y2 = 1.0f;
-public:
- inline float x1() const { return m_X1; }
- void x1(float value) {
- if (m_X1 == value) {
- return;
+ public:
+ inline float x1() const { return m_X1; }
+ void x1(float value) {
+ if (m_X1 == value) {
+ return;
+ }
+ m_X1 = value;
+ x1Changed();
}
- m_X1 = value;
- x1Changed();
- }
- inline float y1() const { return m_Y1; }
- void y1(float value) {
- if (m_Y1 == value) {
- return;
+ inline float y1() const { return m_Y1; }
+ void y1(float value) {
+ if (m_Y1 == value) {
+ return;
+ }
+ m_Y1 = value;
+ y1Changed();
}
- m_Y1 = value;
- y1Changed();
- }
- inline float x2() const { return m_X2; }
- void x2(float value) {
- if (m_X2 == value) {
- return;
+ inline float x2() const { return m_X2; }
+ void x2(float value) {
+ if (m_X2 == value) {
+ return;
+ }
+ m_X2 = value;
+ x2Changed();
}
- m_X2 = value;
- x2Changed();
- }
- inline float y2() const { return m_Y2; }
- void y2(float value) {
- if (m_Y2 == value) {
- return;
+ inline float y2() const { return m_Y2; }
+ void y2(float value) {
+ if (m_Y2 == value) {
+ return;
+ }
+ m_Y2 = value;
+ y2Changed();
}
- m_Y2 = value;
- y2Changed();
- }
- Core* clone() const override;
- 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;
- }
+ Core* clone() const override;
+ 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;
}
- return false;
- }
-protected:
- virtual void x1Changed() {}
- virtual void y1Changed() {}
- virtual void x2Changed() {}
- virtual void y2Changed() {}
-};
+ protected:
+ virtual void x1Changed() {}
+ virtual void y1Changed() {}
+ virtual void x2Changed() {}
+ virtual void y2Changed() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_ENTRY_STATE_BASE_HPP_
#include "rive/animation/layer_state.hpp"
namespace rive {
-class EntryStateBase : public LayerState {
-protected:
- typedef LayerState Super;
+ class EntryStateBase : public LayerState {
+ protected:
+ typedef LayerState Super;
-public:
- static const uint16_t typeKey = 63;
+ public:
+ static const uint16_t typeKey = 63;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case EntryStateBase::typeKey:
- case LayerStateBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case EntryStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_BOOL_CHANGE_BASE_HPP_
+#define _RIVE_EVENT_BOOL_CHANGE_BASE_HPP_
+#include "rive/animation/event_input_change.hpp"
+#include "rive/core/field_types/core_uint_type.hpp"
+namespace rive {
+ class EventBoolChangeBase : public EventInputChange {
+ protected:
+ typedef EventInputChange Super;
+
+ public:
+ static const uint16_t typeKey = 117;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case EventBoolChangeBase::typeKey:
+ case EventInputChangeBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t valuePropertyKey = 228;
+
+ private:
+ uint32_t m_Value = 1;
+
+ public:
+ inline uint32_t value() const { return m_Value; }
+ void value(uint32_t value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
+ }
+
+ Core* clone() const override;
+ void copy(const EventBoolChangeBase& object) {
+ m_Value = object.m_Value;
+ EventInputChange::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case valuePropertyKey:
+ m_Value = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return EventInputChange::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void valueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_INPUT_CHANGE_BASE_HPP_
+#define _RIVE_EVENT_INPUT_CHANGE_BASE_HPP_
+#include "rive/core.hpp"
+#include "rive/core/field_types/core_uint_type.hpp"
+namespace rive {
+ class EventInputChangeBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 116;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case EventInputChangeBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t inputIdPropertyKey = 227;
+
+ private:
+ uint32_t m_InputId = -1;
+
+ public:
+ inline uint32_t inputId() const { return m_InputId; }
+ void inputId(uint32_t value) {
+ if (m_InputId == value) {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
+ }
+
+ void copy(const EventInputChangeBase& 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;
+ }
+ return false;
+ }
+
+ protected:
+ virtual void inputIdChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_NUMBER_CHANGE_BASE_HPP_
+#define _RIVE_EVENT_NUMBER_CHANGE_BASE_HPP_
+#include "rive/animation/event_input_change.hpp"
+#include "rive/core/field_types/core_double_type.hpp"
+namespace rive {
+ class EventNumberChangeBase : public EventInputChange {
+ protected:
+ typedef EventInputChange Super;
+
+ public:
+ static const uint16_t typeKey = 118;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case EventNumberChangeBase::typeKey:
+ case EventInputChangeBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t valuePropertyKey = 229;
+
+ private:
+ float m_Value = 0.0f;
+
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
+ }
+
+ Core* clone() const override;
+ void copy(const EventNumberChangeBase& object) {
+ m_Value = object.m_Value;
+ EventInputChange::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case valuePropertyKey:
+ m_Value = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return EventInputChange::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void valueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_EVENT_TRIGGER_CHANGE_BASE_HPP_
+#define _RIVE_EVENT_TRIGGER_CHANGE_BASE_HPP_
+#include "rive/animation/event_input_change.hpp"
+namespace rive {
+ class EventTriggerChangeBase : public EventInputChange {
+ protected:
+ typedef EventInputChange Super;
+
+ public:
+ static const uint16_t typeKey = 115;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case EventTriggerChangeBase::typeKey:
+ case EventInputChangeBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ Core* clone() const override;
+
+ protected:
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
#define _RIVE_EXIT_STATE_BASE_HPP_
#include "rive/animation/layer_state.hpp"
namespace rive {
-class ExitStateBase : public LayerState {
-protected:
- typedef LayerState Super;
+ class ExitStateBase : public LayerState {
+ protected:
+ typedef LayerState Super;
-public:
- static const uint16_t typeKey = 64;
+ public:
+ static const uint16_t typeKey = 64;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ExitStateBase::typeKey:
- case LayerStateBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ExitStateBase::typeKey:
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class KeyedObjectBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 25;
-
- /// 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;
+ class KeyedObjectBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 25;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t objectIdPropertyKey = 51;
+ static const uint16_t objectIdPropertyKey = 51;
-private:
- uint32_t m_ObjectId = 0;
+ private:
+ uint32_t m_ObjectId = 0;
-public:
- inline uint32_t objectId() const { return m_ObjectId; }
- void objectId(uint32_t value) {
- if (m_ObjectId == value) {
- return;
+ public:
+ inline uint32_t objectId() const { return m_ObjectId; }
+ void objectId(uint32_t value) {
+ if (m_ObjectId == value) {
+ return;
+ }
+ m_ObjectId = value;
+ objectIdChanged();
}
- m_ObjectId = value;
- objectIdChanged();
- }
- Core* clone() const override;
- void copy(const KeyedObjectBase& object) { m_ObjectId = object.m_ObjectId; }
+ 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;
}
- return false;
- }
-protected:
- virtual void objectIdChanged() {}
-};
+ protected:
+ virtual void objectIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class KeyedPropertyBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 26;
-
- /// 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;
+ class KeyedPropertyBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 26;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t propertyKeyPropertyKey = 53;
+ static const uint16_t propertyKeyPropertyKey = 53;
-private:
- uint32_t m_PropertyKey = Core::invalidPropertyKey;
+ private:
+ uint32_t m_PropertyKey = Core::invalidPropertyKey;
-public:
- inline uint32_t propertyKey() const { return m_PropertyKey; }
- void propertyKey(uint32_t value) {
- if (m_PropertyKey == value) {
- return;
+ public:
+ inline uint32_t propertyKey() const { return m_PropertyKey; }
+ void propertyKey(uint32_t value) {
+ if (m_PropertyKey == value) {
+ return;
+ }
+ m_PropertyKey = value;
+ propertyKeyChanged();
}
- m_PropertyKey = value;
- propertyKeyChanged();
- }
-
- Core* clone() const override;
- void copy(const KeyedPropertyBase& object) { m_PropertyKey = object.m_PropertyKey; }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case propertyKeyPropertyKey:
- m_PropertyKey = CoreUintType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const KeyedPropertyBase& object) { m_PropertyKey = object.m_PropertyKey; }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case propertyKeyPropertyKey:
+ m_PropertyKey = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return false;
}
- return false;
- }
-protected:
- virtual void propertyKeyChanged() {}
-};
+ protected:
+ virtual void propertyKeyChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class KeyFrameBase : public Core {
-protected:
- typedef Core Super;
+ class KeyFrameBase : public Core {
+ protected:
+ typedef Core Super;
-public:
- static const uint16_t typeKey = 29;
+ public:
+ static const uint16_t typeKey = 29;
- /// 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;
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t framePropertyKey = 67;
- static const uint16_t interpolationTypePropertyKey = 68;
- static const uint16_t interpolatorIdPropertyKey = 69;
+ static const uint16_t framePropertyKey = 67;
+ static const uint16_t interpolationTypePropertyKey = 68;
+ static const uint16_t interpolatorIdPropertyKey = 69;
-private:
- uint32_t m_Frame = 0;
- uint32_t m_InterpolationType = 0;
- uint32_t m_InterpolatorId = -1;
+ private:
+ uint32_t m_Frame = 0;
+ uint32_t m_InterpolationType = 0;
+ uint32_t m_InterpolatorId = -1;
-public:
- inline uint32_t frame() const { return m_Frame; }
- void frame(uint32_t value) {
- if (m_Frame == value) {
- return;
+ public:
+ inline uint32_t frame() const { return m_Frame; }
+ void frame(uint32_t value) {
+ if (m_Frame == value) {
+ return;
+ }
+ m_Frame = value;
+ frameChanged();
}
- m_Frame = value;
- frameChanged();
- }
- inline uint32_t interpolationType() const { return m_InterpolationType; }
- void interpolationType(uint32_t value) {
- if (m_InterpolationType == value) {
- return;
+ inline uint32_t interpolationType() const { return m_InterpolationType; }
+ void interpolationType(uint32_t value) {
+ if (m_InterpolationType == value) {
+ return;
+ }
+ m_InterpolationType = value;
+ interpolationTypeChanged();
}
- m_InterpolationType = value;
- interpolationTypeChanged();
- }
- inline uint32_t interpolatorId() const { return m_InterpolatorId; }
- void interpolatorId(uint32_t value) {
- if (m_InterpolatorId == value) {
- return;
+ inline uint32_t interpolatorId() const { return m_InterpolatorId; }
+ void interpolatorId(uint32_t value) {
+ if (m_InterpolatorId == value) {
+ return;
+ }
+ m_InterpolatorId = value;
+ interpolatorIdChanged();
}
- m_InterpolatorId = value;
- interpolatorIdChanged();
- }
- void copy(const KeyFrameBase& object) {
- m_Frame = object.m_Frame;
- m_InterpolationType = object.m_InterpolationType;
- m_InterpolatorId = object.m_InterpolatorId;
- }
+ 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;
- case interpolationTypePropertyKey:
- m_InterpolationType = CoreUintType::deserialize(reader);
- return true;
- case interpolatorIdPropertyKey:
- m_InterpolatorId = 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;
+ case interpolatorIdPropertyKey:
+ m_InterpolatorId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return false;
}
- return false;
- }
-protected:
- virtual void frameChanged() {}
- virtual void interpolationTypeChanged() {}
- virtual void interpolatorIdChanged() {}
-};
+ protected:
+ virtual void frameChanged() {}
+ virtual void interpolationTypeChanged() {}
+ virtual void interpolatorIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/keyframe.hpp"
#include "rive/core/field_types/core_bool_type.hpp"
namespace rive {
-class KeyFrameBoolBase : public KeyFrame {
-protected:
- typedef KeyFrame Super;
-
-public:
- static const uint16_t typeKey = 84;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case KeyFrameBoolBase::typeKey:
- case KeyFrameBase::typeKey: return true;
- default: return false;
+ class KeyFrameBoolBase : public KeyFrame {
+ protected:
+ typedef KeyFrame Super;
+
+ public:
+ static const uint16_t typeKey = 84;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case KeyFrameBoolBase::typeKey:
+ case KeyFrameBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 181;
+ static const uint16_t valuePropertyKey = 181;
-private:
- bool m_Value = false;
+ private:
+ bool m_Value = false;
-public:
- inline bool value() const { return m_Value; }
- void value(bool value) {
- if (m_Value == value) {
- return;
+ public:
+ inline bool value() const { return m_Value; }
+ void value(bool value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return KeyFrame::deserialize(propertyKey, reader);
}
- return KeyFrame::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/keyframe.hpp"
#include "rive/core/field_types/core_color_type.hpp"
namespace rive {
-class KeyFrameColorBase : public KeyFrame {
-protected:
- typedef KeyFrame Super;
-
-public:
- static const uint16_t typeKey = 37;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case KeyFrameColorBase::typeKey:
- case KeyFrameBase::typeKey: return true;
- default: return false;
+ class KeyFrameColorBase : public KeyFrame {
+ protected:
+ typedef KeyFrame Super;
+
+ public:
+ static const uint16_t typeKey = 37;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case KeyFrameColorBase::typeKey:
+ case KeyFrameBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 88;
+ static const uint16_t valuePropertyKey = 88;
-private:
- int m_Value = 0;
+ private:
+ int m_Value = 0;
-public:
- inline int value() const { return m_Value; }
- void value(int value) {
- if (m_Value == value) {
- return;
+ public:
+ inline int value() const { return m_Value; }
+ void value(int value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return KeyFrame::deserialize(propertyKey, reader);
}
- return KeyFrame::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/keyframe.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class KeyFrameDoubleBase : public KeyFrame {
-protected:
- typedef KeyFrame Super;
-
-public:
- static const uint16_t typeKey = 30;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case KeyFrameDoubleBase::typeKey:
- case KeyFrameBase::typeKey: return true;
- default: return false;
+ class KeyFrameDoubleBase : public KeyFrame {
+ protected:
+ typedef KeyFrame Super;
+
+ public:
+ static const uint16_t typeKey = 30;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case KeyFrameDoubleBase::typeKey:
+ case KeyFrameBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 70;
+ static const uint16_t valuePropertyKey = 70;
-private:
- float m_Value = 0.0f;
+ private:
+ float m_Value = 0.0f;
-public:
- inline float value() const { return m_Value; }
- void value(float value) {
- if (m_Value == value) {
- return;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return KeyFrame::deserialize(propertyKey, reader);
}
- return KeyFrame::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/keyframe.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class KeyFrameIdBase : public KeyFrame {
-protected:
- typedef KeyFrame Super;
-
-public:
- static const uint16_t typeKey = 50;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case KeyFrameIdBase::typeKey:
- case KeyFrameBase::typeKey: return true;
- default: return false;
+ class KeyFrameIdBase : public KeyFrame {
+ protected:
+ typedef KeyFrame Super;
+
+ public:
+ static const uint16_t typeKey = 50;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case KeyFrameIdBase::typeKey:
+ case KeyFrameBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 122;
+ static const uint16_t valuePropertyKey = 122;
-private:
- uint32_t m_Value = -1;
+ private:
+ uint32_t m_Value = -1;
-public:
- inline uint32_t value() const { return m_Value; }
- void value(uint32_t value) {
- if (m_Value == value) {
- return;
+ public:
+ inline uint32_t value() const { return m_Value; }
+ void value(uint32_t value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return KeyFrame::deserialize(propertyKey, reader);
}
- return KeyFrame::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_LAYER_STATE_BASE_HPP_
#include "rive/animation/state_machine_layer_component.hpp"
namespace rive {
-class LayerStateBase : public StateMachineLayerComponent {
-protected:
- typedef StateMachineLayerComponent Super;
+ class LayerStateBase : public StateMachineLayerComponent {
+ protected:
+ typedef StateMachineLayerComponent Super;
-public:
- static const uint16_t typeKey = 60;
+ public:
+ static const uint16_t typeKey = 60;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case LayerStateBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case LayerStateBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class LinearAnimationBase : public Animation {
-protected:
- typedef Animation Super;
-
-public:
- static const uint16_t typeKey = 31;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case LinearAnimationBase::typeKey:
- case AnimationBase::typeKey: return true;
- default: return false;
+ class LinearAnimationBase : public Animation {
+ protected:
+ typedef Animation Super;
+
+ public:
+ static const uint16_t typeKey = 31;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case LinearAnimationBase::typeKey:
+ case AnimationBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
-
- uint16_t coreType() const override { return typeKey; }
-
- static const uint16_t fpsPropertyKey = 56;
- static const uint16_t durationPropertyKey = 57;
- static const uint16_t speedPropertyKey = 58;
- static const uint16_t loopValuePropertyKey = 59;
- static const uint16_t workStartPropertyKey = 60;
- static const uint16_t workEndPropertyKey = 61;
- static const uint16_t enableWorkAreaPropertyKey = 62;
-
-private:
- uint32_t m_Fps = 60;
- uint32_t m_Duration = 60;
- float m_Speed = 1.0f;
- uint32_t m_LoopValue = 0;
- uint32_t m_WorkStart = -1;
- uint32_t m_WorkEnd = -1;
- bool m_EnableWorkArea = false;
-
-public:
- inline uint32_t fps() const { return m_Fps; }
- void fps(uint32_t value) {
- if (m_Fps == value) {
- return;
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t fpsPropertyKey = 56;
+ static const uint16_t durationPropertyKey = 57;
+ static const uint16_t speedPropertyKey = 58;
+ static const uint16_t loopValuePropertyKey = 59;
+ static const uint16_t workStartPropertyKey = 60;
+ static const uint16_t workEndPropertyKey = 61;
+ static const uint16_t enableWorkAreaPropertyKey = 62;
+
+ private:
+ uint32_t m_Fps = 60;
+ uint32_t m_Duration = 60;
+ float m_Speed = 1.0f;
+ uint32_t m_LoopValue = 0;
+ uint32_t m_WorkStart = -1;
+ uint32_t m_WorkEnd = -1;
+ bool m_EnableWorkArea = false;
+
+ public:
+ inline uint32_t fps() const { return m_Fps; }
+ void fps(uint32_t value) {
+ if (m_Fps == value) {
+ return;
+ }
+ m_Fps = value;
+ fpsChanged();
}
- m_Fps = value;
- fpsChanged();
- }
-
- inline uint32_t duration() const { return m_Duration; }
- void duration(uint32_t value) {
- if (m_Duration == value) {
- return;
+
+ inline uint32_t duration() const { return m_Duration; }
+ void duration(uint32_t value) {
+ if (m_Duration == value) {
+ return;
+ }
+ m_Duration = value;
+ durationChanged();
}
- m_Duration = value;
- durationChanged();
- }
-
- inline float speed() const { return m_Speed; }
- void speed(float value) {
- if (m_Speed == value) {
- return;
+
+ inline float speed() const { return m_Speed; }
+ void speed(float value) {
+ if (m_Speed == value) {
+ return;
+ }
+ m_Speed = value;
+ speedChanged();
}
- m_Speed = value;
- speedChanged();
- }
-
- inline uint32_t loopValue() const { return m_LoopValue; }
- void loopValue(uint32_t value) {
- if (m_LoopValue == value) {
- return;
+
+ inline uint32_t loopValue() const { return m_LoopValue; }
+ void loopValue(uint32_t value) {
+ if (m_LoopValue == value) {
+ return;
+ }
+ m_LoopValue = value;
+ loopValueChanged();
}
- m_LoopValue = value;
- loopValueChanged();
- }
-
- inline uint32_t workStart() const { return m_WorkStart; }
- void workStart(uint32_t value) {
- if (m_WorkStart == value) {
- return;
+
+ inline uint32_t workStart() const { return m_WorkStart; }
+ void workStart(uint32_t value) {
+ if (m_WorkStart == value) {
+ return;
+ }
+ m_WorkStart = value;
+ workStartChanged();
}
- m_WorkStart = value;
- workStartChanged();
- }
-
- inline uint32_t workEnd() const { return m_WorkEnd; }
- void workEnd(uint32_t value) {
- if (m_WorkEnd == value) {
- return;
+
+ inline uint32_t workEnd() const { return m_WorkEnd; }
+ void workEnd(uint32_t value) {
+ if (m_WorkEnd == value) {
+ return;
+ }
+ m_WorkEnd = value;
+ workEndChanged();
}
- m_WorkEnd = value;
- workEndChanged();
- }
-
- inline bool enableWorkArea() const { return m_EnableWorkArea; }
- void enableWorkArea(bool value) {
- if (m_EnableWorkArea == value) {
- return;
+
+ inline bool enableWorkArea() const { return m_EnableWorkArea; }
+ void enableWorkArea(bool value) {
+ if (m_EnableWorkArea == value) {
+ return;
+ }
+ m_EnableWorkArea = value;
+ enableWorkAreaChanged();
}
- m_EnableWorkArea = value;
- enableWorkAreaChanged();
- }
-
- Core* clone() const override;
- void copy(const LinearAnimationBase& object) {
- m_Fps = object.m_Fps;
- m_Duration = object.m_Duration;
- m_Speed = object.m_Speed;
- m_LoopValue = object.m_LoopValue;
- m_WorkStart = object.m_WorkStart;
- m_WorkEnd = object.m_WorkEnd;
- m_EnableWorkArea = object.m_EnableWorkArea;
- 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;
- case enableWorkAreaPropertyKey:
- m_EnableWorkArea = CoreBoolType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const LinearAnimationBase& object) {
+ m_Fps = object.m_Fps;
+ m_Duration = object.m_Duration;
+ m_Speed = object.m_Speed;
+ m_LoopValue = object.m_LoopValue;
+ m_WorkStart = object.m_WorkStart;
+ m_WorkEnd = object.m_WorkEnd;
+ m_EnableWorkArea = object.m_EnableWorkArea;
+ Animation::copy(object);
}
- return Animation::deserialize(propertyKey, reader);
- }
-
-protected:
- virtual void fpsChanged() {}
- virtual void durationChanged() {}
- virtual void speedChanged() {}
- virtual void loopValueChanged() {}
- virtual void workStartChanged() {}
- virtual void workEndChanged() {}
- virtual void enableWorkAreaChanged() {}
-};
+
+ 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;
+ }
+ return Animation::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void fpsChanged() {}
+ virtual void durationChanged() {}
+ virtual void speedChanged() {}
+ virtual void loopValueChanged() {}
+ virtual void workStartChanged() {}
+ virtual void workEndChanged() {}
+ virtual void enableWorkAreaChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_LISTENER_ACTION_BASE_HPP_
#include "rive/core.hpp"
namespace rive {
-class ListenerActionBase : public Core {
-protected:
- typedef Core Super;
+ class ListenerActionBase : public Core {
+ protected:
+ typedef Core Super;
-public:
- static const uint16_t typeKey = 125;
+ public:
+ static const uint16_t typeKey = 125;
- /// 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;
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- void copy(const ListenerActionBase& object) {}
+ void copy(const ListenerActionBase& object) {}
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { return false; }
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { return false; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/listener_action.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class ListenerAlignTargetBase : public ListenerAction {
-protected:
- typedef ListenerAction Super;
-
-public:
- static const uint16_t typeKey = 126;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ListenerAlignTargetBase::typeKey:
- case ListenerActionBase::typeKey: return true;
- default: return false;
+ class ListenerAlignTargetBase : public ListenerAction {
+ protected:
+ typedef ListenerAction Super;
+
+ public:
+ static const uint16_t typeKey = 126;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ListenerAlignTargetBase::typeKey:
+ case ListenerActionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t targetIdPropertyKey = 240;
+ static const uint16_t targetIdPropertyKey = 240;
-private:
- uint32_t m_TargetId = 0;
+ private:
+ uint32_t m_TargetId = 0;
-public:
- inline uint32_t targetId() const { return m_TargetId; }
- void targetId(uint32_t value) {
- if (m_TargetId == value) {
- return;
+ public:
+ inline uint32_t targetId() const { return m_TargetId; }
+ void targetId(uint32_t value) {
+ if (m_TargetId == value) {
+ return;
+ }
+ m_TargetId = value;
+ targetIdChanged();
}
- m_TargetId = value;
- targetIdChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return ListenerAction::deserialize(propertyKey, reader);
}
- return ListenerAction::deserialize(propertyKey, reader);
- }
-protected:
- virtual void targetIdChanged() {}
-};
+ protected:
+ virtual void targetIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/listener_input_change.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class ListenerBoolChangeBase : public ListenerInputChange {
-protected:
- typedef ListenerInputChange Super;
-
-public:
- static const uint16_t typeKey = 117;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ListenerBoolChangeBase::typeKey:
- case ListenerInputChangeBase::typeKey:
- case ListenerActionBase::typeKey: return true;
- default: return false;
+ class ListenerBoolChangeBase : public ListenerInputChange {
+ protected:
+ typedef ListenerInputChange Super;
+
+ public:
+ static const uint16_t typeKey = 117;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ListenerBoolChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
+ case ListenerActionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 228;
+ static const uint16_t valuePropertyKey = 228;
-private:
- uint32_t m_Value = 1;
+ private:
+ uint32_t m_Value = 1;
-public:
- inline uint32_t value() const { return m_Value; }
- void value(uint32_t value) {
- if (m_Value == value) {
- return;
+ public:
+ inline uint32_t value() const { return m_Value; }
+ void value(uint32_t value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return ListenerInputChange::deserialize(propertyKey, reader);
}
- return ListenerInputChange::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/listener_action.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class ListenerInputChangeBase : public ListenerAction {
-protected:
- typedef ListenerAction Super;
-
-public:
- static const uint16_t typeKey = 116;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ListenerInputChangeBase::typeKey:
- case ListenerActionBase::typeKey: return true;
- default: return false;
+ class ListenerInputChangeBase : public ListenerAction {
+ protected:
+ typedef ListenerAction Super;
+
+ public:
+ static const uint16_t typeKey = 116;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ListenerInputChangeBase::typeKey:
+ case ListenerActionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inputIdPropertyKey = 227;
+ static const uint16_t inputIdPropertyKey = 227;
-private:
- uint32_t m_InputId = -1;
+ private:
+ uint32_t m_InputId = -1;
-public:
- inline uint32_t inputId() const { return m_InputId; }
- void inputId(uint32_t value) {
- if (m_InputId == value) {
- return;
+ public:
+ inline uint32_t inputId() const { return m_InputId; }
+ void inputId(uint32_t value) {
+ if (m_InputId == value) {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
}
- m_InputId = value;
- inputIdChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return ListenerAction::deserialize(propertyKey, reader);
}
- return ListenerAction::deserialize(propertyKey, reader);
- }
-protected:
- virtual void inputIdChanged() {}
-};
+ protected:
+ virtual void inputIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/listener_input_change.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class ListenerNumberChangeBase : public ListenerInputChange {
-protected:
- typedef ListenerInputChange Super;
-
-public:
- static const uint16_t typeKey = 118;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ListenerNumberChangeBase::typeKey:
- case ListenerInputChangeBase::typeKey:
- case ListenerActionBase::typeKey: return true;
- default: return false;
+ class ListenerNumberChangeBase : public ListenerInputChange {
+ protected:
+ typedef ListenerInputChange Super;
+
+ public:
+ static const uint16_t typeKey = 118;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ListenerNumberChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
+ case ListenerActionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 229;
+ static const uint16_t valuePropertyKey = 229;
-private:
- float m_Value = 0.0f;
+ private:
+ float m_Value = 0.0f;
-public:
- inline float value() const { return m_Value; }
- void value(float value) {
- if (m_Value == value) {
- return;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return ListenerInputChange::deserialize(propertyKey, reader);
}
- return ListenerInputChange::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_LISTENER_TRIGGER_CHANGE_BASE_HPP_
#include "rive/animation/listener_input_change.hpp"
namespace rive {
-class ListenerTriggerChangeBase : public ListenerInputChange {
-protected:
- typedef ListenerInputChange Super;
+ class ListenerTriggerChangeBase : public ListenerInputChange {
+ protected:
+ typedef ListenerInputChange Super;
-public:
- static const uint16_t typeKey = 115;
+ public:
+ static const uint16_t typeKey = 115;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ListenerTriggerChangeBase::typeKey:
- case ListenerInputChangeBase::typeKey:
- case ListenerActionBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ListenerTriggerChangeBase::typeKey:
+ case ListenerInputChangeBase::typeKey:
+ case ListenerActionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/nested_input.hpp"
#include "rive/core/field_types/core_bool_type.hpp"
namespace rive {
-class NestedBoolBase : public NestedInput {
-protected:
- typedef NestedInput Super;
-
-public:
- static const uint16_t typeKey = 123;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case NestedBoolBase::typeKey:
- case NestedInputBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class NestedBoolBase : public NestedInput {
+ protected:
+ typedef NestedInput Super;
+
+ public:
+ static const uint16_t typeKey = 123;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedBoolBase::typeKey:
+ case NestedInputBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t nestedValuePropertyKey = 238;
+ static const uint16_t nestedValuePropertyKey = 238;
-private:
- bool m_NestedValue = false;
+ private:
+ bool m_NestedValue = false;
-public:
- inline bool nestedValue() const { return m_NestedValue; }
- void nestedValue(bool value) {
- if (m_NestedValue == value) {
- return;
+ public:
+ inline bool nestedValue() const { return m_NestedValue; }
+ void nestedValue(bool value) {
+ if (m_NestedValue == value) {
+ return;
+ }
+ m_NestedValue = value;
+ nestedValueChanged();
}
- m_NestedValue = value;
- nestedValueChanged();
- }
-
- Core* clone() const override;
- void copy(const NestedBoolBase& object) {
- m_NestedValue = object.m_NestedValue;
- NestedInput::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case nestedValuePropertyKey:
- m_NestedValue = CoreBoolType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const NestedBoolBase& object) {
+ m_NestedValue = object.m_NestedValue;
+ NestedInput::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case nestedValuePropertyKey:
+ m_NestedValue = CoreBoolType::deserialize(reader);
+ return true;
+ }
+ return NestedInput::deserialize(propertyKey, reader);
}
- return NestedInput::deserialize(propertyKey, reader);
- }
-protected:
- virtual void nestedValueChanged() {}
-};
+ protected:
+ virtual void nestedValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class NestedInputBase : public Component {
-protected:
- typedef Component Super;
-
-public:
- static const uint16_t typeKey = 121;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case NestedInputBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class NestedInputBase : public Component {
+ protected:
+ typedef Component Super;
+
+ public:
+ static const uint16_t typeKey = 121;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedInputBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inputIdPropertyKey = 237;
+ static const uint16_t inputIdPropertyKey = 237;
-private:
- uint32_t m_InputId = -1;
+ private:
+ uint32_t m_InputId = -1;
-public:
- inline uint32_t inputId() const { return m_InputId; }
- void inputId(uint32_t value) {
- if (m_InputId == value) {
- return;
+ public:
+ inline uint32_t inputId() const { return m_InputId; }
+ void inputId(uint32_t value) {
+ if (m_InputId == value) {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
}
- m_InputId = value;
- inputIdChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return Component::deserialize(propertyKey, reader);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void inputIdChanged() {}
-};
+ protected:
+ virtual void inputIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/nested_animation.hpp"
namespace rive {
-class NestedLinearAnimationBase : public NestedAnimation {
-protected:
- typedef NestedAnimation Super;
-
-public:
- static const uint16_t typeKey = 97;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class NestedLinearAnimationBase : public NestedAnimation {
+ protected:
+ typedef NestedAnimation Super;
+
+ public:
+ static const uint16_t typeKey = 97;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedLinearAnimationBase::typeKey:
+ case NestedAnimationBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t mixPropertyKey = 200;
+ static const uint16_t mixPropertyKey = 200;
-private:
- float m_Mix = 1.0f;
+ private:
+ float m_Mix = 1.0f;
-public:
- inline float mix() const { return m_Mix; }
- void mix(float value) {
- if (m_Mix == value) {
- return;
+ public:
+ inline float mix() const { return m_Mix; }
+ void mix(float value) {
+ if (m_Mix == value) {
+ return;
+ }
+ m_Mix = value;
+ mixChanged();
}
- m_Mix = value;
- mixChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return NestedAnimation::deserialize(propertyKey, reader);
}
- return NestedAnimation::deserialize(propertyKey, reader);
- }
-protected:
- virtual void mixChanged() {}
-};
+ protected:
+ virtual void mixChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/nested_input.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class NestedNumberBase : public NestedInput {
-protected:
- typedef NestedInput Super;
-
-public:
- static const uint16_t typeKey = 124;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case NestedNumberBase::typeKey:
- case NestedInputBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class NestedNumberBase : public NestedInput {
+ protected:
+ typedef NestedInput Super;
+
+ public:
+ static const uint16_t typeKey = 124;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedNumberBase::typeKey:
+ case NestedInputBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t nestedValuePropertyKey = 239;
+ static const uint16_t nestedValuePropertyKey = 239;
-private:
- float m_NestedValue = 0.0f;
+ private:
+ float m_NestedValue = 0.0f;
-public:
- inline float nestedValue() const { return m_NestedValue; }
- void nestedValue(float value) {
- if (m_NestedValue == value) {
- return;
+ public:
+ inline float nestedValue() const { return m_NestedValue; }
+ void nestedValue(float value) {
+ if (m_NestedValue == value) {
+ return;
+ }
+ m_NestedValue = value;
+ nestedValueChanged();
}
- m_NestedValue = value;
- nestedValueChanged();
- }
-
- Core* clone() const override;
- void copy(const NestedNumberBase& object) {
- m_NestedValue = object.m_NestedValue;
- NestedInput::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case nestedValuePropertyKey:
- m_NestedValue = CoreDoubleType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const NestedNumberBase& object) {
+ m_NestedValue = object.m_NestedValue;
+ NestedInput::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case nestedValuePropertyKey:
+ m_NestedValue = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return NestedInput::deserialize(propertyKey, reader);
}
- return NestedInput::deserialize(propertyKey, reader);
- }
-protected:
- virtual void nestedValueChanged() {}
-};
+ protected:
+ virtual void nestedValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/nested_linear_animation.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class NestedRemapAnimationBase : public NestedLinearAnimation {
-protected:
- typedef NestedLinearAnimation Super;
-
-public:
- static const uint16_t typeKey = 98;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class NestedRemapAnimationBase : public NestedLinearAnimation {
+ protected:
+ typedef NestedLinearAnimation Super;
+
+ public:
+ static const uint16_t typeKey = 98;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedRemapAnimationBase::typeKey:
+ case NestedLinearAnimationBase::typeKey:
+ case NestedAnimationBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t timePropertyKey = 202;
+ static const uint16_t timePropertyKey = 202;
-private:
- float m_Time = 0.0f;
+ private:
+ float m_Time = 0.0f;
-public:
- inline float time() const { return m_Time; }
- void time(float value) {
- if (m_Time == value) {
- return;
+ public:
+ inline float time() const { return m_Time; }
+ void time(float value) {
+ if (m_Time == value) {
+ return;
+ }
+ m_Time = value;
+ timeChanged();
}
- m_Time = value;
- timeChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return NestedLinearAnimation::deserialize(propertyKey, reader);
}
- return NestedLinearAnimation::deserialize(propertyKey, reader);
- }
-protected:
- virtual void timeChanged() {}
-};
+ protected:
+ virtual void timeChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bool_type.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class NestedSimpleAnimationBase : public NestedLinearAnimation {
-protected:
- typedef NestedLinearAnimation Super;
+ class NestedSimpleAnimationBase : public NestedLinearAnimation {
+ protected:
+ typedef NestedLinearAnimation Super;
-public:
- static const uint16_t typeKey = 96;
+ public:
+ static const uint16_t typeKey = 96;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedSimpleAnimationBase::typeKey:
+ case NestedLinearAnimationBase::typeKey:
+ case NestedAnimationBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t speedPropertyKey = 199;
- static const uint16_t isPlayingPropertyKey = 201;
+ static const uint16_t speedPropertyKey = 199;
+ static const uint16_t isPlayingPropertyKey = 201;
-private:
- float m_Speed = 1.0f;
- bool m_IsPlaying = false;
+ private:
+ float m_Speed = 1.0f;
+ bool m_IsPlaying = false;
-public:
- inline float speed() const { return m_Speed; }
- void speed(float value) {
- if (m_Speed == value) {
- return;
+ public:
+ inline float speed() const { return m_Speed; }
+ void speed(float value) {
+ if (m_Speed == value) {
+ return;
+ }
+ m_Speed = value;
+ speedChanged();
}
- m_Speed = value;
- speedChanged();
- }
- inline bool isPlaying() const { return m_IsPlaying; }
- void isPlaying(bool value) {
- if (m_IsPlaying == value) {
- return;
+ inline bool isPlaying() const { return m_IsPlaying; }
+ void isPlaying(bool value) {
+ if (m_IsPlaying == value) {
+ return;
+ }
+ m_IsPlaying = value;
+ isPlayingChanged();
}
- m_IsPlaying = value;
- isPlayingChanged();
- }
- Core* clone() const override;
- void copy(const NestedSimpleAnimationBase& object) {
- m_Speed = object.m_Speed;
- m_IsPlaying = object.m_IsPlaying;
- NestedLinearAnimation::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return NestedLinearAnimation::deserialize(propertyKey, reader);
- }
-protected:
- virtual void speedChanged() {}
- virtual void isPlayingChanged() {}
-};
+ protected:
+ virtual void speedChanged() {}
+ virtual void isPlayingChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_NESTED_STATE_MACHINE_BASE_HPP_
#include "rive/nested_animation.hpp"
namespace rive {
-class NestedStateMachineBase : public NestedAnimation {
-protected:
- typedef NestedAnimation Super;
+ class NestedStateMachineBase : public NestedAnimation {
+ protected:
+ typedef NestedAnimation Super;
-public:
- static const uint16_t typeKey = 95;
+ public:
+ static const uint16_t typeKey = 95;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedStateMachineBase::typeKey:
+ case NestedAnimationBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_NESTED_TRIGGER_BASE_HPP_
#include "rive/animation/nested_input.hpp"
namespace rive {
-class NestedTriggerBase : public NestedInput {
-protected:
- typedef NestedInput Super;
+ class NestedTriggerBase : public NestedInput {
+ protected:
+ typedef NestedInput Super;
-public:
- static const uint16_t typeKey = 122;
+ public:
+ static const uint16_t typeKey = 122;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case NestedTriggerBase::typeKey:
- case NestedInputBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedTriggerBase::typeKey:
+ case NestedInputBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_STATE_MACHINE_BASE_HPP_
#include "rive/animation/animation.hpp"
namespace rive {
-class StateMachineBase : public Animation {
-protected:
- typedef Animation Super;
+ class StateMachineBase : public Animation {
+ protected:
+ typedef Animation Super;
-public:
- static const uint16_t typeKey = 53;
+ public:
+ static const uint16_t typeKey = 53;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineBase::typeKey:
- case AnimationBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineBase::typeKey:
+ case AnimationBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/state_machine_input.hpp"
#include "rive/core/field_types/core_bool_type.hpp"
namespace rive {
-class StateMachineBoolBase : public StateMachineInput {
-protected:
- typedef StateMachineInput Super;
-
-public:
- static const uint16_t typeKey = 59;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineBoolBase::typeKey:
- case StateMachineInputBase::typeKey:
- case StateMachineComponentBase::typeKey: return true;
- default: return false;
+ class StateMachineBoolBase : public StateMachineInput {
+ protected:
+ typedef StateMachineInput Super;
+
+ public:
+ static const uint16_t typeKey = 59;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineBoolBase::typeKey:
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 141;
+ static const uint16_t valuePropertyKey = 141;
-private:
- bool m_Value = false;
+ private:
+ bool m_Value = false;
-public:
- inline bool value() const { return m_Value; }
- void value(bool value) {
- if (m_Value == value) {
- return;
+ public:
+ inline bool value() const { return m_Value; }
+ void value(bool value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return StateMachineInput::deserialize(propertyKey, reader);
}
- return StateMachineInput::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_string_type.hpp"
namespace rive {
-class StateMachineComponentBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 54;
-
- /// 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;
+ class StateMachineComponentBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 54;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t namePropertyKey = 138;
+ static const uint16_t namePropertyKey = 138;
-private:
- std::string m_Name = "";
+ private:
+ std::string m_Name = "";
-public:
- inline const std::string& name() const { return m_Name; }
- void name(std::string value) {
- if (m_Name == value) {
- return;
+ public:
+ inline const std::string& name() const { return m_Name; }
+ void name(std::string value) {
+ if (m_Name == value) {
+ return;
+ }
+ m_Name = value;
+ nameChanged();
}
- m_Name = value;
- nameChanged();
- }
- void copy(const StateMachineComponentBase& object) { m_Name = object.m_Name; }
+ void copy(const StateMachineComponentBase& object) { m_Name = object.m_Name; }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- 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;
}
- return false;
- }
-protected:
- virtual void nameChanged() {}
-};
+ protected:
+ virtual void nameChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_EVENT_BASE_HPP_
+#define _RIVE_STATE_MACHINE_EVENT_BASE_HPP_
+#include "rive/animation/state_machine_component.hpp"
+#include "rive/core/field_types/core_uint_type.hpp"
+namespace rive {
+ class StateMachineEventBase : public StateMachineComponent {
+ protected:
+ typedef StateMachineComponent Super;
+
+ public:
+ static const uint16_t typeKey = 114;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineEventBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t targetIdPropertyKey = 224;
+ static const uint16_t eventTypeValuePropertyKey = 225;
+
+ private:
+ uint32_t m_TargetId = 0;
+ uint32_t m_EventTypeValue = 0;
+
+ public:
+ inline uint32_t targetId() const { return m_TargetId; }
+ void targetId(uint32_t value) {
+ if (m_TargetId == value) {
+ return;
+ }
+ m_TargetId = value;
+ targetIdChanged();
+ }
+
+ inline uint32_t eventTypeValue() const { return m_EventTypeValue; }
+ void eventTypeValue(uint32_t value) {
+ if (m_EventTypeValue == value) {
+ return;
+ }
+ m_EventTypeValue = value;
+ eventTypeValueChanged();
+ }
+
+ Core* clone() const override;
+ void copy(const StateMachineEventBase& object) {
+ m_TargetId = object.m_TargetId;
+ m_EventTypeValue = object.m_EventTypeValue;
+ StateMachineComponent::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case targetIdPropertyKey:
+ m_TargetId = CoreUintType::deserialize(reader);
+ return true;
+ case eventTypeValuePropertyKey:
+ m_EventTypeValue = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return StateMachineComponent::deserialize(propertyKey, reader);
+ }
+
+ protected:
+ virtual void targetIdChanged() {}
+ virtual void eventTypeValueChanged() {}
+ };
+} // namespace rive
+
+#endif
\ No newline at end of file
#define _RIVE_STATE_MACHINE_INPUT_BASE_HPP_
#include "rive/animation/state_machine_component.hpp"
namespace rive {
-class StateMachineInputBase : public StateMachineComponent {
-protected:
- typedef StateMachineComponent Super;
+ class StateMachineInputBase : public StateMachineComponent {
+ protected:
+ typedef StateMachineComponent Super;
-public:
- static const uint16_t typeKey = 55;
+ public:
+ static const uint16_t typeKey = 55;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineInputBase::typeKey:
- case StateMachineComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_STATE_MACHINE_LAYER_BASE_HPP_
#include "rive/animation/state_machine_component.hpp"
namespace rive {
-class StateMachineLayerBase : public StateMachineComponent {
-protected:
- typedef StateMachineComponent Super;
+ class StateMachineLayerBase : public StateMachineComponent {
+ protected:
+ typedef StateMachineComponent Super;
-public:
- static const uint16_t typeKey = 57;
+ public:
+ static const uint16_t typeKey = 57;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineLayerBase::typeKey:
- case StateMachineComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineLayerBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_STATE_MACHINE_LAYER_COMPONENT_BASE_HPP_
#include "rive/core.hpp"
namespace rive {
-class StateMachineLayerComponentBase : public Core {
-protected:
- typedef Core Super;
+ class StateMachineLayerComponentBase : public Core {
+ protected:
+ typedef Core Super;
-public:
- static const uint16_t typeKey = 66;
+ public:
+ static const uint16_t typeKey = 66;
- /// 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;
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- void copy(const StateMachineLayerComponentBase& object) {}
+ void copy(const StateMachineLayerComponentBase& object) {}
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { return false; }
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { return false; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/state_machine_component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class StateMachineListenerBase : public StateMachineComponent {
-protected:
- typedef StateMachineComponent Super;
+ class StateMachineListenerBase : public StateMachineComponent {
+ protected:
+ typedef StateMachineComponent Super;
-public:
- static const uint16_t typeKey = 114;
+ public:
+ static const uint16_t typeKey = 114;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineListenerBase::typeKey:
- case StateMachineComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineListenerBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t targetIdPropertyKey = 224;
- static const uint16_t listenerTypeValuePropertyKey = 225;
+ static const uint16_t targetIdPropertyKey = 224;
+ static const uint16_t listenerTypeValuePropertyKey = 225;
-private:
- uint32_t m_TargetId = 0;
- uint32_t m_ListenerTypeValue = 0;
+ private:
+ uint32_t m_TargetId = 0;
+ uint32_t m_ListenerTypeValue = 0;
-public:
- inline uint32_t targetId() const { return m_TargetId; }
- void targetId(uint32_t value) {
- if (m_TargetId == value) {
- return;
+ public:
+ inline uint32_t targetId() const { return m_TargetId; }
+ void targetId(uint32_t value) {
+ if (m_TargetId == value) {
+ return;
+ }
+ m_TargetId = value;
+ targetIdChanged();
}
- m_TargetId = value;
- targetIdChanged();
- }
- inline uint32_t listenerTypeValue() const { return m_ListenerTypeValue; }
- void listenerTypeValue(uint32_t value) {
- if (m_ListenerTypeValue == value) {
- return;
+ inline uint32_t listenerTypeValue() const { return m_ListenerTypeValue; }
+ void listenerTypeValue(uint32_t value) {
+ if (m_ListenerTypeValue == value) {
+ return;
+ }
+ m_ListenerTypeValue = value;
+ listenerTypeValueChanged();
}
- m_ListenerTypeValue = value;
- listenerTypeValueChanged();
- }
- Core* clone() const override;
- void copy(const StateMachineListenerBase& object) {
- m_TargetId = object.m_TargetId;
- m_ListenerTypeValue = object.m_ListenerTypeValue;
- StateMachineComponent::copy(object);
- }
+ Core* clone() const override;
+ 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;
- case listenerTypeValuePropertyKey:
- m_ListenerTypeValue = 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;
+ }
+ return StateMachineComponent::deserialize(propertyKey, reader);
}
- return StateMachineComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void targetIdChanged() {}
- virtual void listenerTypeValueChanged() {}
-};
+ protected:
+ virtual void targetIdChanged() {}
+ virtual void listenerTypeValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/state_machine_input.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class StateMachineNumberBase : public StateMachineInput {
-protected:
- typedef StateMachineInput Super;
-
-public:
- static const uint16_t typeKey = 56;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineNumberBase::typeKey:
- case StateMachineInputBase::typeKey:
- case StateMachineComponentBase::typeKey: return true;
- default: return false;
+ class StateMachineNumberBase : public StateMachineInput {
+ protected:
+ typedef StateMachineInput Super;
+
+ public:
+ static const uint16_t typeKey = 56;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineNumberBase::typeKey:
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 140;
+ static const uint16_t valuePropertyKey = 140;
-private:
- float m_Value = 0.0f;
+ private:
+ float m_Value = 0.0f;
-public:
- inline float value() const { return m_Value; }
- void value(float value) {
- if (m_Value == value) {
- return;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return StateMachineInput::deserialize(propertyKey, reader);
}
- return StateMachineInput::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_STATE_MACHINE_TRIGGER_BASE_HPP_
#include "rive/animation/state_machine_input.hpp"
namespace rive {
-class StateMachineTriggerBase : public StateMachineInput {
-protected:
- typedef StateMachineInput Super;
+ class StateMachineTriggerBase : public StateMachineInput {
+ protected:
+ typedef StateMachineInput Super;
-public:
- static const uint16_t typeKey = 58;
+ public:
+ static const uint16_t typeKey = 58;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateMachineTriggerBase::typeKey:
- case StateMachineInputBase::typeKey:
- case StateMachineComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateMachineTriggerBase::typeKey:
+ case StateMachineInputBase::typeKey:
+ case StateMachineComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/state_machine_layer_component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class StateTransitionBase : public StateMachineLayerComponent {
-protected:
- typedef StateMachineLayerComponent Super;
+ class StateTransitionBase : public StateMachineLayerComponent {
+ protected:
+ typedef StateMachineLayerComponent Super;
-public:
- static const uint16_t typeKey = 65;
+ public:
+ static const uint16_t typeKey = 65;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StateTransitionBase::typeKey:
- case StateMachineLayerComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StateTransitionBase::typeKey:
+ case StateMachineLayerComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t stateToIdPropertyKey = 151;
- static const uint16_t flagsPropertyKey = 152;
- static const uint16_t durationPropertyKey = 158;
- static const uint16_t exitTimePropertyKey = 160;
+ static const uint16_t stateToIdPropertyKey = 151;
+ static const uint16_t flagsPropertyKey = 152;
+ static const uint16_t durationPropertyKey = 158;
+ static const uint16_t exitTimePropertyKey = 160;
-private:
- uint32_t m_StateToId = -1;
- uint32_t m_Flags = 0;
- uint32_t m_Duration = 0;
- uint32_t m_ExitTime = 0;
+ private:
+ uint32_t m_StateToId = -1;
+ uint32_t m_Flags = 0;
+ uint32_t m_Duration = 0;
+ uint32_t m_ExitTime = 0;
-public:
- inline uint32_t stateToId() const { return m_StateToId; }
- void stateToId(uint32_t value) {
- if (m_StateToId == value) {
- return;
+ public:
+ inline uint32_t stateToId() const { return m_StateToId; }
+ void stateToId(uint32_t value) {
+ if (m_StateToId == value) {
+ return;
+ }
+ m_StateToId = value;
+ stateToIdChanged();
}
- m_StateToId = value;
- stateToIdChanged();
- }
- inline uint32_t flags() const { return m_Flags; }
- void flags(uint32_t value) {
- if (m_Flags == value) {
- return;
+ inline uint32_t flags() const { return m_Flags; }
+ void flags(uint32_t value) {
+ if (m_Flags == value) {
+ return;
+ }
+ m_Flags = value;
+ flagsChanged();
}
- m_Flags = value;
- flagsChanged();
- }
- inline uint32_t duration() const { return m_Duration; }
- void duration(uint32_t value) {
- if (m_Duration == value) {
- return;
+ inline uint32_t duration() const { return m_Duration; }
+ void duration(uint32_t value) {
+ if (m_Duration == value) {
+ return;
+ }
+ m_Duration = value;
+ durationChanged();
}
- m_Duration = value;
- durationChanged();
- }
- inline uint32_t exitTime() const { return m_ExitTime; }
- void exitTime(uint32_t value) {
- if (m_ExitTime == value) {
- return;
+ inline uint32_t exitTime() const { return m_ExitTime; }
+ void exitTime(uint32_t value) {
+ if (m_ExitTime == value) {
+ return;
+ }
+ m_ExitTime = value;
+ exitTimeChanged();
}
- m_ExitTime = value;
- exitTimeChanged();
- }
- Core* clone() const override;
- void copy(const StateTransitionBase& object) {
- m_StateToId = object.m_StateToId;
- m_Flags = object.m_Flags;
- m_Duration = object.m_Duration;
- m_ExitTime = object.m_ExitTime;
- StateMachineLayerComponent::copy(object);
- }
+ Core* clone() const override;
+ void copy(const StateTransitionBase& object) {
+ m_StateToId = object.m_StateToId;
+ m_Flags = object.m_Flags;
+ m_Duration = object.m_Duration;
+ m_ExitTime = object.m_ExitTime;
+ 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);
}
- return StateMachineLayerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void stateToIdChanged() {}
- virtual void flagsChanged() {}
- virtual void durationChanged() {}
- virtual void exitTimeChanged() {}
-};
+ protected:
+ virtual void stateToIdChanged() {}
+ virtual void flagsChanged() {}
+ virtual void durationChanged() {}
+ virtual void exitTimeChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_TRANSITION_BOOL_CONDITION_BASE_HPP_
#include "rive/animation/transition_value_condition.hpp"
namespace rive {
-class TransitionBoolConditionBase : public TransitionValueCondition {
-protected:
- typedef TransitionValueCondition Super;
+ class TransitionBoolConditionBase : public TransitionValueCondition {
+ protected:
+ typedef TransitionValueCondition Super;
-public:
- static const uint16_t typeKey = 71;
+ public:
+ static const uint16_t typeKey = 71;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TransitionBoolConditionBase::typeKey:
- case TransitionValueConditionBase::typeKey:
- case TransitionConditionBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TransitionBoolConditionBase::typeKey:
+ case TransitionValueConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TransitionConditionBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 67;
-
- /// 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;
+ class TransitionConditionBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 67;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inputIdPropertyKey = 155;
+ static const uint16_t inputIdPropertyKey = 155;
-private:
- uint32_t m_InputId = -1;
+ private:
+ uint32_t m_InputId = -1;
-public:
- inline uint32_t inputId() const { return m_InputId; }
- void inputId(uint32_t value) {
- if (m_InputId == value) {
- return;
+ public:
+ inline uint32_t inputId() const { return m_InputId; }
+ void inputId(uint32_t value) {
+ if (m_InputId == value) {
+ return;
+ }
+ m_InputId = value;
+ inputIdChanged();
}
- m_InputId = value;
- inputIdChanged();
- }
- void copy(const TransitionConditionBase& object) { m_InputId = object.m_InputId; }
+ void copy(const TransitionConditionBase& object) { m_InputId = object.m_InputId; }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- 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;
}
- return false;
- }
-protected:
- virtual void inputIdChanged() {}
-};
+ protected:
+ virtual void inputIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/transition_value_condition.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class TransitionNumberConditionBase : public TransitionValueCondition {
-protected:
- typedef TransitionValueCondition Super;
-
-public:
- static const uint16_t typeKey = 70;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TransitionNumberConditionBase::typeKey:
- case TransitionValueConditionBase::typeKey:
- case TransitionConditionBase::typeKey: return true;
- default: return false;
+ class TransitionNumberConditionBase : public TransitionValueCondition {
+ protected:
+ typedef TransitionValueCondition Super;
+
+ public:
+ static const uint16_t typeKey = 70;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TransitionNumberConditionBase::typeKey:
+ case TransitionValueConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuePropertyKey = 157;
+ static const uint16_t valuePropertyKey = 157;
-private:
- float m_Value = 0.0f;
+ private:
+ float m_Value = 0.0f;
-public:
- inline float value() const { return m_Value; }
- void value(float value) {
- if (m_Value == value) {
- return;
+ public:
+ inline float value() const { return m_Value; }
+ void value(float value) {
+ if (m_Value == value) {
+ return;
+ }
+ m_Value = value;
+ valueChanged();
}
- m_Value = value;
- valueChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return TransitionValueCondition::deserialize(propertyKey, reader);
}
- return TransitionValueCondition::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valueChanged() {}
-};
+ protected:
+ virtual void valueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_TRANSITION_TRIGGER_CONDITION_BASE_HPP_
#include "rive/animation/transition_condition.hpp"
namespace rive {
-class TransitionTriggerConditionBase : public TransitionCondition {
-protected:
- typedef TransitionCondition Super;
+ class TransitionTriggerConditionBase : public TransitionCondition {
+ protected:
+ typedef TransitionCondition Super;
-public:
- static const uint16_t typeKey = 68;
+ public:
+ static const uint16_t typeKey = 68;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TransitionTriggerConditionBase::typeKey:
- case TransitionConditionBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TransitionTriggerConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/transition_condition.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TransitionValueConditionBase : public TransitionCondition {
-protected:
- typedef TransitionCondition Super;
-
-public:
- static const uint16_t typeKey = 69;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TransitionValueConditionBase::typeKey:
- case TransitionConditionBase::typeKey: return true;
- default: return false;
+ class TransitionValueConditionBase : public TransitionCondition {
+ protected:
+ typedef TransitionCondition Super;
+
+ public:
+ static const uint16_t typeKey = 69;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TransitionValueConditionBase::typeKey:
+ case TransitionConditionBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t opValuePropertyKey = 156;
+ static const uint16_t opValuePropertyKey = 156;
-private:
- uint32_t m_OpValue = 0;
+ private:
+ uint32_t m_OpValue = 0;
-public:
- inline uint32_t opValue() const { return m_OpValue; }
- void opValue(uint32_t value) {
- if (m_OpValue == value) {
- return;
+ public:
+ inline uint32_t opValue() const { return m_OpValue; }
+ void opValue(uint32_t value) {
+ if (m_OpValue == value) {
+ return;
+ }
+ m_OpValue = value;
+ opValueChanged();
}
- m_OpValue = value;
- opValueChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return TransitionCondition::deserialize(propertyKey, reader);
}
- return TransitionCondition::deserialize(propertyKey, reader);
- }
-protected:
- virtual void opValueChanged() {}
-};
+ protected:
+ virtual void opValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/world_transform_component.hpp"
namespace rive {
-class ArtboardBase : public WorldTransformComponent {
-protected:
- typedef WorldTransformComponent Super;
-
-public:
- static const uint16_t typeKey = 1;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class ArtboardBase : public WorldTransformComponent {
+ protected:
+ typedef WorldTransformComponent Super;
+
+ public:
+ static const uint16_t typeKey = 1;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
-
- uint16_t coreType() const override { return typeKey; }
-
- static const uint16_t clipPropertyKey = 196;
- static const uint16_t widthPropertyKey = 7;
- static const uint16_t heightPropertyKey = 8;
- static const uint16_t xPropertyKey = 9;
- static const uint16_t yPropertyKey = 10;
- static const uint16_t originXPropertyKey = 11;
- static const uint16_t originYPropertyKey = 12;
- static const uint16_t defaultStateMachineIdPropertyKey = 236;
-
-private:
- bool m_Clip = true;
- float m_Width = 0.0f;
- float m_Height = 0.0f;
- float m_X = 0.0f;
- float m_Y = 0.0f;
- float m_OriginX = 0.0f;
- float m_OriginY = 0.0f;
- uint32_t m_DefaultStateMachineId = -1;
-
-public:
- inline bool clip() const { return m_Clip; }
- void clip(bool value) {
- if (m_Clip == value) {
- return;
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t clipPropertyKey = 196;
+ static const uint16_t widthPropertyKey = 7;
+ static const uint16_t heightPropertyKey = 8;
+ static const uint16_t xPropertyKey = 9;
+ static const uint16_t yPropertyKey = 10;
+ static const uint16_t originXPropertyKey = 11;
+ static const uint16_t originYPropertyKey = 12;
+ static const uint16_t defaultStateMachineIdPropertyKey = 236;
+
+ private:
+ bool m_Clip = true;
+ float m_Width = 0.0f;
+ float m_Height = 0.0f;
+ float m_X = 0.0f;
+ float m_Y = 0.0f;
+ float m_OriginX = 0.0f;
+ float m_OriginY = 0.0f;
+ uint32_t m_DefaultStateMachineId = -1;
+
+ public:
+ inline bool clip() const { return m_Clip; }
+ void clip(bool value) {
+ if (m_Clip == value) {
+ return;
+ }
+ m_Clip = value;
+ clipChanged();
+ }
+
+ inline float width() const { return m_Width; }
+ void width(float value) {
+ if (m_Width == value) {
+ return;
+ }
+ m_Width = value;
+ widthChanged();
}
- m_Clip = value;
- clipChanged();
- }
-
- inline float width() const { return m_Width; }
- void width(float value) {
- if (m_Width == value) {
- return;
+
+ inline float height() const { return m_Height; }
+ void height(float value) {
+ if (m_Height == value) {
+ return;
+ }
+ m_Height = value;
+ heightChanged();
}
- m_Width = value;
- widthChanged();
- }
-
- inline float height() const { return m_Height; }
- void height(float value) {
- if (m_Height == value) {
- return;
+
+ inline float x() const { return m_X; }
+ void x(float value) {
+ if (m_X == value) {
+ return;
+ }
+ m_X = value;
+ xChanged();
}
- m_Height = value;
- heightChanged();
- }
-
- inline float x() const { return m_X; }
- void x(float value) {
- if (m_X == value) {
- return;
+
+ inline float y() const { return m_Y; }
+ void y(float value) {
+ if (m_Y == value) {
+ return;
+ }
+ m_Y = value;
+ yChanged();
}
- m_X = value;
- xChanged();
- }
-
- inline float y() const { return m_Y; }
- void y(float value) {
- if (m_Y == value) {
- return;
+
+ inline float originX() const { return m_OriginX; }
+ void originX(float value) {
+ if (m_OriginX == value) {
+ return;
+ }
+ m_OriginX = value;
+ originXChanged();
}
- m_Y = value;
- yChanged();
- }
-
- inline float originX() const { return m_OriginX; }
- void originX(float value) {
- if (m_OriginX == value) {
- return;
+
+ inline float originY() const { return m_OriginY; }
+ void originY(float value) {
+ if (m_OriginY == value) {
+ return;
+ }
+ m_OriginY = value;
+ originYChanged();
}
- m_OriginX = value;
- originXChanged();
- }
-
- inline float originY() const { return m_OriginY; }
- void originY(float value) {
- if (m_OriginY == value) {
- return;
+
+ inline uint32_t defaultStateMachineId() const { return m_DefaultStateMachineId; }
+ void defaultStateMachineId(uint32_t value) {
+ if (m_DefaultStateMachineId == value) {
+ return;
+ }
+ m_DefaultStateMachineId = value;
+ defaultStateMachineIdChanged();
}
- m_OriginY = value;
- originYChanged();
- }
-
- inline uint32_t defaultStateMachineId() const { return m_DefaultStateMachineId; }
- void defaultStateMachineId(uint32_t value) {
- if (m_DefaultStateMachineId == value) {
- return;
+
+ Core* clone() const override;
+ void copy(const ArtboardBase& object) {
+ m_Clip = object.m_Clip;
+ m_Width = object.m_Width;
+ m_Height = object.m_Height;
+ m_X = object.m_X;
+ m_Y = object.m_Y;
+ m_OriginX = object.m_OriginX;
+ m_OriginY = object.m_OriginY;
+ m_DefaultStateMachineId = object.m_DefaultStateMachineId;
+ WorldTransformComponent::copy(object);
}
- m_DefaultStateMachineId = value;
- defaultStateMachineIdChanged();
- }
-
- Core* clone() const override;
- void copy(const ArtboardBase& object) {
- m_Clip = object.m_Clip;
- m_Width = object.m_Width;
- m_Height = object.m_Height;
- m_X = object.m_X;
- m_Y = object.m_Y;
- m_OriginX = object.m_OriginX;
- m_OriginY = object.m_OriginY;
- m_DefaultStateMachineId = object.m_DefaultStateMachineId;
- 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;
- case defaultStateMachineIdPropertyKey:
- m_DefaultStateMachineId = CoreUintType::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;
+ }
+ return WorldTransformComponent::deserialize(propertyKey, reader);
}
- return WorldTransformComponent::deserialize(propertyKey, reader);
- }
-
-protected:
- virtual void clipChanged() {}
- virtual void widthChanged() {}
- virtual void heightChanged() {}
- virtual void xChanged() {}
- virtual void yChanged() {}
- virtual void originXChanged() {}
- virtual void originYChanged() {}
- virtual void defaultStateMachineIdChanged() {}
-};
+
+ protected:
+ virtual void clipChanged() {}
+ virtual void widthChanged() {}
+ virtual void heightChanged() {}
+ virtual void xChanged() {}
+ virtual void yChanged() {}
+ virtual void originXChanged() {}
+ virtual void originYChanged() {}
+ virtual void defaultStateMachineIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core.hpp"
#include "rive/core/field_types/core_string_type.hpp"
namespace rive {
-class AssetBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 99;
-
- /// 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;
+ class AssetBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 99;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t namePropertyKey = 203;
+ static const uint16_t namePropertyKey = 203;
-private:
- std::string m_Name = "";
+ private:
+ std::string m_Name = "";
-public:
- inline const std::string& name() const { return m_Name; }
- void name(std::string value) {
- if (m_Name == value) {
- return;
+ public:
+ inline const std::string& name() const { return m_Name; }
+ void name(std::string value) {
+ if (m_Name == value) {
+ return;
+ }
+ m_Name = value;
+ nameChanged();
}
- m_Name = value;
- nameChanged();
- }
- void copy(const AssetBase& object) { m_Name = object.m_Name; }
+ 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;
}
- return false;
- }
-protected:
- virtual void nameChanged() {}
-};
+ protected:
+ virtual void nameChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/assets/file_asset.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class DrawableAssetBase : public FileAsset {
-protected:
- typedef FileAsset Super;
+ class DrawableAssetBase : public FileAsset {
+ protected:
+ typedef FileAsset Super;
-public:
- static const uint16_t typeKey = 104;
+ public:
+ static const uint16_t typeKey = 104;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case DrawableAssetBase::typeKey:
- case FileAssetBase::typeKey:
- case AssetBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case DrawableAssetBase::typeKey:
+ case FileAssetBase::typeKey:
+ case AssetBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t heightPropertyKey = 207;
- static const uint16_t widthPropertyKey = 208;
+ static const uint16_t heightPropertyKey = 207;
+ static const uint16_t widthPropertyKey = 208;
-private:
- float m_Height = 0.0f;
- float m_Width = 0.0f;
+ private:
+ float m_Height = 0.0f;
+ float m_Width = 0.0f;
-public:
- inline float height() const { return m_Height; }
- void height(float value) {
- if (m_Height == value) {
- return;
+ public:
+ inline float height() const { return m_Height; }
+ void height(float value) {
+ if (m_Height == value) {
+ return;
+ }
+ m_Height = value;
+ heightChanged();
}
- m_Height = value;
- heightChanged();
- }
- inline float width() const { return m_Width; }
- void width(float value) {
- if (m_Width == value) {
- return;
+ inline float width() const { return m_Width; }
+ void width(float value) {
+ if (m_Width == value) {
+ return;
+ }
+ m_Width = value;
+ widthChanged();
}
- m_Width = value;
- widthChanged();
- }
- void copy(const DrawableAssetBase& object) {
- m_Height = object.m_Height;
- m_Width = object.m_Width;
- FileAsset::copy(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);
}
- return FileAsset::deserialize(propertyKey, reader);
- }
-protected:
- virtual void heightChanged() {}
- virtual void widthChanged() {}
-};
+ protected:
+ virtual void heightChanged() {}
+ virtual void widthChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/assets/asset.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class FileAssetBase : public Asset {
-protected:
- typedef Asset Super;
-
-public:
- static const uint16_t typeKey = 103;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case FileAssetBase::typeKey:
- case AssetBase::typeKey: return true;
- default: return false;
+ class FileAssetBase : public Asset {
+ protected:
+ typedef Asset Super;
+
+ public:
+ static const uint16_t typeKey = 103;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case FileAssetBase::typeKey:
+ case AssetBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t assetIdPropertyKey = 204;
+ static const uint16_t assetIdPropertyKey = 204;
-private:
- uint32_t m_AssetId = 0;
+ private:
+ uint32_t m_AssetId = 0;
-public:
- inline uint32_t assetId() const { return m_AssetId; }
- void assetId(uint32_t value) {
- if (m_AssetId == value) {
- return;
+ public:
+ inline uint32_t assetId() const { return m_AssetId; }
+ void assetId(uint32_t value) {
+ if (m_AssetId == value) {
+ return;
+ }
+ m_AssetId = value;
+ assetIdChanged();
}
- m_AssetId = value;
- assetIdChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return Asset::deserialize(propertyKey, reader);
}
- return Asset::deserialize(propertyKey, reader);
- }
-protected:
- virtual void assetIdChanged() {}
-};
+ protected:
+ virtual void assetIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bytes_type.hpp"
#include "rive/span.hpp"
namespace rive {
-class FileAssetContentsBase : public Core {
-protected:
- typedef Core Super;
-
-public:
- static const uint16_t typeKey = 106;
-
- /// 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;
+ class FileAssetContentsBase : public Core {
+ protected:
+ typedef Core Super;
+
+ public:
+ static const uint16_t typeKey = 106;
+
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t bytesPropertyKey = 212;
+ static const uint16_t bytesPropertyKey = 212;
-public:
- virtual void decodeBytes(Span<const uint8_t> value) = 0;
- virtual void copyBytes(const FileAssetContentsBase& object) = 0;
+ public:
+ virtual void decodeBytes(Span<const uint8_t> value) = 0;
+ virtual void copyBytes(const FileAssetContentsBase& object) = 0;
- Core* clone() const override;
- void copy(const FileAssetContentsBase& object) { copyBytes(object); }
+ 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;
}
- return false;
- }
-protected:
- virtual void bytesChanged() {}
-};
+ protected:
+ virtual void bytesChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_FOLDER_BASE_HPP_
#include "rive/assets/asset.hpp"
namespace rive {
-class FolderBase : public Asset {
-protected:
- typedef Asset Super;
+ class FolderBase : public Asset {
+ protected:
+ typedef Asset Super;
-public:
- static const uint16_t typeKey = 102;
+ public:
+ static const uint16_t typeKey = 102;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case FolderBase::typeKey:
- case AssetBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case FolderBase::typeKey:
+ case AssetBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_IMAGE_ASSET_BASE_HPP_
#include "rive/assets/drawable_asset.hpp"
namespace rive {
-class ImageAssetBase : public DrawableAsset {
-protected:
- typedef DrawableAsset Super;
+ class ImageAssetBase : public DrawableAsset {
+ protected:
+ typedef DrawableAsset Super;
-public:
- static const uint16_t typeKey = 105;
+ public:
+ static const uint16_t typeKey = 105;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_BACKBOARD_BASE_HPP_
#include "rive/core.hpp"
namespace rive {
-class BackboardBase : public Core {
-protected:
- typedef Core Super;
+ class BackboardBase : public Core {
+ protected:
+ typedef Core Super;
-public:
- static const uint16_t typeKey = 23;
+ public:
+ static const uint16_t typeKey = 23;
- /// 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;
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
- void copy(const BackboardBase& object) {}
+ Core* clone() const override;
+ void copy(const BackboardBase& object) {}
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { return false; }
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override { return false; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/bones/skeletal_component.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class BoneBase : public SkeletalComponent {
-protected:
- typedef SkeletalComponent Super;
-
-public:
- static const uint16_t typeKey = 40;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class BoneBase : public SkeletalComponent {
+ protected:
+ typedef SkeletalComponent Super;
+
+ public:
+ static const uint16_t typeKey = 40;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t lengthPropertyKey = 89;
+ static const uint16_t lengthPropertyKey = 89;
-private:
- float m_Length = 0.0f;
+ private:
+ float m_Length = 0.0f;
-public:
- inline float length() const { return m_Length; }
- void length(float value) {
- if (m_Length == value) {
- return;
+ public:
+ inline float length() const { return m_Length; }
+ void length(float value) {
+ if (m_Length == value) {
+ return;
+ }
+ m_Length = value;
+ lengthChanged();
}
- m_Length = value;
- lengthChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return SkeletalComponent::deserialize(propertyKey, reader);
}
- return SkeletalComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void lengthChanged() {}
-};
+ protected:
+ virtual void lengthChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/bones/weight.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class CubicWeightBase : public Weight {
-protected:
- typedef Weight Super;
+ class CubicWeightBase : public Weight {
+ protected:
+ typedef Weight Super;
-public:
- static const uint16_t typeKey = 46;
+ public:
+ static const uint16_t typeKey = 46;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case CubicWeightBase::typeKey:
- case WeightBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case CubicWeightBase::typeKey:
+ case WeightBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inValuesPropertyKey = 110;
- static const uint16_t inIndicesPropertyKey = 111;
- static const uint16_t outValuesPropertyKey = 112;
- static const uint16_t outIndicesPropertyKey = 113;
+ static const uint16_t inValuesPropertyKey = 110;
+ static const uint16_t inIndicesPropertyKey = 111;
+ static const uint16_t outValuesPropertyKey = 112;
+ static const uint16_t outIndicesPropertyKey = 113;
-private:
- uint32_t m_InValues = 255;
- uint32_t m_InIndices = 1;
- uint32_t m_OutValues = 255;
- uint32_t m_OutIndices = 1;
+ private:
+ uint32_t m_InValues = 255;
+ uint32_t m_InIndices = 1;
+ uint32_t m_OutValues = 255;
+ uint32_t m_OutIndices = 1;
-public:
- inline uint32_t inValues() const { return m_InValues; }
- void inValues(uint32_t value) {
- if (m_InValues == value) {
- return;
+ public:
+ inline uint32_t inValues() const { return m_InValues; }
+ void inValues(uint32_t value) {
+ if (m_InValues == value) {
+ return;
+ }
+ m_InValues = value;
+ inValuesChanged();
}
- m_InValues = value;
- inValuesChanged();
- }
- inline uint32_t inIndices() const { return m_InIndices; }
- void inIndices(uint32_t value) {
- if (m_InIndices == value) {
- return;
+ inline uint32_t inIndices() const { return m_InIndices; }
+ void inIndices(uint32_t value) {
+ if (m_InIndices == value) {
+ return;
+ }
+ m_InIndices = value;
+ inIndicesChanged();
}
- m_InIndices = value;
- inIndicesChanged();
- }
- inline uint32_t outValues() const { return m_OutValues; }
- void outValues(uint32_t value) {
- if (m_OutValues == value) {
- return;
+ inline uint32_t outValues() const { return m_OutValues; }
+ void outValues(uint32_t value) {
+ if (m_OutValues == value) {
+ return;
+ }
+ m_OutValues = value;
+ outValuesChanged();
}
- m_OutValues = value;
- outValuesChanged();
- }
- inline uint32_t outIndices() const { return m_OutIndices; }
- void outIndices(uint32_t value) {
- if (m_OutIndices == value) {
- return;
+ inline uint32_t outIndices() const { return m_OutIndices; }
+ void outIndices(uint32_t value) {
+ if (m_OutIndices == value) {
+ return;
+ }
+ m_OutIndices = value;
+ outIndicesChanged();
}
- m_OutIndices = value;
- outIndicesChanged();
- }
- Core* clone() const override;
- void copy(const CubicWeightBase& object) {
- m_InValues = object.m_InValues;
- m_InIndices = object.m_InIndices;
- m_OutValues = object.m_OutValues;
- m_OutIndices = object.m_OutIndices;
- Weight::copy(object);
- }
+ Core* clone() const override;
+ void copy(const CubicWeightBase& object) {
+ m_InValues = object.m_InValues;
+ m_InIndices = object.m_InIndices;
+ m_OutValues = object.m_OutValues;
+ m_OutIndices = object.m_OutIndices;
+ 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;
- case outIndicesPropertyKey:
- m_OutIndices = 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;
+ }
+ return Weight::deserialize(propertyKey, reader);
}
- return Weight::deserialize(propertyKey, reader);
- }
-protected:
- virtual void inValuesChanged() {}
- virtual void inIndicesChanged() {}
- virtual void outValuesChanged() {}
- virtual void outIndicesChanged() {}
-};
+ protected:
+ virtual void inValuesChanged() {}
+ virtual void inIndicesChanged() {}
+ virtual void outValuesChanged() {}
+ virtual void outIndicesChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/bones/bone.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class RootBoneBase : public Bone {
-protected:
- typedef Bone Super;
+ class RootBoneBase : public Bone {
+ protected:
+ typedef Bone Super;
-public:
- static const uint16_t typeKey = 41;
+ public:
+ static const uint16_t typeKey = 41;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t xPropertyKey = 90;
- static const uint16_t yPropertyKey = 91;
+ static const uint16_t xPropertyKey = 90;
+ static const uint16_t yPropertyKey = 91;
-private:
- float m_X = 0.0f;
- float m_Y = 0.0f;
+ private:
+ float m_X = 0.0f;
+ float m_Y = 0.0f;
-public:
- inline float x() const override { return m_X; }
- void x(float value) {
- if (m_X == value) {
- return;
+ public:
+ inline float x() const override { return m_X; }
+ void x(float value) {
+ if (m_X == value) {
+ return;
+ }
+ m_X = value;
+ xChanged();
}
- m_X = value;
- xChanged();
- }
- inline float y() const override { return m_Y; }
- void y(float value) {
- if (m_Y == value) {
- return;
+ inline float y() const override { return m_Y; }
+ void y(float value) {
+ if (m_Y == value) {
+ return;
+ }
+ m_Y = value;
+ yChanged();
}
- m_Y = value;
- yChanged();
- }
- Core* clone() const override;
- void copy(const RootBoneBase& object) {
- m_X = object.m_X;
- m_Y = object.m_Y;
- Bone::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return Bone::deserialize(propertyKey, reader);
- }
-protected:
- virtual void xChanged() {}
- virtual void yChanged() {}
-};
+ protected:
+ virtual void xChanged() {}
+ virtual void yChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_SKELETAL_COMPONENT_BASE_HPP_
#include "rive/transform_component.hpp"
namespace rive {
-class SkeletalComponentBase : public TransformComponent {
-protected:
- typedef TransformComponent Super;
+ class SkeletalComponentBase : public TransformComponent {
+ protected:
+ typedef TransformComponent Super;
-public:
- static const uint16_t typeKey = 39;
+ public:
+ static const uint16_t typeKey = 39;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/container_component.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class SkinBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
+ class SkinBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
-public:
- static const uint16_t typeKey = 43;
+ public:
+ static const uint16_t typeKey = 43;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case SkinBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case SkinBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t xxPropertyKey = 104;
- static const uint16_t yxPropertyKey = 105;
- static const uint16_t xyPropertyKey = 106;
- static const uint16_t yyPropertyKey = 107;
- static const uint16_t txPropertyKey = 108;
- static const uint16_t tyPropertyKey = 109;
+ static const uint16_t xxPropertyKey = 104;
+ static const uint16_t yxPropertyKey = 105;
+ static const uint16_t xyPropertyKey = 106;
+ static const uint16_t yyPropertyKey = 107;
+ static const uint16_t txPropertyKey = 108;
+ static const uint16_t tyPropertyKey = 109;
-private:
- float m_Xx = 1.0f;
- float m_Yx = 0.0f;
- float m_Xy = 0.0f;
- float m_Yy = 1.0f;
- float m_Tx = 0.0f;
- float m_Ty = 0.0f;
+ private:
+ float m_Xx = 1.0f;
+ float m_Yx = 0.0f;
+ float m_Xy = 0.0f;
+ float m_Yy = 1.0f;
+ float m_Tx = 0.0f;
+ float m_Ty = 0.0f;
-public:
- inline float xx() const { return m_Xx; }
- void xx(float value) {
- if (m_Xx == value) {
- return;
+ public:
+ inline float xx() const { return m_Xx; }
+ void xx(float value) {
+ if (m_Xx == value) {
+ return;
+ }
+ m_Xx = value;
+ xxChanged();
}
- m_Xx = value;
- xxChanged();
- }
- inline float yx() const { return m_Yx; }
- void yx(float value) {
- if (m_Yx == value) {
- return;
+ inline float yx() const { return m_Yx; }
+ void yx(float value) {
+ if (m_Yx == value) {
+ return;
+ }
+ m_Yx = value;
+ yxChanged();
}
- m_Yx = value;
- yxChanged();
- }
- inline float xy() const { return m_Xy; }
- void xy(float value) {
- if (m_Xy == value) {
- return;
+ inline float xy() const { return m_Xy; }
+ void xy(float value) {
+ if (m_Xy == value) {
+ return;
+ }
+ m_Xy = value;
+ xyChanged();
}
- m_Xy = value;
- xyChanged();
- }
- inline float yy() const { return m_Yy; }
- void yy(float value) {
- if (m_Yy == value) {
- return;
+ inline float yy() const { return m_Yy; }
+ void yy(float value) {
+ if (m_Yy == value) {
+ return;
+ }
+ m_Yy = value;
+ yyChanged();
}
- m_Yy = value;
- yyChanged();
- }
- inline float tx() const { return m_Tx; }
- void tx(float value) {
- if (m_Tx == value) {
- return;
+ inline float tx() const { return m_Tx; }
+ void tx(float value) {
+ if (m_Tx == value) {
+ return;
+ }
+ m_Tx = value;
+ txChanged();
}
- m_Tx = value;
- txChanged();
- }
- inline float ty() const { return m_Ty; }
- void ty(float value) {
- if (m_Ty == value) {
- return;
+ inline float ty() const { return m_Ty; }
+ void ty(float value) {
+ if (m_Ty == value) {
+ return;
+ }
+ m_Ty = value;
+ tyChanged();
}
- m_Ty = value;
- tyChanged();
- }
- Core* clone() const override;
- void copy(const SkinBase& object) {
- m_Xx = object.m_Xx;
- m_Yx = object.m_Yx;
- m_Xy = object.m_Xy;
- m_Yy = object.m_Yy;
- m_Tx = object.m_Tx;
- m_Ty = object.m_Ty;
- ContainerComponent::copy(object);
- }
+ Core* clone() const override;
+ void copy(const SkinBase& object) {
+ m_Xx = object.m_Xx;
+ m_Yx = object.m_Yx;
+ m_Xy = object.m_Xy;
+ m_Yy = object.m_Yy;
+ m_Tx = object.m_Tx;
+ m_Ty = object.m_Ty;
+ 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);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void xxChanged() {}
- virtual void yxChanged() {}
- virtual void xyChanged() {}
- virtual void yyChanged() {}
- virtual void txChanged() {}
- virtual void tyChanged() {}
-};
+ protected:
+ virtual void xxChanged() {}
+ virtual void yxChanged() {}
+ virtual void xyChanged() {}
+ virtual void yyChanged() {}
+ virtual void txChanged() {}
+ virtual void tyChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TendonBase : public Component {
-protected:
- typedef Component Super;
-
-public:
- static const uint16_t typeKey = 44;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TendonBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class TendonBase : public Component {
+ protected:
+ typedef Component Super;
+
+ public:
+ static const uint16_t typeKey = 44;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TendonBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
-
- uint16_t coreType() const override { return typeKey; }
-
- static const uint16_t boneIdPropertyKey = 95;
- static const uint16_t xxPropertyKey = 96;
- static const uint16_t yxPropertyKey = 97;
- static const uint16_t xyPropertyKey = 98;
- static const uint16_t yyPropertyKey = 99;
- static const uint16_t txPropertyKey = 100;
- static const uint16_t tyPropertyKey = 101;
-
-private:
- uint32_t m_BoneId = -1;
- float m_Xx = 1.0f;
- float m_Yx = 0.0f;
- float m_Xy = 0.0f;
- float m_Yy = 1.0f;
- float m_Tx = 0.0f;
- float m_Ty = 0.0f;
-
-public:
- inline uint32_t boneId() const { return m_BoneId; }
- void boneId(uint32_t value) {
- if (m_BoneId == value) {
- return;
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t boneIdPropertyKey = 95;
+ static const uint16_t xxPropertyKey = 96;
+ static const uint16_t yxPropertyKey = 97;
+ static const uint16_t xyPropertyKey = 98;
+ static const uint16_t yyPropertyKey = 99;
+ static const uint16_t txPropertyKey = 100;
+ static const uint16_t tyPropertyKey = 101;
+
+ private:
+ uint32_t m_BoneId = -1;
+ float m_Xx = 1.0f;
+ float m_Yx = 0.0f;
+ float m_Xy = 0.0f;
+ float m_Yy = 1.0f;
+ float m_Tx = 0.0f;
+ float m_Ty = 0.0f;
+
+ public:
+ inline uint32_t boneId() const { return m_BoneId; }
+ void boneId(uint32_t value) {
+ if (m_BoneId == value) {
+ return;
+ }
+ m_BoneId = value;
+ boneIdChanged();
}
- m_BoneId = value;
- boneIdChanged();
- }
-
- inline float xx() const { return m_Xx; }
- void xx(float value) {
- if (m_Xx == value) {
- return;
+
+ inline float xx() const { return m_Xx; }
+ void xx(float value) {
+ if (m_Xx == value) {
+ return;
+ }
+ m_Xx = value;
+ xxChanged();
}
- m_Xx = value;
- xxChanged();
- }
-
- inline float yx() const { return m_Yx; }
- void yx(float value) {
- if (m_Yx == value) {
- return;
+
+ inline float yx() const { return m_Yx; }
+ void yx(float value) {
+ if (m_Yx == value) {
+ return;
+ }
+ m_Yx = value;
+ yxChanged();
}
- m_Yx = value;
- yxChanged();
- }
-
- inline float xy() const { return m_Xy; }
- void xy(float value) {
- if (m_Xy == value) {
- return;
+
+ inline float xy() const { return m_Xy; }
+ void xy(float value) {
+ if (m_Xy == value) {
+ return;
+ }
+ m_Xy = value;
+ xyChanged();
}
- m_Xy = value;
- xyChanged();
- }
-
- inline float yy() const { return m_Yy; }
- void yy(float value) {
- if (m_Yy == value) {
- return;
+
+ inline float yy() const { return m_Yy; }
+ void yy(float value) {
+ if (m_Yy == value) {
+ return;
+ }
+ m_Yy = value;
+ yyChanged();
}
- m_Yy = value;
- yyChanged();
- }
-
- inline float tx() const { return m_Tx; }
- void tx(float value) {
- if (m_Tx == value) {
- return;
+
+ inline float tx() const { return m_Tx; }
+ void tx(float value) {
+ if (m_Tx == value) {
+ return;
+ }
+ m_Tx = value;
+ txChanged();
}
- m_Tx = value;
- txChanged();
- }
-
- inline float ty() const { return m_Ty; }
- void ty(float value) {
- if (m_Ty == value) {
- return;
+
+ inline float ty() const { return m_Ty; }
+ void ty(float value) {
+ if (m_Ty == value) {
+ return;
+ }
+ m_Ty = value;
+ tyChanged();
}
- m_Ty = value;
- tyChanged();
- }
-
- Core* clone() const override;
- void copy(const TendonBase& object) {
- m_BoneId = object.m_BoneId;
- m_Xx = object.m_Xx;
- m_Yx = object.m_Yx;
- m_Xy = object.m_Xy;
- m_Yy = object.m_Yy;
- m_Tx = object.m_Tx;
- m_Ty = object.m_Ty;
- 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;
+
+ Core* clone() const override;
+ void copy(const TendonBase& object) {
+ m_BoneId = object.m_BoneId;
+ m_Xx = object.m_Xx;
+ m_Yx = object.m_Yx;
+ m_Xy = object.m_Xy;
+ m_Yy = object.m_Yy;
+ m_Tx = object.m_Tx;
+ m_Ty = object.m_Ty;
+ Component::copy(object);
}
- return Component::deserialize(propertyKey, reader);
- }
-
-protected:
- virtual void boneIdChanged() {}
- virtual void xxChanged() {}
- virtual void yxChanged() {}
- virtual void xyChanged() {}
- virtual void yyChanged() {}
- virtual void txChanged() {}
- virtual void tyChanged() {}
-};
+
+ 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);
+ }
+
+ protected:
+ virtual void boneIdChanged() {}
+ virtual void xxChanged() {}
+ virtual void yxChanged() {}
+ virtual void xyChanged() {}
+ virtual void yyChanged() {}
+ virtual void txChanged() {}
+ virtual void tyChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class WeightBase : public Component {
-protected:
- typedef Component Super;
+ class WeightBase : public Component {
+ protected:
+ typedef Component Super;
-public:
- static const uint16_t typeKey = 45;
+ public:
+ static const uint16_t typeKey = 45;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case WeightBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case WeightBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t valuesPropertyKey = 102;
- static const uint16_t indicesPropertyKey = 103;
+ static const uint16_t valuesPropertyKey = 102;
+ static const uint16_t indicesPropertyKey = 103;
-private:
- uint32_t m_Values = 255;
- uint32_t m_Indices = 1;
+ private:
+ uint32_t m_Values = 255;
+ uint32_t m_Indices = 1;
-public:
- inline uint32_t values() const { return m_Values; }
- void values(uint32_t value) {
- if (m_Values == value) {
- return;
+ public:
+ inline uint32_t values() const { return m_Values; }
+ void values(uint32_t value) {
+ if (m_Values == value) {
+ return;
+ }
+ m_Values = value;
+ valuesChanged();
}
- m_Values = value;
- valuesChanged();
- }
- inline uint32_t indices() const { return m_Indices; }
- void indices(uint32_t value) {
- if (m_Indices == value) {
- return;
+ inline uint32_t indices() const { return m_Indices; }
+ void indices(uint32_t value) {
+ if (m_Indices == value) {
+ return;
+ }
+ m_Indices = value;
+ indicesChanged();
}
- m_Indices = value;
- indicesChanged();
- }
- Core* clone() const override;
- void copy(const WeightBase& object) {
- m_Values = object.m_Values;
- m_Indices = object.m_Indices;
- Component::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void valuesChanged() {}
- virtual void indicesChanged() {}
-};
+ protected:
+ virtual void valuesChanged() {}
+ virtual void indicesChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_string_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class ComponentBase : public Core {
-protected:
- typedef Core Super;
+ class ComponentBase : public Core {
+ protected:
+ typedef Core Super;
-public:
- static const uint16_t typeKey = 10;
+ public:
+ static const uint16_t typeKey = 10;
- /// 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;
+ /// 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t namePropertyKey = 4;
- static const uint16_t parentIdPropertyKey = 5;
+ static const uint16_t namePropertyKey = 4;
+ static const uint16_t parentIdPropertyKey = 5;
-private:
- std::string m_Name = "";
- uint32_t m_ParentId = 0;
+ private:
+ std::string m_Name = "";
+ uint32_t m_ParentId = 0;
-public:
- inline const std::string& name() const { return m_Name; }
- void name(std::string value) {
- if (m_Name == value) {
- return;
+ public:
+ inline const std::string& name() const { return m_Name; }
+ void name(std::string value) {
+ if (m_Name == value) {
+ return;
+ }
+ m_Name = value;
+ nameChanged();
}
- m_Name = value;
- nameChanged();
- }
- inline uint32_t parentId() const { return m_ParentId; }
- void parentId(uint32_t value) {
- if (m_ParentId == value) {
- return;
+ inline uint32_t parentId() const { return m_ParentId; }
+ void parentId(uint32_t value) {
+ if (m_ParentId == value) {
+ return;
+ }
+ m_ParentId = value;
+ parentIdChanged();
}
- m_ParentId = value;
- parentIdChanged();
- }
- void copy(const ComponentBase& object) {
- m_Name = object.m_Name;
- m_ParentId = object.m_ParentId;
- }
+ 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;
}
- return false;
- }
-protected:
- virtual void nameChanged() {}
- virtual void parentIdChanged() {}
-};
+ protected:
+ virtual void nameChanged() {}
+ virtual void parentIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/component.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class ConstraintBase : public Component {
-protected:
- typedef Component Super;
-
-public:
- static const uint16_t typeKey = 79;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ConstraintBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class ConstraintBase : public Component {
+ protected:
+ typedef Component Super;
+
+ public:
+ static const uint16_t typeKey = 79;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ConstraintBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t strengthPropertyKey = 172;
+ static const uint16_t strengthPropertyKey = 172;
-private:
- float m_Strength = 1.0f;
+ private:
+ float m_Strength = 1.0f;
-public:
- inline float strength() const { return m_Strength; }
- void strength(float value) {
- if (m_Strength == value) {
- return;
+ public:
+ inline float strength() const { return m_Strength; }
+ void strength(float value) {
+ if (m_Strength == value) {
+ return;
+ }
+ m_Strength = value;
+ strengthChanged();
}
- m_Strength = value;
- strengthChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return Component::deserialize(propertyKey, reader);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void strengthChanged() {}
-};
+ protected:
+ virtual void strengthChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class DistanceConstraintBase : public TargetedConstraint {
-protected:
- typedef TargetedConstraint Super;
+ class DistanceConstraintBase : public TargetedConstraint {
+ protected:
+ typedef TargetedConstraint Super;
-public:
- static const uint16_t typeKey = 82;
+ public:
+ static const uint16_t typeKey = 82;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t distancePropertyKey = 177;
- static const uint16_t modeValuePropertyKey = 178;
+ static const uint16_t distancePropertyKey = 177;
+ static const uint16_t modeValuePropertyKey = 178;
-private:
- float m_Distance = 100.0f;
- uint32_t m_ModeValue = 0;
+ private:
+ float m_Distance = 100.0f;
+ uint32_t m_ModeValue = 0;
-public:
- inline float distance() const { return m_Distance; }
- void distance(float value) {
- if (m_Distance == value) {
- return;
+ public:
+ inline float distance() const { return m_Distance; }
+ void distance(float value) {
+ if (m_Distance == value) {
+ return;
+ }
+ m_Distance = value;
+ distanceChanged();
}
- m_Distance = value;
- distanceChanged();
- }
- inline uint32_t modeValue() const { return m_ModeValue; }
- void modeValue(uint32_t value) {
- if (m_ModeValue == value) {
- return;
+ inline uint32_t modeValue() const { return m_ModeValue; }
+ void modeValue(uint32_t value) {
+ if (m_ModeValue == value) {
+ return;
+ }
+ m_ModeValue = value;
+ modeValueChanged();
}
- m_ModeValue = value;
- modeValueChanged();
- }
- Core* clone() const override;
- void copy(const DistanceConstraintBase& object) {
- m_Distance = object.m_Distance;
- m_ModeValue = object.m_ModeValue;
- TargetedConstraint::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return TargetedConstraint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void distanceChanged() {}
- virtual void modeValueChanged() {}
-};
+ protected:
+ virtual void distanceChanged() {}
+ virtual void modeValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bool_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class IKConstraintBase : public TargetedConstraint {
-protected:
- typedef TargetedConstraint Super;
+ class IKConstraintBase : public TargetedConstraint {
+ protected:
+ typedef TargetedConstraint Super;
-public:
- static const uint16_t typeKey = 81;
+ public:
+ static const uint16_t typeKey = 81;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t invertDirectionPropertyKey = 174;
- static const uint16_t parentBoneCountPropertyKey = 175;
+ static const uint16_t invertDirectionPropertyKey = 174;
+ static const uint16_t parentBoneCountPropertyKey = 175;
-private:
- bool m_InvertDirection = false;
- uint32_t m_ParentBoneCount = 0;
+ private:
+ bool m_InvertDirection = false;
+ uint32_t m_ParentBoneCount = 0;
-public:
- inline bool invertDirection() const { return m_InvertDirection; }
- void invertDirection(bool value) {
- if (m_InvertDirection == value) {
- return;
+ public:
+ inline bool invertDirection() const { return m_InvertDirection; }
+ void invertDirection(bool value) {
+ if (m_InvertDirection == value) {
+ return;
+ }
+ m_InvertDirection = value;
+ invertDirectionChanged();
}
- m_InvertDirection = value;
- invertDirectionChanged();
- }
- inline uint32_t parentBoneCount() const { return m_ParentBoneCount; }
- void parentBoneCount(uint32_t value) {
- if (m_ParentBoneCount == value) {
- return;
+ inline uint32_t parentBoneCount() const { return m_ParentBoneCount; }
+ void parentBoneCount(uint32_t value) {
+ if (m_ParentBoneCount == value) {
+ return;
+ }
+ m_ParentBoneCount = value;
+ parentBoneCountChanged();
}
- m_ParentBoneCount = value;
- parentBoneCountChanged();
- }
- Core* clone() const override;
- void copy(const IKConstraintBase& object) {
- m_InvertDirection = object.m_InvertDirection;
- m_ParentBoneCount = object.m_ParentBoneCount;
- TargetedConstraint::copy(object);
- }
+ Core* clone() const override;
+ 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) {
- case invertDirectionPropertyKey:
- m_InvertDirection = CoreBoolType::deserialize(reader);
- return true;
- case parentBoneCountPropertyKey:
- m_ParentBoneCount = CoreUintType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case invertDirectionPropertyKey:
+ m_InvertDirection = CoreBoolType::deserialize(reader);
+ return true;
+ case parentBoneCountPropertyKey:
+ m_ParentBoneCount = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return TargetedConstraint::deserialize(propertyKey, reader);
}
- return TargetedConstraint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void invertDirectionChanged() {}
- virtual void parentBoneCountChanged() {}
-};
+ protected:
+ virtual void invertDirectionChanged() {}
+ virtual void parentBoneCountChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_ROTATION_CONSTRAINT_BASE_HPP_
#include "rive/constraints/transform_component_constraint.hpp"
namespace rive {
-class RotationConstraintBase : public TransformComponentConstraint {
-protected:
- typedef TransformComponentConstraint Super;
+ class RotationConstraintBase : public TransformComponentConstraint {
+ protected:
+ typedef TransformComponentConstraint Super;
-public:
- static const uint16_t typeKey = 89;
+ public:
+ static const uint16_t typeKey = 89;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_SCALE_CONSTRAINT_BASE_HPP_
#include "rive/constraints/transform_component_constraint_y.hpp"
namespace rive {
-class ScaleConstraintBase : public TransformComponentConstraintY {
-protected:
- typedef TransformComponentConstraintY Super;
+ class ScaleConstraintBase : public TransformComponentConstraintY {
+ protected:
+ typedef TransformComponentConstraintY Super;
-public:
- static const uint16_t typeKey = 88;
+ public:
+ static const uint16_t typeKey = 88;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/constraints/constraint.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TargetedConstraintBase : public Constraint {
-protected:
- typedef Constraint Super;
-
-public:
- static const uint16_t typeKey = 80;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TargetedConstraintBase::typeKey:
- case ConstraintBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class TargetedConstraintBase : public Constraint {
+ protected:
+ typedef Constraint Super;
+
+ public:
+ static const uint16_t typeKey = 80;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TargetedConstraintBase::typeKey:
+ case ConstraintBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t targetIdPropertyKey = 173;
+ static const uint16_t targetIdPropertyKey = 173;
-private:
- uint32_t m_TargetId = -1;
+ private:
+ uint32_t m_TargetId = -1;
-public:
- inline uint32_t targetId() const { return m_TargetId; }
- void targetId(uint32_t value) {
- if (m_TargetId == value) {
- return;
+ public:
+ inline uint32_t targetId() const { return m_TargetId; }
+ void targetId(uint32_t value) {
+ if (m_TargetId == value) {
+ return;
+ }
+ m_TargetId = value;
+ targetIdChanged();
}
- m_TargetId = value;
- targetIdChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return Constraint::deserialize(propertyKey, reader);
}
- return Constraint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void targetIdChanged() {}
-};
+ protected:
+ virtual void targetIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TransformComponentConstraintBase : public TransformSpaceConstraint {
-protected:
- typedef TransformSpaceConstraint Super;
-
-public:
- static const uint16_t typeKey = 85;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class TransformComponentConstraintBase : public TransformSpaceConstraint {
+ protected:
+ typedef TransformSpaceConstraint Super;
+
+ public:
+ static const uint16_t typeKey = 85;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
-
- uint16_t coreType() const override { return typeKey; }
-
- static const uint16_t minMaxSpaceValuePropertyKey = 195;
- static const uint16_t copyFactorPropertyKey = 182;
- static const uint16_t minValuePropertyKey = 183;
- static const uint16_t maxValuePropertyKey = 184;
- static const uint16_t offsetPropertyKey = 188;
- static const uint16_t doesCopyPropertyKey = 189;
- static const uint16_t minPropertyKey = 190;
- static const uint16_t maxPropertyKey = 191;
-
-private:
- uint32_t m_MinMaxSpaceValue = 0;
- float m_CopyFactor = 1.0f;
- float m_MinValue = 0.0f;
- float m_MaxValue = 0.0f;
- bool m_Offset = false;
- bool m_DoesCopy = true;
- bool m_Min = false;
- bool m_Max = false;
-
-public:
- inline uint32_t minMaxSpaceValue() const { return m_MinMaxSpaceValue; }
- void minMaxSpaceValue(uint32_t value) {
- if (m_MinMaxSpaceValue == value) {
- return;
+
+ uint16_t coreType() const override { return typeKey; }
+
+ static const uint16_t minMaxSpaceValuePropertyKey = 195;
+ static const uint16_t copyFactorPropertyKey = 182;
+ static const uint16_t minValuePropertyKey = 183;
+ static const uint16_t maxValuePropertyKey = 184;
+ static const uint16_t offsetPropertyKey = 188;
+ static const uint16_t doesCopyPropertyKey = 189;
+ static const uint16_t minPropertyKey = 190;
+ static const uint16_t maxPropertyKey = 191;
+
+ private:
+ uint32_t m_MinMaxSpaceValue = 0;
+ float m_CopyFactor = 1.0f;
+ float m_MinValue = 0.0f;
+ float m_MaxValue = 0.0f;
+ bool m_Offset = false;
+ bool m_DoesCopy = true;
+ bool m_Min = false;
+ bool m_Max = false;
+
+ public:
+ inline uint32_t minMaxSpaceValue() const { return m_MinMaxSpaceValue; }
+ void minMaxSpaceValue(uint32_t value) {
+ if (m_MinMaxSpaceValue == value) {
+ return;
+ }
+ m_MinMaxSpaceValue = value;
+ minMaxSpaceValueChanged();
+ }
+
+ inline float copyFactor() const { return m_CopyFactor; }
+ void copyFactor(float value) {
+ if (m_CopyFactor == value) {
+ return;
+ }
+ m_CopyFactor = value;
+ copyFactorChanged();
}
- m_MinMaxSpaceValue = value;
- minMaxSpaceValueChanged();
- }
-
- inline float copyFactor() const { return m_CopyFactor; }
- void copyFactor(float value) {
- if (m_CopyFactor == value) {
- return;
+
+ inline float minValue() const { return m_MinValue; }
+ void minValue(float value) {
+ if (m_MinValue == value) {
+ return;
+ }
+ m_MinValue = value;
+ minValueChanged();
}
- m_CopyFactor = value;
- copyFactorChanged();
- }
-
- inline float minValue() const { return m_MinValue; }
- void minValue(float value) {
- if (m_MinValue == value) {
- return;
+
+ inline float maxValue() const { return m_MaxValue; }
+ void maxValue(float value) {
+ if (m_MaxValue == value) {
+ return;
+ }
+ m_MaxValue = value;
+ maxValueChanged();
}
- m_MinValue = value;
- minValueChanged();
- }
-
- inline float maxValue() const { return m_MaxValue; }
- void maxValue(float value) {
- if (m_MaxValue == value) {
- return;
+
+ inline bool offset() const { return m_Offset; }
+ void offset(bool value) {
+ if (m_Offset == value) {
+ return;
+ }
+ m_Offset = value;
+ offsetChanged();
}
- m_MaxValue = value;
- maxValueChanged();
- }
-
- inline bool offset() const { return m_Offset; }
- void offset(bool value) {
- if (m_Offset == value) {
- return;
+
+ inline bool doesCopy() const { return m_DoesCopy; }
+ void doesCopy(bool value) {
+ if (m_DoesCopy == value) {
+ return;
+ }
+ m_DoesCopy = value;
+ doesCopyChanged();
}
- m_Offset = value;
- offsetChanged();
- }
-
- inline bool doesCopy() const { return m_DoesCopy; }
- void doesCopy(bool value) {
- if (m_DoesCopy == value) {
- return;
+
+ inline bool min() const { return m_Min; }
+ void min(bool value) {
+ if (m_Min == value) {
+ return;
+ }
+ m_Min = value;
+ minChanged();
}
- m_DoesCopy = value;
- doesCopyChanged();
- }
-
- inline bool min() const { return m_Min; }
- void min(bool value) {
- if (m_Min == value) {
- return;
+
+ inline bool max() const { return m_Max; }
+ void max(bool value) {
+ if (m_Max == value) {
+ return;
+ }
+ m_Max = value;
+ maxChanged();
}
- m_Min = value;
- minChanged();
- }
-
- inline bool max() const { return m_Max; }
- void max(bool value) {
- if (m_Max == value) {
- return;
+
+ void copy(const TransformComponentConstraintBase& object) {
+ m_MinMaxSpaceValue = object.m_MinMaxSpaceValue;
+ m_CopyFactor = object.m_CopyFactor;
+ m_MinValue = object.m_MinValue;
+ m_MaxValue = object.m_MaxValue;
+ m_Offset = object.m_Offset;
+ m_DoesCopy = object.m_DoesCopy;
+ m_Min = object.m_Min;
+ m_Max = object.m_Max;
+ TransformSpaceConstraint::copy(object);
}
- m_Max = value;
- maxChanged();
- }
-
- void copy(const TransformComponentConstraintBase& object) {
- m_MinMaxSpaceValue = object.m_MinMaxSpaceValue;
- m_CopyFactor = object.m_CopyFactor;
- m_MinValue = object.m_MinValue;
- m_MaxValue = object.m_MaxValue;
- m_Offset = object.m_Offset;
- m_DoesCopy = object.m_DoesCopy;
- m_Min = object.m_Min;
- m_Max = object.m_Max;
- TransformSpaceConstraint::copy(object);
- }
-
- 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;
+
+ 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;
+ }
+ return TransformSpaceConstraint::deserialize(propertyKey, reader);
}
- return TransformSpaceConstraint::deserialize(propertyKey, reader);
- }
-
-protected:
- virtual void minMaxSpaceValueChanged() {}
- virtual void copyFactorChanged() {}
- virtual void minValueChanged() {}
- virtual void maxValueChanged() {}
- virtual void offsetChanged() {}
- virtual void doesCopyChanged() {}
- virtual void minChanged() {}
- virtual void maxChanged() {}
-};
+
+ protected:
+ virtual void minMaxSpaceValueChanged() {}
+ virtual void copyFactorChanged() {}
+ virtual void minValueChanged() {}
+ virtual void maxValueChanged() {}
+ virtual void offsetChanged() {}
+ virtual void doesCopyChanged() {}
+ virtual void minChanged() {}
+ virtual void maxChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bool_type.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class TransformComponentConstraintYBase : public TransformComponentConstraint {
-protected:
- typedef TransformComponentConstraint Super;
+ class TransformComponentConstraintYBase : public TransformComponentConstraint {
+ protected:
+ typedef TransformComponentConstraint Super;
-public:
- static const uint16_t typeKey = 86;
+ public:
+ static const uint16_t typeKey = 86;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t copyFactorYPropertyKey = 185;
- static const uint16_t minValueYPropertyKey = 186;
- static const uint16_t maxValueYPropertyKey = 187;
- static const uint16_t doesCopyYPropertyKey = 192;
- static const uint16_t minYPropertyKey = 193;
- static const uint16_t maxYPropertyKey = 194;
+ static const uint16_t copyFactorYPropertyKey = 185;
+ static const uint16_t minValueYPropertyKey = 186;
+ static const uint16_t maxValueYPropertyKey = 187;
+ static const uint16_t doesCopyYPropertyKey = 192;
+ static const uint16_t minYPropertyKey = 193;
+ static const uint16_t maxYPropertyKey = 194;
-private:
- float m_CopyFactorY = 1.0f;
- float m_MinValueY = 0.0f;
- float m_MaxValueY = 0.0f;
- bool m_DoesCopyY = true;
- bool m_MinY = false;
- bool m_MaxY = false;
+ private:
+ float m_CopyFactorY = 1.0f;
+ float m_MinValueY = 0.0f;
+ float m_MaxValueY = 0.0f;
+ bool m_DoesCopyY = true;
+ bool m_MinY = false;
+ bool m_MaxY = false;
-public:
- inline float copyFactorY() const { return m_CopyFactorY; }
- void copyFactorY(float value) {
- if (m_CopyFactorY == value) {
- return;
+ public:
+ inline float copyFactorY() const { return m_CopyFactorY; }
+ void copyFactorY(float value) {
+ if (m_CopyFactorY == value) {
+ return;
+ }
+ m_CopyFactorY = value;
+ copyFactorYChanged();
}
- m_CopyFactorY = value;
- copyFactorYChanged();
- }
- inline float minValueY() const { return m_MinValueY; }
- void minValueY(float value) {
- if (m_MinValueY == value) {
- return;
+ inline float minValueY() const { return m_MinValueY; }
+ void minValueY(float value) {
+ if (m_MinValueY == value) {
+ return;
+ }
+ m_MinValueY = value;
+ minValueYChanged();
}
- m_MinValueY = value;
- minValueYChanged();
- }
- inline float maxValueY() const { return m_MaxValueY; }
- void maxValueY(float value) {
- if (m_MaxValueY == value) {
- return;
+ inline float maxValueY() const { return m_MaxValueY; }
+ void maxValueY(float value) {
+ if (m_MaxValueY == value) {
+ return;
+ }
+ m_MaxValueY = value;
+ maxValueYChanged();
}
- m_MaxValueY = value;
- maxValueYChanged();
- }
- inline bool doesCopyY() const { return m_DoesCopyY; }
- void doesCopyY(bool value) {
- if (m_DoesCopyY == value) {
- return;
+ inline bool doesCopyY() const { return m_DoesCopyY; }
+ void doesCopyY(bool value) {
+ if (m_DoesCopyY == value) {
+ return;
+ }
+ m_DoesCopyY = value;
+ doesCopyYChanged();
}
- m_DoesCopyY = value;
- doesCopyYChanged();
- }
- inline bool minY() const { return m_MinY; }
- void minY(bool value) {
- if (m_MinY == value) {
- return;
+ inline bool minY() const { return m_MinY; }
+ void minY(bool value) {
+ if (m_MinY == value) {
+ return;
+ }
+ m_MinY = value;
+ minYChanged();
}
- m_MinY = value;
- minYChanged();
- }
- inline bool maxY() const { return m_MaxY; }
- void maxY(bool value) {
- if (m_MaxY == value) {
- return;
+ inline bool maxY() const { return m_MaxY; }
+ void maxY(bool value) {
+ if (m_MaxY == value) {
+ return;
+ }
+ m_MaxY = value;
+ maxYChanged();
}
- m_MaxY = value;
- maxYChanged();
- }
- void copy(const TransformComponentConstraintYBase& object) {
- m_CopyFactorY = object.m_CopyFactorY;
- m_MinValueY = object.m_MinValueY;
- m_MaxValueY = object.m_MaxValueY;
- m_DoesCopyY = object.m_DoesCopyY;
- m_MinY = object.m_MinY;
- m_MaxY = object.m_MaxY;
- TransformComponentConstraint::copy(object);
- }
+ void copy(const TransformComponentConstraintYBase& object) {
+ m_CopyFactorY = object.m_CopyFactorY;
+ m_MinValueY = object.m_MinValueY;
+ m_MaxValueY = object.m_MaxValueY;
+ m_DoesCopyY = object.m_DoesCopyY;
+ m_MinY = object.m_MinY;
+ m_MaxY = object.m_MaxY;
+ TransformComponentConstraint::copy(object);
+ }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case copyFactorYPropertyKey:
- m_CopyFactorY = CoreDoubleType::deserialize(reader);
- return true;
- case minValueYPropertyKey:
- m_MinValueY = CoreDoubleType::deserialize(reader);
- return true;
- 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;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case copyFactorYPropertyKey:
+ m_CopyFactorY = CoreDoubleType::deserialize(reader);
+ return true;
+ case minValueYPropertyKey:
+ m_MinValueY = CoreDoubleType::deserialize(reader);
+ return true;
+ 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;
+ }
+ return TransformComponentConstraint::deserialize(propertyKey, reader);
}
- return TransformComponentConstraint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void copyFactorYChanged() {}
- virtual void minValueYChanged() {}
- virtual void maxValueYChanged() {}
- virtual void doesCopyYChanged() {}
- virtual void minYChanged() {}
- virtual void maxYChanged() {}
-};
+ protected:
+ virtual void copyFactorYChanged() {}
+ virtual void minValueYChanged() {}
+ virtual void maxValueYChanged() {}
+ virtual void doesCopyYChanged() {}
+ virtual void minYChanged() {}
+ virtual void maxYChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_TRANSFORM_CONSTRAINT_BASE_HPP_
#include "rive/constraints/transform_space_constraint.hpp"
namespace rive {
-class TransformConstraintBase : public TransformSpaceConstraint {
-protected:
- typedef TransformSpaceConstraint Super;
+ class TransformConstraintBase : public TransformSpaceConstraint {
+ protected:
+ typedef TransformSpaceConstraint Super;
-public:
- static const uint16_t typeKey = 83;
+ public:
+ static const uint16_t typeKey = 83;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/constraints/targeted_constraint.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TransformSpaceConstraintBase : public TargetedConstraint {
-protected:
- typedef TargetedConstraint Super;
+ class TransformSpaceConstraintBase : public TargetedConstraint {
+ protected:
+ typedef TargetedConstraint Super;
-public:
- static const uint16_t typeKey = 90;
+ public:
+ static const uint16_t typeKey = 90;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t sourceSpaceValuePropertyKey = 179;
- static const uint16_t destSpaceValuePropertyKey = 180;
+ static const uint16_t sourceSpaceValuePropertyKey = 179;
+ static const uint16_t destSpaceValuePropertyKey = 180;
-private:
- uint32_t m_SourceSpaceValue = 0;
- uint32_t m_DestSpaceValue = 0;
+ private:
+ uint32_t m_SourceSpaceValue = 0;
+ uint32_t m_DestSpaceValue = 0;
-public:
- inline uint32_t sourceSpaceValue() const { return m_SourceSpaceValue; }
- void sourceSpaceValue(uint32_t value) {
- if (m_SourceSpaceValue == value) {
- return;
+ public:
+ inline uint32_t sourceSpaceValue() const { return m_SourceSpaceValue; }
+ void sourceSpaceValue(uint32_t value) {
+ if (m_SourceSpaceValue == value) {
+ return;
+ }
+ m_SourceSpaceValue = value;
+ sourceSpaceValueChanged();
}
- m_SourceSpaceValue = value;
- sourceSpaceValueChanged();
- }
- inline uint32_t destSpaceValue() const { return m_DestSpaceValue; }
- void destSpaceValue(uint32_t value) {
- if (m_DestSpaceValue == value) {
- return;
+ inline uint32_t destSpaceValue() const { return m_DestSpaceValue; }
+ void destSpaceValue(uint32_t value) {
+ if (m_DestSpaceValue == value) {
+ return;
+ }
+ m_DestSpaceValue = value;
+ destSpaceValueChanged();
}
- m_DestSpaceValue = value;
- destSpaceValueChanged();
- }
- void copy(const TransformSpaceConstraintBase& object) {
- m_SourceSpaceValue = object.m_SourceSpaceValue;
- m_DestSpaceValue = object.m_DestSpaceValue;
- TargetedConstraint::copy(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) {
- case sourceSpaceValuePropertyKey:
- m_SourceSpaceValue = CoreUintType::deserialize(reader);
- return true;
- case destSpaceValuePropertyKey:
- m_DestSpaceValue = CoreUintType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case sourceSpaceValuePropertyKey:
+ m_SourceSpaceValue = CoreUintType::deserialize(reader);
+ return true;
+ case destSpaceValuePropertyKey:
+ m_DestSpaceValue = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return TargetedConstraint::deserialize(propertyKey, reader);
}
- return TargetedConstraint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void sourceSpaceValueChanged() {}
- virtual void destSpaceValueChanged() {}
-};
+ protected:
+ virtual void sourceSpaceValueChanged() {}
+ virtual void destSpaceValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_TRANSLATION_CONSTRAINT_BASE_HPP_
#include "rive/constraints/transform_component_constraint_y.hpp"
namespace rive {
-class TranslationConstraintBase : public TransformComponentConstraintY {
-protected:
- typedef TransformComponentConstraintY Super;
+ class TranslationConstraintBase : public TransformComponentConstraintY {
+ protected:
+ typedef TransformComponentConstraintY Super;
-public:
- static const uint16_t typeKey = 87;
+ public:
+ static const uint16_t typeKey = 87;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CONTAINER_COMPONENT_BASE_HPP_
#include "rive/component.hpp"
namespace rive {
-class ContainerComponentBase : public Component {
-protected:
- typedef Component Super;
+ class ContainerComponentBase : public Component {
+ protected:
+ typedef Component Super;
-public:
- static const uint16_t typeKey = 11;
+ public:
+ static const uint16_t typeKey = 11;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/animation/blend_state_transition.hpp"
#include "rive/animation/cubic_interpolator.hpp"
#include "rive/animation/entry_state.hpp"
+#include "rive/animation/event_bool_change.hpp"
+#include "rive/animation/event_input_change.hpp"
+#include "rive/animation/event_number_change.hpp"
+#include "rive/animation/event_trigger_change.hpp"
#include "rive/animation/exit_state.hpp"
#include "rive/animation/keyed_object.hpp"
#include "rive/animation/keyed_property.hpp"
#include "rive/animation/keyframe_id.hpp"
#include "rive/animation/layer_state.hpp"
#include "rive/animation/linear_animation.hpp"
-#include "rive/animation/listener_action.hpp"
-#include "rive/animation/listener_align_target.hpp"
-#include "rive/animation/listener_bool_change.hpp"
-#include "rive/animation/listener_input_change.hpp"
-#include "rive/animation/listener_number_change.hpp"
-#include "rive/animation/listener_trigger_change.hpp"
-#include "rive/animation/nested_bool.hpp"
-#include "rive/animation/nested_input.hpp"
#include "rive/animation/nested_linear_animation.hpp"
-#include "rive/animation/nested_number.hpp"
#include "rive/animation/nested_remap_animation.hpp"
#include "rive/animation/nested_simple_animation.hpp"
#include "rive/animation/nested_state_machine.hpp"
-#include "rive/animation/nested_trigger.hpp"
#include "rive/animation/state_machine.hpp"
#include "rive/animation/state_machine_bool.hpp"
#include "rive/animation/state_machine_component.hpp"
+#include "rive/animation/state_machine_event.hpp"
#include "rive/animation/state_machine_input.hpp"
#include "rive/animation/state_machine_layer.hpp"
#include "rive/animation/state_machine_layer_component.hpp"
-#include "rive/animation/state_machine_listener.hpp"
#include "rive/animation/state_machine_number.hpp"
#include "rive/animation/state_machine_trigger.hpp"
#include "rive/animation/state_transition.hpp"
#include "rive/transform_component.hpp"
#include "rive/world_transform_component.hpp"
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();
+ 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 EventNumberChangeBase::typeKey:
+ return new EventNumberChange();
+ case NestedSimpleAnimationBase::typeKey:
+ return new NestedSimpleAnimation();
+ case AnimationStateBase::typeKey:
+ return new AnimationState();
+ case StateMachineEventBase::typeKey:
+ return new StateMachineEvent();
+ 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 KeyFrameIdBase::typeKey:
+ return new KeyFrameId();
+ case KeyFrameBoolBase::typeKey:
+ return new KeyFrameBool();
+ case TransitionNumberConditionBase::typeKey:
+ return new TransitionNumberCondition();
+ case EventBoolChangeBase::typeKey:
+ return new EventBoolChange();
+ case AnyStateBase::typeKey:
+ return new AnyState();
+ case EventTriggerChangeBase::typeKey:
+ return new EventTriggerChange();
+ case StateMachineLayerBase::typeKey:
+ return new StateMachineLayer();
+ case AnimationBase::typeKey:
+ return new Animation();
+ case CubicInterpolatorBase::typeKey:
+ return new CubicInterpolator();
+ case StateTransitionBase::typeKey:
+ return new StateTransition();
+ 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 BlendStateDirectBase::typeKey:
+ return new BlendStateDirect();
+ case NestedStateMachineBase::typeKey:
+ return new NestedStateMachine();
+ case ExitStateBase::typeKey:
+ return new ExitState();
+ 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;
}
- return nullptr;
- }
- 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;
+ 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;
+ }
}
- }
- static void setUint(Core* object, int propertyKey, uint32_t value) {
- switch (propertyKey) {
- case ComponentBase::parentIdPropertyKey:
- object->as<ComponentBase>()->parentId(value);
- break;
- case DrawTargetBase::drawableIdPropertyKey:
- object->as<DrawTargetBase>()->drawableId(value);
- break;
- case DrawTargetBase::placementValuePropertyKey:
- object->as<DrawTargetBase>()->placementValue(value);
- break;
- case TargetedConstraintBase::targetIdPropertyKey:
- object->as<TargetedConstraintBase>()->targetId(value);
- break;
- case DistanceConstraintBase::modeValuePropertyKey:
- object->as<DistanceConstraintBase>()->modeValue(value);
- break;
- case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
- object->as<TransformSpaceConstraintBase>()->sourceSpaceValue(value);
- break;
- case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
- object->as<TransformSpaceConstraintBase>()->destSpaceValue(value);
- break;
- case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
- object->as<TransformComponentConstraintBase>()->minMaxSpaceValue(value);
- break;
- case IKConstraintBase::parentBoneCountPropertyKey:
- object->as<IKConstraintBase>()->parentBoneCount(value);
- break;
- case DrawableBase::blendModeValuePropertyKey:
- object->as<DrawableBase>()->blendModeValue(value);
- break;
- case DrawableBase::drawableFlagsPropertyKey:
- object->as<DrawableBase>()->drawableFlags(value);
- break;
- case NestedArtboardBase::artboardIdPropertyKey:
- object->as<NestedArtboardBase>()->artboardId(value);
- break;
- case NestedAnimationBase::animationIdPropertyKey:
- object->as<NestedAnimationBase>()->animationId(value);
- break;
- case ListenerInputChangeBase::inputIdPropertyKey:
- object->as<ListenerInputChangeBase>()->inputId(value);
- break;
- case AnimationStateBase::animationIdPropertyKey:
- object->as<AnimationStateBase>()->animationId(value);
- break;
- case NestedInputBase::inputIdPropertyKey:
- object->as<NestedInputBase>()->inputId(value);
- break;
- case KeyedObjectBase::objectIdPropertyKey:
- object->as<KeyedObjectBase>()->objectId(value);
- break;
- case BlendAnimationBase::animationIdPropertyKey:
- object->as<BlendAnimationBase>()->animationId(value);
- break;
- case BlendAnimationDirectBase::inputIdPropertyKey:
- object->as<BlendAnimationDirectBase>()->inputId(value);
- break;
- case TransitionConditionBase::inputIdPropertyKey:
- object->as<TransitionConditionBase>()->inputId(value);
- break;
- case KeyedPropertyBase::propertyKeyPropertyKey:
- object->as<KeyedPropertyBase>()->propertyKey(value);
- break;
- case StateMachineListenerBase::targetIdPropertyKey:
- object->as<StateMachineListenerBase>()->targetId(value);
- break;
- case StateMachineListenerBase::listenerTypeValuePropertyKey:
- object->as<StateMachineListenerBase>()->listenerTypeValue(value);
- break;
- case KeyFrameBase::framePropertyKey: object->as<KeyFrameBase>()->frame(value); break;
- case KeyFrameBase::interpolationTypePropertyKey:
- object->as<KeyFrameBase>()->interpolationType(value);
- break;
- case KeyFrameBase::interpolatorIdPropertyKey:
- object->as<KeyFrameBase>()->interpolatorId(value);
- break;
- case KeyFrameIdBase::valuePropertyKey:
- object->as<KeyFrameIdBase>()->value(value);
- break;
- case ListenerBoolChangeBase::valuePropertyKey:
- object->as<ListenerBoolChangeBase>()->value(value);
- break;
- case ListenerAlignTargetBase::targetIdPropertyKey:
- object->as<ListenerAlignTargetBase>()->targetId(value);
- break;
- case TransitionValueConditionBase::opValuePropertyKey:
- object->as<TransitionValueConditionBase>()->opValue(value);
- break;
- case StateTransitionBase::stateToIdPropertyKey:
- object->as<StateTransitionBase>()->stateToId(value);
- break;
- case StateTransitionBase::flagsPropertyKey:
- object->as<StateTransitionBase>()->flags(value);
- break;
- case StateTransitionBase::durationPropertyKey:
- object->as<StateTransitionBase>()->duration(value);
- break;
- case StateTransitionBase::exitTimePropertyKey:
- object->as<StateTransitionBase>()->exitTime(value);
- break;
- case LinearAnimationBase::fpsPropertyKey:
- object->as<LinearAnimationBase>()->fps(value);
- break;
- case LinearAnimationBase::durationPropertyKey:
- object->as<LinearAnimationBase>()->duration(value);
- break;
- case LinearAnimationBase::loopValuePropertyKey:
- object->as<LinearAnimationBase>()->loopValue(value);
- break;
- case LinearAnimationBase::workStartPropertyKey:
- object->as<LinearAnimationBase>()->workStart(value);
- break;
- case LinearAnimationBase::workEndPropertyKey:
- object->as<LinearAnimationBase>()->workEnd(value);
- break;
- case BlendState1DBase::inputIdPropertyKey:
- object->as<BlendState1DBase>()->inputId(value);
- break;
- 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 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 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 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 CubicWeightBase::inValuesPropertyKey:
- object->as<CubicWeightBase>()->inValues(value);
- break;
- case CubicWeightBase::inIndicesPropertyKey:
- object->as<CubicWeightBase>()->inIndices(value);
- break;
- case CubicWeightBase::outValuesPropertyKey:
- object->as<CubicWeightBase>()->outValues(value);
- break;
- case CubicWeightBase::outIndicesPropertyKey:
- object->as<CubicWeightBase>()->outIndices(value);
- break;
- case FileAssetBase::assetIdPropertyKey:
- object->as<FileAssetBase>()->assetId(value);
- break;
+ static void setUint(Core* object, int propertyKey, uint32_t value) {
+ switch (propertyKey) {
+ case ComponentBase::parentIdPropertyKey:
+ object->as<ComponentBase>()->parentId(value);
+ break;
+ case DrawTargetBase::drawableIdPropertyKey:
+ object->as<DrawTargetBase>()->drawableId(value);
+ break;
+ case DrawTargetBase::placementValuePropertyKey:
+ object->as<DrawTargetBase>()->placementValue(value);
+ break;
+ case TargetedConstraintBase::targetIdPropertyKey:
+ object->as<TargetedConstraintBase>()->targetId(value);
+ break;
+ case DistanceConstraintBase::modeValuePropertyKey:
+ object->as<DistanceConstraintBase>()->modeValue(value);
+ break;
+ case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
+ object->as<TransformSpaceConstraintBase>()->sourceSpaceValue(value);
+ break;
+ case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
+ object->as<TransformSpaceConstraintBase>()->destSpaceValue(value);
+ break;
+ case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
+ object->as<TransformComponentConstraintBase>()->minMaxSpaceValue(value);
+ break;
+ case IKConstraintBase::parentBoneCountPropertyKey:
+ object->as<IKConstraintBase>()->parentBoneCount(value);
+ break;
+ case DrawableBase::blendModeValuePropertyKey:
+ object->as<DrawableBase>()->blendModeValue(value);
+ break;
+ case DrawableBase::drawableFlagsPropertyKey:
+ object->as<DrawableBase>()->drawableFlags(value);
+ break;
+ case NestedArtboardBase::artboardIdPropertyKey:
+ object->as<NestedArtboardBase>()->artboardId(value);
+ break;
+ case NestedAnimationBase::animationIdPropertyKey:
+ object->as<NestedAnimationBase>()->animationId(value);
+ break;
+ case EventInputChangeBase::inputIdPropertyKey:
+ object->as<EventInputChangeBase>()->inputId(value);
+ break;
+ case AnimationStateBase::animationIdPropertyKey:
+ object->as<AnimationStateBase>()->animationId(value);
+ break;
+ case StateMachineEventBase::targetIdPropertyKey:
+ object->as<StateMachineEventBase>()->targetId(value);
+ break;
+ case StateMachineEventBase::eventTypeValuePropertyKey:
+ object->as<StateMachineEventBase>()->eventTypeValue(value);
+ break;
+ case KeyedObjectBase::objectIdPropertyKey:
+ object->as<KeyedObjectBase>()->objectId(value);
+ break;
+ case BlendAnimationBase::animationIdPropertyKey:
+ object->as<BlendAnimationBase>()->animationId(value);
+ break;
+ case BlendAnimationDirectBase::inputIdPropertyKey:
+ object->as<BlendAnimationDirectBase>()->inputId(value);
+ break;
+ case TransitionConditionBase::inputIdPropertyKey:
+ object->as<TransitionConditionBase>()->inputId(value);
+ break;
+ case KeyedPropertyBase::propertyKeyPropertyKey:
+ object->as<KeyedPropertyBase>()->propertyKey(value);
+ break;
+ case KeyFrameBase::framePropertyKey:
+ object->as<KeyFrameBase>()->frame(value);
+ break;
+ case KeyFrameBase::interpolationTypePropertyKey:
+ object->as<KeyFrameBase>()->interpolationType(value);
+ break;
+ case KeyFrameBase::interpolatorIdPropertyKey:
+ object->as<KeyFrameBase>()->interpolatorId(value);
+ break;
+ case KeyFrameIdBase::valuePropertyKey:
+ object->as<KeyFrameIdBase>()->value(value);
+ break;
+ case TransitionValueConditionBase::opValuePropertyKey:
+ object->as<TransitionValueConditionBase>()->opValue(value);
+ break;
+ case EventBoolChangeBase::valuePropertyKey:
+ object->as<EventBoolChangeBase>()->value(value);
+ break;
+ case StateTransitionBase::stateToIdPropertyKey:
+ object->as<StateTransitionBase>()->stateToId(value);
+ break;
+ case StateTransitionBase::flagsPropertyKey:
+ object->as<StateTransitionBase>()->flags(value);
+ break;
+ case StateTransitionBase::durationPropertyKey:
+ object->as<StateTransitionBase>()->duration(value);
+ break;
+ case StateTransitionBase::exitTimePropertyKey:
+ object->as<StateTransitionBase>()->exitTime(value);
+ break;
+ case LinearAnimationBase::fpsPropertyKey:
+ object->as<LinearAnimationBase>()->fps(value);
+ break;
+ case LinearAnimationBase::durationPropertyKey:
+ object->as<LinearAnimationBase>()->duration(value);
+ break;
+ case LinearAnimationBase::loopValuePropertyKey:
+ object->as<LinearAnimationBase>()->loopValue(value);
+ break;
+ case LinearAnimationBase::workStartPropertyKey:
+ object->as<LinearAnimationBase>()->workStart(value);
+ break;
+ case LinearAnimationBase::workEndPropertyKey:
+ object->as<LinearAnimationBase>()->workEnd(value);
+ break;
+ case BlendState1DBase::inputIdPropertyKey:
+ object->as<BlendState1DBase>()->inputId(value);
+ break;
+ 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 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 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 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 CubicWeightBase::inValuesPropertyKey:
+ object->as<CubicWeightBase>()->inValues(value);
+ break;
+ case CubicWeightBase::inIndicesPropertyKey:
+ object->as<CubicWeightBase>()->inIndices(value);
+ break;
+ case CubicWeightBase::outValuesPropertyKey:
+ object->as<CubicWeightBase>()->outValues(value);
+ break;
+ case CubicWeightBase::outIndicesPropertyKey:
+ object->as<CubicWeightBase>()->outIndices(value);
+ break;
+ case FileAssetBase::assetIdPropertyKey:
+ object->as<FileAssetBase>()->assetId(value);
+ break;
+ }
}
- }
- static void setDouble(Core* object, int propertyKey, float value) {
- switch (propertyKey) {
- case ConstraintBase::strengthPropertyKey:
- object->as<ConstraintBase>()->strength(value);
- break;
- case DistanceConstraintBase::distancePropertyKey:
- object->as<DistanceConstraintBase>()->distance(value);
- break;
- case TransformComponentConstraintBase::copyFactorPropertyKey:
- object->as<TransformComponentConstraintBase>()->copyFactor(value);
- break;
- case TransformComponentConstraintBase::minValuePropertyKey:
- object->as<TransformComponentConstraintBase>()->minValue(value);
- break;
- case TransformComponentConstraintBase::maxValuePropertyKey:
- object->as<TransformComponentConstraintBase>()->maxValue(value);
- break;
- case TransformComponentConstraintYBase::copyFactorYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->copyFactorY(value);
- break;
- case TransformComponentConstraintYBase::minValueYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->minValueY(value);
- break;
- case TransformComponentConstraintYBase::maxValueYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->maxValueY(value);
- break;
- case WorldTransformComponentBase::opacityPropertyKey:
- object->as<WorldTransformComponentBase>()->opacity(value);
- break;
- case TransformComponentBase::rotationPropertyKey:
- object->as<TransformComponentBase>()->rotation(value);
- break;
- case TransformComponentBase::scaleXPropertyKey:
- object->as<TransformComponentBase>()->scaleX(value);
- break;
- 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 NestedLinearAnimationBase::mixPropertyKey:
- object->as<NestedLinearAnimationBase>()->mix(value);
- break;
- case NestedSimpleAnimationBase::speedPropertyKey:
- object->as<NestedSimpleAnimationBase>()->speed(value);
- break;
- case StateMachineNumberBase::valuePropertyKey:
- object->as<StateMachineNumberBase>()->value(value);
- break;
- case TransitionNumberConditionBase::valuePropertyKey:
- object->as<TransitionNumberConditionBase>()->value(value);
- break;
- case ListenerNumberChangeBase::valuePropertyKey:
- object->as<ListenerNumberChangeBase>()->value(value);
- break;
- case CubicInterpolatorBase::x1PropertyKey:
- object->as<CubicInterpolatorBase>()->x1(value);
- break;
- case CubicInterpolatorBase::y1PropertyKey:
- object->as<CubicInterpolatorBase>()->y1(value);
- break;
- case CubicInterpolatorBase::x2PropertyKey:
- object->as<CubicInterpolatorBase>()->x2(value);
- break;
- case CubicInterpolatorBase::y2PropertyKey:
- object->as<CubicInterpolatorBase>()->y2(value);
- break;
- case KeyFrameDoubleBase::valuePropertyKey:
- object->as<KeyFrameDoubleBase>()->value(value);
- break;
- case LinearAnimationBase::speedPropertyKey:
- object->as<LinearAnimationBase>()->speed(value);
- break;
- case NestedNumberBase::nestedValuePropertyKey:
- object->as<NestedNumberBase>()->nestedValue(value);
- break;
- case NestedRemapAnimationBase::timePropertyKey:
- object->as<NestedRemapAnimationBase>()->time(value);
- break;
- case BlendAnimation1DBase::valuePropertyKey:
- object->as<BlendAnimation1DBase>()->value(value);
- break;
- case LinearGradientBase::startXPropertyKey:
- object->as<LinearGradientBase>()->startX(value);
- break;
- case LinearGradientBase::startYPropertyKey:
- object->as<LinearGradientBase>()->startY(value);
- break;
- case LinearGradientBase::endXPropertyKey:
- object->as<LinearGradientBase>()->endX(value);
- break;
- case LinearGradientBase::endYPropertyKey:
- object->as<LinearGradientBase>()->endY(value);
- break;
- case LinearGradientBase::opacityPropertyKey:
- object->as<LinearGradientBase>()->opacity(value);
- break;
- case StrokeBase::thicknessPropertyKey:
- object->as<StrokeBase>()->thickness(value);
- break;
- 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 StraightVertexBase::radiusPropertyKey:
- object->as<StraightVertexBase>()->radius(value);
- break;
- case CubicAsymmetricVertexBase::rotationPropertyKey:
- object->as<CubicAsymmetricVertexBase>()->rotation(value);
- break;
- case CubicAsymmetricVertexBase::inDistancePropertyKey:
- object->as<CubicAsymmetricVertexBase>()->inDistance(value);
- break;
- case CubicAsymmetricVertexBase::outDistancePropertyKey:
- object->as<CubicAsymmetricVertexBase>()->outDistance(value);
- break;
- case ParametricPathBase::widthPropertyKey:
- object->as<ParametricPathBase>()->width(value);
- break;
- case ParametricPathBase::heightPropertyKey:
- object->as<ParametricPathBase>()->height(value);
- break;
- case ParametricPathBase::originXPropertyKey:
- object->as<ParametricPathBase>()->originX(value);
- break;
- case ParametricPathBase::originYPropertyKey:
- object->as<ParametricPathBase>()->originY(value);
- break;
- case RectangleBase::cornerRadiusTLPropertyKey:
- object->as<RectangleBase>()->cornerRadiusTL(value);
- break;
- case RectangleBase::cornerRadiusTRPropertyKey:
- object->as<RectangleBase>()->cornerRadiusTR(value);
- break;
- case RectangleBase::cornerRadiusBLPropertyKey:
- object->as<RectangleBase>()->cornerRadiusBL(value);
- break;
- case RectangleBase::cornerRadiusBRPropertyKey:
- object->as<RectangleBase>()->cornerRadiusBR(value);
- break;
- case CubicMirroredVertexBase::rotationPropertyKey:
- object->as<CubicMirroredVertexBase>()->rotation(value);
- break;
- case CubicMirroredVertexBase::distancePropertyKey:
- object->as<CubicMirroredVertexBase>()->distance(value);
- break;
- case PolygonBase::cornerRadiusPropertyKey:
- object->as<PolygonBase>()->cornerRadius(value);
- break;
- case StarBase::innerRadiusPropertyKey:
- object->as<StarBase>()->innerRadius(value);
- break;
- case CubicDetachedVertexBase::inRotationPropertyKey:
- object->as<CubicDetachedVertexBase>()->inRotation(value);
- break;
- case CubicDetachedVertexBase::inDistancePropertyKey:
- object->as<CubicDetachedVertexBase>()->inDistance(value);
- break;
- case CubicDetachedVertexBase::outRotationPropertyKey:
- object->as<CubicDetachedVertexBase>()->outRotation(value);
- break;
- 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::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 DrawableAssetBase::heightPropertyKey:
- object->as<DrawableAssetBase>()->height(value);
- break;
- case DrawableAssetBase::widthPropertyKey:
- object->as<DrawableAssetBase>()->width(value);
- break;
+ static void setDouble(Core* object, int propertyKey, float value) {
+ switch (propertyKey) {
+ case ConstraintBase::strengthPropertyKey:
+ object->as<ConstraintBase>()->strength(value);
+ break;
+ case DistanceConstraintBase::distancePropertyKey:
+ object->as<DistanceConstraintBase>()->distance(value);
+ break;
+ case TransformComponentConstraintBase::copyFactorPropertyKey:
+ object->as<TransformComponentConstraintBase>()->copyFactor(value);
+ break;
+ case TransformComponentConstraintBase::minValuePropertyKey:
+ object->as<TransformComponentConstraintBase>()->minValue(value);
+ break;
+ case TransformComponentConstraintBase::maxValuePropertyKey:
+ object->as<TransformComponentConstraintBase>()->maxValue(value);
+ break;
+ case TransformComponentConstraintYBase::copyFactorYPropertyKey:
+ object->as<TransformComponentConstraintYBase>()->copyFactorY(value);
+ break;
+ case TransformComponentConstraintYBase::minValueYPropertyKey:
+ object->as<TransformComponentConstraintYBase>()->minValueY(value);
+ break;
+ case TransformComponentConstraintYBase::maxValueYPropertyKey:
+ object->as<TransformComponentConstraintYBase>()->maxValueY(value);
+ break;
+ case WorldTransformComponentBase::opacityPropertyKey:
+ object->as<WorldTransformComponentBase>()->opacity(value);
+ break;
+ case TransformComponentBase::rotationPropertyKey:
+ object->as<TransformComponentBase>()->rotation(value);
+ break;
+ case TransformComponentBase::scaleXPropertyKey:
+ object->as<TransformComponentBase>()->scaleX(value);
+ break;
+ 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 EventNumberChangeBase::valuePropertyKey:
+ object->as<EventNumberChangeBase>()->value(value);
+ break;
+ case NestedLinearAnimationBase::mixPropertyKey:
+ object->as<NestedLinearAnimationBase>()->mix(value);
+ break;
+ case NestedSimpleAnimationBase::speedPropertyKey:
+ object->as<NestedSimpleAnimationBase>()->speed(value);
+ break;
+ case StateMachineNumberBase::valuePropertyKey:
+ object->as<StateMachineNumberBase>()->value(value);
+ break;
+ case TransitionNumberConditionBase::valuePropertyKey:
+ object->as<TransitionNumberConditionBase>()->value(value);
+ break;
+ case CubicInterpolatorBase::x1PropertyKey:
+ object->as<CubicInterpolatorBase>()->x1(value);
+ break;
+ case CubicInterpolatorBase::y1PropertyKey:
+ object->as<CubicInterpolatorBase>()->y1(value);
+ break;
+ case CubicInterpolatorBase::x2PropertyKey:
+ object->as<CubicInterpolatorBase>()->x2(value);
+ break;
+ case CubicInterpolatorBase::y2PropertyKey:
+ object->as<CubicInterpolatorBase>()->y2(value);
+ break;
+ case KeyFrameDoubleBase::valuePropertyKey:
+ object->as<KeyFrameDoubleBase>()->value(value);
+ break;
+ case LinearAnimationBase::speedPropertyKey:
+ object->as<LinearAnimationBase>()->speed(value);
+ break;
+ case NestedRemapAnimationBase::timePropertyKey:
+ object->as<NestedRemapAnimationBase>()->time(value);
+ break;
+ case BlendAnimation1DBase::valuePropertyKey:
+ object->as<BlendAnimation1DBase>()->value(value);
+ break;
+ case LinearGradientBase::startXPropertyKey:
+ object->as<LinearGradientBase>()->startX(value);
+ break;
+ case LinearGradientBase::startYPropertyKey:
+ object->as<LinearGradientBase>()->startY(value);
+ break;
+ case LinearGradientBase::endXPropertyKey:
+ object->as<LinearGradientBase>()->endX(value);
+ break;
+ case LinearGradientBase::endYPropertyKey:
+ object->as<LinearGradientBase>()->endY(value);
+ break;
+ case LinearGradientBase::opacityPropertyKey:
+ object->as<LinearGradientBase>()->opacity(value);
+ break;
+ case StrokeBase::thicknessPropertyKey:
+ object->as<StrokeBase>()->thickness(value);
+ break;
+ 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 StraightVertexBase::radiusPropertyKey:
+ object->as<StraightVertexBase>()->radius(value);
+ break;
+ case CubicAsymmetricVertexBase::rotationPropertyKey:
+ object->as<CubicAsymmetricVertexBase>()->rotation(value);
+ break;
+ case CubicAsymmetricVertexBase::inDistancePropertyKey:
+ object->as<CubicAsymmetricVertexBase>()->inDistance(value);
+ break;
+ case CubicAsymmetricVertexBase::outDistancePropertyKey:
+ object->as<CubicAsymmetricVertexBase>()->outDistance(value);
+ break;
+ case ParametricPathBase::widthPropertyKey:
+ object->as<ParametricPathBase>()->width(value);
+ break;
+ case ParametricPathBase::heightPropertyKey:
+ object->as<ParametricPathBase>()->height(value);
+ break;
+ case ParametricPathBase::originXPropertyKey:
+ object->as<ParametricPathBase>()->originX(value);
+ break;
+ case ParametricPathBase::originYPropertyKey:
+ object->as<ParametricPathBase>()->originY(value);
+ break;
+ case RectangleBase::cornerRadiusTLPropertyKey:
+ object->as<RectangleBase>()->cornerRadiusTL(value);
+ break;
+ case RectangleBase::cornerRadiusTRPropertyKey:
+ object->as<RectangleBase>()->cornerRadiusTR(value);
+ break;
+ case RectangleBase::cornerRadiusBLPropertyKey:
+ object->as<RectangleBase>()->cornerRadiusBL(value);
+ break;
+ case RectangleBase::cornerRadiusBRPropertyKey:
+ object->as<RectangleBase>()->cornerRadiusBR(value);
+ break;
+ case CubicMirroredVertexBase::rotationPropertyKey:
+ object->as<CubicMirroredVertexBase>()->rotation(value);
+ break;
+ case CubicMirroredVertexBase::distancePropertyKey:
+ object->as<CubicMirroredVertexBase>()->distance(value);
+ break;
+ case PolygonBase::cornerRadiusPropertyKey:
+ object->as<PolygonBase>()->cornerRadius(value);
+ break;
+ case StarBase::innerRadiusPropertyKey:
+ object->as<StarBase>()->innerRadius(value);
+ break;
+ case CubicDetachedVertexBase::inRotationPropertyKey:
+ object->as<CubicDetachedVertexBase>()->inRotation(value);
+ break;
+ case CubicDetachedVertexBase::inDistancePropertyKey:
+ object->as<CubicDetachedVertexBase>()->inDistance(value);
+ break;
+ case CubicDetachedVertexBase::outRotationPropertyKey:
+ object->as<CubicDetachedVertexBase>()->outRotation(value);
+ break;
+ 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::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 DrawableAssetBase::heightPropertyKey:
+ object->as<DrawableAssetBase>()->height(value);
+ break;
+ case DrawableAssetBase::widthPropertyKey:
+ object->as<DrawableAssetBase>()->width(value);
+ break;
+ }
}
- }
- static void setBool(Core* object, int propertyKey, bool value) {
- switch (propertyKey) {
- case TransformComponentConstraintBase::offsetPropertyKey:
- object->as<TransformComponentConstraintBase>()->offset(value);
- break;
- case TransformComponentConstraintBase::doesCopyPropertyKey:
- object->as<TransformComponentConstraintBase>()->doesCopy(value);
- break;
- case TransformComponentConstraintBase::minPropertyKey:
- object->as<TransformComponentConstraintBase>()->min(value);
- break;
- case TransformComponentConstraintBase::maxPropertyKey:
- object->as<TransformComponentConstraintBase>()->max(value);
- break;
- case TransformComponentConstraintYBase::doesCopyYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->doesCopyY(value);
- break;
- case TransformComponentConstraintYBase::minYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->minY(value);
- break;
- case TransformComponentConstraintYBase::maxYPropertyKey:
- object->as<TransformComponentConstraintYBase>()->maxY(value);
- break;
- case IKConstraintBase::invertDirectionPropertyKey:
- object->as<IKConstraintBase>()->invertDirection(value);
- break;
- case NestedSimpleAnimationBase::isPlayingPropertyKey:
- object->as<NestedSimpleAnimationBase>()->isPlaying(value);
- break;
- case KeyFrameBoolBase::valuePropertyKey:
- object->as<KeyFrameBoolBase>()->value(value);
- break;
- case NestedBoolBase::nestedValuePropertyKey:
- object->as<NestedBoolBase>()->nestedValue(value);
- break;
- case LinearAnimationBase::enableWorkAreaPropertyKey:
- object->as<LinearAnimationBase>()->enableWorkArea(value);
- break;
- case StateMachineBoolBase::valuePropertyKey:
- object->as<StateMachineBoolBase>()->value(value);
- break;
- case ShapePaintBase::isVisiblePropertyKey:
- object->as<ShapePaintBase>()->isVisible(value);
- break;
- case StrokeBase::transformAffectsStrokePropertyKey:
- object->as<StrokeBase>()->transformAffectsStroke(value);
- break;
- case PointsPathBase::isClosedPropertyKey:
- object->as<PointsPathBase>()->isClosed(value);
- break;
- case RectangleBase::linkCornerRadiusPropertyKey:
- object->as<RectangleBase>()->linkCornerRadius(value);
- break;
- case ClippingShapeBase::isVisiblePropertyKey:
- object->as<ClippingShapeBase>()->isVisible(value);
- break;
- case ArtboardBase::clipPropertyKey: object->as<ArtboardBase>()->clip(value); break;
+ static void setBool(Core* object, int propertyKey, bool value) {
+ switch (propertyKey) {
+ case TransformComponentConstraintBase::offsetPropertyKey:
+ object->as<TransformComponentConstraintBase>()->offset(value);
+ break;
+ case TransformComponentConstraintBase::doesCopyPropertyKey:
+ object->as<TransformComponentConstraintBase>()->doesCopy(value);
+ break;
+ case TransformComponentConstraintBase::minPropertyKey:
+ object->as<TransformComponentConstraintBase>()->min(value);
+ break;
+ case TransformComponentConstraintBase::maxPropertyKey:
+ object->as<TransformComponentConstraintBase>()->max(value);
+ break;
+ case TransformComponentConstraintYBase::doesCopyYPropertyKey:
+ object->as<TransformComponentConstraintYBase>()->doesCopyY(value);
+ break;
+ case TransformComponentConstraintYBase::minYPropertyKey:
+ object->as<TransformComponentConstraintYBase>()->minY(value);
+ break;
+ case TransformComponentConstraintYBase::maxYPropertyKey:
+ object->as<TransformComponentConstraintYBase>()->maxY(value);
+ break;
+ case IKConstraintBase::invertDirectionPropertyKey:
+ object->as<IKConstraintBase>()->invertDirection(value);
+ break;
+ case NestedSimpleAnimationBase::isPlayingPropertyKey:
+ object->as<NestedSimpleAnimationBase>()->isPlaying(value);
+ break;
+ case KeyFrameBoolBase::valuePropertyKey:
+ object->as<KeyFrameBoolBase>()->value(value);
+ break;
+ case LinearAnimationBase::enableWorkAreaPropertyKey:
+ object->as<LinearAnimationBase>()->enableWorkArea(value);
+ break;
+ case StateMachineBoolBase::valuePropertyKey:
+ object->as<StateMachineBoolBase>()->value(value);
+ break;
+ case ShapePaintBase::isVisiblePropertyKey:
+ object->as<ShapePaintBase>()->isVisible(value);
+ break;
+ case StrokeBase::transformAffectsStrokePropertyKey:
+ object->as<StrokeBase>()->transformAffectsStroke(value);
+ break;
+ case PointsPathBase::isClosedPropertyKey:
+ object->as<PointsPathBase>()->isClosed(value);
+ break;
+ case RectangleBase::linkCornerRadiusPropertyKey:
+ object->as<RectangleBase>()->linkCornerRadius(value);
+ break;
+ case ClippingShapeBase::isVisiblePropertyKey:
+ object->as<ClippingShapeBase>()->isVisible(value);
+ break;
+ case ArtboardBase::clipPropertyKey:
+ object->as<ArtboardBase>()->clip(value);
+ break;
+ }
}
- }
- static void setColor(Core* object, int propertyKey, int value) {
- switch (propertyKey) {
- case KeyFrameColorBase::valuePropertyKey:
- object->as<KeyFrameColorBase>()->value(value);
- break;
- case SolidColorBase::colorValuePropertyKey:
- object->as<SolidColorBase>()->colorValue(value);
- break;
- case GradientStopBase::colorValuePropertyKey:
- object->as<GradientStopBase>()->colorValue(value);
- break;
+ static void setColor(Core* object, int propertyKey, int value) {
+ switch (propertyKey) {
+ case KeyFrameColorBase::valuePropertyKey:
+ object->as<KeyFrameColorBase>()->value(value);
+ break;
+ case SolidColorBase::colorValuePropertyKey:
+ object->as<SolidColorBase>()->colorValue(value);
+ break;
+ case GradientStopBase::colorValuePropertyKey:
+ object->as<GradientStopBase>()->colorValue(value);
+ break;
+ }
}
- }
- 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();
+ 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();
+ }
+ return "";
}
- return "";
- }
- 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:
- return object->as<DrawTargetBase>()->placementValue();
- case TargetedConstraintBase::targetIdPropertyKey:
- return object->as<TargetedConstraintBase>()->targetId();
- case DistanceConstraintBase::modeValuePropertyKey:
- return object->as<DistanceConstraintBase>()->modeValue();
- case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
- return object->as<TransformSpaceConstraintBase>()->sourceSpaceValue();
- case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
- return object->as<TransformSpaceConstraintBase>()->destSpaceValue();
- case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
- return object->as<TransformComponentConstraintBase>()->minMaxSpaceValue();
- case IKConstraintBase::parentBoneCountPropertyKey:
- return object->as<IKConstraintBase>()->parentBoneCount();
- case DrawableBase::blendModeValuePropertyKey:
- return object->as<DrawableBase>()->blendModeValue();
- case DrawableBase::drawableFlagsPropertyKey:
- return object->as<DrawableBase>()->drawableFlags();
- case NestedArtboardBase::artboardIdPropertyKey:
- return object->as<NestedArtboardBase>()->artboardId();
- case NestedAnimationBase::animationIdPropertyKey:
- return object->as<NestedAnimationBase>()->animationId();
- case ListenerInputChangeBase::inputIdPropertyKey:
- return object->as<ListenerInputChangeBase>()->inputId();
- case AnimationStateBase::animationIdPropertyKey:
- return object->as<AnimationStateBase>()->animationId();
- case NestedInputBase::inputIdPropertyKey:
- return object->as<NestedInputBase>()->inputId();
- case KeyedObjectBase::objectIdPropertyKey:
- return object->as<KeyedObjectBase>()->objectId();
- case BlendAnimationBase::animationIdPropertyKey:
- return object->as<BlendAnimationBase>()->animationId();
- case BlendAnimationDirectBase::inputIdPropertyKey:
- return object->as<BlendAnimationDirectBase>()->inputId();
- case TransitionConditionBase::inputIdPropertyKey:
- return object->as<TransitionConditionBase>()->inputId();
- case KeyedPropertyBase::propertyKeyPropertyKey:
- return object->as<KeyedPropertyBase>()->propertyKey();
- case StateMachineListenerBase::targetIdPropertyKey:
- return object->as<StateMachineListenerBase>()->targetId();
- case StateMachineListenerBase::listenerTypeValuePropertyKey:
- return object->as<StateMachineListenerBase>()->listenerTypeValue();
- 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 ListenerBoolChangeBase::valuePropertyKey:
- return object->as<ListenerBoolChangeBase>()->value();
- case ListenerAlignTargetBase::targetIdPropertyKey:
- return object->as<ListenerAlignTargetBase>()->targetId();
- case TransitionValueConditionBase::opValuePropertyKey:
- return object->as<TransitionValueConditionBase>()->opValue();
- case StateTransitionBase::stateToIdPropertyKey:
- return object->as<StateTransitionBase>()->stateToId();
- case StateTransitionBase::flagsPropertyKey:
- return object->as<StateTransitionBase>()->flags();
- case StateTransitionBase::durationPropertyKey:
- return object->as<StateTransitionBase>()->duration();
- case StateTransitionBase::exitTimePropertyKey:
- return object->as<StateTransitionBase>()->exitTime();
- case LinearAnimationBase::fpsPropertyKey:
- return object->as<LinearAnimationBase>()->fps();
- case LinearAnimationBase::durationPropertyKey:
- return object->as<LinearAnimationBase>()->duration();
- case LinearAnimationBase::loopValuePropertyKey:
- return object->as<LinearAnimationBase>()->loopValue();
- case LinearAnimationBase::workStartPropertyKey:
- return object->as<LinearAnimationBase>()->workStart();
- case LinearAnimationBase::workEndPropertyKey:
- return object->as<LinearAnimationBase>()->workEnd();
- case BlendState1DBase::inputIdPropertyKey:
- 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 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 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 CubicWeightBase::inValuesPropertyKey:
- return object->as<CubicWeightBase>()->inValues();
- case CubicWeightBase::inIndicesPropertyKey:
- return object->as<CubicWeightBase>()->inIndices();
- case CubicWeightBase::outValuesPropertyKey:
- return object->as<CubicWeightBase>()->outValues();
- case CubicWeightBase::outIndicesPropertyKey:
- return object->as<CubicWeightBase>()->outIndices();
- case FileAssetBase::assetIdPropertyKey: return object->as<FileAssetBase>()->assetId();
+ 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:
+ return object->as<DrawTargetBase>()->placementValue();
+ case TargetedConstraintBase::targetIdPropertyKey:
+ return object->as<TargetedConstraintBase>()->targetId();
+ case DistanceConstraintBase::modeValuePropertyKey:
+ return object->as<DistanceConstraintBase>()->modeValue();
+ case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
+ return object->as<TransformSpaceConstraintBase>()->sourceSpaceValue();
+ case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
+ return object->as<TransformSpaceConstraintBase>()->destSpaceValue();
+ case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
+ return object->as<TransformComponentConstraintBase>()->minMaxSpaceValue();
+ case IKConstraintBase::parentBoneCountPropertyKey:
+ return object->as<IKConstraintBase>()->parentBoneCount();
+ case DrawableBase::blendModeValuePropertyKey:
+ return object->as<DrawableBase>()->blendModeValue();
+ case DrawableBase::drawableFlagsPropertyKey:
+ return object->as<DrawableBase>()->drawableFlags();
+ case NestedArtboardBase::artboardIdPropertyKey:
+ return object->as<NestedArtboardBase>()->artboardId();
+ case NestedAnimationBase::animationIdPropertyKey:
+ return object->as<NestedAnimationBase>()->animationId();
+ case EventInputChangeBase::inputIdPropertyKey:
+ return object->as<EventInputChangeBase>()->inputId();
+ case AnimationStateBase::animationIdPropertyKey:
+ return object->as<AnimationStateBase>()->animationId();
+ case StateMachineEventBase::targetIdPropertyKey:
+ return object->as<StateMachineEventBase>()->targetId();
+ case StateMachineEventBase::eventTypeValuePropertyKey:
+ return object->as<StateMachineEventBase>()->eventTypeValue();
+ case KeyedObjectBase::objectIdPropertyKey:
+ return object->as<KeyedObjectBase>()->objectId();
+ case BlendAnimationBase::animationIdPropertyKey:
+ return object->as<BlendAnimationBase>()->animationId();
+ case BlendAnimationDirectBase::inputIdPropertyKey:
+ return object->as<BlendAnimationDirectBase>()->inputId();
+ case TransitionConditionBase::inputIdPropertyKey:
+ return object->as<TransitionConditionBase>()->inputId();
+ case KeyedPropertyBase::propertyKeyPropertyKey:
+ return object->as<KeyedPropertyBase>()->propertyKey();
+ 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 TransitionValueConditionBase::opValuePropertyKey:
+ return object->as<TransitionValueConditionBase>()->opValue();
+ case EventBoolChangeBase::valuePropertyKey:
+ return object->as<EventBoolChangeBase>()->value();
+ case StateTransitionBase::stateToIdPropertyKey:
+ return object->as<StateTransitionBase>()->stateToId();
+ case StateTransitionBase::flagsPropertyKey:
+ return object->as<StateTransitionBase>()->flags();
+ case StateTransitionBase::durationPropertyKey:
+ return object->as<StateTransitionBase>()->duration();
+ case StateTransitionBase::exitTimePropertyKey:
+ return object->as<StateTransitionBase>()->exitTime();
+ case LinearAnimationBase::fpsPropertyKey:
+ return object->as<LinearAnimationBase>()->fps();
+ case LinearAnimationBase::durationPropertyKey:
+ return object->as<LinearAnimationBase>()->duration();
+ case LinearAnimationBase::loopValuePropertyKey:
+ return object->as<LinearAnimationBase>()->loopValue();
+ case LinearAnimationBase::workStartPropertyKey:
+ return object->as<LinearAnimationBase>()->workStart();
+ case LinearAnimationBase::workEndPropertyKey:
+ return object->as<LinearAnimationBase>()->workEnd();
+ case BlendState1DBase::inputIdPropertyKey:
+ 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 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 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 CubicWeightBase::inValuesPropertyKey:
+ return object->as<CubicWeightBase>()->inValues();
+ case CubicWeightBase::inIndicesPropertyKey:
+ return object->as<CubicWeightBase>()->inIndices();
+ case CubicWeightBase::outValuesPropertyKey:
+ return object->as<CubicWeightBase>()->outValues();
+ case CubicWeightBase::outIndicesPropertyKey:
+ return object->as<CubicWeightBase>()->outIndices();
+ case FileAssetBase::assetIdPropertyKey:
+ return object->as<FileAssetBase>()->assetId();
+ }
+ return 0;
}
- return 0;
- }
- static float getDouble(Core* object, int propertyKey) {
- switch (propertyKey) {
- case ConstraintBase::strengthPropertyKey:
- return object->as<ConstraintBase>()->strength();
- case DistanceConstraintBase::distancePropertyKey:
- return object->as<DistanceConstraintBase>()->distance();
- case TransformComponentConstraintBase::copyFactorPropertyKey:
- return object->as<TransformComponentConstraintBase>()->copyFactor();
- case TransformComponentConstraintBase::minValuePropertyKey:
- return object->as<TransformComponentConstraintBase>()->minValue();
- case TransformComponentConstraintBase::maxValuePropertyKey:
- return object->as<TransformComponentConstraintBase>()->maxValue();
- case TransformComponentConstraintYBase::copyFactorYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()->copyFactorY();
- case TransformComponentConstraintYBase::minValueYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()->minValueY();
- case TransformComponentConstraintYBase::maxValueYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()->maxValueY();
- case WorldTransformComponentBase::opacityPropertyKey:
- return object->as<WorldTransformComponentBase>()->opacity();
- case TransformComponentBase::rotationPropertyKey:
- return object->as<TransformComponentBase>()->rotation();
- case TransformComponentBase::scaleXPropertyKey:
- 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 NestedLinearAnimationBase::mixPropertyKey:
- return object->as<NestedLinearAnimationBase>()->mix();
- case NestedSimpleAnimationBase::speedPropertyKey:
- return object->as<NestedSimpleAnimationBase>()->speed();
- case StateMachineNumberBase::valuePropertyKey:
- return object->as<StateMachineNumberBase>()->value();
- case TransitionNumberConditionBase::valuePropertyKey:
- return object->as<TransitionNumberConditionBase>()->value();
- case ListenerNumberChangeBase::valuePropertyKey:
- return object->as<ListenerNumberChangeBase>()->value();
- case CubicInterpolatorBase::x1PropertyKey:
- return object->as<CubicInterpolatorBase>()->x1();
- case CubicInterpolatorBase::y1PropertyKey:
- return object->as<CubicInterpolatorBase>()->y1();
- case CubicInterpolatorBase::x2PropertyKey:
- return object->as<CubicInterpolatorBase>()->x2();
- case CubicInterpolatorBase::y2PropertyKey:
- return object->as<CubicInterpolatorBase>()->y2();
- case KeyFrameDoubleBase::valuePropertyKey:
- return object->as<KeyFrameDoubleBase>()->value();
- case LinearAnimationBase::speedPropertyKey:
- return object->as<LinearAnimationBase>()->speed();
- case NestedNumberBase::nestedValuePropertyKey:
- return object->as<NestedNumberBase>()->nestedValue();
- case NestedRemapAnimationBase::timePropertyKey:
- return object->as<NestedRemapAnimationBase>()->time();
- case BlendAnimation1DBase::valuePropertyKey:
- return object->as<BlendAnimation1DBase>()->value();
- case LinearGradientBase::startXPropertyKey:
- return object->as<LinearGradientBase>()->startX();
- case LinearGradientBase::startYPropertyKey:
- return object->as<LinearGradientBase>()->startY();
- case LinearGradientBase::endXPropertyKey:
- return object->as<LinearGradientBase>()->endX();
- case LinearGradientBase::endYPropertyKey:
- return object->as<LinearGradientBase>()->endY();
- case LinearGradientBase::opacityPropertyKey:
- return object->as<LinearGradientBase>()->opacity();
- 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 StraightVertexBase::radiusPropertyKey:
- return object->as<StraightVertexBase>()->radius();
- case CubicAsymmetricVertexBase::rotationPropertyKey:
- return object->as<CubicAsymmetricVertexBase>()->rotation();
- case CubicAsymmetricVertexBase::inDistancePropertyKey:
- return object->as<CubicAsymmetricVertexBase>()->inDistance();
- case CubicAsymmetricVertexBase::outDistancePropertyKey:
- return object->as<CubicAsymmetricVertexBase>()->outDistance();
- case ParametricPathBase::widthPropertyKey:
- return object->as<ParametricPathBase>()->width();
- case ParametricPathBase::heightPropertyKey:
- return object->as<ParametricPathBase>()->height();
- case ParametricPathBase::originXPropertyKey:
- return object->as<ParametricPathBase>()->originX();
- case ParametricPathBase::originYPropertyKey:
- return object->as<ParametricPathBase>()->originY();
- case RectangleBase::cornerRadiusTLPropertyKey:
- return object->as<RectangleBase>()->cornerRadiusTL();
- case RectangleBase::cornerRadiusTRPropertyKey:
- return object->as<RectangleBase>()->cornerRadiusTR();
- case RectangleBase::cornerRadiusBLPropertyKey:
- return object->as<RectangleBase>()->cornerRadiusBL();
- case RectangleBase::cornerRadiusBRPropertyKey:
- return object->as<RectangleBase>()->cornerRadiusBR();
- case CubicMirroredVertexBase::rotationPropertyKey:
- return object->as<CubicMirroredVertexBase>()->rotation();
- case CubicMirroredVertexBase::distancePropertyKey:
- return object->as<CubicMirroredVertexBase>()->distance();
- case PolygonBase::cornerRadiusPropertyKey:
- return object->as<PolygonBase>()->cornerRadius();
- case StarBase::innerRadiusPropertyKey: return object->as<StarBase>()->innerRadius();
- case CubicDetachedVertexBase::inRotationPropertyKey:
- return object->as<CubicDetachedVertexBase>()->inRotation();
- case CubicDetachedVertexBase::inDistancePropertyKey:
- return object->as<CubicDetachedVertexBase>()->inDistance();
- case CubicDetachedVertexBase::outRotationPropertyKey:
- 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 DrawableAssetBase::heightPropertyKey:
- return object->as<DrawableAssetBase>()->height();
- case DrawableAssetBase::widthPropertyKey:
- return object->as<DrawableAssetBase>()->width();
+ static float getDouble(Core* object, int propertyKey) {
+ switch (propertyKey) {
+ case ConstraintBase::strengthPropertyKey:
+ return object->as<ConstraintBase>()->strength();
+ case DistanceConstraintBase::distancePropertyKey:
+ return object->as<DistanceConstraintBase>()->distance();
+ case TransformComponentConstraintBase::copyFactorPropertyKey:
+ return object->as<TransformComponentConstraintBase>()->copyFactor();
+ case TransformComponentConstraintBase::minValuePropertyKey:
+ return object->as<TransformComponentConstraintBase>()->minValue();
+ case TransformComponentConstraintBase::maxValuePropertyKey:
+ return object->as<TransformComponentConstraintBase>()->maxValue();
+ case TransformComponentConstraintYBase::copyFactorYPropertyKey:
+ return object->as<TransformComponentConstraintYBase>()->copyFactorY();
+ case TransformComponentConstraintYBase::minValueYPropertyKey:
+ return object->as<TransformComponentConstraintYBase>()->minValueY();
+ case TransformComponentConstraintYBase::maxValueYPropertyKey:
+ return object->as<TransformComponentConstraintYBase>()->maxValueY();
+ case WorldTransformComponentBase::opacityPropertyKey:
+ return object->as<WorldTransformComponentBase>()->opacity();
+ case TransformComponentBase::rotationPropertyKey:
+ return object->as<TransformComponentBase>()->rotation();
+ case TransformComponentBase::scaleXPropertyKey:
+ 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 EventNumberChangeBase::valuePropertyKey:
+ return object->as<EventNumberChangeBase>()->value();
+ case NestedLinearAnimationBase::mixPropertyKey:
+ return object->as<NestedLinearAnimationBase>()->mix();
+ case NestedSimpleAnimationBase::speedPropertyKey:
+ return object->as<NestedSimpleAnimationBase>()->speed();
+ case StateMachineNumberBase::valuePropertyKey:
+ return object->as<StateMachineNumberBase>()->value();
+ case TransitionNumberConditionBase::valuePropertyKey:
+ return object->as<TransitionNumberConditionBase>()->value();
+ case CubicInterpolatorBase::x1PropertyKey:
+ return object->as<CubicInterpolatorBase>()->x1();
+ case CubicInterpolatorBase::y1PropertyKey:
+ return object->as<CubicInterpolatorBase>()->y1();
+ case CubicInterpolatorBase::x2PropertyKey:
+ return object->as<CubicInterpolatorBase>()->x2();
+ case CubicInterpolatorBase::y2PropertyKey:
+ return object->as<CubicInterpolatorBase>()->y2();
+ case KeyFrameDoubleBase::valuePropertyKey:
+ return object->as<KeyFrameDoubleBase>()->value();
+ case LinearAnimationBase::speedPropertyKey:
+ return object->as<LinearAnimationBase>()->speed();
+ case NestedRemapAnimationBase::timePropertyKey:
+ return object->as<NestedRemapAnimationBase>()->time();
+ case BlendAnimation1DBase::valuePropertyKey:
+ return object->as<BlendAnimation1DBase>()->value();
+ case LinearGradientBase::startXPropertyKey:
+ return object->as<LinearGradientBase>()->startX();
+ case LinearGradientBase::startYPropertyKey:
+ return object->as<LinearGradientBase>()->startY();
+ case LinearGradientBase::endXPropertyKey:
+ return object->as<LinearGradientBase>()->endX();
+ case LinearGradientBase::endYPropertyKey:
+ return object->as<LinearGradientBase>()->endY();
+ case LinearGradientBase::opacityPropertyKey:
+ return object->as<LinearGradientBase>()->opacity();
+ 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 StraightVertexBase::radiusPropertyKey:
+ return object->as<StraightVertexBase>()->radius();
+ case CubicAsymmetricVertexBase::rotationPropertyKey:
+ return object->as<CubicAsymmetricVertexBase>()->rotation();
+ case CubicAsymmetricVertexBase::inDistancePropertyKey:
+ return object->as<CubicAsymmetricVertexBase>()->inDistance();
+ case CubicAsymmetricVertexBase::outDistancePropertyKey:
+ return object->as<CubicAsymmetricVertexBase>()->outDistance();
+ case ParametricPathBase::widthPropertyKey:
+ return object->as<ParametricPathBase>()->width();
+ case ParametricPathBase::heightPropertyKey:
+ return object->as<ParametricPathBase>()->height();
+ case ParametricPathBase::originXPropertyKey:
+ return object->as<ParametricPathBase>()->originX();
+ case ParametricPathBase::originYPropertyKey:
+ return object->as<ParametricPathBase>()->originY();
+ case RectangleBase::cornerRadiusTLPropertyKey:
+ return object->as<RectangleBase>()->cornerRadiusTL();
+ case RectangleBase::cornerRadiusTRPropertyKey:
+ return object->as<RectangleBase>()->cornerRadiusTR();
+ case RectangleBase::cornerRadiusBLPropertyKey:
+ return object->as<RectangleBase>()->cornerRadiusBL();
+ case RectangleBase::cornerRadiusBRPropertyKey:
+ return object->as<RectangleBase>()->cornerRadiusBR();
+ case CubicMirroredVertexBase::rotationPropertyKey:
+ return object->as<CubicMirroredVertexBase>()->rotation();
+ case CubicMirroredVertexBase::distancePropertyKey:
+ return object->as<CubicMirroredVertexBase>()->distance();
+ case PolygonBase::cornerRadiusPropertyKey:
+ return object->as<PolygonBase>()->cornerRadius();
+ case StarBase::innerRadiusPropertyKey:
+ return object->as<StarBase>()->innerRadius();
+ case CubicDetachedVertexBase::inRotationPropertyKey:
+ return object->as<CubicDetachedVertexBase>()->inRotation();
+ case CubicDetachedVertexBase::inDistancePropertyKey:
+ return object->as<CubicDetachedVertexBase>()->inDistance();
+ case CubicDetachedVertexBase::outRotationPropertyKey:
+ 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 DrawableAssetBase::heightPropertyKey:
+ return object->as<DrawableAssetBase>()->height();
+ case DrawableAssetBase::widthPropertyKey:
+ return object->as<DrawableAssetBase>()->width();
+ }
+ return 0.0f;
}
- return 0.0f;
- }
- static bool getBool(Core* object, int propertyKey) {
- switch (propertyKey) {
- case TransformComponentConstraintBase::offsetPropertyKey:
- return object->as<TransformComponentConstraintBase>()->offset();
- case TransformComponentConstraintBase::doesCopyPropertyKey:
- return object->as<TransformComponentConstraintBase>()->doesCopy();
- case TransformComponentConstraintBase::minPropertyKey:
- return object->as<TransformComponentConstraintBase>()->min();
- case TransformComponentConstraintBase::maxPropertyKey:
- return object->as<TransformComponentConstraintBase>()->max();
- case TransformComponentConstraintYBase::doesCopyYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()->doesCopyY();
- case TransformComponentConstraintYBase::minYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()->minY();
- case TransformComponentConstraintYBase::maxYPropertyKey:
- return object->as<TransformComponentConstraintYBase>()->maxY();
- case IKConstraintBase::invertDirectionPropertyKey:
- return object->as<IKConstraintBase>()->invertDirection();
- case NestedSimpleAnimationBase::isPlayingPropertyKey:
- return object->as<NestedSimpleAnimationBase>()->isPlaying();
- case KeyFrameBoolBase::valuePropertyKey: return object->as<KeyFrameBoolBase>()->value();
- case NestedBoolBase::nestedValuePropertyKey:
- return object->as<NestedBoolBase>()->nestedValue();
- case LinearAnimationBase::enableWorkAreaPropertyKey:
- return object->as<LinearAnimationBase>()->enableWorkArea();
- case StateMachineBoolBase::valuePropertyKey:
- return object->as<StateMachineBoolBase>()->value();
- case ShapePaintBase::isVisiblePropertyKey:
- return object->as<ShapePaintBase>()->isVisible();
- case StrokeBase::transformAffectsStrokePropertyKey:
- return object->as<StrokeBase>()->transformAffectsStroke();
- case PointsPathBase::isClosedPropertyKey:
- return object->as<PointsPathBase>()->isClosed();
- case RectangleBase::linkCornerRadiusPropertyKey:
- return object->as<RectangleBase>()->linkCornerRadius();
- case ClippingShapeBase::isVisiblePropertyKey:
- return object->as<ClippingShapeBase>()->isVisible();
- case ArtboardBase::clipPropertyKey: return object->as<ArtboardBase>()->clip();
+ static bool getBool(Core* object, int propertyKey) {
+ switch (propertyKey) {
+ case TransformComponentConstraintBase::offsetPropertyKey:
+ return object->as<TransformComponentConstraintBase>()->offset();
+ case TransformComponentConstraintBase::doesCopyPropertyKey:
+ return object->as<TransformComponentConstraintBase>()->doesCopy();
+ case TransformComponentConstraintBase::minPropertyKey:
+ return object->as<TransformComponentConstraintBase>()->min();
+ case TransformComponentConstraintBase::maxPropertyKey:
+ return object->as<TransformComponentConstraintBase>()->max();
+ case TransformComponentConstraintYBase::doesCopyYPropertyKey:
+ return object->as<TransformComponentConstraintYBase>()->doesCopyY();
+ case TransformComponentConstraintYBase::minYPropertyKey:
+ return object->as<TransformComponentConstraintYBase>()->minY();
+ case TransformComponentConstraintYBase::maxYPropertyKey:
+ return object->as<TransformComponentConstraintYBase>()->maxY();
+ case IKConstraintBase::invertDirectionPropertyKey:
+ return object->as<IKConstraintBase>()->invertDirection();
+ case NestedSimpleAnimationBase::isPlayingPropertyKey:
+ return object->as<NestedSimpleAnimationBase>()->isPlaying();
+ case KeyFrameBoolBase::valuePropertyKey:
+ return object->as<KeyFrameBoolBase>()->value();
+ case LinearAnimationBase::enableWorkAreaPropertyKey:
+ return object->as<LinearAnimationBase>()->enableWorkArea();
+ case StateMachineBoolBase::valuePropertyKey:
+ return object->as<StateMachineBoolBase>()->value();
+ case ShapePaintBase::isVisiblePropertyKey:
+ return object->as<ShapePaintBase>()->isVisible();
+ case StrokeBase::transformAffectsStrokePropertyKey:
+ return object->as<StrokeBase>()->transformAffectsStroke();
+ case PointsPathBase::isClosedPropertyKey:
+ return object->as<PointsPathBase>()->isClosed();
+ case RectangleBase::linkCornerRadiusPropertyKey:
+ return object->as<RectangleBase>()->linkCornerRadius();
+ case ClippingShapeBase::isVisiblePropertyKey:
+ return object->as<ClippingShapeBase>()->isVisible();
+ case ArtboardBase::clipPropertyKey:
+ return object->as<ArtboardBase>()->clip();
+ }
+ return false;
}
- return false;
- }
- static int getColor(Core* object, int propertyKey) {
- switch (propertyKey) {
- case KeyFrameColorBase::valuePropertyKey:
- return object->as<KeyFrameColorBase>()->value();
- case SolidColorBase::colorValuePropertyKey:
- return object->as<SolidColorBase>()->colorValue();
- case GradientStopBase::colorValuePropertyKey:
- return object->as<GradientStopBase>()->colorValue();
+ static int getColor(Core* object, int propertyKey) {
+ switch (propertyKey) {
+ case KeyFrameColorBase::valuePropertyKey:
+ return object->as<KeyFrameColorBase>()->value();
+ case SolidColorBase::colorValuePropertyKey:
+ return object->as<SolidColorBase>()->colorValue();
+ case GradientStopBase::colorValuePropertyKey:
+ return object->as<GradientStopBase>()->colorValue();
+ }
+ return 0;
}
- return 0;
- }
- static int propertyFieldId(int propertyKey) {
- switch (propertyKey) {
- case ComponentBase::namePropertyKey:
- case StateMachineComponentBase::namePropertyKey:
- case AnimationBase::namePropertyKey:
- case AssetBase::namePropertyKey: return CoreStringType::id;
- case ComponentBase::parentIdPropertyKey:
- case DrawTargetBase::drawableIdPropertyKey:
- case DrawTargetBase::placementValuePropertyKey:
- case TargetedConstraintBase::targetIdPropertyKey:
- case DistanceConstraintBase::modeValuePropertyKey:
- case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
- case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
- case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
- case IKConstraintBase::parentBoneCountPropertyKey:
- case DrawableBase::blendModeValuePropertyKey:
- case DrawableBase::drawableFlagsPropertyKey:
- case NestedArtboardBase::artboardIdPropertyKey:
- case NestedAnimationBase::animationIdPropertyKey:
- case ListenerInputChangeBase::inputIdPropertyKey:
- case AnimationStateBase::animationIdPropertyKey:
- case NestedInputBase::inputIdPropertyKey:
- case KeyedObjectBase::objectIdPropertyKey:
- case BlendAnimationBase::animationIdPropertyKey:
- case BlendAnimationDirectBase::inputIdPropertyKey:
- case TransitionConditionBase::inputIdPropertyKey:
- case KeyedPropertyBase::propertyKeyPropertyKey:
- case StateMachineListenerBase::targetIdPropertyKey:
- case StateMachineListenerBase::listenerTypeValuePropertyKey:
- case KeyFrameBase::framePropertyKey:
- case KeyFrameBase::interpolationTypePropertyKey:
- case KeyFrameBase::interpolatorIdPropertyKey:
- case KeyFrameIdBase::valuePropertyKey:
- case ListenerBoolChangeBase::valuePropertyKey:
- case ListenerAlignTargetBase::targetIdPropertyKey:
- case TransitionValueConditionBase::opValuePropertyKey:
- case StateTransitionBase::stateToIdPropertyKey:
- case StateTransitionBase::flagsPropertyKey:
- case StateTransitionBase::durationPropertyKey:
- case StateTransitionBase::exitTimePropertyKey:
- case LinearAnimationBase::fpsPropertyKey:
- case LinearAnimationBase::durationPropertyKey:
- case LinearAnimationBase::loopValuePropertyKey:
- case LinearAnimationBase::workStartPropertyKey:
- case LinearAnimationBase::workEndPropertyKey:
- case BlendState1DBase::inputIdPropertyKey:
- case BlendStateTransitionBase::exitBlendAnimationIdPropertyKey:
- case StrokeBase::capPropertyKey:
- case StrokeBase::joinPropertyKey:
- case TrimPathBase::modeValuePropertyKey:
- case FillBase::fillRulePropertyKey:
- case PathBase::pathFlagsPropertyKey:
- case ClippingShapeBase::sourceIdPropertyKey:
- case ClippingShapeBase::fillRulePropertyKey:
- case PolygonBase::pointsPropertyKey:
- case ImageBase::assetIdPropertyKey:
- case DrawRulesBase::drawTargetIdPropertyKey:
- case ArtboardBase::defaultStateMachineIdPropertyKey:
- case WeightBase::valuesPropertyKey:
- case WeightBase::indicesPropertyKey:
- case TendonBase::boneIdPropertyKey:
- case CubicWeightBase::inValuesPropertyKey:
- case CubicWeightBase::inIndicesPropertyKey:
- case CubicWeightBase::outValuesPropertyKey:
- case CubicWeightBase::outIndicesPropertyKey:
- case FileAssetBase::assetIdPropertyKey: return CoreUintType::id;
- case ConstraintBase::strengthPropertyKey:
- case DistanceConstraintBase::distancePropertyKey:
- case TransformComponentConstraintBase::copyFactorPropertyKey:
- case TransformComponentConstraintBase::minValuePropertyKey:
- case TransformComponentConstraintBase::maxValuePropertyKey:
- case TransformComponentConstraintYBase::copyFactorYPropertyKey:
- case TransformComponentConstraintYBase::minValueYPropertyKey:
- case TransformComponentConstraintYBase::maxValueYPropertyKey:
- case WorldTransformComponentBase::opacityPropertyKey:
- case TransformComponentBase::rotationPropertyKey:
- case TransformComponentBase::scaleXPropertyKey:
- case TransformComponentBase::scaleYPropertyKey:
- case NodeBase::xPropertyKey:
- case NodeBase::yPropertyKey:
- case NestedLinearAnimationBase::mixPropertyKey:
- case NestedSimpleAnimationBase::speedPropertyKey:
- case StateMachineNumberBase::valuePropertyKey:
- case TransitionNumberConditionBase::valuePropertyKey:
- case ListenerNumberChangeBase::valuePropertyKey:
- case CubicInterpolatorBase::x1PropertyKey:
- case CubicInterpolatorBase::y1PropertyKey:
- case CubicInterpolatorBase::x2PropertyKey:
- case CubicInterpolatorBase::y2PropertyKey:
- case KeyFrameDoubleBase::valuePropertyKey:
- case LinearAnimationBase::speedPropertyKey:
- case NestedNumberBase::nestedValuePropertyKey:
- case NestedRemapAnimationBase::timePropertyKey:
- case BlendAnimation1DBase::valuePropertyKey:
- case LinearGradientBase::startXPropertyKey:
- case LinearGradientBase::startYPropertyKey:
- case LinearGradientBase::endXPropertyKey:
- case LinearGradientBase::endYPropertyKey:
- case LinearGradientBase::opacityPropertyKey:
- case StrokeBase::thicknessPropertyKey:
- case GradientStopBase::positionPropertyKey:
- case TrimPathBase::startPropertyKey:
- case TrimPathBase::endPropertyKey:
- case TrimPathBase::offsetPropertyKey:
- case VertexBase::xPropertyKey:
- case VertexBase::yPropertyKey:
- case MeshVertexBase::uPropertyKey:
- case MeshVertexBase::vPropertyKey:
- case StraightVertexBase::radiusPropertyKey:
- case CubicAsymmetricVertexBase::rotationPropertyKey:
- case CubicAsymmetricVertexBase::inDistancePropertyKey:
- case CubicAsymmetricVertexBase::outDistancePropertyKey:
- case ParametricPathBase::widthPropertyKey:
- case ParametricPathBase::heightPropertyKey:
- case ParametricPathBase::originXPropertyKey:
- case ParametricPathBase::originYPropertyKey:
- case RectangleBase::cornerRadiusTLPropertyKey:
- case RectangleBase::cornerRadiusTRPropertyKey:
- case RectangleBase::cornerRadiusBLPropertyKey:
- case RectangleBase::cornerRadiusBRPropertyKey:
- case CubicMirroredVertexBase::rotationPropertyKey:
- case CubicMirroredVertexBase::distancePropertyKey:
- case PolygonBase::cornerRadiusPropertyKey:
- case StarBase::innerRadiusPropertyKey:
- case CubicDetachedVertexBase::inRotationPropertyKey:
- case CubicDetachedVertexBase::inDistancePropertyKey:
- case CubicDetachedVertexBase::outRotationPropertyKey:
- case CubicDetachedVertexBase::outDistancePropertyKey:
- case ArtboardBase::widthPropertyKey:
- case ArtboardBase::heightPropertyKey:
- case ArtboardBase::xPropertyKey:
- case ArtboardBase::yPropertyKey:
- case ArtboardBase::originXPropertyKey:
- case ArtboardBase::originYPropertyKey:
- case BoneBase::lengthPropertyKey:
- case RootBoneBase::xPropertyKey:
- case RootBoneBase::yPropertyKey:
- case SkinBase::xxPropertyKey:
- case SkinBase::yxPropertyKey:
- case SkinBase::xyPropertyKey:
- case SkinBase::yyPropertyKey:
- case SkinBase::txPropertyKey:
- case SkinBase::tyPropertyKey:
- case TendonBase::xxPropertyKey:
- case TendonBase::yxPropertyKey:
- case TendonBase::xyPropertyKey:
- case TendonBase::yyPropertyKey:
- case TendonBase::txPropertyKey:
- case TendonBase::tyPropertyKey:
- case DrawableAssetBase::heightPropertyKey:
- case DrawableAssetBase::widthPropertyKey: return CoreDoubleType::id;
- case TransformComponentConstraintBase::offsetPropertyKey:
- case TransformComponentConstraintBase::doesCopyPropertyKey:
- case TransformComponentConstraintBase::minPropertyKey:
- case TransformComponentConstraintBase::maxPropertyKey:
- case TransformComponentConstraintYBase::doesCopyYPropertyKey:
- case TransformComponentConstraintYBase::minYPropertyKey:
- case TransformComponentConstraintYBase::maxYPropertyKey:
- case IKConstraintBase::invertDirectionPropertyKey:
- case NestedSimpleAnimationBase::isPlayingPropertyKey:
- case KeyFrameBoolBase::valuePropertyKey:
- case NestedBoolBase::nestedValuePropertyKey:
- case LinearAnimationBase::enableWorkAreaPropertyKey:
- case StateMachineBoolBase::valuePropertyKey:
- case ShapePaintBase::isVisiblePropertyKey:
- case StrokeBase::transformAffectsStrokePropertyKey:
- case PointsPathBase::isClosedPropertyKey:
- case RectangleBase::linkCornerRadiusPropertyKey:
- case ClippingShapeBase::isVisiblePropertyKey:
- case ArtboardBase::clipPropertyKey: return CoreBoolType::id;
- case KeyFrameColorBase::valuePropertyKey:
- case SolidColorBase::colorValuePropertyKey:
- case GradientStopBase::colorValuePropertyKey: return CoreColorType::id;
- case MeshBase::triangleIndexBytesPropertyKey:
- case FileAssetContentsBase::bytesPropertyKey: return CoreBytesType::id;
- default: return -1;
+ static int propertyFieldId(int propertyKey) {
+ switch (propertyKey) {
+ case ComponentBase::namePropertyKey:
+ case StateMachineComponentBase::namePropertyKey:
+ case AnimationBase::namePropertyKey:
+ case AssetBase::namePropertyKey:
+ return CoreStringType::id;
+ case ComponentBase::parentIdPropertyKey:
+ case DrawTargetBase::drawableIdPropertyKey:
+ case DrawTargetBase::placementValuePropertyKey:
+ case TargetedConstraintBase::targetIdPropertyKey:
+ case DistanceConstraintBase::modeValuePropertyKey:
+ case TransformSpaceConstraintBase::sourceSpaceValuePropertyKey:
+ case TransformSpaceConstraintBase::destSpaceValuePropertyKey:
+ case TransformComponentConstraintBase::minMaxSpaceValuePropertyKey:
+ case IKConstraintBase::parentBoneCountPropertyKey:
+ case DrawableBase::blendModeValuePropertyKey:
+ case DrawableBase::drawableFlagsPropertyKey:
+ case NestedArtboardBase::artboardIdPropertyKey:
+ case NestedAnimationBase::animationIdPropertyKey:
+ case EventInputChangeBase::inputIdPropertyKey:
+ case AnimationStateBase::animationIdPropertyKey:
+ case StateMachineEventBase::targetIdPropertyKey:
+ case StateMachineEventBase::eventTypeValuePropertyKey:
+ case KeyedObjectBase::objectIdPropertyKey:
+ case BlendAnimationBase::animationIdPropertyKey:
+ case BlendAnimationDirectBase::inputIdPropertyKey:
+ case TransitionConditionBase::inputIdPropertyKey:
+ case KeyedPropertyBase::propertyKeyPropertyKey:
+ case KeyFrameBase::framePropertyKey:
+ case KeyFrameBase::interpolationTypePropertyKey:
+ case KeyFrameBase::interpolatorIdPropertyKey:
+ case KeyFrameIdBase::valuePropertyKey:
+ case TransitionValueConditionBase::opValuePropertyKey:
+ case EventBoolChangeBase::valuePropertyKey:
+ case StateTransitionBase::stateToIdPropertyKey:
+ case StateTransitionBase::flagsPropertyKey:
+ case StateTransitionBase::durationPropertyKey:
+ case StateTransitionBase::exitTimePropertyKey:
+ case LinearAnimationBase::fpsPropertyKey:
+ case LinearAnimationBase::durationPropertyKey:
+ case LinearAnimationBase::loopValuePropertyKey:
+ case LinearAnimationBase::workStartPropertyKey:
+ case LinearAnimationBase::workEndPropertyKey:
+ case BlendState1DBase::inputIdPropertyKey:
+ case BlendStateTransitionBase::exitBlendAnimationIdPropertyKey:
+ case StrokeBase::capPropertyKey:
+ case StrokeBase::joinPropertyKey:
+ case TrimPathBase::modeValuePropertyKey:
+ case FillBase::fillRulePropertyKey:
+ case PathBase::pathFlagsPropertyKey:
+ case ClippingShapeBase::sourceIdPropertyKey:
+ case ClippingShapeBase::fillRulePropertyKey:
+ case PolygonBase::pointsPropertyKey:
+ case ImageBase::assetIdPropertyKey:
+ case DrawRulesBase::drawTargetIdPropertyKey:
+ case ArtboardBase::defaultStateMachineIdPropertyKey:
+ case WeightBase::valuesPropertyKey:
+ case WeightBase::indicesPropertyKey:
+ case TendonBase::boneIdPropertyKey:
+ case CubicWeightBase::inValuesPropertyKey:
+ case CubicWeightBase::inIndicesPropertyKey:
+ case CubicWeightBase::outValuesPropertyKey:
+ case CubicWeightBase::outIndicesPropertyKey:
+ case FileAssetBase::assetIdPropertyKey:
+ return CoreUintType::id;
+ case ConstraintBase::strengthPropertyKey:
+ case DistanceConstraintBase::distancePropertyKey:
+ case TransformComponentConstraintBase::copyFactorPropertyKey:
+ case TransformComponentConstraintBase::minValuePropertyKey:
+ case TransformComponentConstraintBase::maxValuePropertyKey:
+ case TransformComponentConstraintYBase::copyFactorYPropertyKey:
+ case TransformComponentConstraintYBase::minValueYPropertyKey:
+ case TransformComponentConstraintYBase::maxValueYPropertyKey:
+ case WorldTransformComponentBase::opacityPropertyKey:
+ case TransformComponentBase::rotationPropertyKey:
+ case TransformComponentBase::scaleXPropertyKey:
+ case TransformComponentBase::scaleYPropertyKey:
+ case NodeBase::xPropertyKey:
+ case NodeBase::yPropertyKey:
+ case EventNumberChangeBase::valuePropertyKey:
+ case NestedLinearAnimationBase::mixPropertyKey:
+ case NestedSimpleAnimationBase::speedPropertyKey:
+ case StateMachineNumberBase::valuePropertyKey:
+ case TransitionNumberConditionBase::valuePropertyKey:
+ case CubicInterpolatorBase::x1PropertyKey:
+ case CubicInterpolatorBase::y1PropertyKey:
+ case CubicInterpolatorBase::x2PropertyKey:
+ case CubicInterpolatorBase::y2PropertyKey:
+ case KeyFrameDoubleBase::valuePropertyKey:
+ case LinearAnimationBase::speedPropertyKey:
+ case NestedRemapAnimationBase::timePropertyKey:
+ case BlendAnimation1DBase::valuePropertyKey:
+ case LinearGradientBase::startXPropertyKey:
+ case LinearGradientBase::startYPropertyKey:
+ case LinearGradientBase::endXPropertyKey:
+ case LinearGradientBase::endYPropertyKey:
+ case LinearGradientBase::opacityPropertyKey:
+ case StrokeBase::thicknessPropertyKey:
+ case GradientStopBase::positionPropertyKey:
+ case TrimPathBase::startPropertyKey:
+ case TrimPathBase::endPropertyKey:
+ case TrimPathBase::offsetPropertyKey:
+ case VertexBase::xPropertyKey:
+ case VertexBase::yPropertyKey:
+ case MeshVertexBase::uPropertyKey:
+ case MeshVertexBase::vPropertyKey:
+ case StraightVertexBase::radiusPropertyKey:
+ case CubicAsymmetricVertexBase::rotationPropertyKey:
+ case CubicAsymmetricVertexBase::inDistancePropertyKey:
+ case CubicAsymmetricVertexBase::outDistancePropertyKey:
+ case ParametricPathBase::widthPropertyKey:
+ case ParametricPathBase::heightPropertyKey:
+ case ParametricPathBase::originXPropertyKey:
+ case ParametricPathBase::originYPropertyKey:
+ case RectangleBase::cornerRadiusTLPropertyKey:
+ case RectangleBase::cornerRadiusTRPropertyKey:
+ case RectangleBase::cornerRadiusBLPropertyKey:
+ case RectangleBase::cornerRadiusBRPropertyKey:
+ case CubicMirroredVertexBase::rotationPropertyKey:
+ case CubicMirroredVertexBase::distancePropertyKey:
+ case PolygonBase::cornerRadiusPropertyKey:
+ case StarBase::innerRadiusPropertyKey:
+ case CubicDetachedVertexBase::inRotationPropertyKey:
+ case CubicDetachedVertexBase::inDistancePropertyKey:
+ case CubicDetachedVertexBase::outRotationPropertyKey:
+ case CubicDetachedVertexBase::outDistancePropertyKey:
+ case ArtboardBase::widthPropertyKey:
+ case ArtboardBase::heightPropertyKey:
+ case ArtboardBase::xPropertyKey:
+ case ArtboardBase::yPropertyKey:
+ case ArtboardBase::originXPropertyKey:
+ case ArtboardBase::originYPropertyKey:
+ case BoneBase::lengthPropertyKey:
+ case RootBoneBase::xPropertyKey:
+ case RootBoneBase::yPropertyKey:
+ case SkinBase::xxPropertyKey:
+ case SkinBase::yxPropertyKey:
+ case SkinBase::xyPropertyKey:
+ case SkinBase::yyPropertyKey:
+ case SkinBase::txPropertyKey:
+ case SkinBase::tyPropertyKey:
+ case TendonBase::xxPropertyKey:
+ case TendonBase::yxPropertyKey:
+ case TendonBase::xyPropertyKey:
+ case TendonBase::yyPropertyKey:
+ case TendonBase::txPropertyKey:
+ case TendonBase::tyPropertyKey:
+ case DrawableAssetBase::heightPropertyKey:
+ case DrawableAssetBase::widthPropertyKey:
+ return CoreDoubleType::id;
+ case TransformComponentConstraintBase::offsetPropertyKey:
+ case TransformComponentConstraintBase::doesCopyPropertyKey:
+ case TransformComponentConstraintBase::minPropertyKey:
+ case TransformComponentConstraintBase::maxPropertyKey:
+ case TransformComponentConstraintYBase::doesCopyYPropertyKey:
+ case TransformComponentConstraintYBase::minYPropertyKey:
+ case TransformComponentConstraintYBase::maxYPropertyKey:
+ case IKConstraintBase::invertDirectionPropertyKey:
+ case NestedSimpleAnimationBase::isPlayingPropertyKey:
+ case KeyFrameBoolBase::valuePropertyKey:
+ case LinearAnimationBase::enableWorkAreaPropertyKey:
+ case StateMachineBoolBase::valuePropertyKey:
+ case ShapePaintBase::isVisiblePropertyKey:
+ case StrokeBase::transformAffectsStrokePropertyKey:
+ case PointsPathBase::isClosedPropertyKey:
+ case RectangleBase::linkCornerRadiusPropertyKey:
+ case ClippingShapeBase::isVisiblePropertyKey:
+ case ArtboardBase::clipPropertyKey:
+ return CoreBoolType::id;
+ case KeyFrameColorBase::valuePropertyKey:
+ case SolidColorBase::colorValuePropertyKey:
+ case GradientStopBase::colorValuePropertyKey:
+ return CoreColorType::id;
+ case MeshBase::triangleIndexBytesPropertyKey:
+ case FileAssetContentsBase::bytesPropertyKey:
+ return CoreBytesType::id;
+ default:
+ return -1;
+ }
}
- }
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/container_component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class DrawRulesBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
-
-public:
- static const uint16_t typeKey = 49;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case DrawRulesBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class DrawRulesBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
+
+ public:
+ static const uint16_t typeKey = 49;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case DrawRulesBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t drawTargetIdPropertyKey = 121;
+ static const uint16_t drawTargetIdPropertyKey = 121;
-private:
- uint32_t m_DrawTargetId = -1;
+ private:
+ uint32_t m_DrawTargetId = -1;
-public:
- inline uint32_t drawTargetId() const { return m_DrawTargetId; }
- void drawTargetId(uint32_t value) {
- if (m_DrawTargetId == value) {
- return;
+ public:
+ inline uint32_t drawTargetId() const { return m_DrawTargetId; }
+ void drawTargetId(uint32_t value) {
+ if (m_DrawTargetId == value) {
+ return;
+ }
+ m_DrawTargetId = value;
+ drawTargetIdChanged();
}
- m_DrawTargetId = value;
- drawTargetIdChanged();
- }
-
- Core* clone() const override;
- void copy(const DrawRulesBase& object) {
- m_DrawTargetId = object.m_DrawTargetId;
- ContainerComponent::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case drawTargetIdPropertyKey:
- m_DrawTargetId = CoreUintType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const DrawRulesBase& object) {
+ m_DrawTargetId = object.m_DrawTargetId;
+ ContainerComponent::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case drawTargetIdPropertyKey:
+ m_DrawTargetId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return ContainerComponent::deserialize(propertyKey, reader);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void drawTargetIdChanged() {}
-};
+ protected:
+ virtual void drawTargetIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class DrawTargetBase : public Component {
-protected:
- typedef Component Super;
+ class DrawTargetBase : public Component {
+ protected:
+ typedef Component Super;
-public:
- static const uint16_t typeKey = 48;
+ public:
+ static const uint16_t typeKey = 48;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case DrawTargetBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case DrawTargetBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t drawableIdPropertyKey = 119;
- static const uint16_t placementValuePropertyKey = 120;
+ static const uint16_t drawableIdPropertyKey = 119;
+ static const uint16_t placementValuePropertyKey = 120;
-private:
- uint32_t m_DrawableId = -1;
- uint32_t m_PlacementValue = 0;
+ private:
+ uint32_t m_DrawableId = -1;
+ uint32_t m_PlacementValue = 0;
-public:
- inline uint32_t drawableId() const { return m_DrawableId; }
- void drawableId(uint32_t value) {
- if (m_DrawableId == value) {
- return;
+ public:
+ inline uint32_t drawableId() const { return m_DrawableId; }
+ void drawableId(uint32_t value) {
+ if (m_DrawableId == value) {
+ return;
+ }
+ m_DrawableId = value;
+ drawableIdChanged();
}
- m_DrawableId = value;
- drawableIdChanged();
- }
- inline uint32_t placementValue() const { return m_PlacementValue; }
- void placementValue(uint32_t value) {
- if (m_PlacementValue == value) {
- return;
+ inline uint32_t placementValue() const { return m_PlacementValue; }
+ void placementValue(uint32_t value) {
+ if (m_PlacementValue == value) {
+ return;
+ }
+ m_PlacementValue = value;
+ placementValueChanged();
}
- m_PlacementValue = value;
- placementValueChanged();
- }
- Core* clone() const override;
- void copy(const DrawTargetBase& object) {
- m_DrawableId = object.m_DrawableId;
- m_PlacementValue = object.m_PlacementValue;
- Component::copy(object);
- }
+ Core* clone() const override;
+ 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) {
- case drawableIdPropertyKey:
- m_DrawableId = CoreUintType::deserialize(reader);
- return true;
- case placementValuePropertyKey:
- m_PlacementValue = CoreUintType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case drawableIdPropertyKey:
+ m_DrawableId = CoreUintType::deserialize(reader);
+ return true;
+ case placementValuePropertyKey:
+ m_PlacementValue = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return Component::deserialize(propertyKey, reader);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void drawableIdChanged() {}
- virtual void placementValueChanged() {}
-};
+ protected:
+ virtual void drawableIdChanged() {}
+ virtual void placementValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/node.hpp"
namespace rive {
-class DrawableBase : public Node {
-protected:
- typedef Node Super;
+ class DrawableBase : public Node {
+ protected:
+ typedef Node Super;
-public:
- static const uint16_t typeKey = 13;
+ public:
+ static const uint16_t typeKey = 13;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t blendModeValuePropertyKey = 23;
- static const uint16_t drawableFlagsPropertyKey = 129;
+ static const uint16_t blendModeValuePropertyKey = 23;
+ static const uint16_t drawableFlagsPropertyKey = 129;
-private:
- uint32_t m_BlendModeValue = 3;
- uint32_t m_DrawableFlags = 0;
+ private:
+ uint32_t m_BlendModeValue = 3;
+ uint32_t m_DrawableFlags = 0;
-public:
- inline uint32_t blendModeValue() const { return m_BlendModeValue; }
- void blendModeValue(uint32_t value) {
- if (m_BlendModeValue == value) {
- return;
+ public:
+ inline uint32_t blendModeValue() const { return m_BlendModeValue; }
+ void blendModeValue(uint32_t value) {
+ if (m_BlendModeValue == value) {
+ return;
+ }
+ m_BlendModeValue = value;
+ blendModeValueChanged();
}
- m_BlendModeValue = value;
- blendModeValueChanged();
- }
- inline uint32_t drawableFlags() const { return m_DrawableFlags; }
- void drawableFlags(uint32_t value) {
- if (m_DrawableFlags == value) {
- return;
+ inline uint32_t drawableFlags() const { return m_DrawableFlags; }
+ void drawableFlags(uint32_t value) {
+ if (m_DrawableFlags == value) {
+ return;
+ }
+ m_DrawableFlags = value;
+ drawableFlagsChanged();
}
- m_DrawableFlags = value;
- drawableFlagsChanged();
- }
- void copy(const DrawableBase& object) {
- m_BlendModeValue = object.m_BlendModeValue;
- m_DrawableFlags = object.m_DrawableFlags;
- Node::copy(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) {
- case blendModeValuePropertyKey:
- m_BlendModeValue = CoreUintType::deserialize(reader);
- return true;
- case drawableFlagsPropertyKey:
- m_DrawableFlags = CoreUintType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case blendModeValuePropertyKey:
+ m_BlendModeValue = CoreUintType::deserialize(reader);
+ return true;
+ case drawableFlagsPropertyKey:
+ m_DrawableFlags = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return Node::deserialize(propertyKey, reader);
}
- return Node::deserialize(propertyKey, reader);
- }
-protected:
- virtual void blendModeValueChanged() {}
- virtual void drawableFlagsChanged() {}
-};
+ protected:
+ virtual void blendModeValueChanged() {}
+ virtual void drawableFlagsChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_NESTED_ANIMATION_BASE_HPP_
#define _RIVE_NESTED_ANIMATION_BASE_HPP_
-#include "rive/container_component.hpp"
+#include "rive/component.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class NestedAnimationBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
-
-public:
- static const uint16_t typeKey = 93;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case NestedAnimationBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class NestedAnimationBase : public Component {
+ protected:
+ typedef Component Super;
+
+ public:
+ static const uint16_t typeKey = 93;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case NestedAnimationBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t animationIdPropertyKey = 198;
+ static const uint16_t animationIdPropertyKey = 198;
-private:
- uint32_t m_AnimationId = -1;
+ private:
+ uint32_t m_AnimationId = -1;
-public:
- inline uint32_t animationId() const { return m_AnimationId; }
- void animationId(uint32_t value) {
- if (m_AnimationId == value) {
- return;
+ public:
+ inline uint32_t animationId() const { return m_AnimationId; }
+ void animationId(uint32_t value) {
+ if (m_AnimationId == value) {
+ return;
+ }
+ m_AnimationId = value;
+ animationIdChanged();
}
- m_AnimationId = value;
- animationIdChanged();
- }
-
- void copy(const NestedAnimationBase& object) {
- m_AnimationId = object.m_AnimationId;
- ContainerComponent::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case animationIdPropertyKey:
- m_AnimationId = CoreUintType::deserialize(reader);
- return true;
+
+ void copy(const NestedAnimationBase& object) {
+ m_AnimationId = object.m_AnimationId;
+ Component::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case animationIdPropertyKey:
+ m_AnimationId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return Component::deserialize(propertyKey, reader);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void animationIdChanged() {}
-};
+ protected:
+ virtual void animationIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/drawable.hpp"
namespace rive {
-class NestedArtboardBase : public Drawable {
-protected:
- typedef Drawable Super;
+ class NestedArtboardBase : public Drawable {
+ protected:
+ typedef Drawable Super;
-public:
- static const uint16_t typeKey = 92;
+ public:
+ static const uint16_t typeKey = 92;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t artboardIdPropertyKey = 197;
+ static const uint16_t artboardIdPropertyKey = 197;
-private:
- uint32_t m_ArtboardId = -1;
+ private:
+ uint32_t m_ArtboardId = -1;
-public:
- inline uint32_t artboardId() const { return m_ArtboardId; }
- void artboardId(uint32_t value) {
- if (m_ArtboardId == value) {
- return;
+ public:
+ inline uint32_t artboardId() const { return m_ArtboardId; }
+ void artboardId(uint32_t value) {
+ if (m_ArtboardId == value) {
+ return;
+ }
+ m_ArtboardId = value;
+ artboardIdChanged();
}
- m_ArtboardId = value;
- artboardIdChanged();
- }
- Core* clone() const override;
- void copy(const NestedArtboardBase& object) {
- m_ArtboardId = object.m_ArtboardId;
- Drawable::copy(object);
- }
+ Core* clone() const override;
+ void copy(const NestedArtboardBase& object) {
+ m_ArtboardId = object.m_ArtboardId;
+ Drawable::copy(object);
+ }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case artboardIdPropertyKey:
- m_ArtboardId = CoreUintType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case artboardIdPropertyKey:
+ m_ArtboardId = CoreUintType::deserialize(reader);
+ return true;
+ }
+ return Drawable::deserialize(propertyKey, reader);
}
- return Drawable::deserialize(propertyKey, reader);
- }
-protected:
- virtual void artboardIdChanged() {}
-};
+ protected:
+ virtual void artboardIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/transform_component.hpp"
namespace rive {
-class NodeBase : public TransformComponent {
-protected:
- typedef TransformComponent Super;
+ class NodeBase : public TransformComponent {
+ protected:
+ typedef TransformComponent Super;
-public:
- static const uint16_t typeKey = 2;
+ public:
+ static const uint16_t typeKey = 2;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t xPropertyKey = 13;
- static const uint16_t yPropertyKey = 14;
+ static const uint16_t xPropertyKey = 13;
+ static const uint16_t yPropertyKey = 14;
-private:
- float m_X = 0.0f;
- float m_Y = 0.0f;
+ private:
+ float m_X = 0.0f;
+ float m_Y = 0.0f;
-public:
- inline float x() const override { return m_X; }
- void x(float value) {
- if (m_X == value) {
- return;
+ public:
+ inline float x() const override { return m_X; }
+ void x(float value) {
+ if (m_X == value) {
+ return;
+ }
+ m_X = value;
+ xChanged();
}
- m_X = value;
- xChanged();
- }
- inline float y() const override { return m_Y; }
- void y(float value) {
- if (m_Y == value) {
- return;
+ inline float y() const override { return m_Y; }
+ void y(float value) {
+ if (m_Y == value) {
+ return;
+ }
+ m_Y = value;
+ yChanged();
}
- m_Y = value;
- yChanged();
- }
- Core* clone() const override;
- void copy(const NodeBase& object) {
- m_X = object.m_X;
- m_Y = object.m_Y;
- TransformComponent::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return TransformComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void xChanged() {}
- virtual void yChanged() {}
-};
+ protected:
+ virtual void xChanged() {}
+ virtual void yChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bool_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class ClippingShapeBase : public Component {
-protected:
- typedef Component Super;
+ class ClippingShapeBase : public Component {
+ protected:
+ typedef Component Super;
-public:
- static const uint16_t typeKey = 42;
+ public:
+ static const uint16_t typeKey = 42;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ClippingShapeBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ClippingShapeBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t sourceIdPropertyKey = 92;
- static const uint16_t fillRulePropertyKey = 93;
- static const uint16_t isVisiblePropertyKey = 94;
+ static const uint16_t sourceIdPropertyKey = 92;
+ static const uint16_t fillRulePropertyKey = 93;
+ static const uint16_t isVisiblePropertyKey = 94;
-private:
- uint32_t m_SourceId = -1;
- uint32_t m_FillRule = 0;
- bool m_IsVisible = true;
+ private:
+ uint32_t m_SourceId = -1;
+ uint32_t m_FillRule = 0;
+ bool m_IsVisible = true;
-public:
- inline uint32_t sourceId() const { return m_SourceId; }
- void sourceId(uint32_t value) {
- if (m_SourceId == value) {
- return;
+ public:
+ inline uint32_t sourceId() const { return m_SourceId; }
+ void sourceId(uint32_t value) {
+ if (m_SourceId == value) {
+ return;
+ }
+ m_SourceId = value;
+ sourceIdChanged();
}
- m_SourceId = value;
- sourceIdChanged();
- }
- inline uint32_t fillRule() const { return m_FillRule; }
- void fillRule(uint32_t value) {
- if (m_FillRule == value) {
- return;
+ inline uint32_t fillRule() const { return m_FillRule; }
+ void fillRule(uint32_t value) {
+ if (m_FillRule == value) {
+ return;
+ }
+ m_FillRule = value;
+ fillRuleChanged();
}
- m_FillRule = value;
- fillRuleChanged();
- }
- inline bool isVisible() const { return m_IsVisible; }
- void isVisible(bool value) {
- if (m_IsVisible == value) {
- return;
+ inline bool isVisible() const { return m_IsVisible; }
+ void isVisible(bool value) {
+ if (m_IsVisible == value) {
+ return;
+ }
+ m_IsVisible = value;
+ isVisibleChanged();
}
- m_IsVisible = value;
- isVisibleChanged();
- }
- Core* clone() const override;
- void copy(const ClippingShapeBase& object) {
- m_SourceId = object.m_SourceId;
- m_FillRule = object.m_FillRule;
- m_IsVisible = object.m_IsVisible;
- Component::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void sourceIdChanged() {}
- virtual void fillRuleChanged() {}
- virtual void isVisibleChanged() {}
-};
+ protected:
+ virtual void sourceIdChanged() {}
+ virtual void fillRuleChanged() {}
+ virtual void isVisibleChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CONTOUR_MESH_VERTEX_BASE_HPP_
#include "rive/shapes/mesh_vertex.hpp"
namespace rive {
-class ContourMeshVertexBase : public MeshVertex {
-protected:
- typedef MeshVertex Super;
+ class ContourMeshVertexBase : public MeshVertex {
+ protected:
+ typedef MeshVertex Super;
-public:
- static const uint16_t typeKey = 111;
+ public:
+ static const uint16_t typeKey = 111;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/cubic_vertex.hpp"
namespace rive {
-class CubicAsymmetricVertexBase : public CubicVertex {
-protected:
- typedef CubicVertex Super;
+ class CubicAsymmetricVertexBase : public CubicVertex {
+ protected:
+ typedef CubicVertex Super;
-public:
- static const uint16_t typeKey = 34;
+ public:
+ static const uint16_t typeKey = 34;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t rotationPropertyKey = 79;
- static const uint16_t inDistancePropertyKey = 80;
- static const uint16_t outDistancePropertyKey = 81;
+ static const uint16_t rotationPropertyKey = 79;
+ static const uint16_t inDistancePropertyKey = 80;
+ static const uint16_t outDistancePropertyKey = 81;
-private:
- float m_Rotation = 0.0f;
- float m_InDistance = 0.0f;
- float m_OutDistance = 0.0f;
+ private:
+ float m_Rotation = 0.0f;
+ float m_InDistance = 0.0f;
+ float m_OutDistance = 0.0f;
-public:
- inline float rotation() const { return m_Rotation; }
- void rotation(float value) {
- if (m_Rotation == value) {
- return;
+ public:
+ inline float rotation() const { return m_Rotation; }
+ void rotation(float value) {
+ if (m_Rotation == value) {
+ return;
+ }
+ m_Rotation = value;
+ rotationChanged();
}
- m_Rotation = value;
- rotationChanged();
- }
- inline float inDistance() const { return m_InDistance; }
- void inDistance(float value) {
- if (m_InDistance == value) {
- return;
+ inline float inDistance() const { return m_InDistance; }
+ void inDistance(float value) {
+ if (m_InDistance == value) {
+ return;
+ }
+ m_InDistance = value;
+ inDistanceChanged();
}
- m_InDistance = value;
- inDistanceChanged();
- }
- inline float outDistance() const { return m_OutDistance; }
- void outDistance(float value) {
- if (m_OutDistance == value) {
- return;
+ inline float outDistance() const { return m_OutDistance; }
+ void outDistance(float value) {
+ if (m_OutDistance == value) {
+ return;
+ }
+ m_OutDistance = value;
+ outDistanceChanged();
}
- m_OutDistance = value;
- outDistanceChanged();
- }
- Core* clone() const override;
- void copy(const CubicAsymmetricVertexBase& object) {
- m_Rotation = object.m_Rotation;
- m_InDistance = object.m_InDistance;
- m_OutDistance = object.m_OutDistance;
- CubicVertex::copy(object);
- }
+ Core* clone() const override;
+ 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;
- case inDistancePropertyKey:
- m_InDistance = CoreDoubleType::deserialize(reader);
- return true;
- case outDistancePropertyKey:
- m_OutDistance = 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;
+ case outDistancePropertyKey:
+ m_OutDistance = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return CubicVertex::deserialize(propertyKey, reader);
}
- return CubicVertex::deserialize(propertyKey, reader);
- }
-protected:
- virtual void rotationChanged() {}
- virtual void inDistanceChanged() {}
- virtual void outDistanceChanged() {}
-};
+ protected:
+ virtual void rotationChanged() {}
+ virtual void inDistanceChanged() {}
+ virtual void outDistanceChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/cubic_vertex.hpp"
namespace rive {
-class CubicDetachedVertexBase : public CubicVertex {
-protected:
- typedef CubicVertex Super;
+ class CubicDetachedVertexBase : public CubicVertex {
+ protected:
+ typedef CubicVertex Super;
-public:
- static const uint16_t typeKey = 6;
+ public:
+ static const uint16_t typeKey = 6;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t inRotationPropertyKey = 84;
- static const uint16_t inDistancePropertyKey = 85;
- static const uint16_t outRotationPropertyKey = 86;
- static const uint16_t outDistancePropertyKey = 87;
+ static const uint16_t inRotationPropertyKey = 84;
+ static const uint16_t inDistancePropertyKey = 85;
+ static const uint16_t outRotationPropertyKey = 86;
+ static const uint16_t outDistancePropertyKey = 87;
-private:
- float m_InRotation = 0.0f;
- float m_InDistance = 0.0f;
- float m_OutRotation = 0.0f;
- float m_OutDistance = 0.0f;
+ private:
+ float m_InRotation = 0.0f;
+ float m_InDistance = 0.0f;
+ float m_OutRotation = 0.0f;
+ float m_OutDistance = 0.0f;
-public:
- inline float inRotation() const { return m_InRotation; }
- void inRotation(float value) {
- if (m_InRotation == value) {
- return;
+ public:
+ inline float inRotation() const { return m_InRotation; }
+ void inRotation(float value) {
+ if (m_InRotation == value) {
+ return;
+ }
+ m_InRotation = value;
+ inRotationChanged();
}
- m_InRotation = value;
- inRotationChanged();
- }
- inline float inDistance() const { return m_InDistance; }
- void inDistance(float value) {
- if (m_InDistance == value) {
- return;
+ inline float inDistance() const { return m_InDistance; }
+ void inDistance(float value) {
+ if (m_InDistance == value) {
+ return;
+ }
+ m_InDistance = value;
+ inDistanceChanged();
}
- m_InDistance = value;
- inDistanceChanged();
- }
- inline float outRotation() const { return m_OutRotation; }
- void outRotation(float value) {
- if (m_OutRotation == value) {
- return;
+ inline float outRotation() const { return m_OutRotation; }
+ void outRotation(float value) {
+ if (m_OutRotation == value) {
+ return;
+ }
+ m_OutRotation = value;
+ outRotationChanged();
}
- m_OutRotation = value;
- outRotationChanged();
- }
- inline float outDistance() const { return m_OutDistance; }
- void outDistance(float value) {
- if (m_OutDistance == value) {
- return;
+ inline float outDistance() const { return m_OutDistance; }
+ void outDistance(float value) {
+ if (m_OutDistance == value) {
+ return;
+ }
+ m_OutDistance = value;
+ outDistanceChanged();
}
- m_OutDistance = value;
- outDistanceChanged();
- }
- Core* clone() const override;
- void copy(const CubicDetachedVertexBase& object) {
- m_InRotation = object.m_InRotation;
- m_InDistance = object.m_InDistance;
- m_OutRotation = object.m_OutRotation;
- m_OutDistance = object.m_OutDistance;
- CubicVertex::copy(object);
- }
+ Core* clone() const override;
+ void copy(const CubicDetachedVertexBase& object) {
+ m_InRotation = object.m_InRotation;
+ m_InDistance = object.m_InDistance;
+ m_OutRotation = object.m_OutRotation;
+ m_OutDistance = object.m_OutDistance;
+ CubicVertex::copy(object);
+ }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case inRotationPropertyKey:
- m_InRotation = CoreDoubleType::deserialize(reader);
- return true;
- case inDistancePropertyKey:
- m_InDistance = CoreDoubleType::deserialize(reader);
- return true;
- case outRotationPropertyKey:
- m_OutRotation = CoreDoubleType::deserialize(reader);
- return true;
- case outDistancePropertyKey:
- m_OutDistance = CoreDoubleType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case inRotationPropertyKey:
+ m_InRotation = CoreDoubleType::deserialize(reader);
+ return true;
+ case inDistancePropertyKey:
+ m_InDistance = CoreDoubleType::deserialize(reader);
+ return true;
+ case outRotationPropertyKey:
+ m_OutRotation = CoreDoubleType::deserialize(reader);
+ return true;
+ case outDistancePropertyKey:
+ m_OutDistance = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return CubicVertex::deserialize(propertyKey, reader);
}
- return CubicVertex::deserialize(propertyKey, reader);
- }
-protected:
- virtual void inRotationChanged() {}
- virtual void inDistanceChanged() {}
- virtual void outRotationChanged() {}
- virtual void outDistanceChanged() {}
-};
+ protected:
+ virtual void inRotationChanged() {}
+ virtual void inDistanceChanged() {}
+ virtual void outRotationChanged() {}
+ virtual void outDistanceChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/cubic_vertex.hpp"
namespace rive {
-class CubicMirroredVertexBase : public CubicVertex {
-protected:
- typedef CubicVertex Super;
+ class CubicMirroredVertexBase : public CubicVertex {
+ protected:
+ typedef CubicVertex Super;
-public:
- static const uint16_t typeKey = 35;
+ public:
+ static const uint16_t typeKey = 35;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t rotationPropertyKey = 82;
- static const uint16_t distancePropertyKey = 83;
+ static const uint16_t rotationPropertyKey = 82;
+ static const uint16_t distancePropertyKey = 83;
-private:
- float m_Rotation = 0.0f;
- float m_Distance = 0.0f;
+ private:
+ float m_Rotation = 0.0f;
+ float m_Distance = 0.0f;
-public:
- inline float rotation() const { return m_Rotation; }
- void rotation(float value) {
- if (m_Rotation == value) {
- return;
+ public:
+ inline float rotation() const { return m_Rotation; }
+ void rotation(float value) {
+ if (m_Rotation == value) {
+ return;
+ }
+ m_Rotation = value;
+ rotationChanged();
}
- m_Rotation = value;
- rotationChanged();
- }
- inline float distance() const { return m_Distance; }
- void distance(float value) {
- if (m_Distance == value) {
- return;
+ inline float distance() const { return m_Distance; }
+ void distance(float value) {
+ if (m_Distance == value) {
+ return;
+ }
+ m_Distance = value;
+ distanceChanged();
}
- m_Distance = value;
- distanceChanged();
- }
- Core* clone() const override;
- void copy(const CubicMirroredVertexBase& object) {
- m_Rotation = object.m_Rotation;
- m_Distance = object.m_Distance;
- CubicVertex::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return CubicVertex::deserialize(propertyKey, reader);
- }
-protected:
- virtual void rotationChanged() {}
- virtual void distanceChanged() {}
-};
+ protected:
+ virtual void rotationChanged() {}
+ virtual void distanceChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CUBIC_VERTEX_BASE_HPP_
#include "rive/shapes/path_vertex.hpp"
namespace rive {
-class CubicVertexBase : public PathVertex {
-protected:
- typedef PathVertex Super;
+ class CubicVertexBase : public PathVertex {
+ protected:
+ typedef PathVertex Super;
-public:
- static const uint16_t typeKey = 36;
+ public:
+ static const uint16_t typeKey = 36;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_ELLIPSE_BASE_HPP_
#include "rive/shapes/parametric_path.hpp"
namespace rive {
-class EllipseBase : public ParametricPath {
-protected:
- typedef ParametricPath Super;
+ class EllipseBase : public ParametricPath {
+ protected:
+ typedef ParametricPath Super;
-public:
- static const uint16_t typeKey = 4;
+ public:
+ static const uint16_t typeKey = 4;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case EllipseBase::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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case EllipseBase::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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/drawable.hpp"
namespace rive {
-class ImageBase : public Drawable {
-protected:
- typedef Drawable Super;
-
-public:
- static const uint16_t typeKey = 100;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class ImageBase : public Drawable {
+ protected:
+ typedef Drawable Super;
+
+ public:
+ static const uint16_t typeKey = 100;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t assetIdPropertyKey = 206;
+ static const uint16_t assetIdPropertyKey = 206;
-private:
- uint32_t m_AssetId = -1;
+ private:
+ uint32_t m_AssetId = -1;
-public:
- inline uint32_t assetId() const { return m_AssetId; }
- void assetId(uint32_t value) {
- if (m_AssetId == value) {
- return;
+ public:
+ inline uint32_t assetId() const { return m_AssetId; }
+ void assetId(uint32_t value) {
+ if (m_AssetId == value) {
+ return;
+ }
+ m_AssetId = value;
+ assetIdChanged();
}
- m_AssetId = value;
- assetIdChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return Drawable::deserialize(propertyKey, reader);
}
- return Drawable::deserialize(propertyKey, reader);
- }
-protected:
- virtual void assetIdChanged() {}
-};
+ protected:
+ virtual void assetIdChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bytes_type.hpp"
#include "rive/span.hpp"
namespace rive {
-class MeshBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
-
-public:
- static const uint16_t typeKey = 109;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case MeshBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class MeshBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
+
+ public:
+ static const uint16_t typeKey = 109;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case MeshBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t triangleIndexBytesPropertyKey = 223;
+ static const uint16_t triangleIndexBytesPropertyKey = 223;
-public:
- virtual void decodeTriangleIndexBytes(Span<const uint8_t> value) = 0;
- virtual void copyTriangleIndexBytes(const MeshBase& object) = 0;
+ public:
+ virtual void decodeTriangleIndexBytes(Span<const uint8_t> value) = 0;
+ virtual void copyTriangleIndexBytes(const MeshBase& object) = 0;
- Core* clone() const override;
- void copy(const MeshBase& object) {
- copyTriangleIndexBytes(object);
- ContainerComponent::copy(object);
- }
+ Core* clone() const override;
+ void copy(const MeshBase& object) {
+ copyTriangleIndexBytes(object);
+ ContainerComponent::copy(object);
+ }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case triangleIndexBytesPropertyKey:
- decodeTriangleIndexBytes(CoreBytesType::deserialize(reader));
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case triangleIndexBytesPropertyKey:
+ decodeTriangleIndexBytes(CoreBytesType::deserialize(reader));
+ return true;
+ }
+ return ContainerComponent::deserialize(propertyKey, reader);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void triangleIndexBytesChanged() {}
-};
+ protected:
+ virtual void triangleIndexBytesChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/vertex.hpp"
namespace rive {
-class MeshVertexBase : public Vertex {
-protected:
- typedef Vertex Super;
+ class MeshVertexBase : public Vertex {
+ protected:
+ typedef Vertex Super;
-public:
- static const uint16_t typeKey = 108;
+ public:
+ static const uint16_t typeKey = 108;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t uPropertyKey = 215;
- static const uint16_t vPropertyKey = 216;
+ static const uint16_t uPropertyKey = 215;
+ static const uint16_t vPropertyKey = 216;
-private:
- float m_U = 0.0f;
- float m_V = 0.0f;
+ private:
+ float m_U = 0.0f;
+ float m_V = 0.0f;
-public:
- inline float u() const { return m_U; }
- void u(float value) {
- if (m_U == value) {
- return;
+ public:
+ inline float u() const { return m_U; }
+ void u(float value) {
+ if (m_U == value) {
+ return;
+ }
+ m_U = value;
+ uChanged();
}
- m_U = value;
- uChanged();
- }
- inline float v() const { return m_V; }
- void v(float value) {
- if (m_V == value) {
- return;
+ inline float v() const { return m_V; }
+ void v(float value) {
+ if (m_V == value) {
+ return;
+ }
+ m_V = value;
+ vChanged();
}
- m_V = value;
- vChanged();
- }
- Core* clone() const override;
- void copy(const MeshVertexBase& object) {
- m_U = object.m_U;
- m_V = object.m_V;
- Vertex::copy(object);
- }
+ Core* clone() const override;
+ 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);
}
- return Vertex::deserialize(propertyKey, reader);
- }
-protected:
- virtual void uChanged() {}
- virtual void vChanged() {}
-};
+ protected:
+ virtual void uChanged() {}
+ virtual void vChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/shapes/paint/shape_paint.hpp"
namespace rive {
-class FillBase : public ShapePaint {
-protected:
- typedef ShapePaint Super;
-
-public:
- static const uint16_t typeKey = 20;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class FillBase : public ShapePaint {
+ protected:
+ typedef ShapePaint Super;
+
+ public:
+ static const uint16_t typeKey = 20;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t fillRulePropertyKey = 40;
+ static const uint16_t fillRulePropertyKey = 40;
-private:
- uint32_t m_FillRule = 0;
+ private:
+ uint32_t m_FillRule = 0;
-public:
- inline uint32_t fillRule() const { return m_FillRule; }
- void fillRule(uint32_t value) {
- if (m_FillRule == value) {
- return;
+ public:
+ inline uint32_t fillRule() const { return m_FillRule; }
+ void fillRule(uint32_t value) {
+ if (m_FillRule == value) {
+ return;
+ }
+ m_FillRule = value;
+ fillRuleChanged();
}
- m_FillRule = value;
- fillRuleChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return ShapePaint::deserialize(propertyKey, reader);
}
- return ShapePaint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void fillRuleChanged() {}
-};
+ protected:
+ virtual void fillRuleChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_color_type.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class GradientStopBase : public Component {
-protected:
- typedef Component Super;
+ class GradientStopBase : public Component {
+ protected:
+ typedef Component Super;
-public:
- static const uint16_t typeKey = 19;
+ public:
+ static const uint16_t typeKey = 19;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case GradientStopBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case GradientStopBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t colorValuePropertyKey = 38;
- static const uint16_t positionPropertyKey = 39;
+ static const uint16_t colorValuePropertyKey = 38;
+ static const uint16_t positionPropertyKey = 39;
-private:
- int m_ColorValue = 0xFFFFFFFF;
- float m_Position = 0.0f;
+ private:
+ int m_ColorValue = 0xFFFFFFFF;
+ float m_Position = 0.0f;
-public:
- inline int colorValue() const { return m_ColorValue; }
- void colorValue(int value) {
- if (m_ColorValue == value) {
- return;
+ public:
+ inline int colorValue() const { return m_ColorValue; }
+ void colorValue(int value) {
+ if (m_ColorValue == value) {
+ return;
+ }
+ m_ColorValue = value;
+ colorValueChanged();
}
- m_ColorValue = value;
- colorValueChanged();
- }
- inline float position() const { return m_Position; }
- void position(float value) {
- if (m_Position == value) {
- return;
+ inline float position() const { return m_Position; }
+ void position(float value) {
+ if (m_Position == value) {
+ return;
+ }
+ m_Position = value;
+ positionChanged();
}
- m_Position = value;
- positionChanged();
- }
- Core* clone() const override;
- void copy(const GradientStopBase& object) {
- m_ColorValue = object.m_ColorValue;
- m_Position = object.m_Position;
- Component::copy(object);
- }
+ Core* clone() const override;
+ 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) {
- case colorValuePropertyKey:
- m_ColorValue = CoreColorType::deserialize(reader);
- return true;
- case positionPropertyKey: m_Position = CoreDoubleType::deserialize(reader); return true;
+ 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;
+ }
+ return Component::deserialize(propertyKey, reader);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void colorValueChanged() {}
- virtual void positionChanged() {}
-};
+ protected:
+ virtual void colorValueChanged() {}
+ virtual void positionChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/container_component.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class LinearGradientBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
+ class LinearGradientBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
-public:
- static const uint16_t typeKey = 22;
+ public:
+ static const uint16_t typeKey = 22;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case LinearGradientBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case LinearGradientBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t startXPropertyKey = 42;
- static const uint16_t startYPropertyKey = 33;
- static const uint16_t endXPropertyKey = 34;
- static const uint16_t endYPropertyKey = 35;
- static const uint16_t opacityPropertyKey = 46;
+ static const uint16_t startXPropertyKey = 42;
+ static const uint16_t startYPropertyKey = 33;
+ static const uint16_t endXPropertyKey = 34;
+ static const uint16_t endYPropertyKey = 35;
+ static const uint16_t opacityPropertyKey = 46;
-private:
- float m_StartX = 0.0f;
- float m_StartY = 0.0f;
- float m_EndX = 0.0f;
- float m_EndY = 0.0f;
- float m_Opacity = 1.0f;
+ private:
+ float m_StartX = 0.0f;
+ float m_StartY = 0.0f;
+ float m_EndX = 0.0f;
+ float m_EndY = 0.0f;
+ float m_Opacity = 1.0f;
-public:
- inline float startX() const { return m_StartX; }
- void startX(float value) {
- if (m_StartX == value) {
- return;
+ public:
+ inline float startX() const { return m_StartX; }
+ void startX(float value) {
+ if (m_StartX == value) {
+ return;
+ }
+ m_StartX = value;
+ startXChanged();
}
- m_StartX = value;
- startXChanged();
- }
- inline float startY() const { return m_StartY; }
- void startY(float value) {
- if (m_StartY == value) {
- return;
+ inline float startY() const { return m_StartY; }
+ void startY(float value) {
+ if (m_StartY == value) {
+ return;
+ }
+ m_StartY = value;
+ startYChanged();
}
- m_StartY = value;
- startYChanged();
- }
- inline float endX() const { return m_EndX; }
- void endX(float value) {
- if (m_EndX == value) {
- return;
+ inline float endX() const { return m_EndX; }
+ void endX(float value) {
+ if (m_EndX == value) {
+ return;
+ }
+ m_EndX = value;
+ endXChanged();
}
- m_EndX = value;
- endXChanged();
- }
- inline float endY() const { return m_EndY; }
- void endY(float value) {
- if (m_EndY == value) {
- return;
+ inline float endY() const { return m_EndY; }
+ void endY(float value) {
+ if (m_EndY == value) {
+ return;
+ }
+ m_EndY = value;
+ endYChanged();
}
- m_EndY = value;
- endYChanged();
- }
- inline float opacity() const { return m_Opacity; }
- void opacity(float value) {
- if (m_Opacity == value) {
- return;
+ inline float opacity() const { return m_Opacity; }
+ void opacity(float value) {
+ if (m_Opacity == value) {
+ return;
+ }
+ m_Opacity = value;
+ opacityChanged();
}
- m_Opacity = value;
- opacityChanged();
- }
- Core* clone() const override;
- void copy(const LinearGradientBase& object) {
- m_StartX = object.m_StartX;
- m_StartY = object.m_StartY;
- m_EndX = object.m_EndX;
- m_EndY = object.m_EndY;
- m_Opacity = object.m_Opacity;
- ContainerComponent::copy(object);
- }
+ Core* clone() const override;
+ void copy(const LinearGradientBase& object) {
+ m_StartX = object.m_StartX;
+ m_StartY = object.m_StartY;
+ m_EndX = object.m_EndX;
+ m_EndY = object.m_EndY;
+ m_Opacity = object.m_Opacity;
+ 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);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void startXChanged() {}
- virtual void startYChanged() {}
- virtual void endXChanged() {}
- virtual void endYChanged() {}
- virtual void opacityChanged() {}
-};
+ protected:
+ virtual void startXChanged() {}
+ virtual void startYChanged() {}
+ virtual void endXChanged() {}
+ virtual void endYChanged() {}
+ virtual void opacityChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_RADIAL_GRADIENT_BASE_HPP_
#include "rive/shapes/paint/linear_gradient.hpp"
namespace rive {
-class RadialGradientBase : public LinearGradient {
-protected:
- typedef LinearGradient Super;
+ class RadialGradientBase : public LinearGradient {
+ protected:
+ typedef LinearGradient Super;
-public:
- static const uint16_t typeKey = 17;
+ public:
+ static const uint16_t typeKey = 17;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/container_component.hpp"
#include "rive/core/field_types/core_bool_type.hpp"
namespace rive {
-class ShapePaintBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
-
-public:
- static const uint16_t typeKey = 21;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case ShapePaintBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class ShapePaintBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
+
+ public:
+ static const uint16_t typeKey = 21;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case ShapePaintBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t isVisiblePropertyKey = 41;
+ static const uint16_t isVisiblePropertyKey = 41;
-private:
- bool m_IsVisible = true;
+ private:
+ bool m_IsVisible = true;
-public:
- virtual bool isVisible() const { return m_IsVisible; }
- void isVisible(bool value) {
- if (m_IsVisible == value) {
- return;
+ public:
+ virtual bool isVisible() const { return m_IsVisible; }
+ void isVisible(bool value) {
+ if (m_IsVisible == value) {
+ return;
+ }
+ m_IsVisible = value;
+ isVisibleChanged();
}
- m_IsVisible = value;
- isVisibleChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return ContainerComponent::deserialize(propertyKey, reader);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void isVisibleChanged() {}
-};
+ protected:
+ virtual void isVisibleChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/component.hpp"
#include "rive/core/field_types/core_color_type.hpp"
namespace rive {
-class SolidColorBase : public Component {
-protected:
- typedef Component Super;
-
-public:
- static const uint16_t typeKey = 18;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case SolidColorBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class SolidColorBase : public Component {
+ protected:
+ typedef Component Super;
+
+ public:
+ static const uint16_t typeKey = 18;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case SolidColorBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t colorValuePropertyKey = 37;
+ static const uint16_t colorValuePropertyKey = 37;
-private:
- int m_ColorValue = 0xFF747474;
+ private:
+ int m_ColorValue = 0xFF747474;
-public:
- inline int colorValue() const { return m_ColorValue; }
- void colorValue(int value) {
- if (m_ColorValue == value) {
- return;
+ public:
+ inline int colorValue() const { return m_ColorValue; }
+ void colorValue(int value) {
+ if (m_ColorValue == value) {
+ return;
+ }
+ m_ColorValue = value;
+ colorValueChanged();
}
- m_ColorValue = value;
- colorValueChanged();
- }
-
- Core* clone() const override;
- void copy(const SolidColorBase& object) {
- m_ColorValue = object.m_ColorValue;
- Component::copy(object);
- }
-
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case colorValuePropertyKey:
- m_ColorValue = CoreColorType::deserialize(reader);
- return true;
+
+ Core* clone() const override;
+ void copy(const SolidColorBase& object) {
+ m_ColorValue = object.m_ColorValue;
+ Component::copy(object);
+ }
+
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case colorValuePropertyKey:
+ m_ColorValue = CoreColorType::deserialize(reader);
+ return true;
+ }
+ return Component::deserialize(propertyKey, reader);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void colorValueChanged() {}
-};
+ protected:
+ virtual void colorValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/shapes/paint/shape_paint.hpp"
namespace rive {
-class StrokeBase : public ShapePaint {
-protected:
- typedef ShapePaint Super;
+ class StrokeBase : public ShapePaint {
+ protected:
+ typedef ShapePaint Super;
-public:
- static const uint16_t typeKey = 24;
+ public:
+ static const uint16_t typeKey = 24;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t thicknessPropertyKey = 47;
- static const uint16_t capPropertyKey = 48;
- static const uint16_t joinPropertyKey = 49;
- static const uint16_t transformAffectsStrokePropertyKey = 50;
+ static const uint16_t thicknessPropertyKey = 47;
+ static const uint16_t capPropertyKey = 48;
+ static const uint16_t joinPropertyKey = 49;
+ static const uint16_t transformAffectsStrokePropertyKey = 50;
-private:
- float m_Thickness = 1.0f;
- uint32_t m_Cap = 0;
- uint32_t m_Join = 0;
- bool m_TransformAffectsStroke = true;
+ private:
+ float m_Thickness = 1.0f;
+ uint32_t m_Cap = 0;
+ uint32_t m_Join = 0;
+ bool m_TransformAffectsStroke = true;
-public:
- inline float thickness() const { return m_Thickness; }
- void thickness(float value) {
- if (m_Thickness == value) {
- return;
+ public:
+ inline float thickness() const { return m_Thickness; }
+ void thickness(float value) {
+ if (m_Thickness == value) {
+ return;
+ }
+ m_Thickness = value;
+ thicknessChanged();
}
- m_Thickness = value;
- thicknessChanged();
- }
- inline uint32_t cap() const { return m_Cap; }
- void cap(uint32_t value) {
- if (m_Cap == value) {
- return;
+ inline uint32_t cap() const { return m_Cap; }
+ void cap(uint32_t value) {
+ if (m_Cap == value) {
+ return;
+ }
+ m_Cap = value;
+ capChanged();
}
- m_Cap = value;
- capChanged();
- }
- inline uint32_t join() const { return m_Join; }
- void join(uint32_t value) {
- if (m_Join == value) {
- return;
+ inline uint32_t join() const { return m_Join; }
+ void join(uint32_t value) {
+ if (m_Join == value) {
+ return;
+ }
+ m_Join = value;
+ joinChanged();
}
- m_Join = value;
- joinChanged();
- }
- inline bool transformAffectsStroke() const { return m_TransformAffectsStroke; }
- void transformAffectsStroke(bool value) {
- if (m_TransformAffectsStroke == value) {
- return;
+ inline bool transformAffectsStroke() const { return m_TransformAffectsStroke; }
+ void transformAffectsStroke(bool value) {
+ if (m_TransformAffectsStroke == value) {
+ return;
+ }
+ m_TransformAffectsStroke = value;
+ transformAffectsStrokeChanged();
}
- m_TransformAffectsStroke = value;
- transformAffectsStrokeChanged();
- }
- Core* clone() const override;
- void copy(const StrokeBase& object) {
- m_Thickness = object.m_Thickness;
- m_Cap = object.m_Cap;
- m_Join = object.m_Join;
- m_TransformAffectsStroke = object.m_TransformAffectsStroke;
- ShapePaint::copy(object);
- }
+ Core* clone() const override;
+ void copy(const StrokeBase& object) {
+ m_Thickness = object.m_Thickness;
+ m_Cap = object.m_Cap;
+ m_Join = object.m_Join;
+ m_TransformAffectsStroke = object.m_TransformAffectsStroke;
+ ShapePaint::copy(object);
+ }
- 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 transformAffectsStrokePropertyKey:
- m_TransformAffectsStroke = CoreBoolType::deserialize(reader);
- return true;
+ 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 transformAffectsStrokePropertyKey:
+ m_TransformAffectsStroke = CoreBoolType::deserialize(reader);
+ return true;
+ }
+ return ShapePaint::deserialize(propertyKey, reader);
}
- return ShapePaint::deserialize(propertyKey, reader);
- }
-protected:
- virtual void thicknessChanged() {}
- virtual void capChanged() {}
- virtual void joinChanged() {}
- virtual void transformAffectsStrokeChanged() {}
-};
+ protected:
+ virtual void thicknessChanged() {}
+ virtual void capChanged() {}
+ virtual void joinChanged() {}
+ virtual void transformAffectsStrokeChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/core/field_types/core_uint_type.hpp"
namespace rive {
-class TrimPathBase : public Component {
-protected:
- typedef Component Super;
+ class TrimPathBase : public Component {
+ protected:
+ typedef Component Super;
-public:
- static const uint16_t typeKey = 47;
+ public:
+ static const uint16_t typeKey = 47;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TrimPathBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TrimPathBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t startPropertyKey = 114;
- static const uint16_t endPropertyKey = 115;
- static const uint16_t offsetPropertyKey = 116;
- static const uint16_t modeValuePropertyKey = 117;
+ static const uint16_t startPropertyKey = 114;
+ static const uint16_t endPropertyKey = 115;
+ static const uint16_t offsetPropertyKey = 116;
+ static const uint16_t modeValuePropertyKey = 117;
-private:
- float m_Start = 0.0f;
- float m_End = 0.0f;
- float m_Offset = 0.0f;
- uint32_t m_ModeValue = 0;
+ private:
+ float m_Start = 0.0f;
+ float m_End = 0.0f;
+ float m_Offset = 0.0f;
+ uint32_t m_ModeValue = 0;
-public:
- inline float start() const { return m_Start; }
- void start(float value) {
- if (m_Start == value) {
- return;
+ public:
+ inline float start() const { return m_Start; }
+ void start(float value) {
+ if (m_Start == value) {
+ return;
+ }
+ m_Start = value;
+ startChanged();
}
- m_Start = value;
- startChanged();
- }
- inline float end() const { return m_End; }
- void end(float value) {
- if (m_End == value) {
- return;
+ inline float end() const { return m_End; }
+ void end(float value) {
+ if (m_End == value) {
+ return;
+ }
+ m_End = value;
+ endChanged();
}
- m_End = value;
- endChanged();
- }
- inline float offset() const { return m_Offset; }
- void offset(float value) {
- if (m_Offset == value) {
- return;
+ inline float offset() const { return m_Offset; }
+ void offset(float value) {
+ if (m_Offset == value) {
+ return;
+ }
+ m_Offset = value;
+ offsetChanged();
}
- m_Offset = value;
- offsetChanged();
- }
- inline uint32_t modeValue() const { return m_ModeValue; }
- void modeValue(uint32_t value) {
- if (m_ModeValue == value) {
- return;
+ inline uint32_t modeValue() const { return m_ModeValue; }
+ void modeValue(uint32_t value) {
+ if (m_ModeValue == value) {
+ return;
+ }
+ m_ModeValue = value;
+ modeValueChanged();
}
- m_ModeValue = value;
- modeValueChanged();
- }
- Core* clone() const override;
- void copy(const TrimPathBase& object) {
- m_Start = object.m_Start;
- m_End = object.m_End;
- m_Offset = object.m_Offset;
- m_ModeValue = object.m_ModeValue;
- Component::copy(object);
- }
+ Core* clone() const override;
+ void copy(const TrimPathBase& object) {
+ m_Start = object.m_Start;
+ m_End = object.m_End;
+ m_Offset = object.m_Offset;
+ m_ModeValue = object.m_ModeValue;
+ 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);
}
- return Component::deserialize(propertyKey, reader);
- }
-protected:
- virtual void startChanged() {}
- virtual void endChanged() {}
- virtual void offsetChanged() {}
- virtual void modeValueChanged() {}
-};
+ protected:
+ virtual void startChanged() {}
+ virtual void endChanged() {}
+ virtual void offsetChanged() {}
+ virtual void modeValueChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/path.hpp"
namespace rive {
-class ParametricPathBase : public Path {
-protected:
- typedef Path Super;
+ class ParametricPathBase : public Path {
+ protected:
+ typedef Path Super;
-public:
- static const uint16_t typeKey = 15;
+ public:
+ static const uint16_t typeKey = 15;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t widthPropertyKey = 20;
- static const uint16_t heightPropertyKey = 21;
- static const uint16_t originXPropertyKey = 123;
- static const uint16_t originYPropertyKey = 124;
+ static const uint16_t widthPropertyKey = 20;
+ static const uint16_t heightPropertyKey = 21;
+ static const uint16_t originXPropertyKey = 123;
+ static const uint16_t originYPropertyKey = 124;
-private:
- float m_Width = 0.0f;
- float m_Height = 0.0f;
- float m_OriginX = 0.5f;
- float m_OriginY = 0.5f;
+ private:
+ float m_Width = 0.0f;
+ float m_Height = 0.0f;
+ float m_OriginX = 0.5f;
+ float m_OriginY = 0.5f;
-public:
- inline float width() const { return m_Width; }
- void width(float value) {
- if (m_Width == value) {
- return;
+ public:
+ inline float width() const { return m_Width; }
+ void width(float value) {
+ if (m_Width == value) {
+ return;
+ }
+ m_Width = value;
+ widthChanged();
}
- m_Width = value;
- widthChanged();
- }
- inline float height() const { return m_Height; }
- void height(float value) {
- if (m_Height == value) {
- return;
+ inline float height() const { return m_Height; }
+ void height(float value) {
+ if (m_Height == value) {
+ return;
+ }
+ m_Height = value;
+ heightChanged();
}
- m_Height = value;
- heightChanged();
- }
- inline float originX() const { return m_OriginX; }
- void originX(float value) {
- if (m_OriginX == value) {
- return;
+ inline float originX() const { return m_OriginX; }
+ void originX(float value) {
+ if (m_OriginX == value) {
+ return;
+ }
+ m_OriginX = value;
+ originXChanged();
}
- m_OriginX = value;
- originXChanged();
- }
- inline float originY() const { return m_OriginY; }
- void originY(float value) {
- if (m_OriginY == value) {
- return;
+ inline float originY() const { return m_OriginY; }
+ void originY(float value) {
+ if (m_OriginY == value) {
+ return;
+ }
+ m_OriginY = value;
+ originYChanged();
}
- m_OriginY = value;
- originYChanged();
- }
- void copy(const ParametricPathBase& object) {
- m_Width = object.m_Width;
- m_Height = object.m_Height;
- m_OriginX = object.m_OriginX;
- m_OriginY = object.m_OriginY;
- Path::copy(object);
- }
+ void copy(const ParametricPathBase& object) {
+ m_Width = object.m_Width;
+ m_Height = object.m_Height;
+ m_OriginX = object.m_OriginX;
+ m_OriginY = object.m_OriginY;
+ 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);
}
- return Path::deserialize(propertyKey, reader);
- }
-protected:
- virtual void widthChanged() {}
- virtual void heightChanged() {}
- virtual void originXChanged() {}
- virtual void originYChanged() {}
-};
+ protected:
+ virtual void widthChanged() {}
+ virtual void heightChanged() {}
+ virtual void originXChanged() {}
+ virtual void originYChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/node.hpp"
namespace rive {
-class PathBase : public Node {
-protected:
- typedef Node Super;
-
-public:
- static const uint16_t typeKey = 12;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class PathBase : public Node {
+ protected:
+ typedef Node Super;
+
+ public:
+ static const uint16_t typeKey = 12;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t pathFlagsPropertyKey = 128;
+ static const uint16_t pathFlagsPropertyKey = 128;
-private:
- uint32_t m_PathFlags = 0;
+ private:
+ uint32_t m_PathFlags = 0;
-public:
- inline uint32_t pathFlags() const { return m_PathFlags; }
- void pathFlags(uint32_t value) {
- if (m_PathFlags == value) {
- return;
+ public:
+ inline uint32_t pathFlags() const { return m_PathFlags; }
+ void pathFlags(uint32_t value) {
+ if (m_PathFlags == value) {
+ return;
+ }
+ m_PathFlags = value;
+ pathFlagsChanged();
}
- m_PathFlags = value;
- pathFlagsChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return Node::deserialize(propertyKey, reader);
}
- return Node::deserialize(propertyKey, reader);
- }
-protected:
- virtual void pathFlagsChanged() {}
-};
+ protected:
+ virtual void pathFlagsChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_PATH_VERTEX_BASE_HPP_
#include "rive/shapes/vertex.hpp"
namespace rive {
-class PathVertexBase : public Vertex {
-protected:
- typedef Vertex Super;
+ class PathVertexBase : public Vertex {
+ protected:
+ typedef Vertex Super;
-public:
- static const uint16_t typeKey = 14;
+ public:
+ static const uint16_t typeKey = 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 PathVertexBase::typeKey:
- case VertexBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_bool_type.hpp"
#include "rive/shapes/path.hpp"
namespace rive {
-class PointsPathBase : public Path {
-protected:
- typedef Path Super;
-
-public:
- static const uint16_t typeKey = 16;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class PointsPathBase : public Path {
+ protected:
+ typedef Path Super;
+
+ public:
+ static const uint16_t typeKey = 16;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t isClosedPropertyKey = 32;
+ static const uint16_t isClosedPropertyKey = 32;
-private:
- bool m_IsClosed = false;
+ private:
+ bool m_IsClosed = false;
-public:
- inline bool isClosed() const { return m_IsClosed; }
- void isClosed(bool value) {
- if (m_IsClosed == value) {
- return;
+ public:
+ inline bool isClosed() const { return m_IsClosed; }
+ void isClosed(bool value) {
+ if (m_IsClosed == value) {
+ return;
+ }
+ m_IsClosed = value;
+ isClosedChanged();
}
- m_IsClosed = value;
- isClosedChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return Path::deserialize(propertyKey, reader);
}
- return Path::deserialize(propertyKey, reader);
- }
-protected:
- virtual void isClosedChanged() {}
-};
+ protected:
+ virtual void isClosedChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_uint_type.hpp"
#include "rive/shapes/parametric_path.hpp"
namespace rive {
-class PolygonBase : public ParametricPath {
-protected:
- typedef ParametricPath Super;
+ class PolygonBase : public ParametricPath {
+ protected:
+ typedef ParametricPath Super;
-public:
- static const uint16_t typeKey = 51;
+ public:
+ static const uint16_t typeKey = 51;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case PolygonBase::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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case PolygonBase::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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t pointsPropertyKey = 125;
- static const uint16_t cornerRadiusPropertyKey = 126;
+ static const uint16_t pointsPropertyKey = 125;
+ static const uint16_t cornerRadiusPropertyKey = 126;
-private:
- uint32_t m_Points = 5;
- float m_CornerRadius = 0.0f;
+ private:
+ uint32_t m_Points = 5;
+ float m_CornerRadius = 0.0f;
-public:
- inline uint32_t points() const { return m_Points; }
- void points(uint32_t value) {
- if (m_Points == value) {
- return;
+ public:
+ inline uint32_t points() const { return m_Points; }
+ void points(uint32_t value) {
+ if (m_Points == value) {
+ return;
+ }
+ m_Points = value;
+ pointsChanged();
}
- m_Points = value;
- pointsChanged();
- }
- inline float cornerRadius() const { return m_CornerRadius; }
- void cornerRadius(float value) {
- if (m_CornerRadius == value) {
- return;
+ inline float cornerRadius() const { return m_CornerRadius; }
+ void cornerRadius(float value) {
+ if (m_CornerRadius == value) {
+ return;
+ }
+ m_CornerRadius = value;
+ cornerRadiusChanged();
}
- m_CornerRadius = value;
- cornerRadiusChanged();
- }
- Core* clone() const override;
- void copy(const PolygonBase& object) {
- m_Points = object.m_Points;
- m_CornerRadius = object.m_CornerRadius;
- ParametricPath::copy(object);
- }
+ Core* clone() const override;
+ 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;
- case cornerRadiusPropertyKey:
- m_CornerRadius = CoreDoubleType::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;
+ }
+ return ParametricPath::deserialize(propertyKey, reader);
}
- return ParametricPath::deserialize(propertyKey, reader);
- }
-protected:
- virtual void pointsChanged() {}
- virtual void cornerRadiusChanged() {}
-};
+ protected:
+ virtual void pointsChanged() {}
+ virtual void cornerRadiusChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/parametric_path.hpp"
namespace rive {
-class RectangleBase : public ParametricPath {
-protected:
- typedef ParametricPath Super;
+ class RectangleBase : public ParametricPath {
+ protected:
+ typedef ParametricPath Super;
-public:
- static const uint16_t typeKey = 7;
+ public:
+ static const uint16_t typeKey = 7;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case RectangleBase::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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case RectangleBase::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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t linkCornerRadiusPropertyKey = 164;
- static const uint16_t cornerRadiusTLPropertyKey = 31;
- static const uint16_t cornerRadiusTRPropertyKey = 161;
- static const uint16_t cornerRadiusBLPropertyKey = 162;
- static const uint16_t cornerRadiusBRPropertyKey = 163;
+ static const uint16_t linkCornerRadiusPropertyKey = 164;
+ static const uint16_t cornerRadiusTLPropertyKey = 31;
+ static const uint16_t cornerRadiusTRPropertyKey = 161;
+ static const uint16_t cornerRadiusBLPropertyKey = 162;
+ static const uint16_t cornerRadiusBRPropertyKey = 163;
-private:
- bool m_LinkCornerRadius = true;
- float m_CornerRadiusTL = 0.0f;
- float m_CornerRadiusTR = 0.0f;
- float m_CornerRadiusBL = 0.0f;
- float m_CornerRadiusBR = 0.0f;
+ private:
+ bool m_LinkCornerRadius = true;
+ float m_CornerRadiusTL = 0.0f;
+ float m_CornerRadiusTR = 0.0f;
+ float m_CornerRadiusBL = 0.0f;
+ float m_CornerRadiusBR = 0.0f;
-public:
- inline bool linkCornerRadius() const { return m_LinkCornerRadius; }
- void linkCornerRadius(bool value) {
- if (m_LinkCornerRadius == value) {
- return;
+ public:
+ inline bool linkCornerRadius() const { return m_LinkCornerRadius; }
+ void linkCornerRadius(bool value) {
+ if (m_LinkCornerRadius == value) {
+ return;
+ }
+ m_LinkCornerRadius = value;
+ linkCornerRadiusChanged();
}
- m_LinkCornerRadius = value;
- linkCornerRadiusChanged();
- }
- inline float cornerRadiusTL() const { return m_CornerRadiusTL; }
- void cornerRadiusTL(float value) {
- if (m_CornerRadiusTL == value) {
- return;
+ inline float cornerRadiusTL() const { return m_CornerRadiusTL; }
+ void cornerRadiusTL(float value) {
+ if (m_CornerRadiusTL == value) {
+ return;
+ }
+ m_CornerRadiusTL = value;
+ cornerRadiusTLChanged();
}
- m_CornerRadiusTL = value;
- cornerRadiusTLChanged();
- }
- inline float cornerRadiusTR() const { return m_CornerRadiusTR; }
- void cornerRadiusTR(float value) {
- if (m_CornerRadiusTR == value) {
- return;
+ inline float cornerRadiusTR() const { return m_CornerRadiusTR; }
+ void cornerRadiusTR(float value) {
+ if (m_CornerRadiusTR == value) {
+ return;
+ }
+ m_CornerRadiusTR = value;
+ cornerRadiusTRChanged();
}
- m_CornerRadiusTR = value;
- cornerRadiusTRChanged();
- }
- inline float cornerRadiusBL() const { return m_CornerRadiusBL; }
- void cornerRadiusBL(float value) {
- if (m_CornerRadiusBL == value) {
- return;
+ inline float cornerRadiusBL() const { return m_CornerRadiusBL; }
+ void cornerRadiusBL(float value) {
+ if (m_CornerRadiusBL == value) {
+ return;
+ }
+ m_CornerRadiusBL = value;
+ cornerRadiusBLChanged();
}
- m_CornerRadiusBL = value;
- cornerRadiusBLChanged();
- }
- inline float cornerRadiusBR() const { return m_CornerRadiusBR; }
- void cornerRadiusBR(float value) {
- if (m_CornerRadiusBR == value) {
- return;
+ inline float cornerRadiusBR() const { return m_CornerRadiusBR; }
+ void cornerRadiusBR(float value) {
+ if (m_CornerRadiusBR == value) {
+ return;
+ }
+ m_CornerRadiusBR = value;
+ cornerRadiusBRChanged();
}
- m_CornerRadiusBR = value;
- cornerRadiusBRChanged();
- }
- Core* clone() const override;
- void copy(const RectangleBase& object) {
- m_LinkCornerRadius = object.m_LinkCornerRadius;
- m_CornerRadiusTL = object.m_CornerRadiusTL;
- m_CornerRadiusTR = object.m_CornerRadiusTR;
- m_CornerRadiusBL = object.m_CornerRadiusBL;
- m_CornerRadiusBR = object.m_CornerRadiusBR;
- ParametricPath::copy(object);
- }
+ Core* clone() const override;
+ void copy(const RectangleBase& object) {
+ m_LinkCornerRadius = object.m_LinkCornerRadius;
+ m_CornerRadiusTL = object.m_CornerRadiusTL;
+ m_CornerRadiusTR = object.m_CornerRadiusTR;
+ m_CornerRadiusBL = object.m_CornerRadiusBL;
+ m_CornerRadiusBR = object.m_CornerRadiusBR;
+ ParametricPath::copy(object);
+ }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case linkCornerRadiusPropertyKey:
- m_LinkCornerRadius = CoreBoolType::deserialize(reader);
- return true;
- case cornerRadiusTLPropertyKey:
- m_CornerRadiusTL = CoreDoubleType::deserialize(reader);
- return true;
- case cornerRadiusTRPropertyKey:
- m_CornerRadiusTR = CoreDoubleType::deserialize(reader);
- return true;
- case cornerRadiusBLPropertyKey:
- m_CornerRadiusBL = CoreDoubleType::deserialize(reader);
- return true;
- case cornerRadiusBRPropertyKey:
- m_CornerRadiusBR = CoreDoubleType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case linkCornerRadiusPropertyKey:
+ m_LinkCornerRadius = CoreBoolType::deserialize(reader);
+ return true;
+ case cornerRadiusTLPropertyKey:
+ m_CornerRadiusTL = CoreDoubleType::deserialize(reader);
+ return true;
+ case cornerRadiusTRPropertyKey:
+ m_CornerRadiusTR = CoreDoubleType::deserialize(reader);
+ return true;
+ case cornerRadiusBLPropertyKey:
+ m_CornerRadiusBL = CoreDoubleType::deserialize(reader);
+ return true;
+ case cornerRadiusBRPropertyKey:
+ m_CornerRadiusBR = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return ParametricPath::deserialize(propertyKey, reader);
}
- return ParametricPath::deserialize(propertyKey, reader);
- }
-protected:
- virtual void linkCornerRadiusChanged() {}
- virtual void cornerRadiusTLChanged() {}
- virtual void cornerRadiusTRChanged() {}
- virtual void cornerRadiusBLChanged() {}
- virtual void cornerRadiusBRChanged() {}
-};
+ protected:
+ virtual void linkCornerRadiusChanged() {}
+ virtual void cornerRadiusTLChanged() {}
+ virtual void cornerRadiusTRChanged() {}
+ virtual void cornerRadiusBLChanged() {}
+ virtual void cornerRadiusBRChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_SHAPE_BASE_HPP_
#include "rive/drawable.hpp"
namespace rive {
-class ShapeBase : public Drawable {
-protected:
- typedef Drawable Super;
+ class ShapeBase : public Drawable {
+ protected:
+ typedef Drawable Super;
-public:
- static const uint16_t typeKey = 3;
+ public:
+ static const uint16_t typeKey = 3;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/polygon.hpp"
namespace rive {
-class StarBase : public Polygon {
-protected:
- typedef Polygon Super;
+ class StarBase : public Polygon {
+ protected:
+ typedef Polygon Super;
-public:
- static const uint16_t typeKey = 52;
+ public:
+ static const uint16_t typeKey = 52;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case StarBase::typeKey:
- case PolygonBase::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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case StarBase::typeKey:
+ case PolygonBase::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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t innerRadiusPropertyKey = 127;
+ static const uint16_t innerRadiusPropertyKey = 127;
-private:
- float m_InnerRadius = 0.5f;
+ private:
+ float m_InnerRadius = 0.5f;
-public:
- inline float innerRadius() const { return m_InnerRadius; }
- void innerRadius(float value) {
- if (m_InnerRadius == value) {
- return;
+ public:
+ inline float innerRadius() const { return m_InnerRadius; }
+ void innerRadius(float value) {
+ if (m_InnerRadius == value) {
+ return;
+ }
+ m_InnerRadius = value;
+ innerRadiusChanged();
}
- m_InnerRadius = value;
- innerRadiusChanged();
- }
- Core* clone() const override;
- void copy(const StarBase& object) {
- m_InnerRadius = object.m_InnerRadius;
- Polygon::copy(object);
- }
+ Core* clone() const override;
+ void copy(const StarBase& object) {
+ m_InnerRadius = object.m_InnerRadius;
+ Polygon::copy(object);
+ }
- bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
- switch (propertyKey) {
- case innerRadiusPropertyKey:
- m_InnerRadius = CoreDoubleType::deserialize(reader);
- return true;
+ bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
+ switch (propertyKey) {
+ case innerRadiusPropertyKey:
+ m_InnerRadius = CoreDoubleType::deserialize(reader);
+ return true;
+ }
+ return Polygon::deserialize(propertyKey, reader);
}
- return Polygon::deserialize(propertyKey, reader);
- }
-protected:
- virtual void innerRadiusChanged() {}
-};
+ protected:
+ virtual void innerRadiusChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/shapes/path_vertex.hpp"
namespace rive {
-class StraightVertexBase : public PathVertex {
-protected:
- typedef PathVertex Super;
-
-public:
- static const uint16_t typeKey = 5;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ class StraightVertexBase : public PathVertex {
+ protected:
+ typedef PathVertex Super;
+
+ public:
+ static const uint16_t typeKey = 5;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t radiusPropertyKey = 26;
+ static const uint16_t radiusPropertyKey = 26;
-private:
- float m_Radius = 0.0f;
+ private:
+ float m_Radius = 0.0f;
-public:
- inline float radius() const { return m_Radius; }
- void radius(float value) {
- if (m_Radius == value) {
- return;
+ public:
+ inline float radius() const { return m_Radius; }
+ void radius(float value) {
+ if (m_Radius == value) {
+ return;
+ }
+ m_Radius = value;
+ radiusChanged();
}
- m_Radius = value;
- radiusChanged();
- }
-
- Core* clone() const override;
- 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;
+
+ Core* clone() const override;
+ 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;
+ }
+ return PathVertex::deserialize(propertyKey, reader);
}
- return PathVertex::deserialize(propertyKey, reader);
- }
-protected:
- virtual void radiusChanged() {}
-};
+ protected:
+ virtual void radiusChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_TRIANGLE_BASE_HPP_
#include "rive/shapes/parametric_path.hpp"
namespace rive {
-class TriangleBase : public ParametricPath {
-protected:
- typedef ParametricPath Super;
+ class TriangleBase : public ParametricPath {
+ protected:
+ typedef ParametricPath Super;
-public:
- static const uint16_t typeKey = 8;
+ public:
+ static const uint16_t typeKey = 8;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case TriangleBase::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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case TriangleBase::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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- Core* clone() const override;
+ Core* clone() const override;
-protected:
-};
+ protected:
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/container_component.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class VertexBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
+ class VertexBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
-public:
- static const uint16_t typeKey = 107;
+ public:
+ static const uint16_t typeKey = 107;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case VertexBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case VertexBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t xPropertyKey = 24;
- static const uint16_t yPropertyKey = 25;
+ static const uint16_t xPropertyKey = 24;
+ static const uint16_t yPropertyKey = 25;
-private:
- float m_X = 0.0f;
- float m_Y = 0.0f;
+ private:
+ float m_X = 0.0f;
+ float m_Y = 0.0f;
-public:
- inline float x() const { return m_X; }
- void x(float value) {
- if (m_X == value) {
- return;
+ public:
+ inline float x() const { return m_X; }
+ void x(float value) {
+ if (m_X == value) {
+ return;
+ }
+ m_X = value;
+ xChanged();
}
- m_X = value;
- xChanged();
- }
- inline float y() const { return m_Y; }
- void y(float value) {
- if (m_Y == value) {
- return;
+ inline float y() const { return m_Y; }
+ void y(float value) {
+ if (m_Y == value) {
+ return;
+ }
+ m_Y = value;
+ yChanged();
}
- m_Y = value;
- yChanged();
- }
- void copy(const VertexBase& object) {
- m_X = object.m_X;
- m_Y = object.m_Y;
- ContainerComponent::copy(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);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void xChanged() {}
- virtual void yChanged() {}
-};
+ protected:
+ virtual void xChanged() {}
+ virtual void yChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/core/field_types/core_double_type.hpp"
#include "rive/world_transform_component.hpp"
namespace rive {
-class TransformComponentBase : public WorldTransformComponent {
-protected:
- typedef WorldTransformComponent Super;
+ class TransformComponentBase : public WorldTransformComponent {
+ protected:
+ typedef WorldTransformComponent Super;
-public:
- static const uint16_t typeKey = 38;
+ public:
+ static const uint16_t typeKey = 38;
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- 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;
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ 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;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t rotationPropertyKey = 15;
- static const uint16_t scaleXPropertyKey = 16;
- static const uint16_t scaleYPropertyKey = 17;
+ static const uint16_t rotationPropertyKey = 15;
+ static const uint16_t scaleXPropertyKey = 16;
+ static const uint16_t scaleYPropertyKey = 17;
-private:
- float m_Rotation = 0.0f;
- float m_ScaleX = 1.0f;
- float m_ScaleY = 1.0f;
+ private:
+ float m_Rotation = 0.0f;
+ float m_ScaleX = 1.0f;
+ float m_ScaleY = 1.0f;
-public:
- inline float rotation() const { return m_Rotation; }
- void rotation(float value) {
- if (m_Rotation == value) {
- return;
+ public:
+ inline float rotation() const { return m_Rotation; }
+ void rotation(float value) {
+ if (m_Rotation == value) {
+ return;
+ }
+ m_Rotation = value;
+ rotationChanged();
}
- m_Rotation = value;
- rotationChanged();
- }
- inline float scaleX() const { return m_ScaleX; }
- void scaleX(float value) {
- if (m_ScaleX == value) {
- return;
+ inline float scaleX() const { return m_ScaleX; }
+ void scaleX(float value) {
+ if (m_ScaleX == value) {
+ return;
+ }
+ m_ScaleX = value;
+ scaleXChanged();
}
- m_ScaleX = value;
- scaleXChanged();
- }
- inline float scaleY() const { return m_ScaleY; }
- void scaleY(float value) {
- if (m_ScaleY == value) {
- return;
+ inline float scaleY() const { return m_ScaleY; }
+ void scaleY(float value) {
+ if (m_ScaleY == value) {
+ return;
+ }
+ m_ScaleY = value;
+ scaleYChanged();
}
- m_ScaleY = value;
- scaleYChanged();
- }
- void copy(const TransformComponentBase& object) {
- m_Rotation = object.m_Rotation;
- m_ScaleX = object.m_ScaleX;
- m_ScaleY = object.m_ScaleY;
- WorldTransformComponent::copy(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);
}
- return WorldTransformComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void rotationChanged() {}
- virtual void scaleXChanged() {}
- virtual void scaleYChanged() {}
-};
+ protected:
+ virtual void rotationChanged() {}
+ virtual void scaleXChanged() {}
+ virtual void scaleYChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/container_component.hpp"
#include "rive/core/field_types/core_double_type.hpp"
namespace rive {
-class WorldTransformComponentBase : public ContainerComponent {
-protected:
- typedef ContainerComponent Super;
-
-public:
- static const uint16_t typeKey = 91;
-
- /// Helper to quickly determine if a core object extends another without RTTI
- /// at runtime.
- bool isTypeOf(uint16_t typeKey) const override {
- switch (typeKey) {
- case WorldTransformComponentBase::typeKey:
- case ContainerComponentBase::typeKey:
- case ComponentBase::typeKey: return true;
- default: return false;
+ class WorldTransformComponentBase : public ContainerComponent {
+ protected:
+ typedef ContainerComponent Super;
+
+ public:
+ static const uint16_t typeKey = 91;
+
+ /// Helper to quickly determine if a core object extends another without RTTI
+ /// at runtime.
+ bool isTypeOf(uint16_t typeKey) const override {
+ switch (typeKey) {
+ case WorldTransformComponentBase::typeKey:
+ case ContainerComponentBase::typeKey:
+ case ComponentBase::typeKey:
+ return true;
+ default:
+ return false;
+ }
}
- }
- uint16_t coreType() const override { return typeKey; }
+ uint16_t coreType() const override { return typeKey; }
- static const uint16_t opacityPropertyKey = 18;
+ static const uint16_t opacityPropertyKey = 18;
-private:
- float m_Opacity = 1.0f;
+ private:
+ float m_Opacity = 1.0f;
-public:
- inline float opacity() const { return m_Opacity; }
- void opacity(float value) {
- if (m_Opacity == value) {
- return;
+ public:
+ inline float opacity() const { return m_Opacity; }
+ void opacity(float value) {
+ if (m_Opacity == value) {
+ return;
+ }
+ m_Opacity = value;
+ opacityChanged();
}
- m_Opacity = value;
- opacityChanged();
- }
-
- 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;
+
+ 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;
+ }
+ return ContainerComponent::deserialize(propertyKey, reader);
}
- return ContainerComponent::deserialize(propertyKey, reader);
- }
-protected:
- virtual void opacityChanged() {}
-};
+ protected:
+ virtual void opacityChanged() {}
+ };
} // namespace rive
#endif
\ No newline at end of file
namespace rive {
-class NestedArtboard;
+ class NestedArtboard;
-struct HitInfo {
- IAABB area; // input
- std::vector<NestedArtboard*> mounts; // output
-};
+ struct HitInfo {
+ IAABB area; // input
+ std::vector<NestedArtboard*> mounts; // output
+ };
} // namespace rive
#endif
#include "rive/math/hit_test.hpp"
namespace rive {
-class HitTester;
+ class HitTester;
-class HitTestCommandPath : public CommandPath {
- HitTester m_Tester;
- Mat2D m_Xform;
- IAABB m_Area;
- FillRule m_FillRule = FillRule::nonZero;
+ class HitTestCommandPath : public CommandPath {
+ HitTester m_Tester;
+ Mat2D m_Xform;
+ IAABB m_Area;
+ FillRule m_FillRule = FillRule::nonZero;
-public:
- HitTestCommandPath(const IAABB& area);
+ public:
+ HitTestCommandPath(const IAABB& area);
- // can call this between calls to move/line/etc.
- void setXform(const Mat2D& xform) { m_Xform = xform; }
+ // can call this between calls to move/line/etc.
+ void setXform(const Mat2D& xform) { m_Xform = xform; }
- bool wasHit();
+ bool wasHit();
- // These 4 are not a good for the hit-tester
- void reset() override;
- void fillRule(FillRule value) override;
- void addPath(CommandPath* path, const Mat2D& transform) override;
- RenderPath* renderPath() override;
+ // These 4 are not a good for the hit-tester
+ void reset() override;
+ void fillRule(FillRule value) override;
+ void addPath(CommandPath* path, const Mat2D& transform) override;
+ RenderPath* renderPath() override;
- void moveTo(float x, float y) override;
- void lineTo(float x, float y) override;
- void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
- void close() override;
-};
+ void moveTo(float x, float y) override;
+ void lineTo(float x, float y) override;
+ void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
+ void close() override;
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class Core;
-class Artboard;
-class LinearAnimation;
-class StateMachine;
-class ArtboardImporter : public ImportStackObject {
-private:
- Artboard* m_Artboard;
+ class Core;
+ class Artboard;
+ class LinearAnimation;
+ class StateMachine;
+ class ArtboardImporter : public ImportStackObject {
+ private:
+ Artboard* m_Artboard;
-public:
- ArtboardImporter(Artboard* artboard);
- void addComponent(Core* object);
- void addAnimation(LinearAnimation* animation);
- void addStateMachine(StateMachine* stateMachine);
- StatusCode resolve() override;
- const Artboard* artboard() const { return m_Artboard; }
+ public:
+ ArtboardImporter(Artboard* artboard);
+ void addComponent(Core* object);
+ void addAnimation(LinearAnimation* animation);
+ void addStateMachine(StateMachine* stateMachine);
+ StatusCode resolve() override;
+ const Artboard* artboard() const { return m_Artboard; }
- bool readNullObject() override;
-};
+ bool readNullObject() override;
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class Artboard;
-class NestedArtboard;
-class Backboard;
-class FileAsset;
-class FileAssetReferencer;
-class BackboardImporter : public ImportStackObject {
-private:
- Backboard* m_Backboard;
- std::unordered_map<int, Artboard*> m_ArtboardLookup;
- std::vector<NestedArtboard*> m_NestedArtboards;
- std::vector<FileAsset*> m_FileAssets;
- std::vector<FileAssetReferencer*> m_FileAssetReferencers;
- int m_NextArtboardId;
+ class Artboard;
+ class NestedArtboard;
+ class Backboard;
+ class FileAsset;
+ class FileAssetReferencer;
+ class BackboardImporter : public ImportStackObject {
+ private:
+ Backboard* m_Backboard;
+ std::unordered_map<int, Artboard*> m_ArtboardLookup;
+ std::vector<NestedArtboard*> m_NestedArtboards;
+ std::vector<FileAsset*> m_FileAssets;
+ std::vector<FileAssetReferencer*> m_FileAssetReferencers;
+ int m_NextArtboardId;
-public:
- BackboardImporter(Backboard* backboard);
- void addArtboard(Artboard* artboard);
- void addMissingArtboard();
- void addNestedArtboard(NestedArtboard* artboard);
- void addFileAsset(FileAsset* asset);
- void addFileAssetReferencer(FileAssetReferencer* referencer);
+ public:
+ BackboardImporter(Backboard* backboard);
+ void addArtboard(Artboard* artboard);
+ void addMissingArtboard();
+ void addNestedArtboard(NestedArtboard* artboard);
+ void addFileAsset(FileAsset* asset);
+ void addFileAssetReferencer(FileAssetReferencer* referencer);
- StatusCode resolve() override;
- const Backboard* backboard() const { return m_Backboard; }
-};
+ StatusCode resolve() override;
+ const Backboard* backboard() const { return m_Backboard; }
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class FileAsset;
-class FileAssetContents;
-class FileAssetResolver;
-class Factory;
+ class FileAsset;
+ class FileAssetContents;
+ class FileAssetResolver;
+ class Factory;
-class FileAssetImporter : public ImportStackObject {
-private:
- bool m_LoadedContents = false;
- FileAsset* m_FileAsset;
- FileAssetResolver* m_FileAssetResolver;
- Factory* m_Factory;
- // we will delete this when we go out of scope
- std::unique_ptr<FileAssetContents> m_Content;
+ class FileAssetImporter : public ImportStackObject {
+ private:
+ bool m_LoadedContents = false;
+ FileAsset* m_FileAsset;
+ FileAssetResolver* m_FileAssetResolver;
+ Factory* m_Factory;
-public:
- FileAssetImporter(FileAsset*, FileAssetResolver*, Factory*);
- void loadContents(std::unique_ptr<FileAssetContents> contents);
- StatusCode resolve() override;
-};
+ public:
+ FileAssetImporter(FileAsset*, FileAssetResolver*, Factory*);
+ void loadContents(const FileAssetContents& contents);
+ StatusCode resolve() override;
+ };
} // namespace rive
#endif
#include <algorithm>
namespace rive {
-class ImportStackObject {
-public:
- virtual ~ImportStackObject() {}
- virtual StatusCode resolve() { return StatusCode::Ok; }
- virtual bool readNullObject() { return false; }
-};
+ class ImportStackObject {
+ public:
+ virtual ~ImportStackObject() {}
+ virtual StatusCode resolve() { return StatusCode::Ok; }
+ virtual bool readNullObject() { return false; }
+ };
-class ImportStack {
-private:
- std::unordered_map<uint16_t, ImportStackObject*> m_Latests;
- std::vector<ImportStackObject*> m_LastAdded;
+ 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) {
- auto itr = m_Latests.find(coreType);
- if (itr == m_Latests.end()) {
- return nullptr;
+ public:
+ template <typename T = ImportStackObject> T* latest(uint16_t coreType) {
+ auto itr = m_Latests.find(coreType);
+ if (itr == m_Latests.end()) {
+ return nullptr;
+ }
+ return reinterpret_cast<T*>(itr->second);
}
- return reinterpret_cast<T*>(itr->second);
- }
- 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()) {
- auto stackObject = itr->second;
+ 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()) {
+ auto stackObject = itr->second;
+
+ // Remove it from latests.
+ auto itr = std::find(m_LastAdded.begin(), m_LastAdded.end(), stackObject);
+ if (itr != m_LastAdded.end()) {
+ m_LastAdded.erase(itr);
+ }
- // Remove it from latests.
- auto itr = std::find(m_LastAdded.begin(), m_LastAdded.end(), stackObject);
- if (itr != m_LastAdded.end()) {
- m_LastAdded.erase(itr);
+ StatusCode code = stackObject->resolve();
+ delete stackObject;
+ if (code != StatusCode::Ok) {
+ m_Latests.erase(coreType);
+ return code;
+ }
}
- StatusCode code = stackObject->resolve();
- delete stackObject;
- if (code != StatusCode::Ok) {
+ // Set the new one.
+ if (object == nullptr) {
m_Latests.erase(coreType);
- return code;
+ } else {
+ m_Latests[coreType] = object;
+ m_LastAdded.push_back(object);
}
+ return StatusCode::Ok;
}
- // Set the new one.
- if (object == nullptr) {
- m_Latests.erase(coreType);
- } else {
- m_Latests[coreType] = object;
- m_LastAdded.push_back(object);
- }
- return StatusCode::Ok;
- }
-
- StatusCode resolve() {
- for (auto& pair : m_Latests) {
- StatusCode code = pair.second->resolve();
- if (code != StatusCode::Ok) {
- return code;
+ StatusCode resolve() {
+ for (auto& pair : m_Latests) {
+ StatusCode code = pair.second->resolve();
+ if (code != StatusCode::Ok) {
+ return code;
+ }
}
+ return StatusCode::Ok;
}
- return StatusCode::Ok;
- }
- ~ImportStack() {
- for (auto& pair : m_Latests) {
- delete pair.second;
+ ~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()) {
- return true;
+ bool readNullObject() {
+ for (auto itr = m_LastAdded.rbegin(); itr != m_LastAdded.rend(); itr++) {
+ if ((*itr)->readNullObject()) {
+ return true;
+ }
}
+ return false;
}
- return false;
- }
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/importers/import_stack.hpp"
namespace rive {
-class Core;
-class KeyedObject;
-class KeyedProperty;
-class KeyedObjectImporter : public ImportStackObject {
-private:
- KeyedObject* m_KeyedObject;
+ class Core;
+ class KeyedObject;
+ class KeyedProperty;
+ class KeyedObjectImporter : public ImportStackObject {
+ private:
+ KeyedObject* m_KeyedObject;
-public:
- KeyedObjectImporter(KeyedObject* keyedObject);
- void addKeyedProperty(std::unique_ptr<KeyedProperty>);
-};
+ public:
+ KeyedObjectImporter(KeyedObject* keyedObject);
+ void addKeyedProperty(std::unique_ptr<KeyedProperty>);
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class Core;
-class KeyFrame;
-class KeyedProperty;
-class LinearAnimation;
-class KeyedPropertyImporter : public ImportStackObject {
-private:
- LinearAnimation* m_Animation;
- KeyedProperty* m_KeyedProperty;
+ class Core;
+ class KeyFrame;
+ class KeyedProperty;
+ class LinearAnimation;
+ class KeyedPropertyImporter : public ImportStackObject {
+ private:
+ LinearAnimation* m_Animation;
+ KeyedProperty* m_KeyedProperty;
-public:
- KeyedPropertyImporter(LinearAnimation* animation, KeyedProperty* keyedProperty);
- void addKeyFrame(std::unique_ptr<KeyFrame>);
- bool readNullObject() override;
-};
+ public:
+ KeyedPropertyImporter(LinearAnimation* animation, KeyedProperty* keyedProperty);
+ void addKeyFrame(std::unique_ptr<KeyFrame>);
+ bool readNullObject() override;
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class LayerState;
-class StateTransition;
-class BlendAnimation;
+ class LayerState;
+ class StateTransition;
+ class BlendAnimation;
-class LayerStateImporter : public ImportStackObject {
-private:
- LayerState* m_State;
+ class LayerStateImporter : public ImportStackObject {
+ private:
+ LayerState* m_State;
-public:
- LayerStateImporter(LayerState* state);
- void addTransition(StateTransition* transition);
- bool addBlendAnimation(BlendAnimation* animation);
- StatusCode resolve() override;
-};
+ public:
+ LayerStateImporter(LayerState* state);
+ void addTransition(StateTransition* transition);
+ bool addBlendAnimation(BlendAnimation* animation);
+ StatusCode resolve() override;
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class Core;
-class LinearAnimation;
-class KeyedObject;
-class LinearAnimationImporter : public ImportStackObject {
-private:
- LinearAnimation* m_Animation;
+ class Core;
+ class LinearAnimation;
+ class KeyedObject;
+ class LinearAnimationImporter : public ImportStackObject {
+ private:
+ LinearAnimation* m_Animation;
-public:
- LinearAnimation* animation() const { return m_Animation; }
- LinearAnimationImporter(LinearAnimation* animation);
- void addKeyedObject(std::unique_ptr<KeyedObject>);
-};
+ public:
+ LinearAnimation* animation() const { return m_Animation; };
+ LinearAnimationImporter(LinearAnimation* animation);
+ void addKeyedObject(std::unique_ptr<KeyedObject>);
+ };
} // namespace rive
#endif
--- /dev/null
+#ifndef _RIVE_STATE_MACHINE_EVENT_IMPORTER_HPP_
+#define _RIVE_STATE_MACHINE_EVENT_IMPORTER_HPP_
+
+#include "rive/importers/import_stack.hpp"
+
+namespace rive {
+ class StateMachineEvent;
+ class StateMachine;
+ class EventInputChange;
+ class StateMachineEventImporter : public ImportStackObject {
+ private:
+ StateMachineEvent* m_StateMachineEvent;
+
+ public:
+ StateMachineEventImporter(StateMachineEvent* event);
+ const StateMachineEvent* stateMachineEvent() const { return m_StateMachineEvent; }
+ void addInputChange(EventInputChange* change);
+ StatusCode resolve() override;
+ };
+} // namespace rive
+#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class StateMachineInput;
-class StateMachineLayer;
-class StateMachineListener;
-class StateMachine;
-class StateMachineImporter : public ImportStackObject {
-private:
- StateMachine* m_StateMachine;
+ class StateMachineInput;
+ class StateMachineLayer;
+ class StateMachineEvent;
+ class StateMachine;
+ class StateMachineImporter : public ImportStackObject {
+ private:
+ StateMachine* m_StateMachine;
-public:
- StateMachineImporter(StateMachine* machine);
- const StateMachine* stateMachine() const { return m_StateMachine; }
+ public:
+ StateMachineImporter(StateMachine* machine);
+ const StateMachine* stateMachine() const { return m_StateMachine; }
- void addLayer(std::unique_ptr<StateMachineLayer>);
- void addInput(std::unique_ptr<StateMachineInput>);
- void addListener(std::unique_ptr<StateMachineListener>);
+ void addLayer(std::unique_ptr<StateMachineLayer>);
+ void addInput(std::unique_ptr<StateMachineInput>);
+ void addEvent(std::unique_ptr<StateMachineEvent>);
- StatusCode resolve() override;
- bool readNullObject() override;
-};
+ StatusCode resolve() override;
+ bool readNullObject() override;
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class StateMachineLayer;
-class LayerState;
-class Artboard;
+ class StateMachineLayer;
+ class LayerState;
+ class Artboard;
-class StateMachineLayerImporter : public ImportStackObject {
-private:
- StateMachineLayer* m_Layer;
- const Artboard* m_Artboard;
+ class StateMachineLayerImporter : public ImportStackObject {
+ private:
+ StateMachineLayer* m_Layer;
+ const Artboard* m_Artboard;
-public:
- StateMachineLayerImporter(StateMachineLayer* layer, const Artboard* artboard);
- void addState(LayerState* state);
- StatusCode resolve() override;
- bool readNullObject() override;
-};
+ public:
+ StateMachineLayerImporter(StateMachineLayer* layer, const Artboard* artboard);
+ void addState(LayerState* state);
+ StatusCode resolve() override;
+ bool readNullObject() override;
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class StateMachineListener;
-class StateMachine;
-class ListenerAction;
-class StateMachineListenerImporter : public ImportStackObject {
-private:
- StateMachineListener* m_StateMachineListener;
+ class StateMachineListener;
+ class StateMachine;
+ class ListenerAction;
+ class StateMachineListenerImporter : public ImportStackObject {
+ private:
+ StateMachineListener* m_StateMachineListener;
-public:
- StateMachineListenerImporter(StateMachineListener* listener);
- const StateMachineListener* stateMachineListener() const { return m_StateMachineListener; }
- void addAction(std::unique_ptr<ListenerAction>);
- StatusCode resolve() override;
-};
+ public:
+ StateMachineListenerImporter(StateMachineListener* listener);
+ const StateMachineListener* stateMachineListener() const { return m_StateMachineListener; }
+ void addAction(std::unique_ptr<ListenerAction>);
+ StatusCode resolve() override;
+ };
} // namespace rive
#endif
#include "rive/importers/import_stack.hpp"
namespace rive {
-class StateTransition;
-class TransitionCondition;
+ class StateTransition;
+ class TransitionCondition;
-class StateTransitionImporter : public ImportStackObject {
-private:
- StateTransition* m_Transition;
+ class StateTransitionImporter : public ImportStackObject {
+ private:
+ StateTransition* m_Transition;
-public:
- StateTransitionImporter(StateTransition* transition);
- void addCondition(TransitionCondition* condition);
- StatusCode resolve() override;
-};
+ public:
+ StateTransitionImporter(StateTransition* transition);
+ void addCondition(TransitionCondition* condition);
+ StatusCode resolve() override;
+ };
} // namespace rive
#endif
#ifndef _RIVE_LAYOUT_HPP_
#define _RIVE_LAYOUT_HPP_
namespace rive {
-enum class Fit : unsigned char { fill, contain, cover, fitWidth, fitHeight, none, scaleDown };
+ enum class Fit : unsigned char { fill, contain, cover, fitWidth, fitHeight, none, scaleDown };
-class Alignment {
-private:
- float m_X, m_Y;
+ class Alignment {
+ private:
+ float m_X, m_Y;
-public:
- Alignment(float x, float y) : m_X(x), m_Y(y) {}
+ public:
+ Alignment(float x, float y) : m_X(x), m_Y(y) {}
- float x() const { return m_X; }
- float y() const { return m_Y; }
+ float x() const { return m_X; }
+ float y() const { return m_Y; }
- static const Alignment topLeft;
- static const Alignment topCenter;
- static const Alignment topRight;
- static const Alignment centerLeft;
- static const Alignment center;
- static const Alignment centerRight;
- static const Alignment bottomLeft;
- static const Alignment bottomCenter;
- static const Alignment bottomRight;
-};
+ static const Alignment topLeft;
+ static const Alignment topCenter;
+ static const Alignment topRight;
+ static const Alignment centerLeft;
+ static const Alignment center;
+ static const Alignment centerRight;
+ static const Alignment bottomLeft;
+ static const Alignment bottomCenter;
+ static const Alignment bottomRight;
+ };
} // namespace rive
#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _RIVE_LISTENER_TYPE_HPP_
-#define _RIVE_LISTENER_TYPE_HPP_
-namespace rive {
-enum class ListenerType : int {
- enter = 0,
- exit = 1,
- down = 2,
- up = 3,
- move = 4,
-};
-}
-#endif
\ No newline at end of file
#include "rive/math/mat2d.hpp"
#include "rive/math/vec2d.hpp"
#include <cstddef>
-#include <limits>
namespace rive {
-struct IAABB {
- int32_t left, top, right, bottom;
-
- constexpr int width() const { return right - left; }
- constexpr int height() const { return bottom - top; }
- constexpr bool empty() const { return width() <= 0 || height() <= 0; }
-
- IAABB inset(int dx, int dy) const { return {left + dx, top + dy, right - dx, bottom - dy}; }
- IAABB offset(int dx, int dy) const { return {left + dx, top + dy, right + dx, bottom + dy}; }
-};
-
-class AABB {
-public:
- float minX, minY, maxX, maxY;
-
- AABB() : minX(0), minY(0), maxX(0), maxY(0) {}
- 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) {}
-
- 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 {
- return minX == o.minX && minY == o.minY && maxX == o.maxX && maxY == o.maxY;
- }
- bool operator!=(const AABB& o) const { return !(*this == o); }
-
- float left() const { return minX; }
- float top() const { return minY; }
- float right() const { return maxX; }
- float bottom() const { return maxY; }
-
- float width() const { return maxX - minX; }
- float height() const { return maxY - minY; }
- Vec2D size() const { return {width(), height()}; }
- Vec2D center() const { return {(minX + maxX) * 0.5f, (minY + maxY) * 0.5f}; }
-
- 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);
- return r;
- }
- AABB offset(float dx, float dy) const { return {minX + dx, minY + dy, maxX + dx, maxY + dy}; }
-
- IAABB round() const;
-
- ///
- /// 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() {
- return AABB(std::numeric_limits<float>::max(),
- std::numeric_limits<float>::max(),
- -std::numeric_limits<float>::max(),
- -std::numeric_limits<float>::max());
- }
-
- ///
- /// Grow the AABB to fit the point.
- ///
- static void expandTo(AABB& out, const Vec2D& point);
- static void expandTo(AABB& out, float x, float y);
-
- /// Join two AABBs.
- static void join(AABB& out, const AABB& a, const AABB& b);
-
- void expand(const AABB& other) { join(*this, *this, other); }
-};
+ struct IAABB {
+ int32_t left, top, right, bottom;
+
+ constexpr int width() const { return right - left; }
+ constexpr int height() const { return bottom - top; }
+ constexpr bool empty() const { return width() <= 0 || height() <= 0; }
+
+ IAABB inset(int dx, int dy) const { return {left + dx, top + dy, right - dx, bottom - dy}; }
+ IAABB offset(int dx, int dy) const {
+ return {left + dx, top + dy, right + dx, bottom + dy};
+ }
+ };
+
+ class AABB {
+ public:
+ float minX, minY, maxX, maxY;
+
+ AABB() : minX(0), minY(0), maxX(0), maxY(0) {}
+ 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) {}
+
+ 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 {
+ return minX == o.minX && minY == o.minY && maxX == o.maxX && maxY == o.maxY;
+ }
+ bool operator!=(const AABB& o) const { return !(*this == o); }
+
+ float left() const { return minX; }
+ float top() const { return minY; }
+ float right() const { return maxX; }
+ float bottom() const { return maxY; }
+
+ float width() const { return maxX - minX; }
+ float height() const { return maxY - minY; }
+ Vec2D size() const { return {width(), height()}; }
+ Vec2D center() const { return {(minX + maxX) * 0.5f, (minY + maxY) * 0.5f}; }
+
+ 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);
+ return r;
+ }
+ AABB offset(float dx, float dy) const {
+ return {minX + dx, minY + dy, maxX + dx, maxY + dy};
+ }
+
+ IAABB round() const;
+ };
} // namespace rive
#endif
#include "rive/rive_types.hpp"
namespace rive {
-constexpr float circleConstant = 0.552284749831f;
-constexpr float icircleConstant = 1.0f - circleConstant;
+ constexpr float circleConstant = 0.552284749831f;
+ constexpr float icircleConstant = 1.0f - circleConstant;
} // namespace rive
#endif
--- /dev/null
+#ifndef _RIVE_COLOR_HPP_
+#define _RIVE_COLOR_HPP_
+
+#include "rive/rive_types.hpp"
+
+namespace rive {
+ class Color {
+ private:
+ float m_Buffer[4];
+
+ public:
+ Color() : m_Buffer{1.0f, 1.0f, 1.0f, 1.0f} {}
+
+ Color(float r, float g, float b) : m_Buffer{r, g, b, 1.0f} {}
+
+ Color(float r, float g, float b, float a) : m_Buffer{r, g, b, a} {}
+
+ Color(int r, int g, int b, int a) :
+ m_Buffer{r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f} {}
+
+ Color(int r, int g, int b) : m_Buffer{r / 255.0f, g / 255.0f, b / 255.0f, 1.0f} {}
+
+ Color(float rgba) : m_Buffer{rgba, rgba, rgba, rgba} {}
+
+ inline const float* values() const { return m_Buffer; }
+
+ float& operator[](std::size_t idx) { return m_Buffer[idx]; }
+ const float& operator[](std::size_t idx) const { return m_Buffer[idx]; }
+ bool operator==(const Color& b) const {
+ return m_Buffer[0] == b[0] && m_Buffer[1] == b[1] && m_Buffer[2] == b[2] &&
+ m_Buffer[3] == b[3];
+ }
+
+ void set(float r, float g, float b, float a) {
+ m_Buffer[0] = r;
+ m_Buffer[1] = g;
+ m_Buffer[2] = b;
+ m_Buffer[3] = a;
+ }
+
+ void lerp(const Color& second, float amount) {
+ float iamount = 1.0f - amount;
+ for (int i = 0; i < 4; i++) {
+ m_Buffer[i] = second.m_Buffer[i] * amount + m_Buffer[i] * iamount;
+ }
+ }
+
+ void multiply(const Color& second) {
+ for (int i = 0; i < 4; i++) {
+ m_Buffer[i] *= second.m_Buffer[i];
+ }
+ }
+
+ void copy(const Color& second) {
+ for (int i = 0; i < 4; i++) {
+ m_Buffer[i] = second.m_Buffer[i];
+ }
+ }
+
+ void red(float r) { m_Buffer[0] = r; }
+ void green(float r) { m_Buffer[1] = r; }
+ void blue(float r) { m_Buffer[2] = r; }
+ void alpha(float r) { m_Buffer[3] = r; }
+
+ float red() const { return m_Buffer[0]; }
+ float green() const { return m_Buffer[1]; }
+ float blue() const { return m_Buffer[2]; }
+ float alpha() const { return m_Buffer[3]; }
+
+ float r() const { return m_Buffer[0]; }
+ float g() const { return m_Buffer[1]; }
+ float b() const { return m_Buffer[2]; }
+ float a() const { return m_Buffer[3]; }
+ };
+} // namespace rive
+#endif
namespace rive {
-class ContourMeasure : public RefCnt {
-public:
- static constexpr unsigned kMaxDot30 = (1 << 30) - 1;
- static constexpr float kInvScaleD30 = 1.0f / (float)kMaxDot30;
+ class ContourMeasure : public RefCnt {
+ public:
+ static constexpr unsigned kMaxDot30 = (1 << 30) - 1;
+ static constexpr float kInvScaleD30 = 1.0f / kMaxDot30;
- // Deliberately making this pack well (12 bytes)
- 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
- unsigned m_type : 2; // [private enum]
+ // Deliberately making this pack well (12 bytes)
+ 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
+ unsigned m_type : 2; // [private enum]
- float getT() const { return m_tValue * kInvScaleD30; }
+ float getT() const { return m_tValue * kInvScaleD30; }
- bool operator<(const Segment& other) const { return m_distance < other.m_distance; }
+ bool operator<(const Segment& other) const { return m_distance < other.m_distance; }
- void extract(RawPath* dst, float fromT, float toT, const Vec2D pts[], bool moveTo) const;
- void extract(RawPath* dst, const Vec2D pts[]) const;
- };
+ void
+ extract(RawPath* dst, float fromT, float toT, const Vec2D pts[], bool moveTo) const;
+ void extract(RawPath* dst, const Vec2D pts[]) const;
+ };
-private:
- size_t findSegment(float distance) const;
+ private:
+ size_t findSegment(float distance) const;
- std::vector<Segment> m_segments;
- std::vector<Vec2D> m_points;
- const float m_length;
- const bool m_isClosed;
+ std::vector<Segment> m_segments;
+ std::vector<Vec2D> m_points;
+ const float m_length;
+ const bool m_isClosed;
- ContourMeasure(std::vector<Segment>&&, std::vector<Vec2D>&&, float length, bool isClosed);
+ ContourMeasure(std::vector<Segment>&&, std::vector<Vec2D>&&, float length, bool isClosed);
- friend class ContourMeasureIter;
+ friend class ContourMeasureIter;
-public:
- float length() const { return m_length; }
- bool isClosed() const { return m_isClosed; }
+ public:
+ float length() const { return m_length; }
+ bool isClosed() const { return m_isClosed; }
- struct PosTan {
- Vec2D pos, tan;
- };
- PosTan getPosTan(float distance) const;
+ struct PosTan {
+ Vec2D pos, tan;
+ };
+ PosTan getPosTan(float distance) const;
- void getSegment(float startDistance, float endDistance, RawPath* dst, bool startWithMove) const;
+ void
+ getSegment(float startDistance, float endDistance, RawPath* dst, bool startWithMove) const;
- Vec2D warp(Vec2D src) const {
- const auto result = this->getPosTan(src.x);
- return {
- result.pos.x - result.tan.y * src.y,
- result.pos.y + result.tan.x * src.y,
- };
- }
-
- void dump() const;
-};
-
-class ContourMeasureIter {
- RawPath m_optionalCopy;
- RawPath::Iter m_iter;
- const Vec2D* m_srcPoints;
- float m_invTolerance;
-
- float addQuadSegs(std::vector<ContourMeasure::Segment>&,
- const Vec2D[],
- uint32_t ptIndex,
- float distance) const;
- float addCubicSegs(std::vector<ContourMeasure::Segment>&,
- const Vec2D[],
- uint32_t ptIndex,
- float distance) const;
- rcp<ContourMeasure> tryNext();
-
-public:
- // Tolerance is the max deviation of the curve from its approximating line
- // segments. A smaller tolerance means more line segments, but a better
- // approximation for the curves actual length.
- static constexpr float kDefaultTolerance = 0.5f;
-
- ContourMeasureIter(const RawPath& path, float tol = kDefaultTolerance) {
- this->reset(path, tol);
- }
-
- void reset(const RawPath&, float = kDefaultTolerance);
-
- // Returns a measure object for each contour in the path
- // (contours with zero-length are skipped over)
- // and then returns nullptr when its finished.
- //
- // ContourMeasureIter iter(path);
- // while ((auto meas = iter.next())) {
- // ... meas can be used, and passed to other objects
- // }
- //
- // Each measure object is stand-alone, and can outlive the ContourMeasureIter
- // that created it. It contains no back pointers to the Iter or to the path.
- //
- rcp<ContourMeasure> next();
-};
+ Vec2D warp(Vec2D src) const {
+ const auto result = this->getPosTan(src.x);
+ return {
+ result.pos.x - result.tan.y * src.y,
+ result.pos.y + result.tan.x * src.y,
+ };
+ }
+
+ void dump() const;
+ };
+
+ class ContourMeasureIter {
+ RawPath m_optionalCopy;
+ RawPath::Iter m_iter;
+ const Vec2D* m_srcPoints;
+ float m_invTolerance;
+
+ float addQuadSegs(std::vector<ContourMeasure::Segment>&,
+ const Vec2D[],
+ uint32_t ptIndex,
+ float distance) const;
+ float addCubicSegs(std::vector<ContourMeasure::Segment>&,
+ const Vec2D[],
+ uint32_t ptIndex,
+ float distance) const;
+ rcp<ContourMeasure> tryNext();
+
+ public:
+ // Tolerance is the max deviation of the curve from its approximating line
+ // segments. A smaller tolerance means more line segments, but a better
+ // approximation for the curves actual length.
+ static constexpr float kDefaultTolerance = 0.5f;
+
+ ContourMeasureIter(const RawPath& path, float tol = kDefaultTolerance) {
+ this->reset(path, tol);
+ }
+
+ void reset(const RawPath&, float = kDefaultTolerance);
+
+ // Returns a measure object for each contour in the path
+ // (contours with zero-length are skipped over)
+ // and then returns nullptr when its finished.
+ //
+ // ContourMeasureIter iter(path);
+ // while ((auto meas = iter.next())) {
+ // ... meas can be used, and passed to other objects
+ // }
+ //
+ // Each measure object is stand-alone, and can outlive the ContourMeasureIter
+ // that created it. It contains no back pointers to the Iter or to the path.
+ //
+ rcp<ContourMeasure> next();
+ };
} // namespace rive
#include <algorithm>
namespace rive {
-///
-/// Utility functions for recursively subdividing a cubic.
-///
-class CubicUtilities {
-public:
- static void computeHull(const Vec2D& from,
- const Vec2D& fromOut,
- const Vec2D& toIn,
- const Vec2D& to,
- float t,
- Vec2D* hull) {
- hull[0] = Vec2D::lerp(from, fromOut, t);
- hull[1] = Vec2D::lerp(fromOut, toIn, t);
- hull[2] = Vec2D::lerp(toIn, to, t);
-
- hull[3] = Vec2D::lerp(hull[0], hull[1], t);
- hull[4] = Vec2D::lerp(hull[1], hull[2], t);
-
- hull[5] = Vec2D::lerp(hull[3], hull[4], t);
- }
-
- 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;
- }
-
- static bool shouldSplitCubic(const Vec2D& from,
- const Vec2D& fromOut,
- const Vec2D& toIn,
- const Vec2D& to,
- 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) {
- 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;
- return value;
- }
-};
+ ///
+ /// Utility functions for recursively subdividing a cubic.
+ ///
+ class CubicUtilities {
+ public:
+ static void computeHull(const Vec2D& from,
+ const Vec2D& fromOut,
+ const Vec2D& toIn,
+ const Vec2D& to,
+ float t,
+ Vec2D* hull) {
+ hull[0] = Vec2D::lerp(from, fromOut, t);
+ hull[1] = Vec2D::lerp(fromOut, toIn, t);
+ hull[2] = Vec2D::lerp(toIn, to, t);
+
+ hull[3] = Vec2D::lerp(hull[0], hull[1], t);
+ hull[4] = Vec2D::lerp(hull[1], hull[2], t);
+
+ hull[5] = Vec2D::lerp(hull[3], hull[4], t);
+ }
+
+ 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;
+ }
+
+ static bool shouldSplitCubic(const Vec2D& from,
+ const Vec2D& fromOut,
+ const Vec2D& toIn,
+ const Vec2D& to,
+ 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) {
+ 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;
+ return value;
+ }
+ };
} // namespace rive
#endif
\ No newline at end of file
namespace rive {
-class HitTester {
- std::vector<int> m_DW; // width * height delta-windings
- Vec2D m_First, m_Prev;
- Vec2D m_offset;
- float m_height;
- int m_IWidth, m_IHeight;
- bool m_ExpectsMove;
+ class HitTester {
+ std::vector<int> m_DW; // width * height delta-windings
+ Vec2D m_First, m_Prev;
+ Vec2D m_offset;
+ float m_height;
+ int m_IWidth, m_IHeight;
+ bool m_ExpectsMove;
- void recurse_cubic(Vec2D b, Vec2D c, Vec2D d, int count);
+ void recurse_cubic(Vec2D b, Vec2D c, Vec2D d, int count);
-public:
- HitTester() {}
- HitTester(const IAABB& area) { reset(area); }
+ public:
+ HitTester() {}
+ HitTester(const IAABB& area) { reset(area); }
- void reset();
- void reset(const IAABB& area);
+ void reset();
+ void reset(const IAABB& area);
- void move(Vec2D);
- void line(Vec2D);
- void quad(Vec2D, Vec2D);
- void cubic(Vec2D, Vec2D, Vec2D);
- void close();
+ void move(Vec2D);
+ void line(Vec2D);
+ void quad(Vec2D, Vec2D);
+ void cubic(Vec2D, Vec2D, Vec2D);
+ void close();
- void addRect(const AABB&, const Mat2D&, PathDirection = PathDirection::ccw);
+ void addRect(const AABB&, const Mat2D&, PathDirection = PathDirection::ccw);
- bool test(FillRule = rive::FillRule::nonZero);
+ bool test(FillRule = rive::FillRule::nonZero);
- static bool testMesh(Vec2D point, Span<Vec2D> verts, Span<uint16_t> indices);
- static bool testMesh(const IAABB&, Span<Vec2D> verts, Span<uint16_t> indices);
-};
+ static bool testMesh(Vec2D point, Span<Vec2D> verts, Span<uint16_t> indices);
+ static bool testMesh(const IAABB&, Span<Vec2D> verts, Span<uint16_t> indices);
+ };
} // namespace rive
#endif
#include <cstddef>
namespace rive {
-class TransformComponents;
-class Mat2D {
-private:
- float m_Buffer[6];
-
-public:
- Mat2D() : m_Buffer{1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f} {}
- Mat2D(const Mat2D& copy) = default;
- Mat2D(float x1, float y1, float x2, float y2, float tx, float ty) :
- m_Buffer{x1, y1, x2, y2, tx, ty} {}
-
- inline const float* values() const { return m_Buffer; }
-
- float& operator[](std::size_t idx) { return m_Buffer[idx]; }
- const float& operator[](std::size_t idx) const { return m_Buffer[idx]; }
-
- static Mat2D fromRotation(float rad);
- static Mat2D fromScale(float sx, float sy) { return {sx, 0, 0, sy, 0, 0}; }
- static Mat2D fromTranslate(float tx, float ty) { return {1, 0, 0, 1, tx, ty}; }
-
- void scaleByValues(float sx, float sy);
+ class TransformComponents;
+ class Mat2D {
+ private:
+ float m_Buffer[6];
+
+ public:
+ Mat2D() : m_Buffer{1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f} {}
+ Mat2D(const Mat2D& copy) = default;
+ Mat2D(float x1, float y1, float x2, float y2, float tx, float ty) :
+ m_Buffer{x1, y1, x2, y2, tx, ty} {}
+
+ inline const float* values() const { return m_Buffer; }
+
+ float& operator[](std::size_t idx) { return m_Buffer[idx]; }
+ const float& operator[](std::size_t idx) const { return m_Buffer[idx]; }
+
+ static Mat2D fromRotation(float rad);
+ static Mat2D fromScale(float sx, float sy) { return {sx, 0, 0, sy, 0, 0}; }
+ static Mat2D fromTranslate(float tx, float ty) { return {1, 0, 0, 1, tx, ty}; }
+
+ void scaleByValues(float sx, float sy);
+
+ Mat2D& operator*=(const Mat2D& rhs) {
+ *this = Mat2D::multiply(*this, rhs);
+ return *this;
+ }
+
+ // If returns true, result holds the inverse.
+ // If returns false, result is unchnaged.
+ bool invert(Mat2D* result) const;
+
+ Mat2D invertOrIdentity() const {
+ Mat2D inverse; // initialized to identity
+ (void)invert(&inverse); // inverse is unchanged if invert() fails
+ return inverse;
+ }
+
+ TransformComponents decompose() const;
+ static Mat2D compose(const TransformComponents&);
+ Mat2D scale(Vec2D) const;
+
+ static Mat2D multiply(const Mat2D& a, const Mat2D& b);
+
+ float xx() const { return m_Buffer[0]; }
+ float xy() const { return m_Buffer[1]; }
+ float yx() const { return m_Buffer[2]; }
+ float yy() const { return m_Buffer[3]; }
+ float tx() const { return m_Buffer[4]; }
+ float ty() const { return m_Buffer[5]; }
+
+ Vec2D translation() const { return {m_Buffer[4], m_Buffer[5]}; }
+
+ void xx(float value) { m_Buffer[0] = value; }
+ void xy(float value) { m_Buffer[1] = value; }
+ void yx(float value) { m_Buffer[2] = value; }
+ void yy(float value) { m_Buffer[3] = value; }
+ void tx(float value) { m_Buffer[4] = value; }
+ void ty(float value) { m_Buffer[5] = value; }
+ };
- Mat2D& operator*=(const Mat2D& rhs) {
- *this = Mat2D::multiply(*this, rhs);
- return *this;
+ 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],
+ };
}
- // If returns true, result holds the inverse.
- // If returns false, result is unchnaged.
- bool invert(Mat2D* result) const;
+ inline Mat2D operator*(const Mat2D& a, const Mat2D& b) { return Mat2D::multiply(a, b); }
- Mat2D invertOrIdentity() const {
- Mat2D inverse; // initialized to identity
- (void)invert(&inverse); // inverse is unchanged if invert() fails
- return inverse;
+ 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];
}
-
- TransformComponents decompose() const;
- static Mat2D compose(const TransformComponents&);
- Mat2D scale(Vec2D) const;
-
- static Mat2D multiply(const Mat2D& a, const Mat2D& b);
-
- float xx() const { return m_Buffer[0]; }
- float xy() const { return m_Buffer[1]; }
- float yx() const { return m_Buffer[2]; }
- float yy() const { return m_Buffer[3]; }
- float tx() const { return m_Buffer[4]; }
- float ty() const { return m_Buffer[5]; }
-
- Vec2D translation() const { return {m_Buffer[4], m_Buffer[5]}; }
-
- void xx(float value) { m_Buffer[0] = value; }
- void xy(float value) { m_Buffer[1] = value; }
- void yx(float value) { m_Buffer[2] = value; }
- void yy(float value) { m_Buffer[3] = value; }
- void tx(float value) { m_Buffer[4] = value; }
- void ty(float value) { m_Buffer[5] = value; }
-};
-
-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],
- };
-}
-
-inline Mat2D operator*(const Mat2D& a, const Mat2D& b) { return Mat2D::multiply(a, b); }
-
-inline bool operator==(const Mat2D& a, const Mat2D& b) {
- return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3] && a[4] == b[4] &&
- a[5] == b[5];
-}
-
-inline bool operator!=(const Mat2D& a, const Mat2D& b) { return !(a == b); }
-
} // namespace rive
#endif
namespace rive {
namespace math {
-constexpr float PI = 3.14159265f;
+ constexpr float PI = 3.14159265f;
}
-template <typename T> T lerp(const T& a, const T& b, float t) { return a + (b - a) * t; }
-
-} // namespace rive
+}
#endif
namespace rive {
-enum class FillRule {
- nonZero,
- evenOdd,
-};
-
-enum class PathDirection {
- cw,
- ccw,
- // aliases
- clockwise = cw,
- counterclockwise = ccw,
-};
-
-enum class PathVerb : uint8_t {
- // These deliberately match Skia's values
- move = 0,
- line = 1,
- quad = 2,
- // conic
- cubic = 4,
- close = 5,
-};
-
-int path_verb_to_point_count(PathVerb);
+ enum class FillRule {
+ nonZero,
+ evenOdd,
+ };
+
+ enum class PathDirection {
+ cw,
+ ccw,
+ // aliases
+ clockwise = cw,
+ counterclockwise = ccw,
+ };
+
+ enum class PathVerb : uint8_t {
+ move,
+ line,
+ quad,
+ conic_unused, // so we match skia's order
+ cubic,
+ close,
+ };
} // namespace rive
#endif
namespace rive {
-class CommandPath;
-
-class RawPath {
-public:
- std::vector<Vec2D> m_Points;
- std::vector<PathVerb> m_Verbs;
-
- // Construct a RawPath from count points and verbs.
- RawPath(Span<const Vec2D> points, Span<const PathVerb> verbs);
- RawPath() {}
-
- bool operator==(const RawPath& o) const;
- bool operator!=(const RawPath& o) const { return !(*this == o); }
-
- bool empty() const { return m_Points.empty(); }
- AABB bounds() const;
-
- void move(Vec2D);
- void line(Vec2D);
- void quad(Vec2D, Vec2D);
- void cubic(Vec2D, Vec2D, Vec2D);
- void close();
-
- // Makes the path empty and frees any memory allocated by the drawing
- // (line, curve, move, close) calls.
- void reset();
-
- // Makes the path empty but keeps the memory for the drawing calls reserved.
- void rewind();
-
- RawPath transform(const Mat2D&) const;
- void transformInPlace(const Mat2D&);
- RawPath operator*(const Mat2D& mat) const { return this->transform(mat); }
-
- Span<const Vec2D> points() const { return m_Points; }
- Span<Vec2D> points() { return m_Points; }
-
- Span<const PathVerb> verbs() const { return m_Verbs; }
- Span<PathVerb> verbs() { return m_Verbs; }
+ class RawPath {
+ public:
+ std::vector<Vec2D> m_Points;
+ std::vector<PathVerb> m_Verbs;
- 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());
- }
+ RawPath() {}
+ ~RawPath() {}
- // Syntactic sugar for x,y -vs- vec2d
+ bool empty() const { return m_Points.empty(); }
+ AABB bounds() const;
- void moveTo(float x, float y) { move({x, y}); }
- void lineTo(float x, float y) { line({x, y}); }
- void quadTo(float x, float y, float x1, float y1) { quad({x, y}, {x1, y1}); }
- void cubicTo(float x, float y, float x1, float y1, float x2, float y2) {
- cubic({x, y}, {x1, y1}, {x2, y2});
- }
+ void move(Vec2D);
+ void line(Vec2D);
+ void quad(Vec2D, Vec2D);
+ void cubic(Vec2D, Vec2D, Vec2D);
+ void close();
- // Helpers for adding new contours
+ RawPath transform(const Mat2D&) const;
+ void transformInPlace(const Mat2D&);
- void addRect(const AABB&, PathDirection = PathDirection::cw);
- void addOval(const AABB&, PathDirection = PathDirection::cw);
- void addPoly(Span<const Vec2D>, bool isClosed);
+ Span<const Vec2D> points() const { return toSpan(m_Points); }
+ Span<Vec2D> points() { return toSpan(m_Points); }
- void addPath(const RawPath&, const Mat2D* = nullptr);
+ Span<const PathVerb> verbs() const { return toSpan(m_Verbs); }
+ Span<PathVerb> verbs() { return toSpan(m_Verbs); }
- class Iter {
- const Vec2D* m_currPts;
- const PathVerb* m_currVerb;
- const PathVerb* m_stopVerb; // 1 past last verb
- public:
- Iter() : m_currPts(nullptr), m_currVerb(nullptr), m_stopVerb(nullptr) {}
- Iter(const RawPath& path) { this->reset(path); }
+ // Syntactic sugar for x,y -vs- vec2d
- void reset(const RawPath& path) {
- m_currPts = path.m_Points.data();
- m_currVerb = path.m_Verbs.data();
- m_stopVerb = path.m_Verbs.data() + path.m_Verbs.size();
+ void moveTo(float x, float y) { move({x, y}); }
+ void lineTo(float x, float y) { line({x, y}); }
+ void quadTo(float x, float y, float x1, float y1) { quad({x, y}, {x1, y1}); }
+ void cubicTo(float x, float y, float x1, float y1, float x2, float y2) {
+ cubic({x, y}, {x1, y1}, {x2, y2});
}
- // returns true iff next() will return false
- bool isDone() const { return m_currVerb >= m_stopVerb; }
-
- struct Rec {
- const Vec2D* pts;
- int count;
- PathVerb verb;
+ // Helpers for adding new contours
- operator bool() const { return pts != nullptr; }
- };
- Rec next();
-
- void backUp();
+ void addRect(const AABB&, PathDirection = PathDirection::cw);
+ void addOval(const AABB&, PathDirection = PathDirection::cw);
+ void addPoly(Span<const Vec2D>, bool isClosed);
};
- template <typename Handler> RawPath morph(Handler proc) const {
- RawPath dst;
- // todo: dst.reserve(src.ptCount, src.verbCount);
- RawPath::Iter iter(*this);
- while (auto rec = iter.next()) {
- Vec2D pts[3];
- for (int i = 0; i < rec.count; ++i) {
- pts[i] = proc(rec.pts[i]);
- }
- switch (rec.verb) {
- case PathVerb::move: dst.move(pts[0]); break;
- case PathVerb::line: dst.line(pts[0]); break;
- case PathVerb::quad: dst.quad(pts[0], pts[1]); break;
- case PathVerb::cubic: dst.cubic(pts[0], pts[1], pts[2]); break;
- case PathVerb::close: dst.close(); break;
- }
- }
- return dst;
- }
-
- // Utility for pouring a RawPath into a CommandPath
- void addTo(CommandPath*) const;
-};
-
} // namespace rive
#endif
#include "rive/math/vec2d.hpp"
namespace rive {
-static inline Vec2D two(Vec2D v) { return v + v; }
+ static inline Vec2D two(Vec2D v) { return v + v; }
-// Caches the setup to evaluate a quadratic bezier. Useful if you
-// want to evaluate the save curve at multiple t values.
-// clang-format off
+ // Caches the setup to evaluate a quadratic bezier. Useful if you
+ // want to evaluate the save curve at multiple t values.
+ // clang-format off
struct EvalQuad {
const Vec2D a, b, c; // at^2 + bt + c
Vec2D operator()(float t) const { return (a * t + b) * t + c; }
};
-// clang-format on
+ // clang-format on
-// Caches the setup to evaluate a cubic bezier. Useful if you
-// want to evaluate the save curve at multiple t values.
-struct EvalCubic {
- const Vec2D a, b, c, d; // at^3 + bt^2 + ct + d
+ // Caches the setup to evaluate a cubic bezier. Useful if you
+ // want to evaluate the save curve at multiple t values.
+ struct EvalCubic {
+ const Vec2D a, b, c, d; // at^3 + bt^2 + ct + d
- // pts are the 4 cubic bezier control points
- EvalCubic(const Vec2D pts[4]) :
- 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]) {}
+ // pts are the 4 cubic bezier control points
+ EvalCubic(const Vec2D pts[4]) :
+ 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]) {}
- Vec2D operator()(float t) const { return ((a * t + b) * t + c) * t + d; }
-};
+ Vec2D operator()(float t) const { return ((a * t + b) * t + c) * t + d; }
+ };
-// These compute the number of line segments need to apprixmate the bezier
-// curve to the specified inverse-tolerance. We take inverse since we need
-// to divide by the "tolerance", and we want to save the cost of the divide.
-//
-// At "standard" tolerance might be 0.5 (half a pixel error), so the caller
-// would base 2.0 as its inverse.
-//
-// These always return at least 1
-//
+ // These compute the number of line segments need to apprixmate the bezier
+ // curve to the specified inverse-tolerance. We take inverse since we need
+ // to divide by the "tolerance", and we want to save the cost of the divide.
+ //
+ // At "standard" tolerance might be 0.5 (half a pixel error), so the caller
+ // would base 2.0 as its inverse.
+ //
+ // These always return at least 1
+ //
-extern int computeApproximatingQuadLineSegments(const Vec2D bezier[3], float invTolerance);
+ extern int computeApproximatingQuadLineSegments(const Vec2D bezier[3], float invTolerance);
-extern int computeApproximatingCubicLineSegments(const Vec2D bezier[4], float invTolerance);
+ extern int computeApproximatingCubicLineSegments(const Vec2D bezier[4], float invTolerance);
-// Extract a subcurve from the curve (given start and end t-values)
+ // Extract a subcurve from the curve (given start and end t-values)
-extern void quad_subdivide(const Vec2D src[3], float t, Vec2D dst[5]);
-extern void cubic_subdivide(const Vec2D src[4], float t, Vec2D dst[7]);
+ extern void quad_subdivide(const Vec2D src[3], float t, Vec2D dst[5]);
+ extern void cubic_subdivide(const Vec2D src[4], float t, Vec2D dst[7]);
-extern void line_extract(const Vec2D src[2], float startT, float endT, Vec2D dst[2]);
-extern void quad_extract(const Vec2D src[3], float startT, float endT, Vec2D dst[3]);
-extern void cubic_extract(const Vec2D src[4], float startT, float endT, Vec2D dst[4]);
+ extern void line_extract(const Vec2D src[2], float startT, float endT, Vec2D dst[2]);
+ extern void quad_extract(const Vec2D src[3], float startT, float endT, Vec2D dst[3]);
+ extern void cubic_extract(const Vec2D src[4], float startT, float endT, Vec2D dst[4]);
} // namespace rive
#include "rive/math/vec2d.hpp"
namespace rive {
-class TransformComponents {
-private:
- float m_X;
- float m_Y;
- float m_ScaleX;
- float m_ScaleY;
- float m_Rotation;
- float m_Skew;
+ class TransformComponents {
+ private:
+ float m_X;
+ float m_Y;
+ float m_ScaleX;
+ float m_ScaleY;
+ float m_Rotation;
+ float m_Skew;
-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) {}
- 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) {}
+ 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) {}
+ 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) {}
- float x() const { return m_X; }
- void x(float value) { m_X = value; }
- float y() const { return m_Y; }
- void y(float value) { m_Y = value; }
- float scaleX() const { return m_ScaleX; }
- void scaleX(float value) { m_ScaleX = value; }
- float scaleY() const { return m_ScaleY; }
- void scaleY(float value) { m_ScaleY = value; }
- float rotation() const { return m_Rotation; }
- void rotation(float value) { m_Rotation = value; }
- float skew() const { return m_Skew; }
- void skew(float value) { m_Skew = value; }
+ float x() const { return m_X; }
+ void x(float value) { m_X = value; }
+ float y() const { return m_Y; }
+ void y(float value) { m_Y = value; }
+ float scaleX() const { return m_ScaleX; }
+ void scaleX(float value) { m_ScaleX = value; }
+ float scaleY() const { return m_ScaleY; }
+ void scaleY(float value) { m_ScaleY = value; }
+ float rotation() const { return m_Rotation; }
+ void rotation(float value) { m_Rotation = value; }
+ float skew() const { return m_Skew; }
+ void skew(float value) { m_Skew = value; }
- Vec2D translation() const { return {m_X, m_Y}; }
- Vec2D scale() const { return {m_ScaleX, m_ScaleY}; }
+ Vec2D translation() const { return {m_X, m_Y}; }
+ Vec2D scale() const { return {m_ScaleX, m_ScaleY}; }
- TransformComponents& operator=(const TransformComponents& a) {
- m_X = a.m_X;
- m_Y = a.m_Y;
- m_ScaleX = a.m_ScaleX;
- m_ScaleY = a.m_ScaleY;
- m_Rotation = a.m_Rotation;
- m_Skew = a.m_Skew;
- return *this;
- }
-};
+ TransformComponents& operator=(const TransformComponents& a) {
+ m_X = a.m_X;
+ m_Y = a.m_Y;
+ m_ScaleX = a.m_ScaleX;
+ m_ScaleY = a.m_ScaleY;
+ m_Rotation = a.m_Rotation;
+ m_Skew = a.m_Skew;
+ return *this;
+ }
+ };
} // namespace rive
#endif
#include "rive/rive_types.hpp"
namespace rive {
-class Mat2D;
-class Vec2D {
-public:
- float x, y;
-
- constexpr Vec2D() : x(0), y(0) {}
- constexpr Vec2D(float x, float y) : x(x), y(y) {}
- constexpr Vec2D(const Vec2D&) = default;
-
- float lengthSquared() const { return x * x + y * y; }
- float length() const;
- Vec2D normalized() const;
-
- // Normalize this Vec, and return its previous length
- float normalizeLength() {
- const float len = this->length();
- x /= len;
- y /= len;
- return len;
+ class Mat2D;
+ class Vec2D {
+ public:
+ float x, y;
+
+ constexpr Vec2D() : x(0), y(0) {}
+ constexpr Vec2D(float x, float y) : x(x), y(y) {}
+ constexpr Vec2D(const Vec2D&) = default;
+
+ float lengthSquared() const { return x * x + y * y; }
+ float length() const;
+ Vec2D normalized() const;
+
+ // Normalize this Vec, and return its previous length
+ float normalizeLength() {
+ const float len = this->length();
+ x /= len;
+ y /= len;
+ return len;
+ }
+
+ Vec2D operator-() const { return {-x, -y}; }
+
+ void operator*=(float s) {
+ x *= s;
+ y *= s;
+ }
+
+ void operator/=(float s) {
+ x /= s;
+ y /= s;
+ }
+
+ friend inline Vec2D operator-(const Vec2D& a, const Vec2D& b) {
+ return {a.x - b.x, a.y - b.y};
+ }
+
+ static inline Vec2D lerp(Vec2D a, Vec2D b, float f);
+
+ static Vec2D transformDir(const Vec2D& a, const Mat2D& m);
+
+ static float dot(Vec2D a, Vec2D b) { return a.x * b.x + a.y * b.y; }
+ static Vec2D scaleAndAdd(Vec2D a, Vec2D b, float scale) {
+ return {
+ a.x + b.x * scale,
+ a.y + b.y * scale,
+ };
+ }
+ 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) {
+ x += v.x;
+ y += v.y;
+ return *this;
+ }
+ Vec2D& operator-=(Vec2D v) {
+ x -= v.x;
+ y -= v.y;
+ return *this;
+ }
+ };
+
+ inline Vec2D operator*(const Vec2D& v, float s) { return {v.x * s, v.y * s}; }
+ inline Vec2D operator*(float s, const Vec2D& v) { return {v.x * s, v.y * s}; }
+ inline Vec2D operator/(const Vec2D& v, float s) { return {v.x / s, v.y / s}; }
+
+ inline Vec2D operator+(const Vec2D& a, const Vec2D& b) { return {a.x + b.x, a.y + b.y}; }
+
+ inline bool operator==(const Vec2D& a, const Vec2D& b) { return a.x == b.x && a.y == b.y; }
+ inline bool operator!=(const Vec2D& a, const Vec2D& b) { return a.x != b.x || a.y != b.y; }
+
+ Vec2D Vec2D::lerp(Vec2D a, Vec2D b, float t) {
+ return a + (b - a) * t;
}
- Vec2D operator-() const { return {-x, -y}; }
-
- void operator*=(float s) {
- x *= s;
- y *= s;
- }
-
- void operator/=(float s) {
- x /= s;
- y /= s;
- }
-
- friend inline Vec2D operator-(const Vec2D& a, const Vec2D& b) { return {a.x - b.x, a.y - b.y}; }
-
- static inline Vec2D lerp(Vec2D a, Vec2D b, float f);
-
- static Vec2D transformDir(const Vec2D& a, const Mat2D& m);
-
- 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) {
- return {
- a.x + b.x * scale,
- a.y + b.y * scale,
- };
- }
- 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) {
- x += v.x;
- y += v.y;
- return *this;
- }
- Vec2D& operator-=(Vec2D v) {
- x -= v.x;
- y -= v.y;
- return *this;
- }
-};
-
-inline Vec2D operator*(const Vec2D& v, float s) { return {v.x * s, v.y * s}; }
-inline Vec2D operator*(float s, const Vec2D& v) { return {v.x * s, v.y * s}; }
-inline Vec2D operator/(const Vec2D& v, float s) { return {v.x / s, v.y / s}; }
-
-inline Vec2D operator+(const Vec2D& a, const Vec2D& b) { return {a.x + b.x, a.y + b.y}; }
-
-inline bool operator==(const Vec2D& a, const Vec2D& b) { return a.x == b.x && a.y == b.y; }
-inline bool operator!=(const Vec2D& a, const Vec2D& b) { return a.x != b.x || a.y != b.y; }
-
-Vec2D Vec2D::lerp(Vec2D a, Vec2D b, float t) { return a + (b - a) * t; }
-
} // namespace rive
#endif
#include "rive/generated/nested_animation_base.hpp"
#include <stdio.h>
namespace rive {
-class ArtboardInstance;
+ class ArtboardInstance;
-class NestedAnimation : public NestedAnimationBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
+ class NestedAnimation : public NestedAnimationBase {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
- // Advance animations and apply them to the artboard.
- virtual void advance(float elapsedSeconds) = 0;
+ // Advance animations and apply them to the artboard.
+ virtual void advance(float elapsedSeconds) = 0;
- // Initialize the animation (make instances as necessary) from the
- // source artboard.
- virtual void initializeAnimation(ArtboardInstance*) = 0;
-};
+ // Initialize the animation (make instances as necessary) from the
+ // source artboard.
+ virtual void initializeAnimation(ArtboardInstance*) = 0;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/nested_artboard_base.hpp"
#include "rive/hit_info.hpp"
-#include "rive/span.hpp"
#include <stdio.h>
namespace rive {
-class ArtboardInstance;
-class NestedAnimation;
-class NestedArtboard : public NestedArtboardBase {
-
-private:
- Artboard* m_Artboard = nullptr; // might point to m_Instance, and might not
- std::unique_ptr<ArtboardInstance> m_Instance; // may be null
- std::vector<NestedAnimation*> m_NestedAnimations;
-
-public:
- NestedArtboard();
- ~NestedArtboard() override;
- StatusCode onAddedClean(CoreContext* context) override;
- void draw(Renderer* renderer) override;
- Core* hitTest(HitInfo*, const Mat2D&) override;
- void addNestedAnimation(NestedAnimation* nestedAnimation);
-
- void nest(Artboard* artboard);
-
- StatusCode import(ImportStack& importStack) override;
- Core* clone() const override;
- bool advance(float elapsedSeconds);
- void update(ComponentDirt value) override;
-
- bool hasNestedStateMachines() const;
- Span<NestedAnimation*> nestedAnimations();
-
- /// Convert a world space (relative to the artboard that this
- /// NestedArtboard is a child of) to the local space of the Artboard
- /// nested within. Returns true when the conversion succeeds, and false
- /// when one is not possible.
- bool worldToLocal(Vec2D world, Vec2D* local);
-};
+ class ArtboardInstance;
+ class NestedAnimation;
+ class NestedArtboard : public NestedArtboardBase {
+
+ private:
+ Artboard* m_Artboard = nullptr; // might point to m_Instance, and might not
+ std::unique_ptr<ArtboardInstance> m_Instance; // may be null
+ std::vector<NestedAnimation*> m_NestedAnimations;
+
+ public:
+ NestedArtboard();
+ ~NestedArtboard();
+ StatusCode onAddedClean(CoreContext* context) override;
+ void draw(Renderer* renderer) override;
+ Core* hitTest(HitInfo*, const Mat2D&) override;
+ void addNestedAnimation(NestedAnimation* nestedAnimation);
+
+ void nest(Artboard* artboard);
+
+ StatusCode import(ImportStack& importStack) override;
+ Core* clone() const override;
+ bool advance(float elapsedSeconds);
+ void update(ComponentDirt value) override;
+ };
} // namespace rive
#endif
#include "rive/generated/node_base.hpp"
namespace rive {
-/// A Rive Node
-class Node : public NodeBase {
-protected:
- void xChanged() override;
- void yChanged() override;
-};
+ /// A Rive Node
+ class Node : public NodeBase {
+ protected:
+ void xChanged() override;
+ void yChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
namespace rive {
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
+ 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 {
PointerEventType m_Type;
- Vec2D m_Position;
- int m_PointerIndex;
+ Vec2D m_Position;
+ int m_PointerIndex;
// add more fields as needed
};
-
+
} // namespace rive
#endif
namespace rive {
-class RefCnt {
-public:
- RefCnt() : m_refcnt(1) {}
+ class RefCnt {
+ public:
+ RefCnt() : m_refcnt(1) {}
- virtual ~RefCnt() { assert(this->debugging_refcnt() == 1); }
+ virtual ~RefCnt() { assert(this->debugging_refcnt() == 1); }
- void ref() const { (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed); }
+ void ref() const { (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed); }
- void unref() const {
- if (1 == m_refcnt.fetch_add(-1, std::memory_order_acq_rel)) {
+ void unref() const {
+ if (1 == m_refcnt.fetch_add(-1, std::memory_order_acq_rel)) {
#ifndef NDEBUG
- // we restore the "1" in debug builds just to make our destructor happy
- (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed);
+ // we restore the "1" in debug builds just to make our destructor happy
+ (void)m_refcnt.fetch_add(+1, std::memory_order_relaxed);
#endif
- delete this;
+ delete this;
+ }
}
- }
- // not reliable in actual threaded scenarios, but useful (perhaps) for debugging
- int32_t debugging_refcnt() const { return m_refcnt.load(std::memory_order_relaxed); }
+ // not reliable in actual threaded scenarios, but useful (perhaps) for debugging
+ int32_t debugging_refcnt() const { return m_refcnt.load(std::memory_order_relaxed); }
-private:
- // mutable, so can be changed even on a const object
- mutable std::atomic<int32_t> m_refcnt;
+ private:
+ // mutable, so can be changed even on a const object
+ mutable std::atomic<int32_t> m_refcnt;
- RefCnt(RefCnt&&) = delete;
- RefCnt(const RefCnt&) = delete;
- RefCnt& operator=(RefCnt&&) = delete;
- RefCnt& operator=(const RefCnt&) = delete;
-};
+ RefCnt(RefCnt&&) = delete;
+ RefCnt(const RefCnt&) = delete;
+ RefCnt& operator=(RefCnt&&) = delete;
+ RefCnt& operator=(const RefCnt&) = delete;
+ };
-template <typename T> static inline T* safe_ref(T* obj) {
- if (obj) {
- obj->ref();
+ template <typename T> static inline T* safe_ref(T* obj) {
+ if (obj) {
+ obj->ref();
+ }
+ return obj;
}
- return obj;
-}
-template <typename T> static inline void safe_unref(T* obj) {
- if (obj) {
- obj->unref();
+ template <typename T> static inline void safe_unref(T* obj) {
+ if (obj) {
+ obj->unref();
+ }
}
-}
-// rcp : smart point template for holding subclasses of RefCnt
+ // rcp : smart point template for holding subclasses of RefCnt
-template <typename T> class rcp {
-public:
- constexpr rcp() : m_ptr(nullptr) {}
- constexpr rcp(std::nullptr_t) : m_ptr(nullptr) {}
- explicit rcp(T* ptr) : m_ptr(ptr) {}
+ template <typename T> class rcp {
+ public:
+ constexpr rcp() : m_ptr(nullptr) {}
+ constexpr rcp(std::nullptr_t) : m_ptr(nullptr) {}
+ explicit rcp(T* ptr) : m_ptr(ptr) {}
- rcp(const rcp<T>& other) : m_ptr(safe_ref(other.get())) {}
- rcp(rcp<T>&& other) : m_ptr(other.release()) {}
+ rcp(const rcp<T>& other) : m_ptr(safe_ref(other.get())) {}
+ rcp(rcp<T>&& other) : m_ptr(other.release()) {}
- /**
- * Calls unref() on the underlying object pointer.
- */
- ~rcp() { safe_unref(m_ptr); }
+ /**
+ * Calls unref() on the underlying object pointer.
+ */
+ ~rcp() { safe_unref(m_ptr); }
- rcp<T>& operator=(std::nullptr_t) {
- this->reset();
- return *this;
- }
+ rcp<T>& operator=(std::nullptr_t) {
+ this->reset();
+ return *this;
+ }
- rcp<T>& operator=(const rcp<T>& other) {
- if (this != &other) {
- this->reset(safe_ref(other.get()));
+ rcp<T>& operator=(const rcp<T>& other) {
+ if (this != &other) {
+ this->reset(safe_ref(other.get()));
+ }
+ return *this;
}
- return *this;
- }
- rcp<T>& operator=(rcp<T>&& other) {
- this->reset(other.release());
- return *this;
- }
+ rcp<T>& operator=(rcp<T>&& other) {
+ this->reset(other.release());
+ return *this;
+ }
- T& operator*() const {
- assert(this->get() != nullptr);
- return *this->get();
- }
+ T& operator*() const {
+ assert(this->get() != nullptr);
+ return *this->get();
+ }
- explicit operator bool() const { return this->get() != nullptr; }
+ explicit operator bool() const { return this->get() != nullptr; }
- T* get() const { return m_ptr; }
- T* operator->() const { return m_ptr; }
+ T* get() const { return m_ptr; }
+ T* operator->() const { return m_ptr; }
- // Unrefs the current pointer, and accepts the new pointer, but
- // DOES NOT increment ownership of the new pointer.
- void reset(T* ptr = nullptr) {
- // Calling m_ptr->unref() may call this->~() or this->reset(T*).
- // http://wg21.cmeerw.net/lwg/issue998
- // http://wg21.cmeerw.net/lwg/issue2262
- T* oldPtr = m_ptr;
- m_ptr = ptr;
- safe_unref(oldPtr);
- }
+ // Unrefs the current pointer, and accepts the new pointer, but
+ // DOES NOT increment ownership of the new pointer.
+ void reset(T* ptr = nullptr) {
+ // Calling m_ptr->unref() may call this->~() or this->reset(T*).
+ // http://wg21.cmeerw.net/lwg/issue998
+ // http://wg21.cmeerw.net/lwg/issue2262
+ T* oldPtr = m_ptr;
+ m_ptr = ptr;
+ safe_unref(oldPtr);
+ }
- // This returns the bare point WITHOUT CHANGING ITS REFCNT, but removes it
- // from this object, so the caller must manually manage its count.
- T* release() {
- T* ptr = m_ptr;
- m_ptr = nullptr;
- return ptr;
- }
+ // This returns the bare point WITHOUT CHANGING ITS REFCNT, but removes it
+ // from this object, so the caller must manually manage its count.
+ T* release() {
+ T* ptr = m_ptr;
+ m_ptr = nullptr;
+ return ptr;
+ }
- void swap(rcp<T>& other) { std::swap(m_ptr, other.m_ptr); }
+ void swap(rcp<T>& other) { std::swap(m_ptr, other.m_ptr); }
-private:
- T* m_ptr;
-};
+ private:
+ T* m_ptr;
+ };
-template <typename T> inline void swap(rcp<T>& a, rcp<T>& b) { a.swap(b); }
+ template <typename T> inline void swap(rcp<T>& a, rcp<T>& b) { a.swap(b); }
-// == variants
+ // == variants
-template <typename T> inline bool operator==(const rcp<T>& a, std::nullptr_t) { return !a; }
-template <typename T> inline bool operator==(std::nullptr_t, const rcp<T>& b) { return !b; }
-template <typename T, typename U> inline bool operator==(const rcp<T>& a, const rcp<U>& b) {
- return a.get() == b.get();
-}
+ template <typename T> inline bool operator==(const rcp<T>& a, std::nullptr_t) { return !a; }
+ template <typename T> inline bool operator==(std::nullptr_t, const rcp<T>& b) { return !b; }
+ template <typename T, typename U> inline bool operator==(const rcp<T>& a, const rcp<U>& b) {
+ return a.get() == b.get();
+ }
-// != variants
+ // != variants
-template <typename T> inline bool operator!=(const rcp<T>& a, std::nullptr_t) {
- return static_cast<bool>(a);
-}
-template <typename T> inline bool operator!=(std::nullptr_t, const rcp<T>& b) {
- return static_cast<bool>(b);
-}
-template <typename T, typename U> inline bool operator!=(const rcp<T>& a, const rcp<U>& b) {
- return a.get() != b.get();
-}
+ template <typename T> inline bool operator!=(const rcp<T>& a, std::nullptr_t) {
+ return static_cast<bool>(a);
+ }
+ template <typename T> inline bool operator!=(std::nullptr_t, const rcp<T>& b) {
+ return static_cast<bool>(b);
+ }
+ template <typename T, typename U> inline bool operator!=(const rcp<T>& a, const rcp<U>& b) {
+ return a.get() != b.get();
+ }
} // namespace rive
#include <string>
namespace rive {
-class FileAsset;
-class Factory;
+ 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 {
-private:
- std::string m_Path;
- Factory* m_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 {
+ private:
+ std::string m_Path;
+ Factory* m_Factory;
-public:
- RelativeLocalAssetResolver(std::string filename, Factory* factory) : m_Factory(factory) {
- std::size_t finalSlash = filename.rfind('/');
+ public:
+ RelativeLocalAssetResolver(std::string filename, Factory* factory)
+ : m_Factory(factory)
+ {
+ std::size_t finalSlash = filename.rfind('/');
- if (finalSlash != std::string::npos) {
- m_Path = filename.substr(0, finalSlash + 1);
+ if (finalSlash != std::string::npos) {
+ m_Path = filename.substr(0, finalSlash + 1);
+ }
}
- }
- void loadContents(FileAsset& asset) override {
- std::string filename = m_Path + asset.uniqueFilename();
- FILE* fp = fopen(filename.c_str(), "rb");
+ void loadContents(FileAsset& asset) override {
+ std::string filename = m_Path + asset.uniqueFilename();
+ FILE* fp = fopen(filename.c_str(), "rb");
- fseek(fp, 0, SEEK_END);
- 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) {
- asset.decode(Span<const uint8_t>(bytes, length), m_Factory);
+ fseek(fp, 0, SEEK_END);
+ 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) {
+ asset.decode(Span<const uint8_t>(bytes, length), m_Factory);
+ }
+ delete[] bytes;
}
- delete[] bytes;
- }
-};
+ };
} // namespace rive
#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_RENDER_TEXT_HPP_
-#define _RIVE_RENDER_TEXT_HPP_
-
-#include "rive/math/raw_path.hpp"
-#include "rive/refcnt.hpp"
-#include "rive/span.hpp"
-
-namespace rive {
-
-using Unichar = uint32_t;
-using GlyphID = uint16_t;
-
-struct RenderTextRun;
-struct RenderGlyphRun;
-
-class RenderFont : public RefCnt {
-public:
- struct LineMetrics {
- float ascent, descent;
- };
-
- const LineMetrics& lineMetrics() const { return m_LineMetrics; }
-
- // This is experimental
- // -- may only be needed by Editor
- // -- so it may be removed from here later
- //
- struct Axis {
- uint32_t tag;
- float min;
- float def; // default value
- float max;
- };
-
- // Returns the canonical set of Axes for this font. Use this to know
- // what variations are possible. If you want to know the specific
- // coordinate within that variations space for *this* font, call
- // getCoords().
- //
- virtual std::vector<Axis> getAxes() const = 0;
-
- struct Coord {
- uint32_t axis;
- float value;
- };
-
- // Returns the specific coords in variation space for this font.
- // If you want to have a description of the entire variation space,
- // call getAxes().
- //
- virtual std::vector<Coord> getCoords() const = 0;
-
- virtual rcp<RenderFont> makeAtCoords(Span<const Coord>) const = 0;
-
- rcp<RenderFont> makeAtCoord(Coord c) { return this->makeAtCoords(Span<const Coord>(&c, 1)); }
-
- // Returns a 1-point path for this glyph. It will be positioned
- // relative to (0,0) with the typographic baseline at y = 0.
- //
- virtual RawPath getPath(GlyphID) const = 0;
-
- std::vector<RenderGlyphRun> shapeText(rive::Span<const rive::Unichar> text,
- rive::Span<const rive::RenderTextRun> runs) const;
-
-protected:
- RenderFont(const LineMetrics& lm) : m_LineMetrics(lm) {}
-
- virtual std::vector<RenderGlyphRun>
- onShapeText(rive::Span<const rive::Unichar> text,
- rive::Span<const rive::RenderTextRun> runs) const = 0;
-
-private:
- const LineMetrics m_LineMetrics;
-};
-
-struct RenderTextRun {
- rcp<RenderFont> font;
- float size;
- uint32_t unicharCount;
-};
-
-struct RenderGlyphRun {
- rcp<RenderFont> font;
- float size;
-
- std::vector<GlyphID> glyphs; // [#glyphs]
- std::vector<uint32_t> textOffsets; // [#glyphs]
- std::vector<float> xpos; // [#glyphs + 1]
-};
-
-} // namespace rive
-#endif
#include <cstdint>
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 {
- const size_t m_Count;
-
-public:
- RenderBuffer(size_t count);
- ~RenderBuffer() override;
-
- size_t count() const { return m_Count; }
-};
-
-enum class RenderPaintStyle { stroke, fill };
-
-/*
- * Base class for Render objects that specify the src colors.
- *
- * Shaders are immutable, and sharable between multiple paints, etc.
- *
- * 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 {
-public:
- RenderShader();
- ~RenderShader() override;
-};
-
-class RenderPaint {
-public:
- RenderPaint();
- virtual ~RenderPaint();
-
- virtual void style(RenderPaintStyle style) = 0;
- virtual void color(ColorInt value) = 0;
- virtual void thickness(float value) = 0;
- virtual void join(StrokeJoin value) = 0;
- virtual void cap(StrokeCap value) = 0;
- virtual void blendMode(BlendMode value) = 0;
- virtual void shader(rcp<RenderShader>) = 0;
- virtual void invalidateStroke() = 0;
-};
-
-class RenderImage {
-protected:
- int m_Width = 0;
- int m_Height = 0;
-
-public:
- RenderImage();
- virtual ~RenderImage();
-
- int width() const { return m_Width; }
- int height() const { return m_Height; }
-};
-
-class RenderPath : public CommandPath {
-public:
- RenderPath();
- ~RenderPath() override;
-
- RenderPath* renderPath() override { return this; }
- void addPath(CommandPath* path, const Mat2D& transform) override {
- addRenderPath(path->renderPath(), transform);
- }
-
- virtual void addRenderPath(RenderPath* path, const Mat2D& transform) = 0;
-};
-
-class Renderer {
-public:
- virtual ~Renderer() {}
- virtual void save() = 0;
- virtual void restore() = 0;
- virtual void transform(const Mat2D& transform) = 0;
- virtual void drawPath(RenderPath* path, RenderPaint* paint) = 0;
- virtual void clipPath(RenderPath* path) = 0;
- virtual void drawImage(const RenderImage*, BlendMode, float opacity) = 0;
- virtual void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) = 0;
-
- // helpers
-
- void translate(float x, float y);
- void scale(float sx, float sy);
- void rotate(float radians);
-
- void align(Fit fit, Alignment alignment, const AABB& frame, const AABB& content) {
- transform(computeAlignment(fit, alignment, frame, content));
- }
-};
+ 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 {
+ const size_t m_Count;
+
+ public:
+ RenderBuffer(size_t count) : m_Count(count) {}
+
+ size_t count() const { return m_Count; }
+ };
+
+ enum class RenderPaintStyle { stroke, fill };
+
+ enum class RenderTileMode {
+ clamp,
+ repeat,
+ mirror,
+ decal, // fill outside the domain with transparent
+ };
+
+ /*
+ * Base class for Render objects that specify the src colors.
+ *
+ * Shaders are immutable, and sharable between multiple paints, etc.
+ *
+ * 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 {};
+
+ class RenderPaint {
+ public:
+ virtual void style(RenderPaintStyle style) = 0;
+ virtual void color(ColorInt value) = 0;
+ virtual void thickness(float value) = 0;
+ virtual void join(StrokeJoin value) = 0;
+ virtual void cap(StrokeCap value) = 0;
+ virtual void blendMode(BlendMode value) = 0;
+ virtual void shader(rcp<RenderShader>) = 0;
+
+ virtual ~RenderPaint() {}
+ };
+
+ class RenderImage {
+ protected:
+ int m_Width = 0;
+ int m_Height = 0;
+
+ public:
+ virtual ~RenderImage() {}
+ int width() const { return m_Width; }
+ int height() const { return m_Height; }
+
+ virtual rcp<RenderShader> makeShader(RenderTileMode tx,
+ RenderTileMode ty,
+ const Mat2D* localMatrix = nullptr) const = 0;
+ };
+
+ class RenderPath : public CommandPath {
+ public:
+ RenderPath* renderPath() override { return this; }
+ void addPath(CommandPath* path, const Mat2D& transform) override {
+ addRenderPath(path->renderPath(), transform);
+ }
+
+ virtual void addRenderPath(RenderPath* path, const Mat2D& transform) = 0;
+ };
+
+ class Renderer {
+ public:
+ virtual ~Renderer() {}
+ virtual void save() = 0;
+ virtual void restore() = 0;
+ virtual void transform(const Mat2D& transform) = 0;
+ virtual void drawPath(RenderPath* path, RenderPaint* paint) = 0;
+ virtual void clipPath(RenderPath* path) = 0;
+ virtual void drawImage(const RenderImage*, BlendMode, float opacity) = 0;
+ virtual void drawImageMesh(const RenderImage*,
+ rcp<RenderBuffer> vertices_f32,
+ rcp<RenderBuffer> uvCoords_f32,
+ rcp<RenderBuffer> indices_u16,
+ BlendMode,
+ float opacity) = 0;
+
+ // helpers
+
+ void translate(float x, float y);
+ void scale(float sx, float sy);
+ void rotate(float radians);
+
+ void align(Fit fit, Alignment alignment, const AABB& frame, const AABB& content) {
+ transform(computeAlignment(fit, alignment, frame, content));
+ }
+ };
} // namespace rive
#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_COUNTER_HPP_
-#define _RIVE_COUNTER_HPP_
-
-#include "rive/rive_types.hpp"
-
-namespace rive {
-
-struct Counter {
- enum Type {
- kFile,
- kArtboardInstance,
- kLinearAnimationInstance,
- kStateMachineInstance,
-
- kBuffer,
- kPath,
- kPaint,
- kShader,
- kImage,
-
- kLastType = kImage,
- };
-
- static constexpr int kNumTypes = Type::kLastType + 1;
- static int counts[kNumTypes];
-
- static void update(Type ct, int delta) {
- assert(delta == 1 || delta == -1);
- counts[ct] += delta;
- assert(counts[ct] >= 0);
- }
-};
-
-} // namespace rive
-
-#endif
#ifndef _RIVE_TYPES_HPP_
#define _RIVE_TYPES_HPP_
-// clang-format off
+// We treat NDEBUG is the root of truth from the user.
+// Our other symbols (DEBUG, RELEASE) must agree with it.
+// ... its ok if our client doesn't set these, we will do that...
+// ... they just can't set them inconsistently.
-#if defined(DEBUG) && defined(NDEBUG)
- #error "can't determine if we're debug or release"
+#ifdef NDEBUG
+// we're in release mode
+#ifdef DEBUG
+#error "can't define both DEBUG and NDEBUG"
#endif
-
-#if !defined(DEBUG) && !defined(NDEBUG)
- // we have to make a decision what mode we're in
- // historically this has been to look for NDEBUG, and in its
- // absence assume we're DEBUG.
- #define DEBUG 1
- // fyi - Xcode seems to set DEBUG (or not), so the above guess
- // doesn't work for them - so our projects may need to explicitly
- // set NDEBUG in our 'release' builds.
+#ifndef RELEASE
+#define RELEASE
#endif
-
-#ifdef NDEBUG
- #ifndef RELEASE
- #define RELEASE 1
- #endif
-#else // debug mode
- #ifndef DEBUG
- #define DEBUG 1
- #endif
+#else
+// we're in debug mode
+#ifdef RELEASE
+#error "can't define RELEASE and not NDEBUG"
+#endif
+#ifndef DEBUG
+#define DEBUG
#endif
-
-// Some checks to guess what platform we're building for
-
-#ifdef __APPLE__
-
- #define RIVE_BUILD_FOR_APPLE
- #include <TargetConditionals.h>
-
- #if TARGET_OS_IPHONE
- #define RIVE_BUILD_FOR_IOS
- #elif TARGET_OS_MAC
- #define RIVE_BUILD_FOR_OSX
- #endif
-
#endif
// We really like these headers, so we include them all the time.
#include <memory>
#include <type_traits>
-// Annotations to assert unreachable control flow.
-#ifdef __GNUC__ // GCC 4.8+, Clang, Intel and others compatible with GCC (-std=c++0x or above)
- #define RIVE_UNREACHABLE __builtin_unreachable()
-#elif _MSC_VER
- #define RIVE_UNREACHABLE __assume(0)
-#else
- #define RIVE_UNREACHABLE do {} while(0)
-#endif
-
-// clang-format on
-
#endif // rive_types
#include <unordered_map>
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 {
-private:
- static constexpr char fingerprint[] = "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 {
+ private:
+ static constexpr char fingerprint[] = "RIVE";
- int m_MajorVersion;
- int m_MinorVersion;
- int m_FileId;
- std::unordered_map<int, int> m_PropertyToFieldIndex;
+ int m_MajorVersion;
+ int m_MinorVersion;
+ int m_FileId;
+ std::unordered_map<int, int> m_PropertyToFieldIndex;
-public:
- /// @returns the file's major version
- int majorVersion() const { return m_MajorVersion; }
- /// @returns the file's minor version
- int minorVersion() const { return m_MinorVersion; }
- /// @returns the file's id; may be zero
- int fileId() const { return m_FileId; }
+ public:
+ /// @returns the file's major version
+ int majorVersion() const { return m_MajorVersion; }
+ /// @returns the file's minor version
+ int minorVersion() const { return m_MinorVersion; }
+ /// @returns the file's id; may be zero
+ int fileId() const { return m_FileId; }
- int propertyFieldId(int propertyKey) const {
- auto itr = m_PropertyToFieldIndex.find(propertyKey);
- if (itr == m_PropertyToFieldIndex.end()) {
- return -1;
+ int propertyFieldId(int propertyKey) const {
+ auto itr = m_PropertyToFieldIndex.find(propertyKey);
+ if (itr == m_PropertyToFieldIndex.end()) {
+ return -1;
+ }
+
+ return itr->second;
}
- return itr->second;
- }
+ /// Reads the header from a binary buffer/
+ /// @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++) {
+ auto b = reader.readByte();
+ if (fingerprint[i] != b) {
+ return false;
+ }
+ }
- /// Reads the header from a binary buffer/
- /// @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++) {
- auto b = reader.readByte();
- if (fingerprint[i] != b) {
+ header.m_MajorVersion = reader.readVarUintAs<int>();
+ if (reader.didOverflow()) {
+ return false;
+ }
+ header.m_MinorVersion = reader.readVarUintAs<int>();
+ if (reader.didOverflow()) {
return false;
}
- }
-
- header.m_MajorVersion = reader.readVarUintAs<int>();
- if (reader.didOverflow()) {
- return false;
- }
- header.m_MinorVersion = reader.readVarUintAs<int>();
- if (reader.didOverflow()) {
- return false;
- }
-
- header.m_FileId = reader.readVarUintAs<int>();
- if (reader.didOverflow()) {
- return false;
- }
+ header.m_FileId = reader.readVarUintAs<int>();
- std::vector<int> propertyKeys;
- for (int propertyKey = reader.readVarUintAs<int>(); propertyKey != 0;
- propertyKey = reader.readVarUintAs<int>())
- {
- propertyKeys.push_back(propertyKey);
if (reader.didOverflow()) {
return false;
}
- }
- int currentInt = 0;
- int currentBit = 8;
- for (auto propertyKey : propertyKeys) {
- if (currentBit == 8) {
- currentInt = reader.readUint32();
- currentBit = 0;
+ std::vector<int> propertyKeys;
+ for (int propertyKey = reader.readVarUintAs<int>(); propertyKey != 0;
+ propertyKey = reader.readVarUintAs<int>())
+ {
+ propertyKeys.push_back(propertyKey);
+ if (reader.didOverflow()) {
+ return false;
+ }
}
- int fieldIndex = (currentInt >> currentBit) & 3;
- header.m_PropertyToFieldIndex[propertyKey] = fieldIndex;
- currentBit += 2;
- if (reader.didOverflow()) {
- return false;
+
+ int currentInt = 0;
+ int 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()) {
+ return false;
+ }
}
- }
- return true;
- }
-};
+ return true;
+ }
+ };
} // namespace rive
#endif
#include <string>
namespace rive {
-class ArtboardInstance;
-class Renderer;
-
-class SMIInput;
-class SMIBool;
-class SMINumber;
-class SMITrigger;
-
-class Scene {
-protected:
- ArtboardInstance* m_ArtboardInstance;
-
- Scene(ArtboardInstance*);
-
-public:
- virtual ~Scene() {}
-
- Scene(Scene const& lhs) : m_ArtboardInstance(lhs.m_ArtboardInstance) {}
-
- float width() const;
- float height() const;
- AABB bounds() const { return {0, 0, this->width(), this->height()}; }
-
- virtual std::string name() const = 0;
-
- // Returns onShot if this has no looping (e.g. a statemachine)
- virtual Loop loop() const = 0;
- // Returns true iff the Scene is known to not be fully opaque
- virtual bool isTranslucent() const = 0;
- // returns -1 for continuous
- virtual float durationSeconds() const = 0;
-
- // returns true if draw() should be called
- virtual bool advanceAndApply(float elapsedSeconds) = 0;
-
- void draw(Renderer*);
-
- virtual void pointerDown(Vec2D);
- virtual void pointerMove(Vec2D);
- virtual void pointerUp(Vec2D);
-
- virtual size_t inputCount() const;
- virtual SMIInput* input(size_t index) const;
- virtual SMIBool* getBool(const std::string&) const;
- virtual SMINumber* getNumber(const std::string&) const;
- virtual SMITrigger* getTrigger(const std::string&) const;
-};
+ class ArtboardInstance;
+ class Renderer;
+
+ class SMIInput;
+ class SMIBool;
+ class SMINumber;
+ class SMITrigger;
+
+ class Scene {
+ protected:
+ ArtboardInstance* m_ArtboardInstance;
+
+ Scene(ArtboardInstance*);
+
+ public:
+ virtual ~Scene() {}
+
+ float width() const;
+ float height() const;
+ AABB bounds() const { return {0, 0, this->width(), this->height()}; }
+
+ virtual std::string name() const = 0;
+
+ // Returns onShot if this has no looping (e.g. a statemachine)
+ virtual Loop loop() const = 0;
+ // Returns true iff the Scene is known to not be fully opaque
+ virtual bool isTranslucent() const = 0;
+ // returns -1 for continuous
+ virtual float durationSeconds() const = 0;
+
+ // returns true if draw() should be called
+ virtual bool advanceAndApply(float elapsedSeconds) = 0;
+
+ void draw(Renderer*);
+
+ virtual void pointerDown(Vec2D);
+ virtual void pointerMove(Vec2D);
+ virtual void pointerUp(Vec2D);
+
+ virtual size_t inputCount() const;
+ virtual SMIInput* input(size_t index) const;
+ virtual SMIBool* getBool(const std::string&) const;
+ virtual SMINumber* getNumber(const std::string&) const;
+ virtual SMITrigger* getTrigger(const std::string&) const;
+ };
} // namespace rive
#include <vector>
namespace rive {
-class Shape;
-class Node;
-class RenderPath;
-class ClippingShape : public ClippingShapeBase {
-private:
- std::vector<Shape*> m_Shapes;
- Node* m_Source = nullptr;
- std::unique_ptr<RenderPath> m_RenderPath;
+ class Shape;
+ class Node;
+ class RenderPath;
+ class ClippingShape : public ClippingShapeBase {
+ private:
+ std::vector<Shape*> m_Shapes;
+ Node* m_Source = nullptr;
+ std::unique_ptr<RenderPath> m_RenderPath;
- // The actual render path used for clipping, which may be different from
- // the stored render path. For example if there's only one clipping
- // shape, we don't build a whole new path for it.
- RenderPath* m_ClipRenderPath = nullptr;
+ public:
+ Node* source() const { return m_Source; }
+ const std::vector<Shape*>& shapes() const { return m_Shapes; }
+ StatusCode onAddedClean(CoreContext* context) override;
+ StatusCode onAddedDirty(CoreContext* context) override;
+ void buildDependencies() override;
+ void update(ComponentDirt value) override;
-public:
- Node* source() const { return m_Source; }
- const std::vector<Shape*>& shapes() const { return m_Shapes; }
- StatusCode onAddedClean(CoreContext* context) override;
- StatusCode onAddedDirty(CoreContext* context) override;
- void buildDependencies() override;
- void update(ComponentDirt value) override;
-
- RenderPath* renderPath() const { return m_ClipRenderPath; }
-};
+ RenderPath* renderPath() const { return m_RenderPath.get(); }
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/shapes/contour_mesh_vertex_base.hpp"
namespace rive {
-class ContourMeshVertex : public ContourMeshVertexBase {
-public:
-};
+ class ContourMeshVertex : public ContourMeshVertexBase {
+ public:
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CUBIC_ASYMMETRIC_VERTEX_HPP_
#include "rive/generated/shapes/cubic_asymmetric_vertex_base.hpp"
namespace rive {
-class CubicAsymmetricVertex : public CubicAsymmetricVertexBase {
-protected:
- void computeIn() override;
- void computeOut() override;
- void rotationChanged() override;
- void inDistanceChanged() override;
- void outDistanceChanged() override;
-};
+ class CubicAsymmetricVertex : public CubicAsymmetricVertexBase {
+ protected:
+ void computeIn() override;
+ void computeOut() override;
+ void rotationChanged() override;
+ void inDistanceChanged() override;
+ void outDistanceChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CUBIC_DETACHED_VERTEX_HPP_
#include "rive/generated/shapes/cubic_detached_vertex_base.hpp"
namespace rive {
-class CubicDetachedVertex : public CubicDetachedVertexBase {
-protected:
- void computeIn() override;
- void computeOut() override;
+ class CubicDetachedVertex : public CubicDetachedVertexBase {
+ protected:
+ void computeIn() override;
+ void computeOut() override;
- void inRotationChanged() override;
- void inDistanceChanged() override;
- void outRotationChanged() override;
- void outDistanceChanged() override;
-};
+ void inRotationChanged() override;
+ void inDistanceChanged() override;
+ void outRotationChanged() override;
+ void outDistanceChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_CUBIC_MIRRORED_VERTEX_HPP_
#include "rive/generated/shapes/cubic_mirrored_vertex_base.hpp"
namespace rive {
-class CubicMirroredVertex : public CubicMirroredVertexBase {
-protected:
- void computeIn() override;
- void computeOut() override;
- void rotationChanged() override;
- void distanceChanged() override;
-};
+ class CubicMirroredVertex : public CubicMirroredVertexBase {
+ protected:
+ void computeIn() override;
+ void computeOut() override;
+ void rotationChanged() override;
+ void distanceChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/math/vec2d.hpp"
namespace rive {
-class Vec2D;
-class CubicVertex : public CubicVertexBase {
-protected:
- bool m_InValid = false;
- bool m_OutValid = false;
- Vec2D m_InPoint;
- Vec2D m_OutPoint;
+ class Vec2D;
+ class CubicVertex : public CubicVertexBase {
+ protected:
+ bool m_InValid = false;
+ bool m_OutValid = false;
+ Vec2D m_InPoint;
+ Vec2D m_OutPoint;
- virtual void computeIn() = 0;
- virtual void computeOut() = 0;
+ virtual void computeIn() = 0;
+ virtual void computeOut() = 0;
-public:
- const Vec2D& outPoint();
- const Vec2D& inPoint();
- const Vec2D& renderOut();
- const Vec2D& renderIn();
+ public:
+ const Vec2D& outPoint();
+ const Vec2D& inPoint();
+ const Vec2D& renderOut();
+ const Vec2D& renderIn();
- void outPoint(const Vec2D& value);
- void inPoint(const Vec2D& value);
- void xChanged() override;
- void yChanged() override;
+ void outPoint(const Vec2D& value);
+ void inPoint(const Vec2D& value);
+ void xChanged() override;
+ void yChanged() override;
- void deform(const Mat2D& worldTransform, const float* boneTransforms) override;
-};
+ void deform(const Mat2D& worldTransform, const float* boneTransforms) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/shapes/cubic_detached_vertex.hpp"
namespace rive {
-class Ellipse : public EllipseBase {
- CubicDetachedVertex m_Vertex1, m_Vertex2, m_Vertex3, m_Vertex4;
+ class Ellipse : public EllipseBase {
+ CubicDetachedVertex m_Vertex1, m_Vertex2, m_Vertex3, m_Vertex4;
-public:
- Ellipse();
- void update(ComponentDirt value) override;
-};
+ public:
+ Ellipse();
+ void update(ComponentDirt value) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/assets/file_asset_referencer.hpp"
namespace rive {
-class ImageAsset;
-class Mesh;
-class Image : public ImageBase, public FileAssetReferencer {
-private:
- ImageAsset* m_ImageAsset = nullptr;
- Mesh* m_Mesh = nullptr;
+ class ImageAsset;
+ class Mesh;
+ class Image : public ImageBase, public FileAssetReferencer {
+ private:
+ ImageAsset* m_ImageAsset = nullptr;
+ Mesh* m_Mesh = nullptr;
-public:
- Mesh* mesh() const;
- void setMesh(Mesh* mesh);
- ImageAsset* imageAsset() const { return m_ImageAsset; }
- void draw(Renderer* renderer) override;
- Core* hitTest(HitInfo*, const Mat2D&) override;
- StatusCode import(ImportStack& importStack) override;
- void assets(const std::vector<FileAsset*>& assets) override;
- Core* clone() const override;
-};
+ public:
+ Mesh* mesh() const;
+ void setMesh(Mesh* mesh);
+ ImageAsset* imageAsset() const { return m_ImageAsset; }
+ void draw(Renderer* renderer) override;
+ Core* hitTest(HitInfo*, const Mat2D&) override;
+ StatusCode import(ImportStack& importStack) override;
+ void assets(const std::vector<FileAsset*>& assets) override;
+ Core* clone() const override;
+ };
} // namespace rive
#endif
#include "rive/renderer.hpp"
namespace rive {
-class MeshVertex;
+ class MeshVertex;
-class Mesh : public MeshBase, public Skinnable {
+ class Mesh : public MeshBase, public Skinnable {
-protected:
- class IndexBuffer : public std::vector<uint16_t>, public RefCnt {};
- std::vector<MeshVertex*> m_Vertices;
- rcp<IndexBuffer> m_IndexBuffer;
+ protected:
+ class IndexBuffer : public std::vector<uint16_t>, public RefCnt {};
+ std::vector<MeshVertex*> m_Vertices;
+ rcp<IndexBuffer> m_IndexBuffer;
- rcp<RenderBuffer> m_IndexRenderBuffer;
- rcp<RenderBuffer> m_VertexRenderBuffer;
- rcp<RenderBuffer> m_UVRenderBuffer;
+ rcp<RenderBuffer> m_IndexRenderBuffer;
+ rcp<RenderBuffer> m_VertexRenderBuffer;
+ rcp<RenderBuffer> m_UVRenderBuffer;
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- StatusCode onAddedClean(CoreContext* context) override;
- void markDrawableDirty();
- void addVertex(MeshVertex* vertex);
- void decodeTriangleIndexBytes(Span<const uint8_t> value) override;
- void copyTriangleIndexBytes(const MeshBase& object) override;
- void buildDependencies() override;
- void update(ComponentDirt value) override;
- void draw(Renderer* renderer, const RenderImage* image, BlendMode blendMode, float opacity);
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ StatusCode onAddedClean(CoreContext* context) override;
+ void markDrawableDirty();
+ void addVertex(MeshVertex* vertex);
+ void decodeTriangleIndexBytes(Span<const uint8_t> value) override;
+ void copyTriangleIndexBytes(const MeshBase& object) override;
+ void buildDependencies() override;
+ void update(ComponentDirt value) override;
+ void draw(Renderer* renderer, const RenderImage* image, BlendMode blendMode, float opacity);
- void updateVertexRenderBuffer(Renderer* renderer);
- void markSkinDirty() override;
+ void updateVertexRenderBuffer(Renderer* renderer);
+ void markSkinDirty() override;
#ifdef TESTING
- std::vector<MeshVertex*>& vertices() { return m_Vertices; }
- rcp<IndexBuffer> indices() { return m_IndexBuffer; }
+ std::vector<MeshVertex*>& vertices() { return m_Vertices; }
+ rcp<IndexBuffer> indices() { return m_IndexBuffer; }
#endif
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/generated/shapes/mesh_vertex_base.hpp"
#include <stdio.h>
namespace rive {
-class MeshVertex : public MeshVertexBase {
-public:
- void markGeometryDirty() override;
- StatusCode onAddedDirty(CoreContext* context) override;
-};
+ class MeshVertex : public MeshVertexBase {
+ public:
+ void markGeometryDirty() override;
+ StatusCode onAddedDirty(CoreContext* context) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_METRICS_PATH_HPP_
#include "rive/command_path.hpp"
-#include "rive/math/contour_measure.hpp"
#include "rive/math/vec2d.hpp"
#include <cassert>
#include <vector>
namespace rive {
-class MetricsPath : public CommandPath {
-private:
- RawPath m_RawPath; // temporary, until we build m_Contour
- rcp<ContourMeasure> m_Contour;
- std::vector<MetricsPath*> m_Paths;
- Mat2D m_ComputedLengthTransform;
- float m_ComputedLength = 0;
-
-public:
- const std::vector<MetricsPath*>& paths() const { return m_Paths; }
-
- void addPath(CommandPath* path, const Mat2D& transform) override;
- void reset() override;
- void moveTo(float x, float y) override;
- void lineTo(float x, float y) override;
- void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
- void close() override;
-
- float length() const { return m_ComputedLength; }
-
- /// Add commands to the result RenderPath that will draw the segment
- /// from startLength to endLength of this MetricsPath. Requires
- /// computeLength be called prior to trimming.
- void trim(float startLength, float endLength, bool moveTo, RenderPath* result);
-
-private:
- float computeLength(const Mat2D& transform);
-};
-
-class OnlyMetricsPath : public MetricsPath {
-public:
- void fillRule(FillRule value) override {}
-
- RenderPath* renderPath() override {
- // Should never be used for actual rendering.
- assert(false);
- return nullptr;
- }
-};
-
-class RenderMetricsPath : public MetricsPath {
-private:
- std::unique_ptr<RenderPath> m_RenderPath;
-
-public:
- RenderMetricsPath(std::unique_ptr<RenderPath>);
- RenderPath* renderPath() override { return m_RenderPath.get(); }
- void addPath(CommandPath* path, const Mat2D& transform) override;
-
- void fillRule(FillRule value) override;
- void reset() override;
- void moveTo(float x, float y) override;
- void lineTo(float x, float y) override;
- void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
- void close() override;
-};
+ struct CubicSegment {
+ float t;
+ float length;
+ CubicSegment(float tValue, float lengthValue) : t(tValue), length(lengthValue) {}
+ };
+
+ struct PathPart {
+ static const unsigned char line = 0;
+ /// Type is 0 when this is a line segment, it's 1 or greater when it's a
+ /// cubic. When it's a cubic it also represents the index in
+ /// CubicSegments-1.
+ unsigned char type;
+
+ /// Offset is the offset in original path points (which get transformed
+ /// when they're added to another path).
+ unsigned char offset;
+
+ // Only used by the cubic to count the number of cubic segments used by
+ // this part.
+ unsigned char numSegments;
+
+ PathPart(unsigned char t, unsigned char l) : type(t), offset(l), numSegments(0) {}
+ };
+
+ class MetricsPath : public CommandPath {
+ private:
+ std::vector<Vec2D> m_Points;
+ std::vector<Vec2D> m_TransformedPoints;
+ std::vector<CubicSegment> m_CubicSegments;
+ std::vector<PathPart> m_Parts;
+ std::vector<float> m_Lengths;
+ std::vector<MetricsPath*> m_Paths;
+ float m_ComputedLength = 0.0f;
+ Mat2D m_ComputedLengthTransform;
+
+ public:
+ const std::vector<MetricsPath*>& paths() const { return m_Paths; }
+ void addPath(CommandPath* path, const Mat2D& transform) override;
+ void reset() override;
+ void moveTo(float x, float y) override;
+ void lineTo(float x, float y) override;
+ void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
+ void close() override;
+
+ float length() const { return m_ComputedLength; }
+
+ /// Add commands to the result RenderPath that will draw the segment
+ /// from startLength to endLength of this MetricsPath. Requires
+ /// computeLength be called prior to trimming.
+ void trim(float startLength, float endLength, bool moveTo, RenderPath* result);
+
+ private:
+ float computeLength(const Mat2D& transform);
+
+ /// Extract a single segment from startT to endT as render commands
+ /// added to result.
+ void extractSubPart(int index, float startT, float endT, bool moveTo, RenderPath* result);
+ };
+
+ class OnlyMetricsPath : public MetricsPath {
+ public:
+ void fillRule(FillRule value) override {}
+
+ RenderPath* renderPath() override {
+ // Should never be used for actual rendering.
+ assert(false);
+ return nullptr;
+ }
+ };
+
+ class RenderMetricsPath : public MetricsPath {
+ private:
+ std::unique_ptr<RenderPath> m_RenderPath;
+
+ public:
+ RenderMetricsPath(std::unique_ptr<RenderPath>);
+ RenderPath* renderPath() override { return m_RenderPath.get(); }
+ void addPath(CommandPath* path, const Mat2D& transform) override;
+
+ void fillRule(FillRule value) override;
+ void reset() override;
+ void moveTo(float x, float y) override;
+ void lineTo(float x, float y) override;
+ void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
+ void close() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_BLEND_MODE_HPP_
#define _RIVE_BLEND_MODE_HPP_
namespace rive {
-enum class BlendMode : unsigned int {
- srcOver = 3,
- screen = 14,
- overlay = 15,
- darken = 16,
- lighten = 17,
- colorDodge = 18,
- colorBurn = 19,
- hardLight = 20,
- softLight = 21,
- difference = 22,
- exclusion = 23,
- multiply = 24,
- hue = 25,
- saturation = 26,
- color = 27,
- luminosity = 28
-};
+ enum class BlendMode : unsigned int {
+ srcOver = 3,
+ screen = 14,
+ overlay = 15,
+ darken = 16,
+ lighten = 17,
+ colorDodge = 18,
+ colorBurn = 19,
+ hardLight = 20,
+ softLight = 21,
+ difference = 22,
+ exclusion = 23,
+ multiply = 24,
+ hue = 25,
+ saturation = 26,
+ color = 27,
+ luminosity = 28
+ };
}
#endif
\ No newline at end of file
#include <cstdint>
namespace rive {
-using ColorInt = uint32_t;
+ using ColorInt = uint32_t;
-ColorInt colorARGB(int a, int r, int g, int b);
+ ColorInt colorARGB(int a, int r, int g, int b);
-unsigned int colorRed(ColorInt value);
+ unsigned int colorRed(ColorInt value);
-unsigned int colorGreen(ColorInt value);
+ unsigned int colorGreen(ColorInt value);
-unsigned int colorBlue(ColorInt value);
+ unsigned int colorBlue(ColorInt value);
-unsigned int colorAlpha(ColorInt value);
+ unsigned int colorAlpha(ColorInt value);
-float colorOpacity(unsigned int value);
+ float colorOpacity(unsigned int value);
-ColorInt colorWithAlpha(ColorInt value, unsigned int a);
+ ColorInt colorWithAlpha(ColorInt value, unsigned int a);
-ColorInt colorWithOpacity(ColorInt value, float opacity);
+ ColorInt colorWithOpacity(ColorInt value, float opacity);
-ColorInt colorModulateOpacity(ColorInt value, float opacity);
+ ColorInt colorModulateOpacity(ColorInt value, float opacity);
-ColorInt colorLerp(ColorInt from, ColorInt to, float mix);
+ ColorInt colorLerp(ColorInt from, ColorInt to, float mix);
} // namespace rive
#endif
#include "rive/generated/shapes/paint/fill_base.hpp"
#include "rive/shapes/path_space.hpp"
namespace rive {
-class Fill : public FillBase {
-public:
- RenderPaint* initRenderPaint(ShapePaintMutator* mutator) override;
- PathSpace pathSpace() const override;
- void draw(Renderer* renderer, CommandPath* path) override;
-};
+ class Fill : public FillBase {
+ public:
+ RenderPaint* initRenderPaint(ShapePaintMutator* mutator) override;
+ PathSpace pathSpace() const override;
+ void draw(Renderer* renderer, CommandPath* path) override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_GRADIENT_STOP_HPP_
#include "rive/generated/shapes/paint/gradient_stop_base.hpp"
namespace rive {
-class GradientStop : public GradientStopBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
+ class GradientStop : public GradientStopBase {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
-protected:
- void colorValueChanged() override;
- void positionChanged() override;
-};
+ protected:
+ void colorValueChanged() override;
+ void positionChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class Node;
-class GradientStop;
+ class Node;
+ class GradientStop;
-class LinearGradient : public LinearGradientBase, public ShapePaintMutator {
-private:
- std::vector<GradientStop*> m_Stops;
- Node* m_ShapePaintContainer = nullptr;
+ class LinearGradient : public LinearGradientBase, public ShapePaintMutator {
+ private:
+ std::vector<GradientStop*> m_Stops;
+ Node* m_ShapePaintContainer = nullptr;
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- void addStop(GradientStop* stop);
- void update(ComponentDirt value) override;
- void markGradientDirty();
- void markStopsDirty();
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ void addStop(GradientStop* stop);
+ void update(ComponentDirt value) override;
+ void markGradientDirty();
+ void markStopsDirty();
-protected:
- void buildDependencies() override;
- void startXChanged() override;
- void startYChanged() override;
- void endXChanged() override;
- void endYChanged() override;
- void opacityChanged() override;
- void renderOpacityChanged() override;
- bool internalIsTranslucent() const override;
+ protected:
+ void buildDependencies() override;
+ void startXChanged() override;
+ void startYChanged() override;
+ void endXChanged() override;
+ void endYChanged() override;
+ void opacityChanged() override;
+ void renderOpacityChanged() override;
+ bool internalIsTranslucent() const override;
- virtual void
- makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count);
-};
+ virtual void
+ makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count);
+ };
} // namespace rive
#endif
#define _RIVE_RADIAL_GRADIENT_HPP_
#include "rive/generated/shapes/paint/radial_gradient_base.hpp"
namespace rive {
-class RadialGradient : public RadialGradientBase {
-public:
- void
- makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count) override;
-};
+ class RadialGradient : public RadialGradientBase {
+ public:
+ void makeGradient(
+ Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count) override;
+ };
} // namespace rive
#endif
#include "rive/shapes/paint/shape_paint_mutator.hpp"
#include "rive/shapes/path_space.hpp"
namespace rive {
-class RenderPaint;
-class ShapePaintMutator;
-class ShapePaint : public ShapePaintBase {
-protected:
- std::unique_ptr<RenderPaint> m_RenderPaint;
- ShapePaintMutator* m_PaintMutator = nullptr;
+ class RenderPaint;
+ class ShapePaintMutator;
+ class ShapePaint : public ShapePaintBase {
+ protected:
+ std::unique_ptr<RenderPaint> m_RenderPaint;
+ ShapePaintMutator* m_PaintMutator = nullptr;
-public:
- StatusCode onAddedClean(CoreContext* context) override;
+ public:
+ StatusCode onAddedClean(CoreContext* context) override;
- float renderOpacity() const { return m_PaintMutator->renderOpacity(); }
- void renderOpacity(float value) { m_PaintMutator->renderOpacity(value); }
+ float renderOpacity() const { return m_PaintMutator->renderOpacity(); }
+ void renderOpacity(float value) { m_PaintMutator->renderOpacity(value); }
- void blendMode(BlendMode value);
+ void blendMode(BlendMode value);
- /// Creates a RenderPaint object for the provided ShapePaintMutator*.
- /// This should be called only once as the ShapePaint manages the
- /// lifecycle of the RenderPaint.
- virtual RenderPaint* initRenderPaint(ShapePaintMutator* mutator);
+ /// Creates a RenderPaint object for the provided ShapePaintMutator*.
+ /// This should be called only once as the ShapePaint manages the
+ /// lifecycle of the RenderPaint.
+ virtual RenderPaint* initRenderPaint(ShapePaintMutator* mutator);
- virtual PathSpace pathSpace() const = 0;
+ virtual PathSpace pathSpace() const = 0;
- virtual void draw(Renderer* renderer, CommandPath* path) = 0;
+ virtual void draw(Renderer* renderer, CommandPath* path) = 0;
- RenderPaint* renderPaint() { return m_RenderPaint.get(); }
+ RenderPaint* renderPaint() { return m_RenderPaint.get(); }
+
+ /// Get the component that represents the ShapePaintMutator for this
+ /// ShapePaint. It'll be one of SolidColor, LinearGradient, or
+ /// RadialGradient.
+ Component* paint() const { return m_PaintMutator->component(); }
- /// Get the component that represents the ShapePaintMutator for this
- /// ShapePaint. It'll be one of SolidColor, LinearGradient, or
- /// RadialGradient.
- Component* paint() const { return m_PaintMutator->component(); }
-
- bool isTranslucent() const { return !this->isVisible() || m_PaintMutator->isTranslucent(); }
-};
+ bool isTranslucent() const { return !this->isVisible() || m_PaintMutator->isTranslucent(); }
+ };
} // namespace rive
#endif
#define _RIVE_SHAPE_PAINT_MUTATOR_HPP_
namespace rive {
-class Component;
-class RenderPaint;
-class ShapePaintMutator {
-private:
- float m_RenderOpacity = 1.0f;
- RenderPaint* m_RenderPaint = nullptr;
- /// The Component providing this ShapePaintMutator interface.
- Component* m_Component = nullptr;
+ class Component;
+ class RenderPaint;
+ class ShapePaintMutator {
+ private:
+ float m_RenderOpacity = 1.0f;
+ RenderPaint* m_RenderPaint = nullptr;
+ /// The Component providing this ShapePaintMutator interface.
+ Component* m_Component = nullptr;
-protected:
- /// Hook up this paint mutator as the mutator for the shape paint
- /// expected to be the parent.
- bool initPaintMutator(Component* component);
- virtual void renderOpacityChanged() = 0;
+ protected:
+ /// Hook up this paint mutator as the mutator for the shape paint
+ /// expected to be the parent.
+ bool initPaintMutator(Component* component);
+ virtual void renderOpacityChanged() = 0;
- RenderPaint* renderPaint() const { return m_RenderPaint; }
+ RenderPaint* renderPaint() const { return m_RenderPaint; }
- virtual bool internalIsTranslucent() const = 0;
+ virtual bool internalIsTranslucent() const = 0;
-public:
- virtual ~ShapePaintMutator() {}
+ public:
+ float renderOpacity() const { return m_RenderOpacity; }
+ void renderOpacity(float value);
- float renderOpacity() const { return m_RenderOpacity; }
- void renderOpacity(float value);
+ Component* component() const { return m_Component; }
- Component* component() const { return m_Component; }
-
- bool isTranslucent() const { return m_RenderOpacity < 1 || this->internalIsTranslucent(); }
-};
+ bool isTranslucent() const { return m_RenderOpacity < 1 || this->internalIsTranslucent(); }
+ };
} // namespace rive
#endif
#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 {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
+ class SolidColor : public SolidColorBase, public ShapePaintMutator {
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
-protected:
- void renderOpacityChanged() override;
- void colorValueChanged() override;
- bool internalIsTranslucent() const override;
-};
+ protected:
+ void renderOpacityChanged() override;
+ void colorValueChanged() override;
+ bool internalIsTranslucent() const override;
+ };
} // namespace rive
#endif
#include "rive/generated/shapes/paint/stroke_base.hpp"
#include "rive/shapes/path_space.hpp"
namespace rive {
-class StrokeEffect;
-class Stroke : public StrokeBase {
-private:
- StrokeEffect* m_Effect = nullptr;
+ class StrokeEffect;
+ class Stroke : public StrokeBase {
+ private:
+ StrokeEffect* m_Effect = nullptr;
-public:
- RenderPaint* initRenderPaint(ShapePaintMutator* mutator) override;
- PathSpace pathSpace() const override;
- void draw(Renderer* renderer, CommandPath* path) override;
- void addStrokeEffect(StrokeEffect* effect);
- bool hasStrokeEffect() { return m_Effect != nullptr; }
- void invalidateEffects();
- bool isVisible() const override;
- void invalidateRendering();
+ public:
+ RenderPaint* initRenderPaint(ShapePaintMutator* mutator) override;
+ PathSpace pathSpace() const override;
+ void draw(Renderer* renderer, CommandPath* path) override;
+ void addStrokeEffect(StrokeEffect* effect);
+ bool hasStrokeEffect() { return m_Effect != nullptr; }
+ void invalidateEffects();
+ bool isVisible() const override;
-protected:
- void thicknessChanged() override;
- void capChanged() override;
- void joinChanged() override;
-};
+ protected:
+ void thicknessChanged() override;
+ void capChanged() override;
+ void joinChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_STROKE_CAP_HPP_
#define _RIVE_STROKE_CAP_HPP_
namespace rive {
-/// Style used for stroke line endings.
-enum class StrokeCap : unsigned int {
- /// Flat edge at the start/end of the stroke.
- butt = 0,
+ /// Style used for stroke line endings.
+ enum class StrokeCap : unsigned int {
+ /// Flat edge at the start/end of the stroke.
+ butt = 0,
- /// Circular edge at the start/end of the stroke.
- round = 1,
+ /// Circular edge at the start/end of the stroke.
+ round = 1,
- /// Flat protruding edge at the start/end of the stroke.
- square = 2
-};
+ /// Flat protruding edge at the start/end of the stroke.
+ square = 2
+ };
} // namespace rive
#endif
#include "rive/rive_types.hpp"
namespace rive {
-class Factory;
-class RenderPath;
-class MetricsPath;
+ class Factory;
+ class RenderPath;
+ class MetricsPath;
-class StrokeEffect {
-public:
- virtual ~StrokeEffect() {}
- virtual RenderPath* effectPath(MetricsPath* source, Factory*) = 0;
- virtual void invalidateEffect() = 0;
-};
+ class StrokeEffect {
+ public:
+ virtual RenderPath* effectPath(MetricsPath* source, Factory*) = 0;
+ virtual void invalidateEffect() = 0;
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_STROKE_JOIN_HPP_
#define _RIVE_STROKE_JOIN_HPP_
namespace rive {
-/// Style used for stroke segment joins when there is a sharp change.
-enum class StrokeJoin : unsigned int {
- /// Makes a sharp corner at the joint.
- miter = 0,
+ /// Style used for stroke segment joins when there is a sharp change.
+ enum class StrokeJoin : unsigned int {
+ /// Makes a sharp corner at the joint.
+ miter = 0,
- /// Smoothens the joint with a circular/semi-circular shape at the
- /// joint.
- round = 1,
+ /// Smoothens the joint with a circular/semi-circular shape at the
+ /// joint.
+ round = 1,
- /// Creates a beveled edge at the joint.
- bevel = 2
-};
+ /// Creates a beveled edge at the joint.
+ bevel = 2
+ };
} // namespace rive
#endif
#include <stdio.h>
namespace rive {
-class TrimPath : public TrimPathBase, public StrokeEffect {
-private:
- std::unique_ptr<RenderPath> m_TrimmedPath;
- RenderPath* m_RenderPath = nullptr;
+ class TrimPath : public TrimPathBase, public StrokeEffect {
+ private:
+ std::unique_ptr<RenderPath> m_TrimmedPath;
+ RenderPath* m_RenderPath = nullptr;
-public:
- StatusCode onAddedClean(CoreContext* context) override;
- RenderPath* effectPath(MetricsPath* source, Factory*) override;
- void invalidateEffect() override;
+ public:
+ StatusCode onAddedClean(CoreContext* context) override;
+ RenderPath* effectPath(MetricsPath* source, Factory*) override;
+ void invalidateEffect() override;
- void startChanged() override;
- void endChanged() override;
- void offsetChanged() override;
- void modeValueChanged() override;
-};
+ void startChanged() override;
+ void endChanged() override;
+ void offsetChanged() override;
+ void modeValueChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_PARAMETRIC_PATH_HPP_
#include "rive/generated/shapes/parametric_path_base.hpp"
namespace rive {
-class ParametricPath : public ParametricPathBase {
-protected:
- void widthChanged() override;
- void heightChanged() override;
- void originXChanged() override;
- void originYChanged() override;
-};
+ class ParametricPath : public ParametricPathBase {
+ protected:
+ void widthChanged() override;
+ void heightChanged() override;
+ void originXChanged() override;
+ void originYChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class Shape;
-class PathVertex;
+ class Shape;
+ class PathVertex;
#ifdef ENABLE_QUERY_FLAT_VERTICES
-/// Optionally compiled in for tools that need to compute per frame world
-/// transformed path vertices. These should not be used at runtime as it's
-/// not optimized for performance (it does a lot of memory allocation).
+ /// Optionally compiled in for tools that need to compute per frame world
+ /// transformed path vertices. These should not be used at runtime as it's
+ /// not optimized for performance (it does a lot of memory allocation).
-/// A flattened path is composed of only linear
-/// 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 {
-private:
- std::vector<PathVertex*> m_Vertices;
+ /// A flattened path is composed of only linear
+ /// 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 {
+ private:
+ std::vector<PathVertex*> m_Vertices;
-public:
- ~FlattenedPath();
+ public:
+ ~FlattenedPath();
- const std::vector<PathVertex*>& vertices() const { return m_Vertices; }
- void addVertex(PathVertex* vertex, const Mat2D& transform);
-};
+ const std::vector<PathVertex*>& vertices() const { return m_Vertices; }
+ void addVertex(PathVertex* vertex, const Mat2D& transform);
+ };
#endif
-class Path : public PathBase {
-protected:
- Shape* m_Shape = nullptr;
- std::unique_ptr<CommandPath> m_CommandPath;
- std::vector<PathVertex*> m_Vertices;
+ class Path : public PathBase {
+ protected:
+ Shape* m_Shape = nullptr;
+ std::unique_ptr<CommandPath> m_CommandPath;
+ std::vector<PathVertex*> m_Vertices;
-public:
- Shape* shape() const { return m_Shape; }
- StatusCode onAddedClean(CoreContext* context) override;
- void buildDependencies() override;
- virtual const Mat2D& pathTransform() const;
- CommandPath* commandPath() const { return m_CommandPath.get(); }
- void update(ComponentDirt value) override;
+ public:
+ Shape* shape() const { return m_Shape; }
+ StatusCode onAddedClean(CoreContext* context) override;
+ void buildDependencies() override;
+ virtual const Mat2D& pathTransform() const;
+ CommandPath* commandPath() const { return m_CommandPath.get(); }
+ void update(ComponentDirt value) override;
- void addVertex(PathVertex* vertex);
+ void addVertex(PathVertex* vertex);
- virtual void markPathDirty();
- virtual bool isPathClosed() const { return true; }
- void onDirty(ComponentDirt dirt) override;
+ virtual void markPathDirty();
+ virtual bool isPathClosed() const { return true; }
+ void onDirty(ComponentDirt dirt) override;
#ifdef ENABLE_QUERY_FLAT_VERTICES
- FlattenedPath* makeFlat(bool transformToParent);
+ FlattenedPath* makeFlat(bool transformToParent);
#endif
#ifdef TESTING
- std::vector<PathVertex*>& vertices() { return m_Vertices; }
+ std::vector<PathVertex*>& vertices() { return m_Vertices; }
#endif
- // pour ourselves into a command-path
- void buildPath(CommandPath&) const;
-};
+ // pour ourselves into a command-path
+ void buildPath(CommandPath&) const;
+ };
} // namespace rive
#endif
#define _RIVE_PATH_COMPOSER_HPP_
#include "rive/component.hpp"
namespace rive {
-class Shape;
-class CommandPath;
-class RenderPath;
-class PathComposer : public Component {
-private:
- Shape* m_Shape;
- std::unique_ptr<CommandPath> m_LocalPath;
- std::unique_ptr<CommandPath> m_WorldPath;
+ class Shape;
+ class CommandPath;
+ class RenderPath;
+ class PathComposer : public Component {
+ private:
+ Shape* m_Shape;
+ std::unique_ptr<CommandPath> m_LocalPath;
+ std::unique_ptr<CommandPath> m_WorldPath;
-public:
- PathComposer(Shape* shape);
- Shape* shape() const { return m_Shape; }
- void buildDependencies() override;
- void update(ComponentDirt value) override;
+ public:
+ PathComposer(Shape* shape);
+ Shape* shape() const { return m_Shape; }
+ void buildDependencies() override;
+ void update(ComponentDirt value) override;
- CommandPath* localPath() const { return m_LocalPath.get(); }
- CommandPath* worldPath() const { return m_WorldPath.get(); }
-};
+ CommandPath* localPath() const { return m_LocalPath.get(); }
+ CommandPath* worldPath() const { return m_WorldPath.get(); }
+ };
} // namespace rive
#endif
#include "rive/rive_types.hpp"
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) {
- return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) &
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
-}
-
-inline constexpr PathSpace operator^(PathSpace lhs, PathSpace rhs) {
- return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
-}
-
-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) {
- return static_cast<PathSpace>(~static_cast<std::underlying_type<PathSpace>::type>(rhs));
-}
-
-inline PathSpace& operator|=(PathSpace& lhs, PathSpace rhs) {
- lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) |
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
-
- return lhs;
-}
-
-inline PathSpace& operator&=(PathSpace& lhs, PathSpace rhs) {
- lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) &
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
-
- return lhs;
-}
-
-inline PathSpace& operator^=(PathSpace& lhs, PathSpace rhs) {
- lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
- static_cast<std::underlying_type<PathSpace>::type>(rhs));
-
- return lhs;
-}
+ enum class PathSpace : unsigned char {
+ Neither = 0,
+ Local = 1 << 1,
+ World = 1 << 2,
+ Difference = 1 << 3,
+ Clipping = 1 << 4
+ };
+
+ 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) {
+ return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ }
+
+ inline constexpr PathSpace operator|(PathSpace lhs, PathSpace rhs) {
+ return static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) |
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
+ }
+
+ 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) {
+ lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) |
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
+
+ return lhs;
+ }
+
+ inline PathSpace& operator&=(PathSpace& lhs, PathSpace rhs) {
+ lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) &
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
+
+ return lhs;
+ }
+
+ inline PathSpace& operator^=(PathSpace& lhs, PathSpace rhs) {
+ lhs = static_cast<PathSpace>(static_cast<std::underlying_type<PathSpace>::type>(lhs) ^
+ static_cast<std::underlying_type<PathSpace>::type>(rhs));
+
+ return lhs;
+ }
} // namespace rive
#endif
#include "rive/generated/shapes/path_vertex_base.hpp"
#include "rive/math/mat2d.hpp"
namespace rive {
-class PathVertex : public PathVertexBase {
+ class PathVertex : public PathVertexBase {
-public:
- StatusCode onAddedDirty(CoreContext* context) override;
- void markGeometryDirty() override;
-};
+ public:
+ StatusCode onAddedDirty(CoreContext* context) override;
+ void markGeometryDirty() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/bones/skinnable.hpp"
#include "rive/generated/shapes/points_path_base.hpp"
namespace rive {
-class PointsPath : public PointsPathBase, public Skinnable {
-public:
- bool isPathClosed() const override { return isClosed(); }
- void buildDependencies() override;
- void update(ComponentDirt value) override;
- void markPathDirty() override;
- void markSkinDirty() override;
- const Mat2D& pathTransform() const override;
-};
+ class PointsPath : public PointsPathBase, public Skinnable {
+ public:
+ bool isPathClosed() const override { return isClosed(); }
+ void buildDependencies() override;
+ void update(ComponentDirt value) override;
+ void markPathDirty() override;
+ void markSkinDirty() override;
+ const Mat2D& pathTransform() const override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/shapes/straight_vertex.hpp"
#include <vector>
namespace rive {
-class Polygon : public PolygonBase {
-protected:
- std::vector<StraightVertex> m_PolygonVertices;
+ class Polygon : public PolygonBase {
+ protected:
+ std::vector<StraightVertex> m_PolygonVertices;
-public:
- Polygon();
- ~Polygon() override;
- void update(ComponentDirt value) override;
+ public:
+ Polygon();
+ ~Polygon();
+ void update(ComponentDirt value) override;
-protected:
- void cornerRadiusChanged() override;
- void pointsChanged() override;
- virtual std::size_t vertexCount();
- virtual void buildPolygon();
-};
+ protected:
+ void cornerRadiusChanged() override;
+ void pointsChanged() override;
+ virtual std::size_t vertexCount();
+ virtual void buildPolygon();
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/shapes/straight_vertex.hpp"
namespace rive {
-class Rectangle : public RectangleBase {
- StraightVertex m_Vertex1, m_Vertex2, m_Vertex3, m_Vertex4;
+ class Rectangle : public RectangleBase {
+ StraightVertex m_Vertex1, m_Vertex2, m_Vertex3, m_Vertex4;
-public:
- Rectangle();
- void update(ComponentDirt value) override;
+ public:
+ Rectangle();
+ void update(ComponentDirt value) override;
-protected:
- void cornerRadiusTLChanged() override;
- void cornerRadiusTRChanged() override;
- void cornerRadiusBLChanged() override;
- void cornerRadiusBRChanged() override;
-};
+ protected:
+ void cornerRadiusTLChanged() override;
+ void cornerRadiusTRChanged() override;
+ void cornerRadiusBLChanged() override;
+ void cornerRadiusBRChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include <vector>
namespace rive {
-class Path;
-class PathComposer;
-class HitTester;
-class Shape : public ShapeBase, public ShapePaintContainer {
-private:
- PathComposer m_PathComposer;
- std::vector<Path*> m_Paths;
-
- bool m_WantDifferencePath = false;
-
- Artboard* getArtboard() override { return artboard(); }
-
-public:
- Shape();
- void buildDependencies() override;
- void addPath(Path* path);
- std::vector<Path*>& paths() { return m_Paths; }
-
- bool wantDifferencePath() const { return m_WantDifferencePath; }
-
- void update(ComponentDirt value) override;
- void draw(Renderer* renderer) override;
- Core* hitTest(HitInfo*, const Mat2D&) override;
- bool hitTest(const IAABB& area) const;
-
- const PathComposer* pathComposer() const { return &m_PathComposer; }
- PathComposer* pathComposer() { return &m_PathComposer; }
-
- void pathChanged();
- void addDefaultPathSpace(PathSpace space);
- StatusCode onAddedDirty(CoreContext* context) override;
-};
+ class Path;
+ class PathComposer;
+ class HitTester;
+ class Shape : public ShapeBase, public ShapePaintContainer {
+ private:
+ PathComposer m_PathComposer;
+ std::vector<Path*> m_Paths;
+
+ bool m_WantDifferencePath = false;
+
+ Artboard* getArtboard() override { return artboard(); }
+
+ public:
+ Shape();
+ void buildDependencies() override;
+ void addPath(Path* path);
+ std::vector<Path*>& paths() { return m_Paths; }
+
+ bool wantDifferencePath() const { return m_WantDifferencePath; }
+
+ void update(ComponentDirt value) override;
+ void draw(Renderer* renderer) override;
+ Core* hitTest(HitInfo*, const Mat2D&) override;
+ bool hitTest(const IAABB& area) const;
+
+ PathComposer* pathComposer() const { return (PathComposer*)&m_PathComposer; }
+
+ void pathChanged();
+ void addDefaultPathSpace(PathSpace space);
+ StatusCode onAddedDirty(CoreContext* context) override;
+ };
} // namespace rive
#endif
#include <vector>
namespace rive {
-class Artboard;
-class ShapePaint;
-class Component;
+ class Artboard;
+ class ShapePaint;
+ class Component;
-class CommandPath;
+ class CommandPath;
-class ShapePaintContainer {
- friend class ShapePaint;
+ class ShapePaintContainer {
+ friend class ShapePaint;
-protected:
- // Need this to access our artboard. We are treated as a mixin, either
- // as a Shape or Artboard, so both of those will override this.
- virtual Artboard* getArtboard() = 0;
+ protected:
+ // Need this to access our artboard. We are treated as a mixin, either
+ // as a Shape or Artboard, so both of those will override this.
+ virtual Artboard* getArtboard() = 0;
+
+ PathSpace m_DefaultPathSpace = PathSpace::Neither;
+ std::vector<ShapePaint*> m_ShapePaints;
+ void addPaint(ShapePaint* paint);
- PathSpace m_DefaultPathSpace = PathSpace::Neither;
- std::vector<ShapePaint*> m_ShapePaints;
- void addPaint(ShapePaint* paint);
+ // TODO: void draw(Renderer* renderer, PathComposer& composer);
+ public:
+ static ShapePaintContainer* from(Component* component);
- // TODO: void draw(Renderer* renderer, PathComposer& composer);
-public:
- static ShapePaintContainer* from(Component* component);
+ PathSpace pathSpace() const;
- virtual ~ShapePaintContainer() {}
+ void invalidateStrokeEffects();
- PathSpace pathSpace() const;
-
- void invalidateStrokeEffects();
-
- std::unique_ptr<CommandPath> makeCommandPath(PathSpace space);
-};
+ std::unique_ptr<CommandPath> makeCommandPath(PathSpace space);
+ };
} // namespace rive
#endif
#include "rive/generated/shapes/star_base.hpp"
#include <stdio.h>
namespace rive {
-class Star : public StarBase {
-public:
- Star();
- void update(ComponentDirt value) override;
+ class Star : public StarBase {
+ public:
+ Star();
+ void update(ComponentDirt value) override;
-protected:
- void innerRadiusChanged() override;
- std::size_t vertexCount() override;
- void buildPolygon() override;
-};
+ protected:
+ void innerRadiusChanged() override;
+ std::size_t vertexCount() override;
+ void buildPolygon() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#define _RIVE_STRAIGHT_VERTEX_HPP_
#include "rive/generated/shapes/straight_vertex_base.hpp"
namespace rive {
-class StraightVertex : public StraightVertexBase {
-protected:
- void radiusChanged() override;
-};
+ class StraightVertex : public StraightVertexBase {
+ protected:
+ void radiusChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/shapes/straight_vertex.hpp"
namespace rive {
-class Triangle : public TriangleBase {
-private:
- StraightVertex m_Vertex1, m_Vertex2, m_Vertex3;
+ class Triangle : public TriangleBase {
+ private:
+ StraightVertex m_Vertex1, m_Vertex2, m_Vertex3;
-public:
- Triangle();
- void update(ComponentDirt value) override;
-};
+ public:
+ Triangle();
+ void update(ComponentDirt value) override;
+ };
} // namespace rive
#endif
#include "rive/generated/shapes/vertex_base.hpp"
#include "rive/math/mat2d.hpp"
namespace rive {
-class Vertex : public VertexBase {
- friend class Weight;
+ class Vertex : public VertexBase {
+ friend class Weight;
-private:
- Weight* m_Weight = nullptr;
- void weight(Weight* value) { m_Weight = value; }
+ private:
+ Weight* m_Weight = nullptr;
+ void weight(Weight* value) { m_Weight = value; }
-public:
- template <typename T> T* weight() { return m_Weight->as<T>(); }
- virtual void deform(const Mat2D& worldTransform, const float* boneTransforms);
- bool hasWeight() { return m_Weight != nullptr; }
- Vec2D renderTranslation();
+ public:
+ template <typename T> T* weight() { return m_Weight->as<T>(); }
+ virtual void deform(const Mat2D& worldTransform, const float* boneTransforms);
+ bool hasWeight() { return m_Weight != nullptr; }
+ Vec2D renderTranslation();
-protected:
- virtual void markGeometryDirty() = 0;
- void xChanged() override;
- void yChanged() override;
+ protected:
+ virtual void markGeometryDirty() = 0;
+ void xChanged() override;
+ void yChanged() override;
#ifdef TESTING
-public:
- Weight* weight() { return m_Weight; }
+ public:
+ Weight* weight() { return m_Weight; }
#endif
-};
+ };
} // namespace rive
#endif
\ No newline at end of file
#include "rive/rive_types.hpp"
-#include <initializer_list>
-#include <type_traits>
-
/*
* Span : cheap impl of std::span (which is C++20)
*
namespace rive {
-template <typename T> class Span {
- T* m_Ptr;
- size_t m_Size;
-
-public:
- Span() : m_Ptr(nullptr), m_Size(0) {}
- Span(T* ptr, size_t size) : m_Ptr(ptr), m_Size(size) { assert(ptr <= ptr + size); }
-
- // Handle Span<foo> --> Span<const foo>
- template <typename U, typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
- constexpr Span(const Span<U>& that) : Span(that.data(), that.size()) {}
- constexpr Span(const Span&) = default;
- 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 {
- assert(index < m_Size);
- return m_Ptr[index];
- }
-
- constexpr T* data() const { return m_Ptr; }
- constexpr size_t size() const { return m_Size; }
- constexpr bool empty() const { return m_Size == 0; }
-
- constexpr T* begin() const { return m_Ptr; }
- constexpr T* end() const { return m_Ptr + m_Size; }
-
- constexpr T& front() const { return (*this)[0]; }
- constexpr T& back() const { return (*this)[m_Size - 1]; }
-
- // returns byte-size of the entire span
- constexpr size_t size_bytes() const { return m_Size * sizeof(T); }
-
- constexpr int count() const {
- const int n = static_cast<int>(m_Size);
- assert(n >= 0);
- return n;
+ template <typename T> class Span {
+ T* m_Ptr;
+ size_t m_Size;
+
+ public:
+ Span() : m_Ptr(nullptr), m_Size(0) {}
+ Span(T* ptr, size_t size) : m_Ptr(ptr), m_Size(size) { assert(ptr <= ptr + size); }
+
+ // Handle Span<foo> --> Span<const foo>
+ template <typename U,
+ typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
+ constexpr Span(const Span<U>& that) : Span(that.data(), that.size()) {}
+ constexpr Span(const Span&) = default;
+
+ constexpr T& operator[](size_t index) const {
+ assert(index < m_Size);
+ return m_Ptr[index];
+ }
+
+ constexpr T* data() const { return m_Ptr; }
+ constexpr size_t size() const { return m_Size; }
+ constexpr bool empty() const { return m_Size == 0; }
+
+ constexpr T* begin() const { return m_Ptr; }
+ constexpr T* end() const { return m_Ptr + m_Size; }
+
+ constexpr T& front() const { return (*this)[0]; }
+ constexpr T& back() const { return (*this)[m_Size - 1]; }
+
+ // returns byte-size of the entire span
+ constexpr size_t size_bytes() const { return m_Size * sizeof(T); }
+
+ 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 {
+ assert(offset <= m_Size);
+ assert(size <= m_Size - offset);
+ return {m_Ptr + offset, size};
+ }
+ };
+
+ template <typename Container>
+ inline auto toSpan(Container& c)
+ -> Span<typename std::remove_reference<decltype(*(c.data()))>::type> {
+ return {c.data(), c.size()};
}
- 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};
- }
-
- // Makes rive::Span std::Container compatible
- // https://en.cppreference.com/w/cpp/named_req/Container
- typedef typename std::remove_cv<T>::type value_type;
- typedef T& reference;
- typedef T const& const_reference;
- typedef T* iterator;
- typedef T const* const_iterator;
- typedef std::ptrdiff_t difference_type;
- typedef size_t size_type;
-};
-
} // namespace rive
#endif
#include "rive/rive_types.hpp"
namespace rive {
-enum class StatusCode : unsigned char { Ok, MissingObject, InvalidObject, FailedInversion };
+ enum class StatusCode : unsigned char { Ok, MissingObject, InvalidObject, FailedInversion };
}
#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_RENDER_GLYPH_LINE_H_
-#define _RIVE_RENDER_GLYPH_LINE_H_
-
-#include "rive/render_text.hpp"
-
-namespace rive {
-
-struct RenderGlyphLine {
- int startRun;
- int startIndex;
- int endRun;
- int endIndex;
- int wsRun;
- int wsIndex;
- float startX;
- float top = 0, baseline = 0, bottom = 0;
-
- RenderGlyphLine(int startRun,
- int startIndex,
- int endRun,
- int endIndex,
- int wsRun,
- int wsIndex,
- float startX) :
- startRun(startRun),
- startIndex(startIndex),
- endRun(endRun),
- endIndex(endIndex),
- wsRun(wsRun),
- wsIndex(wsIndex),
- startX(startX) {}
-
- static std::vector<RenderGlyphLine> BreakLines(Span<const RenderGlyphRun> runs,
- Span<const int> breaks,
- float width);
-
- // Compute values for top/baseline/bottom per line
- static void ComputeLineSpacing(rive::Span<RenderGlyphLine>, rive::Span<const RenderGlyphRun>);
-};
-
-} // namespace rive
-
-#endif
#include "rive/math/mat2d.hpp"
namespace rive {
-class Constraint;
-class WorldTransformComponent;
-class TransformComponent : public TransformComponentBase {
-private:
- Mat2D m_Transform;
- float m_RenderOpacity = 0.0f;
- WorldTransformComponent* m_ParentTransformComponent = nullptr;
- std::vector<Constraint*> m_Constraints;
-
-public:
+ class Constraint;
+ class WorldTransformComponent;
+ class TransformComponent : public TransformComponentBase {
+ private:
+ Mat2D m_Transform;
+ float m_RenderOpacity = 0.0f;
+ WorldTransformComponent* m_ParentTransformComponent = nullptr;
+ std::vector<Constraint*> m_Constraints;
+
+ public:
#ifdef TESTING
- const std::vector<Constraint*>& constraints() const { return m_Constraints; }
+ const std::vector<Constraint*>& constraints() const { return m_Constraints; }
#endif
- StatusCode onAddedClean(CoreContext* context) override;
- void buildDependencies() override;
- void update(ComponentDirt value) override;
- void updateTransform();
- void updateWorldTransform();
- void markTransformDirty();
+ StatusCode onAddedClean(CoreContext* context) override;
+ void buildDependencies() override;
+ void update(ComponentDirt value) override;
+ void updateTransform();
+ void updateWorldTransform();
+ void markTransformDirty();
- /// Opacity inherited by any child of this transform component. This'll
- /// later get overridden by effect layers.
- float childOpacity() override { return m_RenderOpacity; }
- float renderOpacity() const { return m_RenderOpacity; }
+ /// Opacity inherited by any child of this transform component. This'll
+ /// later get overridden by effect layers.
+ float childOpacity() override { return m_RenderOpacity; }
+ float renderOpacity() const { return m_RenderOpacity; }
- const Mat2D& transform() const;
+ const Mat2D& transform() const;
- /// Explicitly dangerous. Use transform/worldTransform when you don't
- /// need to transform things outside of their hierarchy.
- Mat2D& mutableTransform();
+ /// Explicitly dangerous. Use transform/worldTransform when you don't
+ /// need to transform things outside of their hierarchy.
+ Mat2D& mutableTransform();
- virtual float x() const = 0;
- virtual float y() const = 0;
+ virtual float x() const = 0;
+ virtual float y() const = 0;
- void rotationChanged() override;
- void scaleXChanged() override;
- void scaleYChanged() override;
+ void rotationChanged() override;
+ void scaleXChanged() override;
+ void scaleYChanged() override;
- void addConstraint(Constraint* constraint);
-};
+ void addConstraint(Constraint* constraint);
+ };
} // namespace rive
#endif
\ No newline at end of file
#ifndef _RIVE_TRANSFORM_SPACE_HPP_
#define _RIVE_TRANSFORM_SPACE_HPP_
namespace rive {
-enum class TransformSpace : unsigned int { world = 0, local = 1 };
+ enum class TransformSpace : unsigned int { world = 0, local = 1 };
}
#endif
\ No newline at end of file
#include "rive/math/mat2d.hpp"
namespace rive {
-class TransformComponent;
-class WorldTransformComponent : public WorldTransformComponentBase {
- friend class TransformComponent;
+ class TransformComponent;
+ class WorldTransformComponent : public WorldTransformComponentBase {
+ friend class TransformComponent;
-protected:
- Mat2D m_WorldTransform;
+ protected:
+ Mat2D m_WorldTransform;
-public:
- void markWorldTransformDirty();
- virtual float childOpacity();
- Mat2D& mutableWorldTransform();
- const Mat2D& worldTransform() const;
- Vec2D worldTranslation() const { return m_WorldTransform.translation(); }
- void opacityChanged() override;
-};
+ public:
+ void markWorldTransformDirty();
+ virtual float childOpacity();
+ Mat2D& mutableWorldTransform();
+ const Mat2D& worldTransform() const;
+ Vec2D worldTranslation() const { return m_WorldTransform.translation(); }
+ void opacityChanged() override;
+ };
} // namespace rive
#endif
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_FACTORY_UTILS_HPP_
-#define _RIVE_FACTORY_UTILS_HPP_
-
-#include "rive/factory.hpp"
-
-namespace rive {
-
-// Generic subclass of RenderBuffer that just stores the data on the cpu.
-//
-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) {
- 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 {
- assert(m_elemSize == sizeof(float));
- return reinterpret_cast<const float*>(m_storage.data());
- }
-
- const uint16_t* u16s() const {
- assert(m_elemSize == sizeof(uint16_t));
- return reinterpret_cast<const uint16_t*>(m_storage.data());
- }
-
- const Vec2D* vecs() const { return reinterpret_cast<const Vec2D*>(this->f32s()); }
-
- size_t elemSize() const { return m_elemSize; }
-
- static const DataRenderBuffer* Cast(const RenderBuffer* buffer) {
- return static_cast<const DataRenderBuffer*>(buffer);
- }
-
- template <typename T> static rcp<RenderBuffer> Make(Span<T> span) {
- return rcp<RenderBuffer>(new DataRenderBuffer(span.data(), span.size(), sizeof(T)));
- }
-};
-
-} // namespace rive
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_NOOP_FACTORY_HPP_
-#define _RIVE_NOOP_FACTORY_HPP_
-
-#include "rive/factory.hpp"
-
-namespace rive {
-
-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;
-
- rcp<RenderShader> makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- rcp<RenderShader> makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule) override;
-
- std::unique_ptr<RenderPath> makeEmptyRenderPath() override;
-
- std::unique_ptr<RenderPaint> makeRenderPaint() override;
-
- std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) override;
-};
-} // namespace rive
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_NOOP_RENDERER_HPP_
-#define _RIVE_NOOP_RENDERER_HPP_
-
-#include "rive/renderer.hpp"
-
-namespace rive {
-
-class NoOpRenderer : public Renderer {
-public:
- void save() override {}
- void restore() override {}
- void transform(const Mat2D&) override {}
- void drawPath(RenderPath* path, RenderPaint* paint) override {}
- void clipPath(RenderPath* path) override {}
- void drawImage(const RenderImage*, BlendMode, float) override {}
- void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer>,
- rcp<RenderBuffer>,
- rcp<RenderBuffer>,
- BlendMode,
- float) override {}
-};
-
-} // namespace rive
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_UTF_HPP_
-#define _RIVE_UTF_HPP_
-
-#include "rive/render_text.hpp"
-
-namespace rive {
-
-class UTF {
-public:
- // returns the number of bytes needed in this sequence
- // For ascii, this will return 1
- static int CountUTF8Length(const uint8_t utf8[]);
-
- // Return the unichar pointed to by the utf8 pointer, and then
- // update the pointer to point to the next sequence.
- static Unichar NextUTF8(const uint8_t** utf8Ptr);
-
- // Convert the unichar into (1 or 2) utf16 values, and return
- // the number of values.
- static int ToUTF16(Unichar uni, uint16_t utf16[]);
-};
-
-} // namespace rive
-
-#endif
files {
"../**.cpp",
- "../../utils/no_op_factory.cpp",
+ "../../test/no_op_factory.cpp",
}
buildoptions {"-Wall", "-fno-rtti", "-g"}
#include "rive/animation/linear_animation_instance.hpp"
#include "rive/animation/state_machine_instance.hpp"
#include "rive/animation/state_machine_input_instance.hpp"
-#include "utils/no_op_factory.hpp"
+#include "no_op_factory.hpp"
class JSoner {
std::vector<bool> m_IsArray;
printf("%c\n", c);
}
- void add(const char key[], int value) { this->add(key, std::to_string(value).c_str()); }
+ void add(const char key[], int value) {
+ this->add(key, std::to_string(value).c_str());
+ }
};
//////////////////////////////////////////////////
}
static rive::NoOpFactory gFactory;
- return rive::File::import(bytes, &gFactory);
+ return rive::File::import(rive::toSpan(bytes), &gFactory);
}
static bool is_arg(const char arg[], const char target[], const char alt[] = nullptr) {
+++ /dev/null
-#!/bin/bash
-
-set -e
-
-# required envs
-RIVE_RUNTIME_DIR="${RIVE_RUNTIME_DIR:=../..}"
-SKIA_DIR_NAME="${SKIA_DIR_NAME:=skia}"
-SKIA_REPO=${SKIA_REPO:-https://github.com/rive-app/skia}
-SKIA_BRANCH=${SKIA_BRANCH:-rive}
-COMPILE_TARGET="${COMPILE_TARGET:-$(uname -s)_$(uname -m)}"
-CACHE_NAME="${CACHE_NAME:=skia}"
-OUTPUT_CACHE="${OUTPUT_CACHE:=out}"
-MAKE_SKIA_FILE="${MAKE_SKIA_FILE:=make_skia_android.sh}"
-ARCHIVE_CONTENTS_NAME="${ARCHIVE_CONTENTS_NAME:=archive_contents}"
-
-# lets just make sure this exists, or fail
-if [[ ! -d $RIVE_RUNTIME_DIR ]]
-then
- echo "Cannot find $RIVE_RUNTIME_DIR, bad setup"
- exit 1
-fi
-
-# computed environment variables
-SKIA_DEPENDENCIES_DIR="$RIVE_RUNTIME_DIR/skia/dependencies"
-SKIA_DIR="$SKIA_DEPENDENCIES_DIR/$SKIA_DIR_NAME"
-
-# gotta switch into a non .git folder to check the remote repo's hash
-# this avoid issues with corrupted git repos throwing irrelevant errors
-pushd ~
-SKIA_COMMIT_HASH="$(git ls-remote $SKIA_REPO $SKIA_BRANCH | awk '{print $1}')"
-popd
-
-ARCHIVE_CONTENTS_PATH="$SKIA_DIR/$ARCHIVE_CONTENTS_NAME"
-echo $ARCHIVE_CONTENTS_PATH
-
-ARCHIVE_CONTENTS="missing"
-if test -f "$ARCHIVE_CONTENTS_PATH"; then
- ARCHIVE_CONTENTS="$(cat $ARCHIVE_CONTENTS_PATH)"
-fi
-
-# TODO: could add OS_RELEASE in if portability is a problem
-# TODO: hmm how do we know the make skia script.. i guess its an arg? a back arg?
-if [[ $OSTYPE == 'darwin'* ]]; then
- # md5 -r == md5sum
- CONFIGURE_VERSION=$(md5 -r cache_helper.sh|awk '{print $1}')
- MAKE_SKIA_HASH=$(md5 -r $SKIA_DEPENDENCIES_DIR/$MAKE_SKIA_FILE|awk '{print $1}')
- BUILD_HASH=$(md5 -r -s "$SKIA_COMMIT_HASH $MAKE_SKIA_HASH $CONFIGURE_VERSION" | awk '{print $1}')
-else
- CONFIGURE_VERSION=$(md5sum cache_helper.sh|awk '{print $1}')
- MAKE_SKIA_HASH=$(md5sum $SKIA_DEPENDENCIES_DIR/$MAKE_SKIA_FILE|awk '{print $1}')
- BUILD_HASH=$(echo "$SKIA_COMMIT_HASH $MAKE_SKIA_HASH $CONFIGURE_VERSION" | md5sum | awk '{print $1}')
-fi
-
-echo "Created hash: $BUILD_HASH from skia_commit=$SKIA_COMMIT_HASH make_skia_script=$MAKE_SKIA_HASH configure_script=$CONFIGURE_VERSION"
-
-EXPECTED_ARCHIVE_CONTENTS="$BUILD_HASH"_"$COMPILE_TARGET"
-
-ARCHIVE_FILE_NAME="$CACHE_NAME"_"$EXPECTED_ARCHIVE_CONTENTS.tar.gz"
-ARCHIVE_URL="https://cdn.2dimensions.com/archives/$ARCHIVE_FILE_NAME"
-ARCHIVE_PATH="$SKIA_DIR/$ARCHIVE_FILE_NAME"
-
-pull_cache() {
- echo "Grabbing cached build from $ARCHIVE_URL"
- mkdir -p $SKIA_DIR
- curl --output $SKIA_DIR/$ARCHIVE_FILE_NAME $ARCHIVE_URL
- pushd $SKIA_DIR
- tar -xf $ARCHIVE_FILE_NAME out include $ARCHIVE_CONTENTS_NAME third_party
-}
-
-is_build_cached_remotely() {
- echo "Checking for cache build $ARCHIVE_URL"
- if curl --output /dev/null --head --silent --fail $ARCHIVE_URL
- then
- return 0
- else
- return 1
- fi
-}
-
-upload_cache() {
- pushd $SKIA_DEPENDENCIES_DIR
- echo $EXPECTED_ARCHIVE_CONTENTS > $SKIA_DIR_NAME/$ARCHIVE_CONTENTS_NAME
- # not really sure about this third party biz
- # also we are caching on a per architecture path here, but out could contain more :thinking:
- tar -C $SKIA_DIR_NAME -cf $SKIA_DIR_NAME/$ARCHIVE_FILE_NAME $OUTPUT_CACHE $ARCHIVE_CONTENTS_NAME include third_party/libpng third_party/externals/libpng
- popd
- # # if we're configured to upload the archive back into our cache, lets do it!
- echo "Uploading to s3://2d-public/archives/$ARCHIVE_FILE_NAME"
- ls $ARCHIVE_PATH
- aws s3 cp $ARCHIVE_PATH s3://2d-public/archives/$ARCHIVE_FILE_NAME
-}
-
-
-
-is_build_cached_locally() {
- if [ "$EXPECTED_ARCHIVE_CONTENTS" == "$ARCHIVE_CONTENTS" ]; then
- return 0
- else
- return 1
- fi
-}
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-set -e
-
-# Requires depot_tools and git:
-# https://skia.org/user/download
-# Build notes:
-# https://skia.org/user/build
-# GLFW requires CMake
-
-SKIA_REPO="${SKIA_REPO:-https://github.com/rive-app/skia}"
-SKIA_BRANCH="${SKIA_BRANCH:-rive}"
-
-# note: we have imports in recorder that rely on this being "skia"
-# either: change that in recorder, or check out skia into a subfolder
-# both have consequences.
-SKIA_DIR_NAME="${SKIA_DIR_NAME:-skia}"
-
-_skiaExists() {
- if test -d $SKIA_DIR_NAME/.git; then
- return 0
- else
- return 1
- fi
-}
-
-_skiaHasExpectedRemote() {
- if test -d $SKIA_DIR_NAME/.git; then
- pushd $SKIA_DIR_NAME
- if git remote -v |grep "$SKIA_REPO"; then
- popd
- return 0
- else
- popd
- echo "Skia it is using the wrong remote."
- return 1
- fi
- else
- echo "Skia is expected to be a git repo"
- return 1
- fi
-}
-
-_updateSkia() {
- pushd $SKIA_DIR_NAME
- git fetch && git pull
- popd
-}
-
-_cloneSkia() {
- echo "Cloning Skia [$SKIA_REPO : $SKIA_BRANCH] into $SKIA_DIR_NAME."
- git clone $SKIA_REPO $SKIA_DIR_NAME
-}
-
-_removeSkia(){
- echo "Removing skia folder."
- rm -rf $SKIA_DIR_NAME
-}
-
-getSkia () {
- # -----------------------------
- # Get Skia:
- # -----------------------------
- if _skiaExists; then
- if _skiaHasExpectedRemote; then
- _updateSkia
- else
- _removeSkia
- _cloneSkia
- fi
- else
- _removeSkia
- _cloneSkia
- fi
-
- pushd $SKIA_DIR_NAME
-
- echo "Checking out branch $SKIA_BRANCH"
- git checkout $SKIA_BRANCH
- python tools/git-sync-deps
-
- popd
-}
\ No newline at end of file
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
+ skia_use_libjpeg_turbo_decode=false \
skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
+ skia_use_libwebp_decode=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
+ skia_use_libjpeg_turbo_decode=false \
skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
+ skia_use_libwebp_decode=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
+ skia_use_libjpeg_turbo_decode=false \
skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
+ skia_use_libwebp_decode=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
+ skia_use_libjpeg_turbo_decode=false \
skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
+ skia_use_libwebp_decode=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
+ skia_use_libjpeg_turbo_decode=false \
skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
+ skia_use_libwebp_decode=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
skia_use_icu=false \
skia_use_libheif=false \
skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
+ skia_use_libjpeg_turbo_decode=false \
skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
+ skia_use_libwebp_decode=false \
skia_use_lua=false \
skia_use_piex=false \
skia_use_vulkan=false \
ninja -C out/static
du -hs out/static/libskia.a
-cd ..
+cd ..
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-set -ex
-
-source ./get_skia2.sh
-source ./cache_helper.sh
-
-ARCH=$1
-CONFIG=$2
-
-build_skia_android() {
- cd $SKIA_DIR_NAME
-
- if [ "$ARCH" != "x86" ] &&
- [ "$ARCH" != "x64" ] &&
- [ "$ARCH" != "arm" ] &&
- [ "$ARCH" != "arm64" ]; then
- printf "Invalid architecture: '%s'. Choose one between 'x86', \
- 'x64', \
- 'arm', \
- or 'arm64'" "$ARCH"
- exit 1
- fi
-
- BUILD_FLAGS=
- EXTRA_CFLAGS=
- if [ "$CONFIG" = "debug" ]; then
- BUILD_FLAGS="is_official_build=false is_debug=true skia_enable_tools=false"
- else # release
- BUILD_FLAGS="is_official_build=true is_debug=false"
- EXTRA_CFLAGS="\
- \"-fno-rtti\", \
- \"-flto=full\", \
- \"-fembed-bitcode\", \
- \"-DRIVE_OPTIMIZED\", \
- \"-DSK_DISABLE_SKPICTURE\", \
- \"-DSK_DISABLE_TEXT\", \
- \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \
- \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \
- \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \
- \"-DSK_DISABLE_AAA\", \
- \"-DSK_DISABLE_EFFECT_DESERIALIZATION\" \
- "
- fi
-
- # Useful for debugging:
- # bin/gn args --list out/${ARCH}
-
- bin/gn gen out/"${CONFIG}"/"${ARCH}" --args=" \
- ndk=\"${NDK_PATH}\" \
- target_cpu=\"${ARCH}\" \
- extra_cflags=[ \
- ${EXTRA_CFLAGS} \
- ] \
- \
- ${BUILD_FLAGS} \
-
- skia_gl_standard=\"gles\"
- skia_use_zlib=true \
- skia_use_egl=true \
- skia_use_gl=true \
- skia_enable_gpu=true \
- skia_use_libpng_decode=false \
- skia_use_libpng_encode=false \
-
- skia_use_angle=false \
- skia_use_dng_sdk=false \
-
- skia_use_expat=false \
- skia_use_fontconfig=false \
- skia_use_system_freetype2=false \
- skia_use_icu=false \
- skia_use_libheif=false \
- skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
- skia_use_system_libwebp=false \
- skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=false \
- skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=false \
- skia_use_lua=false \
- skia_use_piex=false \
- skia_use_vulkan=false \
-
- skia_use_system_zlib=false \
- skia_enable_fontmgr_empty=false \
- skia_enable_spirv_validation=false \
- skia_enable_pdf=false \
- skia_enable_skottie=false \
- "
-
- ninja -C out/"${CONFIG}"/"${ARCH}"
- cd ..
-}
-
-if is_build_cached_locally; then
- echo "Build is cached, nothing to do."
-else
- if is_build_cached_remotely; then
- pull_cache
- else
- getSkia
- build_skia_android
- # hmm not the appiest with this guy
- if [ "$CONFIG" != "debug" ]; then
- OUTPUT_CACHE=out/"${CONFIG}"/$ARCH upload_cache
- fi
- fi
-fi
+++ /dev/null
-#!/bin/bash
-
-set -ex
-
-source ./get_skia2.sh
-source ./cache_helper.sh
-
-build_skia_ios(){
- cd $SKIA_DIR_NAME
- case $1 in
- arm64)
- ARCH=arm64
- FOLDER=arm64
- ;;
- arm)
- ARCH=arm
- FOLDER=arm
- ;;
- x86)
- ARCH=x86
- FOLDER=x86
- ;;
- x64)
- ARCH=x64
- FOLDER=x64
- ;;
- iossim_arm64)
- ARCH=arm64
- FOLDER=iossim_arm64
- EXTRA_CFLAGS=", \"--target=arm64-apple-ios12.0.0-simulator\""
- EXTRA_LDLAGS="\"--target=arm64-apple-ios12.0.0-simulator\""
- ;;
- *)
- echo "Do not know build configuration for $1"
- exit 1
- esac
-
- # use Rive optimized/stripped Skia for iOS static libs.
- bin/gn gen out/$FOLDER --type=static_library --args=" \
- target_os=\"ios\" \
- target_cpu=\"$ARCH\" \
- extra_cflags=[ \
- \"-fno-rtti\", \
- \"-fembed-bitcode\", \
- \"-mios-version-min=10.0\", \
- \"-flto=full\", \
- \"-DSK_DISABLE_SKPICTURE\", \
- \"-DSK_DISABLE_TEXT\", \
- \"-DRIVE_OPTIMIZED\", \
- \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", \
- \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", \
- \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", \
- \"-DSK_DISABLE_AAA\", \
- \"-DSK_DISABLE_EFFECT_DESERIALIZATION\" \
- ${EXTRA_CFLAGS}
- ] \
-
- extra_ldflags=[ \
- ${EXTRA_LDLAGS} \
- ] \
-
- is_official_build=true \
- skia_use_freetype=true \
- skia_use_metal=true \
- skia_use_zlib=true \
- skia_enable_gpu=true \
- skia_use_libpng_encode=true \
- skia_use_libpng_decode=true \
- skia_skip_codesign=true \
-
- skia_use_angle=false \
- skia_use_dng_sdk=false \
- skia_use_egl=false \
- skia_use_expat=false \
- skia_use_fontconfig=false \
- skia_use_system_freetype2=false \
- skia_use_icu=false \
- skia_use_libheif=false \
- skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
- skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
- skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
- skia_use_lua=false \
- skia_use_piex=false \
- skia_use_vulkan=false \
- skia_use_gl=false \
- skia_use_system_zlib=false \
- skia_enable_fontmgr_empty=false \
- skia_enable_spirv_validation=false \
- skia_enable_pdf=false \
- skia_enable_skottie=false \
- $OVERRIDES
- "
- ninja -C out/$FOLDER
- cd ..
-}
-
-if is_build_cached_locally; then
- echo "Build is cached, nothing to do."
-else
- if is_build_cached_remotely; then
- pull_cache
- else
- getSkia
- build_skia_ios $1
- # hmm not the appiest with this guy
- OUTPUT_CACHE=out/$FOLDER upload_cache
- fi
-fi
-
-cd ..
+++ /dev/null
-#!/bin/bash
-set -ex
-
-source ./get_skia2.sh
-source ./cache_helper.sh
-
-build_skia_recorder() {
- cd $SKIA_DIR_NAME
-
- bin/gn gen out/static --args=" \
- is_official_build=true \
- extra_cflags=[
- \"-fno-rtti\",\
- \"-DSK_DISABLE_SKPICTURE\",\
- \"-DSK_DISABLE_TEXT\",\
- \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\",\
- \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\",\
- \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\",\
- \"-DSK_DISABLE_AAA\",\
- \"-DSK_DISABLE_EFFECT_DESERIALIZATION\"\
- ] \
- rive_use_picture=true \
- skia_use_angle=false \
- skia_use_dng_sdk=false \
- skia_use_egl=false \
- skia_use_expat=false \
- skia_use_fontconfig=false \
- skia_use_freetype=false \
- skia_use_icu=false \
- skia_use_libheif=false \
- skia_use_system_libpng=false \
- skia_use_system_libjpeg_turbo=false \
- skia_use_libjpeg_turbo_encode=false \
- skia_use_libjpeg_turbo_decode=true \
- skia_use_libwebp_encode=false \
- skia_use_libwebp_decode=true \
- skia_use_system_libwebp=false \
- skia_use_lua=false \
- skia_use_piex=false \
- skia_use_vulkan=false \
- skia_use_metal=false \
- skia_use_gl=true \
- skia_use_zlib=true \
- skia_use_system_zlib=false \
- skia_enable_gpu=true \
- skia_enable_fontmgr_empty=true \
- skia_enable_spirv_validation=false \
- skia_enable_pdf=false \
- skia_use_libpng_encode = true \
- skia_use_libpng_decode = true \
- skia_enable_skottie = false \
- skia_enable_tools = false \
- skia_enable_skgpu_v1 = true \
- skia_enable_skgpu_v2 = false \
- "
- ninja -C out/static
-
- cd ..
-}
-
-if is_build_cached_locally; then
- echo "Build is cached, nothing to do."
-else
- if is_build_cached_remotely; then
- pull_cache
- else
- getSkia
- build_skia_recorder
- OUTPUT_CACHE=out upload_cache
- fi
-fi
\ No newline at end of file
# GLFW requires CMake
if [ -z "${PAT_GITHUB}" ]; then
- SKIA_URL=git@github.com:rive-app/skia.git
+ SKIA_EXPERIMENTAL_URL=git@github.com:rive-app/skia-experimental.git
else
- SKIA_URL=https://${PAT_GITHUB}@github.com/rive-app/skia.git
+ SKIA_EXPERIMENTAL_URL=https://${PAT_GITHUB}@github.com/rive-app/skia-experimental.git
fi
-./get_skia.sh ${SKIA_URL} rive skia_rive_optimized
+./get_skia.sh ${SKIA_EXPERIMENTAL_URL} main skia-experimental
-cd skia_rive_optimized
+cd skia-experimental
# build static for host
bin/gn gen out/wasm --type=static_library --args=" \
// build vector of unique chars
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;
- });
+ auto iter = std::find_if(
+ rec.begin(), rec.end(), [code](const auto& r) { return r.charCode == code; });
if (iter == rec.end()) {
// gonna add code -- now see if its glyph is unique
uint16_t srcGlyph = glyphIDs[i];
}
}
- std::sort(rec.begin(), rec.end(), [](const Rec& a, const Rec& b) {
- return a.charCode < b.charCode;
- });
+ std::sort(
+ rec.begin(), rec.end(), [](const Rec& a, const Rec& b) { return a.charCode < b.charCode; });
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});
}
- std::sort(rec.begin(), rec.end(), [](const Rec& a, const Rec& b) {
- return a.dstGlyph < b.dstGlyph;
- });
+ std::sort(
+ rec.begin(), rec.end(), [](const Rec& a, const Rec& b) { return a.dstGlyph < b.dstGlyph; });
font.setLinearMetrics(true);
auto append_glyph = [&](uint16_t srcGlyph) {
}
varray.push_back(verb);
switch ((SkPathVerb)verb) {
- case SkPathVerb::kMove: add_point(pts[0]); break;
- case SkPathVerb::kLine: add_point(pts[1]); break;
+ 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]);
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());
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;
dir.push_back({kAdvances_TableTag, advances.detach()});
}
- std::sort(dir.begin(), dir.end(), [](const DirRec& a, const DirRec& b) {
- return a.tag < b.tag;
- });
+ std::sort(
+ dir.begin(), dir.end(), [](const DirRec& a, const DirRec& b) { return a.tag < b.tag; });
ByteBuilder header;
header.addU32(kSignature);
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;
+ 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;
args::Group optional(m_Parser, "optional arguments:", args::Group::Validators::DontCare);
args::ValueFlag<std::string> source(required, "path", "source filename", {'s', "source"});
- args::ValueFlag<std::string> destination(required,
- "path",
- "destination filename",
- {'d', "destination"});
- args::ValueFlag<std::string> charset(optional,
- "path",
- "charset filename",
- {'c', "charset"});
+ args::ValueFlag<std::string> destination(
+ required, "path", "destination filename", {'d', "destination"});
+ args::ValueFlag<std::string> charset(
+ optional, "path", "charset filename", {'c', "charset"});
args::CompletionFlag completion(m_Parser, {"complete"});
try {
echo build.sh clean - clean the build
echo build.sh release - build release library
echo build.sh -p ios release - build release ios library
- echo build.sh -p ios_sim release - build release ios simulator library
echo build.sh -p android release - build release android library
exit 1
}
help
else
build() {
- echo "Building Rive Renderer for platform=$platform option=$OPTION"
+ echo "Building Rive for platform=$platform option=$OPTION"
PREMAKE="premake5 gmake2 $1"
eval "$PREMAKE"
if [ "$OPTION" = "clean" ]; then
echo "Building for iOS"
export IOS_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)
build "--os=ios"
- if [ "$OPTION" = "clean" ]; then
- exit
- fi
- ;;
- ios_sim)
- echo "Building for iOS Simulator"
export IOS_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
build "--os=ios --variant=emulator"
if [ "$OPTION" = "clean" ]; then
esac
fi
-popd &>/dev/null
\ No newline at end of file
+popd &>/dev/null
workspace "rive"
configurations {"debug", "release"}
-SKIA_DIR = os.getenv('SKIA_DIR') or 'skia'
-dependencies = os.getenv('DEPENDENCIES')
-
-if dependencies ~= nil then
- SKIA_DIR = dependencies .. '/skia'
-else
- SKIA_DIR = "../../dependencies/" .. SKIA_DIR
-end
-
project "rive_skia_renderer"
kind "StaticLib"
language "C++"
toolset "clang"
targetdir "%{cfg.system}/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/obj/%{cfg.buildcfg}"
- includedirs {
- "../../../../../third_party/externals/harfbuzz/src",
- "../include",
- "../../../include"
- }
+ includedirs {"../include", "../../../include"}
if os.host() == "macosx" then
links {"Cocoa.framework", "rive", "skia"}
libdirs {"../../../build/%{cfg.system}/bin/%{cfg.buildcfg}"}
- files {
- "../src/**.cpp"
- }
+ files {"../src/**.cpp"}
buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti", "-Werror=format"}
filter {"system:macosx" }
- includedirs {SKIA_DIR}
- libdirs {SKIA_DIR.. "/out/static"}
+ buildoptions {"-flto=full"}
+ includedirs {"../../dependencies/skia"}
+ libdirs {"../../dependencies/skia/out/static"}
filter {"system:linux or windows" }
- includedirs {SKIA_DIR}
- libdirs {SKIA_DIR.. "/out/static"}
+ includedirs {"../../dependencies/skia"}
+ libdirs {"../../dependencies/skia/out/static"}
filter {"system:ios" }
- includedirs {SKIA_DIR}
- libdirs {SKIA_DIR.. "/out/static"}
+ buildoptions {"-flto=full"}
+ includedirs {"../../dependencies/skia_rive_optimized"}
+ libdirs {"../../dependencies/skia_rive_optimized/out/static"}
filter {"system:ios", "options:variant=system" }
buildoptions {"-mios-version-min=10.0 -fembed-bitcode -arch armv7 -arch arm64 -arch arm64e -isysroot " .. (os.getenv("IOS_SYSROOT") or "")}
targetdir "%{cfg.system}_sim/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}_sim/obj/%{cfg.buildcfg}"
+ filter { "system:android", "configurations:release" }
+ buildoptions {"-flto=full"}
+
-- Is there a way to pass 'arch' as a variable here?
filter { "system:android" }
- includedirs {SKIA_DIR}
+ includedirs {"../../dependencies/skia_rive_optimized"}
filter { "system:android", "options:arch=x86" }
targetdir "%{cfg.system}/x86/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/x86/obj/%{cfg.buildcfg}"
- libdirs {SKIA_DIR.. "/out/x86"}
+ libdirs {"../../dependencies/skia_rive_optimized/out/x86"}
filter { "system:android", "options:arch=x64" }
targetdir "%{cfg.system}/x64/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/x64/obj/%{cfg.buildcfg}"
- libdirs {SKIA_DIR.. "/out/x64"}
+ libdirs {"../../dependencies/skia_rive_optimized/out/x64"}
filter { "system:android", "options:arch=arm" }
targetdir "%{cfg.system}/arm/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/arm/obj/%{cfg.buildcfg}"
- libdirs {SKIA_DIR.. "/out/arm"}
+ libdirs {"../../dependencies/skia_rive_optimized/out/arm"}
filter { "system:android", "options:arch=arm64" }
targetdir "%{cfg.system}/arm64/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/arm64/obj/%{cfg.buildcfg}"
- libdirs {SKIA_DIR.. "/out/arm64"}
-
- filter { "configurations:release", "system:macosx" }
- buildoptions {"-flto=full"}
-
- filter { "configurations:release", "system:android" }
- buildoptions {"-flto=full"}
-
- filter { "configurations:release", "system:ios" }
- buildoptions {"-flto=full"}
-
+ libdirs {"../../dependencies/skia_rive_optimized/out/arm64"}
+
filter "configurations:debug"
- buildoptions {"-g"}
defines {"DEBUG"}
symbols "On"
defines {"RELEASE", "NDEBUG"}
optimize "On"
- filter {"options:with-text" }
- defines {"RIVE_TEXT"}
-
-newoption {
- trigger = "with-text",
- description = "Enables text experiments"
-}
-
newoption {
trigger = "variant",
value = "type",
{ "arm64" }
}
-}
\ No newline at end of file
+}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_CG_FACTORY_HPP_
-#define _RIVE_CG_FACTORY_HPP_
-
-#include "rive/factory.hpp"
-#include <vector>
-
-namespace rive {
-
-class CGFactory : public Factory {
-public:
- rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override;
- rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override;
- rcp<RenderBuffer> makeBufferF32(Span<const float>) override;
-
- rcp<RenderShader> makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- rcp<RenderShader> makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule) override;
-
- std::unique_ptr<RenderPath> makeEmptyRenderPath() override;
-
- std::unique_ptr<RenderPaint> makeRenderPaint() override;
-
- std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) override;
-};
-
-} // namespace rive
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_CG_RENDERER_HPP_
-#define _RIVE_CG_RENDERER_HPP_
-
-#include "rive/renderer.hpp"
-
-#if defined(RIVE_BUILD_FOR_OSX)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(RIVE_BUILD_FOR_IOS)
-#include <CoreGraphics/CoreGraphics.h>
-#include <ImageIO/ImageIO.h>
-#endif
-
-namespace rive {
-class CGRenderer : public Renderer {
-protected:
- CGContextRef m_ctx;
-
-public:
- CGRenderer(CGContextRef ctx, int width, int height);
- ~CGRenderer() override;
-
- void save() override;
- void restore() override;
- void transform(const Mat2D& transform) override;
- void clipPath(RenderPath* path) override;
- void drawPath(RenderPath* path, RenderPaint* paint) override;
- void drawImage(const RenderImage*, BlendMode, float opacity) override;
- void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) override;
-};
-} // namespace rive
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_CGSkiaFactory_HPP_
-#define _RIVE_CGSkiaFactory_HPP_
-
-#include "skia_factory.hpp"
-
-namespace rive {
-struct CGSkiaFactory : public SkiaFactory {
- std::vector<uint8_t> platformDecode(Span<const uint8_t>, SkiaFactory::ImageInfo*) override;
-};
-} // namespace rive
-
-#endif // _RIVE_CGSkiaFactory_HPP_
+++ /dev/null
-#ifndef _RIVE_MAC_UTILS_HPP_
-#define _RIVE_MAC_UTILS_HPP_
-
-#include "rive/rive_types.hpp"
-#include "rive/span.hpp"
-#include <string>
-
-#ifdef RIVE_BUILD_FOR_APPLE
-
-#if defined(RIVE_BUILD_FOR_OSX)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(RIVE_BUILD_FOR_IOS)
-#include <CoreFoundation/CoreFoundation.h>
-#include <CoreGraphics/CGImage.h>
-#endif
-
-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) {
- m_ptr = m_storage;
- if (n > N) {
- m_ptr = new T[n];
- }
- }
- ~AutoSTArray() {
- if (m_ptr != m_storage) {
- delete[] m_ptr;
- }
- }
-
- T* data() const { return m_ptr; }
-
- 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) {
- return (a << 24) | (b << 16) | (c << 8) | d;
-}
-
-static inline std::string tag2str(uint32_t tag) {
- std::string str = "abcd";
- str[0] = (tag >> 24) & 0xFF;
- str[1] = (tag >> 16) & 0xFF;
- str[2] = (tag >> 8) & 0xFF;
- str[3] = (tag >> 0) & 0xFF;
- return str;
-}
-
-template <typename T> class AutoCF {
- T m_obj;
-
-public:
- AutoCF(T obj = nullptr) : m_obj(obj) {}
- AutoCF(const AutoCF& other) {
- if (other.m_obj) {
- CFRetain(other.m_obj);
- }
- m_obj = other.m_obj;
- }
- AutoCF(AutoCF&& other) {
- m_obj = other.m_obj;
- other.m_obj = nullptr;
- }
- ~AutoCF() {
- if (m_obj) {
- CFRelease(m_obj);
- }
- }
-
- AutoCF& operator=(const AutoCF& other) {
- if (m_obj != other.m_obj) {
- if (other.m_obj) {
- CFRetain(other.m_obj);
- }
- if (m_obj) {
- CFRelease(m_obj);
- }
- m_obj = other.m_obj;
- }
- return *this;
- }
-
- void reset(T obj) {
- if (obj != m_obj) {
- if (m_obj) {
- CFRelease(m_obj);
- }
- m_obj = obj;
- }
- }
-
- operator T() const { return m_obj; }
- operator bool() const { return m_obj != nullptr; }
- T get() const { return m_obj; }
-};
-
-static inline float find_float(CFDictionaryRef dict, const void* key) {
- auto num = (CFNumberRef)CFDictionaryGetValue(dict, key);
- assert(num);
- float value = 0;
- CFNumberGetValue(num, kCFNumberFloat32Type, &value);
- return value;
-}
-
-static inline uint32_t find_u32(CFDictionaryRef dict, const void* key) {
- auto num = (CFNumberRef)CFDictionaryGetValue(dict, key);
- assert(num);
- assert(!CFNumberIsFloatType(num));
- uint32_t value = 0;
- CFNumberGetValue(num, kCFNumberSInt32Type, &value);
- return value;
-}
-
-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) {
- float value;
- CFNumberGetValue(num, kCFNumberFloat32Type, &value);
- return value;
-}
-
-namespace rive {
-AutoCF<CGImageRef> DecodeToCGImage(Span<const uint8_t>);
-AutoCF<CGImageRef> FlipCGImageInY(AutoCF<CGImageRef>);
-} // namespace rive
-
-#endif
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_RENDERER_UTILS_HPP_
-#define _RIVE_RENDERER_UTILS_HPP_
-
-#include "rive/rive_types.hpp"
-#include "rive/core/type_conversions.hpp"
-#include <string>
-
-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) {
- m_ptr = m_storage;
- if (n > N) {
- m_ptr = new T[n];
- }
- }
- ~AutoSTArray() {
- if (m_ptr != m_storage) {
- delete[] m_ptr;
- }
- }
-
- size_t size() const { return m_count; }
- int count() const { return rive::castTo<int>(m_count); }
-
- T* data() const { return m_ptr; }
-
- 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) {
- return (a << 24) | (b << 16) | (c << 8) | d;
-}
-
-static inline std::string tag2str(uint32_t tag) {
- std::string str = "abcd";
- str[0] = (tag >> 24) & 0xFF;
- str[1] = (tag >> 16) & 0xFF;
- str[2] = (tag >> 8) & 0xFF;
- str[3] = (tag >> 0) & 0xFF;
- return str;
-}
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_RENDERFONT_CORETEXT_HPP_
-#define _RIVE_RENDERFONT_CORETEXT_HPP_
-
-#include "rive/factory.hpp"
-#include "rive/render_text.hpp"
-
-#if defined(RIVE_BUILD_FOR_OSX)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(RIVE_BUILD_FOR_IOS)
-#include <CoreText/CoreText.h>
-#endif
-
-class CoreTextRenderFont : public rive::RenderFont {
-public:
- CTFontRef m_font;
- const std::vector<Axis> m_axes;
- const std::vector<Coord> m_coords;
-
- // We assume ownership of font!
- CoreTextRenderFont(CTFontRef, std::vector<Axis>);
- ~CoreTextRenderFont() override;
-
- std::vector<Axis> getAxes() const override { return m_axes; }
- std::vector<Coord> getCoords() const override { return m_coords; }
- rive::rcp<rive::RenderFont> makeAtCoords(rive::Span<const Coord>) const override;
- rive::RawPath getPath(rive::GlyphID) const override;
- std::vector<rive::RenderGlyphRun>
- onShapeText(rive::Span<const rive::Unichar>,
- rive::Span<const rive::RenderTextRun>) const override;
-
- static rive::rcp<rive::RenderFont> Decode(rive::Span<const uint8_t>);
- static rive::rcp<rive::RenderFont> FromCT(CTFontRef);
-};
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_RENDERFONT_HB_HPP_
-#define _RIVE_RENDERFONT_HB_HPP_
-
-#include "rive/factory.hpp"
-#include "rive/render_text.hpp"
-
-struct hb_font_t;
-struct hb_draw_funcs_t;
-
-class HBRenderFont : public rive::RenderFont {
- hb_draw_funcs_t* m_DrawFuncs;
-
-public:
- hb_font_t* m_Font;
-
- // We assume ownership of font!
- HBRenderFont(hb_font_t* font);
- ~HBRenderFont() override;
-
- std::vector<Axis> getAxes() const override;
- std::vector<Coord> getCoords() const override;
- rive::rcp<rive::RenderFont> makeAtCoords(rive::Span<const Coord>) const override;
- rive::RawPath getPath(rive::GlyphID) const override;
- std::vector<rive::RenderGlyphRun>
- onShapeText(rive::Span<const rive::Unichar>,
- rive::Span<const rive::RenderTextRun>) const override;
-
- static rive::rcp<rive::RenderFont> Decode(rive::Span<const uint8_t>);
-
- // If the platform can supply fallback font(s), set this function pointer.
- // It will be called with a span of unichars, and the platform attempts to
- // return a font that can draw (at least some of) them. If no font is available
- // just return nullptr.
-
- using FallbackProc = rive::rcp<rive::RenderFont> (*)(rive::Span<const rive::Unichar>);
-
- static FallbackProc gFallbackProc;
-};
-
-#endif
#define _RIVE_SKIA_FACTORY_HPP_
#include "rive/factory.hpp"
-#include <vector>
namespace rive {
class SkiaFactory : public Factory {
-public:
rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override;
rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override;
rcp<RenderBuffer> makeBufferF32(Span<const float>) override;
- rcp<RenderShader> makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- rcp<RenderShader> makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
+ rcp<RenderShader> makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) override;
+
+ rcp<RenderShader> makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) override;
std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
+ Span<const uint8_t> verbs,
FillRule) override;
std::unique_ptr<RenderPath> makeEmptyRenderPath() override;
std::unique_ptr<RenderPaint> makeRenderPaint() override;
std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) override;
-
- //
- // New virtual for access the platform's codecs
- //
-
- enum class ColorType {
- rgba,
- bgra,
- };
- enum class AlphaType {
- premul,
- opaque,
- };
- struct ImageInfo {
- size_t rowBytes; // number of bytes between rows
- uint32_t width; // logical width in pixels
- uint32_t height; // logical height in pixels
- ColorType colorType;
- AlphaType alphaType;
- };
-
- // 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) {
- return std::vector<uint8_t>(); // empty vector means decode failed
- }
};
} // namespace rive
class SkCanvas;
namespace rive {
-class SkiaRenderer : public Renderer {
-protected:
- SkCanvas* m_Canvas;
+ class SkiaRenderer : public Renderer {
+ protected:
+ SkCanvas* m_Canvas;
-public:
- SkiaRenderer(SkCanvas* canvas) : m_Canvas(canvas) {}
- void save() override;
- void restore() override;
- void transform(const Mat2D& transform) override;
- void clipPath(RenderPath* path) override;
- void drawPath(RenderPath* path, RenderPaint* paint) override;
- void drawImage(const RenderImage*, BlendMode, float opacity) override;
- void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) override;
-};
+ public:
+ SkiaRenderer(SkCanvas* canvas) : m_Canvas(canvas) {}
+ void save() override;
+ void restore() override;
+ void transform(const Mat2D& transform) override;
+ void clipPath(RenderPath* path) override;
+ void drawPath(RenderPath* path, RenderPaint* paint) override;
+ void drawImage(const RenderImage*, BlendMode, float opacity) override;
+ void drawImageMesh(const RenderImage*,
+ rcp<RenderBuffer> vertices_f32,
+ rcp<RenderBuffer> uvCoords_f32,
+ rcp<RenderBuffer> indices_u16,
+ BlendMode,
+ float opacity) override;
+ };
} // namespace rive
#endif
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
-#include "include/core/SkPath.h"
#include "include/core/SkPathTypes.h"
#include "include/core/SkTileMode.h"
#include "rive/math/mat2d.hpp"
-#include "rive/math/raw_path.hpp"
#include "rive/math/vec2d.hpp"
#include "rive/renderer.hpp"
#include "rive/shapes/paint/stroke_cap.hpp"
#include "rive/shapes/paint/blend_mode.hpp"
namespace rive {
-class ToSkia {
-public:
- 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);
- }
+ class ToSkia {
+ public:
+ 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);
+ }
- static SkPoint convert(rive::Vec2D point) { return SkPoint::Make(point.x, point.y); }
+ static SkPoint convert(rive::Vec2D point) {
+ return SkPoint::Make(point.x, point.y);
+ }
+
+ // clang-format off
+ static SkTileMode convert(RenderTileMode rtm) {
+ switch (rtm) {
+ case RenderTileMode::clamp: return SkTileMode::kClamp;
+ case RenderTileMode::repeat: return SkTileMode::kRepeat;
+ case RenderTileMode::mirror: return SkTileMode::kMirror;
+ case RenderTileMode::decal: return SkTileMode::kDecal;
+ }
+ assert(false);
+ return SkTileMode::kClamp;
+ }
- // clang-format off
static SkPathFillType convert(FillRule value) {
switch (value) {
case FillRule::evenOdd: return SkPathFillType::kEvenOdd;
assert(false);
return SkBlendMode::kSrcOver;
}
-
- static SkPath convert(const RawPath& rp) {
- const auto pts = rp.points();
- const auto vbs = rp.verbsU8();
- return SkPath::Make((const SkPoint*)pts.data(), pts.size(),
- vbs.data(), vbs.size(),
- nullptr, 0, SkPathFillType::kWinding);
- }
// clang-format off
};
} // namespace rive
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/rive_types.hpp"
-
-#ifdef RIVE_BUILD_FOR_APPLE
-
-#include "cg_factory.hpp"
-#include "cg_renderer.hpp"
-#include "mac_utils.hpp"
-
-#if defined(RIVE_BUILD_FOR_OSX)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(RIVE_BUILD_FOR_IOS)
-#include <CoreGraphics/CoreGraphics.h>
-#include <ImageIO/ImageIO.h>
-#endif
-
-#include "utils/factory_utils.hpp"
-#include "rive/math/vec2d.hpp"
-#include "rive/core/type_conversions.hpp"
-#include "rive/shapes/paint/color.hpp"
-
-using namespace rive;
-
-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) {
- return (rule == FillRule::nonZero) ? CGPathDrawingMode::kCGPathFill
- : CGPathDrawingMode::kCGPathEOFill;
-}
-
-static CGLineJoin convert(StrokeJoin j) {
- const CGLineJoin cg[] = {
- CGLineJoin::kCGLineJoinMiter,
- CGLineJoin::kCGLineJoinRound,
- CGLineJoin::kCGLineJoinBevel,
- };
- return cg[(unsigned)j];
-}
-
-static CGLineCap convert(StrokeCap c) {
- const CGLineCap cg[] = {
- CGLineCap::kCGLineCapButt,
- CGLineCap::kCGLineCapRound,
- CGLineCap::kCGLineCapSquare,
- };
- return cg[(unsigned)c];
-}
-
-// clang-format off
-static CGBlendMode convert(BlendMode mode) {
- CGBlendMode cg = kCGBlendModeNormal;
- switch (mode) {
- case BlendMode::srcOver: cg = kCGBlendModeNormal; break;
- case BlendMode::screen: cg = kCGBlendModeScreen; break;
- case BlendMode::overlay: cg = kCGBlendModeOverlay; break;
- case BlendMode::darken: cg = kCGBlendModeDarken; break;
- case BlendMode::lighten: cg = kCGBlendModeLighten; break;
- case BlendMode::colorDodge: cg = kCGBlendModeColorDodge; break;
- case BlendMode::colorBurn: cg = kCGBlendModeColorBurn; break;
- case BlendMode::hardLight: cg = kCGBlendModeHardLight; break;
- case BlendMode::softLight: cg = kCGBlendModeSoftLight; break;
- case BlendMode::difference: cg = kCGBlendModeDifference; break;
- case BlendMode::exclusion: cg = kCGBlendModeExclusion; break;
- case BlendMode::multiply: cg = kCGBlendModeMultiply; break;
- case BlendMode::hue: cg = kCGBlendModeHue; break;
- case BlendMode::saturation: cg = kCGBlendModeSaturation; break;
- case BlendMode::color: cg = kCGBlendModeColor; break;
- case BlendMode::luminosity: cg = kCGBlendModeLuminosity; break;
- }
- return cg;
-}
-// clang-format on
-
-static void convertColor(ColorInt c, CGFloat rgba[]) {
- constexpr float kByteToUnit = 1.0f / 255;
- rgba[0] = colorRed(c) * kByteToUnit;
- rgba[1] = colorGreen(c) * kByteToUnit;
- rgba[2] = colorBlue(c) * kByteToUnit;
- rgba[3] = colorAlpha(c) * kByteToUnit;
-}
-
-class CGRenderPath : public RenderPath {
-private:
- AutoCF<CGMutablePathRef> m_path = CGPathCreateMutable();
- CGPathDrawingMode m_fillMode = CGPathDrawingMode::kCGPathFill;
-
-public:
- CGRenderPath() {}
-
- 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) {
- case PathVerb::move:
- CGPathMoveToPoint(m_path, nullptr, p[0].x, p[0].y);
- p += 1;
- break;
- case PathVerb::line:
- CGPathAddLineToPoint(m_path, nullptr, p[0].x, p[0].y);
- p += 1;
- break;
- case PathVerb::quad:
- CGPathAddQuadCurveToPoint(m_path, nullptr, p[0].x, p[0].y, p[1].x, p[1].y);
- p += 2;
- break;
- case PathVerb::cubic:
- CGPathAddCurveToPoint(m_path,
- nullptr,
- p[0].x,
- p[0].y,
- p[1].x,
- p[1].y,
- p[2].x,
- p[2].y);
- p += 3;
- break;
- case PathVerb::close: CGPathCloseSubpath(m_path); break;
- }
- }
- assert(p == pts.end());
- }
-
- CGPathRef path() const { return m_path.get(); }
- 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 {
- auto transform = convert(mx);
- CGPathAddPath(m_path, &transform, ((CGRenderPath*)path)->path());
- }
- 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 {
- CGPathAddCurveToPoint(m_path, nullptr, ox, oy, ix, iy, x, y);
- }
- void close() override { CGPathCloseSubpath(m_path); }
-};
-
-class CGRenderShader : public RenderShader {
-public:
- CGRenderShader() {}
-
- static constexpr int clampOptions =
- kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation;
-
- virtual void draw(CGContextRef) {}
-};
-
-class CGRenderPaint : public RenderPaint {
-private:
- bool m_isStroke = false;
- CGFloat m_rgba[4] = {0, 0, 0, 1};
- float m_width = 1;
- CGLineJoin m_join = kCGLineJoinMiter;
- CGLineCap m_cap = kCGLineCapButt;
- CGBlendMode m_blend = kCGBlendModeNormal;
- rcp<RenderShader> m_shader;
-
-public:
- CGRenderPaint() {}
-
- bool isStroke() const { return m_isStroke; }
- float opacity() const { return m_rgba[3]; }
-
- CGRenderShader* shader() const { return static_cast<CGRenderShader*>(m_shader.get()); }
-
- 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 {
- CGContextSetRGBFillColor(ctx, m_rgba[0], m_rgba[1], m_rgba[2], m_rgba[3]);
- }
- CGContextSetBlendMode(ctx, m_blend);
- }
-
- void style(RenderPaintStyle style) override {
- m_isStroke = (style == RenderPaintStyle::stroke);
- }
- void color(ColorInt value) override { convertColor(value, m_rgba); }
- void thickness(float value) override { m_width = value; }
- void join(StrokeJoin value) override { m_join = convert(value); }
- void cap(StrokeCap value) override { m_cap = convert(value); }
- void blendMode(BlendMode value) override { m_blend = convert(value); }
- void shader(rcp<RenderShader> sh) override { m_shader = std::move(sh); }
- void invalidateStroke() override {}
-};
-
-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) {
- convertColor(colors[i], &c[i * 4]);
-
- // Rive wants the colors to be premultiplied *after* interpolation
- // Unfortunately, CG doesn't know about this option, it just does
- // a straight interpolation and uses the result (thinking it is
- // in premul form already). This can lead to artifacts in the drawing
- // (e.g. sparkles) so as a hack, we premul our color stops up front.
- // Not exactly correct, but does remove the sparkles.
- // A better fix might be to write a custom Shading proc... but that
- // is likely to be be slower (but need to try/time it to know for sure).
- CGFloat* p = &c[i * 4];
- p[0] *= p[3];
- p[1] *= p[3];
- p[2] *= p[3];
- }
- if (stops) {
- for (size_t i = 0; i < count; ++i) {
- s[i] = stops[i];
- }
- }
- return CGGradientCreateWithColorComponents(space, c, s, count);
-}
-
-class CGRadialGradientRenderShader : public CGRenderShader {
- AutoCF<CGGradientRef> m_grad;
- CGPoint m_center;
- CGFloat m_radius;
-
-public:
- CGRadialGradientRenderShader(float cx,
- float cy,
- float radius,
- const ColorInt colors[],
- const float stops[],
- size_t count) :
- m_grad(convert(colors, stops, count)) {
- m_center = CGPointMake(cx, cy);
- m_radius = radius;
- }
-
- void draw(CGContextRef ctx) override {
- CGContextDrawRadialGradient(ctx, m_grad, m_center, 0, m_center, m_radius, clampOptions);
- }
-};
-
-class CGLinearGradientRenderShader : public CGRenderShader {
- AutoCF<CGGradientRef> m_grad;
- CGPoint m_start, m_end;
-
-public:
- CGLinearGradientRenderShader(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) :
- m_grad(convert(colors, stops, count)) {
- m_start = CGPointMake(sx, sy);
- m_end = CGPointMake(ex, ey);
- }
-
- void draw(CGContextRef ctx) override {
- CGContextDrawLinearGradient(ctx, m_grad, m_start, m_end, clampOptions);
- }
-};
-
-class CGRenderImage : public RenderImage {
-public:
- AutoCF<CGImageRef> 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()));
- }
- }
-
- Mat2D localM2D() const { return Mat2D(1, 0, 0, -1, 0, (float)m_Height); }
-
- void applyLocalMatrix(CGContextRef ctx) const {
- CGContextConcatCTM(ctx, CGAffineTransformMake(1, 0, 0, -1, 0, (float)m_Height));
- }
-
- static const CGRenderImage* Cast(const RenderImage* image) {
- return reinterpret_cast<const CGRenderImage*>(image);
- }
-};
-
-//////////////////////////////////////////////////////////////////////////
-
-CGRenderer::CGRenderer(CGContextRef ctx, int width, int height) : m_ctx(ctx) {
- CGContextSaveGState(ctx);
-
- Mat2D m(1, 0, 0, -1, 0, height);
- CGContextConcatCTM(ctx, convert(m));
-
- CGContextSetInterpolationQuality(ctx, kCGInterpolationMedium);
-}
-
-CGRenderer::~CGRenderer() { CGContextRestoreGState(m_ctx); }
-
-void CGRenderer::save() { CGContextSaveGState(m_ctx); }
-
-void CGRenderer::restore() { CGContextRestoreGState(m_ctx); }
-
-void CGRenderer::transform(const Mat2D& m) { CGContextConcatCTM(m_ctx, convert(m)); }
-
-void CGRenderer::drawPath(RenderPath* path, RenderPaint* paint) {
- auto cgpaint = reinterpret_cast<CGRenderPaint*>(paint);
- auto cgpath = reinterpret_cast<CGRenderPath*>(path);
-
- cgpaint->apply(m_ctx);
-
- CGContextBeginPath(m_ctx);
- CGContextAddPath(m_ctx, cgpath->path());
- if (auto sh = cgpaint->shader()) {
- if (cgpaint->isStroke()) {
- // so we can clip against the "stroke" of the path
- CGContextReplacePathWithStrokedPath(m_ctx);
- }
- CGContextSaveGState(m_ctx);
- CGContextClip(m_ctx);
-
- // so the gradient modulates with the color's alpha
- CGContextSetAlpha(m_ctx, cgpaint->opacity());
-
- sh->draw(m_ctx);
- CGContextRestoreGState(m_ctx);
- } else {
- CGContextDrawPath(m_ctx, cgpath->drawingMode(cgpaint->isStroke()));
- }
-
- assert(CGContextIsPathEmpty(m_ctx));
-}
-
-void CGRenderer::clipPath(RenderPath* path) {
- auto cgpath = reinterpret_cast<CGRenderPath*>(path);
-
- CGContextBeginPath(m_ctx);
- CGContextAddPath(m_ctx, cgpath->path());
- CGContextClip(m_ctx);
-}
-
-void CGRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity) {
- auto bounds = CGRectMake(0, 0, image->width(), image->height());
-
- CGContextSaveGState(m_ctx);
- CGContextSetAlpha(m_ctx, opacity);
- CGContextSetBlendMode(m_ctx, convert(blendMode));
- auto cgimg = CGRenderImage::Cast(image);
- cgimg->applyLocalMatrix(m_ctx);
- CGContextDrawImage(m_ctx, bounds, cgimg->m_image);
- CGContextRestoreGState(m_ctx);
-}
-
-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);
-}
-
-void CGRenderer::drawImageMesh(const RenderImage* image,
- rcp<RenderBuffer> vertices,
- rcp<RenderBuffer> uvCoords,
- rcp<RenderBuffer> indices,
- BlendMode blendMode,
- float opacity) {
- auto cgimage = CGRenderImage::Cast(image);
- auto const localMatrix = cgimage->localM2D();
-
- const float sx = image->width();
- const float sy = image->height();
- auto const bounds = CGRectMake(0, 0, sx, sy);
-
- auto scale = [sx, sy](Vec2D v) { return Vec2D{v.x * sx, v.y * sy}; };
-
- auto triangles = indices->count() / 3;
- auto ndx = DataRenderBuffer::Cast(indices.get())->u16s();
- auto pts = DataRenderBuffer::Cast(vertices.get())->vecs();
- auto uvs = DataRenderBuffer::Cast(uvCoords.get())->vecs();
-
- // We use the path to set the clip for each triangle. Since calling
- // CGContextClip() resets the path, we only need to this once at
- // the beginning.
- CGContextBeginPath(m_ctx);
-
- CGContextSaveGState(m_ctx);
- CGContextSetAlpha(m_ctx, opacity);
- CGContextSetBlendMode(m_ctx, convert(blendMode));
- CGContextSetShouldAntialias(m_ctx, false);
-
- for (size_t i = 0; i < triangles; ++i) {
- const auto index0 = *ndx++;
- const auto index1 = *ndx++;
- const auto index2 = *ndx++;
-
- CGContextSaveGState(m_ctx);
-
- const auto p0 = pts[index0];
- const auto p1 = pts[index1];
- const auto p2 = pts[index2];
- CGContextMoveToPoint(m_ctx, p0.x, p0.y);
- CGContextAddLineToPoint(m_ctx, p1.x, p1.y);
- CGContextAddLineToPoint(m_ctx, p2.x, p2.y);
- CGContextClip(m_ctx);
-
- const auto v0 = scale(uvs[index0]);
- const auto v1 = scale(uvs[index1]);
- const auto v2 = scale(uvs[index2]);
- auto mx =
- basis_matrix(p0, p1, p2) * basis_matrix(v0, v1, v2).invertOrIdentity() * localMatrix;
- CGContextConcatCTM(m_ctx, convert(mx));
- CGContextDrawImage(m_ctx, bounds, cgimage->m_image);
-
- CGContextRestoreGState(m_ctx);
- }
-
- CGContextRestoreGState(m_ctx); // restore opacity, antialias, etc.
-}
-
-// Factory
-
-rcp<RenderBuffer> CGFactory::makeBufferU16(Span<const uint16_t> data) {
- return DataRenderBuffer::Make(data);
-}
-
-rcp<RenderBuffer> CGFactory::makeBufferU32(Span<const uint32_t> data) {
- return DataRenderBuffer::Make(data);
-}
-
-rcp<RenderBuffer> CGFactory::makeBufferF32(Span<const float> data) {
- return DataRenderBuffer::Make(data);
-}
-
-rcp<RenderShader> CGFactory::makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- return rcp<RenderShader>(
- new CGLinearGradientRenderShader(sx, sy, ex, ey, colors, stops, count));
-}
-
-rcp<RenderShader> CGFactory::makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- return rcp<RenderShader>(
- new CGRadialGradientRenderShader(cx, cy, radius, colors, stops, count));
-}
-
-std::unique_ptr<RenderPath> CGFactory::makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule fillRule) {
- return std::make_unique<CGRenderPath>(points, verbs, fillRule);
-}
-
-std::unique_ptr<RenderPath> CGFactory::makeEmptyRenderPath() {
- return std::make_unique<CGRenderPath>();
-}
-
-std::unique_ptr<RenderPaint> CGFactory::makeRenderPaint() {
- return std::make_unique<CGRenderPaint>();
-}
-
-std::unique_ptr<RenderImage> CGFactory::decodeImage(Span<const uint8_t> encoded) {
- return std::make_unique<CGRenderImage>(encoded);
-}
-
-#endif // APPLE
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/core/type_conversions.hpp"
-#include <vector>
-
-#ifdef RIVE_BUILD_FOR_APPLE
-
-#include "cg_skia_factory.hpp"
-#include "mac_utils.hpp"
-
-#if defined(RIVE_BUILD_FOR_OSX)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(RIVE_BUILD_FOR_IOS)
-#include <CoreGraphics/CoreGraphics.h>
-#include <ImageIO/ImageIO.h>
-#endif
-
-using namespace rive;
-
-std::vector<uint8_t> CGSkiaFactory::platformDecode(Span<const uint8_t> span,
- SkiaFactory::ImageInfo* info) {
- std::vector<uint8_t> pixels;
-
- AutoCF image = DecodeToCGImage(span);
- if (!image) {
- return pixels;
- }
-
- bool isOpaque = false;
- switch (CGImageGetAlphaInfo(image.get())) {
- case kCGImageAlphaNone:
- case kCGImageAlphaNoneSkipFirst:
- 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) {
- cgInfo |= kCGImageAlphaNoneSkipLast;
- } else {
- cgInfo |= kCGImageAlphaPremultipliedLast; // premul
- }
- const size_t width = CGImageGetWidth(image);
- const size_t height = CGImageGetHeight(image);
- const size_t rowBytes = width * 4; // 4 bytes per pixel
- const size_t size = rowBytes * height;
-
- pixels.resize(size);
-
- AutoCF cs = CGColorSpaceCreateDeviceRGB();
- AutoCF cg =
- CGBitmapContextCreate(pixels.data(), width, height, bitsPerComponent, rowBytes, cs, cgInfo);
- if (!cg) {
- pixels.clear();
- return pixels;
- }
-
- CGContextSetBlendMode(cg, kCGBlendModeCopy);
- CGContextDrawImage(cg, CGRectMake(0, 0, width, height), image);
-
- info->alphaType = isOpaque ? AlphaType::opaque : AlphaType::premul;
- info->colorType = ColorType::rgba;
- info->width = castTo<uint32_t>(width);
- info->height = castTo<uint32_t>(height);
- info->rowBytes = rowBytes;
- return pixels;
-};
-
-#endif // RIVE_BUILD_FOR_APPLE
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "mac_utils.hpp"
-
-#ifdef RIVE_BUILD_FOR_APPLE
-
-#if defined(RIVE_BUILD_FOR_IOS)
-#include <CoreGraphics/CGImage.h>
-#include <ImageIO/CGImageSource.h>
-#endif
-
-AutoCF<CGImageRef> rive::FlipCGImageInY(AutoCF<CGImageRef> image) {
- if (!image) {
- return nullptr;
- }
-
- auto w = CGImageGetWidth(image);
- auto h = CGImageGetHeight(image);
- AutoCF space = CGColorSpaceCreateDeviceRGB();
- auto info = kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast;
- AutoCF ctx = CGBitmapContextCreate(nullptr, w, h, 8, 0, space, info);
- CGContextConcatCTM(ctx, CGAffineTransformMake(1, 0, 0, -1, 0, h));
- CGContextDrawImage(ctx, CGRectMake(0, 0, w, h), image);
- return CGBitmapContextCreateImage(ctx);
-}
-
-AutoCF<CGImageRef> rive::DecodeToCGImage(rive::Span<const uint8_t> span) {
- AutoCF data = CFDataCreate(nullptr, span.data(), span.size());
- if (!data) {
- printf("CFDataCreate failed\n");
- return nullptr;
- }
-
- AutoCF source = CGImageSourceCreateWithData(data, nullptr);
- if (!source) {
- printf("CGImageSourceCreateWithData failed\n");
- return nullptr;
- }
-
- AutoCF image = CGImageSourceCreateImageAtIndex(source, 0, nullptr);
- if (!image) {
- printf("CGImageSourceCreateImageAtIndex failed\n");
- }
- return image;
-}
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/rive_types.hpp"
-#include "utils/rive_utf.hpp"
-
-#if defined(RIVE_BUILD_FOR_APPLE) && defined(RIVE_TEXT)
-#include "renderfont_coretext.hpp"
-#include "mac_utils.hpp"
-
-#include "rive/factory.hpp"
-#include "rive/render_text.hpp"
-#include "rive/core/type_conversions.hpp"
-
-#if defined(RIVE_BUILD_FOR_OSX)
-#include <ApplicationServices/ApplicationServices.h>
-#elif defined(RIVE_BUILD_FOR_IOS)
-#include <CoreText/CoreText.h>
-#include <CoreText/CTFontManager.h>
-#include <CoreGraphics/CoreGraphics.h>
-#include <CoreFoundation/CoreFoundation.h>
-#endif
-
-constexpr int kStdScale = 2048;
-constexpr float gInvScale = 1.0f / kStdScale;
-
-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) {
- axes.reserve(count);
-
- for (auto i = 0; i < count; ++i) {
- auto axis = (CFDictionaryRef)CFArrayGetValueAtIndex(array, i);
-
- auto tag = find_u32(axis, kCTFontVariationAxisIdentifierKey);
- auto min = find_float(axis, kCTFontVariationAxisMinimumValueKey);
- auto def = find_float(axis, kCTFontVariationAxisDefaultValueKey);
- auto max = find_float(axis, kCTFontVariationAxisMaximumValueKey);
- // printf("%08X %g %g %g\n", tag, min, def, max);
-
- axes.push_back({tag, min, def, max});
- }
- }
- return axes;
-}
-
-static std::vector<rive::RenderFont::Coord> compute_coords(CTFontRef font) {
- std::vector<rive::RenderFont::Coord> coords(0);
- AutoCF dict = CTFontCopyVariation(font);
- if (dict) {
- int count = CFDictionaryGetCount(dict);
- 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) {
- 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);
- coords[i] = {tag, value};
- }
- }
- }
- return coords;
-}
-
-static rive::RenderFont::LineMetrics make_lmx(CTFontRef font) {
- return {
- (float)-CTFontGetAscent(font) * gInvScale,
- (float)CTFontGetDescent(font) * gInvScale,
- };
-}
-
-CoreTextRenderFont::CoreTextRenderFont(CTFontRef font, std::vector<rive::RenderFont::Axis> axes) :
- rive::RenderFont(make_lmx(font)),
- m_font(font), // we take ownership of font
- m_axes(std::move(axes)),
- m_coords(compute_coords(font)) {}
-
-CoreTextRenderFont::~CoreTextRenderFont() { CFRelease(m_font); }
-
-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) {
- AutoCF tagNum = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &c.axis);
- AutoCF valueNum = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &c.value);
- CFDictionaryAddValue(vars.get(), tagNum.get(), valueNum.get());
- }
-
- AutoCF attrs = CFDictionaryCreateMutable(kCFAllocatorDefault,
- 1,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFDictionarySetValue(attrs.get(), kCTFontVariationAttribute, vars.get());
-
- AutoCF desc = (CTFontDescriptorRef)CTFontDescriptorCreateWithAttributes(attrs.get());
-
- auto font = CTFontCreateCopyWithAttributes(m_font, 0, nullptr, desc.get());
-
- return rive::rcp<rive::RenderFont>(new CoreTextRenderFont(font, compute_axes(font)));
-}
-
-static CTFontRef font_from_run(CTRunRef run) {
- auto attr = CTRunGetAttributes(run);
- assert(attr);
- CTFontRef ct = (CTFontRef)CFDictionaryGetValue(attr, kCTFontAttributeName);
- assert(ct);
- return ct;
-}
-
-static rive::rcp<rive::RenderFont> convert_to_renderfont(CTFontRef ct,
- rive::rcp<rive::RenderFont> rf) {
- auto ctrf = static_cast<CoreTextRenderFont*>(rf.get());
- 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) {
- auto path = (rive::RawPath*)ctx;
- const CGPoint* points = element->points;
-
- 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 kCGPathElementAddQuadCurveToPoint:
- path->quadTo(points[0].x, points[0].y, points[1].x, points[1].y);
- break;
-
- case kCGPathElementAddCurveToPoint:
- path->cubicTo(points[0].x,
- points[0].y,
- points[1].x,
- points[1].y,
- points[2].x,
- points[2].y);
- break;
-
- case kCGPathElementCloseSubpath: path->close(); break;
-
- default: assert(false); break;
- }
-}
-
-rive::RawPath CoreTextRenderFont::getPath(rive::GlyphID glyph) const {
- rive::RawPath rpath;
-
- AutoCF cgPath = CTFontCreatePathForGlyph(m_font, glyph, nullptr);
- if (!cgPath) {
- return rpath;
- }
-
- CGPathApply(cgPath.get(), &rpath, apply_element);
- rpath.transformInPlace(rive::Mat2D::fromScale(gInvScale, -gInvScale));
- return rpath;
-}
-
-////////////////////////////////////////////////////////////////////////////////////
-
-struct AutoUTF16 {
- std::vector<uint16_t> array;
-
- AutoUTF16(const rive::Unichar uni[], int count) {
- array.reserve(count);
- 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) {
- array.push_back(tmp[i]);
- }
- }
- }
-};
-
-static float
-add_run(rive::RenderGlyphRun* gr, CTRunRef run, uint32_t textStart, float textSize, float startX) {
- if (auto count = CTRunGetGlyphCount(run)) {
- const float scale = textSize * gInvScale;
-
- gr->glyphs.resize(count);
- gr->xpos.resize(count + 1);
- gr->textOffsets.resize(count);
-
- CTRunGetGlyphs(run, {0, count}, gr->glyphs.data());
-
- AutoSTArray<1024, CFIndex> indices(count);
- AutoSTArray<1024, CGSize> advances(count);
-
- CTRunGetAdvances(run, {0, count}, advances.data());
- CTRunGetStringIndices(run, {0, count}, indices.data());
-
- for (CFIndex i = 0; i < count; ++i) {
- gr->xpos[i] = startX;
- gr->textOffsets[i] = textStart + indices[i]; // utf16 offsets, will fix-up later
- startX += advances[i].width * scale;
- }
- gr->xpos[count] = startX;
- }
- return startX;
-}
-
-std::vector<rive::RenderGlyphRun>
-CoreTextRenderFont::onShapeText(rive::Span<const rive::Unichar> text,
- rive::Span<const rive::RenderTextRun> truns) const {
- std::vector<rive::RenderGlyphRun> gruns;
- gruns.reserve(truns.size());
-
- uint32_t textIndex = 0;
- float startX = 0;
- for (const auto& tr : truns) {
- CTFontRef font = ((CoreTextRenderFont*)tr.font.get())->m_font;
-
- AutoUTF16 utf16(&text[textIndex], tr.unicharCount);
- const bool hasSurrogates = utf16.array.size() != tr.unicharCount;
- assert(!hasSurrogates);
-
- AutoCF string = CFStringCreateWithCharactersNoCopy(nullptr,
- utf16.array.data(),
- utf16.array.size(),
- kCFAllocatorNull);
-
- AutoCF attr = CFDictionaryCreateMutable(kCFAllocatorDefault,
- 0,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attr.get(), kCTFontAttributeName, font);
-
- AutoCF attrString = CFAttributedStringCreate(kCFAllocatorDefault, string.get(), attr.get());
-
- AutoCF typesetter = CTTypesetterCreateWithAttributedString(attrString.get());
-
- AutoCF line = CTTypesetterCreateLine(typesetter.get(), {0, tr.unicharCount});
-
- CFArrayRef run_array = CTLineGetGlyphRuns(line.get());
- CFIndex runCount = CFArrayGetCount(run_array);
- for (CFIndex i = 0; i < runCount; ++i) {
- CTRunRef runref = (CTRunRef)CFArrayGetValueAtIndex(run_array, i);
- rive::RenderGlyphRun grun;
- startX = add_run(&grun, runref, textIndex, tr.size, startX);
- if (grun.glyphs.size() > 0) {
- auto ct = font_from_run(runref);
- grun.font = convert_to_renderfont(ct, tr.font);
- grun.size = tr.size;
- gruns.push_back(std::move(grun));
- }
- }
- textIndex += tr.unicharCount;
- }
-
- return gruns;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-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) {
- ctfont = CTFontCreateCopyWithAttributes(ctfont, kStdScale, nullptr, nullptr);
- } 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) {
- constexpr uint32_t kOPSZ = make_tag('o', 'p', 's', 'z');
- 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
- auto newfont = CTFontCreateCopyWithAttributes(ctfont, ax.def, &xform, nullptr);
- CFRelease(ctfont);
- ctfont = newfont;
- break;
- }
- }
- }
-
- return rive::rcp<rive::RenderFont>(new CoreTextRenderFont(ctfont, std::move(axes)));
-}
-
-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) {
- assert(false);
- return nullptr;
- }
-
- AutoCF desc = CTFontManagerCreateFontDescriptorFromData(data.get());
- if (!desc) {
- assert(false);
- return nullptr;
- }
-
- CTFontOptions options = kCTFontOptionsPreventAutoActivation;
-
- AutoCF ctfont =
- CTFontCreateWithFontDescriptorAndOptions(desc.get(), kStdScale, nullptr, options);
- if (!ctfont) {
- assert(false);
- return nullptr;
- }
- return FromCT(ctfont.get());
-}
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/render_text.hpp"
-
-#ifdef RIVE_TEXT
-#include "renderfont_hb.hpp"
-
-#include "rive/factory.hpp"
-#include "renderer_utils.hpp"
-
-#include "hb.h"
-#include "hb-ot.h"
-
-// 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) {
- auto blob = hb_blob_create_or_fail((const char*)span.data(),
- (unsigned)span.size(),
- HB_MEMORY_MODE_DUPLICATE,
- nullptr,
- nullptr);
- if (blob) {
- auto face = hb_face_create(blob, 0);
- hb_blob_destroy(blob);
- if (face) {
- auto font = hb_font_create(face);
- hb_face_destroy(face);
- if (font) {
- return rive::rcp<rive::RenderFont>(new HBRenderFont(font));
- }
- }
- }
- return nullptr;
-}
-
-//////////////
-
-constexpr int kStdScale = 2048;
-constexpr float gInvScale = 1.0f / kStdScale;
-
-extern "C" {
-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);
-}
-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);
-}
-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);
-}
-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);
-}
-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) {
- // premable on font...
- hb_ot_font_set_funcs(font);
- hb_font_set_scale(font, kStdScale, kStdScale);
-
- hb_font_extents_t extents;
- hb_font_get_h_extents(font, &extents);
- return {-extents.ascender * gInvScale, -extents.descender * gInvScale};
-}
-
-HBRenderFont::HBRenderFont(hb_font_t* font) :
- 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);
- hb_draw_funcs_set_line_to_func(m_DrawFuncs, rpath_line_to, nullptr, nullptr);
- hb_draw_funcs_set_quadratic_to_func(m_DrawFuncs, rpath_quad_to, nullptr, nullptr);
- hb_draw_funcs_set_cubic_to_func(m_DrawFuncs, rpath_cubic_to, nullptr, nullptr);
- hb_draw_funcs_set_close_path_func(m_DrawFuncs, rpath_close, nullptr, nullptr);
- hb_draw_funcs_make_immutable(m_DrawFuncs);
-}
-
-HBRenderFont::~HBRenderFont() {
- hb_draw_funcs_destroy(m_DrawFuncs);
- hb_font_destroy(m_Font);
-}
-
-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) {
- axes.resize(count);
-
- hb_ot_var_axis_info_t info;
- for (int i = 0; i < count; ++i) {
- unsigned n = 1;
- hb_ot_var_get_axis_infos(face, i, &n, &info);
- assert(n == 1);
- axes[i] = {info.tag, info.min_value, info.default_value, info.max_value};
- // printf("[%d] %08X %g %g %g\n", i, info.tag, info.min_value, info.default_value,
- // info.max_value);
- }
- }
- return axes;
-}
-
-std::vector<rive::RenderFont::Coord> HBRenderFont::getCoords() const {
- auto axes = this->getAxes();
- // const int count = (int)axes.size();
-
- unsigned length;
- 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) {
- coords[i] = {axes[i].tag, values[i]};
- }
- return coords;
-}
-
-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) {
- vars[i] = {coords[i].axis, coords[i].value};
- }
- auto font = hb_font_create_sub_font(m_Font);
- hb_font_set_variations(font, vars.data(), vars.size());
- return rive::rcp<rive::RenderFont>(new HBRenderFont(font));
-}
-
-rive::RawPath HBRenderFont::getPath(rive::GlyphID glyph) const {
- rive::RawPath rpath;
- hb_font_get_glyph_shape(m_Font, glyph, m_DrawFuncs, &rpath);
- return rpath;
-}
-
-///////////////////////////////////////////////////////////
-
-const hb_feature_t gFeatures[] = {
- {'liga', 1, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END},
- {'dlig', 1, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END},
- {'kern', 1, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END},
-};
-constexpr int gNumFeatures = sizeof(gFeatures) / sizeof(gFeatures[0]);
-
-static rive::RenderGlyphRun shape_run(const rive::Unichar text[],
- const rive::RenderTextRun& tr,
- unsigned textOffset) {
- hb_buffer_t* buf = hb_buffer_create();
- hb_buffer_add_utf32(buf, text, tr.unicharCount, 0, tr.unicharCount);
-
- hb_buffer_set_direction(buf, HB_DIRECTION_LTR);
- hb_buffer_set_script(buf, HB_SCRIPT_LATIN);
- hb_buffer_set_language(buf, hb_language_from_string("en", -1));
-
- auto hbfont = (HBRenderFont*)tr.font.get();
- hb_shape(hbfont->m_Font, buf, gFeatures, gNumFeatures);
-
- unsigned int glyph_count;
- hb_glyph_info_t* glyph_info = hb_buffer_get_glyph_infos(buf, &glyph_count);
- hb_glyph_position_t* glyph_pos = hb_buffer_get_glyph_positions(buf, &glyph_count);
-
- // todo: check for missing glyphs, and perform font-substitution
-
- rive::RenderGlyphRun gr;
- gr.font = tr.font;
- gr.size = tr.size;
- gr.glyphs.resize(glyph_count);
- gr.textOffsets.resize(glyph_count);
- gr.xpos.resize(glyph_count + 1);
-
- const float scale = tr.size / kStdScale;
- 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;
-
- gr.glyphs[i] = (uint16_t)glyph_info[i].codepoint;
- gr.textOffsets[i] = textOffset + glyph_info[i].cluster;
- gr.xpos[i] = glyph_pos[i].x_advance * scale;
- }
- gr.xpos[glyph_count] = 0; // so the next run can line up snug
- hb_buffer_destroy(buf);
- return gr;
-}
-
-static rive::RenderGlyphRun extract_subset(const rive::RenderGlyphRun& orig,
- size_t start,
- size_t end) {
- rive::RenderGlyphRun subset;
- subset.font = std::move(orig.font);
- subset.size = orig.size;
- subset.glyphs.insert(subset.glyphs.begin(), &orig.glyphs[start], &orig.glyphs[end]);
- subset.textOffsets.insert(subset.textOffsets.begin(),
- &orig.textOffsets[start],
- &orig.textOffsets[end]);
- subset.xpos.insert(subset.xpos.begin(), &orig.xpos[start], &orig.xpos[end + 1]);
- subset.xpos.back() = 0; // since we're now the end of a run
- return subset;
-}
-
-static void perform_fallback(rive::rcp<rive::RenderFont> fallbackFont,
- std::vector<rive::RenderGlyphRun>* gruns,
- const rive::Unichar text[],
- const rive::RenderGlyphRun& orig) {
- assert(orig.glyphs.size() > 0);
-
- const size_t count = orig.glyphs.size();
- size_t startI = 0;
- while (startI < count) {
- size_t endI = startI + 1;
- if (orig.glyphs[startI] == 0) {
- while (endI < count && orig.glyphs[endI] == 0) {
- ++endI;
- }
- auto textStart = orig.textOffsets[startI];
- auto textCount = orig.textOffsets[endI - 1] - textStart + 1;
- auto tr = rive::RenderTextRun{fallbackFont, orig.size, textCount};
- auto gr = shape_run(&text[textStart], tr, textStart);
- gruns->push_back(std::move(gr));
- } else {
- while (endI < count && orig.glyphs[endI] != 0) {
- ++endI;
- }
- gruns->push_back(extract_subset(orig, startI, endI));
- }
- startI = endI;
- }
-}
-
-std::vector<rive::RenderGlyphRun>
-HBRenderFont::onShapeText(rive::Span<const rive::Unichar> text,
- rive::Span<const rive::RenderTextRun> truns) const {
- std::vector<rive::RenderGlyphRun> gruns;
- gruns.reserve(truns.size());
-
- /////////////////
-
- uint32_t unicharIndex = 0;
- 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) {
- gruns.push_back(std::move(gr));
- } 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.textOffsets[index]];
- // todo: consider sending more chars if that helps choose a font
- auto fallback = gFallbackProc({&missing, 1});
- if (fallback) {
- perform_fallback(fallback, &gruns, text.data(), gr);
- } else {
- gruns.push_back(std::move(gr)); // oh well, just keep the missing glyphs
- }
- }
- }
-
- // 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) {
- float adv = xp;
- xp = pos;
- pos += adv;
- }
- }
- return gruns;
-}
-
-#endif
\ No newline at end of file
#include "include/core/SkCanvas.h"
#include "include/core/SkData.h"
#include "include/core/SkImage.h"
-#include "include/core/SkPixmap.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkVertices.h"
#include "rive/math/vec2d.hpp"
#include "rive/shapes/paint/color.hpp"
-#include "utils/factory_utils.hpp"
using namespace rive;
-// skia's has/had bugs in trilerp, so backing down to nearest mip
-const SkSamplingOptions gSampling(SkFilterMode::kLinear, SkMipmapMode::kNearest);
-
class SkiaRenderPath : public RenderPath {
private:
SkPath m_Path;
void cap(StrokeCap value) override;
void blendMode(BlendMode value) override;
void shader(rcp<RenderShader>) override;
- void invalidateStroke() override {}
};
class SkiaRenderImage : public RenderImage {
SkiaRenderImage(sk_sp<SkImage> image);
sk_sp<SkImage> skImage() const { return m_SkImage; }
+
+ rcp<RenderShader>
+ makeShader(RenderTileMode tx, RenderTileMode ty, const Mat2D* localMatrix) const override;
+};
+
+class SkiaBuffer : public RenderBuffer {
+ const size_t m_ElemSize;
+ void* m_Buffer;
+
+public:
+ SkiaBuffer(const void* src, size_t count, size_t elemSize) :
+ RenderBuffer(count), m_ElemSize(elemSize) {
+ size_t bytes = count * elemSize;
+ m_Buffer = malloc(bytes);
+ memcpy(m_Buffer, src, bytes);
+ }
+
+ ~SkiaBuffer() override { free(m_Buffer); }
+
+ const float* f32s() const {
+ assert(m_ElemSize == sizeof(float));
+ return static_cast<const float*>(m_Buffer);
+ }
+
+ const uint16_t* u16s() const {
+ assert(m_ElemSize == sizeof(uint16_t));
+ return static_cast<const uint16_t*>(m_Buffer);
+ }
+
+ const SkPoint* points() const { return reinterpret_cast<const SkPoint*>(this->f32s()); }
+
+ static const SkiaBuffer* Cast(const RenderBuffer* buffer) {
+ return reinterpret_cast<const SkiaBuffer*>(buffer);
+ }
};
+template <typename T> rcp<RenderBuffer> make_buffer(Span<T> span) {
+ return rcp<RenderBuffer>(new SkiaBuffer(span.data(), span.size(), sizeof(T)));
+}
+
class SkiaRenderShader : public RenderShader {
public:
SkiaRenderShader(sk_sp<SkShader> sh) : shader(std::move(sh)) {}
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;
+ 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); }
paint.setAlphaf(opacity);
paint.setBlendMode(ToSkia::convert(blendMode));
auto skiaImage = reinterpret_cast<const SkiaRenderImage*>(image);
- m_Canvas->drawImage(skiaImage->skImage(), 0.0f, 0.0f, gSampling, &paint);
+ SkSamplingOptions sampling(SkFilterMode::kLinear);
+ m_Canvas->drawImage(skiaImage->skImage(), 0.0f, 0.0f, sampling, &paint);
}
#define SKIA_BUG_13047
SkMatrix scaleM;
- auto uvs = (const SkPoint*)DataRenderBuffer::Cast(uvCoords.get())->vecs();
+ const SkPoint* uvs = SkiaBuffer::Cast(uvCoords.get())->points();
#ifdef SKIA_BUG_13047
// The local matrix is ignored for drawVertices, so we have to manually scale
#endif
auto skiaImage = reinterpret_cast<const SkiaRenderImage*>(image)->skImage();
- auto shader = skiaImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, gSampling, &scaleM);
+ const SkSamplingOptions sampling(SkFilterMode::kLinear);
+ auto shader = skiaImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, sampling, &scaleM);
SkPaint paint;
paint.setAlphaf(opacity);
// clang-format off
auto vt = SkVertices::MakeCopy(vertexMode,
vertexCount,
- (const SkPoint*)DataRenderBuffer::Cast(vertices.get())->vecs(),
+ SkiaBuffer::Cast(vertices.get())->points(),
uvs,
no_colors,
indices->count(),
- DataRenderBuffer::Cast(indices.get())->u16s());
+ SkiaBuffer::Cast(indices.get())->u16s());
// clang-format on
// The blend mode is ignored if we don't have colors && uvs
m_Height = m_SkImage->height();
}
+rcp<RenderShader>
+SkiaRenderImage::makeShader(RenderTileMode tx, RenderTileMode ty, const Mat2D* localMatrix) const {
+ const SkMatrix lm = localMatrix ? ToSkia::convert(*localMatrix) : SkMatrix();
+ const SkSamplingOptions options(SkFilterMode::kLinear);
+ auto sh = m_SkImage->makeShader(ToSkia::convert(tx), ToSkia::convert(ty), options, &lm);
+ return rcp<RenderShader>(new SkiaRenderShader(std::move(sh)));
+}
+
// Factory
rcp<RenderBuffer> SkiaFactory::makeBufferU16(Span<const uint16_t> data) {
- return DataRenderBuffer::Make(data);
+ return make_buffer(data);
}
rcp<RenderBuffer> SkiaFactory::makeBufferU32(Span<const uint32_t> data) {
- return DataRenderBuffer::Make(data);
+ return make_buffer(data);
}
rcp<RenderBuffer> SkiaFactory::makeBufferF32(Span<const float> data) {
- return DataRenderBuffer::Make(data);
+ return make_buffer(data);
}
-rcp<RenderShader> SkiaFactory::makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
+rcp<RenderShader> SkiaFactory::makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode mode,
+ const Mat2D* localMatrix) {
const SkPoint pts[] = {{sx, sy}, {ex, ey}};
- auto sh =
- SkGradientShader::MakeLinear(pts, (const SkColor*)colors, stops, count, SkTileMode::kClamp);
+ const SkMatrix lm = localMatrix ? ToSkia::convert(*localMatrix) : SkMatrix();
+ auto sh = SkGradientShader::MakeLinear(
+ pts, (const SkColor*)colors, stops, count, ToSkia::convert(mode), 0, &lm);
return rcp<RenderShader>(new SkiaRenderShader(std::move(sh)));
}
-rcp<RenderShader> SkiaFactory::makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- auto sh = SkGradientShader::MakeRadial({cx, cy},
- radius,
- (const SkColor*)colors,
- stops,
- count,
- SkTileMode::kClamp);
+rcp<RenderShader> SkiaFactory::makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode mode,
+ const Mat2D* localMatrix) {
+ const SkMatrix lm = localMatrix ? ToSkia::convert(*localMatrix) : SkMatrix();
+ auto sh = SkGradientShader::MakeRadial(
+ {cx, cy}, radius, (const SkColor*)colors, stops, count, ToSkia::convert(mode), 0, &lm);
return rcp<RenderShader>(new SkiaRenderShader(std::move(sh)));
}
std::unique_ptr<RenderPath> SkiaFactory::makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
+ Span<const uint8_t> verbs,
FillRule fillRule) {
- const bool isVolatile = false; // ???
+ const bool isVolatile = false; // ???
const SkScalar* conicWeights = nullptr;
const int conicWeightCount = 0;
- return std::make_unique<SkiaRenderPath>(
- SkPath::Make(reinterpret_cast<const SkPoint*>(points.data()),
- points.count(),
- (uint8_t*)verbs.data(),
- verbs.count(),
- conicWeights,
- conicWeightCount,
- ToSkia::convert(fillRule),
- isVolatile));
+ return std::make_unique<SkiaRenderPath>(SkPath::Make(reinterpret_cast<const SkPoint*>(points.data()),
+ points.count(),
+ verbs.data(),
+ verbs.count(),
+ conicWeights,
+ conicWeightCount,
+ ToSkia::convert(fillRule),
+ isVolatile));
}
std::unique_ptr<RenderPath> SkiaFactory::makeEmptyRenderPath() {
sk_sp<SkData> data = SkData::MakeWithoutCopy(encoded.data(), encoded.size());
auto image = SkImage::MakeFromEncoded(data);
+ // Our optimized skia buld seems to have broken lazy-image decode.
+ // As a work-around for now, force the image to be decoded.
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 {
- // Skia failed, so let's try the platform
- ImageInfo info;
- auto pixels = this->platformDecode(encoded, &info);
- if (pixels.size() > 0) {
- auto ct =
- info.colorType == ColorType::rgba ? kRGBA_8888_SkColorType : kBGRA_8888_SkColorType;
- auto at =
- info.alphaType == AlphaType::premul ? kPremul_SkAlphaType : kOpaque_SkAlphaType;
- auto skinfo = SkImageInfo::Make(info.width, info.height, ct, at);
- image = SkImage::MakeRasterCopy({skinfo, pixels.data(), info.rowBytes});
- }
}
return image ? std::make_unique<SkiaRenderImage>(std::move(image)) : nullptr;
#!/bin/bash
-set -e
dir=$(pwd)
cd ../renderer
-./build.sh "$@"
+./build.sh $@
-cd "$dir"
+cd $dir
cd build
}
fclose(fp);
- auto file = rive::File::import(bytes, &factory);
+ auto file = rive::File::import(rive::toSpan(bytes), &factory);
if (!file) {
fprintf(stderr, "Failed to read rive file.\n");
return 1;
--- /dev/null
+#!/bin/bash
+
+# dir=$(pwd)
+
+# cd ../renderer
+# ./build.sh $@
+
+# cd $dir
+
+cd build
+
+OPTION=$1
+
+if [ "$OPTION" = 'help' ]; then
+ echo build.sh - build debug library
+ echo build.sh clean - clean the build
+ echo build.sh release - build release library
+elif [ "$OPTION" = "clean" ]; then
+ echo Cleaning project ...
+ # TODO: fix premake5 clean to bubble the clean command to dependent projects
+ premake5 gmake && make clean
+elif [ "$OPTION" = "release" ]; then
+ premake5 gmake && make config=release -j7
+else
+ premake5 gmake && make config=debug -j7
+fi
--- /dev/null
+workspace "rive"
+configurations {"debug", "release"}
+
+BASE_DIR = path.getabsolute("../../../build")
+location("./")
+dofile(path.join(BASE_DIR, "premake5.lua"))
+
+BASE_DIR = path.getabsolute("../../renderer/build")
+location("./")
+dofile(path.join(BASE_DIR, "premake5.lua"))
+
+project "rive_viewer"
+ kind "ConsoleApp"
+ language "C++"
+ cppdialect "C++17"
+ targetdir "%{cfg.system}/bin/%{cfg.buildcfg}"
+ objdir "%{cfg.system}/obj/%{cfg.buildcfg}"
+ includedirs {
+ "../include",
+ "../../../include",
+ "../../renderer/include",
+ "../../dependencies/glfw/include",
+ "../../dependencies/skia",
+ "../../dependencies/skia/include/core",
+ "../../dependencies/skia/include/effects",
+ "../../dependencies/skia/include/gpu",
+ "../../dependencies/skia/include/config",
+ "../../dependencies/imgui",
+ "../../dependencies",
+ "../../dependencies/gl3w/build/include"
+ }
+
+ links {
+ "Cocoa.framework",
+ "IOKit.framework",
+ "CoreVideo.framework",
+ "rive",
+ "skia",
+ "rive_skia_renderer",
+ "glfw3"
+ }
+
+ libdirs {
+ "../../../build/%{cfg.system}/bin/%{cfg.buildcfg}",
+ "../../dependencies/glfw_build/src",
+ "../../dependencies/skia/out/static",
+ "../../renderer/build/%{cfg.system}/bin/%{cfg.buildcfg}"
+ }
+
+ files {
+ "../src/**.cpp",
+ "../../dependencies/gl3w/build/src/gl3w.c",
+ "../../dependencies/imgui/backends/imgui_impl_glfw.cpp",
+ "../../dependencies/imgui/backends/imgui_impl_opengl3.cpp",
+ "../../dependencies/imgui/imgui_widgets.cpp",
+ "../../dependencies/imgui/imgui.cpp",
+ "../../dependencies/imgui/imgui_tables.cpp",
+ "../../dependencies/imgui/imgui_draw.cpp"
+ }
+
+ buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti"}
+
+ filter "configurations:debug"
+ buildoptions {"-g"}
+ defines {"DEBUG"}
+ symbols "On"
+
+ filter "configurations:release"
+ buildoptions {"-flto=full"}
+ defines {"RELEASE"}
+ defines {"NDEBUG"}
+ optimize "On"
+
+-- Clean Function --
+newaction {
+ trigger = "clean",
+ description = "clean the build",
+ execute = function()
+ print("clean the build...")
+ os.rmdir("./bin")
+ os.rmdir("./obj")
+ os.remove("Makefile")
+ -- no wildcards in os.remove, so use shell
+ os.execute("rm *.make")
+ print("build cleaned")
+ end
+}
--- /dev/null
+
+OPTION=$1
+unameSystem="$(uname -s)"
+case "${unameSystem}" in
+ Linux*) system=linux;;
+ Darwin*) system=macosx;;
+ *) system="unknown:${unameSystem}"
+esac
+
+if [ "$OPTION" = 'help' ]; then
+ echo build.sh - build debug library
+ echo build.sh clean - clean the build
+ echo build.sh release - build release library
+elif [ "$OPTION" = "release" ]; then
+ ./build/$system/bin/release/rive_viewer
+elif [ "$OPTION" = "lldb" ]; then
+ lldb build/$system/bin/debug/rive_viewer
+else
+ ./build/$system/bin/debug/rive_viewer
+fi
--- /dev/null
+
+// Makes ure gl3w is included before glfw3
+#include "GL/gl3w.h"
+
+#define SK_GL
+#include "GLFW/glfw3.h"
+
+#include "GrBackendSurface.h"
+#include "GrDirectContext.h"
+#include "SkCanvas.h"
+#include "SkColorSpace.h"
+#include "SkSurface.h"
+#include "SkTypes.h"
+#include "gl/GrGLInterface.h"
+
+#include "rive/animation/linear_animation_instance.hpp"
+#include "rive/animation/state_machine_instance.hpp"
+#include "rive/animation/state_machine_input_instance.hpp"
+#include "rive/animation/state_machine_number.hpp"
+#include "rive/animation/state_machine_bool.hpp"
+#include "rive/animation/state_machine_trigger.hpp"
+#include "rive/artboard.hpp"
+#include "rive/file.hpp"
+#include "rive/layout.hpp"
+#include "rive/math/aabb.hpp"
+#include "skia_factory.hpp"
+#include "skia_renderer.hpp"
+
+#include "imgui/backends/imgui_impl_glfw.h"
+#include "imgui/backends/imgui_impl_opengl3.h"
+
+#include <cmath>
+#include <stdio.h>
+
+rive::SkiaFactory skiaFactory;
+
+std::string filename;
+std::unique_ptr<rive::File> currentFile;
+std::unique_ptr<rive::ArtboardInstance> artboardInstance;
+std::unique_ptr<rive::Scene> currentScene;
+
+// 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
+std::vector<std::string> animationNames;
+std::vector<std::string> stateMachineNames;
+
+constexpr int REQUEST_DEFAULT_SCENE = -1;
+
+#include <time.h>
+double GetSecondsToday() {
+ time_t m_time;
+ time(&m_time);
+ struct tm tstruct;
+ gmtime_r(&m_time, &tstruct);
+
+ int hours = tstruct.tm_hour - 4;
+ if (hours < 0) {
+ hours += 12;
+ } else if (hours >= 12) {
+ hours -= 12;
+ }
+
+ auto secs = (double)hours * 60 * 60 +
+ (double)tstruct.tm_min * 60 +
+ (double)tstruct.tm_sec;
+// printf("%d %d %d\n", tstruct.tm_sec, tstruct.tm_min, hours);
+// printf("%g %g %g\n", secs, secs/60, secs/60/60);
+ return secs;
+}
+
+// We hold onto the file's bytes for the lifetime of the file, in case we want
+// to change animations or state-machines, we just rebuild the rive::File from
+// it.
+std::vector<uint8_t> fileBytes;
+
+int animationIndex = 0;
+int stateMachineIndex = -1;
+
+static void loadNames(const rive::Artboard* ab) {
+ animationNames.clear();
+ stateMachineNames.clear();
+ 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) {
+ stateMachineNames.push_back(ab->stateMachineNameAt(i));
+ }
+ }
+}
+
+void initStateMachine(int index) {
+ assert(fileBytes.size() != 0);
+ auto file = rive::File::import(rive::toSpan(fileBytes), &skiaFactory);
+ if (!file) {
+ fileBytes.clear();
+ fprintf(stderr, "failed to import file\n");
+ return;
+ }
+
+ stateMachineIndex = -1;
+ animationIndex = -1;
+ currentScene = nullptr;
+ artboardInstance = nullptr;
+
+ currentFile = std::move(file);
+ artboardInstance = currentFile->artboardDefault();
+ artboardInstance->advance(0.0f);
+ loadNames(artboardInstance.get());
+
+ if (index < 0) {
+ currentScene = artboardInstance->defaultStateMachine();
+ index = artboardInstance->defaultStateMachineIndex();
+ }
+ if (!currentScene) {
+ if (index >= artboardInstance->stateMachineCount()) {
+ index = 0;
+ }
+ currentScene = artboardInstance->stateMachineAt(index);
+ }
+ if (!currentScene) {
+ index = -1;
+ currentScene = artboardInstance->animationAt(0);
+ animationIndex = 0;
+ }
+ stateMachineIndex = index;
+
+ if (currentScene) {
+ currentScene->inputCount();
+ }
+}
+
+void initAnimation(int index) {
+ animationIndex = index;
+ stateMachineIndex = -1;
+ assert(fileBytes.size() != 0);
+ auto file = rive::File::import(rive::toSpan(fileBytes), &skiaFactory);
+ if (!file) {
+ fileBytes.clear();
+ fprintf(stderr, "failed to import file\n");
+ return;
+ }
+ currentScene = nullptr;
+ artboardInstance = nullptr;
+
+ currentFile = std::move(file);
+ artboardInstance = currentFile->artboardDefault();
+ artboardInstance->advance(0.0f);
+ loadNames(artboardInstance.get());
+
+ if (index >= 0 && index < artboardInstance->animationCount()) {
+ currentScene = artboardInstance->animationAt(index);
+ currentScene->inputCount();
+ }
+}
+
+rive::Mat2D gInverseViewTransform;
+rive::Vec2D lastWorldMouse;
+static void glfwCursorPosCallback(GLFWwindow* window, double x, double y) {
+ float xscale, yscale;
+ glfwGetWindowContentScale(window, &xscale, &yscale);
+ lastWorldMouse = gInverseViewTransform * rive::Vec2D(x * xscale, y * yscale);
+ if (currentScene) {
+ currentScene->pointerMove(lastWorldMouse);
+ }
+}
+void glfwMouseButtonCallback(GLFWwindow* window, int button, int action, int mods) {
+ if (currentScene) {
+ switch (action) {
+ case GLFW_PRESS:
+ currentScene->pointerDown(lastWorldMouse);
+ break;
+ case GLFW_RELEASE:
+ currentScene->pointerUp(lastWorldMouse);
+ break;
+ }
+ }
+}
+
+void glfwErrorCallback(int error, const char* description) { puts(description); }
+
+void glfwDropCallback(GLFWwindow* window, int count, const char** paths) {
+ // Just get the last dropped file for now...
+ filename = paths[count - 1];
+
+ FILE* fp = fopen(filename.c_str(), "rb");
+ fseek(fp, 0, SEEK_END);
+ size_t size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ fileBytes.resize(size);
+ if (fread(fileBytes.data(), 1, size, fp) != size) {
+ fileBytes.clear();
+ fprintf(stderr, "failed to read all of %s\n", filename.c_str());
+ return;
+ }
+ initStateMachine(REQUEST_DEFAULT_SCENE);
+}
+
+int main() {
+ if (!glfwInit()) {
+ fprintf(stderr, "Failed to initialize glfw.\n");
+ return 1;
+ }
+ glfwSetErrorCallback(glfwErrorCallback);
+
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
+ GLFWwindow* window = glfwCreateWindow(1280, 720, "Rive Viewer", NULL, NULL);
+ if (window == nullptr) {
+ fprintf(stderr, "Failed to make window or GL.\n");
+ glfwTerminate();
+ return 1;
+ }
+
+ glfwSetDropCallback(window, glfwDropCallback);
+ glfwSetCursorPosCallback(window, glfwCursorPosCallback);
+ glfwSetMouseButtonCallback(window, glfwMouseButtonCallback);
+ glfwMakeContextCurrent(window);
+ if (gl3wInit() != 0) {
+ fprintf(stderr, "Failed to make initialize gl3w.\n");
+ glfwTerminate();
+ return 1;
+ }
+ // Enable VSYNC.
+ glfwSwapInterval(1);
+
+ // Setup ImGui
+ ImGui::CreateContext();
+ ImGuiIO& io = ImGui::GetIO();
+ (void)io;
+
+ ImGui::StyleColorsDark();
+ ImGui_ImplGlfw_InitForOpenGL(window, true);
+ ImGui_ImplOpenGL3_Init("#version 150");
+ io.Fonts->AddFontDefault();
+
+ // Setup Skia
+ GrContextOptions options;
+ sk_sp<GrDirectContext> context = GrDirectContext::MakeGL(nullptr, options);
+ GrGLFramebufferInfo framebufferInfo;
+ framebufferInfo.fFBOID = 0;
+ framebufferInfo.fFormat = GL_RGBA8;
+
+ sk_sp<SkSurface> surface;
+ SkCanvas* canvas = nullptr;
+
+ // Render loop.
+ int width = 0, height = 0;
+ int lastScreenWidth = 0, lastScreenHeight = 0;
+ double lastTime = glfwGetTime();
+ while (!glfwWindowShouldClose(window)) {
+ glfwGetFramebufferSize(window, &width, &height);
+
+ // Update surface.
+ if (!surface || width != lastScreenWidth || height != lastScreenHeight) {
+ lastScreenWidth = width;
+ lastScreenHeight = height;
+
+ SkColorType colorType =
+ kRGBA_8888_SkColorType; // GrColorTypeToSkColorType(GrPixelConfigToColorType(kRGBA_8888_GrPixelConfig));
+ //
+ // if (kRGBA_8888_GrPixelConfig == kSkia8888_GrPixelConfig)
+ // {
+ // colorType = kRGBA_8888_SkColorType;
+ // }
+ // else
+ // {
+ // colorType = kBGRA_8888_SkColorType;
+ // }
+
+ GrBackendRenderTarget backendRenderTarget(width,
+ height,
+ 0, // sample count
+ 0, // stencil bits
+ framebufferInfo);
+
+ surface = SkSurface::MakeFromBackendRenderTarget(context.get(),
+ backendRenderTarget,
+ kBottomLeft_GrSurfaceOrigin,
+ colorType,
+ nullptr,
+ nullptr);
+ if (!surface) {
+ fprintf(stderr, "Failed to create Skia surface\n");
+ return 1;
+ }
+ canvas = surface->getCanvas();
+ }
+
+ double time = glfwGetTime();
+ float elapsed = (float)(time - lastTime);
+ lastTime = time;
+
+ // Clear screen.
+ SkPaint paint;
+ paint.setColor(SK_ColorDKGRAY);
+ canvas->drawPaint(paint);
+
+ if (currentScene) {
+ // See if we can "set the time" e.g. clock statemachine
+ if (auto num = currentScene->getNumber("isTime")) {
+ num->value(GetSecondsToday()/60/60);
+ }
+
+ currentScene->advanceAndApply(elapsed);
+
+ rive::SkiaRenderer renderer(canvas);
+ renderer.save();
+
+ auto viewTransform = rive::computeAlignment(rive::Fit::contain,
+ rive::Alignment::center,
+ rive::AABB(0, 0, width, height),
+ currentScene->bounds());
+ renderer.transform(viewTransform);
+ // Store the inverse view so we can later go from screen to world.
+ gInverseViewTransform = viewTransform.invertOrIdentity();
+ // post_mouse_event(artboard.get(), canvas->getTotalMatrix());
+
+ currentScene->draw(&renderer);
+ renderer.restore();
+ }
+ context->flush();
+
+ ImGui_ImplOpenGL3_NewFrame();
+ ImGui_ImplGlfw_NewFrame();
+ ImGui::NewFrame();
+
+ if (artboardInstance != nullptr) {
+ ImGui::Begin(filename.c_str(), nullptr);
+ if (ImGui::ListBox(
+ "Animations",
+ &animationIndex,
+ [](void* data, int index, const char** name) {
+ *name = animationNames[index].c_str();
+ return true;
+ },
+ artboardInstance.get(),
+ animationNames.size(),
+ 4))
+ {
+ stateMachineIndex = -1;
+ initAnimation(animationIndex);
+ }
+ if (ImGui::ListBox(
+ "State Machines",
+ &stateMachineIndex,
+ [](void* data, int index, const char** name) {
+ *name = stateMachineNames[index].c_str();
+ return true;
+ },
+ artboardInstance.get(),
+ stateMachineNames.size(),
+ 4))
+ {
+ animationIndex = -1;
+ initStateMachine(stateMachineIndex);
+ }
+ if (currentScene != nullptr) {
+
+ ImGui::Columns(2);
+ ImGui::SetColumnWidth(0, ImGui::GetWindowWidth() * 0.6666);
+
+ for (int i = 0; i < currentScene->inputCount(); i++) {
+ auto inputInstance = currentScene->input(i);
+
+ 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];
+ snprintf(label, 256, "##%u", i);
+
+ auto number = static_cast<rive::SMINumber*>(inputInstance);
+ float v = number->value();
+ ImGui::InputFloat(label, &v, 1.0f, 2.0f, "%.3f");
+ number->value(v);
+ ImGui::NextColumn();
+ } 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)) {
+ auto trigger = static_cast<rive::SMITrigger*>(inputInstance);
+ trigger->fire();
+ }
+ ImGui::NextColumn();
+ } 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];
+ snprintf(label, 256, "##%u", i);
+ auto boolInput = static_cast<rive::SMIBool*>(inputInstance);
+ bool value = boolInput->value();
+
+ ImGui::Checkbox(label, &value);
+ boolInput->value(value);
+ ImGui::NextColumn();
+ }
+ ImGui::Text("%s", inputInstance->input()->name().c_str());
+ ImGui::NextColumn();
+ }
+
+ ImGui::Columns(1);
+ }
+ ImGui::End();
+
+ } else {
+ ImGui::Text("Drop a .riv file to preview.");
+ }
+
+ ImGui::Render();
+ ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
+
+ glfwSwapBuffers(window);
+ glfwPollEvents();
+ }
+
+ // Cleanup Skia.
+ surface = nullptr;
+ context = nullptr;
+
+ ImGui_ImplGlfw_Shutdown();
+
+ // Cleanup GLFW.
+ glfwDestroyWindow(window);
+ glfwTerminate();
+
+ return 0;
+}
#include "rive/animation/animation_state.hpp"
#include "rive/animation/linear_animation.hpp"
#include "rive/animation/animation_state_instance.hpp"
+#include "rive/animation/system_state_instance.hpp"
#include "rive/core_context.hpp"
#include "rive/artboard.hpp"
using namespace rive;
std::unique_ptr<StateInstance> AnimationState::makeInstance(ArtboardInstance* instance) const {
+ if (animation() == nullptr) {
+ // Failed to load at runtime/some new type we don't understand.
+ return std::make_unique<SystemStateInstance>(this, instance);
+ }
return std::make_unique<AnimationStateInstance>(this, instance);
-}
+}
\ No newline at end of file
using namespace rive;
-static LinearAnimation emptyAnimation;
-
AnimationStateInstance::AnimationStateInstance(const AnimationState* state,
ArtboardInstance* instance) :
StateInstance(state),
- // We're careful to always instance a valid animation here as the
- // StateMachine makes assumptions about AnimationState's producing valid
- // AnimationStateInstances with backing animations. This was discovered when
- // using Clang address sanitizer. We previously returned a
- // SystemStateInstance (basically a no-op StateMachine state) which would
- // 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_AnimationInstance(state->animation(), instance),
+ m_KeepGoing(true)
+{}
void AnimationStateInstance::advance(float seconds, Span<SMIInput*>) {
m_KeepGoing = m_AnimationInstance.advance(seconds);
}
-void AnimationStateInstance::apply(float mix) { m_AnimationInstance.apply(mix); }
+void AnimationStateInstance::apply(float mix) {
+ m_AnimationInstance.apply(mix);
+}
bool AnimationStateInstance::keepGoing() const { return m_KeepGoing; }
\ No newline at end of file
using namespace rive;
-BlendState1DInstance::BlendState1DInstance(const BlendState1D* blendState,
- ArtboardInstance* instance) :
+BlendState1DInstance::BlendState1DInstance(const BlendState1D* blendState, ArtboardInstance* instance) :
BlendStateInstance<BlendState1D, BlendAnimation1D>(blendState, instance) {}
int BlendState1DInstance::animationIndex(float value) {
using namespace rive;
-BlendStateDirectInstance::BlendStateDirectInstance(const BlendStateDirect* blendState,
- ArtboardInstance* instance) :
+BlendStateDirectInstance::BlendStateDirectInstance(const BlendStateDirect* blendState, ArtboardInstance* instance) :
BlendStateInstance<BlendStateDirect, BlendAnimationDirect>(blendState, instance) {}
void BlendStateDirectInstance::advance(float seconds, Span<SMIInput*> inputs) {
--- /dev/null
+#include "rive/animation/event_bool_change.hpp"
+#include "rive/animation/state_machine_instance.hpp"
+#include "rive/animation/state_machine_bool.hpp"
+#include "rive/animation/state_machine_input_instance.hpp"
+using namespace rive;
+
+bool EventBoolChange::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 EventBoolChange::perform(StateMachineInstance* stateMachineInstance) const {
+ auto inputInstance = stateMachineInstance->input(inputId());
+ 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;
+ }
+}
\ No newline at end of file
--- /dev/null
+#include "rive/animation/state_machine_event.hpp"
+#include "rive/importers/import_stack.hpp"
+#include "rive/importers/state_machine_event_importer.hpp"
+#include "rive/importers/state_machine_importer.hpp"
+#include "rive/animation/event_input_change.hpp"
+#include "rive/animation/state_machine.hpp"
+
+using namespace rive;
+
+StatusCode EventInputChange::import(ImportStack& importStack) {
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
+ if (stateMachineImporter == nullptr) {
+ return StatusCode::MissingObject;
+ }
+
+ auto stateMachineEventImporter =
+ importStack.latest<StateMachineEventImporter>(StateMachineEventBase::typeKey);
+ if (stateMachineEventImporter == nullptr) {
+ return StatusCode::MissingObject;
+ }
+
+ if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) {
+ return StatusCode::InvalidObject;
+ }
+ stateMachineEventImporter->addInputChange(this);
+ return Super::import(importStack);
+}
--- /dev/null
+#include "rive/animation/event_number_change.hpp"
+#include "rive/animation/state_machine_instance.hpp"
+#include "rive/animation/state_machine_number.hpp"
+#include "rive/animation/state_machine_input_instance.hpp"
+
+using namespace rive;
+
+bool EventNumberChange::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 EventNumberChange::perform(StateMachineInstance* stateMachineInstance) const {
+ auto inputInstance = stateMachineInstance->input(inputId());
+ if (inputInstance == nullptr) {
+ return;
+ }
+ // If it's not null, it must be our correct type (why we validate at load time).
+ auto numberInput = reinterpret_cast<SMINumber*>(inputInstance);
+ numberInput->value(value());
+}
--- /dev/null
+#include "rive/animation/event_trigger_change.hpp"
+#include "rive/animation/state_machine_instance.hpp"
+#include "rive/animation/state_machine_trigger.hpp"
+#include "rive/animation/state_machine_input_instance.hpp"
+
+using namespace rive;
+
+bool EventTriggerChange::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>();
+}
+
+void EventTriggerChange::perform(StateMachineInstance* stateMachineInstance) const {
+ auto inputInstance = stateMachineInstance->input(inputId());
+ if (inputInstance == nullptr) {
+ return;
+ }
+ // If it's not null, it must be our correct type (why we validate at load time).
+ auto triggerInput = reinterpret_cast<SMITrigger*>(inputInstance);
+ triggerInput->fire();
+}
\ No newline at end of file
CoreRegistry::setBool(object, propertyKey, value());
}
-void KeyFrameBool::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameBool::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
CoreRegistry::setBool(object, propertyKey, value());
}
\ No newline at end of file
applyColor(object, propertyKey, mix, value());
}
-void KeyFrameColor::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameColor::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
auto kfc = nextFrame->as<KeyFrameColor>();
const KeyFrameColor& nextColor = *kfc;
float f = (currentTime - seconds()) / (nextColor.seconds() - seconds());
CoreRegistry::setDouble(object, propertyKey, value);
} else {
float mixi = 1.0f - mix;
- CoreRegistry::setDouble(object,
- propertyKey,
- CoreRegistry::getDouble(object, propertyKey) * mixi + value * mix);
+ CoreRegistry::setDouble(
+ object, propertyKey, CoreRegistry::getDouble(object, propertyKey) * mixi + value * mix);
}
}
applyDouble(object, propertyKey, mix, value());
}
-void KeyFrameDouble::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameDouble::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
auto kfd = nextFrame->as<KeyFrameDouble>();
const KeyFrameDouble& nextDouble = *kfd;
float f = (currentTime - seconds()) / (nextDouble.seconds() - seconds());
CoreRegistry::setUint(object, propertyKey, value());
}
-void KeyFrameId::applyInterpolation(Core* object,
- int propertyKey,
- float currentTime,
- const KeyFrame* nextFrame,
- float mix) {
+void KeyFrameId::applyInterpolation(
+ Core* object, int propertyKey, float currentTime, const KeyFrame* nextFrame, float mix) {
CoreRegistry::setUint(object, propertyKey, value());
}
\ No newline at end of file
float LinearAnimation::globalToLocalSeconds(float seconds) const {
switch (loop()) {
- case Loop::oneShot: return seconds + startSeconds();
+ case Loop::oneShot:
+ return seconds + startSeconds();
case Loop::loop:
return std::fmod(seconds, (endSeconds() - startSeconds())) + startSeconds();
case Loop::pingPong:
int direction = ((int)(seconds / (endSeconds() - startSeconds()))) % 2;
return direction == 0 ? localTime + startSeconds() : endSeconds() - localTime;
}
- RIVE_UNREACHABLE;
}
\ No newline at end of file
#include "rive/animation/linear_animation_instance.hpp"
#include "rive/animation/linear_animation.hpp"
#include "rive/animation/loop.hpp"
-#include "rive/rive_counter.hpp"
#include <cmath>
using namespace rive;
m_TotalTime(0.0f),
m_LastTotalTime(0.0f),
m_SpilledTime(0.0f),
- m_Direction(1) {
- Counter::update(Counter::kLinearAnimationInstance, +1);
-}
-
-LinearAnimationInstance::LinearAnimationInstance(LinearAnimationInstance const& lhs) :
- Scene(lhs),
- m_Animation(lhs.m_Animation),
- m_Time(lhs.m_Time),
- m_TotalTime(lhs.m_TotalTime),
- m_LastTotalTime(lhs.m_LastTotalTime),
- m_SpilledTime(lhs.m_SpilledTime),
- m_Direction(lhs.m_Direction),
- m_DidLoop(lhs.m_DidLoop),
- m_LoopValue(lhs.m_LoopValue) {
- Counter::update(Counter::kLinearAnimationInstance, +1);
-}
-
-LinearAnimationInstance::~LinearAnimationInstance() {
- Counter::update(Counter::kLinearAnimationInstance, -1);
-}
+ m_Direction(1) {}
bool LinearAnimationInstance::advanceAndApply(float seconds) {
bool more = this->advance(seconds);
if (m_Direction == 1 && frames > end) {
keepGoing = false;
m_SpilledTime = (frames - end) / fps;
- frames = (float)end;
+ frames = end;
m_Time = frames / fps;
didLoop = true;
} else if (m_Direction == -1 && frames < start) {
keepGoing = false;
m_SpilledTime = (start - frames) / fps;
- frames = (float)start;
+ frames = start;
m_Time = frames / fps;
didLoop = true;
}
float LinearAnimationInstance::startSeconds() const { return m_Animation->startSeconds(); }
-std::string LinearAnimationInstance::name() const { return m_Animation->name(); }
+std::string LinearAnimationInstance::name() const {
+ return m_Animation->name();
+}
bool LinearAnimationInstance::isTranslucent() const {
return m_ArtboardInstance->isTranslucent(this);
+++ /dev/null
-#include "rive/animation/state_machine_listener.hpp"
-#include "rive/importers/import_stack.hpp"
-#include "rive/importers/state_machine_listener_importer.hpp"
-#include "rive/importers/state_machine_importer.hpp"
-#include "rive/animation/listener_input_change.hpp"
-#include "rive/animation/state_machine.hpp"
-
-using namespace rive;
-
-StatusCode ListenerAction::import(ImportStack& importStack) {
- auto stateMachineListenerImporter =
- importStack.latest<StateMachineListenerImporter>(StateMachineListenerBase::typeKey);
- if (stateMachineListenerImporter == nullptr) {
- return StatusCode::MissingObject;
- }
-
- stateMachineListenerImporter->addAction(std::unique_ptr<ListenerAction>(this));
- return Super::import(importStack);
-}
+++ /dev/null
-#include "rive/animation/listener_align_target.hpp"
-#include "rive/animation/state_machine_instance.hpp"
-#include "rive/node.hpp"
-#include "rive/constraints/constraint.hpp"
-
-using namespace rive;
-
-void ListenerAlignTarget::perform(StateMachineInstance* stateMachineInstance,
- Vec2D position) const {
- auto coreTarget = stateMachineInstance->artboard()->resolve(targetId());
- if (coreTarget == nullptr || !coreTarget->is<Node>()) {
- return;
- }
- auto target = coreTarget->as<Node>();
- Mat2D targetParentWorld = getParentWorld(*target);
- Mat2D inverse;
- if (!targetParentWorld.invert(&inverse)) {
- return;
- }
-
- auto localPosition = inverse * position;
- target->x(localPosition.x);
- target->y(localPosition.y);
-}
+++ /dev/null
-#include "rive/animation/listener_bool_change.hpp"
-#include "rive/animation/state_machine_instance.hpp"
-#include "rive/animation/state_machine_bool.hpp"
-#include "rive/animation/state_machine_input_instance.hpp"
-using namespace rive;
-
-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 {
- auto inputInstance = stateMachineInstance->input(inputId());
- 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;
- }
-}
\ No newline at end of file
+++ /dev/null
-#include "rive/animation/state_machine_listener.hpp"
-#include "rive/importers/import_stack.hpp"
-#include "rive/importers/state_machine_listener_importer.hpp"
-#include "rive/importers/state_machine_importer.hpp"
-#include "rive/animation/listener_input_change.hpp"
-#include "rive/animation/state_machine.hpp"
-
-using namespace rive;
-
-StatusCode ListenerInputChange::import(ImportStack& importStack) {
- auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachine::typeKey);
- if (stateMachineImporter == nullptr) {
- return StatusCode::MissingObject;
- }
-
- if (!validateInputType(stateMachineImporter->stateMachine()->input((size_t)inputId()))) {
- return StatusCode::InvalidObject;
- }
- return Super::import(importStack);
-}
+++ /dev/null
-#include "rive/animation/listener_number_change.hpp"
-#include "rive/animation/state_machine_instance.hpp"
-#include "rive/animation/state_machine_number.hpp"
-#include "rive/animation/state_machine_input_instance.hpp"
-
-using namespace rive;
-
-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 {
- auto inputInstance = stateMachineInstance->input(inputId());
- if (inputInstance == nullptr) {
- return;
- }
- // If it's not null, it must be our correct type (why we validate at load time).
- auto numberInput = reinterpret_cast<SMINumber*>(inputInstance);
- numberInput->value(value());
-}
+++ /dev/null
-#include "rive/animation/listener_trigger_change.hpp"
-#include "rive/animation/state_machine_instance.hpp"
-#include "rive/animation/state_machine_trigger.hpp"
-#include "rive/animation/state_machine_input_instance.hpp"
-
-using namespace rive;
-
-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.
- return input == nullptr || input->is<StateMachineTrigger>();
-}
-
-void ListenerTriggerChange::perform(StateMachineInstance* stateMachineInstance,
- Vec2D position) const {
- auto inputInstance = stateMachineInstance->input(inputId());
- if (inputInstance == nullptr) {
- return;
- }
- // If it's not null, it must be our correct type (why we validate at load time).
- auto triggerInput = reinterpret_cast<SMITrigger*>(inputInstance);
- triggerInput->fire();
-}
\ No newline at end of file
NestedLinearAnimation::~NestedLinearAnimation() {}
void NestedLinearAnimation::initializeAnimation(ArtboardInstance* artboard) {
- m_AnimationInstance =
- std::make_unique<LinearAnimationInstance>(artboard->animation(animationId()), artboard);
+ m_AnimationInstance = std::make_unique<LinearAnimationInstance>(artboard->animation(animationId()),
+ artboard);
}
\ No newline at end of file
#include "rive/animation/nested_state_machine.hpp"
-#include "rive/animation/state_machine_instance.hpp"
using namespace rive;
-NestedStateMachine::NestedStateMachine() {}
-NestedStateMachine::~NestedStateMachine() {}
+void NestedStateMachine::advance(float elapsedSeconds) {}
-void NestedStateMachine::advance(float elapsedSeconds) {
- if (m_StateMachineInstance != nullptr) {
- m_StateMachineInstance->advance(elapsedSeconds);
- }
-}
-
-void NestedStateMachine::initializeAnimation(ArtboardInstance* artboard) {
- m_StateMachineInstance = artboard->stateMachineAt(animationId());
-}
-
-StateMachineInstance* NestedStateMachine::stateMachineInstance() {
- return m_StateMachineInstance.get();
-}
-
-void NestedStateMachine::pointerMove(Vec2D position) {
- if (m_StateMachineInstance != nullptr) {
- m_StateMachineInstance->pointerMove(position);
- }
-}
-
-void NestedStateMachine::pointerDown(Vec2D position) {
- if (m_StateMachineInstance != nullptr) {
- m_StateMachineInstance->pointerDown(position);
- }
-}
-
-void NestedStateMachine::pointerUp(Vec2D position) {
- if (m_StateMachineInstance != nullptr) {
- m_StateMachineInstance->pointerUp(position);
- }
-}
\ No newline at end of file
+void NestedStateMachine::initializeAnimation(ArtboardInstance*) {}
\ No newline at end of file
#include "rive/importers/artboard_importer.hpp"
#include "rive/animation/state_machine_layer.hpp"
#include "rive/animation/state_machine_input.hpp"
-#include "rive/animation/state_machine_listener.hpp"
+#include "rive/animation/state_machine_event.hpp"
using namespace rive;
return code;
}
}
- for (auto& object : m_Listeners) {
+ for (auto& object : m_Events) {
if ((code = object->onAddedDirty(context)) != StatusCode::Ok) {
return code;
}
return code;
}
}
- for (auto& object : m_Listeners) {
+ for (auto& object : m_Events) {
if ((code = object->onAddedClean(context)) != StatusCode::Ok) {
return code;
}
m_Inputs.push_back(std::move(input));
}
-void StateMachine::addListener(std::unique_ptr<StateMachineListener> listener) {
- m_Listeners.push_back(std::move(listener));
+void StateMachine::addEvent(std::unique_ptr<StateMachineEvent> event) {
+ m_Events.push_back(std::move(event));
}
const StateMachineInput* StateMachine::input(std::string name) const {
return nullptr;
}
-const StateMachineListener* StateMachine::listener(size_t index) const {
- if (index < m_Listeners.size()) {
- return m_Listeners[index].get();
+const StateMachineEvent* StateMachine::event(size_t index) const {
+ if (index < m_Events.size()) {
+ return m_Events[index].get();
}
return nullptr;
}
\ No newline at end of file
--- /dev/null
+#include "rive/animation/state_machine_event.hpp"
+#include "rive/importers/import_stack.hpp"
+#include "rive/importers/state_machine_importer.hpp"
+#include "rive/generated/animation/state_machine_base.hpp"
+#include "rive/artboard.hpp"
+#include "rive/shapes/shape.hpp"
+#include "rive/animation/state_machine_instance.hpp"
+#include "rive/animation/event_input_change.hpp"
+
+using namespace rive;
+
+void StateMachineEvent::addInputChange(EventInputChange* inputChange) {
+ m_InputChanges.push_back(inputChange);
+}
+
+StatusCode StateMachineEvent::import(ImportStack& importStack) {
+ auto stateMachineImporter = importStack.latest<StateMachineImporter>(StateMachineBase::typeKey);
+ if (stateMachineImporter == nullptr) {
+ return StatusCode::MissingObject;
+ }
+ // Handing off ownership of this!
+ stateMachineImporter->addEvent(std::unique_ptr<StateMachineEvent>(this));
+ return Super::import(importStack);
+}
+
+const EventInputChange* StateMachineEvent::inputChange(size_t index) const {
+ if (index < m_InputChanges.size()) {
+ return m_InputChanges[index];
+ }
+ return nullptr;
+}
+
+StatusCode StateMachineEvent::onAddedClean(CoreContext* context) {
+ auto artboard = static_cast<Artboard*>(context);
+ auto target = artboard->resolve(targetId());
+
+ for (auto core : artboard->objects()) {
+ if (core == nullptr) {
+ continue;
+ }
+
+ // Iterate artboard to find Shapes that are parented to the target
+ if (core->is<Shape>()) {
+ auto shape = core->as<Shape>();
+
+ for (ContainerComponent* component = shape; component != nullptr;
+ component = component->parent()) {
+ if (component == target) {
+ auto index = artboard->idOf(shape);
+ if (index != 0) {
+ m_HitShapesIds.push_back(index);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return Super::onAddedClean(context);
+}
+
+void StateMachineEvent::performChanges(StateMachineInstance* stateMachineInstance) const {
+ for (auto inputChange : m_InputChanges) {
+ inputChange->perform(stateMachineInstance);
+ }
+}
\ No newline at end of file
#include "rive/animation/animation_state.hpp"
#include "rive/animation/state_instance.hpp"
#include "rive/animation/animation_state_instance.hpp"
-#include "rive/animation/state_machine_listener.hpp"
+#include "rive/animation/state_machine_event.hpp"
#include "rive/shapes/shape.hpp"
#include "rive/math/aabb.hpp"
#include "rive/math/hit_test.hpp"
-#include "rive/nested_artboard.hpp"
-#include "rive/nested_animation.hpp"
-#include "rive/animation/nested_state_machine.hpp"
-#include "rive/rive_counter.hpp"
#include <unordered_map>
using namespace rive;
namespace rive {
-class StateMachineLayerInstance {
-private:
- static const int maxIterations = 100;
- const StateMachineLayer* m_Layer = nullptr;
- ArtboardInstance* m_ArtboardInstance = nullptr;
-
- StateInstance* m_AnyStateInstance = nullptr;
- StateInstance* m_CurrentState = nullptr;
- StateInstance* m_StateFrom = nullptr;
-
- // const LayerState* m_CurrentState = nullptr;
- // const LayerState* m_StateFrom = nullptr;
- const StateTransition* m_Transition = nullptr;
-
- bool m_HoldAnimationFrom = false;
- // LinearAnimationInstance* m_AnimationInstance = nullptr;
- // LinearAnimationInstance* m_AnimationInstanceFrom = nullptr;
- float m_Mix = 1.0f;
- float m_MixFrom = 1.0f;
- bool m_StateChangedOnAdvance = false;
-
- bool m_WaitingForExit = false;
- /// Used to ensure a specific animation is applied on the next apply.
- const LinearAnimation* m_HoldAnimation = nullptr;
- float m_HoldTime = 0.0f;
-
-public:
- ~StateMachineLayerInstance() {
- delete m_AnyStateInstance;
- delete m_CurrentState;
- delete m_StateFrom;
- }
-
- void init(const StateMachineLayer* layer, ArtboardInstance* instance) {
- m_ArtboardInstance = instance;
- assert(m_Layer == nullptr);
- m_AnyStateInstance = layer->anyState()->makeInstance(instance).release();
- m_Layer = layer;
- changeState(m_Layer->entryState());
- }
-
- 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 {
- m_Mix = 1.0f;
+ class StateMachineLayerInstance {
+ private:
+ static const int maxIterations = 100;
+ const StateMachineLayer* m_Layer = nullptr;
+ ArtboardInstance* m_ArtboardInstance = nullptr;
+
+ StateInstance* m_AnyStateInstance = nullptr;
+ StateInstance* m_CurrentState = nullptr;
+ StateInstance* m_StateFrom = nullptr;
+
+ // const LayerState* m_CurrentState = nullptr;
+ // const LayerState* m_StateFrom = nullptr;
+ const StateTransition* m_Transition = nullptr;
+
+ bool m_HoldAnimationFrom = false;
+ // LinearAnimationInstance* m_AnimationInstance = nullptr;
+ // LinearAnimationInstance* m_AnimationInstanceFrom = nullptr;
+ float m_Mix = 1.0f;
+ float m_MixFrom = 1.0f;
+ bool m_StateChangedOnAdvance = false;
+
+ bool m_WaitingForExit = false;
+ /// Used to ensure a specific animation is applied on the next apply.
+ const LinearAnimation* m_HoldAnimation = nullptr;
+ float m_HoldTime = 0.0f;
+
+ public:
+ ~StateMachineLayerInstance() {
+ delete m_AnyStateInstance;
+ delete m_CurrentState;
+ delete m_StateFrom;
}
- }
- bool advance(/*Artboard* artboard, */ float seconds, Span<SMIInput*> inputs) {
- m_StateChangedOnAdvance = false;
+ void init(const StateMachineLayer* layer, ArtboardInstance* instance) {
+ m_ArtboardInstance = instance;
+ assert(m_Layer == nullptr);
+ m_AnyStateInstance = layer->anyState()->makeInstance(instance).release();
+ m_Layer = layer;
+ changeState(m_Layer->entryState());
+ }
- if (m_CurrentState != nullptr) {
- m_CurrentState->advance(seconds, inputs);
+ 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 {
+ m_Mix = 1.0f;
+ }
}
- updateMix(seconds);
+ bool advance(/*Artboard* artboard, */ float seconds, Span<SMIInput*> inputs) {
+ m_StateChangedOnAdvance = false;
- 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);
- }
+ if (m_CurrentState != nullptr) {
+ m_CurrentState->advance(seconds, inputs);
+ }
- for (int i = 0; updateState(inputs, i != 0); i++) {
- apply();
+ updateMix(seconds);
- if (i == maxIterations) {
- fprintf(stderr, "StateMachine exceeded max iterations.\n");
- return false;
+ 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);
}
- }
- apply();
+ for (int i = 0; updateState(inputs, i != 0); i++) {
+ apply();
- return m_Mix != 1.0f || m_WaitingForExit ||
- (m_CurrentState != nullptr && m_CurrentState->keepGoing());
- }
+ if (i == maxIterations) {
+ fprintf(stderr, "StateMachine exceeded max iterations.\n");
+ return false;
+ }
+ }
- bool isTransitioning() {
- return m_Transition != nullptr && m_StateFrom != nullptr && m_Transition->duration() != 0 &&
- m_Mix < 1.0f;
- }
+ apply();
- 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()) {
- return false;
+ return m_Mix != 1.0f || m_WaitingForExit ||
+ (m_CurrentState != nullptr && m_CurrentState->keepGoing());
}
- m_WaitingForExit = false;
-
- if (tryChangeState(m_AnyStateInstance, inputs, ignoreTriggers)) {
- return true;
+ bool isTransitioning() {
+ return m_Transition != nullptr && m_StateFrom != nullptr &&
+ m_Transition->duration() != 0 && m_Mix < 1.0f;
}
- return tryChangeState(m_CurrentState, inputs, 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()) {
+ return false;
+ }
- bool changeState(const LayerState* stateTo) {
- if ((m_CurrentState == nullptr ? nullptr : m_CurrentState->state()) == stateTo) {
- return false;
+ m_WaitingForExit = false;
+
+ if (tryChangeState(m_AnyStateInstance, inputs, ignoreTriggers)) {
+ return true;
+ }
+
+ return tryChangeState(m_CurrentState, inputs, ignoreTriggers);
}
- m_CurrentState =
- stateTo == nullptr ? nullptr : stateTo->makeInstance(m_ArtboardInstance).release();
- return true;
- }
- bool tryChangeState(StateInstance* stateFromInstance,
- Span<SMIInput*> inputs,
- bool ignoreTriggers) {
- if (stateFromInstance == nullptr) {
- return false;
+ bool changeState(const LayerState* stateTo) {
+ if ((m_CurrentState == nullptr ? nullptr : m_CurrentState->state()) == stateTo) {
+ return false;
+ }
+ m_CurrentState =
+ stateTo == nullptr ? nullptr : stateTo->makeInstance(m_ArtboardInstance).release();
+ return true;
}
- auto stateFrom = stateFromInstance->state();
- auto outState = m_CurrentState;
- 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())) {
- m_StateChangedOnAdvance = true;
- // state actually has changed
- m_Transition = transition;
- if (m_StateFrom != m_AnyStateInstance) {
- // Old state from is done.
- delete m_StateFrom;
- }
- m_StateFrom = outState;
-
- // 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)) {
- // Make sure we apply this state. This only returns true
- // when it's an animation state instance.
- auto instance =
- static_cast<AnimationStateInstance*>(m_StateFrom)->animationInstance();
-
- m_HoldAnimation = instance->animation();
- m_HoldTime = instance->time();
- }
- m_MixFrom = m_Mix;
- // Keep mixing last animation that was mixed in.
- if (m_Mix != 0.0f) {
- m_HoldAnimationFrom = transition->pauseOnExit();
- }
- if (m_StateFrom != nullptr && m_StateFrom->state()->is<AnimationState>() &&
- m_CurrentState != nullptr)
- {
- auto instance =
- static_cast<AnimationStateInstance*>(m_StateFrom)->animationInstance();
-
- auto spilledTime = instance->spilledTime();
- m_CurrentState->advance(spilledTime, inputs);
+ bool tryChangeState(StateInstance* stateFromInstance,
+ Span<SMIInput*> inputs,
+ bool ignoreTriggers) {
+ if (stateFromInstance == nullptr) {
+ return false;
+ }
+ auto stateFrom = stateFromInstance->state();
+ auto outState = m_CurrentState;
+ for (size_t i = 0, length = stateFrom->transitionCount(); i < length; i++) {
+ auto transition = stateFrom->transition(i);
+ auto allowed = transition->allowed(stateFromInstance, inputs, ignoreTriggers);
+ if (allowed == AllowTransition::yes && changeState(transition->stateTo())) {
+ m_StateChangedOnAdvance = true;
+ // state actually has changed
+ m_Transition = transition;
+ if (m_StateFrom != m_AnyStateInstance) {
+ // Old state from is done.
+ delete m_StateFrom;
+ }
+ m_StateFrom = outState;
+
+ // 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)) {
+ // Make sure we apply this state. This only returns true
+ // when it's an animation state instance.
+ auto instance =
+ static_cast<AnimationStateInstance*>(m_StateFrom)->animationInstance();
+
+ m_HoldAnimation = instance->animation();
+ m_HoldTime = instance->time();
+ }
+ m_MixFrom = m_Mix;
+
+ // Keep mixing last animation that was mixed in.
+ if (m_Mix != 0.0f) {
+ m_HoldAnimationFrom = transition->pauseOnExit();
+ }
+ if (m_StateFrom != nullptr && m_StateFrom->state()->is<AnimationState>() &&
+ m_CurrentState != nullptr)
+ {
+ auto instance =
+ static_cast<AnimationStateInstance*>(m_StateFrom)->animationInstance();
+
+ auto spilledTime = instance->spilledTime();
+ m_CurrentState->advance(spilledTime, inputs);
+ }
+ m_Mix = 0.0f;
+ updateMix(0.0f);
+ m_WaitingForExit = false;
+ return true;
+ } else if (allowed == AllowTransition::waitingForExit) {
+ m_WaitingForExit = true;
}
- m_Mix = 0.0f;
- updateMix(0.0f);
- m_WaitingForExit = false;
- return true;
- } else if (allowed == AllowTransition::waitingForExit) {
- m_WaitingForExit = true;
}
+ return false;
}
- return false;
- }
- void apply(/*Artboard* artboard*/) {
- if (m_HoldAnimation != nullptr) {
- m_HoldAnimation->apply(m_ArtboardInstance, m_HoldTime, m_MixFrom);
- 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) {
- m_StateFrom->apply(m_MixFrom);
- }
- if (m_CurrentState != nullptr) {
- m_CurrentState->apply(m_Mix);
+ if (m_StateFrom != nullptr && m_Mix < 1.0f) {
+ m_StateFrom->apply(m_MixFrom);
+ }
+ if (m_CurrentState != nullptr) {
+ m_CurrentState->apply(m_Mix);
+ }
}
- }
- bool stateChangedOnAdvance() const { return m_StateChangedOnAdvance; }
+ bool stateChangedOnAdvance() const { return m_StateChangedOnAdvance; }
- const LayerState* currentState() {
- return m_CurrentState == nullptr ? nullptr : m_CurrentState->state();
- }
+ const LayerState* currentState() {
+ return m_CurrentState == nullptr ? nullptr : m_CurrentState->state();
+ }
- const LinearAnimationInstance* currentAnimation() const {
- if (m_CurrentState == nullptr || !m_CurrentState->state()->is<AnimationState>()) {
- return nullptr;
+ const LinearAnimationInstance* currentAnimation() const {
+ if (m_CurrentState == nullptr || !m_CurrentState->state()->is<AnimationState>()) {
+ return nullptr;
+ }
+ return static_cast<AnimationStateInstance*>(m_CurrentState)->animationInstance();
}
- return static_cast<AnimationStateInstance*>(m_CurrentState)->animationInstance();
- }
-};
-
-/// 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 {
-private:
- Shape* m_Shape;
-
-public:
- Shape* shape() const { return m_Shape; }
- HitShape(Shape* shape) : m_Shape(shape) {}
- bool isHovered = false;
- std::vector<const StateMachineListener*> listeners;
-};
+ };
+
+ /// Representation of a Shape from the Artboard Instance and all the events it
+ /// triggers. Allows tracking hover and performing hit detection only once on
+ /// shapes that trigger multiple events.
+ class HitShape {
+ private:
+ Shape* m_Shape;
+
+ public:
+ Shape* shape() const { return m_Shape; }
+ HitShape(Shape* shape) : m_Shape(shape) {}
+ bool isHovered = false;
+ std::vector<const StateMachineEvent*> events;
+ };
} // namespace rive
-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());
- }
+void StateMachineInstance::processEvent(Vec2D position, EventType hitEvent) {
+ position -= Vec2D(m_ArtboardInstance->originX() * m_ArtboardInstance->width(),
+ m_ArtboardInstance->originY() * m_ArtboardInstance->height());
const float hitRadius = 2;
auto hitArea = AABB(position.x - hitRadius,
bool hoverChange = hitShape->isHovered != isOver;
hitShape->isHovered = isOver;
- // iterate all listeners associated with this hit shape
- for (auto listener : hitShape->listeners) {
- // Always update hover states regardless of which specific listener type
+ // iterate all events associated with this hit shape
+ for (auto event : hitShape->events) {
+ // Always update hover states regardless of which specific event type
// we're trying to trigger.
if (hoverChange) {
- if (isOver && listener->listenerType() == ListenerType::enter) {
- listener->performChanges(this, position);
+ if (isOver && event->eventType() == EventType::enter) {
+ event->performChanges(this);
markNeedsAdvance();
- } else if (!isOver && listener->listenerType() == ListenerType::exit) {
- listener->performChanges(this, position);
+ } else if (!isOver && event->eventType() == EventType::exit) {
+ event->performChanges(this);
markNeedsAdvance();
}
}
- if (isOver && hitType == listener->listenerType()) {
- listener->performChanges(this, position);
+ if (isOver && hitEvent == event->eventType()) {
+ event->performChanges(this);
markNeedsAdvance();
}
}
}
-
- // TODO: store a hittable abstraction for HitShape and NestedArtboard that
- // 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) {
- Vec2D 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>()) {
- 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;
- case ListenerType::enter:
- case ListenerType::exit: break;
- }
- }
- }
- }
}
void StateMachineInstance::pointerMove(Vec2D position) {
- updateListeners(position, ListenerType::move);
-}
-void StateMachineInstance::pointerDown(Vec2D position) {
- updateListeners(position, ListenerType::down);
-}
-void StateMachineInstance::pointerUp(Vec2D position) {
- updateListeners(position, ListenerType::up);
+ processEvent(position, EventType::updateHover);
}
+void StateMachineInstance::pointerDown(Vec2D position) { processEvent(position, EventType::down); }
+void StateMachineInstance::pointerUp(Vec2D position) { processEvent(position, EventType::up); }
StateMachineInstance::StateMachineInstance(const StateMachine* machine,
ArtboardInstance* instance) :
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++) {
m_Layers[i].init(machine->layer(i), m_ArtboardInstance);
}
- // Initialize listeners. Store a lookup table of shape id to hit shape
- // representation (an object that stores all the listeners triggered by the
- // shape producing a listener).
+ // Initialize events. Store a lookup table of shape id to hit shape
+ // representation (an object that stores all the events triggered by the
+ // shape producing an event).
std::unordered_map<uint32_t, HitShape*> hitShapeLookup;
- for (std::size_t i = 0; i < machine->listenerCount(); i++) {
- auto listener = machine->listener(i);
+ for (std::size_t i = 0; i < machine->eventCount(); i++) {
+ auto event = machine->event(i);
- // Iterate actual leaf hittable shapes tied to this listener and resolve
+ // Iterate actual leaf hittable shapes tied to this event and resolve
// corresponding ones in the artboard instance.
- for (auto id : listener->hitShapeIds()) {
+ for (auto id : event->hitShapeIds()) {
HitShape* hitShape;
auto itr = hitShapeLookup.find(id);
if (itr == hitShapeLookup.end()) {
} else {
hitShape = itr->second;
}
- hitShape->listeners.push_back(listener);
- }
- }
-
- for (auto nestedArtboard : instance->nestedArtboards()) {
- if (nestedArtboard->hasNestedStateMachines()) {
- m_HitNestedArtboards.push_back(nestedArtboard);
+ hitShape->events.push_back(event);
}
}
}
delete inst;
}
delete[] m_Layers;
-
- Counter::update(Counter::kStateMachineInstance, -1);
}
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)) {
+ if (m_Layers[i].advance(seconds, toSpan(m_InputInstances))) {
m_NeedsAdvance = true;
}
}
return nullptr;
}
-size_t StateMachineInstance::currentAnimationCount() const {
+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) {
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;
+ 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) {
: nullptr;
}
-AllowTransition StateTransition::allowed(StateInstance* stateFrom,
- Span<SMIInput*> inputs,
- bool ignoreTriggers) const {
+AllowTransition
+StateTransition::allowed(StateInstance* stateFrom, Span<SMIInput*> inputs, bool ignoreTriggers) const {
if (isDisabled()) {
return AllowTransition::no;
}
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();
+ 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
#include "rive/draw_target_placement.hpp"
#include "rive/drawable.hpp"
#include "rive/animation/keyed_object.hpp"
-#include "rive/factory.hpp"
#include "rive/node.hpp"
#include "rive/renderer.hpp"
#include "rive/shapes/paint/shape_paint.hpp"
StatusCode Artboard::initialize() {
StatusCode code;
- // these will be re-built in update() -- are they needed here?
- m_BackgroundPath = factory()->makeEmptyRenderPath();
- m_ClipPath = factory()->makeEmptyRenderPath();
+ m_BackgroundPath = makeCommandPath(PathSpace::Neither);
+ m_ClipPath = makeCommandPath(PathSpace::Neither);
// 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
// Animations and StateMachines initialize only once on the source/origin
// Artboard. Instances will hold references to the original Animations and StateMachines, so
// 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
+ // unpredictable behaviour. One such example was that resolved objects like event inputs were
// being added to lists twice.
if (!isInstance()) {
for (auto object : m_Animations) {
auto it = std::find(m_Objects.begin(), m_Objects.end(), object);
if (it != m_Objects.end()) {
- return castTo<uint32_t>(it - m_Objects.begin());
+ return it - m_Objects.begin();
} else {
return 0;
}
sortDrawOrder();
}
if (hasDirt(value, ComponentDirt::Path)) {
- AABB bg = {-width() * originX(), -height() * originY(), width(), height()};
- AABB clip;
+ m_ClipPath->reset();
if (m_FrameOrigin) {
- clip = {0.0f, 0.0f, width(), height()};
+ m_ClipPath->addRect(0.0f, 0.0f, width(), height());
} else {
- clip = bg;
+ m_ClipPath->addRect(-width() * originX(), -height() * originY(), width(), height());
}
- m_ClipPath = factory()->makeRenderPath(clip);
- m_BackgroundPath = factory()->makeRenderPath(bg);
+ m_BackgroundPath->addRect(-width() * originX(), -height() * originY(), width(), height());
}
}
void Artboard::draw(Renderer* renderer, DrawOption option) {
renderer->save();
if (clip()) {
- renderer->clipPath(m_ClipPath.get());
+ renderer->clipPath(m_ClipPath->renderPath());
}
if (m_FrameOrigin) {
if (option != DrawOption::kHideBG) {
for (auto shapePaint : m_ShapePaints) {
- shapePaint->draw(renderer, m_BackgroundPath.get());
+ shapePaint->draw(renderer, backgroundPath());
}
}
////////// ArtboardInstance
-#include "rive/rive_counter.hpp"
#include "rive/animation/linear_animation_instance.hpp"
#include "rive/animation/state_machine_instance.hpp"
-ArtboardInstance::ArtboardInstance() { Counter::update(Counter::kArtboardInstance, +1); }
-
-ArtboardInstance::~ArtboardInstance() { Counter::update(Counter::kArtboardInstance, -1); }
-
std::unique_ptr<LinearAnimationInstance> ArtboardInstance::animationAt(size_t index) {
auto la = this->animation(index);
return la ? std::make_unique<LinearAnimationInstance>(la, this) : nullptr;
scene = this->animationAt(0);
}
return scene;
-}
+}
\ No newline at end of file
if (fileAssetImporter == nullptr) {
return StatusCode::MissingObject;
}
- fileAssetImporter->loadContents(std::unique_ptr<FileAssetContents>(this));
+ fileAssetImporter->loadContents(*this);
return Super::import(importStack);
}
assert(false);
}
-Span<const uint8_t> FileAssetContents::bytes() const { return m_Bytes; }
+Span<const uint8_t> FileAssetContents::bytes() const { return toSpan(m_Bytes); }
float Bone::y() const { return 0.0f; }
-Vec2D Bone::tipWorldTranslation() const { return worldTransform() * Vec2D(length(), 0); }
+Vec2D Bone::tipWorldTranslation() const {
+ return worldTransform() * Vec2D(length(), 0);
+}
void Bone::addPeerConstraint(Constraint* peer) {
assert(std::find(m_PeerConstraints.begin(), m_PeerConstraints.end(), peer) ==
Skinnable* Skinnable::from(Component* component) {
switch (component->coreType()) {
- case PointsPath::typeKey: return component->as<PointsPath>();
- case Mesh::typeKey: return component->as<Mesh>();
+ case PointsPath::typeKey:
+ return component->as<PointsPath>();
+ break;
+ case Mesh::typeKey:
+ return component->as<Mesh>();
+ break;
}
return nullptr;
}
}
Vec2D Weight::deform(Vec2D inPoint,
- unsigned int indices,
- unsigned int weights,
- const Mat2D& world,
- const float* boneTransforms) {
+ unsigned int indices,
+ unsigned int weights,
+ const Mat2D& world,
+ const float* boneTransforms) {
float xx = 0, xy = 0, yx = 0, yy = 0, tx = 0, ty = 0;
for (int i = 0; i < 4; i++) {
int weight = encodedWeightValue(i, weights);
const Vec2D targetTranslation = m_Target->worldTranslation();
const Vec2D ourTranslation = component->worldTranslation();
-
+
Vec2D toTarget = ourTranslation - targetTranslation;
float currentDistance = toTarget.length();
return;
}
break;
- case Mode::Exact: break;
+ default:
+ break;
}
if (currentDistance < 0.001f) {
return;
using namespace rive;
-static float atan2(Vec2D v) { return std::atan2(v.y, v.x); }
+static float atan2(Vec2D v) {
+ return std::atan2(v.y, v.x);
+}
void IKConstraint::buildDependencies() {
Super::buildDependencies();
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;
+ 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++) {
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 = m_FkChain.size() - 1; j < end; j++) {
BoneChainLink& fk = m_FkChain[j];
fk.parentWorldInverse = getParentWorld(*fk.bone).invertOrIdentity();
}
}
size_t BinaryReader::lengthInBytes() const { return m_Bytes.size(); }
-const uint8_t* BinaryReader::position() const { return m_Position; }
bool BinaryReader::didOverflow() const { return m_Overflowed; }
return std::string();
}
- std::vector<char> rawValue((size_t)length + 1);
+ std::vector<char> rawValue(length + 1);
auto readBytes = decode_string(length, m_Position, m_Bytes.end(), &rawValue[0]);
if (readBytes != length) {
overflow();
return std::string();
}
m_Position += readBytes;
- return std::string(rawValue.data(), (size_t)length);
+ return std::string(rawValue.data(), length);
}
Span<const uint8_t> BinaryReader::readBytes() {
}
RenderPath* renderPath = clippingShape->renderPath();
- // Can intentionally be null if all the clipping shapes are hidden.
- if (renderPath != nullptr) {
- renderer->clipPath(renderPath);
- }
+
+ assert(renderPath != nullptr);
+ renderer->clipPath(renderPath);
}
return true;
}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/factory.hpp"
-#include "rive/math/aabb.hpp"
-#include "rive/math/raw_path.hpp"
-
-using namespace rive;
-
-std::unique_ptr<RenderPath> Factory::makeRenderPath(const AABB& r) {
- const Vec2D pts[] = {
- {r.left(), r.top()},
- {r.right(), r.top()},
- {r.right(), r.bottom()},
- {r.left(), r.bottom()},
- };
- const PathVerb verbs[] = {
- PathVerb::move,
- PathVerb::line,
- PathVerb::line,
- PathVerb::line,
- PathVerb::close,
- };
- return this->makeRenderPath(pts, verbs, FillRule::nonZero);
-}
-
-std::unique_ptr<RenderPath> Factory::makeRenderPath(const RawPath& rp, FillRule fill) {
- return this->makeRenderPath(rp.points(), rp.verbs(), fill);
-}
#include "rive/file.hpp"
-#include "rive/rive_counter.hpp"
#include "rive/runtime_header.hpp"
#include "rive/animation/animation.hpp"
#include "rive/core/field_types/core_color_type.hpp"
#include "rive/importers/keyed_property_importer.hpp"
#include "rive/importers/linear_animation_importer.hpp"
#include "rive/importers/state_machine_importer.hpp"
-#include "rive/importers/state_machine_listener_importer.hpp"
+#include "rive/importers/state_machine_event_importer.hpp"
#include "rive/importers/state_machine_layer_importer.hpp"
#include "rive/importers/layer_state_importer.hpp"
#include "rive/importers/state_transition_importer.hpp"
#include "rive/animation/animation_state.hpp"
#include "rive/animation/blend_state_1d.hpp"
#include "rive/animation/blend_state_direct.hpp"
-#include "rive/assets/file_asset.hpp"
-#include "rive/assets/file_asset_contents.hpp"
// Default namespace for Rive Cpp code
using namespace rive;
}
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;
+ 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;
}
}
}
return object;
}
-File::File(Factory* factory, FileAssetResolver* assetResolver) :
- m_Factory(factory), m_AssetResolver(assetResolver) {
- Counter::update(Counter::kFile, +1);
-
+File::File(Factory* factory, FileAssetResolver* assetResolver)
+ : m_Factory(factory)
+ , m_AssetResolver(assetResolver)
+{
assert(factory);
}
-File::~File() { Counter::update(Counter::kFile, -1); }
+File::~File() {}
-std::unique_ptr<File> File::import(Span<const uint8_t> bytes,
- Factory* factory,
- ImportResult* result,
- FileAssetResolver* assetResolver) {
+std::unique_ptr<File>
+File::import(Span<const uint8_t> bytes, Factory* factory,
+ ImportResult* result, FileAssetResolver* assetResolver) {
BinaryReader reader(bytes);
RuntimeHeader header;
if (!RuntimeHeader::read(reader, header)) {
}
if (object->import(importStack) == StatusCode::Ok) {
switch (object->coreType()) {
- case Backboard::typeKey: m_Backboard.reset(object->as<Backboard>()); break;
+ 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: {
- auto fa = object->as<FileAsset>();
- m_FileAssets.push_back(std::unique_ptr<FileAsset>(fa));
- } break;
}
} else {
fprintf(stderr, "Failed to import object of type %d\n", object->coreType());
stackObject = new StateTransitionImporter(object->as<StateTransition>());
stackType = StateTransition::typeKey;
break;
- case StateMachineListener::typeKey:
- stackObject = new StateMachineListenerImporter(object->as<StateMachineListener>());
+ case StateMachineEvent::typeKey:
+ stackObject = new StateMachineEventImporter(object->as<StateMachineEvent>());
break;
case ImageAsset::typeKey:
- stackObject =
- new FileAssetImporter(object->as<FileAsset>(), m_AssetResolver, m_Factory);
+ stackObject = new FileAssetImporter(object->as<FileAsset>(), m_AssetResolver, m_Factory);
stackType = FileAsset::typeKey;
break;
}
}
}
- return !reader.hasError() && importStack.resolve() == StatusCode::Ok ? ImportResult::success
- : ImportResult::malformed;
+ return !reader.hasError() && importStack.resolve() == StatusCode::Ok
+ ? ImportResult::success : ImportResult::malformed;
}
Artboard* File::artboard(std::string name) const {
auto ab = this->artboard(name);
return ab ? ab->instance() : nullptr;
}
-
-#ifdef WITH_RIVE_TOOLS
-const std::vector<uint8_t> File::stripAssets(Span<const uint8_t> bytes,
- std::set<uint16_t> typeKeys,
- ImportResult* result) {
- std::vector<uint8_t> strippedData;
- strippedData.reserve(bytes.size());
- BinaryReader reader(bytes);
- RuntimeHeader header;
- if (!RuntimeHeader::read(reader, header)) {
- if (result) {
- *result = ImportResult::malformed;
- }
-
- } else if (header.majorVersion() != majorVersion) {
- if (result) {
- *result = ImportResult::unsupportedVersion;
- }
- } 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()) {
- auto object = readRuntimeObject(reader, header);
- if (object == nullptr) {
- continue;
- }
- if (object->is<FileAssetBase>()) {
- lastAssetType = object->coreType();
- }
- if (object->is<FileAssetContents>() && typeKeys.find(lastAssetType) != typeKeys.end()) {
- if (from != to) {
- strippedData.insert(strippedData.end(), from, to);
- }
- from = reader.position();
- }
- delete object;
- to = reader.position();
- }
- if (from != to) {
- strippedData.insert(strippedData.end(), from, to);
- }
- *result = ImportResult::success;
- }
- return strippedData;
-}
-#endif
\ No newline at end of file
--- /dev/null
+#include "rive/generated/animation/event_bool_change_base.hpp"
+#include "rive/animation/event_bool_change.hpp"
+
+using namespace rive;
+
+Core* EventBoolChangeBase::clone() const {
+ auto cloned = new EventBoolChange();
+ cloned->copy(*this);
+ return cloned;
+}
--- /dev/null
+#include "rive/generated/animation/event_number_change_base.hpp"
+#include "rive/animation/event_number_change.hpp"
+
+using namespace rive;
+
+Core* EventNumberChangeBase::clone() const {
+ auto cloned = new EventNumberChange();
+ cloned->copy(*this);
+ return cloned;
+}
--- /dev/null
+#include "rive/generated/animation/event_trigger_change_base.hpp"
+#include "rive/animation/event_trigger_change.hpp"
+
+using namespace rive;
+
+Core* EventTriggerChangeBase::clone() const {
+ auto cloned = new EventTriggerChange();
+ cloned->copy(*this);
+ return cloned;
+}
+++ /dev/null
-#include "rive/generated/animation/listener_align_target_base.hpp"
-#include "rive/animation/listener_align_target.hpp"
-
-using namespace rive;
-
-Core* ListenerAlignTargetBase::clone() const {
- auto cloned = new ListenerAlignTarget();
- cloned->copy(*this);
- return cloned;
-}
+++ /dev/null
-#include "rive/generated/animation/listener_bool_change_base.hpp"
-#include "rive/animation/listener_bool_change.hpp"
-
-using namespace rive;
-
-Core* ListenerBoolChangeBase::clone() const {
- auto cloned = new ListenerBoolChange();
- cloned->copy(*this);
- return cloned;
-}
+++ /dev/null
-#include "rive/generated/animation/listener_number_change_base.hpp"
-#include "rive/animation/listener_number_change.hpp"
-
-using namespace rive;
-
-Core* ListenerNumberChangeBase::clone() const {
- auto cloned = new ListenerNumberChange();
- cloned->copy(*this);
- return cloned;
-}
+++ /dev/null
-#include "rive/generated/animation/listener_trigger_change_base.hpp"
-#include "rive/animation/listener_trigger_change.hpp"
-
-using namespace rive;
-
-Core* ListenerTriggerChangeBase::clone() const {
- auto cloned = new ListenerTriggerChange();
- cloned->copy(*this);
- return cloned;
-}
+++ /dev/null
-#include "rive/generated/animation/nested_bool_base.hpp"
-#include "rive/animation/nested_bool.hpp"
-
-using namespace rive;
-
-Core* NestedBoolBase::clone() const {
- auto cloned = new NestedBool();
- cloned->copy(*this);
- return cloned;
-}
+++ /dev/null
-#include "rive/generated/animation/nested_number_base.hpp"
-#include "rive/animation/nested_number.hpp"
-
-using namespace rive;
-
-Core* NestedNumberBase::clone() const {
- auto cloned = new NestedNumber();
- cloned->copy(*this);
- return cloned;
-}
+++ /dev/null
-#include "rive/generated/animation/nested_trigger_base.hpp"
-#include "rive/animation/nested_trigger.hpp"
-
-using namespace rive;
-
-Core* NestedTriggerBase::clone() const {
- auto cloned = new NestedTrigger();
- cloned->copy(*this);
- return cloned;
-}
--- /dev/null
+#include "rive/generated/animation/state_machine_event_base.hpp"
+#include "rive/animation/state_machine_event.hpp"
+
+using namespace rive;
+
+Core* StateMachineEventBase::clone() const {
+ auto cloned = new StateMachineEvent();
+ cloned->copy(*this);
+ return cloned;
+}
+++ /dev/null
-#include "rive/generated/animation/state_machine_listener_base.hpp"
-#include "rive/animation/state_machine_listener.hpp"
-
-using namespace rive;
-
-Core* StateMachineListenerBase::clone() const {
- auto cloned = new StateMachineListener();
- cloned->copy(*this);
- return cloned;
-}
using namespace rive;
-FileAssetImporter::FileAssetImporter(FileAsset* fileAsset,
- FileAssetResolver* assetResolver,
- Factory* factory) :
- m_FileAsset(fileAsset), m_FileAssetResolver(assetResolver), m_Factory(factory) {}
+FileAssetImporter::FileAssetImporter(FileAsset* fileAsset, FileAssetResolver* assetResolver, Factory* factory) :
+ m_FileAsset(fileAsset),
+ m_FileAssetResolver(assetResolver),
+ m_Factory(factory)
+{}
-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();
+void FileAssetImporter::loadContents(const FileAssetContents& contents) {
+ auto data = contents.bytes();
if (m_FileAsset->decode(data, m_Factory)) {
m_LoadedContents = true;
}
--- /dev/null
+#include "rive/importers/state_machine_event_importer.hpp"
+#include "rive/animation/state_machine_event.hpp"
+
+using namespace rive;
+
+StateMachineEventImporter::StateMachineEventImporter(StateMachineEvent* event) :
+ m_StateMachineEvent(event) {}
+
+void StateMachineEventImporter::addInputChange(EventInputChange* change) {
+ m_StateMachineEvent->addInputChange(change);
+}
+
+StatusCode StateMachineEventImporter::resolve() { return StatusCode::Ok; }
\ No newline at end of file
#include "rive/importers/state_machine_importer.hpp"
#include "rive/animation/state_machine.hpp"
-#include "rive/animation/state_machine_listener.hpp"
+#include "rive/animation/state_machine_event.hpp"
#include "rive/animation/state_machine_input.hpp"
#include "rive/animation/state_machine_layer.hpp"
m_StateMachine->addInput(std::move(input));
}
-void StateMachineImporter::addListener(std::unique_ptr<StateMachineListener> listener) {
- m_StateMachine->addListener(std::move(listener));
+void StateMachineImporter::addEvent(std::unique_ptr<StateMachineEvent> event) {
+ m_StateMachine->addEvent(std::move(event));
}
bool StateMachineImporter::readNullObject() {
+++ /dev/null
-#include "rive/animation/listener_action.hpp"
-#include "rive/importers/state_machine_listener_importer.hpp"
-#include "rive/animation/state_machine_listener.hpp"
-
-using namespace rive;
-
-StateMachineListenerImporter::StateMachineListenerImporter(StateMachineListener* listener) :
- m_StateMachineListener(listener) {}
-
-void StateMachineListenerImporter::addAction(std::unique_ptr<ListenerAction> action) {
- m_StateMachineListener->addAction(std::move(action));
-}
-
-StatusCode StateMachineListenerImporter::resolve() { return StatusCode::Ok; }
\ No newline at end of file
graphics_round(bottom()),
};
}
-
-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) {
- out.minX = x;
- }
- if (x > out.maxX) {
- out.maxX = x;
- }
- if (y < out.minY) {
- out.minY = y;
- }
- if (y > out.maxY) {
- out.maxY = y;
- }
-}
-
-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);
- out.maxY = std::max(a.maxY, b.maxY);
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/core/type_conversions.hpp"
-#include "rive/math/raw_path_utils.hpp"
-#include "rive/math/contour_measure.hpp"
-#include "rive/math/math_types.hpp"
-#include <cmath>
-
-using namespace rive;
-
-enum SegmentType { // must fit in 2 bits
- kLine,
- kQuad,
- kCubic,
- // unused for now
-};
-
-/*
- * Inspired by Skia's SkContourMeasure
- */
-
-ContourMeasure::ContourMeasure(std::vector<Segment>&& segs,
- std::vector<Vec2D>&& pts,
- float length,
- bool 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 {
- assert(m_segments.front().m_distance > 0);
- assert(m_segments.back().m_distance == m_length);
-
- assert(distance >= 0 && distance <= m_length);
-
- const Segment seg = {distance, 0, 0, 0};
- auto iter = std::lower_bound(m_segments.begin(), m_segments.end(), seg);
- assert(iter != m_segments.end());
- assert(iter->m_distance >= distance);
- assert(iter->m_ptIndex < m_points.size());
- return iter - m_segments.begin();
-}
-
-static ContourMeasure::PosTan eval_quad(const Vec2D pts[], float t) {
- assert(t >= 0 && t <= 1);
-
- const EvalQuad eval(pts);
-
- // Compute derivative as at + b
- auto a = two(eval.a);
- auto b = eval.b;
-
- return {
- eval(t),
- (a * t + b).normalized(),
- };
-}
-
-static ContourMeasure::PosTan eval_cubic(const Vec2D pts[], float t) {
- assert(t >= 0 && t <= 1);
-
- const EvalCubic eval(pts);
-
- // Compute derivative as at^2 + bt + c;
- auto a = eval.a * 3;
- auto b = two(eval.b);
- auto c = eval.c;
-
- return {
- eval(t),
- ((a * t + b) * t + c).normalized(),
- };
-}
-
-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;
- }
-}
-
-void ContourMeasure::Segment::extract(RawPath* dst,
- float fromT,
- float toT,
- const Vec2D pts[],
- bool moveTo) const {
- assert(fromT <= toT);
- pts += m_ptIndex;
-
- Vec2D tmp[4];
- switch (m_type) {
- case SegmentType::kLine:
- line_extract(pts, fromT, toT, tmp);
- if (moveTo) {
- dst->move(tmp[0]);
- }
- dst->line(tmp[1]);
- break;
- case SegmentType::kQuad:
- quad_extract(pts, fromT, toT, tmp);
- if (moveTo) {
- dst->move(tmp[0]);
- }
- dst->quad(tmp[1], tmp[2]);
- break;
- case SegmentType::kCubic:
- cubic_extract(pts, fromT, toT, tmp);
- if (moveTo) {
- dst->move(tmp[0]);
- }
- dst->cubic(tmp[1], tmp[2], tmp[3]);
- break;
- }
-}
-
-ContourMeasure::PosTan ContourMeasure::getPosTan(float distance) const {
- // specal-case end of the contour
- 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) {
- distance = 0;
- }
-
- size_t i = this->findSegment(distance);
- assert(i < m_segments.size());
- const auto seg = m_segments[i];
- const float currD = seg.m_distance;
- const float prevD = i > 0 ? m_segments[i - 1].m_distance : 0;
-
- assert(prevD < currD);
- assert(distance <= currD);
- assert(distance >= prevD);
-
- const float relD = (distance - prevD) / (currD - prevD);
- assert(relD >= 0 && relD <= 1);
-
- 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];
- return {
- Vec2D::lerp(p0, p1, relD),
- (p1 - p0).normalized(),
- };
- }
-
- float prevT = 0;
- if (i > 0) {
- auto prev = m_segments[i - 1];
- if (prev.m_ptIndex == seg.m_ptIndex) {
- prevT = prev.getT();
- }
- }
-
- const float t = lerp(prevT, seg.getT(), relD);
- assert(t >= 0 && t <= 1);
-
- if (seg.m_type == SegmentType::kQuad) {
- assert(seg.m_ptIndex + 2 < m_points.size());
- return eval_quad(&m_points[seg.m_ptIndex], t);
- } 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) {
- auto startingPtIndex = seg->m_ptIndex;
- 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) {
- const auto seg = segs[index];
- assert(distance <= seg.m_distance);
-
- float prevDist = 0, prevT = 0;
- if (index > 0) {
- const auto prev = segs[index - 1];
- prevDist = prev.m_distance;
- if (prev.m_ptIndex == seg.m_ptIndex) {
- prevT = prev.getT();
- }
- }
-
- assert(prevDist < seg.m_distance);
- const auto ratio = (distance - prevDist) / (seg.m_distance - prevDist);
- return lerp(prevT, seg.getT(), ratio);
-}
-
-void ContourMeasure::getSegment(float startDist,
- float endDist,
- RawPath* dst,
- bool startWithMove) const {
- // sanitize the inputs
- startDist = std::max(0.f, startDist);
- endDist = std::min(m_length, endDist);
- if (startDist >= endDist) {
- return;
- }
-
- const auto startIndex = this->findSegment(startDist);
- const auto endIndex = this->findSegment(endDist);
-
- const auto start = m_segments[startIndex];
- const auto end = m_segments[endIndex];
-
- 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) {
- start.extract(dst, startT, endT, m_points.data(), startWithMove);
- } 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) {
- seg->extract(dst, m_points.data());
- seg = next_segment_beginning(seg);
- }
- assert(seg->m_ptIndex == end.m_ptIndex);
-
- end.extract(dst, 0, endT, m_points.data(), false);
- }
-}
-
-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) {
- printf(" %g %d %g %d\n", s.m_distance, s.m_ptIndex, s.getT(), s.m_type);
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-constexpr auto kMaxDot30 = ContourMeasure::kMaxDot30;
-
-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) {
- const auto& last = array.back();
- assert(last.m_distance <= seg.m_distance);
- if (last.m_distance == seg.m_distance) {
- assert(!required);
- return;
- }
- }
- array.push_back(seg);
-}
-
-// These add[SegmentType]Segs routines append intermediate segments for the curve.
-// They assume the caller has set the initial segment (with t == 0), so they only
-// add intermediates.
-
-float ContourMeasureIter::addQuadSegs(std::vector<ContourMeasure::Segment>& segs,
- const Vec2D pts[],
- uint32_t ptIndex,
- 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) {
- auto next = eval(t);
- distance += (next - prev).length();
- addSeg(segs, {distance, ptIndex, toDot30(t), SegmentType::kQuad});
- prev = next;
- t += dt;
- }
- distance += (pts[2] - prev).length();
- addSeg(segs, {distance, ptIndex, kMaxDot30, SegmentType::kQuad});
- return distance;
-}
-
-float ContourMeasureIter::addCubicSegs(std::vector<ContourMeasure::Segment>& segs,
- const Vec2D pts[],
- uint32_t ptIndex,
- 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) {
- auto next = eval(t);
- distance += (next - prev).length();
- addSeg(segs, {distance, ptIndex, toDot30(t), SegmentType::kCubic});
- prev = next;
- t += dt;
- }
- distance += (pts[3] - prev).length();
- addSeg(segs, {distance, ptIndex, kMaxDot30, SegmentType::kCubic});
- return distance;
-}
-
-void ContourMeasureIter::reset(const RawPath& path, float tolerance) {
- m_iter.reset(path);
- m_srcPoints = path.points().data();
-
- constexpr float kMinTolerance = 1.0f / 16;
- m_invTolerance = 1.0f / std::max(tolerance, kMinTolerance);
-}
-
-// Can return null if either it encountered an empty contour (length == 0)
-// or the iterator is exhausted.
-//
-rcp<ContourMeasure> ContourMeasureIter::tryNext() {
- std::vector<ContourMeasure::Segment> segs;
- std::vector<Vec2D> pts;
- float distance = 0;
- bool isClosed = false;
- bool doneWithThisContour = false;
-
- if (auto rec = m_iter.next()) {
- assert(rec.verb == PathVerb::move);
- pts.push_back(rec.pts[0]);
-
- while (!doneWithThisContour && (rec = m_iter.next())) {
- float prevDistance = distance;
- const uint32_t ptIndex = castTo<uint32_t>(pts.size() - 1);
- switch (rec.verb) {
- case PathVerb::move:
- m_iter.backUp(); // so we can see this verb again the next time
- doneWithThisContour = true;
- break;
- case PathVerb::line:
- distance += (rec.pts[0] - rec.pts[-1]).length();
- if (distance > prevDistance) {
- addSeg(segs, {distance, ptIndex, kMaxDot30, SegmentType::kLine}, true);
- pts.push_back(rec.pts[0]);
- }
- break;
- case PathVerb::quad:
- distance = this->addQuadSegs(segs, &rec.pts[-1], ptIndex, distance);
- if (distance > prevDistance) {
- pts.push_back(rec.pts[0]);
- pts.push_back(rec.pts[1]);
- }
- break;
- case PathVerb::cubic:
- distance = this->addCubicSegs(segs, &rec.pts[-1], ptIndex, distance);
- if (distance > prevDistance) {
- pts.push_back(rec.pts[0]);
- pts.push_back(rec.pts[1]);
- pts.push_back(rec.pts[2]);
- }
- break;
- case PathVerb::close: {
- auto first = pts.front();
- distance += (first - pts.back()).length();
- if (distance > prevDistance) {
- addSeg(segs, {distance, ptIndex, kMaxDot30, SegmentType::kLine}, true);
- pts.push_back(first);
- }
- isClosed = true;
- doneWithThisContour = true;
- } break;
- }
- }
- }
-
- 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> cm;
- for (;;) {
- if ((cm = this->tryNext())) {
- break;
- }
- if (m_iter.isDone()) {
- break;
- }
- }
- return cm;
-}
/////////////////////////
-static bool cross_lt(Vec2D a, Vec2D b) { return a.x * b.y < a.y * b.x; }
+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) {
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()) {
+ if (bounds.bottom() < pt.y || pt.y < bounds.top() ||
+ bounds.right() < pt.x || pt.x < bounds.left()) {
return false;
}
}
auto pa = a - pt;
auto pb = b - pt;
auto pc = c - pt;
-
+
auto ab = cross_lt(pa, pb);
auto bc = cross_lt(pb, pc);
auto ca = cross_lt(pc, pa);
// 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) {
- return testMesh(Vec2D((float)area.left, (float)area.top), verts, indices);
+ return testMesh(Vec2D(area.left, area.top), verts, indices);
}
if (verts.size() < 3) {
std::vector<int> windings(area.width() * area.height());
const auto offset = Vec2D((float)area.left, (float)area.top);
int* deltas = windings.data();
-
+
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;
-
- clip_line((float)area.height(), a, b, deltas, area.width());
- clip_line((float)area.height(), b, c, deltas, area.width());
- clip_line((float)area.height(), c, a, deltas, area.width());
+
+ clip_line(area.height(), a, b, deltas, area.width());
+ clip_line(area.height(), b, c, deltas, area.width());
+ clip_line(area.height(), c, a, deltas, area.width());
int nonzero = 0;
for (auto w : windings) {
}
Mat2D Mat2D::multiply(const Mat2D& a, const Mat2D& b) {
- float a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5], b0 = b[0], b1 = b[1],
- b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
+ float a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
+ b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
return {
a0 * b0 + a2 * b1,
a1 * b0 + a3 * b1,
}
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 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) {
det = 1.0f / det;
*result = {
- ad * det,
+ ad * det,
-ab * det,
-ac * det,
- aa * det,
+ aa * det,
(ac * aty - ad * atx) * det,
(ab * atx - aa * aty) * det,
};
}
TransformComponents Mat2D::decompose() const {
- float m0 = m_Buffer[0], m1 = m_Buffer[1], m2 = m_Buffer[2], m3 = m_Buffer[3];
+ float m0 = m_Buffer[0], m1 = m_Buffer[1],
+ m2 = m_Buffer[2], m3 = m_Buffer[3];
float rotation = (float)std::atan2(m1, m0);
float denom = m0 * m0 + m1 * m1;
#include "rive/math/raw_path.hpp"
#include <cmath>
-#include <cstring>
-#include <algorithm>
using namespace rive;
-RawPath::RawPath(Span<const Vec2D> points, Span<const PathVerb> verbs) :
- m_Points(points.begin(), points.end()), m_Verbs(verbs.begin(), verbs.end()) {}
-
-bool RawPath::operator==(const RawPath& o) const {
- return m_Points == o.m_Points && m_Verbs == o.m_Verbs;
-}
-
AABB RawPath::bounds() const {
if (this->empty()) {
return {0, 0, 0, 0};
}
void RawPath::move(Vec2D a) {
- m_Points.push_back(a);
- m_Verbs.push_back(PathVerb::move);
+ const auto n = m_Verbs.size();
+ if (n > 0 && m_Verbs[n - 1] == PathVerb::move) {
+ m_Points[n - 1] = a; // replace previous move position
+ } else {
+ m_Points.push_back(a);
+ m_Verbs.push_back(PathVerb::move);
+ }
}
void RawPath::line(Vec2D a) {
close();
}
}
-
-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) {
- 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) {
- dst[i] = *mat * src.m_Points[i];
- }
- } else {
- m_Points.insert(m_Points.end(), src.m_Points.cbegin(), src.m_Points.cend());
- }
-}
-
-//////////////////////////////////////////////////////////////////////////
-
-namespace rive {
-int path_verb_to_point_count(PathVerb v) {
- static uint8_t ptCounts[] = {
- 1, // move
- 1, // line
- 2, // quad
- 2, // conic (unused)
- 3, // cubic
- 0, // close
- };
- size_t index = (size_t)v;
- assert(index < sizeof(ptCounts));
- return ptCounts[index];
-}
-} // namespace rive
-
-RawPath::Iter::Rec RawPath::Iter::next() {
- // initialize with "false"
- Rec rec = {nullptr, -1, (PathVerb)-1};
-
- if (m_currVerb < m_stopVerb) {
- rec.pts = m_currPts;
- rec.verb = *m_currVerb++;
- rec.count = path_verb_to_point_count(rec.verb);
-
- m_currPts += rec.count;
- }
- return rec;
-}
-
-void RawPath::Iter::backUp() {
- --m_currVerb;
- const int n = path_verb_to_point_count(*m_currVerb);
- m_currPts -= n;
-}
-
-void RawPath::reset() {
- m_Points.clear();
- m_Points.shrink_to_fit();
- m_Verbs.clear();
- m_Verbs.shrink_to_fit();
-}
-
-void RawPath::rewind() {
- m_Points.clear();
- m_Verbs.clear();
-}
-
-///////////////////////////////////
-
-#include "rive/command_path.hpp"
-
-void RawPath::addTo(CommandPath* result) const {
- RawPath::Iter iter(*this);
- while (auto rec = iter.next()) {
- switch (rec.verb) {
- case PathVerb::move: result->move(rec.pts[0]); break;
- case PathVerb::line: result->line(rec.pts[0]); break;
- case PathVerb::quad: assert(false); break;
- case PathVerb::cubic: result->cubic(rec.pts[0], rec.pts[1], rec.pts[2]); break;
- case PathVerb::close: result->close(); break;
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/math/math_types.hpp"
-#include "rive/math/raw_path_utils.hpp"
-#include <cmath>
-
-// just putting a sane limit, the particular value not important.
-constexpr int MAX_LINE_SEGMENTS = 100;
-
-// (a+c)/2 - (a+2b+c)/4)
-// a/4 - b/2 + c/4
-// d = |a - 2b + c|/4
-// count = sqrt(d / tol)
-//
-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) {
- 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));
- float dy = std::max(std::abs(abc.y), std::abs(bcd.y));
- float d = Vec2D{dx, dy}.length();
- // count = sqrt(3*d / 4*tol)
- float count = sqrtf(d * invTolerance * 0.75f);
- return std::max(1, std::min((int)std::ceil(count), MAX_LINE_SEGMENTS));
-}
-
-// Extract subsets
-
-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);
- dst[0] = src[0];
- dst[1] = ab;
- dst[2] = lerp(ab, bc, t);
- dst[3] = bc;
- dst[4] = src[2];
-}
-
-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);
- auto cd = lerp(src[2], src[3], t);
- auto abc = lerp(ab, bc, t);
- auto bcd = lerp(bc, cd, t);
- dst[0] = src[0];
- dst[1] = ab;
- dst[2] = abc;
- dst[3] = lerp(abc, bcd, t);
- dst[4] = bcd;
- dst[5] = cd;
- dst[6] = src[3];
-}
-
-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);
-
- dst[0] = lerp(src[0], src[1], startT);
- 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]) {
- assert(startT <= endT);
- assert(startT >= 0 && endT <= 1);
-
- rive::Vec2D tmp[5];
- if (startT == 0 && endT == 1) {
- std::copy(src, src + 3, dst);
- } else if (startT == 0) {
- rive::quad_subdivide(src, endT, tmp);
- std::copy(tmp, tmp + 3, dst);
- } else if (endT == 1) {
- rive::quad_subdivide(src, startT, tmp);
- std::copy(tmp + 2, tmp + 5, dst);
- } else {
- assert(endT > 0);
- rive::quad_subdivide(src, endT, tmp);
- rive::Vec2D tmp2[5];
- rive::quad_subdivide(tmp, startT / endT, tmp2);
- std::copy(tmp2 + 2, tmp2 + 5, dst);
- }
-}
-
-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) {
- std::copy(src, src + 4, dst);
- } else if (startT == 0) {
- rive::cubic_subdivide(src, endT, tmp);
- std::copy(tmp, tmp + 4, dst);
- } else if (endT == 1) {
- rive::cubic_subdivide(src, startT, tmp);
- std::copy(tmp + 3, tmp + 7, dst);
- } else {
- assert(endT > 0);
- rive::cubic_subdivide(src, endT, tmp);
- rive::Vec2D tmp2[7];
- rive::cubic_subdivide(tmp, startT / endT, tmp2);
- std::copy(tmp2 + 3, tmp2 + 7, dst);
- }
-}
#include "rive/importers/import_stack.hpp"
#include "rive/importers/backboard_importer.hpp"
#include "rive/nested_animation.hpp"
-#include "rive/animation/nested_state_machine.hpp"
-#include <cassert>
using namespace rive;
assert(artboard != nullptr);
m_Artboard = artboard;
- 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;
- }
- m_Artboard->frameOrigin(false);
- m_Artboard->opacity(renderOpacity());
m_Instance = nullptr;
if (artboard->isInstance()) {
m_Instance.reset(static_cast<ArtboardInstance*>(artboard)); // take ownership
// transformations.
renderer->save();
}
- renderer->transform(worldTransform());
+ renderer->transform(worldTransform() * makeTranslate(m_Artboard));
m_Artboard->draw(renderer);
renderer->restore();
}
void NestedArtboard::update(ComponentDirt value) {
Super::update(value);
- if (hasDirt(value, ComponentDirt::RenderOpacity) && m_Artboard != nullptr) {
+ if (hasDirt(value, ComponentDirt::WorldTransform) && m_Artboard != nullptr) {
m_Artboard->opacity(renderOpacity());
}
}
-
-bool NestedArtboard::hasNestedStateMachines() const {
- for (auto animation : m_NestedAnimations) {
- if (animation->is<NestedStateMachine>()) {
- return true;
- }
- }
- return false;
-}
-
-Span<NestedAnimation*> NestedArtboard::nestedAnimations() { return m_NestedAnimations; }
-
-bool NestedArtboard::worldToLocal(Vec2D world, Vec2D* local) {
- assert(local != nullptr);
- if (m_Artboard == nullptr) {
- return false;
- }
- Mat2D toMountedArtboard;
- if (!worldTransform().invert(&toMountedArtboard)) {
- return false;
- }
-
- *local = toMountedArtboard * world;
-
- return true;
-}
\ No newline at end of file
#include "rive/math/mat2d.hpp"
#include "rive/renderer.hpp"
-#include "rive/rive_counter.hpp"
using namespace rive;
const float c = std::cos(radians);
this->transform(Mat2D(c, s, -s, c, 0, 0));
}
-
-RenderBuffer::RenderBuffer(size_t count) : m_Count(count) { Counter::update(Counter::kBuffer, 1); }
-
-RenderBuffer::~RenderBuffer() { Counter::update(Counter::kBuffer, -1); }
-
-RenderShader::RenderShader() { Counter::update(Counter::kShader, 1); }
-RenderShader::~RenderShader() { Counter::update(Counter::kShader, -1); }
-
-RenderPaint::RenderPaint() { Counter::update(Counter::kPaint, 1); }
-RenderPaint::~RenderPaint() { Counter::update(Counter::kPaint, -1); }
-
-RenderImage::RenderImage() { Counter::update(Counter::kImage, 1); }
-RenderImage::~RenderImage() { Counter::update(Counter::kImage, -1); }
-
-RenderPath::RenderPath() { Counter::update(Counter::kPath, 1); }
-RenderPath::~RenderPath() { Counter::update(Counter::kPath, -1); }
-
-#include "rive/render_text.hpp"
-
-std::vector<RenderGlyphRun>
-RenderFont::shapeText(rive::Span<const rive::Unichar> text,
- rive::Span<const rive::RenderTextRun> runs) const {
-#ifdef DEBUG
- size_t count = 0;
- for (const auto& tr : runs) {
- assert(tr.unicharCount > 0);
- count += tr.unicharCount;
- }
- assert(count <= text.size());
-#endif
- auto gruns = this->onShapeText(text, runs);
-#ifdef DEBUG
- for (const auto& gr : gruns) {
- assert(gr.glyphs.size() > 0);
- assert(gr.glyphs.size() == gr.textOffsets.size());
- assert(gr.glyphs.size() + 1 == gr.xpos.size());
- }
-#endif
- return gruns;
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/rive_counter.hpp"
-
-using namespace rive;
-
-int Counter::counts[Type::kLastType + 1] = {};
assert(m_ArtboardInstance->isInstance());
}
-float Scene::width() const { return m_ArtboardInstance->width(); }
+float Scene::width() const {
+ return m_ArtboardInstance->width();
+}
-float Scene::height() const { return m_ArtboardInstance->height(); }
+float Scene::height() const {
+ return m_ArtboardInstance->height();
+}
-void Scene::draw(Renderer* renderer) { m_ArtboardInstance->draw(renderer); }
+void Scene::draw(Renderer* renderer) {
+ m_ArtboardInstance->draw(renderer);
+}
void Scene::pointerDown(Vec2D) {}
void Scene::pointerMove(Vec2D) {}
}
}
- // We only need a render path if we have more than 1 clip path as we join them.
- if (m_Shapes.size() > 1) {
- m_RenderPath = artboard->factory()->makeEmptyRenderPath();
- }
+ m_RenderPath = artboard->factory()->makeEmptyRenderPath();
return StatusCode::Ok;
}
static Mat2D identity;
void ClippingShape::update(ComponentDirt value) {
if (hasDirt(value, ComponentDirt::Path | ComponentDirt::WorldTransform)) {
- if (m_RenderPath) {
- m_RenderPath->reset();
+ m_RenderPath->reset();
- m_RenderPath->fillRule((FillRule)fillRule());
- m_ClipRenderPath = nullptr;
- for (auto shape : m_Shapes) {
- if (!shape->isHidden()) {
- m_RenderPath->addPath(shape->pathComposer()->worldPath(), identity);
- m_ClipRenderPath = m_RenderPath.get();
- }
- }
- } else {
- auto first = m_Shapes.front();
- if (first->isHidden()) {
- m_ClipRenderPath = nullptr;
- } else {
- m_ClipRenderPath = static_cast<RenderPath*>(first->pathComposer()->worldPath());
+ m_RenderPath->fillRule((FillRule)fillRule());
+ for (auto shape : m_Shapes) {
+ if (!shape->isHidden()) {
+ m_RenderPath->addPath(shape->pathComposer()->worldPath(), identity);
}
}
}
-}
\ No newline at end of file
+}
using namespace rive;
void Image::draw(Renderer* renderer) {
- rive::RenderImage* renderImage;
- if (m_ImageAsset == nullptr || renderOpacity() == 0.0f ||
- (renderImage = m_ImageAsset->renderImage()) == nullptr)
- {
+ if (m_ImageAsset == nullptr || renderOpacity() == 0.0f) {
return;
}
renderer->save();
}
+ auto renderImage = m_ImageAsset->renderImage();
auto width = renderImage->width();
auto height = renderImage->height();
// TODO: handle clip?
auto renderImage = m_ImageAsset->renderImage();
- int width = renderImage->width();
- int height = renderImage->height();
+ auto width = renderImage->width();
+ auto height = renderImage->height();
if (m_Mesh) {
printf("Missing mesh\n");
} 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);
+ tester.addRect(AABB(0, 0, width, height), mx);
if (tester.test()) {
return this;
}
}
auto factory = artboard()->factory();
- m_UVRenderBuffer = factory->makeBufferF32(uv);
- m_IndexRenderBuffer = factory->makeBufferU16(*m_IndexBuffer);
+ m_UVRenderBuffer = factory->makeBufferF32(toSpan(uv));
+ m_IndexRenderBuffer = factory->makeBufferU16(toSpan(*m_IndexBuffer));
}
void Mesh::update(ComponentDirt value) {
}
auto factory = artboard()->factory();
- m_VertexRenderBuffer = factory->makeBufferF32(vertices);
+ m_VertexRenderBuffer = factory->makeBufferF32(toSpan(vertices));
}
if (skin() == nullptr) {
renderer->transform(parent()->as<WorldTransformComponent>()->worldTransform());
}
- renderer->drawImageMesh(image,
- m_VertexRenderBuffer,
- m_UVRenderBuffer,
- m_IndexRenderBuffer,
- blendMode,
- opacity);
+ renderer->drawImageMesh(
+ image, m_VertexRenderBuffer, m_UVRenderBuffer, m_IndexRenderBuffer, blendMode, opacity);
}
#include "rive/core/type_conversions.hpp"
#include "rive/shapes/metrics_path.hpp"
#include "rive/renderer.hpp"
-#include "rive/math/cubic_utilities.hpp"
-#include "rive/math/raw_path.hpp"
-#include "rive/math/contour_measure.hpp"
using namespace rive;
+static float clamp(float v, float lo, float hi) {
+ return std::min(std::max(v, lo), hi);
+}
+
+// Less exact, but faster, than std::lerp
+static float lerp(float from, float to, float f) {
+ return from + f * (to - from);
+}
+
void MetricsPath::reset() {
+ m_ComputedLength = 0.0f;
+ m_CubicSegments.clear();
+ m_Points.clear();
+ m_Parts.clear();
+ m_Lengths.clear();
m_Paths.clear();
- m_Contour.reset(nullptr);
- m_RawPath = RawPath();
- m_ComputedLengthTransform = Mat2D();
- m_ComputedLength = 0;
}
void MetricsPath::addPath(CommandPath* path, const Mat2D& transform) {
}
void MetricsPath::moveTo(float x, float y) {
- assert(m_RawPath.points().size() == 0);
- m_RawPath.move({x, y});
+ assert(m_Points.size() == 0);
+ m_Points.emplace_back(Vec2D(x, y));
}
-void MetricsPath::lineTo(float x, float y) { m_RawPath.line({x, y}); }
+void MetricsPath::lineTo(float x, float y) {
+ // TODO: resize PathPart to allow for larger offsets
+ auto offset = castTo<uint8_t>(m_Points.size());
+ m_Parts.push_back(PathPart(0, offset));
+ m_Points.emplace_back(Vec2D(x, 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});
+ auto offset = castTo<uint8_t>(m_Points.size());
+ m_Parts.push_back(PathPart(1, offset));
+ m_Points.emplace_back(Vec2D(ox, oy));
+ m_Points.emplace_back(Vec2D(ix, iy));
+ m_Points.emplace_back(Vec2D(x, y));
+}
+
+void MetricsPath::close() {}
+
+static void computeHull(const Vec2D& from,
+ const Vec2D& fromOut,
+ const Vec2D& toIn,
+ const Vec2D& to,
+ float t,
+ Vec2D* hull) {
+ hull[0] = Vec2D::lerp(from, fromOut, t);
+ hull[1] = Vec2D::lerp(fromOut, toIn, t);
+ hull[2] = Vec2D::lerp(toIn, to, t);
+
+ hull[3] = Vec2D::lerp(hull[0], hull[1], t);
+ hull[4] = Vec2D::lerp(hull[1], hull[2], t);
+
+ hull[5] = Vec2D::lerp(hull[3], hull[4], t);
+}
+
+static const float minSegmentLength = 0.05f;
+static const float distTooFar = 1.0f;
+
+static bool tooFar(const Vec2D& a, const Vec2D& b) {
+ auto diff = a - b;
+ return std::max(std::abs(diff.x), std::abs(diff.y)) > distTooFar;
}
-void MetricsPath::close() {
- // Should we pass the close() to our m_RawPath ???
+static bool
+shouldSplitCubic(const Vec2D& from, const Vec2D& fromOut, const Vec2D& toIn, const Vec2D& to) {
+ const Vec2D oneThird = Vec2D::lerp(from, to, 1.0f / 3.0f),
+ twoThird = Vec2D::lerp(from, to, 2.0f / 3.0f);
+ return tooFar(fromOut, oneThird) || tooFar(toIn, twoThird);
+}
+
+static float segmentCubic(const Vec2D& from,
+ const Vec2D& fromOut,
+ const Vec2D& toIn,
+ const Vec2D& to,
+ float runningLength,
+ float t1,
+ float t2,
+ std::vector<CubicSegment>& segments) {
+
+ if (shouldSplitCubic(from, fromOut, toIn, to)) {
+ float halfT = (t1 + t2) / 2.0f;
+
+ Vec2D hull[6];
+ computeHull(from, fromOut, toIn, to, 0.5f, hull);
+
+ runningLength =
+ segmentCubic(from, hull[0], hull[3], hull[5], runningLength, t1, halfT, segments);
+ runningLength =
+ segmentCubic(hull[5], hull[4], hull[2], to, runningLength, halfT, t2, segments);
+ } else {
+ float length = Vec2D::distance(from, to);
+ runningLength += length;
+ if (length > minSegmentLength) {
+ segments.emplace_back(CubicSegment(t2, runningLength));
+ }
+ }
+ return runningLength;
}
float MetricsPath::computeLength(const Mat2D& transform) {
- // Only compute if our pre-computed length is not valid
- if (!m_Contour || transform != m_ComputedLengthTransform) {
- m_ComputedLengthTransform = transform;
- m_Contour = ContourMeasureIter(m_RawPath * transform).next();
- m_ComputedLength = m_Contour ? m_Contour->length() : 0;
+ // If the pre-computed length is still valid (transformed with the same
+ // transform) just return that.
+ if (!m_Lengths.empty() && transform == m_ComputedLengthTransform) {
+ return m_ComputedLength;
}
- return m_ComputedLength;
+ m_ComputedLengthTransform = transform;
+ m_Lengths.clear();
+ m_CubicSegments.clear();
+
+ // We have to dupe the transformed points as we're not sure whether just the
+ // transform is changing (path may not have been reset but got added with
+ // another transform).
+ m_TransformedPoints.resize(m_Points.size());
+ for (size_t i = 0, l = m_Points.size(); i < l; i++) {
+ m_TransformedPoints[i] = transform * m_Points[i];
+ }
+
+ // Should never have subPaths with more subPaths (Skia allows this but for
+ // Rive this isn't necessary and it keeps things simpler).
+ assert(m_Paths.empty());
+ const Vec2D* pen = &m_TransformedPoints[0];
+ int idx = 1;
+ float length = 0.0f;
+
+ for (PathPart& part : m_Parts) {
+ switch (part.type) {
+ case PathPart::line: {
+ const Vec2D& point = m_TransformedPoints[idx++];
+
+ float partLength = Vec2D::distance(*pen, point);
+ m_Lengths.push_back(partLength);
+ pen = &point;
+ length += partLength;
+ break;
+ }
+ // Anything above 0 is the number of cubic parts...
+ default: {
+ // Subdivide as necessary...
+
+ // push in the parts
+
+ const Vec2D& from = pen[0];
+ const Vec2D& fromOut = pen[1];
+ const Vec2D& toIn = pen[2];
+ const Vec2D& to = pen[3];
+
+ idx += 3;
+ pen = &to;
+
+ int index = (int)m_CubicSegments.size();
+ part.type = castTo<uint8_t>(index + 1);
+ float partLength =
+ segmentCubic(from, fromOut, toIn, to, 0.0f, 0.0f, 1.0f, m_CubicSegments);
+ m_Lengths.push_back(partLength);
+ length += partLength;
+ part.numSegments = castTo<uint8_t>(m_CubicSegments.size() - index);
+ break;
+ }
+ }
+ }
+ m_ComputedLength = length;
+ return length;
}
void MetricsPath::trim(float startLength, float endLength, bool moveTo, RenderPath* result) {
m_Paths.front()->trim(startLength, endLength, moveTo, result);
return;
}
+ if (startLength == endLength) {
+ // nothing to trim.
+ return;
+ }
+ // We need to find the first part to trim.
+ float length = 0.0f;
- // TODO: if we can change the signature of MetricsPath and/or trim() to speak native
- // rawpaths, we wouldn't need this temporary copy (since ContourMeasure speaks
- // native rawpaths).
- RawPath tmp;
- m_Contour->getSegment(startLength, endLength, &tmp, moveTo);
- tmp.addTo(result);
+ int partCount = (int)m_Parts.size();
+ int firstPartIndex = -1, lastPartIndex = partCount - 1;
+ float startT = 0.0f, endT = 1.0f;
+ // Find first part.
+ for (int i = 0; i < partCount; i++) {
+ float partLength = m_Lengths[i];
+ if (length + partLength > startLength) {
+ firstPartIndex = i;
+ startT = (startLength - length) / partLength;
+ break;
+ }
+ length += partLength;
+ }
+ if (firstPartIndex == -1) {
+ // Couldn't find it.
+ return;
+ }
+
+ // Find last part.
+ for (int i = firstPartIndex; i < partCount; i++) {
+ float partLength = m_Lengths[i];
+ if (length + partLength >= endLength) {
+ lastPartIndex = i;
+ endT = (endLength - length) / partLength;
+ break;
+ }
+ length += partLength;
+ }
+
+ // Lets make sur we're between 0 & 1f on both start & end.
+ startT = clamp(startT, 0.0f, 1.0f);
+ endT = clamp(endT, 0.0f, 1.0f);
+
+ if (firstPartIndex == lastPartIndex) {
+ extractSubPart(firstPartIndex, startT, endT, moveTo, result);
+ } else {
+ extractSubPart(firstPartIndex, startT, 1.0f, moveTo, result);
+ for (int i = firstPartIndex + 1; i < lastPartIndex; i++) {
+ // add entire part...
+ const PathPart& part = m_Parts[i];
+ switch (part.type) {
+ case PathPart::line: {
+ result->line(m_TransformedPoints[part.offset]);
+ break;
+ }
+ default: {
+ result->cubic(m_TransformedPoints[part.offset + 0],
+ m_TransformedPoints[part.offset + 1],
+ m_TransformedPoints[part.offset + 2]);
+ break;
+ }
+ }
+ }
+ extractSubPart(lastPartIndex, 0.0f, endT, false, result);
+ }
+}
+
+void MetricsPath::extractSubPart(
+ int index, float startT, float endT, bool moveTo, RenderPath* result) {
+ assert(startT >= 0.0f && startT <= 1.0f && endT >= 0.0f && endT <= 1.0f);
+ const PathPart& part = m_Parts[index];
+ switch (part.type) {
+ case PathPart::line: {
+ const Vec2D from = m_TransformedPoints[part.offset - 1];
+ const Vec2D to = m_TransformedPoints[part.offset];
+ const Vec2D dir = to - from;
+ if (moveTo) {
+ result->move(from + dir * startT);
+ }
+ result->line(from + dir * endT);
+
+ break;
+ }
+ default: {
+ auto startingSegmentIndex = part.type - 1;
+ auto startEndSegmentIndex = startingSegmentIndex;
+ auto endingSegmentIndex = startingSegmentIndex + part.numSegments;
+
+ // Find cubicStartT and cubicEndT
+ float length = m_Lengths[index];
+ if (startT != 0.0f) {
+ float startLength = startT * length;
+ for (int si = startingSegmentIndex; si < endingSegmentIndex; si++) {
+ const CubicSegment& segment = m_CubicSegments[si];
+ if (segment.length >= startLength) {
+ if (si == startingSegmentIndex) {
+ startT = segment.t * (startLength / segment.length);
+ } else {
+ float previousLength = m_CubicSegments[si - 1].length;
+
+ float t =
+ (startLength - previousLength) / (segment.length - previousLength);
+ startT = lerp(m_CubicSegments[si - 1].t, segment.t, t);
+ }
+ // Help out the ending segment finder by setting its
+ // start to where we landed while finding the first
+ // segment, that way it can skip a bunch of work.
+ startEndSegmentIndex = si;
+ break;
+ }
+ }
+ }
+
+ if (endT != 1.0f) {
+ float endLength = endT * length;
+ for (int si = startEndSegmentIndex; si < endingSegmentIndex; si++) {
+ const CubicSegment& segment = m_CubicSegments[si];
+ if (segment.length >= endLength) {
+ if (si == startingSegmentIndex) {
+ endT = segment.t * (endLength / segment.length);
+ } else {
+ float previousLength = m_CubicSegments[si - 1].length;
+
+ float t =
+ (endLength - previousLength) / (segment.length - previousLength);
+ endT = lerp(m_CubicSegments[si - 1].t, segment.t, t);
+ }
+ break;
+ }
+ }
+ }
+
+ Vec2D hull[6];
+
+ const Vec2D& from = m_TransformedPoints[part.offset - 1];
+ const Vec2D& fromOut = m_TransformedPoints[part.offset];
+ const Vec2D& toIn = m_TransformedPoints[part.offset + 1];
+ const Vec2D& to = m_TransformedPoints[part.offset + 2];
+
+ if (startT == 0.0f) {
+ // Start is 0, so split at end and keep the left side.
+ computeHull(from, fromOut, toIn, to, endT, hull);
+ if (moveTo) {
+ result->move(from);
+ }
+ result->cubic(hull[0], hull[3], hull[5]);
+ } else {
+ // Split at start since it's non 0.
+ computeHull(from, fromOut, toIn, to, startT, hull);
+ if (moveTo) {
+ // Move to first point on the right side.
+ result->move(hull[5]);
+ }
+ if (endT == 1.0f) {
+ // End is 1, so no further split is necessary just cubicTo
+ // the remaining right side.
+ result->cubic(hull[4], hull[2], to);
+ } else {
+ // End is not 1, so split again and cubic to the left side
+ // of the split and remap endT to the new curve range
+ computeHull(
+ hull[5], hull[4], hull[2], to, (endT - startT) / (1.0f - startT), hull);
+
+ result->cubic(hull[0], hull[3], hull[5]);
+ }
+ }
+ break;
+ }
+ }
}
-RenderMetricsPath::RenderMetricsPath(std::unique_ptr<RenderPath> path) :
- m_RenderPath(std::move(path)) {}
+RenderMetricsPath::RenderMetricsPath(std::unique_ptr<RenderPath> path)
+ : m_RenderPath(std::move(path))
+{}
void RenderMetricsPath::addPath(CommandPath* path, const Mat2D& transform) {
MetricsPath::addPath(path, transform);
#include <stdio.h>
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;
-}
+ 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;
+ }
-unsigned int colorRed(ColorInt value) { return (0x00ff0000 & value) >> 16; }
+ unsigned int colorRed(ColorInt value) { return (0x00ff0000 & value) >> 16; }
-unsigned int colorGreen(ColorInt value) { return (0x0000ff00 & value) >> 8; }
+ unsigned int colorGreen(ColorInt value) { return (0x0000ff00 & value) >> 8; }
-unsigned int colorBlue(ColorInt value) { return (0x000000ff & value) >> 0; }
+ unsigned int colorBlue(ColorInt value) { return (0x000000ff & value) >> 0; }
-unsigned int colorAlpha(ColorInt value) { return (0xff000000 & value) >> 24; }
+ unsigned int colorAlpha(ColorInt value) { return (0xff000000 & value) >> 24; }
-float colorOpacity(ColorInt value) { return (float)colorAlpha(value) / 0xFF; }
+ float colorOpacity(ColorInt value) { return (float)colorAlpha(value) / 0xFF; }
-ColorInt colorWithAlpha(ColorInt value, unsigned int a) {
- return colorARGB(a, colorRed(value), colorGreen(value), colorBlue(value));
-}
+ ColorInt colorWithAlpha(ColorInt value, unsigned int a) {
+ return colorARGB(a, colorRed(value), colorGreen(value), colorBlue(value));
+ }
-ColorInt colorWithOpacity(ColorInt value, float opacity) {
- return colorWithAlpha(value, std::lround(255.f * opacity));
-}
+ ColorInt colorWithOpacity(ColorInt value, float opacity) {
+ return colorWithAlpha(value, std::round(255.0 * opacity));
+ }
-ColorInt colorModulateOpacity(ColorInt value, float opacity) {
- return colorWithAlpha(value, std::lround(255.f * colorOpacity(value) * opacity));
-}
+ ColorInt colorModulateOpacity(ColorInt value, float opacity) {
+ return colorWithAlpha(value, std::round(255.0f * colorOpacity(value) * opacity));
+ }
-static unsigned int lerp(unsigned int a, unsigned int b, float mix) {
- return std::lround(a * (1.0f - mix) + b * mix);
-}
+ static unsigned int lerp(unsigned int a, unsigned int b, float mix) {
+ return a * (1.0f - mix) + b * 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),
- lerp(colorBlue(from), colorBlue(to), 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),
+ lerp(colorBlue(from), colorBlue(to), mix));
+ }
} // namespace rive
}
}
-void LinearGradient::makeGradient(Vec2D start,
- Vec2D end,
- const ColorInt colors[],
- const float stops[],
- size_t count) {
+void LinearGradient::makeGradient(
+ Vec2D start, Vec2D end, const ColorInt colors[], const float stops[], size_t count) {
auto factory = artboard()->factory();
- renderPaint()->shader(
- factory->makeLinearGradient(start.x, start.y, end.x, end.y, colors, stops, count));
+ renderPaint()->shader(factory->makeLinearGradient(
+ start.x, start.y, end.x, end.y, colors, stops, count, RenderTileMode::clamp));
}
void LinearGradient::markGradientDirty() { addDirt(ComponentDirt::Paint); }
using namespace rive;
-void RadialGradient::makeGradient(Vec2D start,
- Vec2D end,
- const ColorInt colors[],
- const float stops[],
- size_t count) {
+void RadialGradient::makeGradient(
+ Vec2D start, Vec2D end, const ColorInt colors[], const float stops[], size_t count) {
auto factory = artboard()->factory();
renderPaint()->shader(factory->makeRadialGradient(start.x,
start.y,
Vec2D::distance(start, end),
colors,
stops,
- count));
+ count,
+ RenderTileMode::clamp));
}
if (m_Effect != nullptr) {
m_Effect->invalidateEffect();
}
- invalidateRendering();
-}
-
-void Stroke::invalidateRendering() {
- assert(m_RenderPaint != nullptr);
- m_RenderPaint->invalidateStroke();
}
\ No newline at end of file
void TrimPath::invalidateEffect() {
m_RenderPath = nullptr;
- auto stroke = parent()->as<Stroke>();
- stroke->parent()->addDirt(ComponentDirt::Paint);
- stroke->invalidateRendering();
+ parent()->as<Stroke>()->parent()->addDirt(ComponentDirt::Paint);
}
void TrimPath::startChanged() { invalidateEffect(); }
#include "rive/shapes/path.hpp"
+#include "rive/math/circle_constant.hpp"
#include "rive/renderer.hpp"
#include "rive/shapes/cubic_vertex.hpp"
#include "rive/shapes/cubic_detached_vertex.hpp"
#include "rive/shapes/path_vertex.hpp"
#include "rive/shapes/shape.hpp"
#include "rive/shapes/straight_vertex.hpp"
-#include "rive/math/math_types.hpp"
#include <cassert>
using namespace rive;
-/// Compute an ideal control point distance to create a curve of the given
-/// radius. Based on "natural rounding" https://observablehq.com/@daformat/rounding-polygon-corners
-static float computeIdealControlPointDistance(const Vec2D& toPrev,
- const Vec2D& toNext,
- float radius) {
- // Get the angle between next and prev
- float angle = fabs(atan2(Vec2D::cross(toPrev, toNext), Vec2D::dot(toPrev, toNext)));
-
- return fmin(radius,
- (4.0f / 3.0f) * tan(math::PI / (2.0f * ((2.0f * math::PI) / angle))) * radius *
- (angle < math::PI / 2 ? 1 + cos(angle) : 2.0f - sin(angle)));
-}
-
StatusCode Path::onAddedClean(CoreContext* context) {
StatusCode code = Super::onAddedClean(context);
if (code != StatusCode::Ok) {
} else {
startIsCubic = prevIsCubic = false;
auto point = *firstPoint->as<StraightVertex>();
- auto radius = point.radius();
- if (radius > 0.0f) {
+
+ if (auto radius = point.radius(); radius > 0.0f) {
auto prev = vertices[length - 1];
Vec2D pos = point.renderTranslation();
pos;
auto toNextLength = toNext.normalizeLength();
- float renderRadius =
- std::min(toPrevLength / 2.0f, std::min(toNextLength / 2.0f, radius));
- float idealDistance = computeIdealControlPointDistance(toPrev, toNext, renderRadius);
+ float renderRadius = std::min(toPrevLength, std::min(toNextLength, radius));
startIn = start = Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
commandPath.move(startIn);
- Vec2D outPoint = Vec2D::scaleAndAdd(pos, toPrev, renderRadius - idealDistance);
- Vec2D inPoint = Vec2D::scaleAndAdd(pos, toNext, renderRadius - idealDistance);
+ Vec2D outPoint = Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
+ Vec2D inPoint = Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
out = Vec2D::scaleAndAdd(pos, toNext, renderRadius);
commandPath.cubic(outPoint, inPoint, out);
prevIsCubic = false;
} else {
auto point = *vertex->as<StraightVertex>();
Vec2D pos = point.renderTranslation();
- auto radius = point.radius();
- if (radius > 0.0f) {
- auto prev = vertices[i - 1];
- Vec2D toPrev = (prev->is<CubicVertex>() ? prev->as<CubicVertex>()->renderOut()
- : prev->renderTranslation()) -
- pos;
+
+ if (auto radius = point.radius(); radius > 0.0f) {
+ Vec2D toPrev = out - pos;
auto toPrevLength = toPrev.normalizeLength();
auto next = vertices[(i + 1) % length];
pos;
auto toNextLength = toNext.normalizeLength();
- float renderRadius =
- std::min(toPrevLength / 2.0f, std::min(toNextLength / 2.0f, radius));
- float idealDistance =
- computeIdealControlPointDistance(toPrev, toNext, renderRadius);
+ float renderRadius = std::min(toPrevLength, std::min(toNextLength, radius));
Vec2D translation = Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
if (prevIsCubic) {
commandPath.line(translation);
}
- Vec2D outPoint = Vec2D::scaleAndAdd(pos, toPrev, renderRadius - idealDistance);
- Vec2D inPoint = Vec2D::scaleAndAdd(pos, toNext, renderRadius - idealDistance);
+ Vec2D outPoint = Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
+ Vec2D inPoint = Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
out = Vec2D::scaleAndAdd(pos, toNext, renderRadius);
commandPath.cubic(outPoint, inPoint, out);
prevIsCubic = false;
Vec2D toNext = nextPoint - pos;
auto toNextLength = toNext.normalizeLength();
- auto renderRadius = std::min(toPrevLength / 2.0f,
- std::min(toNextLength / 2.0f, point.radius()));
- float idealDistance =
- computeIdealControlPointDistance(toPrev, toNext, renderRadius);
+ auto renderRadius =
+ std::min(toPrevLength, std::min(toNextLength, point.radius()));
Vec2D translation = Vec2D::scaleAndAdd(pos, toPrev, renderRadius);
- Vec2D out = Vec2D::scaleAndAdd(pos, toPrev, renderRadius - idealDistance);
+ Vec2D out = Vec2D::scaleAndAdd(pos, toPrev, icircleConstant * renderRadius);
{
auto v1 = new DisplayCubicVertex(translation, out, translation);
flat->addVertex(v1, transform);
translation = Vec2D::scaleAndAdd(pos, toNext, renderRadius);
- Vec2D in = Vec2D::scaleAndAdd(pos, toNext, renderRadius - idealDistance);
+ Vec2D in = Vec2D::scaleAndAdd(pos, toNext, icircleConstant * renderRadius);
auto v2 = new DisplayCubicVertex(in, translation, translation);
flat->addVertex(v2, transform);
deletePrevious = true;
break;
}
- [[fallthrough]];
}
default:
if (deletePrevious) {
using namespace rive;
+Mat2D identity;
void PointsPath::buildDependencies() {
Super::buildDependencies();
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) {
- skin()->deform(Span<Vertex*>((Vertex**)m_Vertices.data(), m_Vertices.size()));
+ skin()->deform(Span((Vertex**)m_Vertices.data(), m_Vertices.size()));
}
Super::update(value);
}
Super::markPathDirty();
}
-void PointsPath::markSkinDirty() { markPathDirty(); }
+void PointsPath::markSkinDirty() { markPathDirty(); }
\ No newline at end of file
ShapePaintContainer* ShapePaintContainer::from(Component* component) {
switch (component->coreType()) {
- case Artboard::typeKey: return component->as<Artboard>();
- case Shape::typeKey: return component->as<Shape>();
+ case Artboard::typeKey:
+ return component->as<Artboard>();
+ break;
+ case Shape::typeKey:
+ return component->as<Shape>();
+ break;
}
return nullptr;
}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/text/line_breaker.hpp"
-
-using namespace rive;
-
-// Return the index for the run that contains the char at textOffset
-static int _offsetToRunIndex(Span<const RenderGlyphRun> runs, size_t textOffset) {
- assert(textOffset >= 0);
- for (int i = 0; i < (int)runs.size() - 1; ++i) {
- if (textOffset <= runs[i].textOffsets.back()) {
- return i;
- }
- }
- return (int)runs.size() - 1;
-}
-
-static int textOffsetToGlyphIndex(const RenderGlyphRun& run, size_t textOffset) {
- assert(textOffset >= run.textOffsets.front());
- // assert(textOffset <= run.textOffsets.back()); // not true for last run
-
- // todo: bsearch?
- auto begin = run.textOffsets.begin();
- auto end = run.textOffsets.end();
- auto iter = std::find(begin, end, textOffset);
- if (iter == end) { // end of run
- return (int)run.glyphs.size() - 1;
- }
- return (int)(iter - begin);
-}
-
-std::vector<RenderGlyphLine> RenderGlyphLine::BreakLines(Span<const RenderGlyphRun> runs,
- Span<const int> breaks,
- float width) {
- assert(breaks.size() >= 2);
-
- std::vector<RenderGlyphLine> lines;
- int startRun = 0;
- int startIndex = 0;
- double xlimit = width;
-
- int prevRun = 0;
- int prevIndex = 0;
-
- int wordStart = breaks[0];
- int wordEnd = breaks[1];
- size_t nextBreakIndex = 2;
- int lineStartTextOffset = wordStart;
-
- for (;;) {
- assert(wordStart <= wordEnd); // == means trailing spaces?
-
- int endRun = _offsetToRunIndex(runs, wordEnd);
- int endIndex = textOffsetToGlyphIndex(runs[endRun], wordEnd);
- float pos = runs[endRun].xpos[endIndex];
- bool bumpBreakIndex = true;
- if (pos > xlimit) {
- int wsRun = _offsetToRunIndex(runs, wordStart);
- int wsIndex = textOffsetToGlyphIndex(runs[wsRun], wordStart);
-
- bumpBreakIndex = false;
- // does just one word not fit?
- if (lineStartTextOffset == wordStart) {
- // walk backwards a letter at a time until we fit, stopping at
- // 1 letter.
- int wend = wordEnd;
- while (pos > xlimit && wend - 1 > wordStart) {
- wend -= 1;
- prevRun = _offsetToRunIndex(runs, wend);
- prevIndex = textOffsetToGlyphIndex(runs[prevRun], wend);
- pos = runs[prevRun].xpos[prevIndex];
- }
- assert(wend < wordEnd || wend == wordEnd && wordStart + 1 == wordEnd);
- if (wend == wordEnd) {
- bumpBreakIndex = true;
- }
-
- // now reset our "whitespace" marker to just be prev, since
- // by defintion we have no extra whitespace on this line
- wsRun = prevRun;
- wsIndex = prevIndex;
- wordStart = wend;
- }
-
- // bulid the line
- const auto lineStartX = runs[startRun].xpos[startIndex];
- lines.push_back(RenderGlyphLine(startRun,
- startIndex,
- prevRun,
- prevIndex,
- wsRun,
- wsIndex,
- lineStartX));
-
- // update for the next line
- xlimit = runs[wsRun].xpos[wsIndex] + width;
- startRun = prevRun = wsRun;
- startIndex = prevIndex = wsIndex;
- lineStartTextOffset = wordStart;
- } else {
- // we didn't go too far, so remember this word-end boundary
- prevRun = endRun;
- prevIndex = endIndex;
- }
-
- if (bumpBreakIndex) {
- if (nextBreakIndex < breaks.size()) {
- wordStart = breaks[nextBreakIndex++];
- wordEnd = breaks[nextBreakIndex++];
- } else {
- break; // bust out of the loop
- }
- }
- }
- // scoop up the last line (if present)
- const int tailRun = (int)runs.size() - 1;
- const int tailIndex = (int)runs[tailRun].glyphs.size();
- if (startRun != tailRun || startIndex != tailIndex) {
- const auto startX = runs[startRun].xpos[startIndex];
- lines.push_back(
- RenderGlyphLine(startRun, startIndex, tailRun, tailIndex, tailRun, tailIndex, startX));
- }
-
- ComputeLineSpacing(lines, runs);
-
- return lines;
-}
-
-void RenderGlyphLine::ComputeLineSpacing(Span<RenderGlyphLine> lines,
- Span<const RenderGlyphRun> runs) {
- float Y = 0; // top of our frame
- for (auto& line : lines) {
- float asc = 0;
- float des = 0;
- for (int i = line.startRun; i <= line.wsRun; ++i) {
- const auto& run = runs[i];
-
- asc = std::min(asc, run.font->lineMetrics().ascent * run.size);
- des = std::max(des, run.font->lineMetrics().descent * run.size);
- }
- line.top = Y;
- Y -= asc;
- line.baseline = Y;
- Y += des;
- line.bottom = Y;
- }
- // TODO: good place to perform left/center/right alignment
-}
+++ /dev/null
-#!/bin/sh
-set -e
-
-source ../../../dependencies/macosx/config_directories.sh
-
-if [[ ! -f "$DEPENDENCIES/bin/premake5" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_premake5.sh
- popd
-fi
-
-if [[ ! -d "$DEPENDENCIES/sokol" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_sokol.sh
- popd
-fi
-
-if [[ ! -d "$DEPENDENCIES/earcut.hpp" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_earcut.sh
- popd
-fi
-
-if [[ ! -d "$DEPENDENCIES/libtess2" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_libtess2.sh
- popd
-fi
-
-export PREMAKE=$DEPENDENCIES/bin/premake5
-pushd ..
-
-CONFIG=debug
-GRAPHICS=gl
-TEST=false
-for var in "$@"; do
- if [[ $var = "release" ]]; then
- CONFIG=release
- fi
- if [[ $var = "gl" ]]; then
- GRAPHICS=gl
- fi
- if [[ $var = "d3d" ]]; then
- GRAPHICS=d3d
- fi
- if [[ $var = "metal" ]]; then
- GRAPHICS=metal
- fi
- if [[ $var = "test" ]]; then
- TEST=true
- fi
-done
-
-$PREMAKE --file=./premake5_tess.lua gmake2 --graphics=$GRAPHICS --with_rive_tools
-
-for var in "$@"; do
- if [[ $var = "clean" ]]; then
- make clean
- make config=release clean
- fi
-done
-
-# compile shaders
-$DEPENDENCIES/bin/sokol-shdc --input ../src/sokol/shader.glsl --output ../src/sokol/generated/shader.h --slang glsl330:hlsl5:metal_macos
-
-make config=$CONFIG -j$(($(sysctl -n hw.physicalcpu) + 1))
-
-if [[ $TEST = "true" ]]; then
- macosx/bin/$CONFIG/rive_tess_tests
-fi
-popd
+++ /dev/null
-workspace 'rive'
-configurations {'debug', 'release'}
-
-dependencies = os.getenv('DEPENDENCIES')
-
-rive = '../../'
-
-dofile(path.join(path.getabsolute(rive) .. '/build', 'premake5.lua'))
-
-project 'rive_tess_renderer'
-do
- kind 'StaticLib'
- language 'C++'
- cppdialect 'C++17'
- toolset 'clang'
- targetdir '%{cfg.system}/bin/%{cfg.buildcfg}'
- objdir '%{cfg.system}/obj/%{cfg.buildcfg}'
- includedirs {
- '../include',
- rive .. '/include',
- dependencies .. '/sokol',
- dependencies .. '/earcut.hpp/include/mapbox',
- dependencies .. '/libtess2/Include'
- }
- files {
- '../src/**.cpp',
- dependencies .. '/libtess2/Source/**.c'
- }
- buildoptions {'-Wall', '-fno-exceptions', '-fno-rtti', '-Werror=format'}
-
- filter 'configurations:debug'
- do
- buildoptions {'-g'}
- defines {'DEBUG'}
- symbols 'On'
- end
-
- filter 'configurations:release'
- do
- buildoptions {'-flto=full'}
- defines {'RELEASE', 'NDEBUG'}
- optimize 'On'
- end
-
- filter {'options:graphics=gl'}
- do
- defines {'SOKOL_GLCORE33'}
- end
-
- filter {'options:graphics=metal'}
- do
- defines {'SOKOL_METAL'}
- end
-
- filter {'options:graphics=d3d'}
- do
- defines {'SOKOL_D3D11'}
- end
-
- newoption {
- trigger = 'graphics',
- value = 'gl',
- description = 'The graphics api to use.',
- allowed = {
- {'gl'},
- {'metal'},
- {'d3d'}
- }
- }
-end
-
-project 'rive_tess_tests'
-do
- dependson 'rive_tess_renderer'
- dependson 'rive'
- kind 'ConsoleApp'
- language 'C++'
- cppdialect 'C++17'
- toolset 'clang'
- targetdir '%{cfg.system}/bin/%{cfg.buildcfg}'
- objdir '%{cfg.system}/obj/%{cfg.buildcfg}'
- includedirs {
- rive .. 'dev/test/include', -- for catch.hpp
- rive .. 'test', -- for things like rive_file_reader.hpp
- '../include',
- rive .. '/include',
- dependencies .. '/sokol',
- dependencies .. '/earcut.hpp/include/mapbox'
- }
- files {
- '../test/**.cpp',
- rive .. 'utils/no_op_factory.cpp'
- }
- links {'rive_tess_renderer', 'rive'}
- buildoptions {'-Wall', '-fno-exceptions', '-fno-rtti', '-Werror=format'}
- defines {'TESTING'}
-
- filter 'configurations:debug'
- do
- buildoptions {'-g'}
- defines {'DEBUG'}
- symbols 'On'
- end
-
- filter 'configurations:release'
- do
- buildoptions {'-flto=full'}
- defines {'RELEASE', 'NDEBUG'}
- optimize 'On'
- end
-end
+++ /dev/null
-#ifndef _RIVE_MAT4_HPP_
-#define _RIVE_MAT4_HPP_
-
-#include <cstddef>
-
-namespace rive {
-class Mat2D;
-class Mat4 {
-private:
- float m_Buffer[16];
-
-public:
- Mat4() :
- m_Buffer{
- // clang-format off
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 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
- // order.
- Mat4(
- // clang-format off
- float x1, float y1, float z1, float w1,
- float x2, float y2, float z2, float w2,
- float x3, float y3, float z3, float w3,
- float tx, float ty, float tz, float tw
- // clang-format on
- ) :
- m_Buffer{
- // clang-format off
- x1, y1, z1, w1,
- x2, y2, z2, w2,
- x3, y3, z3, w3,
- tx, ty, tz, tw,
- // clang-format on
- } {}
-
- Mat4(const Mat2D& mat2d);
-
- inline const float* values() const { return m_Buffer; }
-
- 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) {
- *this = Mat4::multiply(*this, rhs);
- return *this;
- }
-
- Mat4& operator*=(const Mat2D& rhs) {
- *this = Mat4::multiply(*this, rhs);
- return *this;
- }
-
- static Mat4 multiply(const Mat4& a, const Mat4& b);
- static Mat4 multiply(const Mat4& a, const Mat2D& b);
-};
-inline Mat4 operator*(const Mat4& a, const Mat4& b) { return Mat4::multiply(a, b); }
-inline Mat4 operator*(const Mat4& a, const Mat2D& b) { return Mat4::multiply(a, b); }
-} // namespace rive
-#endif
+++ /dev/null
-#ifndef _RIVE_CONTOUR_STROKE_HPP_
-#define _RIVE_CONTOUR_STROKE_HPP_
-
-#include "rive/renderer.hpp"
-#include "rive/math/aabb.hpp"
-#include "rive/math/mat2d.hpp"
-#include <vector>
-#include <cstdint>
-
-namespace rive {
-class SegmentedContour;
-
-///
-/// Builds a triangle strip vertex buffer from a SegmentedContour.
-///
-class ContourStroke {
-protected:
- std::vector<Vec2D> m_TriangleStrip;
- std::vector<std::size_t> m_Offsets;
- uint32_t m_RenderOffset = 0;
-
-public:
- const std::vector<Vec2D>& triangleStrip() const { return m_TriangleStrip; }
-
- void reset();
- void resetRenderOffset();
- bool nextRenderOffset(std::size_t& start, std::size_t& end);
-
- void extrude(const SegmentedContour* contour,
- bool isClosed,
- StrokeJoin join,
- StrokeCap cap,
- float strokeWidth);
-};
-} // namespace rive
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _RIVE_SEGMENTED_CONTOUR_HPP_
-#define _RIVE_SEGMENTED_CONTOUR_HPP_
-
-#include "rive/math/vec2d.hpp"
-#include "rive/math/mat2d.hpp"
-#include "rive/math/aabb.hpp"
-#include <vector>
-
-namespace rive {
-class RawPath;
-
-/// Utilty for converting a RawPath into a contour segments.
-class SegmentedContour {
-private:
- Vec2D m_pen;
- Vec2D m_penDown;
- bool m_isPenDown = false;
- std::vector<Vec2D> m_contourPoints;
-
- AABB m_bounds;
- float m_threshold;
- float m_thresholdSquared;
-
- void addVertex(Vec2D vertex);
- void penDown();
- void close();
- void segmentCubic(const Vec2D& from,
- const Vec2D& fromOut,
- const Vec2D& toIn,
- const Vec2D& to,
- float t1,
- float t2);
-
-public:
- const Span<const Vec2D> contourPoints(uint32_t endOffset = 0) const;
- const std::size_t contourSize() const;
-
- SegmentedContour(float threshold);
-
- float threshold() const;
- void threshold(float value);
- const AABB& bounds() const;
-
- void contour(const RawPath& rawPath, const Mat2D& transform);
-};
-} // namespace rive
-#endif
\ No newline at end of file
+++ /dev/null
-//
-// Copyright 2022 Rive
-//
-
-#ifndef _RIVE_SOKOL_FACTORY_HPP_
-#define _RIVE_SOKOL_FACTORY_HPP_
-
-#include "rive/factory.hpp"
-
-namespace rive {
-
-class SokolFactory : public Factory {
-
-public:
- SokolFactory();
-
- rcp<RenderBuffer> makeBufferU16(Span<const uint16_t>) override;
- rcp<RenderBuffer> makeBufferU32(Span<const uint32_t>) override;
- rcp<RenderBuffer> makeBufferF32(Span<const float>) override;
-
- rcp<RenderShader> makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- rcp<RenderShader> makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) override;
-
- // Returns a full-formed RenderPath -- can be treated as immutable
- std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule) override;
-
- std::unique_ptr<RenderPath> makeEmptyRenderPath() override;
-
- std::unique_ptr<RenderPaint> makeRenderPaint() override;
-};
-} // namespace rive
-#endif
+++ /dev/null
-//
-// Copyright 2022 Rive
-//
-
-#ifndef _RIVE_SOKOL_TESS_RENDERER_HPP_
-#define _RIVE_SOKOL_TESS_RENDERER_HPP_
-
-#include "rive/tess/tess_renderer.hpp"
-#include "sokol_gfx.h"
-
-namespace rive {
-
-class SokolRenderImage : public RenderImage {
-private:
- sg_image m_image;
- sg_buffer m_vertexBuffer;
-
-public:
- // bytes is expected to be tightly packed RGBA*width*height.
- SokolRenderImage(const uint8_t* bytes, uint32_t width, uint32_t height);
- ~SokolRenderImage() override;
-
- sg_image image() const { return m_image; }
- sg_buffer vertexBuffer() const { return m_vertexBuffer; }
-};
-
-class SokolTessRenderer : public TessRenderer {
-private:
- static const std::size_t maxClippingPaths = 16;
- sg_pipeline m_meshPipeline;
- sg_pipeline m_currentPipeline = {0};
- int m_clipCount = 0;
-
- // Src Over Pipelines
- sg_pipeline m_pathPipeline[maxClippingPaths + 1];
-
- // Screen Pipelines
- sg_pipeline m_pathScreenPipeline[maxClippingPaths + 1];
-
- // Additive
- sg_pipeline m_pathAdditivePipeline[maxClippingPaths + 1];
-
- // Multiply
- sg_pipeline m_pathMultiplyPipeline[maxClippingPaths + 1];
-
- sg_pipeline m_incClipPipeline;
- sg_pipeline m_decClipPipeline;
- sg_buffer m_boundsIndices;
- sg_buffer m_defaultUV;
-
- std::vector<SubPath> m_ClipPaths;
-
- void applyClipping();
- void setPipeline(sg_pipeline pipeline);
-
-public:
- SokolTessRenderer();
- ~SokolTessRenderer();
- void orthographicProjection(float left,
- float right,
- float bottom,
- float top,
- float near,
- float far) override;
- void drawPath(RenderPath* path, RenderPaint* paint) override;
- void drawImage(const RenderImage*, BlendMode, float opacity) override;
- void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) override;
- void restore() override;
- void reset();
-};
-} // namespace rive
-#endif
+++ /dev/null
-#ifndef _RIVE_SUB_PATH_HPP_
-#define _RIVE_SUB_PATH_HPP_
-
-#include "rive/renderer.hpp"
-#include "rive/math/mat2d.hpp"
-
-namespace rive {
-///
-/// A reference to a sub-path added to a TessRenderPath with its relative
-/// transform.
-///
-class SubPath {
-private:
- RenderPath* m_Path;
- Mat2D m_Transform;
-
-public:
- SubPath(RenderPath* path, const Mat2D& transform);
-
- RenderPath* path() const;
- const Mat2D& transform() const;
-};
-} // namespace rive
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _RIVE_TESS_RENDER_PATH_HPP_
-#define _RIVE_TESS_RENDER_PATH_HPP_
-
-#include "rive/math/raw_path.hpp"
-#include "rive/renderer.hpp"
-#include "rive/span.hpp"
-#include "rive/tess/segmented_contour.hpp"
-#include "rive/tess/sub_path.hpp"
-#include "earcut.hpp"
-
-namespace rive {
-
-class ContourStroke;
-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
- // triangulating the segmented contour).
- RawPath m_rawPath;
- FillRule m_fillRule;
-
- // We hold a reference to the segmented contour so it can reserve and
- // reuse storage when re-contouring.
- SegmentedContour m_segmentedContour;
-
- mapbox::detail::Earcut<uint16_t> m_earcut;
-
- bool m_isContourDirty = true;
- bool m_isTriangulationDirty = true;
- Mat2D m_contourTransform;
- bool m_isClosed;
-
-protected:
- std::vector<SubPath> m_subPaths;
- virtual void addTriangles(Span<const Vec2D> vertices, Span<const uint16_t> indices) = 0;
- virtual void setTriangulatedBounds(const AABB& value) = 0;
- void contour(const Mat2D& transform);
- void triangulate(TessRenderPath* containerPath);
-
-public:
- TessRenderPath();
- TessRenderPath(Span<const Vec2D> points, Span<const PathVerb> verbs, FillRule fillRule);
- ~TessRenderPath();
- void reset() override;
- void fillRule(FillRule value) override;
- bool empty() const;
-
- // In Rive a Path is used as a simple container (with no commands) when
- // it aggregates multiple paths.
- bool isContainer() const { return !m_subPaths.empty(); }
-
- void moveTo(float x, float y) override;
- void lineTo(float x, float y) override;
- void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
- void close() override;
- void addRenderPath(RenderPath* path, const Mat2D& transform) override;
-
- const SegmentedContour& segmentedContour() const;
- bool triangulate();
- void extrudeStroke(ContourStroke* stroke,
- StrokeJoin join,
- StrokeCap cap,
- float strokeWidth,
- const Mat2D& transform);
- const RawPath& rawPath() const;
-};
-} // namespace rive
-#endif
\ No newline at end of file
+++ /dev/null
-//
-// Copyright 2022 Rive
-//
-
-#ifndef _RIVE_TESS_RENDERER_HPP_
-#define _RIVE_TESS_RENDERER_HPP_
-
-#include "rive/renderer.hpp"
-#include "rive/tess/sub_path.hpp"
-#include "rive/math/mat2d.hpp"
-#include "rive/math/mat4.hpp"
-#include <vector>
-#include <list>
-
-namespace rive {
-
-struct RenderState {
- Mat2D transform;
- std::vector<SubPath> clipPaths;
-};
-
-class TessRenderer : public Renderer {
-protected:
- Mat4 m_Projection;
- std::list<RenderState> m_Stack;
- bool m_IsClippingDirty = false;
-
-public:
- TessRenderer();
-
- void projection(const Mat4& value);
- virtual void orthographicProjection(float left,
- float right,
- float bottom,
- float top,
- float near,
- float far) = 0;
-
- void save() override;
- void restore() override;
- void transform(const Mat2D& transform) override;
- const Mat2D& transform() { return m_Stack.back().transform; }
- void clipPath(RenderPath* path) override;
- void drawImage(const RenderImage*, BlendMode, float opacity) override;
- void drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) override;
-};
-} // namespace rive
-#endif
+++ /dev/null
-#include "rive/math/math_types.hpp"
-#include "rive/tess/contour_stroke.hpp"
-#include "rive/tess/segmented_contour.hpp"
-#include "rive/math/vec2d.hpp"
-#include <assert.h>
-#include <algorithm>
-
-using namespace rive;
-
-static const int subdivisionArcLength = 4.0f;
-
-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()) {
- return false;
- }
- start = m_RenderOffset == 0 ? 0 : m_Offsets[m_RenderOffset - 1];
- end = m_Offsets[m_RenderOffset++];
- return true;
-}
-
-void ContourStroke::extrude(const SegmentedContour* contour,
- bool isClosed,
- StrokeJoin join,
- StrokeCap cap,
- float strokeWidth) {
- auto contourPoints = contour->contourPoints();
- std::vector<Vec2D> points(contourPoints.begin(), contourPoints.end());
-
- auto pointCount = points.size();
- if (pointCount < 2) {
- return;
- }
- auto startOffset = m_TriangleStrip.size();
- Vec2D lastPoint = points[0];
- Vec2D lastDiff = points[1] - lastPoint;
-
- float lastLength = lastDiff.length();
- Vec2D lastDiffNormalized = lastDiff / lastLength;
-
- Vec2D perpendicularStrokeDiff =
- Vec2D(lastDiffNormalized.y * -strokeWidth, lastDiffNormalized.x * strokeWidth);
- Vec2D lastA = lastPoint + perpendicularStrokeDiff;
- Vec2D lastB = lastPoint - perpendicularStrokeDiff;
-
- if (!isClosed) {
- switch (cap) {
- case StrokeCap::square: {
- Vec2D strokeDiff = lastDiffNormalized * strokeWidth;
- Vec2D squareA = lastA - strokeDiff;
- Vec2D squareB = lastB - strokeDiff;
- m_TriangleStrip.push_back(squareA);
- m_TriangleStrip.push_back(squareB);
- break;
- }
- case StrokeCap::round: {
- Vec2D capDirection = Vec2D(-lastDiffNormalized.y, lastDiffNormalized.x);
- float arcLength = std::abs(math::PI * strokeWidth);
- int steps = (int)std::ceil(arcLength / subdivisionArcLength);
- float angleTo = std::atan2(capDirection.y, capDirection.x);
- 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++) {
- m_TriangleStrip.push_back(lastPoint);
- m_TriangleStrip.push_back(Vec2D(lastPoint.x + std::cos(angle) * strokeWidth,
- lastPoint.y + std::sin(angle) * strokeWidth));
- angle += inc;
- }
- break;
- }
- default: break;
- }
- }
- m_TriangleStrip.push_back(lastA);
- m_TriangleStrip.push_back(lastB);
-
- pointCount -= isClosed ? 1 : 0;
- std::size_t adjustedPointCount = isClosed ? pointCount + 1 : pointCount;
-
- 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) {
- diff = (next = points[(i + 1) % pointCount]) - point;
- length = diff.length();
- diffNormalized = diff / length;
- } else {
- diff = lastDiff;
- next = point;
- length = lastLength;
- diffNormalized = lastDiffNormalized;
- }
-
- // perpendicular dx
- float pdx0 = -lastDiffNormalized.y;
- float pdy0 = lastDiffNormalized.x;
- float pdx1 = -diffNormalized.y;
- float pdy1 = diffNormalized.x;
-
- // Compute bisector without a normalization by averaging perpendicular
- // diffs.
- Vec2D bisector((pdx0 + pdx1) * 0.5f, (pdy0 + pdy1) * 0.5f);
- float cross = Vec2D::cross(diff, lastDiff);
- float dot = Vec2D::dot(bisector, bisector);
-
- float lengthLimit = std::min(length, lastLength);
- bool bevelInner = false;
- bool bevel = join == StrokeJoin::miter ? dot < 0.1f : dot < 0.999f;
-
- // Scale bisector to match stroke size.
- if (dot > 0.000001f) {
- float scale = 1.0f / dot * strokeWidth;
- float limit = lengthLimit / strokeWidth;
- if (dot * limit * limit < 1.0f) {
- bevelInner = true;
- }
- bisector *= scale;
- } else {
- bisector *= strokeWidth;
- }
-
- if (!bevel) {
- Vec2D c = point + bisector;
- Vec2D d = point - bisector;
-
- if (!bevelInner) {
- // Normal mitered edge.
- m_TriangleStrip.push_back(c);
- m_TriangleStrip.push_back(d);
- } else if (cross <= 0) {
- // Overlap the inner (in this case right) edge (sometimes called
- // miter inner).
- Vec2D c1 = point + Vec2D(lastDiffNormalized.y * -strokeWidth,
- lastDiffNormalized.x * strokeWidth);
- Vec2D c2 =
- point + Vec2D(diffNormalized.y * -strokeWidth, diffNormalized.x * strokeWidth);
-
- m_TriangleStrip.push_back(c1);
- m_TriangleStrip.push_back(d);
- m_TriangleStrip.push_back(c2);
- m_TriangleStrip.push_back(d);
- } else {
- // Overlap the inner (in this case left) edge (sometimes called
- // miter inner).
- Vec2D d1 = point - Vec2D(lastDiffNormalized.y * -strokeWidth,
- lastDiffNormalized.x * strokeWidth);
- Vec2D d2 =
- point - Vec2D(diffNormalized.y * -strokeWidth, diffNormalized.x * strokeWidth);
-
- m_TriangleStrip.push_back(c);
- m_TriangleStrip.push_back(d1);
- m_TriangleStrip.push_back(c);
- m_TriangleStrip.push_back(d2);
- }
- } else {
- Vec2D ldPStroke =
- Vec2D(lastDiffNormalized.y * -strokeWidth, lastDiffNormalized.x * strokeWidth);
- Vec2D dPStroke = Vec2D(diffNormalized.y * -strokeWidth, diffNormalized.x * strokeWidth);
- if (cross <= 0) {
- // Bevel the outer (left in this case) edge.
- Vec2D a1;
- Vec2D a2;
-
- if (bevelInner) {
- a1 = point + ldPStroke;
- a2 = point + dPStroke;
- } else {
- a1 = point + bisector;
- a2 = a1;
- }
-
- Vec2D b = point - ldPStroke;
- Vec2D bn = point - dPStroke;
-
- m_TriangleStrip.push_back(a1);
- m_TriangleStrip.push_back(b);
- 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) {
- angleTo -= math::PI * 2.0f;
- }
- float range = angleTo - angleFrom;
- float arcLength = std::abs(range * strokeWidth);
- int steps = std::ceil(arcLength / subdivisionArcLength);
-
- float inc = range / steps;
- float angle = angleTo - inc;
- for (int j = 0; j < steps - 1; j++) {
- m_TriangleStrip.push_back(pivot);
- m_TriangleStrip.emplace_back(
- Vec2D(point.x + std::cos(angle) * strokeWidth,
- point.y + std::sin(angle) * strokeWidth));
-
- angle -= inc;
- }
- }
- m_TriangleStrip.push_back(a2);
- m_TriangleStrip.push_back(bn);
- } else {
- // Bevel the outer (right in this case) edge.
- Vec2D b1;
- Vec2D b2;
- if (bevelInner) {
- b1 = point - ldPStroke;
- b2 = point - dPStroke;
- } else {
- b1 = point - bisector;
- b2 = b1;
- }
-
- Vec2D a = point + ldPStroke;
- Vec2D an = point + dPStroke;
-
- m_TriangleStrip.push_back(a);
- m_TriangleStrip.push_back(b1);
-
- 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) {
- angleTo -= math::PI * 2.0f;
- }
-
- float range = angleTo - angleFrom;
- float arcLength = std::abs(range * strokeWidth);
- int steps = std::ceil(arcLength / subdivisionArcLength);
- float inc = range / steps;
-
- float angle = angleFrom + inc;
- 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));
- m_TriangleStrip.push_back(pivot);
- angle += inc;
- }
- }
- m_TriangleStrip.push_back(an);
- m_TriangleStrip.push_back(b2);
- }
- }
-
- lastPoint = point;
- lastDiff = diff;
- lastDiffNormalized = diffNormalized;
- }
-
- 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: {
- auto l = m_TriangleStrip.size();
-
- Vec2D strokeDiff = lastDiffNormalized * strokeWidth;
- Vec2D squareA = m_TriangleStrip[l - 2] + strokeDiff;
- Vec2D squareB = m_TriangleStrip[l - 1] + strokeDiff;
-
- m_TriangleStrip.push_back(squareA);
- m_TriangleStrip.push_back(squareB);
- break;
- }
- case StrokeCap::round: {
- Vec2D capDirection = Vec2D(-lastDiffNormalized.y, lastDiffNormalized.x);
- float arcLength = std::abs(math::PI * strokeWidth);
- int steps = (int)std::ceil(arcLength / subdivisionArcLength);
- float angleTo = std::atan2(capDirection.y, capDirection.x);
- 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++) {
- m_TriangleStrip.push_back(lastPoint);
- m_TriangleStrip.push_back(Vec2D(lastPoint.x + std::cos(angle) * strokeWidth,
- lastPoint.y + std::sin(angle) * strokeWidth));
- angle -= inc;
- }
- break;
- }
- default: break;
- }
- }
-
- m_Offsets.push_back(m_TriangleStrip.size());
-}
\ No newline at end of file
+++ /dev/null
-#include "rive/math/mat4.hpp"
-#include "rive/math/mat2d.hpp"
-#include <cmath>
-
-using namespace rive;
-
-Mat4::Mat4(const Mat2D& mat2d) :
- m_Buffer{
- // clang-format off
- mat2d[0], mat2d[1], 0.0f, 0.0f,
- mat2d[2], mat2d[3], 0.0f, 0.0f,
- 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) {
- return {
- // clang-format off
- b[0] * a[0] + b[1] * a[4] + b[2] * a[8] + b[3] * a[12],
- b[0] * a[1] + b[1] * a[5] + b[2] * a[9] + b[3] * a[13],
- b[0] * a[2] + b[1] * a[6] + b[2] * a[10] + b[3] * a[14],
- b[0] * a[3] + b[1] * a[7] + b[2] * a[11] + b[3] * a[15],
-
- b[4] * a[0] + b[5] * a[4] + b[6] * a[8] + b[7] * a[12],
- b[4] * a[1] + b[5] * a[5] + b[6] * a[9] + b[7] * a[13],
- b[4] * a[2] + b[5] * a[6] + b[6] * a[10] + b[7] * a[14],
- b[4] * a[3] + b[5] * a[7] + b[6] * a[11] + b[7] * a[15],
-
- b[8] * a[0] + b[9] * a[4] + b[10] * a[8] + b[11] * a[12],
- b[8] * a[1] + b[9] * a[5] + b[10] * a[9] + b[11] * a[13],
- b[8] * a[2] + b[9] * a[6] + b[10] * a[10] + b[11] * a[14],
- b[8] * a[3] + b[9] * a[7] + b[10] * a[11] + b[11] * a[15],
-
- b[12] * a[0] + b[13] * a[4] + b[14] * a[8] + b[15] * a[12],
- b[12] * a[1] + b[13] * a[5] + b[14] * a[9] + b[15] * a[13],
- b[12] * a[2] + b[13] * a[6] + b[14] * a[10] + b[15] * a[14],
- b[12] * a[3] + b[13] * a[7] + b[14] * a[11] + b[15] * a[15],
- // clang-format on
- };
-}
-
-Mat4 Mat4::multiply(const Mat4& a, const Mat2D& b) {
- return {
- // clang-format off
- b[0] * a[0] + b[1] * a[4],
- b[0] * a[1] + b[1] * a[5],
- b[0] * a[2] + b[1] * a[6],
- b[0] * a[3] + b[1] * a[7],
-
- b[2] * a[0] + b[3] * a[4],
- b[2] * a[1] + b[3] * a[5],
- b[2] * a[2] + b[3] * a[6],
- b[2] * a[3] + b[3] * a[7],
-
- a[8],
- a[9],
- a[10],
- a[11],
-
- b[4] * a[0] + b[5] * a[4] + a[12],
- b[4] * a[1] + b[5] * a[5] + a[13],
- b[4] * a[2] + b[5] * a[6] + a[14],
- b[4] * a[3] + b[5] * a[7] + a[15],
- // clang-format on
- };
-}
+++ /dev/null
-#include "rive/tess/segmented_contour.hpp"
-#include "rive/math/raw_path.hpp"
-#include "rive/math/cubic_utilities.hpp"
-
-using namespace rive;
-
-SegmentedContour::SegmentedContour(float threshold) :
- m_bounds(AABB::forExpansion()),
- m_threshold(threshold),
- m_thresholdSquared(threshold * threshold) {}
-
-float SegmentedContour::threshold() const { return m_threshold; }
-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) {
- m_contourPoints.push_back(vertex);
- AABB::expandTo(m_bounds, vertex);
-}
-
-void SegmentedContour::penDown() {
- if (m_isPenDown) {
- return;
- }
- m_isPenDown = true;
- m_penDown = m_pen;
- addVertex(m_penDown);
-}
-
-void SegmentedContour::close() {
- if (!m_isPenDown) {
- return;
- }
- m_pen = m_penDown;
- m_isPenDown = false;
-}
-
-const std::size_t SegmentedContour::contourSize() const { return m_contourPoints.size(); }
-
-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);
-}
-
-void SegmentedContour::segmentCubic(const Vec2D& from,
- const Vec2D& fromOut,
- const Vec2D& toIn,
- const Vec2D& to,
- float t1,
- float t2) {
- if (CubicUtilities::shouldSplitCubic(from, fromOut, toIn, to, m_threshold)) {
- float halfT = (t1 + t2) / 2.0f;
-
- Vec2D hull[6];
- CubicUtilities::computeHull(from, fromOut, toIn, to, 0.5f, hull);
-
- 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) {
- 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) {
- m_contourPoints.clear();
-
- RawPath::Iter iter(rawPath);
- // Possible perf consideration: could add second path that doesn't transform
- // if transform is the identity.
- while (auto rec = iter.next()) {
- switch (rec.verb) {
- case PathVerb::move:
- m_isPenDown = false;
- m_pen = transform * rec.pts[0];
- break;
- case PathVerb::line:
- penDown();
- m_pen = transform * rec.pts[0];
- addVertex(m_pen);
- break;
- case PathVerb::cubic:
- penDown();
- segmentCubic(m_pen,
- transform * rec.pts[0],
- transform * rec.pts[1],
- transform * rec.pts[2],
- 0.0f,
- 1.0f);
- m_pen = transform * rec.pts[2];
- break;
- case PathVerb::close: close(); break;
- case PathVerb::quad:
- // TODO: not currently used by render paths, however might be
- // necessary for fonts.
- break;
- }
- }
- close();
-}
+++ /dev/null
-DisableFormat: true
-SortIncludes: false
\ No newline at end of file
+++ /dev/null
-#pragma once
-/*
- #version:1# (machine generated, don't edit!)
-
- Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
-
- Cmdline: sokol-shdc --input ../src/sokol/shader.glsl --output ../src/sokol/generated/shader.h --slang glsl330:hlsl5:metal_macos
-
- Overview:
-
- Shader program 'rive_tess':
- Get shader desc: rive_tess_shader_desc(sg_query_backend());
- Vertex shader: vs
- Attribute slots:
- ATTR_vs_position = 0
- ATTR_vs_texcoord0 = 1
- Uniform block 'vs_params':
- C struct: vs_params_t
- Bind slot: SLOT_vs_params = 0
- Fragment shader: fs
- Image 'tex':
- Type: SG_IMAGETYPE_2D
- Component Type: SG_SAMPLERTYPE_FLOAT
- Bind slot: SLOT_tex = 0
-
- Shader program 'rive_tess_path':
- Get shader desc: rive_tess_path_shader_desc(sg_query_backend());
- Vertex shader: vs_path
- Attribute slots:
- ATTR_vs_path_position = 0
- Uniform block 'vs_path_params':
- C struct: vs_path_params_t
- Bind slot: SLOT_vs_path_params = 0
- Fragment shader: fs_path
- Uniform block 'fs_path_uniforms':
- C struct: fs_path_uniforms_t
- Bind slot: SLOT_fs_path_uniforms = 0
-
-
- Shader descriptor structs:
-
- sg_shader rive_tess = sg_make_shader(rive_tess_shader_desc(sg_query_backend()));
- sg_shader rive_tess_path = sg_make_shader(rive_tess_path_shader_desc(sg_query_backend()));
-
- Vertex attribute locations for vertex shader 'vs':
-
- sg_pipeline pip = sg_make_pipeline(&(sg_pipeline_desc){
- .layout = {
- .attrs = {
- [ATTR_vs_position] = { ... },
- [ATTR_vs_texcoord0] = { ... },
- },
- },
- ...});
-
- Vertex attribute locations for vertex shader 'vs_path':
-
- sg_pipeline pip = sg_make_pipeline(&(sg_pipeline_desc){
- .layout = {
- .attrs = {
- [ATTR_vs_path_position] = { ... },
- },
- },
- ...});
-
- Image bind slots, use as index in sg_bindings.vs_images[] or .fs_images[]
-
- SLOT_tex = 0;
-
- Bind slot and C-struct for uniform block 'vs_params':
-
- vs_params_t vs_params = {
- .mvp = ...;
- };
- sg_apply_uniforms(SG_SHADERSTAGE_[VS|FS], SLOT_vs_params, &SG_RANGE(vs_params));
-
- Bind slot and C-struct for uniform block 'vs_path_params':
-
- vs_path_params_t vs_path_params = {
- .mvp = ...;
- .fillType = ...;
- .gradientStart = ...;
- .gradientEnd = ...;
- };
- sg_apply_uniforms(SG_SHADERSTAGE_[VS|FS], SLOT_vs_path_params, &SG_RANGE(vs_path_params));
-
- Bind slot and C-struct for uniform block 'fs_path_uniforms':
-
- fs_path_uniforms_t fs_path_uniforms = {
- .fillType = ...;
- .colors = ...;
- .stops = ...;
- .stopCount = ...;
- };
- sg_apply_uniforms(SG_SHADERSTAGE_[VS|FS], SLOT_fs_path_uniforms, &SG_RANGE(fs_path_uniforms));
-
-*/
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stddef.h>
-#if !defined(SOKOL_SHDC_ALIGN)
- #if defined(_MSC_VER)
- #define SOKOL_SHDC_ALIGN(a) __declspec(align(a))
- #else
- #define SOKOL_SHDC_ALIGN(a) __attribute__((aligned(a)))
- #endif
-#endif
-#define ATTR_vs_position (0)
-#define ATTR_vs_texcoord0 (1)
-#define ATTR_vs_path_position (0)
-#define SLOT_tex (0)
-#define SLOT_vs_params (0)
-#pragma pack(push,1)
-SOKOL_SHDC_ALIGN(16) typedef struct vs_params_t {
- rive::Mat4 mvp;
-} vs_params_t;
-#pragma pack(pop)
-#define SLOT_vs_path_params (0)
-#pragma pack(push,1)
-SOKOL_SHDC_ALIGN(16) typedef struct vs_path_params_t {
- rive::Mat4 mvp;
- int fillType;
- uint8_t _pad_68[4];
- rive::Vec2D gradientStart;
- rive::Vec2D gradientEnd;
- uint8_t _pad_88[8];
-} vs_path_params_t;
-#pragma pack(pop)
-#define SLOT_fs_path_uniforms (0)
-#pragma pack(push,1)
-SOKOL_SHDC_ALIGN(16) typedef struct fs_path_uniforms_t {
- int fillType;
- uint8_t _pad_4[12];
- float colors[16][4];
- float stops[4][4];
- int stopCount;
- uint8_t _pad_340[12];
-} fs_path_uniforms_t;
-#pragma pack(pop)
-/*
- #version 330
-
- uniform vec4 vs_params[4];
- layout(location = 0) in vec2 position;
- out vec2 uv;
- layout(location = 1) in vec2 texcoord0;
-
- void main()
- {
- gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * vec4(position.x, position.y, 0.0, 1.0);
- uv = texcoord0;
- }
-
-*/
-static const char vs_source_glsl330[293] = {
- 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e,
- 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
- 0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
- 0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
- 0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
- 0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,
- 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,
- 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,
- 0x72,0x64,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
- 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
- 0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,
- 0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
- 0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
- 0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,
- 0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,
- 0x6f,0x6e,0x2e,0x78,0x2c,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,
- 0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,
- 0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,
- 0x0a,0x7d,0x0a,0x0a,0x00,
-};
-/*
- #version 330
-
- uniform sampler2D tex;
-
- layout(location = 0) out vec4 frag_color;
- in vec2 uv;
-
- void main()
- {
- frag_color = texture(tex, uv);
- }
-
-*/
-static const char fs_source_glsl330[146] = {
- 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e,
- 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,
- 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,
- 0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,
- 0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
- 0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,
- 0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
- 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,
- 0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x3b,0x0a,0x7d,0x0a,
- 0x0a,0x00,
-};
-/*
- #version 330
-
- struct vs_path_params
- {
- mat4 mvp;
- int fillType;
- vec2 gradientStart;
- vec2 gradientEnd;
- };
-
- uniform vs_path_params _22;
-
- layout(location = 0) in vec2 position;
- out vec2 gradient_uv;
-
- void main()
- {
- gl_Position = _22.mvp * vec4(position, 0.0, 1.0);
- if (_22.fillType == 1)
- {
- vec2 _54 = _22.gradientEnd - _22.gradientStart;
- float _59 = _54.x;
- float _64 = _54.y;
- gradient_uv.x = dot(position - _22.gradientStart, _54) / ((_59 * _59) + (_64 * _64));
- }
- else
- {
- if (_22.fillType == 2)
- {
- gradient_uv = (position - _22.gradientStart) / vec2(distance(_22.gradientStart, _22.gradientEnd));
- }
- }
- }
-
-*/
-static const char vs_path_source_glsl330[709] = {
- 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x73,0x74,
- 0x72,0x75,0x63,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x70,0x61,0x72,
- 0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x74,0x34,0x20,0x6d,
- 0x76,0x70,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x66,0x69,0x6c,0x6c,
- 0x54,0x79,0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x67,
- 0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x3b,0x0a,0x20,0x20,
- 0x20,0x20,0x76,0x65,0x63,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x45,
- 0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,
- 0x76,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x5f,
- 0x32,0x32,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
- 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
- 0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,
- 0x76,0x65,0x63,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,
- 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
- 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
- 0x20,0x3d,0x20,0x5f,0x32,0x32,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x76,0x65,0x63,
- 0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,
- 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
- 0x32,0x32,0x2e,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x31,
- 0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x76,0x65,0x63,0x32,0x20,0x5f,0x35,0x34,0x20,0x3d,0x20,0x5f,0x32,0x32,0x2e,0x67,
- 0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x45,0x6e,0x64,0x20,0x2d,0x20,0x5f,0x32,0x32,
- 0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x3b,0x0a,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,
- 0x39,0x20,0x3d,0x20,0x5f,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x5f,
- 0x35,0x34,0x2e,0x79,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x67,0x72,
- 0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x2e,0x78,0x20,0x3d,0x20,0x64,0x6f,
- 0x74,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x5f,0x32,0x32,
- 0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x2c,0x20,
- 0x5f,0x35,0x34,0x29,0x20,0x2f,0x20,0x28,0x28,0x5f,0x35,0x39,0x20,0x2a,0x20,0x5f,
- 0x35,0x39,0x29,0x20,0x2b,0x20,0x28,0x5f,0x36,0x34,0x20,0x2a,0x20,0x5f,0x36,0x34,
- 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,
- 0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x32,0x2e,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,
- 0x65,0x20,0x3d,0x3d,0x20,0x32,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x67,0x72,
- 0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x20,0x3d,0x20,0x28,0x70,0x6f,0x73,
- 0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,0x64,
- 0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x29,0x20,0x2f,0x20,0x76,0x65,0x63,
- 0x32,0x28,0x64,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x28,0x5f,0x32,0x32,0x2e,0x67,
- 0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x2c,0x20,0x5f,0x32,
- 0x32,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x45,0x6e,0x64,0x29,0x29,0x3b,
- 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,
- 0x0a,0x7d,0x0a,0x0a,0x00,
-};
-/*
- #version 330
-
- struct fs_path_uniforms
- {
- int fillType;
- vec4 colors[16];
- vec4 stops[4];
- int stopCount;
- };
-
- uniform fs_path_uniforms _18;
-
- layout(location = 0) out vec4 frag_color;
- in vec2 gradient_uv;
-
- void main()
- {
- if (_18.fillType == 0)
- {
- frag_color = _18.colors[0];
- }
- else
- {
- float _39;
- if (_18.fillType == 1)
- {
- _39 = gradient_uv.x;
- }
- else
- {
- _39 = length(gradient_uv);
- }
- vec4 color = mix(_18.colors[0], _18.colors[1], vec4(smoothstep(_18.stops[0].x, _18.stops[0].y, _39)));
- for (int i = 1; i < 15; i++)
- {
- if (i >= (_18.stopCount - 1))
- {
- break;
- }
- int _91 = i + 1;
- color = mix(color, _18.colors[_91], vec4(smoothstep(_18.stops[i / 4][i % 4], _18.stops[_91 / 4][_91 % 4], _39)));
- }
- frag_color = color;
- }
- }
-
-*/
-static const char fs_path_source_glsl330[949] = {
- 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x73,0x74,
- 0x72,0x75,0x63,0x74,0x20,0x66,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x75,0x6e,0x69,
- 0x66,0x6f,0x72,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,
- 0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,
- 0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x31,0x36,0x5d,0x3b,0x0a,0x20,
- 0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x73,0x74,0x6f,0x70,0x73,0x5b,0x34,0x5d,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x73,0x74,0x6f,0x70,0x43,0x6f,
- 0x75,0x6e,0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,
- 0x20,0x66,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,
- 0x73,0x20,0x5f,0x31,0x38,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
- 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,
- 0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
- 0x3b,0x0a,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,
- 0x6e,0x74,0x5f,0x75,0x76,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
- 0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,
- 0x38,0x2e,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x30,0x29,
- 0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
- 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x31,0x38,0x2e,
- 0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x30,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
- 0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,
- 0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
- 0x31,0x38,0x2e,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x31,
- 0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x20,0x3d,0x20,0x67,0x72,
- 0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,
- 0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x20,0x3d,0x20,
- 0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,
- 0x75,0x76,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,
- 0x72,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x5f,0x31,0x38,0x2e,0x63,0x6f,0x6c,0x6f,
- 0x72,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x5f,0x31,0x38,0x2e,0x63,0x6f,0x6c,0x6f,0x72,
- 0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x6d,0x6f,0x6f,0x74,
- 0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,0x5b,
- 0x30,0x5d,0x2e,0x78,0x2c,0x20,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,0x5b,
- 0x30,0x5d,0x2e,0x79,0x2c,0x20,0x5f,0x33,0x39,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,
- 0x20,0x3d,0x20,0x31,0x3b,0x20,0x69,0x20,0x3c,0x20,0x31,0x35,0x3b,0x20,0x69,0x2b,
- 0x2b,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x69,0x20,0x3e,
- 0x3d,0x20,0x28,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x43,0x6f,0x75,0x6e,0x74,
- 0x20,0x2d,0x20,0x31,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x62,0x72,0x65,0x61,0x6b,0x3b,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x39,0x31,0x20,0x3d,0x20,
- 0x69,0x20,0x2b,0x20,0x31,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x6d,0x69,0x78,0x28,0x63,
- 0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x5f,0x31,0x38,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x73,
- 0x5b,0x5f,0x39,0x31,0x5d,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x73,0x6d,0x6f,0x6f,
- 0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,
- 0x5b,0x69,0x20,0x2f,0x20,0x34,0x5d,0x5b,0x69,0x20,0x25,0x20,0x34,0x5d,0x2c,0x20,
- 0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,0x5b,0x5f,0x39,0x31,0x20,0x2f,0x20,
- 0x34,0x5d,0x5b,0x5f,0x39,0x31,0x20,0x25,0x20,0x34,0x5d,0x2c,0x20,0x5f,0x33,0x39,
- 0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
- 0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,
- 0x0a,0x7d,0x0a,0x0a,0x00,
-};
-/*
- cbuffer vs_params : register(b0)
- {
- row_major float4x4 _21_mvp : packoffset(c0);
- };
-
-
- static float4 gl_Position;
- static float2 position;
- static float2 uv;
- static float2 texcoord0;
-
- struct SPIRV_Cross_Input
- {
- float2 position : TEXCOORD0;
- float2 texcoord0 : TEXCOORD1;
- };
-
- struct SPIRV_Cross_Output
- {
- float2 uv : TEXCOORD0;
- float4 gl_Position : SV_Position;
- };
-
- #line 16 "../src/sokol/shader.glsl"
- void vert_main()
- {
- #line 16 "../src/sokol/shader.glsl"
- gl_Position = mul(float4(position.x, position.y, 0.0f, 1.0f), _21_mvp);
- #line 17 "../src/sokol/shader.glsl"
- uv = texcoord0;
- }
-
- SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
- {
- position = stage_input.position;
- texcoord0 = stage_input.texcoord0;
- vert_main();
- SPIRV_Cross_Output stage_output;
- stage_output.gl_Position = gl_Position;
- stage_output.uv = uv;
- return stage_output;
- }
-*/
-static const char vs_source_hlsl5[890] = {
- 0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
- 0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,
- 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,
- 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,
- 0x70,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,
- 0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
- 0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
- 0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
- 0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,
- 0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x73,0x74,
- 0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,0x65,0x78,0x63,
- 0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,
- 0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,
- 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,
- 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
- 0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,
- 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,
- 0x4f,0x52,0x44,0x31,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
- 0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,
- 0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,
- 0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,
- 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,
- 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,
- 0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,
- 0x20,0x31,0x36,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,
- 0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,
- 0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,
- 0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x2e,0x2e,0x2f,0x73,
- 0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,
- 0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
- 0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,0x6f,0x61,
- 0x74,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x2c,0x20,0x70,
- 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x2c,0x20,0x30,0x2e,0x30,0x66,0x2c,
- 0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x32,0x31,0x5f,0x6d,0x76,0x70,0x29,
- 0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x2e,0x2e,0x2f,0x73,
- 0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,
- 0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,
- 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,
- 0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,
- 0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
- 0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,
- 0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,
- 0x6f,0x6e,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,
- 0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x74,
- 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,
- 0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,
- 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
- 0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
- 0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,
- 0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
- 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
- 0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,
- 0x74,0x70,0x75,0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x75,0x76,0x3b,0x0a,0x20,0x20,
- 0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
- 0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
-};
-/*
- Texture2D<float4> tex : register(t0);
- SamplerState _tex_sampler : register(s0);
-
- static float4 frag_color;
- static float2 uv;
-
- struct SPIRV_Cross_Input
- {
- float2 uv : TEXCOORD0;
- };
-
- struct SPIRV_Cross_Output
- {
- float4 frag_color : SV_Target0;
- };
-
- #line 12 "../src/sokol/shader.glsl"
- void frag_main()
- {
- #line 12 "../src/sokol/shader.glsl"
- frag_color = tex.Sample(_tex_sampler, uv);
- }
-
- SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
- {
- uv = stage_input.uv;
- frag_main();
- SPIRV_Cross_Output stage_output;
- stage_output.frag_color = frag_color;
- return stage_output;
- }
-*/
-static const char fs_source_hlsl5[599] = {
- 0x54,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x34,
- 0x3e,0x20,0x74,0x65,0x78,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,
- 0x28,0x74,0x30,0x29,0x3b,0x0a,0x53,0x61,0x6d,0x70,0x6c,0x65,0x72,0x53,0x74,0x61,
- 0x74,0x65,0x20,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,
- 0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x73,0x30,0x29,0x3b,0x0a,
- 0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,
- 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,
- 0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,0x76,0x3b,0x0a,0x0a,0x73,0x74,
- 0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,
- 0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
- 0x61,0x74,0x32,0x20,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,
- 0x44,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,
- 0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,
- 0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,
- 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x53,0x56,0x5f,0x54,
- 0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,
- 0x65,0x20,0x31,0x32,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,
- 0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,
- 0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
- 0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x32,0x20,0x22,0x2e,0x2e,0x2f,
- 0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,
- 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
- 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x53,0x61,0x6d,0x70,
- 0x6c,0x65,0x28,0x5f,0x74,0x65,0x78,0x5f,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x2c,
- 0x20,0x75,0x76,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
- 0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
- 0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,
- 0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,
- 0x7b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,
- 0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
- 0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
- 0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,
- 0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,
- 0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,
- 0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,
- 0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,
- 0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,
- 0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
-};
-/*
- cbuffer vs_path_params : register(b0)
- {
- row_major float4x4 _22_mvp : packoffset(c0);
- int _22_fillType : packoffset(c4);
- float2 _22_gradientStart : packoffset(c4.z);
- float2 _22_gradientEnd : packoffset(c5);
- };
-
-
- static float4 gl_Position;
- static float2 position;
- static float2 gradient_uv;
-
- struct SPIRV_Cross_Input
- {
- float2 position : TEXCOORD0;
- };
-
- struct SPIRV_Cross_Output
- {
- float2 gradient_uv : TEXCOORD0;
- float4 gl_Position : SV_Position;
- };
-
- #line 17 "../src/sokol/shader.glsl"
- void vert_main()
- {
- #line 17 "../src/sokol/shader.glsl"
- gl_Position = mul(float4(position, 0.0f, 1.0f), _22_mvp);
- #line 19 "../src/sokol/shader.glsl"
- if (_22_fillType == 1)
- {
- #line 21 "../src/sokol/shader.glsl"
- float2 _54 = _22_gradientEnd - _22_gradientStart;
- #line 22 "../src/sokol/shader.glsl"
- float _59 = _54.x;
- float _64 = _54.y;
- #line 23 "../src/sokol/shader.glsl"
- gradient_uv.x = dot(position - _22_gradientStart, _54) / ((_59 * _59) + (_64 * _64));
- }
- else
- {
- #line 25 "../src/sokol/shader.glsl"
- if (_22_fillType == 2)
- {
- #line 27 "../src/sokol/shader.glsl"
- gradient_uv = (position - _22_gradientStart) / distance(_22_gradientStart, _22_gradientEnd).xx;
- }
- }
- }
-
- SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
- {
- position = stage_input.position;
- vert_main();
- SPIRV_Cross_Output stage_output;
- stage_output.gl_Position = gl_Position;
- stage_output.gradient_uv = gradient_uv;
- return stage_output;
- }
-*/
-static const char vs_path_source_hlsl5[1537] = {
- 0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,
- 0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,
- 0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x72,0x6f,0x77,0x5f,
- 0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x5f,
- 0x32,0x32,0x5f,0x6d,0x76,0x70,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,
- 0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,
- 0x20,0x5f,0x32,0x32,0x5f,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3a,0x20,
- 0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x34,0x29,0x3b,0x0a,
- 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x32,0x32,0x5f,0x67,
- 0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x20,0x3a,0x20,0x70,
- 0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x34,0x2e,0x7a,0x29,0x3b,
- 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x32,0x32,0x5f,
- 0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x45,0x6e,0x64,0x20,0x3a,0x20,0x70,0x61,
- 0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x35,0x29,0x3b,0x0a,0x7d,0x3b,
- 0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
- 0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,
- 0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,
- 0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,
- 0x61,0x74,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x3b,
- 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
- 0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
- 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
- 0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x7d,0x3b,
- 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
- 0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
- 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,
- 0x74,0x5f,0x75,0x76,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,
- 0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,
- 0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,
- 0x65,0x20,0x31,0x37,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,
- 0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,
- 0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
- 0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x2e,0x2e,0x2f,
- 0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,
- 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
- 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x75,0x6c,0x28,0x66,0x6c,0x6f,
- 0x61,0x74,0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,
- 0x30,0x66,0x2c,0x20,0x31,0x2e,0x30,0x66,0x29,0x2c,0x20,0x5f,0x32,0x32,0x5f,0x6d,
- 0x76,0x70,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x39,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
- 0x28,0x5f,0x32,0x32,0x5f,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,
- 0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
- 0x32,0x31,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,
- 0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x5f,0x35,0x34,
- 0x20,0x3d,0x20,0x5f,0x32,0x32,0x5f,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x45,
- 0x6e,0x64,0x20,0x2d,0x20,0x5f,0x32,0x32,0x5f,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,
- 0x74,0x53,0x74,0x61,0x72,0x74,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x32,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x39,0x20,0x3d,0x20,
- 0x5f,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x5f,0x35,0x34,0x2e,0x79,
- 0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x33,0x20,0x22,0x2e,0x2e,0x2f,0x73,
- 0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,
- 0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x67,0x72,
- 0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x2e,0x78,0x20,0x3d,0x20,0x64,0x6f,
- 0x74,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x5f,0x32,0x32,
- 0x5f,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x2c,0x20,
- 0x5f,0x35,0x34,0x29,0x20,0x2f,0x20,0x28,0x28,0x5f,0x35,0x39,0x20,0x2a,0x20,0x5f,
- 0x35,0x39,0x29,0x20,0x2b,0x20,0x28,0x5f,0x36,0x34,0x20,0x2a,0x20,0x5f,0x36,0x34,
- 0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,
- 0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,
- 0x35,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,
- 0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x32,0x32,0x5f,0x66,0x69,0x6c,
- 0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x32,0x29,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x37,0x20,0x22,
- 0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,
- 0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,
- 0x76,0x20,0x3d,0x20,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,
- 0x5f,0x32,0x32,0x5f,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,
- 0x74,0x29,0x20,0x2f,0x20,0x64,0x69,0x73,0x74,0x61,0x6e,0x63,0x65,0x28,0x5f,0x32,
- 0x32,0x5f,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x2c,
- 0x20,0x5f,0x32,0x32,0x5f,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x45,0x6e,0x64,
- 0x29,0x2e,0x78,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,
- 0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
- 0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,
- 0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,
- 0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,
- 0x7b,0x0a,0x20,0x20,0x20,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,
- 0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x70,0x6f,0x73,
- 0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,
- 0x6d,0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,
- 0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,
- 0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,
- 0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,
- 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,
- 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,
- 0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,
- 0x6e,0x74,0x5f,0x75,0x76,0x20,0x3d,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,
- 0x5f,0x75,0x76,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
- 0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
- 0x00,
-};
-/*
- cbuffer fs_path_uniforms : register(b0)
- {
- int _18_fillType : packoffset(c0);
- float4 _18_colors[16] : packoffset(c1);
- float4 _18_stops[4] : packoffset(c17);
- int _18_stopCount : packoffset(c21);
- };
-
-
- static float4 frag_color;
- static float2 gradient_uv;
-
- struct SPIRV_Cross_Input
- {
- float2 gradient_uv : TEXCOORD0;
- };
-
- struct SPIRV_Cross_Output
- {
- float4 frag_color : SV_Target0;
- };
-
- #line 18 "../src/sokol/shader.glsl"
- void frag_main()
- {
- #line 18 "../src/sokol/shader.glsl"
- if (_18_fillType == 0)
- {
- #line 20 "../src/sokol/shader.glsl"
- frag_color = _18_colors[0];
- }
- else
- {
- #line 23 "../src/sokol/shader.glsl"
- float _39;
- if (_18_fillType == 1)
- {
- _39 = gradient_uv.x;
- }
- else
- {
- _39 = length(gradient_uv);
- }
- #line 24 "../src/sokol/shader.glsl"
- #line 25 "../src/sokol/shader.glsl"
- float4 color = lerp(_18_colors[0], _18_colors[1], smoothstep(_18_stops[0].x, _18_stops[0].y, _39).xxxx);
- #line 26 "../src/sokol/shader.glsl"
- for (int i = 1; i < 15; i++)
- {
- #line 28 "../src/sokol/shader.glsl"
- if (i >= (_18_stopCount - 1))
- {
- #line 30 "../src/sokol/shader.glsl"
- break;
- }
- #line 33 "../src/sokol/shader.glsl"
- #line 35 "../src/sokol/shader.glsl"
- #line 34 "../src/sokol/shader.glsl"
- int _91 = i + 1;
- #line 35 "../src/sokol/shader.glsl"
- color = lerp(color, _18_colors[_91], smoothstep(_18_stops[i / 4][i % 4], _18_stops[_91 / 4][_91 % 4], _39).xxxx);
- }
- #line 37 "../src/sokol/shader.glsl"
- frag_color = color;
- }
- }
-
- SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
- {
- gradient_uv = stage_input.gradient_uv;
- frag_main();
- SPIRV_Cross_Output stage_output;
- stage_output.frag_color = frag_color;
- return stage_output;
- }
-*/
-static const char fs_path_source_hlsl5[1870] = {
- 0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x66,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,
- 0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,
- 0x74,0x65,0x72,0x28,0x62,0x30,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,
- 0x74,0x20,0x5f,0x31,0x38,0x5f,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3a,
- 0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,
- 0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x38,0x5f,
- 0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x31,0x36,0x5d,0x20,0x3a,0x20,0x70,0x61,0x63,
- 0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x31,0x29,0x3b,0x0a,0x20,0x20,0x20,
- 0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x31,0x38,0x5f,0x73,0x74,0x6f,0x70,
- 0x73,0x5b,0x34,0x5d,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,
- 0x74,0x28,0x63,0x31,0x37,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,
- 0x5f,0x31,0x38,0x5f,0x73,0x74,0x6f,0x70,0x43,0x6f,0x75,0x6e,0x74,0x20,0x3a,0x20,
- 0x70,0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x32,0x31,0x29,0x3b,
- 0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,
- 0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
- 0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x67,0x72,
- 0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
- 0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,
- 0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,
- 0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x20,0x3a,0x20,
- 0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,
- 0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
- 0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
- 0x20,0x3a,0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,
- 0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x2e,0x2e,0x2f,
- 0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,
- 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,
- 0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
- 0x31,0x38,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,
- 0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,
- 0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x38,0x5f,0x66,0x69,0x6c,0x6c,0x54,0x79,
- 0x70,0x65,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,
- 0x6c,0x69,0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,
- 0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,
- 0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,
- 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x31,0x38,0x5f,0x63,0x6f,0x6c,0x6f,
- 0x72,0x73,0x5b,0x30,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,
- 0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,
- 0x65,0x20,0x32,0x33,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,
- 0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,
- 0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,
- 0x31,0x38,0x5f,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x31,
- 0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x20,0x3d,0x20,0x67,0x72,
- 0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,
- 0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x20,0x3d,0x20,
- 0x6c,0x65,0x6e,0x67,0x74,0x68,0x28,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,
- 0x75,0x76,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x23,
- 0x6c,0x69,0x6e,0x65,0x20,0x32,0x34,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,
- 0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,
- 0x6c,0x22,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x35,0x20,0x22,0x2e,0x2e,0x2f,
- 0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,
- 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x6c,0x65,
- 0x72,0x70,0x28,0x5f,0x31,0x38,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x30,0x5d,
- 0x2c,0x20,0x5f,0x31,0x38,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x31,0x5d,0x2c,
- 0x20,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x38,0x5f,
- 0x73,0x74,0x6f,0x70,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,0x20,0x5f,0x31,0x38,0x5f,
- 0x73,0x74,0x6f,0x70,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x2c,0x20,0x5f,0x33,0x39,0x29,
- 0x2e,0x78,0x78,0x78,0x78,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x36,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x20,0x3d,
- 0x20,0x31,0x3b,0x20,0x69,0x20,0x3c,0x20,0x31,0x35,0x3b,0x20,0x69,0x2b,0x2b,0x29,
- 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,
- 0x20,0x32,0x38,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,
- 0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x69,
- 0x20,0x3e,0x3d,0x20,0x28,0x5f,0x31,0x38,0x5f,0x73,0x74,0x6f,0x70,0x43,0x6f,0x75,
- 0x6e,0x74,0x20,0x2d,0x20,0x31,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x30,0x20,
- 0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,
- 0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x72,0x65,0x61,0x6b,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,
- 0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x33,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,
- 0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,
- 0x73,0x6c,0x22,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x35,0x20,0x22,0x2e,0x2e,
- 0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,
- 0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x34,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x39,0x31,0x20,
- 0x3d,0x20,0x69,0x20,0x2b,0x20,0x31,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,
- 0x35,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,
- 0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
- 0x20,0x6c,0x65,0x72,0x70,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x5f,0x31,0x38,
- 0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x5f,0x39,0x31,0x5d,0x2c,0x20,0x73,0x6d,
- 0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,0x5f,0x31,0x38,0x5f,0x73,0x74,0x6f,
- 0x70,0x73,0x5b,0x69,0x20,0x2f,0x20,0x34,0x5d,0x5b,0x69,0x20,0x25,0x20,0x34,0x5d,
- 0x2c,0x20,0x5f,0x31,0x38,0x5f,0x73,0x74,0x6f,0x70,0x73,0x5b,0x5f,0x39,0x31,0x20,
- 0x2f,0x20,0x34,0x5d,0x5b,0x5f,0x39,0x31,0x20,0x25,0x20,0x34,0x5d,0x2c,0x20,0x5f,
- 0x33,0x39,0x29,0x2e,0x78,0x78,0x78,0x78,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x7d,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x37,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,
- 0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x7d,0x0a,0x0a,0x53,0x50,
- 0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,
- 0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
- 0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
- 0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x72,0x61,0x64,0x69,
- 0x65,0x6e,0x74,0x5f,0x75,0x76,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
- 0x6e,0x70,0x75,0x74,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,
- 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
- 0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
- 0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,
- 0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
- 0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,0x61,
- 0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
-};
-/*
- #include <metal_stdlib>
- #include <simd/simd.h>
-
- using namespace metal;
-
- struct vs_params
- {
- float4x4 mvp;
- };
-
- struct main0_out
- {
- float2 uv [[user(locn0)]];
- float4 gl_Position [[position]];
- };
-
- struct main0_in
- {
- float2 position [[attribute(0)]];
- float2 texcoord0 [[attribute(1)]];
- };
-
- #line 16 "../src/sokol/shader.glsl"
- vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _21 [[buffer(0)]])
- {
- main0_out out = {};
- #line 16 "../src/sokol/shader.glsl"
- out.gl_Position = _21.mvp * float4(in.position.x, in.position.y, 0.0, 1.0);
- #line 17 "../src/sokol/shader.glsl"
- out.uv = in.texcoord0;
- return out;
- }
-
-*/
-static const char vs_source_metal_macos[652] = {
- 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
- 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
- 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
- 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
- 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76,
- 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a,
- 0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,
- 0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x75,
- 0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,
- 0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,
- 0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,
- 0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,
- 0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,
- 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
- 0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,
- 0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x74,
- 0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,
- 0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,
- 0x6c,0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,
- 0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,
- 0x6c,0x22,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
- 0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,
- 0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
- 0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,
- 0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x31,0x20,0x5b,0x5b,0x62,0x75,
- 0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
- 0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
- 0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x36,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
- 0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,
- 0x32,0x31,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
- 0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x2c,0x20,0x69,
- 0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x79,0x2c,0x20,0x30,0x2e,
- 0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,
- 0x37,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,
- 0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,
- 0x20,0x6f,0x75,0x74,0x2e,0x75,0x76,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x74,0x65,0x78,
- 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,
- 0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
-};
-/*
- #include <metal_stdlib>
- #include <simd/simd.h>
-
- using namespace metal;
-
- struct main0_out
- {
- float4 frag_color [[color(0)]];
- };
-
- struct main0_in
- {
- float2 uv [[user(locn0)]];
- };
-
- #line 12 "../src/sokol/shader.glsl"
- fragment main0_out main0(main0_in in [[stage_in]], texture2d<float> tex [[texture(0)]], sampler texSmplr [[sampler(0)]])
- {
- main0_out out = {};
- #line 12 "../src/sokol/shader.glsl"
- out.frag_color = tex.sample(texSmplr, in.uv);
- return out;
- }
-
-*/
-static const char fs_source_metal_macos[473] = {
- 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
- 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
- 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
- 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
- 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,
- 0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
- 0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
- 0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
- 0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
- 0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,
- 0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x32,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x66,0x72,0x61,0x67,
- 0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,
- 0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,
- 0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x74,
- 0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,
- 0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x30,0x29,
- 0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x65,0x78,0x53,
- 0x6d,0x70,0x6c,0x72,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x28,0x30,
- 0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,
- 0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,
- 0x6c,0x69,0x6e,0x65,0x20,0x31,0x32,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,
- 0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,
- 0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,
- 0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x2e,0x73,0x61,0x6d,0x70,
- 0x6c,0x65,0x28,0x74,0x65,0x78,0x53,0x6d,0x70,0x6c,0x72,0x2c,0x20,0x69,0x6e,0x2e,
- 0x75,0x76,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
- 0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
-};
-/*
- #include <metal_stdlib>
- #include <simd/simd.h>
-
- using namespace metal;
-
- struct vs_path_params
- {
- float4x4 mvp;
- int fillType;
- float2 gradientStart;
- float2 gradientEnd;
- };
-
- struct main0_out
- {
- float2 gradient_uv [[user(locn0)]];
- float4 gl_Position [[position]];
- };
-
- struct main0_in
- {
- float2 position [[attribute(0)]];
- };
-
- #line 17 "../src/sokol/shader.glsl"
- vertex main0_out main0(main0_in in [[stage_in]], constant vs_path_params& _22 [[buffer(0)]])
- {
- main0_out out = {};
- #line 17 "../src/sokol/shader.glsl"
- out.gl_Position = _22.mvp * float4(in.position, 0.0, 1.0);
- #line 19 "../src/sokol/shader.glsl"
- if (_22.fillType == 1)
- {
- #line 21 "../src/sokol/shader.glsl"
- float2 _54 = _22.gradientEnd - _22.gradientStart;
- #line 22 "../src/sokol/shader.glsl"
- float _59 = _54.x;
- float _64 = _54.y;
- #line 23 "../src/sokol/shader.glsl"
- out.gradient_uv.x = dot(in.position - _22.gradientStart, _54) / ((_59 * _59) + (_64 * _64));
- }
- else
- {
- #line 25 "../src/sokol/shader.glsl"
- if (_22.fillType == 2)
- {
- #line 27 "../src/sokol/shader.glsl"
- out.gradient_uv = (in.position - _22.gradientStart) / float2(distance(_22.gradientStart, _22.gradientEnd));
- }
- }
- return out;
- }
-
-*/
-static const char vs_path_source_metal_macos[1280] = {
- 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
- 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
- 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
- 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
- 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76,
- 0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,
- 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,
- 0x3b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x66,0x69,0x6c,0x6c,0x54,0x79,
- 0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x67,
- 0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x3b,0x0a,0x20,0x20,
- 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,
- 0x74,0x45,0x6e,0x64,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
- 0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,
- 0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,
- 0x5f,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,
- 0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
- 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x70,0x6f,
- 0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,
- 0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,
- 0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,
- 0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,
- 0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
- 0x31,0x37,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,
- 0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x76,0x65,
- 0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,
- 0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,
- 0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,
- 0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,
- 0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x32,0x20,0x5b,0x5b,0x62,0x75,
- 0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
- 0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
- 0x20,0x7b,0x7d,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x37,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
- 0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x5f,
- 0x32,0x32,0x2e,0x6d,0x76,0x70,0x20,0x2a,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,
- 0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,
- 0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x39,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
- 0x69,0x66,0x20,0x28,0x5f,0x32,0x32,0x2e,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,
- 0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,
- 0x6e,0x65,0x20,0x32,0x31,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,
- 0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,
- 0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,
- 0x5f,0x35,0x34,0x20,0x3d,0x20,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,
- 0x6e,0x74,0x45,0x6e,0x64,0x20,0x2d,0x20,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,0x64,
- 0x69,0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,
- 0x20,0x32,0x32,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,
- 0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x35,0x39,
- 0x20,0x3d,0x20,0x5f,0x35,0x34,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x36,0x34,0x20,0x3d,0x20,0x5f,0x35,
- 0x34,0x2e,0x79,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x33,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x6f,0x75,0x74,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,
- 0x2e,0x78,0x20,0x3d,0x20,0x64,0x6f,0x74,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,
- 0x74,0x69,0x6f,0x6e,0x20,0x2d,0x20,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,0x64,0x69,
- 0x65,0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x2c,0x20,0x5f,0x35,0x34,0x29,0x20,0x2f,
- 0x20,0x28,0x28,0x5f,0x35,0x39,0x20,0x2a,0x20,0x5f,0x35,0x39,0x29,0x20,0x2b,0x20,
- 0x28,0x5f,0x36,0x34,0x20,0x2a,0x20,0x5f,0x36,0x34,0x29,0x29,0x3b,0x0a,0x20,0x20,
- 0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,
- 0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x35,0x20,0x22,0x2e,0x2e,0x2f,
- 0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,
- 0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,
- 0x66,0x20,0x28,0x5f,0x32,0x32,0x2e,0x66,0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,
- 0x3d,0x3d,0x20,0x32,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,
- 0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x37,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,
- 0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,
- 0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x6f,0x75,0x74,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x20,
- 0x3d,0x20,0x28,0x69,0x6e,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2d,
- 0x20,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x53,0x74,0x61,
- 0x72,0x74,0x29,0x20,0x2f,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x64,0x69,0x73,
- 0x74,0x61,0x6e,0x63,0x65,0x28,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,
- 0x6e,0x74,0x53,0x74,0x61,0x72,0x74,0x2c,0x20,0x5f,0x32,0x32,0x2e,0x67,0x72,0x61,
- 0x64,0x69,0x65,0x6e,0x74,0x45,0x6e,0x64,0x29,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,
- 0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
-
-};
-/*
- #include <metal_stdlib>
- #include <simd/simd.h>
-
- using namespace metal;
-
- struct fs_path_uniforms
- {
- int fillType;
- float4 colors[16];
- float4 stops[4];
- int stopCount;
- };
-
- struct main0_out
- {
- float4 frag_color [[color(0)]];
- };
-
- struct main0_in
- {
- float2 gradient_uv [[user(locn0)]];
- };
-
- #line 18 "../src/sokol/shader.glsl"
- fragment main0_out main0(main0_in in [[stage_in]], constant fs_path_uniforms& _18 [[buffer(0)]])
- {
- main0_out out = {};
- #line 18 "../src/sokol/shader.glsl"
- if (_18.fillType == 0)
- {
- #line 20 "../src/sokol/shader.glsl"
- out.frag_color = _18.colors[0];
- }
- else
- {
- #line 23 "../src/sokol/shader.glsl"
- float _39;
- if (_18.fillType == 1)
- {
- _39 = in.gradient_uv.x;
- }
- else
- {
- _39 = length(in.gradient_uv);
- }
- #line 24 "../src/sokol/shader.glsl"
- #line 25 "../src/sokol/shader.glsl"
- float4 color = mix(_18.colors[0], _18.colors[1], float4(smoothstep(_18.stops[0].x, _18.stops[0].y, _39)));
- #line 26 "../src/sokol/shader.glsl"
- for (int i = 1; i < 15; i++)
- {
- #line 28 "../src/sokol/shader.glsl"
- if (i >= (_18.stopCount - 1))
- {
- #line 30 "../src/sokol/shader.glsl"
- break;
- }
- #line 33 "../src/sokol/shader.glsl"
- #line 35 "../src/sokol/shader.glsl"
- #line 34 "../src/sokol/shader.glsl"
- int _91 = i + 1;
- #line 35 "../src/sokol/shader.glsl"
- color = mix(color, _18.colors[_91], float4(smoothstep(_18.stops[i / 4][i % 4], _18.stops[_91 / 4][_91 % 4], _39)));
- }
- #line 37 "../src/sokol/shader.glsl"
- out.frag_color = color;
- }
- return out;
- }
-
-*/
-static const char fs_path_source_metal_macos[1686] = {
- 0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
- 0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
- 0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
- 0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
- 0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x66,
- 0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x73,0x0a,
- 0x7b,0x0a,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x66,0x69,0x6c,0x6c,0x54,0x79,
- 0x70,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
- 0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x31,0x36,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x34,0x20,0x73,0x74,0x6f,0x70,0x73,0x5b,0x34,0x5d,0x3b,0x0a,
- 0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x73,0x74,0x6f,0x70,0x43,0x6f,0x75,0x6e,
- 0x74,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,
- 0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,
- 0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
- 0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,
- 0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,
- 0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x32,0x20,0x67,
- 0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,0x76,0x20,0x5b,0x5b,0x75,0x73,0x65,
- 0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,
- 0x23,0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,
- 0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,
- 0x73,0x6c,0x22,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,
- 0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,
- 0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,
- 0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,
- 0x66,0x73,0x5f,0x70,0x61,0x74,0x68,0x5f,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x73,
- 0x26,0x20,0x5f,0x31,0x38,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,
- 0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,
- 0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x23,
- 0x6c,0x69,0x6e,0x65,0x20,0x31,0x38,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,
- 0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,
- 0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x38,0x2e,0x66,
- 0x69,0x6c,0x6c,0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x30,0x29,0x0a,0x20,0x20,
- 0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x30,0x20,0x22,0x2e,0x2e,
- 0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,
- 0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
- 0x20,0x5f,0x31,0x38,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x30,0x5d,0x3b,0x0a,
- 0x20,0x20,0x20,0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,0x20,
- 0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x33,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x39,0x3b,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,0x5f,0x31,0x38,0x2e,0x66,0x69,0x6c,0x6c,
- 0x54,0x79,0x70,0x65,0x20,0x3d,0x3d,0x20,0x31,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x5f,0x33,0x39,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,
- 0x6e,0x74,0x5f,0x75,0x76,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x7d,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x65,0x6c,0x73,0x65,0x0a,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x5f,0x33,0x39,0x20,0x3d,0x20,0x6c,0x65,0x6e,0x67,
- 0x74,0x68,0x28,0x69,0x6e,0x2e,0x67,0x72,0x61,0x64,0x69,0x65,0x6e,0x74,0x5f,0x75,
- 0x76,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x23,0x6c,
- 0x69,0x6e,0x65,0x20,0x32,0x34,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,
- 0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,
- 0x22,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,0x35,0x20,0x22,0x2e,0x2e,0x2f,0x73,
- 0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,
- 0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6c,
- 0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x6d,0x69,0x78,
- 0x28,0x5f,0x31,0x38,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x30,0x5d,0x2c,0x20,
- 0x5f,0x31,0x38,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x66,
- 0x6c,0x6f,0x61,0x74,0x34,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,
- 0x28,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x2c,
- 0x20,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,0x5b,0x30,0x5d,0x2e,0x79,0x2c,
- 0x20,0x5f,0x33,0x39,0x29,0x29,0x29,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x32,
- 0x36,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,
- 0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x20,
- 0x3d,0x20,0x31,0x3b,0x20,0x69,0x20,0x3c,0x20,0x31,0x35,0x3b,0x20,0x69,0x2b,0x2b,
- 0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,
- 0x65,0x20,0x32,0x38,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,
- 0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x28,
- 0x69,0x20,0x3e,0x3d,0x20,0x28,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x43,0x6f,
- 0x75,0x6e,0x74,0x20,0x2d,0x20,0x31,0x29,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x7b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x30,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x72,0x65,0x61,
- 0x6b,0x3b,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,
- 0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x33,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,
- 0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,
- 0x6c,0x73,0x6c,0x22,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x35,0x20,0x22,0x2e,
- 0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,0x68,0x61,0x64,
- 0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,
- 0x34,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,
- 0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x6e,0x74,0x20,0x5f,0x39,0x31,
- 0x20,0x3d,0x20,0x69,0x20,0x2b,0x20,0x31,0x3b,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,
- 0x33,0x35,0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,
- 0x2f,0x73,0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,
- 0x3d,0x20,0x6d,0x69,0x78,0x28,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x5f,0x31,0x38,
- 0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x73,0x5b,0x5f,0x39,0x31,0x5d,0x2c,0x20,0x66,0x6c,
- 0x6f,0x61,0x74,0x34,0x28,0x73,0x6d,0x6f,0x6f,0x74,0x68,0x73,0x74,0x65,0x70,0x28,
- 0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,0x70,0x73,0x5b,0x69,0x20,0x2f,0x20,0x34,0x5d,
- 0x5b,0x69,0x20,0x25,0x20,0x34,0x5d,0x2c,0x20,0x5f,0x31,0x38,0x2e,0x73,0x74,0x6f,
- 0x70,0x73,0x5b,0x5f,0x39,0x31,0x20,0x2f,0x20,0x34,0x5d,0x5b,0x5f,0x39,0x31,0x20,
- 0x25,0x20,0x34,0x5d,0x2c,0x20,0x5f,0x33,0x39,0x29,0x29,0x29,0x3b,0x0a,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x20,0x20,0x7d,0x0a,0x23,0x6c,0x69,0x6e,0x65,0x20,0x33,0x37,
- 0x20,0x22,0x2e,0x2e,0x2f,0x73,0x72,0x63,0x2f,0x73,0x6f,0x6b,0x6f,0x6c,0x2f,0x73,
- 0x68,0x61,0x64,0x65,0x72,0x2e,0x67,0x6c,0x73,0x6c,0x22,0x0a,0x20,0x20,0x20,0x20,
- 0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
- 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,
- 0x7d,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
- 0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
-};
-#if !defined(SOKOL_GFX_INCLUDED)
- #error "Please include sokol_gfx.h before shader.h"
-#endif
-static inline const sg_shader_desc* rive_tess_shader_desc(sg_backend backend) {
- if (backend == SG_BACKEND_GLCORE33) {
- static sg_shader_desc desc;
- static bool valid;
- if (!valid) {
- valid = true;
- desc.attrs[0].name = "position";
- desc.attrs[1].name = "texcoord0";
- desc.vs.source = vs_source_glsl330;
- desc.vs.entry = "main";
- desc.vs.uniform_blocks[0].size = 64;
- desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
- desc.vs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_FLOAT4;
- desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
- desc.fs.source = fs_source_glsl330;
- desc.fs.entry = "main";
- desc.fs.images[0].name = "tex";
- desc.fs.images[0].image_type = SG_IMAGETYPE_2D;
- desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT;
- desc.label = "rive_tess_shader";
- }
- return &desc;
- }
- if (backend == SG_BACKEND_D3D11) {
- static sg_shader_desc desc;
- static bool valid;
- if (!valid) {
- valid = true;
- desc.attrs[0].sem_name = "TEXCOORD";
- desc.attrs[0].sem_index = 0;
- desc.attrs[1].sem_name = "TEXCOORD";
- desc.attrs[1].sem_index = 1;
- desc.vs.source = vs_source_hlsl5;
- desc.vs.d3d11_target = "vs_5_0";
- desc.vs.entry = "main";
- desc.vs.uniform_blocks[0].size = 64;
- desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.fs.source = fs_source_hlsl5;
- desc.fs.d3d11_target = "ps_5_0";
- desc.fs.entry = "main";
- desc.fs.images[0].name = "tex";
- desc.fs.images[0].image_type = SG_IMAGETYPE_2D;
- desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT;
- desc.label = "rive_tess_shader";
- }
- return &desc;
- }
- if (backend == SG_BACKEND_METAL_MACOS) {
- static sg_shader_desc desc;
- static bool valid;
- if (!valid) {
- valid = true;
- desc.vs.source = vs_source_metal_macos;
- desc.vs.entry = "main0";
- desc.vs.uniform_blocks[0].size = 64;
- desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.fs.source = fs_source_metal_macos;
- desc.fs.entry = "main0";
- desc.fs.images[0].name = "tex";
- desc.fs.images[0].image_type = SG_IMAGETYPE_2D;
- desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT;
- desc.label = "rive_tess_shader";
- }
- return &desc;
- }
- return 0;
-}
-static inline const sg_shader_desc* rive_tess_path_shader_desc(sg_backend backend) {
- if (backend == SG_BACKEND_GLCORE33) {
- static sg_shader_desc desc;
- static bool valid;
- if (!valid) {
- valid = true;
- desc.attrs[0].name = "position";
- desc.vs.source = vs_path_source_glsl330;
- desc.vs.entry = "main";
- desc.vs.uniform_blocks[0].size = 96;
- desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.vs.uniform_blocks[0].uniforms[0].name = "_22.mvp";
- desc.vs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_MAT4;
- desc.vs.uniform_blocks[0].uniforms[0].array_count = 1;
- desc.vs.uniform_blocks[0].uniforms[1].name = "_22.fillType";
- desc.vs.uniform_blocks[0].uniforms[1].type = SG_UNIFORMTYPE_INT;
- desc.vs.uniform_blocks[0].uniforms[1].array_count = 1;
- desc.vs.uniform_blocks[0].uniforms[2].name = "_22.gradientStart";
- desc.vs.uniform_blocks[0].uniforms[2].type = SG_UNIFORMTYPE_FLOAT2;
- desc.vs.uniform_blocks[0].uniforms[2].array_count = 1;
- desc.vs.uniform_blocks[0].uniforms[3].name = "_22.gradientEnd";
- desc.vs.uniform_blocks[0].uniforms[3].type = SG_UNIFORMTYPE_FLOAT2;
- desc.vs.uniform_blocks[0].uniforms[3].array_count = 1;
- desc.fs.source = fs_path_source_glsl330;
- desc.fs.entry = "main";
- desc.fs.uniform_blocks[0].size = 352;
- desc.fs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.fs.uniform_blocks[0].uniforms[0].name = "_18.fillType";
- desc.fs.uniform_blocks[0].uniforms[0].type = SG_UNIFORMTYPE_INT;
- desc.fs.uniform_blocks[0].uniforms[0].array_count = 1;
- desc.fs.uniform_blocks[0].uniforms[1].name = "_18.colors";
- desc.fs.uniform_blocks[0].uniforms[1].type = SG_UNIFORMTYPE_FLOAT4;
- desc.fs.uniform_blocks[0].uniforms[1].array_count = 16;
- desc.fs.uniform_blocks[0].uniforms[2].name = "_18.stops";
- desc.fs.uniform_blocks[0].uniforms[2].type = SG_UNIFORMTYPE_FLOAT4;
- desc.fs.uniform_blocks[0].uniforms[2].array_count = 4;
- desc.fs.uniform_blocks[0].uniforms[3].name = "_18.stopCount";
- desc.fs.uniform_blocks[0].uniforms[3].type = SG_UNIFORMTYPE_INT;
- desc.fs.uniform_blocks[0].uniforms[3].array_count = 1;
- desc.label = "rive_tess_path_shader";
- }
- return &desc;
- }
- if (backend == SG_BACKEND_D3D11) {
- static sg_shader_desc desc;
- static bool valid;
- if (!valid) {
- valid = true;
- desc.attrs[0].sem_name = "TEXCOORD";
- desc.attrs[0].sem_index = 0;
- desc.vs.source = vs_path_source_hlsl5;
- desc.vs.d3d11_target = "vs_5_0";
- desc.vs.entry = "main";
- desc.vs.uniform_blocks[0].size = 96;
- desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.fs.source = fs_path_source_hlsl5;
- desc.fs.d3d11_target = "ps_5_0";
- desc.fs.entry = "main";
- desc.fs.uniform_blocks[0].size = 352;
- desc.fs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.label = "rive_tess_path_shader";
- }
- return &desc;
- }
- if (backend == SG_BACKEND_METAL_MACOS) {
- static sg_shader_desc desc;
- static bool valid;
- if (!valid) {
- valid = true;
- desc.vs.source = vs_path_source_metal_macos;
- desc.vs.entry = "main0";
- desc.vs.uniform_blocks[0].size = 96;
- desc.vs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.fs.source = fs_path_source_metal_macos;
- desc.fs.entry = "main0";
- desc.fs.uniform_blocks[0].size = 352;
- desc.fs.uniform_blocks[0].layout = SG_UNIFORMLAYOUT_STD140;
- desc.label = "rive_tess_path_shader";
- }
- return &desc;
- }
- return 0;
-}
+++ /dev/null
-@ctype mat4 rive::Mat4
-@ctype vec2 rive::Vec2D
-
-@vs vs
-uniform vs_params {
- mat4 mvp;
-};
-
-in vec2 position;
-in vec2 texcoord0;
-
-out vec2 uv;
-
-void main() {
- gl_Position = mvp * vec4(position.x, position.y, 0.0, 1.0);
- uv = texcoord0;
-}
-@end
-
-@fs fs
-uniform sampler2D tex;
-
-in vec2 uv;
-out vec4 frag_color;
-
-void main() {
- frag_color = texture(tex, uv);
-}
-@end
-
-@program rive_tess vs fs
-
-
-@vs vs_path
-uniform vs_path_params {
- mat4 mvp;
- int fillType;
- vec2 gradientStart;
- vec2 gradientEnd;
-};
-
-in vec2 position;
-out vec2 gradient_uv;
-
-void main() {
- gl_Position = mvp * vec4(position, 0.0, 1.0);
-
- if(fillType == 1) {
- // Linear gradient.
- vec2 toEnd = gradientEnd - gradientStart;
- float lengthSquared = toEnd.x * toEnd.x + toEnd.y * toEnd.y;
- gradient_uv.x = dot(position - gradientStart, toEnd) / lengthSquared;
- }
- else if(fillType == 2) {
- // fillType == 2 (Radial gradient)
- gradient_uv = (position - gradientStart) / distance(gradientStart, gradientEnd);
- }
-}
-@end
-
-@fs fs_path
-
-uniform fs_path_uniforms {
- int fillType;
- vec4 colors[16];
- vec4 stops[4];
- int stopCount;
-};
-
-in vec2 gradient_uv;
-out vec4 frag_color;
-
-void main() {
- if (fillType == 0) {
- // Solid color.
- frag_color = colors[0];
- }
- else {
- float f = fillType == 1 ? gradient_uv.x : length(gradient_uv);
- vec4 color =
- mix(colors[0], colors[1], smoothstep(stops[0][0], stops[0][1], f));
- for (int i = 1; i < 15; ++i)
- {
- if (i >= stopCount - 1)
- {
- break;
- }
-
- color = mix(color,
- colors[i + 1],
- smoothstep(stops[i/4][i%4], stops[(i+1)/4][(i+1)%4], f));
- }
- frag_color = color;
- }
-}
-@end
-
-@program rive_tess_path vs_path fs_path
\ No newline at end of file
+++ /dev/null
-#include "rive/tess/sokol/sokol_factory.hpp"
-
-using namespace rive;
-
-class NoOpRenderPaint : public RenderPaint {
-public:
- void color(unsigned int value) override {}
- void style(RenderPaintStyle value) override {}
- void thickness(float value) override {}
- void join(StrokeJoin value) override {}
- void cap(StrokeCap value) override {}
- void blendMode(BlendMode value) override {}
- void shader(rcp<RenderShader>) override {}
- void invalidateStroke() override {}
-};
-
-class NoOpRenderPath : public RenderPath {
-public:
- void reset() override {}
-
- void fillRule(FillRule value) override {}
- void addPath(CommandPath* path, const Mat2D& transform) override {}
- void addRenderPath(RenderPath* path, const Mat2D& transform) override {}
-
- void moveTo(float x, float y) override {}
- void lineTo(float x, float y) override {}
- void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override {}
- void close() override {}
-};
-
-SokolFactory::SokolFactory() {}
+++ /dev/null
-#include "rive/tess/sokol/sokol_tess_renderer.hpp"
-#include "rive/tess/sokol/sokol_factory.hpp"
-#include "rive/tess/tess_render_path.hpp"
-#include "rive/tess/contour_stroke.hpp"
-#include "generated/shader.h"
-#include <unordered_set>
-
-using namespace rive;
-
-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 {
-public:
- SokolRenderPath() {}
- SokolRenderPath(Span<const Vec2D> points, Span<const PathVerb> verbs, FillRule fillRule) :
- TessRenderPath(points, verbs, fillRule) {}
-
- ~SokolRenderPath() {
- sg_destroy_buffer(m_vertexBuffer);
- sg_destroy_buffer(m_indexBuffer);
- }
-
-private:
- std::vector<Vec2D> m_vertices;
- std::vector<uint16_t> m_indices;
-
- sg_buffer m_vertexBuffer = {0};
- sg_buffer m_indexBuffer = {0};
-
- std::size_t m_boundsIndex = 0;
-
-protected:
- 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 {
- m_boundsIndex = m_vertices.size();
- m_vertices.emplace_back(Vec2D(value.minX, value.minY));
- m_vertices.emplace_back(Vec2D(value.maxX, value.minY));
- m_vertices.emplace_back(Vec2D(value.maxX, value.maxY));
- m_vertices.emplace_back(Vec2D(value.minX, value.maxY));
- }
-
-public:
- void reset() override {
- TessRenderPath::reset();
- m_vertices.clear();
- m_indices.clear();
- }
-
- void drawStroke(ContourStroke* stroke) {
- if (isContainer()) {
- for (auto& subPath : m_subPaths) {
- reinterpret_cast<SokolRenderPath*>(subPath.path())->drawStroke(stroke);
- }
- return;
- }
- std::size_t start, end;
- stroke->nextRenderOffset(start, end);
- sg_draw(start < 2 ? 0 : (start - 2) * 3, end - start < 2 ? 0 : (end - start - 2) * 3, 1);
- }
-
- void drawFill() {
- if (triangulate()) {
- sg_destroy_buffer(m_vertexBuffer);
- sg_destroy_buffer(m_indexBuffer);
- if (m_indices.size() == 0 || m_vertices.size() == 0) {
- m_vertexBuffer = {0};
- m_indexBuffer = {0};
- return;
- }
-
- m_vertexBuffer = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_VERTEXBUFFER,
- .data =
- {
- m_vertices.data(),
- m_vertices.size() * sizeof(Vec2D),
- },
- });
-
- m_indexBuffer = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_INDEXBUFFER,
- .data =
- {
- m_indices.data(),
- m_indices.size() * sizeof(uint16_t),
- },
- });
- }
-
- if (m_vertexBuffer.id == 0) {
- return;
- }
-
- sg_bindings bind = {
- .vertex_buffers[0] = m_vertexBuffer,
- .index_buffer = m_indexBuffer,
- };
-
- sg_apply_bindings(&bind);
- sg_draw(0, m_indices.size(), 1);
- }
-
- void drawBounds(const sg_buffer& boundsIndexBuffer) {
- if (m_vertexBuffer.id == 0) {
- return;
- }
- sg_bindings bind = {
- .vertex_buffers[0] = m_vertexBuffer,
- .vertex_buffer_offsets[0] = (int)(m_boundsIndex * sizeof(Vec2D)),
- .index_buffer = boundsIndexBuffer,
- };
-
- sg_apply_bindings(&bind);
- sg_draw(0, 6, 1);
- }
-};
-
-// Returns a full-formed RenderPath -- can be treated as immutable
-std::unique_ptr<RenderPath> SokolFactory::makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule rule) {
- return std::make_unique<SokolRenderPath>(points, verbs, rule);
-}
-
-std::unique_ptr<RenderPath> SokolFactory::makeEmptyRenderPath() {
- return std::make_unique<SokolRenderPath>();
-}
-
-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)) {}
- ~SokolBuffer() { sg_destroy_buffer(m_Buffer); }
-
- sg_buffer buffer() { return m_Buffer; }
-};
-
-rcp<RenderBuffer> SokolFactory::makeBufferU16(Span<const uint16_t> span) {
- return rcp<RenderBuffer>(new SokolBuffer(span.size(),
- (sg_buffer_desc){
- .type = SG_BUFFERTYPE_INDEXBUFFER,
- .data =
- {
- span.data(),
- span.size_bytes(),
- },
- }));
-}
-
-rcp<RenderBuffer> SokolFactory::makeBufferU32(Span<const uint32_t> span) {
- return rcp<RenderBuffer>(new SokolBuffer(span.size(),
- (sg_buffer_desc){
- .type = SG_BUFFERTYPE_INDEXBUFFER,
- .data =
- {
- span.data(),
- span.size_bytes(),
- },
- }));
-}
-rcp<RenderBuffer> SokolFactory::makeBufferF32(Span<const float> span) {
- return rcp<RenderBuffer>(new SokolBuffer(span.size(),
- (sg_buffer_desc){
- .type = SG_BUFFERTYPE_VERTEXBUFFER,
- .data =
- {
- span.data(),
- span.size_bytes(),
- },
- }));
-}
-
-sg_pipeline vectorPipeline(sg_shader shader,
- sg_blend_state blend,
- sg_stencil_state stencil,
- sg_color_mask colorMask = SG_COLORMASK_RGBA) {
- return sg_make_pipeline((sg_pipeline_desc){
- .layout =
- {
- .attrs =
- {
- [ATTR_vs_path_position] =
- {
- .format = SG_VERTEXFORMAT_FLOAT2,
- .buffer_index = 0,
- },
- },
- },
- .shader = shader,
- .index_type = SG_INDEXTYPE_UINT16,
- .cull_mode = SG_CULLMODE_NONE,
- .depth =
- {
- .compare = SG_COMPAREFUNC_ALWAYS,
- .write_enabled = false,
- },
- .colors =
- {
- [0] =
- {
- .write_mask = colorMask,
- .blend = blend,
- },
- },
- .stencil = stencil,
- .label = "path-pipeline",
- });
-}
-
-SokolTessRenderer::SokolTessRenderer() {
- m_meshPipeline = sg_make_pipeline((sg_pipeline_desc){
- .layout =
- {
- .attrs =
- {
- [ATTR_vs_position] = {.format = SG_VERTEXFORMAT_FLOAT2, .buffer_index = 0},
- [ATTR_vs_texcoord0] = {.format = SG_VERTEXFORMAT_FLOAT2, .buffer_index = 1},
- },
- },
- .shader = sg_make_shader(rive_tess_shader_desc(sg_query_backend())),
- .index_type = SG_INDEXTYPE_UINT16,
- .cull_mode = SG_CULLMODE_NONE,
- .depth =
- {
- .compare = SG_COMPAREFUNC_ALWAYS,
- .write_enabled = false,
- },
- .colors =
- {
- [0] =
- {
- .write_mask = SG_COLORMASK_RGBA,
- .blend =
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- },
- },
- .label = "mesh-pipeline",
- });
-
- auto uberShader = sg_make_shader(rive_tess_path_shader_desc(sg_query_backend()));
-
- assert(maxClippingPaths < 256);
-
- // Src Over Pipelines
- {
- m_pathPipeline[0] = vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- {
- .enabled = false,
- });
-
- for (std::size_t i = 1; i <= maxClippingPaths; i++) {
- m_pathPipeline[i] =
- vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- {
- .enabled = true,
- .ref = (uint8_t)i,
- .read_mask = 0xFF,
- .write_mask = 0x00,
- .front =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- .back =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- });
- }
- }
-
- // Screen Pipelines
- {
- m_pathScreenPipeline[0] =
- vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE,
- .src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- {
- .enabled = false,
- });
-
- for (std::size_t i = 1; i <= maxClippingPaths; i++) {
- m_pathScreenPipeline[i] =
- vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE,
- .src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- {
- .enabled = true,
- .ref = (uint8_t)i,
- .read_mask = 0xFF,
- .write_mask = 0x00,
- .front =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- .back =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- });
- }
- }
-
- // Additive Pipelines
- {
- m_pathAdditivePipeline[0] = vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE,
- },
- {
- .enabled = false,
- });
-
- for (std::size_t i = 1; i <= maxClippingPaths; i++) {
- m_pathAdditivePipeline[i] =
- vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE,
- },
- {
- .enabled = true,
- .ref = (uint8_t)i,
- .read_mask = 0xFF,
- .write_mask = 0x00,
- .front =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- .back =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- });
- }
- }
-
- // Multiply Pipelines
- {
- m_pathMultiplyPipeline[0] =
- vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_DST_COLOR,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- {
- .enabled = false,
- });
-
- for (std::size_t i = 1; i <= maxClippingPaths; i++) {
- m_pathMultiplyPipeline[i] =
- vectorPipeline(uberShader,
- {
- .enabled = true,
- .src_factor_rgb = SG_BLENDFACTOR_DST_COLOR,
- .dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
- },
- {
- .enabled = true,
- .ref = (uint8_t)i,
- .read_mask = 0xFF,
- .write_mask = 0x00,
- .front =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- .back =
- {
- .compare = SG_COMPAREFUNC_EQUAL,
- },
- });
- }
- }
-
- m_incClipPipeline = vectorPipeline(uberShader,
- {
- .enabled = false,
- },
- {
- .enabled = true,
- .read_mask = 0xFF,
- .write_mask = 0xFF,
- .front =
- {
- .compare = SG_COMPAREFUNC_ALWAYS,
- .depth_fail_op = SG_STENCILOP_KEEP,
- .fail_op = SG_STENCILOP_KEEP,
- .pass_op = SG_STENCILOP_INCR_CLAMP,
- },
- .back =
- {
- .compare = SG_COMPAREFUNC_ALWAYS,
- .depth_fail_op = SG_STENCILOP_KEEP,
- .fail_op = SG_STENCILOP_KEEP,
- .pass_op = SG_STENCILOP_INCR_CLAMP,
- },
- },
- SG_COLORMASK_NONE);
-
- m_decClipPipeline = vectorPipeline(uberShader,
- {
- .enabled = false,
- },
- {
- .enabled = true,
- .read_mask = 0xFF,
- .write_mask = 0xFF,
- .front =
- {
- .compare = SG_COMPAREFUNC_ALWAYS,
- .depth_fail_op = SG_STENCILOP_KEEP,
- .fail_op = SG_STENCILOP_KEEP,
- .pass_op = SG_STENCILOP_DECR_CLAMP,
- },
- .back =
- {
- .compare = SG_COMPAREFUNC_ALWAYS,
- .depth_fail_op = SG_STENCILOP_KEEP,
- .fail_op = SG_STENCILOP_KEEP,
- .pass_op = SG_STENCILOP_DECR_CLAMP,
- },
- },
- SG_COLORMASK_NONE);
-
- uint16_t indices[] = {0, 1, 2, 0, 2, 3};
-
- m_boundsIndices = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_INDEXBUFFER,
- .data = SG_RANGE(indices),
- });
-
- // The UV buffer used by drawImage. Consider this the "default uv
- // vertex buffer" used when a mesh isn't provided by Rive.
- Vec2D defUV[] = {
- Vec2D(0.0f, 0.0f),
- Vec2D(1.0f, 0.0f),
- Vec2D(1.0f, 1.0f),
- Vec2D(0.0f, 1.0f),
- };
-
- m_defaultUV = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_VERTEXBUFFER,
- .data = SG_RANGE(defUV),
- });
-}
-
-SokolTessRenderer::~SokolTessRenderer() {
- sg_destroy_buffer(m_defaultUV);
- 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++) {
- sg_destroy_pipeline(m_pathPipeline[i]);
- sg_destroy_pipeline(m_pathScreenPipeline[i]);
- }
-}
-
-void SokolTessRenderer::orthographicProjection(float left,
- float right,
- float bottom,
- float top,
- float near,
- float far) {
- m_Projection[0] = 2.0f / (right - left);
- m_Projection[1] = 0.0f;
- m_Projection[2] = 0.0f;
- m_Projection[3] = 0.0f;
-
- m_Projection[4] = 0.0f;
- m_Projection[5] = 2.0f / (top - bottom);
- m_Projection[6] = 0.0f;
- m_Projection[7] = 0.0f;
-
-#ifdef SOKOL_GLCORE33
- m_Projection[8] = 0.0f;
- m_Projection[9] = 0.0f;
- m_Projection[10] = 2.0f / (near - far);
- m_Projection[11] = 0.0f;
-
- m_Projection[12] = (right + left) / (left - right);
- m_Projection[13] = (top + bottom) / (bottom - top);
- m_Projection[14] = (far + near) / (near - far);
- m_Projection[15] = 1.0f;
-#else
- // NDC are slightly different in Metal:
- // https://metashapes.com/blog/opengl-metal-projection-matrix-problem/
- m_Projection[8] = 0.0f;
- m_Projection[9] = 0.0f;
- m_Projection[10] = 1.0f / (far - near);
- m_Projection[11] = 0.0f;
-
- m_Projection[12] = (right + left) / (left - right);
- m_Projection[13] = (top + bottom) / (bottom - top);
- m_Projection[14] = near / (near - far);
- m_Projection[15] = 1.0f;
-#endif
- // for (int i = 0; i < 4; i++) {
- // int b = i * 4;
- // printf("%f\t%f\t%f\t%f\n",
- // m_Projection[b],
- // m_Projection[b + 1],
- // m_Projection[b + 2],
- // m_Projection[b + 3]);
- // }
-}
-
-void SokolTessRenderer::drawImage(const RenderImage* image, BlendMode, float opacity) {
- vs_params_t vs_params;
-
- const Mat2D& world = transform();
- vs_params.mvp = m_Projection * world;
-
- auto sokolImage = static_cast<const SokolRenderImage*>(image);
- setPipeline(m_meshPipeline);
- sg_bindings bind = {
- .vertex_buffers[0] = sokolImage->vertexBuffer(),
- .vertex_buffers[1] = m_defaultUV,
- .index_buffer = m_boundsIndices,
- .fs_images[SLOT_tex] = sokolImage->image(),
- };
-
- sg_apply_bindings(&bind);
- sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_params, SG_RANGE_REF(vs_params));
- sg_draw(0, 6, 1);
-}
-
-void SokolTessRenderer::drawImageMesh(const RenderImage* renderImage,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode blendMode,
- float opacity) {
- vs_params_t vs_params;
-
- const Mat2D& world = transform();
- vs_params.mvp = m_Projection * world;
-
- setPipeline(m_meshPipeline);
- sg_bindings bind = {
- .vertex_buffers[0] = static_cast<SokolBuffer*>(vertices_f32.get())->buffer(),
- .vertex_buffers[1] = static_cast<SokolBuffer*>(uvCoords_f32.get())->buffer(),
- .index_buffer = static_cast<SokolBuffer*>(indices_u16.get())->buffer(),
- .fs_images[SLOT_tex] = static_cast<const SokolRenderImage*>(renderImage)->image(),
- };
-
- sg_apply_bindings(&bind);
- sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_params, SG_RANGE_REF(vs_params));
- sg_draw(0, indices_u16->count(), 1);
-}
-
-class SokolGradient : public RenderShader {
-private:
- Vec2D m_start;
- Vec2D m_end;
- int m_type;
- std::vector<float> m_colors;
- std::vector<float> m_stops;
- bool m_isVisible = false;
-
-private:
- // General gradient
- SokolGradient(int type, const ColorInt colors[], const float stops[], size_t count) :
- m_type(type) {
- m_stops.resize(count);
- m_colors.resize(count * 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) {
- m_isVisible = true;
- }
- }
- }
-
-public:
- // Linear gradient
- SokolGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[],
- const float stops[],
- size_t count) :
- SokolGradient(1, colors, stops, count) {
- m_start = Vec2D(sx, sy);
- m_end = Vec2D(ex, ey);
- }
-
- SokolGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t 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) {
- 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++) {
- auto colorBufferIndex = i * 4;
- for (int j = 0; j < 4; j++) {
- fragmentUniforms.colors[i][j] = m_colors[colorBufferIndex + j];
- }
- fragmentUniforms.stops[i / 4][i % 4] = m_stops[i];
- }
- }
-};
-
-rcp<RenderShader> SokolFactory::makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[],
- const float stops[],
- size_t count) {
- return rcp<RenderShader>(new SokolGradient(sx, sy, ex, ey, colors, stops, count));
-}
-
-rcp<RenderShader> SokolFactory::makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- return rcp<RenderShader>(new SokolGradient(cx, cy, radius, colors, stops, count));
-}
-
-class SokolRenderPaint : public RenderPaint {
-private:
- fs_path_uniforms_t m_uniforms = {0};
- rcp<RenderShader> m_shader;
- RenderPaintStyle m_style;
- std::unique_ptr<ContourStroke> m_stroke;
- bool m_strokeDirty = false;
- float m_strokeThickness = 0.0f;
- StrokeJoin m_strokeJoin;
- StrokeCap m_strokeCap;
-
- sg_buffer m_strokeVertexBuffer = {0};
- sg_buffer m_strokeIndexBuffer = {0};
- std::vector<std::size_t> m_StrokeOffsets;
-
- BlendMode m_blendMode = BlendMode::srcOver;
-
-public:
- ~SokolRenderPaint() override {
- sg_destroy_buffer(m_strokeVertexBuffer);
- sg_destroy_buffer(m_strokeIndexBuffer);
- }
-
- void color(ColorInt value) override {
- fillColorBuffer(m_uniforms.colors[0], value);
- m_uniforms.fillType = 0;
- }
-
- void style(RenderPaintStyle value) override {
- m_style = value;
-
- switch (m_style) {
- case RenderPaintStyle::fill:
- m_stroke = nullptr;
- m_strokeDirty = false;
- break;
- case RenderPaintStyle::stroke:
- m_stroke = std::make_unique<ContourStroke>();
- m_strokeDirty = true;
- break;
- }
- }
-
- RenderPaintStyle style() const { return m_style; }
-
- void thickness(float value) override {
- m_strokeThickness = value;
- m_strokeDirty = true;
- }
-
- void join(StrokeJoin value) override {
- m_strokeJoin = value;
- m_strokeDirty = true;
- }
-
- void cap(StrokeCap value) override {
- m_strokeCap = value;
- m_strokeDirty = true;
- }
-
- void invalidateStroke() override {
- if (m_stroke) {
- m_strokeDirty = true;
- }
- }
-
- void blendMode(BlendMode value) override { m_blendMode = value; }
- BlendMode blendMode() const { return m_blendMode; }
-
- void shader(rcp<RenderShader> shader) override { m_shader = 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) {
- static Mat2D identity;
- m_stroke->reset();
- path->extrudeStroke(m_stroke.get(),
- m_strokeJoin,
- m_strokeCap,
- m_strokeThickness / 2.0f,
- identity);
- m_strokeDirty = false;
-
- const std::vector<Vec2D>& strip = m_stroke->triangleStrip();
-
- sg_destroy_buffer(m_strokeVertexBuffer);
- sg_destroy_buffer(m_strokeIndexBuffer);
- auto size = strip.size();
- if (size <= 2) {
- m_strokeVertexBuffer = {0};
- m_strokeIndexBuffer = {0};
- return;
- }
-
- m_strokeVertexBuffer = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_VERTEXBUFFER,
- .data =
- {
- strip.data(),
- strip.size() * sizeof(Vec2D),
- },
- });
-
- // Let's use a tris index buffer so we can keep the same sokol pipeline.
- std::vector<uint16_t> indices;
-
- // Build them by stroke offsets (where each offset represents a sub-path, or a move
- // to)
- m_stroke->resetRenderOffset();
- m_StrokeOffsets.clear();
- while (true) {
- std::size_t 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) {
- indices.push_back(i + strokeStart);
- indices.push_back(i + 1 + strokeStart);
- indices.push_back(i + 2 + strokeStart);
- } else {
- indices.push_back(i + strokeStart);
- indices.push_back(i + 2 + strokeStart);
- indices.push_back(i + 1 + strokeStart);
- }
- }
- m_StrokeOffsets.push_back(indices.size());
- }
- }
-
- m_strokeIndexBuffer = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_INDEXBUFFER,
- .data =
- {
- indices.data(),
- indices.size() * sizeof(uint16_t),
- },
- });
- }
- if (m_strokeVertexBuffer.id == 0) {
- return;
- }
-
- sg_bindings bind = {
- .vertex_buffers[0] = m_strokeVertexBuffer,
- .index_buffer = m_strokeIndexBuffer,
- };
-
- sg_apply_bindings(&bind);
-
- m_stroke->resetRenderOffset();
- // path->drawStroke(m_stroke.get());
- std::size_t start = 0;
- for (auto end : m_StrokeOffsets) {
- sg_draw(start, end - start, 1);
- start = end;
- }
-
- } else {
- path->drawFill();
- }
- }
-};
-
-std::unique_ptr<RenderPaint> SokolFactory::makeRenderPaint() {
- return std::make_unique<SokolRenderPaint>();
-}
-
-void SokolTessRenderer::restore() {
- TessRenderer::restore();
- 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) {
- return;
- }
- m_IsClippingDirty = false;
- RenderState& state = m_Stack.back();
-
- auto currentClipLength = m_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()) {
- allSame = false;
- break;
- }
- }
- if (allSame) {
- return;
- }
- }
-
- vs_path_params_t vs_params = {.fillType = 0};
- fs_path_uniforms_t uniforms = {0};
-
- // Decr any paths from the last clip that are gone.
- std::unordered_set<RenderPath*> alreadyApplied;
-
- for (auto appliedPath : m_ClipPaths) {
- bool decr = true;
- for (auto nextClipPath : state.clipPaths) {
- if (nextClipPath.path() == appliedPath.path()) {
- decr = false;
- alreadyApplied.insert(appliedPath.path());
- break;
- }
- }
- if (decr) {
- // Draw appliedPath.path() with decr pipeline
- setPipeline(m_decClipPipeline);
- vs_params.mvp = m_Projection * appliedPath.transform();
- sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_path_params, SG_RANGE_REF(vs_params));
- sg_apply_uniforms(SG_SHADERSTAGE_FS, SLOT_fs_path_uniforms, SG_RANGE_REF(uniforms));
- auto sokolPath = static_cast<SokolRenderPath*>(appliedPath.path());
- sokolPath->drawFill();
- }
- }
-
- // Incr any paths that are added.
- for (auto nextClipPath : state.clipPaths) {
- if (alreadyApplied.count(nextClipPath.path())) {
- // Already applied.
- continue;
- }
- // Draw nextClipPath.path() with incr pipeline
- setPipeline(m_incClipPipeline);
- vs_params.mvp = m_Projection * nextClipPath.transform();
- sg_apply_uniforms(SG_SHADERSTAGE_VS, SLOT_vs_path_params, SG_RANGE_REF(vs_params));
- sg_apply_uniforms(SG_SHADERSTAGE_FS, SLOT_fs_path_uniforms, SG_RANGE_REF(uniforms));
- auto sokolPath = static_cast<SokolRenderPath*>(nextClipPath.path());
- sokolPath->drawFill();
- }
-
- // Pick which pipeline to use for draw path operations.
- // TODO: something similar for draw mesh.
- m_clipCount = state.clipPaths.size();
-
- m_ClipPaths = state.clipPaths;
-}
-
-void SokolTessRenderer::reset() { m_currentPipeline = {0}; }
-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) {
- auto sokolPaint = static_cast<SokolRenderPaint*>(paint);
-
- applyClipping();
- vs_path_params_t vs_params = {.fillType = 0};
- 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;
- }
-
- static_cast<SokolRenderPaint*>(paint)->draw(vs_params, static_cast<SokolRenderPath*>(path));
-}
-
-SokolRenderImage::SokolRenderImage(const uint8_t* bytes, uint32_t width, uint32_t height) :
- m_image(sg_make_image((sg_image_desc){
- .width = (int)width,
- .height = (int)height,
- .data.subimage[0][0] = {bytes, width * height * 4},
- .pixel_format = SG_PIXELFORMAT_RGBA8,
- }))
-
-{
- float halfWidth = width / 2.0f;
- float halfHeight = height / 2.0f;
- Vec2D points[] = {
- Vec2D(-halfWidth, -halfHeight),
- Vec2D(halfWidth, -halfHeight),
- Vec2D(halfWidth, halfHeight),
- Vec2D(-halfWidth, halfHeight),
- };
- m_vertexBuffer = sg_make_buffer((sg_buffer_desc){
- .type = SG_BUFFERTYPE_VERTEXBUFFER,
- .data = SG_RANGE(points),
- });
-}
-
-SokolRenderImage::~SokolRenderImage() {
- sg_destroy_buffer(m_vertexBuffer);
- sg_destroy_image(m_image);
-}
\ No newline at end of file
+++ /dev/null
-#include "rive/tess/sub_path.hpp"
-
-using namespace rive;
-
-SubPath::SubPath(RenderPath* path, const Mat2D& transform) : m_Path(path), m_Transform(transform) {}
-
-RenderPath* SubPath::path() const { return m_Path; }
-const Mat2D& SubPath::transform() const { return m_Transform; }
\ No newline at end of file
+++ /dev/null
-#include "rive/tess/tess_render_path.hpp"
-#include "rive/tess/contour_stroke.hpp"
-#include "tesselator.h"
-
-static const float contourThreshold = 1.0f;
-
-using namespace rive;
-TessRenderPath::TessRenderPath() : m_segmentedContour(contourThreshold) {}
-TessRenderPath::TessRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule fillRule) :
- m_rawPath(points, verbs), m_fillRule(fillRule), m_segmentedContour(contourThreshold) {}
-
-TessRenderPath::~TessRenderPath() {}
-
-void TessRenderPath::reset() {
- m_rawPath.rewind();
- m_subPaths.clear();
- m_isContourDirty = m_isTriangulationDirty = true;
-}
-
-void TessRenderPath::fillRule(FillRule value) { m_fillRule = value; }
-
-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) {
- m_rawPath.cubicTo(ox, oy, ix, iy, x, y);
-}
-void TessRenderPath::close() {
- m_rawPath.close();
- m_isClosed = true;
-}
-
-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 {
-
-template <> struct nth<0, Vec2D> {
- inline static auto get(const Vec2D& t) { return t.x; };
-};
-template <> struct nth<1, Vec2D> {
- inline static auto get(const Vec2D& t) { return t.y; };
-};
-
-} // namespace util
-} // namespace mapbox
-
-const RawPath& TessRenderPath::rawPath() const { return m_rawPath; }
-
-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) {
- TESS_NOTUSED(userData);
- free(ptr);
-}
-
-bool TessRenderPath::triangulate() {
- if (!m_isTriangulationDirty) {
- return false;
- }
- m_isTriangulationDirty = false;
- triangulate(this);
- return true;
-}
-
-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()) {
- Mat2D identity;
- contour(identity);
-
- bounds = m_segmentedContour.bounds();
-
- auto contour = m_segmentedContour.contourPoints();
- auto contours = Span(&contour, 1);
- m_earcut(contours);
-
- containerPath->addTriangles(contour, m_earcut.indices);
- }
- } 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()) {
- // Nope, subpath is also a container, keep going.
- subRenderPath->triangulate(containerPath);
- } else if (!subRenderPath->empty()) {
- // Yes, it's a single path with commands, triangulate it.
- subRenderPath->contour(subPath.transform());
- const SegmentedContour& segmentedContour = subRenderPath->segmentedContour();
- auto contour = segmentedContour.contourPoints();
- auto contours = Span(&contour, 1);
- m_earcut(contours);
-
- containerPath->addTriangles(contour, m_earcut.indices);
- }
- } else {
- // We're a container with multiple sub-paths.
- TESStesselator* tess = nullptr;
- for (SubPath& subPath : m_subPaths) {
- auto subRenderPath = static_cast<TessRenderPath*>(subPath.path());
- if (subRenderPath->isContainer()) {
- subRenderPath->triangulate(containerPath);
- } else if (!subRenderPath->empty()) {
- if (tess == nullptr) {
- tess = tessNewTess(nullptr);
- }
- subRenderPath->contour(subPath.transform());
- const SegmentedContour& segmentedContour = subRenderPath->segmentedContour();
- auto contour = segmentedContour.contourPoints();
- tessAddContour(tess, 2, contour.data(), sizeof(float) * 2, contour.size());
- bounds.expand(segmentedContour.bounds());
- }
- }
- 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);
- auto elems = tessGetElements(tess);
- auto nelems = tessGetElementCount(tess);
-
- std::vector<uint16_t> indices;
- for (int i = 0; i < nelems * 3; i++) {
- indices.push_back(elems[i]);
- }
-
- containerPath->addTriangles(Span(reinterpret_cast<const Vec2D*>(verts), nverts),
- indices);
- }
- tessDeleteTess(tess);
- }
- }
-
- containerPath->setTriangulatedBounds(bounds);
-}
-
-void TessRenderPath::contour(const Mat2D& transform) {
- if (!m_isContourDirty && transform == m_contourTransform) {
- return;
- }
-
- m_isContourDirty = false;
- m_contourTransform = transform;
- m_segmentedContour.contour(m_rawPath, transform);
-}
-
-void TessRenderPath::extrudeStroke(ContourStroke* stroke,
- StrokeJoin join,
- StrokeCap cap,
- float strokeWidth,
- const Mat2D& transform) {
- if (isContainer()) {
- for (auto& subPath : m_subPaths) {
- static_cast<TessRenderPath*>(subPath.path())
- ->extrudeStroke(stroke, join, cap, strokeWidth, subPath.transform());
- }
- return;
- }
-
- contour(transform);
-
- stroke->extrude(&m_segmentedContour, m_isClosed, join, cap, strokeWidth);
-}
-
-bool TessRenderPath::empty() const { return m_rawPath.empty(); }
+++ /dev/null
-#include "rive/tess/tess_renderer.hpp"
-#include <cassert>
-
-using namespace rive;
-
-TessRenderer::TessRenderer() { m_Stack.emplace_back(RenderState()); }
-
-void TessRenderer::projection(const Mat4& value) { m_Projection = value; }
-
-void TessRenderer::save() { m_Stack.push_back(m_Stack.back()); }
-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()) {
- m_IsClippingDirty = true;
- }
-}
-
-void TessRenderer::transform(const Mat2D& transform) {
- Mat2D& stackMat = m_Stack.back().transform;
- stackMat = stackMat * transform;
-}
-
-void TessRenderer::clipPath(RenderPath* path) {
-
- RenderState& state = m_Stack.back();
- state.clipPaths.emplace_back(SubPath(path, state.transform));
- m_IsClippingDirty = true;
-}
-
-void TessRenderer::drawImage(const RenderImage*, BlendMode, float opacity) {}
-void TessRenderer::drawImageMesh(const RenderImage*,
- rcp<RenderBuffer> vertices_f32,
- rcp<RenderBuffer> uvCoords_f32,
- rcp<RenderBuffer> indices_u16,
- BlendMode,
- float opacity) {}
\ No newline at end of file
+++ /dev/null
-// The only purpose of this file is to DEFINE the catch config so it can include
-// main()
-
-#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this
- // in one cpp file
-#include <catch.hpp>
\ No newline at end of file
+++ /dev/null
-#include <catch.hpp>
-#include "rive/math/mat4.hpp"
-#include "rive/math/mat2d.hpp"
-
-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);
- REQUIRE(matrix4x4[1] == 0.2f);
- REQUIRE(matrix4x4[4] == 0.0f);
- REQUIRE(matrix4x4[5] == 2.0f);
- REQUIRE(matrix4x4[12] == 22.0f);
- REQUIRE(matrix4x4[13] == 33.0f);
-}
-
-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;
- REQUIRE(matrix4x4[0] == 0.1f);
- REQUIRE(matrix4x4[1] == 0.2f);
- REQUIRE(matrix4x4[4] == 0.0f);
- REQUIRE(matrix4x4[5] == 2.0f);
- REQUIRE(matrix4x4[12] == 22.0f);
- REQUIRE(matrix4x4[13] == 33.0f);
-}
-
-TEST_CASE("Mat4 times Mat4 works", "[mat4]") {
- rive::Mat4 a(
- // clang-format off
- 5.0f, 7.0f, 9.0f, 10.0f,
- 2.0f, 3.0f, 3.0f, 8.0f,
- 8.0f, 10.0f, 2.0f, 3.0f,
- 3.0f, 3.0f, 4.0f, 8.0f
- // clang-format on
- );
- rive::Mat4 b(
- // clang-format off
- 3.0f, 10.0f, 12.0f, 18.0f,
- 12.0f, 1.0f, 4.0f, 9.0f,
- 9.0f, 10.0f, 12.0f, 2.0f,
- 3.0f, 12.0f, 4.0f, 10.0f
- // clang-format on
- );
-
- auto result = b * a;
- REQUIRE(result[0] == 210.0f);
- REQUIRE(result[1] == 267.0f);
- REQUIRE(result[2] == 236.0f);
- REQUIRE(result[3] == 271.0f);
-
- REQUIRE(result[4] == 93.0f);
- REQUIRE(result[5] == 149.0f);
- REQUIRE(result[6] == 104.0f);
- REQUIRE(result[7] == 149.0f);
-
- REQUIRE(result[8] == 171.0f);
- REQUIRE(result[9] == 146.0f);
- REQUIRE(result[10] == 172.0f);
- REQUIRE(result[11] == 268.0f);
-
- REQUIRE(result[12] == 105.0f);
- REQUIRE(result[13] == 169.0f);
- REQUIRE(result[14] == 128.0f);
- REQUIRE(result[15] == 169.0f);
-}
\ No newline at end of file
+++ /dev/null
-#include "rive/shapes/path.hpp"
-#include "rive/math/mat2d.hpp"
-#include "rive/tess/tess_render_path.hpp"
-#include "rive_file_reader.hpp"
-
-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 {
- vertices.insert(vertices.end(), vts.begin(), vts.end());
- indices.insert(indices.end(), idx.begin(), idx.end());
- }
-
- void setTriangulatedBounds(const rive::AABB& value) override {}
-};
-
-TEST_CASE("simple triangle path triangulates as expected", "[file]") {
- auto file = ReadRiveFile("../test/assets/triangle.riv");
- auto artboard = file->artboard();
- artboard->advance(0.0f);
-
- auto path = artboard->find<rive::Path>("triangle_path");
- REQUIRE(path != nullptr);
- TestRenderPath renderPath;
- path->buildPath(renderPath);
-
- rive::Mat2D identity;
- TestRenderPath shapeRenderPath;
- shapeRenderPath.addRenderPath(&renderPath, identity);
- shapeRenderPath.triangulate();
- REQUIRE(shapeRenderPath.vertices.size() == 4);
- REQUIRE(shapeRenderPath.indices.size() == 3);
- REQUIRE(shapeRenderPath.indices[0] == 2);
- REQUIRE(shapeRenderPath.indices[1] == 0);
- REQUIRE(shapeRenderPath.indices[2] == 1);
-}
\ No newline at end of file
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));
- REQUIRE(rive::fitsIn<T>(min - 0));
- REQUIRE(!rive::fitsIn<T>(max + 1));
- REQUIRE(!rive::fitsIn<T>(min - 1));
+ REQUIRE( rive::fitsIn<T>(max+0));
+ REQUIRE( rive::fitsIn<T>(min-0));
+ REQUIRE(!rive::fitsIn<T>(max+1));
+ REQUIRE(!rive::fitsIn<T>(min-1));
}
TEST_CASE("fitsIn checks", "[type_conversions]") {
p = packvarint(storage, value);
rive::BinaryReader reader(rive::Span(storage, p - storage));
-
+
auto newValue = reader.readVarUintAs<T>();
-
+
if (reader.hasError()) {
REQUIRE(newValue == 0);
}
}
TEST_CASE("range checks", "[binary_reader]") {
- REQUIRE(checkAs<uint8_t>(100));
- REQUIRE(checkAs<uint16_t>(100));
- REQUIRE(checkAs<uint32_t>(100));
+ REQUIRE( checkAs<uint8_t>(100));
+ REQUIRE( checkAs<uint16_t>(100));
+ REQUIRE( checkAs<uint32_t>(100));
REQUIRE(!checkAs<uint8_t>(1000));
- REQUIRE(checkAs<uint16_t>(1000));
- REQUIRE(checkAs<uint32_t>(1000));
+ REQUIRE( checkAs<uint16_t>(1000));
+ REQUIRE( checkAs<uint32_t>(1000));
REQUIRE(!checkAs<uint8_t>(100000));
REQUIRE(!checkAs<uint16_t>(100000));
- REQUIRE(checkAs<uint32_t>(100000));
+ REQUIRE( checkAs<uint32_t>(100000));
}
#include <rive/shapes/points_path.hpp>
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
-#include "utils/no_op_factory.hpp"
+#include "no_op_factory.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
#include <rive/shapes/clipping_shape.hpp>
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include <rive/math/contour_measure.hpp>
-#include <rive/math/math_types.hpp>
-#include <rive/math/raw_path.hpp>
-#include <rive/math/vec2d.hpp>
-
-#include <catch.hpp>
-#include <cstdio>
-
-using namespace rive;
-
-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) {
- 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) {
- return nearly_eq(a.x, b.x, tol) && nearly_eq(a.y, b.y, tol);
-}
-
-TEST_CASE("contour-basics", "[contourmeasure]") {
- const float tol = 0.000001f;
-
- RawPath path;
- ContourMeasureIter iter(path, false);
- REQUIRE(iter.next() == nullptr);
-
- path.moveTo(1, 2);
- iter.reset(path, false);
- REQUIRE(iter.next() == nullptr);
-
- path.lineTo(4, 6);
- iter.reset(path, false);
- auto cm = iter.next();
- REQUIRE(cm);
- REQUIRE(nearly_eq(cm->length(), 5, tol));
- REQUIRE(iter.next() == nullptr);
-
- // check the mid-points of a rectangle
-
- path = RawPath();
- const float w = 4, h = 6;
- path.addRect({0, 0, w, h}, PathDirection::cw);
- iter.reset(path, false);
- cm = iter.next();
- REQUIRE(cm);
- REQUIRE(nearly_eq(cm->length(), 2 * (w + h), tol));
- const float midDistances[] = {
- w / 2,
- w + h / 2,
- w + h + w / 2,
- w + h + w + h / 2,
- };
- const ContourMeasure::PosTan midPoints[] = {
- {{w / 2, 0}, {1, 0}},
- {{w, h / 2}, {0, 1}},
- {{w / 2, h}, {-1, 0}},
- {{0, h / 2}, {0, -1}},
- };
- 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));
- }
- REQUIRE(iter.next() == nullptr);
-}
-
-TEST_CASE("multi-contours", "[contourmeasure]") {
- const Vec2D pts[] = {
- {0, 0},
- {3, 0},
- {3, 4},
- };
- auto span = Span(pts, sizeof(pts) / sizeof(pts[0]));
-
- // We expect 3 measurable contours out of this: 7, 16, 7
- // the others should be skipped since they are empty (len == 0)
-
- RawPath path;
- path.addPoly(span, false); // len == 7
-
- path.addPoly(span, true); // len == 12
-
- // should be skipped (lengh == 0)
- path.moveTo(0, 0);
-
- // should be skipped (lengh == 0)
- path.moveTo(0, 0);
- path.close();
-
- // should be skipped (lengh == 0)
- path.moveTo(0, 0);
- path.lineTo(0, 0);
-
- // should be skipped (lengh == 0)
- path.moveTo(0, 0);
- path.lineTo(0, 0);
- path.close();
-
- path.addPoly(span, false); // len == 7
-
- ContourMeasureIter iter(path, false);
- auto cm = iter.next();
- REQUIRE(cm->length() == 7);
- cm = iter.next();
- REQUIRE(cm->length() == 12);
- cm = iter.next();
- REQUIRE(cm->length() == 7);
- cm = iter.next();
- REQUIRE(!cm);
-}
-
-TEST_CASE("contour-oval", "[contourmeasure]") {
- const float tol = 0.0075f;
-
- const float r = 10;
- RawPath path;
- path.addOval({-r, -r, r, r}, PathDirection::cw);
- ContourMeasureIter iter(path, false);
-
- auto cm = iter.next();
- REQUIRE(nearly_eq(cm->length(), 2 * r * math::PI, tol));
- REQUIRE(!iter.next());
-}
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
#include <rive/animation/state_machine_instance.hpp>
-#include "utils/no_op_factory.hpp"
-#include "utils/no_op_renderer.hpp"
+#include "no_op_factory.hpp"
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
#include <rive/shapes/clipping_shape.hpp>
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
-#include "utils/no_op_renderer.hpp"
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
#include <rive/node.hpp>
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
-#include <rive/assets/image_asset.hpp>
-#include "utils/no_op_renderer.hpp"
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
-#include <cstring>
TEST_CASE("file can be read", "[file]") {
- RenderObjectLeakChecker checker;
auto file = ReadRiveFile("../../test/assets/two_artboards.riv");
// Default artboard should be named Two.
}
TEST_CASE("file with animation can be read", "[file]") {
- RenderObjectLeakChecker checker;
auto file = ReadRiveFile("../../test/assets/juice.riv");
auto artboard = file->artboard();
}
TEST_CASE("artboards can be counted and accessed via index or name", "[file]") {
- RenderObjectLeakChecker checker;
auto file = ReadRiveFile("../../test/assets/dependency_test.riv");
// The artboards caqn be counted
}
TEST_CASE("dependencies are as expected", "[file]") {
- RenderObjectLeakChecker checker;
// ┌────┐
// │Blue│
// └────┘
}
TEST_CASE("long name in object is parsed correctly", "[file]") {
- RenderObjectLeakChecker checker;
auto file = ReadRiveFile("../../test/assets/long_name.riv");
auto artboard = file->artboard();
REQUIRE(artboard->objects().size() == 7);
}
-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);
-
- fseek(fp, 0, SEEK_END);
- const size_t length = ftell(fp);
- fseek(fp, 0, SEEK_SET);
- std::vector<uint8_t> bytes(length);
- REQUIRE(fread(bytes.data(), 1, length, fp) == length);
- fclose(fp);
-
- rive::ImportResult result;
- auto file = rive::File::import(bytes, &gNoOpFactory, &result);
- REQUIRE(result == rive::ImportResult::success);
- REQUIRE(file.get() != nullptr);
- REQUIRE(file->artboard() != nullptr);
-
- // Default artboard should be named Two.
- REQUIRE(file->artboard()->name() == "Jellyfish");
-
- // Strip nothing should result in the same file.
- {
- rive::ImportResult stripResult;
- auto strippedBytes = rive::File::stripAssets(bytes, {}, &stripResult);
- REQUIRE(stripResult == rive::ImportResult::success);
- REQUIRE(bytes.size() == strippedBytes.size());
- REQUIRE(std::memcmp(bytes.data(), strippedBytes.data(), bytes.size()) == 0);
- }
-
- // Strip image assets should result in a smaller file.
- {
- rive::ImportResult stripResult;
- auto strippedBytes =
- rive::File::stripAssets(bytes, {rive::ImageAsset::typeKey}, &stripResult);
- REQUIRE(stripResult == rive::ImportResult::success);
- REQUIRE(strippedBytes.size() < bytes.size());
- }
-}
-
// TODO:
// ShapePaint (fill/stroke) needs to be implemented in WASM (jsFill/jsStroke) in
// order to create Paint objects as necessary.
#include <rive/node.hpp>
#include <rive/bones/bone.hpp>
#include <rive/shapes/shape.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include "rive_testing.hpp"
#include <cstdio>
#include <rive/shapes/image.hpp>
#include <rive/assets/image_asset.hpp>
#include <rive/relative_local_asset_resolver.hpp>
-#include <utils/no_op_factory.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_factory.hpp"
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
TEST_CASE("image assets loads correctly", "[assets]") {
- RenderObjectLeakChecker checker;
auto file = ReadRiveFile("../../test/assets/walle.riv");
auto node = file->artboard()->find("walle");
}
TEST_CASE("out of band image assets loads correctly", "[assets]") {
- RenderObjectLeakChecker checker;
rive::NoOpFactory gEmptyFactory;
-
+
std::string filename = "../../test/assets/out_of_band/walle.riv";
rive::RelativeLocalAssetResolver resolver(filename, &gEmptyFactory);
#include <rive/shapes/mesh.hpp>
#include <rive/assets/image_asset.hpp>
#include <rive/relative_local_asset_resolver.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
#include <rive/shapes/clipping_shape.hpp>
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
-#include <utils/no_op_factory.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_factory.hpp"
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
// Make sure no animations were deleted by deleting the instance.
REQUIRE(rive::LinearAnimation::deleteCount == 0);
- size_t numberOfAnimations = file->artboard()->animationCount();
+ int numberOfAnimations = file->artboard()->animationCount();
file.reset(nullptr);
// Now the animations should've been deleted.
REQUIRE(rive::LinearAnimation::deleteCount == numberOfAnimations);
#include <rive/animation/loop.hpp>
#include <rive/animation/linear_animation.hpp>
#include <rive/animation/linear_animation_instance.hpp>
-#include "utils/no_op_factory.hpp"
+#include "no_op_factory.hpp"
#include <catch.hpp>
#include <cstdio>
--- /dev/null
+#include "no_op_factory.hpp"
+#include "no_op_renderer.hpp"
+
+using namespace rive;
+
+NoOpFactory gNoOpFactory;
+
+rcp<RenderBuffer> NoOpFactory::makeBufferU16(Span<const uint16_t>) { return nullptr; }
+rcp<RenderBuffer> NoOpFactory::makeBufferU32(Span<const uint32_t>) { return nullptr; }
+rcp<RenderBuffer> NoOpFactory::makeBufferF32(Span<const float>) { return nullptr; }
+
+rcp<RenderShader> NoOpFactory::makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix) { return nullptr; }
+
+rcp<RenderShader> NoOpFactory::makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix) { return nullptr; }
+
+std::unique_ptr<RenderPath> NoOpFactory::makeRenderPath(Span<const Vec2D> points,
+ Span<const uint8_t> verbs,
+ FillRule) {
+ return std::make_unique<NoOpRenderPath>();
+}
+
+std::unique_ptr<RenderPath> NoOpFactory::makeEmptyRenderPath() {
+ return std::make_unique<NoOpRenderPath>();
+}
+
+std::unique_ptr<RenderPaint> NoOpFactory::makeRenderPaint() {
+ return std::make_unique<NoOpRenderPaint>();
+}
+
+std::unique_ptr<RenderImage> NoOpFactory::decodeImage(Span<const uint8_t>) {
+ return std::make_unique<NoOpRenderImage>();
+}
--- /dev/null
+#ifndef _RIVE_NOOP_FACTORY_HPP_
+#define _RIVE_NOOP_FACTORY_HPP_
+
+#include <rive/renderer.hpp>
+#include <rive/factory.hpp>
+
+namespace rive {
+
+ 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;
+
+ rcp<RenderShader> makeLinearGradient(float sx, float sy,
+ float ex, float ey,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) override;
+
+ rcp<RenderShader> makeRadialGradient(float cx, float cy, float radius,
+ const ColorInt colors[], // [count]
+ const float stops[], // [count]
+ int count,
+ RenderTileMode,
+ const Mat2D* localMatrix = nullptr) override;
+
+ std::unique_ptr<RenderPath> makeRenderPath(Span<const Vec2D> points,
+ Span<const uint8_t> verbs,
+ FillRule) override;
+
+ std::unique_ptr<RenderPath> makeEmptyRenderPath() override;
+
+ std::unique_ptr<RenderPaint> makeRenderPaint() override;
+
+ std::unique_ptr<RenderImage> decodeImage(Span<const uint8_t>) override;
+ };
+
+ static NoOpFactory gNoOpFactory;
+
+} // namespace rive
+#endif
--- /dev/null
+#ifndef _RIVE_NOOP_RENDERER_HPP_
+#define _RIVE_NOOP_RENDERER_HPP_
+
+#include <rive/renderer.hpp>
+#include <rive/factory.hpp>
+#include <vector>
+
+namespace rive {
+ class NoOpRenderImage : public RenderImage {
+ public:
+ rcp<RenderShader> makeShader(RenderTileMode, RenderTileMode, const Mat2D*) const override {
+ return nullptr;
+ }
+ };
+
+ class NoOpRenderPaint : public RenderPaint {
+ public:
+ void color(unsigned int value) override {}
+ void style(RenderPaintStyle value) override {}
+ void thickness(float value) override {}
+ void join(StrokeJoin value) override {}
+ void cap(StrokeCap value) override {}
+ void blendMode(BlendMode value) override {}
+ void shader(rcp<RenderShader>) override {}
+ };
+
+ enum class NoOpPathCommandType { MoveTo, LineTo, CubicTo, Reset, Close };
+
+ struct NoOpPathCommand {
+ NoOpPathCommandType command;
+ float x;
+ float y;
+ float inX;
+ float inY;
+ float outX;
+ float outY;
+ };
+
+ class NoOpRenderPath : public RenderPath {
+ public:
+ std::vector<NoOpPathCommand> commands;
+ void reset() override {
+ commands.emplace_back(
+ (NoOpPathCommand){NoOpPathCommandType::Reset, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f});
+ }
+
+ void fillRule(FillRule value) override {}
+ void addPath(CommandPath* path, const Mat2D& transform) override {}
+ void addRenderPath(RenderPath* path, const Mat2D& transform) override {}
+
+ void moveTo(float x, float y) override {
+ commands.emplace_back(
+ (NoOpPathCommand){NoOpPathCommandType::MoveTo, x, y, 0.0f, 0.0f, 0.0f, 0.0f});
+ }
+ void lineTo(float x, float y) override {
+ commands.emplace_back(
+ (NoOpPathCommand){NoOpPathCommandType::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 {
+ commands.emplace_back(
+ (NoOpPathCommand){NoOpPathCommandType::CubicTo, x, y, ix, iy, ox, oy});
+ }
+ void close() override {
+ commands.emplace_back(
+ (NoOpPathCommand){NoOpPathCommandType::Close, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f});
+ }
+ };
+
+ class NoOpRenderer : public Renderer {
+ void save() override {}
+ void restore() override {}
+ void transform(const Mat2D& transform) override {}
+ void drawPath(RenderPath* path, RenderPaint* paint) override {}
+ void clipPath(RenderPath* path) override {}
+ void drawImage(const RenderImage* image, BlendMode value, float opacity) override {}
+ void drawImageMesh(const RenderImage*,
+ rcp<RenderBuffer> vertices,
+ rcp<RenderBuffer> uvCoords,
+ rcp<RenderBuffer> indices,
+ BlendMode,
+ float opacity) override {}
+ };
+
+} // namespace rive
+#endif
#include <rive/shapes/path_composer.hpp>
#include <rive/shapes/rectangle.hpp>
#include <rive/shapes/shape.hpp>
-#include <utils/no_op_factory.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_factory.hpp"
+#include "no_op_renderer.hpp"
#include <catch.hpp>
#include <cstdio>
-// Need a specialized "noop" factory that does make an inspectable Path
-
-namespace {
-enum class TestPathCommandType { MoveTo, LineTo, CubicTo, Reset, Close };
-
-struct TestPathCommand {
- TestPathCommandType command;
- float x;
- float y;
- float inX;
- float inY;
- float outX;
- float outY;
-};
-
-class TestRenderPath : public rive::RenderPath {
-public:
- std::vector<TestPathCommand> commands;
- void reset() override {
- commands.emplace_back(
- (TestPathCommand){TestPathCommandType::Reset, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f});
- }
-
- void fillRule(rive::FillRule value) override {}
- 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 {
- commands.emplace_back(
- (TestPathCommand){TestPathCommandType::MoveTo, x, y, 0.0f, 0.0f, 0.0f, 0.0f});
- }
- 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 {
- commands.emplace_back(
- (TestPathCommand){TestPathCommandType::CubicTo, x, y, ix, iy, ox, oy});
- }
- 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 {
-public:
- std::unique_ptr<rive::RenderPath> makeEmptyRenderPath() override {
- return std::make_unique<TestRenderPath>();
- }
-};
-} // namespace
-
TEST_CASE("rectangle path builds expected commands", "[path]") {
- TestNoOpFactory emptyFactory;
+ rive::NoOpFactory emptyFactory;
rive::Artboard artboard(&emptyFactory);
rive::Shape* shape = new rive::Shape();
rive::Rectangle* rectangle = new rive::Rectangle();
REQUIRE(rectangle->commandPath() != nullptr);
- auto path = reinterpret_cast<TestRenderPath*>(rectangle->commandPath());
+ auto path = reinterpret_cast<rive::NoOpRenderPath*>(rectangle->commandPath());
REQUIRE(path->commands.size() == 7);
- REQUIRE(path->commands[0].command == TestPathCommandType::Reset);
- REQUIRE(path->commands[1].command == TestPathCommandType::MoveTo);
- REQUIRE(path->commands[2].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[3].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[4].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[5].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[6].command == TestPathCommandType::Close);
+ REQUIRE(path->commands[0].command == rive::NoOpPathCommandType::Reset);
+ REQUIRE(path->commands[1].command == rive::NoOpPathCommandType::MoveTo);
+ REQUIRE(path->commands[2].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[3].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[4].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[5].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[6].command == rive::NoOpPathCommandType::Close);
}
TEST_CASE("rounded rectangle path builds expected commands", "[path]") {
- TestNoOpFactory emptyFactory;
+ rive::NoOpFactory emptyFactory;
rive::Artboard artboard(&emptyFactory);
rive::Shape* shape = new rive::Shape();
rive::Rectangle* rectangle = new rive::Rectangle();
REQUIRE(rectangle->commandPath() != nullptr);
- auto path = reinterpret_cast<TestRenderPath*>(rectangle->commandPath());
+ auto path = reinterpret_cast<rive::NoOpRenderPath*>(rectangle->commandPath());
// reset
// moveTo
REQUIRE(path->commands.size() == 11);
// Init
- REQUIRE(path->commands[0].command == TestPathCommandType::Reset);
- REQUIRE(path->commands[1].command == TestPathCommandType::MoveTo);
+ REQUIRE(path->commands[0].command == rive::NoOpPathCommandType::Reset);
+ REQUIRE(path->commands[1].command == rive::NoOpPathCommandType::MoveTo);
// 1st
- REQUIRE(path->commands[2].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[2].command == rive::NoOpPathCommandType::CubicTo);
// 2nd
- REQUIRE(path->commands[3].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[4].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[3].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[4].command == rive::NoOpPathCommandType::CubicTo);
// 3rd
- REQUIRE(path->commands[5].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[6].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[5].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[6].command == rive::NoOpPathCommandType::CubicTo);
// 4th
- REQUIRE(path->commands[7].command == TestPathCommandType::LineTo);
- REQUIRE(path->commands[8].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[7].command == rive::NoOpPathCommandType::LineTo);
+ REQUIRE(path->commands[8].command == rive::NoOpPathCommandType::CubicTo);
- REQUIRE(path->commands[9].command == TestPathCommandType::LineTo);
+ REQUIRE(path->commands[9].command == rive::NoOpPathCommandType::LineTo);
- REQUIRE(path->commands[10].command == TestPathCommandType::Close);
+ REQUIRE(path->commands[10].command == rive::NoOpPathCommandType::Close);
}
TEST_CASE("ellipse path builds expected commands", "[path]") {
- TestNoOpFactory emptyFactory;
+ rive::NoOpFactory emptyFactory;
rive::Artboard artboard(&emptyFactory);
rive::Ellipse* ellipse = new rive::Ellipse();
rive::Shape* shape = new rive::Shape();
REQUIRE(ellipse->commandPath() != nullptr);
- auto path = reinterpret_cast<TestRenderPath*>(ellipse->commandPath());
+ auto path = reinterpret_cast<rive::NoOpRenderPath*>(ellipse->commandPath());
// reset
// moveTo
REQUIRE(path->commands.size() == 7);
// Init
- REQUIRE(path->commands[0].command == TestPathCommandType::Reset);
- REQUIRE(path->commands[1].command == TestPathCommandType::MoveTo);
+ REQUIRE(path->commands[0].command == rive::NoOpPathCommandType::Reset);
+ REQUIRE(path->commands[1].command == rive::NoOpPathCommandType::MoveTo);
REQUIRE(path->commands[1].x == 0.0f);
REQUIRE(path->commands[1].y == -100.0f);
// 1st
- REQUIRE(path->commands[2].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[2].command == rive::NoOpPathCommandType::CubicTo);
REQUIRE(path->commands[2].outX == 50.0f * rive::circleConstant);
REQUIRE(path->commands[2].outY == -100.0f);
REQUIRE(path->commands[2].inX == 50.0f);
REQUIRE(path->commands[2].y == 0.0f);
// 2nd
- REQUIRE(path->commands[3].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[3].command == rive::NoOpPathCommandType::CubicTo);
REQUIRE(path->commands[3].outX == 50.0f);
REQUIRE(path->commands[3].outY == 100.0f * rive::circleConstant);
REQUIRE(path->commands[3].inX == 50.0f * rive::circleConstant);
REQUIRE(path->commands[3].y == 100.0f);
// 3rd
- REQUIRE(path->commands[4].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[4].command == rive::NoOpPathCommandType::CubicTo);
REQUIRE(path->commands[4].outX == -50.0f * rive::circleConstant);
REQUIRE(path->commands[4].outY == 100.0f);
REQUIRE(path->commands[4].inX == -50.0f);
REQUIRE(path->commands[4].y == 0.0f);
// 4th
- REQUIRE(path->commands[5].command == TestPathCommandType::CubicTo);
+ REQUIRE(path->commands[5].command == rive::NoOpPathCommandType::CubicTo);
REQUIRE(path->commands[5].outX == -50.0f);
REQUIRE(path->commands[5].outY == -100.0f * rive::circleConstant);
REQUIRE(path->commands[5].inX == -50.0f * rive::circleConstant);
REQUIRE(path->commands[5].x == 0.0f);
REQUIRE(path->commands[5].y == -100.0f);
- REQUIRE(path->commands[6].command == TestPathCommandType::Close);
+ REQUIRE(path->commands[6].command == rive::NoOpPathCommandType::Close);
}
\ No newline at end of file
#include <rive/math/aabb.hpp>
#include <rive/math/raw_path.hpp>
+#include "no_op_renderer.hpp"
#include <catch.hpp>
#include <cstdio>
}
}
}
-
-//////////////////////////////////////////////////////////////////////////
-
-static bool is_move(const RawPath::Iter::Rec& rec) {
- if (rec.verb == PathVerb::move) {
- REQUIRE(rec.count == 1);
- return true;
- }
- return false;
-}
-
-static bool is_line(const RawPath::Iter::Rec& rec) {
- if (rec.verb == PathVerb::line) {
- REQUIRE(rec.count == 1);
- return true;
- }
- return false;
-}
-
-static bool is_quad(const RawPath::Iter::Rec& rec) {
- if (rec.verb == PathVerb::quad) {
- REQUIRE(rec.count == 2);
- return true;
- }
- return false;
-}
-
-static bool is_cubic(const RawPath::Iter::Rec& rec) {
- if (rec.verb == PathVerb::cubic) {
- REQUIRE(rec.count == 3);
- return true;
- }
- return false;
-}
-
-static bool is_close(const RawPath::Iter::Rec& rec) {
- if (rec.verb == PathVerb::close) {
- REQUIRE(rec.count == 0);
- return true;
- }
- return false;
-}
-
-// clang-format off
-static inline bool eq(Vec2D p, float x, float y) {
- return p.x == x && p.y == y;
-}
-// clang-format on
-
-TEST_CASE("rawpath-iter", "[rawpath]") {
- {
- RawPath rp;
- RawPath::Iter iter(rp);
- REQUIRE(iter.next() == false);
- REQUIRE(iter.next() == false); // should be safe to call again
- }
- {
- RawPath rp;
- rp.moveTo(1, 2);
- rp.lineTo(3, 4);
- rp.quadTo(5, 6, 7, 8);
- rp.cubicTo(9, 10, 11, 12, 13, 14);
- rp.close();
- RawPath::Iter iter(rp);
- auto rec = iter.next();
- REQUIRE((rec && is_move(rec) && eq(rec.pts[0], 1, 2)));
- rec = iter.next();
- REQUIRE((rec && is_line(rec) && eq(rec.pts[0], 3, 4)));
- rec = iter.next();
- REQUIRE((rec && is_quad(rec) && eq(rec.pts[0], 5, 6) && eq(rec.pts[1], 7, 8)));
- rec = iter.next();
- REQUIRE((rec && is_cubic(rec) && eq(rec.pts[0], 9, 10) && eq(rec.pts[1], 11, 12) &&
- eq(rec.pts[2], 13, 14)));
- rec = iter.next();
- REQUIRE((rec && is_close(rec)));
- rec = iter.next();
- REQUIRE(rec == false);
- REQUIRE(iter.next() == false); // should be safe to call again
- }
-}
-
-TEST_CASE("isDone", "[rawpath::iter]") {
- RawPath rp;
- rp.moveTo(1, 2);
- rp.lineTo(3, 4);
- RawPath::Iter iter(rp);
-
- REQUIRE(!iter.isDone()); // moveTo
- REQUIRE(iter.next());
-
- REQUIRE(!iter.isDone()); // lineTo
- REQUIRE(iter.next());
-
- REQUIRE(iter.isDone()); // now we're done
- REQUIRE(!iter.next());
- REQUIRE(iter.isDone()); // ensure we 'still' think we're done
-}
-
-TEST_CASE("reset", "[rawpath]") {
- RawPath path;
- path.moveTo(1, 2);
- path.lineTo(3, 4);
- RawPath::Iter iter(path);
- auto rec = iter.next();
- REQUIRE((rec && is_move(rec) && eq(rec.pts[0], 1, 2)));
- rec = iter.next();
- REQUIRE((rec && is_line(rec) && eq(rec.pts[0], 3, 4)));
- REQUIRE(!iter.next());
-
- // now change the path (not required for the test per-se)
- path = RawPath();
- path.moveTo(0, 0);
- path.close();
-
- iter.reset(path);
- rec = iter.next();
- REQUIRE((rec && is_move(rec) && eq(rec.pts[0], 0, 0)));
- rec = iter.next();
- REQUIRE((rec && is_close(rec)));
- REQUIRE(!iter.next());
-}
-
-TEST_CASE("backup", "[rawpath]") {
- RawPath rp;
- rp.moveTo(1, 2);
- rp.lineTo(3, 4);
- rp.close();
- RawPath::Iter iter(rp);
-
- auto rec = iter.next();
- REQUIRE((rec && is_move(rec) && eq(rec.pts[0], 1, 2)));
- const Vec2D* move_pts = rec.pts;
-
- rec = iter.next();
- REQUIRE((rec && is_line(rec) && eq(rec.pts[0], 3, 4)));
- const Vec2D* line_pts = rec.pts;
-
- rec = iter.next();
- REQUIRE((rec && is_close(rec)));
-
- rec = iter.next();
- REQUIRE(!rec);
-
- // Now try backing up
-
- iter.backUp(); // go back to 'close'
- rec = iter.next();
- REQUIRE((rec && is_close(rec)));
-
- iter.backUp(); // go back to 'close'
- iter.backUp(); // go back to 'line'
- rec = iter.next();
- REQUIRE((rec && is_line(rec) && eq(rec.pts[0], 3, 4)));
- REQUIRE(rec.pts == line_pts);
-
- iter.backUp(); // go back to 'line'
- iter.backUp(); // go back to 'move'
- rec = iter.next();
- REQUIRE((rec && is_move(rec) && eq(rec.pts[0], 1, 2)));
- REQUIRE(rec.pts == move_pts);
-}
-
-TEST_CASE("addPath", "[rawpath]") {
- using PathMaker = void (*)(RawPath * sink);
-
- const PathMaker makers[] = {
- [](RawPath* sink) {},
- [](RawPath* sink) {
- sink->moveTo(1, 2);
- sink->lineTo(3, 4);
- },
- [](RawPath* sink) {
- sink->moveTo(1, 2);
- sink->lineTo(3, 4);
- sink->close();
- },
- [](RawPath* sink) {
- sink->moveTo(1, 2);
- sink->lineTo(3, 4);
- sink->quadTo(5, 6, 7, 8);
- sink->cubicTo(9, 10, 11, 12, 13, 14);
- sink->close();
- },
- };
- constexpr size_t N = sizeof(makers) / sizeof(makers[0]);
-
- auto direct = [](PathMaker m0, PathMaker m1, const Mat2D* mx) {
- RawPath p;
- m0(&p);
- m1(&p);
- if (mx) {
- p.transformInPlace(*mx);
- }
- return p;
- };
- auto useadd = [](PathMaker m0, PathMaker m1, const Mat2D* mx) {
- RawPath p;
-
- RawPath tmp;
- m0(&tmp);
- p.addPath(tmp, mx);
-
- tmp.reset();
- m1(&tmp);
- p.addPath(tmp, mx);
- return p;
- };
-
- for (auto i = 0; i < N; ++i) {
- for (auto j = 0; j < N; ++j) {
- RawPath p0, p1;
-
- p0 = direct(makers[i], makers[j], nullptr);
- p1 = useadd(makers[i], makers[j], nullptr);
- REQUIRE(p0 == p1);
-
- auto mx = Mat2D::fromScale(2, 3);
- p0 = direct(makers[i], makers[j], &mx);
- p1 = useadd(makers[i], makers[j], &mx);
- REQUIRE(p0 == p1);
- }
- }
-}
-
-TEST_CASE("factory", "[rawpath]") {
- // clang-format off
- const Vec2D pts[] = {
- {1, 2},
- {2, 3},
- {4, 5}, {6, 7}, {8, 9},
- };
- const PathVerb vbs[] = {
- PathVerb::move, PathVerb::line, PathVerb::cubic, PathVerb::close
- };
- // clang-format on
-
- RawPath path0(pts, vbs);
-
- RawPath path1;
- path1.move(pts[0]);
- path1.line(pts[1]);
- path1.cubic(pts[2], pts[3], pts[4]);
- path1.close();
-
- REQUIRE(path0 == path1);
-}
\ No newline at end of file
#define _RIVE_FILE_READER_HPP_
#include <rive/file.hpp>
-#include "rive/rive_counter.hpp"
-
#include "rive_testing.hpp"
-#include "utils/no_op_factory.hpp"
-
-static rive::NoOpFactory gNoOpFactory;
+#include "no_op_factory.hpp"
static inline std::unique_ptr<rive::File>
ReadRiveFile(const char path[],
rive::Factory* factory = nullptr,
rive::FileAssetResolver* resolver = nullptr) {
if (!factory) {
- factory = &gNoOpFactory;
+ factory = &rive::gNoOpFactory;
}
FILE* fp = fopen(path, "rb");
fclose(fp);
rive::ImportResult result;
- auto file = rive::File::import(bytes, factory, &result, resolver);
+ auto file = rive::File::import(rive::toSpan(bytes), factory, &result, resolver);
REQUIRE(result == rive::ImportResult::success);
REQUIRE(file.get() != nullptr);
REQUIRE(file->artboard() != nullptr);
return file;
}
-class RenderObjectLeakChecker {
- int m_before[rive::Counter::kNumTypes];
-
-public:
- RenderObjectLeakChecker() {
- std::copy(rive::Counter::counts,
- rive::Counter::counts + rive::Counter::kNumTypes,
- m_before);
- }
- ~RenderObjectLeakChecker() {
- const int* after = rive::Counter::counts;
- 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);
- }
- }
- }
-};
-
#endif
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) {
- std::ostringstream os;
- os << value[0] << ", " << value[1] << ", " << value[2] << ", " << value[3] << ", "
- << value[4] << ", " << value[5];
- return os.str();
- }
-};
+ 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];
+ return os.str();
+ }
+ };
} // namespace Catch
#endif
\ No newline at end of file
#include <rive/bones/bone.hpp>
#include <rive/shapes/shape.hpp>
#include <rive/math/transform_components.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include "rive_testing.hpp"
#include <cstdio>
#include <rive/bones/bone.hpp>
#include <rive/shapes/shape.hpp>
#include <rive/math/transform_components.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include "rive_testing.hpp"
#include <cstdio>
funcb({carray, 4});
int array[] = {1, 2, 3, 4};
- funca(array);
funca({array, 4});
- funcb(array);
funcb({array, 4});
std::vector<int> v;
- funca(v);
- funcb(v);
+ funca(toSpan(v));
+ funcb(toSpan(v));
}
#include <rive/file.hpp>
#include <rive/animation/state_machine_bool.hpp>
#include <rive/animation/state_machine_layer.hpp>
-#include <rive/animation/state_machine_listener.hpp>
+#include <rive/animation/state_machine_event.hpp>
#include <rive/animation/animation_state.hpp>
#include <rive/animation/entry_state.hpp>
#include <rive/animation/state_transition.hpp>
#include <rive/animation/blend_animation_1d.hpp>
#include <rive/animation/blend_state_direct.hpp>
#include <rive/animation/blend_state_transition.hpp>
-#include <rive/animation/listener_input_change.hpp>
+#include <rive/animation/event_input_change.hpp>
#include <rive/node.hpp>
#include "catch.hpp"
#include "rive_file_reader.hpp"
#include <cstdio>
-TEST_CASE("file with state machine listeners be read", "[file]") {
+TEST_CASE("file with state machine events be read", "[file]") {
auto file = ReadRiveFile("../../test/assets/bullet_man.riv");
auto artboard = file->artboard("Bullet Man");
auto stateMachine = artboard->stateMachine(0);
REQUIRE(stateMachine != nullptr);
- REQUIRE(stateMachine->listenerCount() == 3);
+ REQUIRE(stateMachine->eventCount() == 3);
REQUIRE(stateMachine->inputCount() == 4);
- // Expect each of the three listeners to have one input change each.
- auto listener1 = stateMachine->listener(0);
- auto target1 = artboard->resolve(listener1->targetId());
+ // Expect each of the three events to have one input change each.
+ auto event1 = stateMachine->event(0);
+ auto target1 = artboard->resolve(event1->targetId());
REQUIRE(target1->is<rive::Node>());
REQUIRE(target1->as<rive::Node>()->name() == "HandWickHit");
- REQUIRE(listener1->actionCount() == 1);
- auto inputChange1 = listener1->action(0);
+ REQUIRE(event1->inputChangeCount() == 1);
+ auto inputChange1 = event1->inputChange(0);
REQUIRE(inputChange1 != nullptr);
- REQUIRE(inputChange1->is<rive::ListenerInputChange>());
- REQUIRE(inputChange1->as<rive::ListenerInputChange>()->inputId() == 0);
+ REQUIRE(inputChange1->inputId() == 0);
- auto listener2 = stateMachine->listener(1);
- auto target2 = artboard->resolve(listener2->targetId());
+ auto event2 = stateMachine->event(1);
+ auto target2 = artboard->resolve(event2->targetId());
REQUIRE(target2->is<rive::Node>());
REQUIRE(target2->as<rive::Node>()->name() == "HandCannonHit");
- REQUIRE(listener2->actionCount() == 1);
- auto inputChange2 = listener2->action(0);
+ REQUIRE(event2->inputChangeCount() == 1);
+ auto inputChange2 = event2->inputChange(0);
REQUIRE(inputChange2 != nullptr);
- REQUIRE(inputChange2->is<rive::ListenerInputChange>());
- REQUIRE(inputChange2->as<rive::ListenerInputChange>()->inputId() == 1);
+ REQUIRE(inputChange2->inputId() == 1);
- auto listener3 = stateMachine->listener(2);
- auto target3 = artboard->resolve(listener3->targetId());
+ auto event3 = stateMachine->event(2);
+ auto target3 = artboard->resolve(event3->targetId());
REQUIRE(target3->is<rive::Node>());
REQUIRE(target3->as<rive::Node>()->name() == "HandHelmetHit");
- REQUIRE(listener3->actionCount() == 1);
- auto inputChange3 = listener3->action(0);
+ REQUIRE(event3->inputChangeCount() == 1);
+ auto inputChange3 = event3->inputChange(0);
REQUIRE(inputChange3 != nullptr);
- REQUIRE(inputChange3->is<rive::ListenerInputChange>());
- REQUIRE(inputChange3->as<rive::ListenerInputChange>()->inputId() == 2);
+ REQUIRE(inputChange3->inputId() == 2);
}
TEST_CASE("hit testing via a state machine works", "[file]") {
REQUIRE(trigger->didFire());
}
-TEST_CASE("hit a toggle boolean listener", "[file]") {
+TEST_CASE("hit a toggle boolean event", "[file]") {
auto file = ReadRiveFile("../../test/assets/light_switch.riv");
auto artboard = file->artboard()->instance();
#include <rive/shapes/paint/stroke.hpp>
#include <rive/shapes/paint/solid_color.hpp>
#include <rive/shapes/paint/color.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include <catch.hpp>
#include <cstdio>
#include <rive/node.hpp>
#include <rive/bones/bone.hpp>
#include <rive/shapes/shape.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include "rive_testing.hpp"
#include <cstdio>
#include <rive/bones/bone.hpp>
#include <rive/shapes/shape.hpp>
#include <rive/math/transform_components.hpp>
-#include <utils/no_op_renderer.hpp>
+#include "no_op_renderer.hpp"
#include "rive_file_reader.hpp"
#include "rive_testing.hpp"
#include <cstdio>
+++ /dev/null
-#include "utils/no_op_factory.hpp"
-#include "utils/no_op_renderer.hpp"
-
-using namespace rive;
-
-namespace {
-class NoOpRenderImage : public RenderImage {
-public:
-};
-
-class NoOpRenderPaint : public RenderPaint {
-public:
- void color(unsigned int value) override {}
- void style(RenderPaintStyle value) override {}
- void thickness(float value) override {}
- void join(StrokeJoin value) override {}
- void cap(StrokeCap value) override {}
- void blendMode(BlendMode value) override {}
- void shader(rcp<RenderShader>) override {}
- void invalidateStroke() override {}
-};
-
-class NoOpRenderPath : public RenderPath {
-public:
- void reset() override {}
-
- void fillRule(FillRule value) override {}
- void addPath(CommandPath* path, const Mat2D& transform) override {}
- void addRenderPath(RenderPath* path, const Mat2D& transform) override {}
-
- void moveTo(float x, float y) override {}
- void lineTo(float x, float y) override {}
- void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override {}
- void close() override {}
-};
-} // namespace
-
-rcp<RenderBuffer> NoOpFactory::makeBufferU16(Span<const uint16_t>) { return nullptr; }
-rcp<RenderBuffer> NoOpFactory::makeBufferU32(Span<const uint32_t>) { return nullptr; }
-rcp<RenderBuffer> NoOpFactory::makeBufferF32(Span<const float>) { return nullptr; }
-
-rcp<RenderShader> NoOpFactory::makeLinearGradient(float sx,
- float sy,
- float ex,
- float ey,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- return nullptr;
-}
-
-rcp<RenderShader> NoOpFactory::makeRadialGradient(float cx,
- float cy,
- float radius,
- const ColorInt colors[], // [count]
- const float stops[], // [count]
- size_t count) {
- return nullptr;
-}
-
-std::unique_ptr<RenderPath> NoOpFactory::makeRenderPath(Span<const Vec2D> points,
- Span<const PathVerb> verbs,
- FillRule) {
- return std::make_unique<NoOpRenderPath>();
-}
-
-std::unique_ptr<RenderPath> NoOpFactory::makeEmptyRenderPath() {
- return std::make_unique<NoOpRenderPath>();
-}
-
-std::unique_ptr<RenderPaint> NoOpFactory::makeRenderPaint() {
- return std::make_unique<NoOpRenderPaint>();
-}
-
-std::unique_ptr<RenderImage> NoOpFactory::decodeImage(Span<const uint8_t>) {
- return std::make_unique<NoOpRenderImage>();
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "utils/rive_utf.hpp"
-#include "rive/core/type_conversions.hpp"
-
-using namespace rive;
-
-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) {
- return 1;
- }
- int n = 1;
- lead <<= 1;
- while (lead & 0x80) {
- n += 1;
- lead <<= 1;
- }
- assert(n >= 1 && n <= 4);
- return n;
-}
-
-// 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) {
- const uint8_t* text = *utf8Ptr;
-
- uint32_t c = 0;
- int n = CountUTF8Length(text);
- assert(n >= 1 && n <= 4);
-
- unsigned first = *text++;
- if (n == 1) {
- c = first;
- } else {
- c = first & ((unsigned)0xFF >> n);
- --n;
- do {
- c = (c << 6) | (*text++ & 0x3F);
- } while (--n);
- }
- *utf8Ptr = text; // update the pointer
- return c;
-}
-
-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;
- }
- utf16[0] = castTo<uint16_t>(uni);
- return 1;
-}
+++ /dev/null
-# Rive Viewer
-This is a desktop utility for previewing .riv files, Rive experiments, and different renderers. It also serves as a reference implementation for how to interface the Rive C++ Runtime (rive-cpp) with different renderers and factories for fonts, images, etc.
-
-## Abstraction
-Rive is built to be platform and subsystem agnostic so you can plug-in any renderer to draw all of or only portions of your Rive animations. For example a simple WebGL renderer could only draw Rive meshes and drop all the vector content if it wanted to. Similarly image and font loading can be deferred to platform decoders. We provide some example fully fledged implementations that support all of the Rive features.
-
-## Building
-We currently provide build files for MacOS but we will be adding Windows and others soon too.
-### MacOS
-All the build scripts are in viewer/build/macosx.
-```
-cd viewer/build/macosx
-```
-You can tell the build script to build and run a Viewer that's backed by a Metal view with our Skia renderer:
-```
-./build_viewer.sh metal skia run
-```
-An OpenGL example using a tessellating renderer:
-```
-./build_viewer.sh gl tess run
-```
-Both the Skia and Tess renderers work with either gl or metal options.
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-set -e
-
-source ../../../dependencies/macosx/config_directories.sh
-
-CONFIG=debug
-GRAPHICS=gl
-RENDERER=skia
-
-for var in "$@"; do
- if [[ $var = "release" ]]; then
- CONFIG=release
- fi
- if [[ $var = "gl" ]]; then
- GRAPHICS=gl
- fi
- if [[ $var = "d3d" ]]; then
- GRAPHICS=d3d
- fi
- if [[ $var = "metal" ]]; then
- GRAPHICS=metal
- fi
- if [[ $var = "tess" ]]; then
- RENDERER=tess
- fi
- if [[ $var = "skia" ]]; then
- RENDERER=skia
- fi
-done
-
-if [[ ! -f "$DEPENDENCIES/bin/premake5" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_premake5.sh
- popd
-fi
-
-if [[ ! -d "$DEPENDENCIES/imgui" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_imgui.sh
- popd
-fi
-
-if [[ $RENDERER = "tess" ]] && [[ ! -d "$DEPENDENCIES/libpng" ]]; then
- pushd $DEPENDENCIES_SCRIPTS
- ./get_libpng.sh
- popd
-fi
-
-if [ $RENDERER = "skia" ]; then
- pushd ../../../skia/renderer/build/macosx
- ./build_skia_renderer.sh text $@
- popd
-fi
-
-if [ $RENDERER = "tess" ]; then
- pushd ../../../tess/build/macosx
- ./build_tess.sh $@
- popd
-fi
-
-export PREMAKE=$DEPENDENCIES/bin/premake5
-
-pushd ..
-
-$PREMAKE --file=./premake5_viewer.lua gmake2 --graphics=$GRAPHICS --renderer=$RENDERER
-
-for var in "$@"; do
- if [[ $var = "clean" ]]; then
- make clean
- make config=release clean
- fi
-done
-
-make config=$CONFIG -j$(($(sysctl -n hw.physicalcpu) + 1))
-
-popd
-
-for var in "$@"; do
- if [[ $var = "run" ]]; then
- bin/$CONFIG/$RENDERER/$GRAPHICS/rive_viewer
- fi
- if [[ $var = "lldb" ]]; then
- lldb bin/$CONFIG/$RENDERER/$GRAPHICS/rive_viewer
- fi
-done
+++ /dev/null
-dependencies = os.getenv('DEPENDENCIES')
-
-libpng = dependencies .. '/libpng'
-
-project 'libpng'
-do
- kind 'StaticLib'
- language 'C++'
- cppdialect 'C++17'
- toolset 'clang'
- targetdir '%{cfg.system}/bin/%{cfg.buildcfg}/'
- objdir '%{cfg.system}/obj/%{cfg.buildcfg}/'
- buildoptions {
- '-fno-exceptions',
- '-fno-rtti'
- }
- includedirs {
- '../include/viewer/tess',
- dependencies,
- libpng
- }
- files {
- libpng .. '/png.c',
- libpng .. '/pngerror.c',
- libpng .. '/pngget.c',
- libpng .. '/pngmem.c',
- libpng .. '/pngpread.c',
- libpng .. '/pngread.c',
- libpng .. '/pngrio.c',
- libpng .. '/pngrtran.c',
- libpng .. '/pngrutil.c',
- libpng .. '/pngset.c',
- libpng .. '/pngtrans.c',
- libpng .. '/pngwio.c',
- libpng .. '/pngwrite.c',
- libpng .. '/pngwtran.c',
- libpng .. '/pngwutil.c'
- }
-
- architecture('ARM64')
- do
- files {
- libpng .. '/arm/arm_init.c',
- libpng .. '/arm/filter_neon_intrinsics.c',
- libpng .. '/arm/palette_neon_intrinsics.c'
- }
- end
-end
-
-zlib = dependencies .. '/zlib'
-
-project 'zlib'
-do
- kind 'StaticLib'
- language 'C++'
- cppdialect 'C++17'
- toolset 'clang'
- targetdir '%{cfg.system}/bin/%{cfg.buildcfg}/'
- objdir '%{cfg.system}/obj/%{cfg.buildcfg}/'
- buildoptions {
- '-fno-exceptions',
- '-fno-rtti'
- }
- defines {'ZLIB_IMPLEMENTATION', 'HAVE_UNISTD_H'}
- includedirs {
- zlib
- }
- files {
- zlib .. '/adler32.c',
- zlib .. '/compress.c',
- zlib .. '/crc32.c',
- zlib .. '/deflate.c',
- zlib .. '/gzclose.c',
- zlib .. '/gzlib.c',
- zlib .. '/gzread.c',
- zlib .. '/gzwrite.c',
- zlib .. '/infback.c',
- zlib .. '/inffast.c',
- zlib .. '/inftrees.c',
- zlib .. '/trees.c',
- zlib .. '/uncompr.c',
- zlib .. '/zutil.c',
- zlib .. '/inflate.c'
- }
-end
+++ /dev/null
-workspace 'rive'
-configurations {
- 'debug',
- 'release'
-}
-
-dependencies = os.getenv('DEPENDENCIES')
-
-rive = '../../'
-rive_thirdparty = '../../../../third_party'
-rive_tess = '../../tess'
-rive_skia = '../../skia'
-skia = dependencies .. '/skia'
-libpng = dependencies .. '/libpng'
-
-if _OPTIONS.renderer == 'tess' then
- dofile('premake5_libpng.lua')
- dofile(path.join(path.getabsolute(rive_tess) .. '/build', 'premake5_tess.lua'))
-end
-
-project 'rive_viewer'
-do
- if _OPTIONS.renderer == 'tess' then
- dependson 'libpng'
- end
- kind 'ConsoleApp'
- language 'C++'
- cppdialect 'C++17'
- toolset 'clang'
- targetdir('%{cfg.system}/bin/%{cfg.buildcfg}/' .. _OPTIONS.renderer .. '/' .. _OPTIONS.graphics)
- objdir('%{cfg.system}/obj/%{cfg.buildcfg}/' .. _OPTIONS.renderer .. '/' .. _OPTIONS.graphics)
-
- defines { "RIVE_TEXT" }
-
- includedirs {
- '../include',
- rive .. '/include',
- rive .. '/skia/renderer/include', -- for renderfont backends
- rive_thirdparty .. '/externals/harfbuzz/src',
- dependencies,
- dependencies .. '/sokol',
- dependencies .. '/imgui'
- }
-
- links {
- 'rive',
- 'rive_harfbuzz',
- }
-
- libdirs {
- rive .. '/build/%{cfg.system}/bin/%{cfg.buildcfg}',
- rive_thirdparty .. '/harfbuzz/build/%{cfg.buildcfg}/bin',
- }
-
- files {
- '../src/**.cpp',
- '../../utils/rive_utf.cpp',
- rive .. '/skia/renderer/src/renderfont_coretext.cpp',
- rive .. '/skia/renderer/src/renderfont_hb.cpp',
- rive .. '/utils/rive_utf.cpp',
- dependencies .. '/imgui/imgui.cpp',
- dependencies .. '/imgui/imgui_widgets.cpp',
- dependencies .. '/imgui/imgui_tables.cpp',
- dependencies .. '/imgui/imgui_draw.cpp'
- }
-
- buildoptions {
- '-Wall',
- '-fno-exceptions',
- '-fno-rtti'
- }
-
- filter {
- 'system:macosx'
- }
- do
- links {
- 'Cocoa.framework',
- 'IOKit.framework',
- 'CoreVideo.framework',
- 'OpenGL.framework'
- }
- files {
- '../src/**.m',
- '../src/**.mm'
- }
- end
-
- filter {
- 'system:macosx',
- 'options:graphics=gl'
- }
- do
- links {
- 'OpenGL.framework'
- }
- end
-
- filter {
- 'system:macosx',
- 'options:graphics=metal'
- }
- do
- links {
- 'Metal.framework',
- 'MetalKit.framework',
- 'QuartzCore.framework'
- }
- end
-
- -- Tess Renderer Configuration
- filter {
- 'options:renderer=tess'
- }
- do
- includedirs {
- rive_tess .. '/include',
- libpng
- }
- defines {
- 'RIVE_RENDERER_TESS'
- }
- links {
- 'rive_tess_renderer',
- 'libpng',
- 'zlib'
- }
- libdirs {
- rive_tess .. '/build/%{cfg.system}/bin/%{cfg.buildcfg}'
- }
- end
-
- filter {
- 'options:renderer=tess',
- 'options:graphics=gl'
- }
- do
- defines {
- 'SOKOL_GLCORE33'
- }
- end
-
- filter {
- 'options:renderer=tess',
- 'options:graphics=metal'
- }
- do
- defines {
- 'SOKOL_METAL'
- }
- end
-
- filter {
- 'options:renderer=tess',
- 'options:graphics=d3d'
- }
- do
- defines {
- 'SOKOL_D3D11'
- }
- end
-
- filter {
- 'options:renderer=skia',
- 'options:graphics=gl'
- }
- do
- defines {
- 'SK_GL',
- 'SOKOL_GLCORE33'
- }
- files {
- '../src/skia/viewer_skia_gl.cpp'
- }
- libdirs {
- skia .. '/out/gl/%{cfg.buildcfg}'
- }
- end
-
- filter {
- 'options:renderer=skia',
- 'options:graphics=metal'
- }
- do
- defines {
- 'SK_METAL',
- 'SOKOL_METAL'
- }
- libdirs {
- skia .. '/out/metal/%{cfg.buildcfg}'
- }
- end
-
- filter {
- 'options:renderer=skia',
- 'options:graphics=d3d'
- }
- do
- defines {
- 'SK_DIRECT3D'
- }
- libdirs {
- skia .. '/out/d3d/%{cfg.buildcfg}'
- }
- end
-
- filter {
- 'options:renderer=skia'
- }
- do
- includedirs {
- skia,
- skia .. '/include/core',
- skia .. '/include/effects',
- skia .. '/include/gpu',
- skia .. '/include/config',
- }
- defines {
- 'RIVE_RENDERER_SKIA'
- }
- libdirs {
- rive_skia .. '/renderer/build/%{cfg.system}/bin/%{cfg.buildcfg}',
- rive_thirdparty .. '/harfbuzz/build/%{cfg.buildcfg}/bin'
- }
- links {
- 'skia',
- 'rive_skia_renderer',
- }
- end
-
- filter 'configurations:debug'
- do
- buildoptions {
- '-g'
- }
- defines {
- 'DEBUG'
- }
- symbols 'On'
- end
-
- filter 'configurations:release'
- do
- buildoptions {
- '-flto=full'
- }
- defines {
- 'RELEASE'
- }
- defines {
- 'NDEBUG'
- }
- optimize 'On'
- end
-
- -- CLI config options
- newoption {
- trigger = 'graphics',
- value = 'gl',
- description = 'The graphics api to use.',
- allowed = {
- {
- 'gl'
- },
- {
- 'metal'
- },
- {
- 'd3d'
- }
- }
- }
-
- newoption {
- trigger = 'renderer',
- value = 'skia',
- description = 'The renderer to use.',
- allowed = {
- {
- 'skia'
- },
- {
- 'tess'
- }
- }
- }
-end
+++ /dev/null
-#ifndef _RIVE_BITMAP_DECODER_HPP_
-#define _RIVE_BITMAP_DECODER_HPP_
-
-#include "rive/rive_types.hpp"
-#include "rive/span.hpp"
-
-/// Bitmap will always take ownership of the bytes it is constructed with.
-class Bitmap {
-public:
- enum class PixelFormat : uint8_t { R, RGB, RGBA };
-
- Bitmap(uint32_t width,
- uint32_t height,
- PixelFormat pixelFormat,
- std::unique_ptr<const uint8_t[]> bytes);
-
- Bitmap(uint32_t width, uint32_t height, PixelFormat pixelFormat, const uint8_t* bytes);
-
-private:
- uint32_t m_Width;
- uint32_t m_Height;
- PixelFormat m_PixelFormat;
- std::unique_ptr<const uint8_t[]> m_Bytes;
-
-public:
- uint32_t width() const { return m_Width; }
- uint32_t height() const { return m_Height; }
- PixelFormat pixelFormat() const { return m_PixelFormat; }
- const uint8_t* bytes() const { return m_Bytes.get(); }
- size_t byteSize() const;
- size_t byteSize(PixelFormat format) const;
- size_t bytesPerPixel(PixelFormat format) const;
-
- static std::unique_ptr<Bitmap> decode(rive::Span<const uint8_t> bytes);
-
- // Change the pixel format (note this will resize bytes).
- void pixelFormat(PixelFormat format);
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-#include "libpng/scripts/pnglibconf.h.prebuilt"
\ No newline at end of file
+++ /dev/null
-#ifndef _RIVE_VIEWER_SOKOL_FACTORY_HPP_
-#define _RIVE_VIEWER_SOKOL_FACTORY_HPP_
-
-#include "rive/tess/sokol/sokol_factory.hpp"
-
-class ViewerSokolFactory : public rive::SokolFactory {
-public:
- std::unique_ptr<rive::RenderImage> decodeImage(rive::Span<const uint8_t>) override;
-};
-#endif
\ No newline at end of file
+++ /dev/null
-#ifndef _RIVE_VIEWER_HPP_
-#define _RIVE_VIEWER_HPP_
-
-#ifdef RIVE_RENDERER_SKIA
-#include "GrBackendSurface.h"
-#include "GrDirectContext.h"
-#include "SkCanvas.h"
-#include "SkColorSpace.h"
-#include "SkSurface.h"
-#include "SkTypes.h"
-
-sk_sp<GrDirectContext> makeSkiaContext();
-sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height);
-void skiaPresentSurface(sk_sp<SkSurface> surface);
-#endif
-
-// Helper to ensure the gl context is currently bound.
-void bindGraphicsContext();
-
-#endif
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_VIEWER_CONTENT_HPP_
-#define _RIVE_VIEWER_CONTENT_HPP_
-
-#include "rive/span.hpp"
-#include "rive/refcnt.hpp"
-
-#include "imgui.h"
-
-namespace rive {
-class Renderer;
-class Factory;
-class RenderFont;
-} // namespace rive
-
-class ViewerContent {
-public:
- virtual ~ViewerContent();
-
- virtual void handleResize(int width, int height) = 0;
- virtual void handleDraw(rive::Renderer* renderer, double elapsed) = 0;
- virtual void handleImgui() = 0;
-
- virtual void handlePointerMove(float x, float y) {}
- virtual void handlePointerDown(float x, float y) {}
- virtual void handlePointerUp(float x, float y) {}
-
- 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[]) {
- Factory factories[] = {
- Scene,
- Image,
- Text,
- TextPath,
- };
- for (auto f : factories) {
- if (auto content = f(filename)) {
- return content;
- }
- }
- return nullptr;
- }
-
- // Private factories...
- static std::unique_ptr<ViewerContent> Image(const char[]);
- static std::unique_ptr<ViewerContent> Scene(const char[]);
- static std::unique_ptr<ViewerContent> Text(const char[]);
- static std::unique_ptr<ViewerContent> TextPath(const char[]);
- static std::unique_ptr<ViewerContent> TrimPath(const char[]);
-
- static std::vector<uint8_t> LoadFile(const char path[]);
- static void DumpCounters(const char label[]);
-
- // Abstracts which rive Factory is currently used.
- static rive::Factory* RiveFactory();
-
- // Abstracts which font backend is currently used.
- static rive::rcp<rive::RenderFont> DecodeFont(rive::Span<const uint8_t>);
-};
-
-#endif
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#ifndef _RIVE_VIEWER_HOST_HPP_
-#define _RIVE_VIEWER_HOST_HPP_
-
-#include "rive/factory.hpp"
-#include "rive/renderer.hpp"
-#include "rive/render_text.hpp"
-
-#include "sokol_gfx.h"
-
-class ViewerContent;
-
-class ViewerHost {
-public:
- virtual ~ViewerHost() {}
-
- // subclasses can modify sg_pass_action if they wish, but need not.
- virtual bool init(sg_pass_action*, int width, int height) = 0;
-
- virtual void handleResize(int width, int height) = 0;
-
- // subclasses need only override one or the other
- virtual void beforeDefaultPass(ViewerContent*, double) {}
- virtual void afterDefaultPass(ViewerContent*, double) {}
-
- static std::unique_ptr<ViewerHost> Make();
- static rive::Factory* Factory();
-};
-
-#endif
+++ /dev/null
-#include "sokol_app.h"
-#include "sokol_gfx.h"
-#define SOKOL_IMPL
-#include "imgui.h"
-#include "util/sokol_imgui.h"
\ No newline at end of file
+++ /dev/null
-#include "viewer/viewer.hpp"
-#ifdef SOKOL_GLCORE33
-#include "sokol_app.h"
-#ifndef GL_SILENCE_DEPRECATION
-#define GL_SILENCE_DEPRECATION
-#endif
-#import "Cocoa/Cocoa.h"
-#endif
-
-void bindGraphicsContext() {
-#ifdef SOKOL_GLCORE33
- NSWindow* window = (NSWindow*)sapp_macos_get_window();
- NSOpenGLView* sokolView = (NSOpenGLView*)window.contentView;
- NSOpenGLContext* ctx = [sokolView openGLContext];
- [ctx makeCurrentContext];
-#endif
-}
\ No newline at end of file
+++ /dev/null
-#define SOKOL_IMPL
-#include "sokol_app.h"
-#include "sokol_gfx.h"
-#include "sokol_glue.h"
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_host.hpp"
-#include "viewer/viewer_content.hpp"
-
-#ifdef RIVE_RENDERER_SKIA
-
-#ifdef RIVE_BUILD_FOR_APPLE
-#include "cg_skia_factory.hpp"
-static rive::CGSkiaFactory skiaFactory;
-#else
-#include "skia_factory.hpp"
-static rive::SkiaFactory skiaFactory;
-#endif
-#include "skia_renderer.hpp"
-
-#include "include/core/SkSurface.h"
-#include "include/core/SkCanvas.h"
-#include "include/core/SkPaint.h"
-#include "include/core/SkSize.h"
-#include "GrDirectContext.h"
-
-sk_sp<GrDirectContext> makeSkiaContext();
-sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height);
-void skiaPresentSurface(sk_sp<SkSurface> surface);
-
-// Experimental flag, until we complete coregraphics_host
-//#define TEST_CG_RENDERER
-
-//#define SW_SKIA_MODE
-
-#ifdef TEST_CG_RENDERER
-#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) {
- // cons up a CGContext
- auto pixels = SkData::MakeUninitialized(w * h * 4);
- auto bytes = (uint8_t*)pixels->writable_data();
- std::fill(bytes, bytes + pixels->size(), 0);
- AutoCF space = CGColorSpaceCreateDeviceRGB();
- auto info = kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast;
- AutoCF ctx = CGBitmapContextCreate(bytes, w, h, 8, w * 4, space, info);
-
- // Wrap it with our renderer
- rive::CGRenderer renderer(ctx, w, h);
- content->handleDraw(&renderer, elapsed);
- CGContextFlush(ctx);
-
- // Draw the pixels into the canvas
- auto img = SkImage::MakeRasterData(SkImageInfo::MakeN32Premul(w, h), pixels, w * 4);
- canvas->drawImage(img, 0, 0, SkSamplingOptions(SkFilterMode::kNearest), nullptr);
-}
-#endif
-
-class SkiaViewerHost : public ViewerHost {
-public:
- sk_sp<GrDirectContext> m_context;
- SkISize m_dimensions;
-
- bool init(sg_pass_action* action, int width, int height) override {
- m_dimensions = {width, height};
-
-#if defined(SK_METAL)
- // Skia is layered behind the Sokol view, so we need to make sure Sokol
- // clears transparent. Skia will draw the background.
- *action = (sg_pass_action){.colors[0] = {
- .action = SG_ACTION_CLEAR,
- .value =
- { 0.0f,
- 0.0,
- 0.0f,
- 0.0 }
- }};
-#elif defined(SK_GL)
- // Skia commands are issued to the same GL context before Sokol, so we need
- // to make sure Sokol does not clear the buffer.
- *action = (sg_pass_action){.colors[0] = {.action = SG_ACTION_DONTCARE }};
-#endif
-
- m_context = makeSkiaContext();
- return m_context != nullptr;
- }
-
- void handleResize(int width, int height) override { m_dimensions = {width, height}; }
-
- 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();
- SkPaint paint;
- paint.setColor(0xFF161616);
- canvas->drawPaint(paint);
-
- if (content) {
-#ifdef TEST_CG_RENDERER
- render_with_cg(canvas, m_dimensions.width(), m_dimensions.height(), content, elapsed);
-#elif defined(SW_SKIA_MODE)
- auto info = SkImageInfo::MakeN32Premul(m_dimensions.width(), m_dimensions.height());
- auto swsurf = SkSurface::MakeRaster(info);
- rive::SkiaRenderer skiaRenderer(swsurf->getCanvas());
- content->handleDraw(&skiaRenderer, elapsed);
- auto img = swsurf->makeImageSnapshot();
- canvas->drawImage(img, 0, 0, SkSamplingOptions(SkFilterMode::kNearest), nullptr);
-#else
- rive::SkiaRenderer skiaRenderer(canvas);
- content->handleDraw(&skiaRenderer, elapsed);
-#endif
- }
-
- canvas->flush();
- skiaPresentSurface(surf);
- sg_reset_state_cache();
- }
-};
-
-std::unique_ptr<ViewerHost> ViewerHost::Make() { return std::make_unique<SkiaViewerHost>(); }
-
-rive::Factory* ViewerHost::Factory() {
-#ifdef TEST_CG_RENDERER
- static rive::CGFactory gFactory;
- return &gFactory;
-#else
- return &skiaFactory;
-#endif
-}
-
-#endif
+++ /dev/null
-#if defined(RIVE_RENDERER_SKIA) && defined(SK_GL)
-#include "sokol_app.h"
-#include "sokol_gfx.h"
-#include "viewer/viewer.hpp"
-
-#include "gl/GrGLInterface.h"
-
-sk_sp<GrDirectContext> makeSkiaContext() { return GrDirectContext::MakeGL(); }
-
-sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height) {
- GrGLFramebufferInfo framebufferInfo;
- framebufferInfo.fFBOID = 0;
- framebufferInfo.fFormat = 0x8058; // GL_RGBA8;
-
- GrBackendRenderTarget backendRenderTarget(width,
- height,
- 0, // sample count
- 0, // stencil bits
- framebufferInfo);
-
- return SkSurface::MakeFromBackendRenderTarget(context,
- backendRenderTarget,
- kBottomLeft_GrSurfaceOrigin,
- kRGBA_8888_SkColorType,
- nullptr,
- nullptr);
-}
-
-void skiaPresentSurface(sk_sp<SkSurface> surface) {}
-#endif
\ No newline at end of file
+++ /dev/null
-#if defined(RIVE_RENDERER_SKIA) && defined(SK_METAL)
-#include "viewer/viewer.hpp"
-#include "sokol_app.h"
-#include "sokol_gfx.h"
-
-#import <Metal/Metal.h>
-#import <MetalKit/MetalKit.h>
-#include "mtl/GrMtlBackendContext.h"
-#include "mtl/GrMtlTypes.h"
-#import <QuartzCore/CAMetalLayer.h>
-#import "Cocoa/Cocoa.h"
-
-id<MTLCommandQueue> commandQueue;
-id<CAMetalDrawable> drawable;
-GrMtlTextureInfo mtlTexture;
-MTKView* skiaView;
-NSView* contentView;
-
-typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
- UIViewAutoresizingNone = 0,
- UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
- UIViewAutoresizingFlexibleWidth = 1 << 1,
- UIViewAutoresizingFlexibleRightMargin = 1 << 2,
- UIViewAutoresizingFlexibleTopMargin = 1 << 3,
- UIViewAutoresizingFlexibleHeight = 1 << 4,
- UIViewAutoresizingFlexibleBottomMargin = 1 << 5
-};
-
-sk_sp<GrDirectContext> makeSkiaContext() {
- // This is a little tricky...when using Metal we need to divorce the two
- // views so we don't get contention between Sokol drawing (mostly for ImGui)
- // with Metal and Skia drawing with Metal. I couldn't find a good way to let
- // them share a command queue, so drawing to two separate Metal Layers is
- // the next best thing.
- id<MTLDevice> device = (id<MTLDevice>)sg_mtl_device();
- commandQueue = [device newCommandQueue];
-
- NSWindow* window = (NSWindow*)sapp_macos_get_window();
-
- // Add a new metal view to our window.
- skiaView = [[MTKView alloc] init];
- skiaView.device = device;
- skiaView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
- [skiaView setWantsLayer:YES];
-
- // Grab the current contentView which is the default view Sokol App creates.
- NSView* sokolView = window.contentView;
- sokolView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-
- // Make a new contentView (root container).
- contentView = [[NSView alloc] init];
- contentView.frame = sokolView.bounds;
- skiaView.frame = sokolView.bounds;
- window.contentView = contentView;
-
- // Add Sokol and Skia views to it. Make sure to layer Sokol over Skia.
- [contentView addSubview:skiaView];
- [contentView addSubview:sokolView];
- // Make sure Sokol view is transparent so ImGui can draw over our Skia
- // content.
- sokolView.layer.opaque = false;
-
- return GrDirectContext::MakeMetal(device, commandQueue);
-}
-
-sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height) {
- NSView* view = skiaView;
- CAMetalLayer* layer = (CAMetalLayer*)view.layer;
-
- drawable = [layer nextDrawable];
- GrMtlTextureInfo fbInfo;
- fbInfo.fTexture.retain((const void*)(drawable.texture));
- GrBackendRenderTarget renderTarget =
- GrBackendRenderTarget(width, height, 1 /* sample count/MSAA */, fbInfo);
-
- return SkSurface::MakeFromBackendRenderTarget(
- context, renderTarget, kTopLeft_GrSurfaceOrigin, kBGRA_8888_SkColorType, nullptr, nullptr);
-}
-
-void skiaPresentSurface(sk_sp<SkSurface> surface) {
- id<MTLCommandBuffer> commandBuffer = [(id<MTLCommandQueue>)commandQueue commandBuffer];
- commandBuffer.label = @"Present";
- [commandBuffer presentDrawable:(id<CAMetalDrawable>)drawable];
- [commandBuffer commit];
-}
-
-#endif
\ No newline at end of file
+++ /dev/null
-#include "sokol_app.h"
-#include "imgui.h"
-
-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)) {
-
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
- ImGui::Text("fps");
- ImGui::TableNextColumn();
- ImGui::Text("%.1f", ImGui::GetIO().Framerate);
-
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
- ImGui::Text("ms/frame");
- ImGui::TableNextColumn();
- ImGui::Text("%.3f", 1000.0f / ImGui::GetIO().Framerate);
-
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
- ImGui::Text("window size");
- ImGui::TableNextColumn();
- ImGui::Text("%dx%d (%.1f)", sapp_width(), sapp_height(), sapp_dpi_scale());
-
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
- ImGui::Text("graphics api");
- ImGui::TableNextColumn();
- ImGui::Text(
-#if defined(SOKOL_GLCORE33)
- "OpenGL 3.3"
-#elif defined(SOKOL_GLES2)
- "OpenGL ES 2"
-#elif defined(SOKOL_GLES3)
- "OpenGL ES 3"
-#elif defined(SOKOL_D3D11)
- "D3D11"
-#elif defined(SOKOL_METAL)
- "Metal"
-#elif defined(SOKOL_WGPU)
- "WebGPU"
-#endif
- );
-
- ImGui::TableNextRow();
- ImGui::TableNextColumn();
- ImGui::Text("renderer");
- ImGui::TableNextColumn();
- ImGui::Text(
-#if defined(RIVE_RENDERER_TESS)
- "Rive Tess"
-#elif defined(RIVE_RENDERER_SKIA)
- "Rive Skia"
-#endif
- );
-
- ImGui::EndTable();
- }
-
- ImGui::SetWindowSize(ImVec2(230.0f, 102.0f));
- ImGui::SetWindowPos(ImVec2(sapp_width() / sapp_dpi_scale() - ImGui::GetWindowWidth(),
- sapp_height() / sapp_dpi_scale() - ImGui::GetWindowHeight()),
- true);
- ImGui::End();
-}
\ No newline at end of file
+++ /dev/null
-#ifdef RIVE_RENDERER_TESS
-#include "viewer/tess/bitmap_decoder.hpp"
-#include <vector>
-
-Bitmap::Bitmap(uint32_t width,
- 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)) {}
-
-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)) {}
-
-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 {
- return m_Width * m_Height * bytesPerPixel(format);
-}
-
-size_t Bitmap::byteSize() const { return byteSize(m_PixelFormat); }
-
-std::unique_ptr<Bitmap> DecodePng(rive::Span<const uint8_t> bytes);
-std::unique_ptr<Bitmap> DecodeJpeg(rive::Span<const uint8_t> bytes) { return nullptr; }
-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 {
- const char* name;
- std::vector<const uint8_t> fingerprint;
- BitmapDecoder decodeImage;
-};
-
-std::unique_ptr<Bitmap> Bitmap::decode(rive::Span<const uint8_t> bytes) {
- static ImageFormat decoders[] = {
- {
- "png",
- {0x89, 0x50, 0x4E, 0x47},
- DecodePng,
- },
- {
- "jpeg",
- {0xFF, 0xD8, 0xFF},
- DecodeJpeg,
- },
- {
- "webp",
- {0x52, 0x49, 0x46},
- DecodeWebP,
- },
- };
-
- 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()) {
- 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) {
- continue;
- }
-
- auto bitmap = recognizer.decodeImage(bytes);
- if (!bitmap) {
- fprintf(stderr, "Bitmap::decode - failed to decode a %s.\n", recognizer.name);
- }
- return bitmap;
- }
- return nullptr;
-}
-
-void Bitmap::pixelFormat(PixelFormat format) {
- if (format == m_PixelFormat) {
- return;
- }
- auto nextByteSize = byteSize(format);
- auto nextBytes = std::make_unique<uint8_t[]>(nextByteSize);
-
- auto fromBytesPerPixel = bytesPerPixel(m_PixelFormat);
- 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++) {
- nextBytes[writeIndex++] = j < fromBytesPerPixel ? m_Bytes[readIndex++] : 255;
- }
- }
-
- m_Bytes = std::move(nextBytes);
- m_PixelFormat = format;
-}
-#endif
\ No newline at end of file
+++ /dev/null
-#ifdef RIVE_RENDERER_TESS
-#include "viewer/tess/bitmap_decoder.hpp"
-#include "viewer/tess/pnglibconf.h"
-#include "png.h"
-
-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) {
- png_voidp a = png_get_io_ptr(png_ptr);
- if (a == nullptr) {
- return;
- }
- EncodedImageBuffer& stream = *(EncodedImageBuffer*)a;
-
- size_t bytesRead = std::min(byteCountToRead, (stream.size - stream.position));
- memcpy(outBytes, stream.bytes + stream.position, bytesRead);
- stream.position += bytesRead;
-
- if ((png_size_t)bytesRead != byteCountToRead) {
- // Report image error?
- }
-}
-
-std::unique_ptr<Bitmap> DecodePng(rive::Span<const uint8_t> bytes) {
- png_structp png_ptr;
- png_infop info_ptr;
- png_uint_32 width, height;
- int bit_depth, color_type, interlace_type;
-
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, 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) {
- png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
- printf("DecodePng - libpng failed (png_create_info_struct).");
- return nullptr;
- }
-
- EncodedImageBuffer stream = {
- .bytes = bytes.data(),
- .size = bytes.size(),
- .position = 0,
- };
-
- png_set_read_fn(png_ptr, &stream, ReadDataFromMemory);
-
- png_read_info(png_ptr, info_ptr);
-
- png_get_IHDR(png_ptr,
- info_ptr,
- &width,
- &height,
- &bit_depth,
- &color_type,
- &interlace_type,
- NULL,
- NULL);
-
- png_set_strip_16(png_ptr);
-
- int bitDepth = 0;
- 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)) {
- png_set_expand(png_ptr);
- bitDepth += 8;
- }
- } else if (color_type == PNG_COLOR_TYPE_GRAY) {
- png_set_expand(png_ptr);
- bitDepth = 8;
- } 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) {
- png_set_expand(png_ptr);
- bitDepth = 32;
- }
-
- int pixelBytes = bitDepth / 8;
- auto pixelBuffer = new uint8_t[width * height * pixelBytes];
-
- png_bytep* row_pointers = new png_bytep[height];
-
- for (unsigned row = 0; row < height; row++) {
- unsigned int rIndex = row;
- // if (flipY) {
- // rIndex = height - row - 1;
- // }
- row_pointers[rIndex] = pixelBuffer + (row * (width * pixelBytes));
- }
- png_read_image(png_ptr, row_pointers);
- png_read_end(png_ptr, info_ptr);
-
- png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) nullptr);
-
- delete[] row_pointers;
-
- 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;
- }
- return std::make_unique<Bitmap>(width, height, pixelFormat, pixelBuffer);
-}
-#endif
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_host.hpp"
-#include "viewer/viewer_content.hpp"
-
-#ifdef RIVE_RENDERER_TESS
-
-#include "rive/tess/sokol/sokol_tess_renderer.hpp"
-#include "viewer/tess/viewer_sokol_factory.hpp"
-
-class TessViewerHost : public ViewerHost {
-public:
- std::unique_ptr<rive::SokolTessRenderer> m_renderer;
-
- 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 {
- m_renderer->orthographicProjection(0.0f, width, height, 0.0f, 0.0f, 1.0f);
- }
-
- void afterDefaultPass(ViewerContent* content, double elapsed) override {
- m_renderer->reset();
- if (content) {
- content->handleDraw(m_renderer.get(), elapsed);
- }
- }
-};
-
-std::unique_ptr<ViewerHost> ViewerHost::Make() { return std::make_unique<TessViewerHost>(); }
-
-rive::Factory* ViewerHost::Factory() {
- static ViewerSokolFactory sokolFactory;
- return &sokolFactory;
-}
-
-#endif
+++ /dev/null
-#ifdef RIVE_RENDERER_TESS
-#include "viewer/tess/viewer_sokol_factory.hpp"
-#include "viewer/tess/bitmap_decoder.hpp"
-#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) {
- auto bitmap = Bitmap::decode(bytes);
- 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) {
- bitmap->pixelFormat(Bitmap::PixelFormat::RGBA);
- }
-
- return std::make_unique<rive::SokolRenderImage>(bitmap->bytes(),
- bitmap->width(),
- bitmap->height());
- }
- return nullptr;
-}
-#endif
\ No newline at end of file
+++ /dev/null
-// Viewer & Rive
-#include "viewer/viewer.hpp"
-#include "viewer/viewer_content.hpp"
-#include "viewer/viewer_host.hpp"
-#include "rive/shapes/paint/color.hpp"
-
-// Graphics and UI abstraction
-#include "sokol_app.h"
-#include "sokol_gfx.h"
-#include "sokol_glue.h"
-#include "imgui.h"
-#include "util/sokol_imgui.h"
-
-// Std lib
-#include <stdio.h>
-#include <memory>
-
-std::unique_ptr<ViewerHost> g_Host = ViewerHost::Make();
-std::unique_ptr<ViewerContent> g_Content = ViewerContent::TrimPath("");
-static struct { sg_pass_action pass_action; } state;
-
-void displayStats();
-
-static const int backgroundColor = rive::colorARGB(255, 22, 22, 22);
-
-static void init(void) {
- sg_desc descriptor = {
- .context = sapp_sgcontext(),
- .buffer_pool_size = 1024,
- .pipeline_pool_size = 1024,
- };
- sg_setup(&descriptor);
- simgui_desc_t imguiDescriptor = {
- .write_alpha_channel = true,
- };
- simgui_setup(&imguiDescriptor);
-
- // If the host doesn't overwrite this (in init()), Sokol is in full control,
- // so let's clear to our bg color.
- state.pass_action = (sg_pass_action){
- .colors[0] =
- {
- .action = SG_ACTION_CLEAR,
- .value =
- {
- rive::colorRed(backgroundColor) / 255.0f,
- rive::colorGreen(backgroundColor) / 255.0f,
- rive::colorBlue(backgroundColor) / 255.0f,
- rive::colorOpacity(backgroundColor),
- },
- },
- .stencil =
- {
- .action = SG_ACTION_CLEAR,
- },
- };
-
- if (!g_Host->init(&state.pass_action, sapp_width(), sapp_height())) {
- fprintf(stderr, "failed to initialize host\n");
- sapp_quit();
- }
-}
-
-static void frame(void) {
- auto dur = sapp_frame_duration();
-
- g_Host->beforeDefaultPass(g_Content.get(), dur);
-
- sg_begin_default_pass(&state.pass_action, sapp_width(), sapp_height());
-
- g_Host->afterDefaultPass(g_Content.get(), dur);
-
- simgui_frame_desc_t imguiDesc = {
- .width = sapp_width(),
- .height = sapp_height(),
- .delta_time = sapp_frame_duration(),
- .dpi_scale = sapp_dpi_scale(),
- };
- simgui_new_frame(&imguiDesc);
-
- displayStats();
-
- if (g_Content) {
- g_Content->handleImgui();
- }
- simgui_render();
-
- sg_end_pass();
- sg_commit();
-}
-
-static void cleanup(void) {
- g_Content = nullptr;
- g_Host = nullptr;
-
- simgui_shutdown();
- sg_shutdown();
-}
-
-static void event(const sapp_event* ev) {
- simgui_handle_event(ev);
-
- switch (ev->type) {
- case SAPP_EVENTTYPE_RESIZED:
- 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: {
- // 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) {
- const char* filename = sapp_get_dropped_file_path(numDroppedFiles - 1);
- auto newContent = ViewerContent::findHandler(filename);
- if (newContent) {
- g_Content = std::move(newContent);
- g_Content->handleResize(ev->framebuffer_width, ev->framebuffer_height);
- } else {
- fprintf(stderr, "No handler found for %s\n", filename);
- }
- }
- break;
- }
- case SAPP_EVENTTYPE_MOUSE_DOWN:
- case SAPP_EVENTTYPE_TOUCHES_BEGAN:
- 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) {
- g_Content->handlePointerUp(ev->mouse_x, ev->mouse_y);
- break;
- }
- case SAPP_EVENTTYPE_MOUSE_MOVE:
- case SAPP_EVENTTYPE_TOUCHES_MOVED:
- 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;
- }
- break;
- default: break;
- }
-}
-
-sapp_desc sokol_main(int argc, char* argv[]) {
- (void)argc;
- (void)argv;
-
- 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 "
-#if defined(SOKOL_GLCORE33)
- "(OpenGL 3.3)",
-#elif defined(SOKOL_GLES2)
- "(OpenGL ES 2)",
-#elif defined(SOKOL_GLES3)
- "(OpenGL ES 3)",
-#elif defined(SOKOL_D3D11)
- "(D3D11)",
-#elif defined(SOKOL_METAL)
- "(Metal)",
-#elif defined(SOKOL_WGPU)
- "(WebGPU)",
-#endif
- .width = 800, .height = 600, .icon.sokol_default = true, .gl_force_gles2 = true,
- };
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_content.hpp"
-#include "rive/factory.hpp"
-#include "rive/renderer.hpp"
-
-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 {
- renderer->drawImage(m_image.get(), rive::BlendMode::srcOver, 1);
- }
-
- void handleResize(int width, int height) override {}
- void handleImgui() override {}
-};
-
-std::unique_ptr<ViewerContent> ViewerContent::Image(const char filename[]) {
- auto bytes = LoadFile(filename);
- auto image = RiveFactory()->decodeImage(bytes);
- if (image) {
- return std::make_unique<ImageContent>(std::move(image));
- }
- return nullptr;
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "rive/animation/linear_animation_instance.hpp"
-#include "rive/animation/state_machine_instance.hpp"
-#include "rive/animation/state_machine_input_instance.hpp"
-#include "rive/animation/state_machine_number.hpp"
-#include "rive/animation/state_machine_bool.hpp"
-#include "rive/animation/state_machine_trigger.hpp"
-#include "rive/artboard.hpp"
-#include "rive/file.hpp"
-#include "rive/layout.hpp"
-#include "rive/math/aabb.hpp"
-#include "viewer/viewer_content.hpp"
-
-constexpr int REQUEST_DEFAULT_SCENE = -1;
-
-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
- std::vector<std::string> artboardNames;
- std::vector<std::string> animationNames;
- std::vector<std::string> stateMachineNames;
-
- void loadArtboardNames() {
- if (m_File) {
- artboardNames.clear();
- auto abCnt = m_File->artboardCount();
-
- for (int i = 0; i < abCnt; i++) {
- auto abName = m_File->artboardNameAt(i);
- artboardNames.push_back(abName);
- }
- }
- }
-
- void loadNames(const rive::Artboard* ab) {
- animationNames.clear();
- stateMachineNames.clear();
- 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) {
- stateMachineNames.push_back(ab->stateMachineNameAt(i));
- }
- }
- }
-
- std::string m_Filename;
- std::unique_ptr<rive::File> m_File;
-
- std::unique_ptr<rive::ArtboardInstance> m_ArtboardInstance;
- std::unique_ptr<rive::Scene> m_CurrentScene;
- int m_ArtboardIndex = 0;
- int m_AnimationIndex = 0;
- int m_StateMachineIndex = -1;
-
- int m_width = 0, m_height = 0;
- rive::Mat2D m_InverseViewTransform;
-
- void initArtboard(int index) {
- if (!m_File)
- return;
- loadArtboardNames();
- m_ArtboardInstance = nullptr;
-
- m_ArtboardIndex = (index == REQUEST_DEFAULT_SCENE) ? 0 : index;
- m_ArtboardInstance = m_File->artboardAt(m_ArtboardIndex);
-
- m_ArtboardInstance->advance(0.0f);
- loadNames(m_ArtboardInstance.get());
-
- initStateMachine(REQUEST_DEFAULT_SCENE);
- }
-
- void initStateMachine(int index) {
- m_StateMachineIndex = -1;
- m_AnimationIndex = -1;
- m_CurrentScene = nullptr;
-
- m_ArtboardInstance->advance(0.0f);
-
- if (index < 0) {
- m_CurrentScene = m_ArtboardInstance->defaultStateMachine();
- index = m_ArtboardInstance->defaultStateMachineIndex();
- }
- if (!m_CurrentScene) {
- if (index >= m_ArtboardInstance->stateMachineCount()) {
- index = 0;
- }
- m_CurrentScene = m_ArtboardInstance->stateMachineAt(index);
- }
- if (!m_CurrentScene) {
- index = -1;
- m_CurrentScene = m_ArtboardInstance->animationAt(0);
- m_AnimationIndex = 0;
- }
- m_StateMachineIndex = index;
-
- if (m_CurrentScene) {
- m_CurrentScene->inputCount();
- }
-
- DumpCounters("After loading file");
- }
-
- 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()) {
- m_AnimationIndex = index;
- m_CurrentScene = m_ArtboardInstance->animationAt(index);
- m_CurrentScene->inputCount();
- }
-
- DumpCounters("After loading file");
- }
-
-public:
- SceneContent(const char filename[], std::unique_ptr<rive::File> file) :
- m_Filename(filename), m_File(std::move(file)) {
- initArtboard(REQUEST_DEFAULT_SCENE);
- }
-
- void handlePointerMove(float x, float y) override {
- auto pointer = m_InverseViewTransform * rive::Vec2D(x, y);
- if (m_CurrentScene) {
- m_CurrentScene->pointerMove(pointer);
- }
- }
-
- void handlePointerDown(float x, float y) override {
- auto pointer = m_InverseViewTransform * rive::Vec2D(x, y);
- if (m_CurrentScene) {
- m_CurrentScene->pointerDown(pointer);
- }
- }
-
- void handlePointerUp(float x, float y) override {
- auto pointer = m_InverseViewTransform * rive::Vec2D(x, y);
- if (m_CurrentScene) {
- m_CurrentScene->pointerUp(pointer);
- }
- }
-
- void handleResize(int width, int height) override {
- m_width = width;
- m_height = height;
- }
-
- void handleDraw(rive::Renderer* renderer, double elapsed) override {
- renderer->save();
-
- auto viewTransform = rive::computeAlignment(rive::Fit::contain,
- rive::Alignment::center,
- rive::AABB(0, 0, m_width, m_height),
- m_ArtboardInstance->bounds());
- renderer->transform(viewTransform);
- // Store the inverse view so we can later go from screen to world.
- m_InverseViewTransform = viewTransform.invertOrIdentity();
-
- if (m_CurrentScene) {
- m_CurrentScene->advanceAndApply(elapsed);
- m_CurrentScene->draw(renderer);
- } else {
- m_ArtboardInstance->draw(renderer); // we're just a still-frame file/artboard
- }
-
- renderer->restore();
- }
-
- void handleImgui() override {
- if (m_ArtboardInstance != nullptr) {
- ImGui::Begin(m_Filename.c_str(), nullptr);
- if (ImGui::ListBox(
- "Artboard",
- &m_ArtboardIndex,
- [](void* data, int index, const char** name) {
- auto& names = *static_cast<std::vector<std::string>*>(data);
- *name = names[index].c_str();
- return true;
- },
- &artboardNames,
- artboardNames.size(),
- 4))
- {
- initArtboard(m_ArtboardIndex);
- }
- if (ImGui::ListBox(
- "Animations",
- &m_AnimationIndex,
- [](void* data, int index, const char** name) {
- auto& names = *static_cast<std::vector<std::string>*>(data);
- *name = names[index].c_str();
- return true;
- },
- &animationNames,
- animationNames.size(),
- 4))
- {
- m_StateMachineIndex = -1;
- initAnimation(m_AnimationIndex);
- }
- if (ImGui::ListBox(
- "State Machines",
- &m_StateMachineIndex,
- [](void* data, int index, const char** name) {
- auto& names = *static_cast<std::vector<std::string>*>(data);
- *name = names[index].c_str();
- return true;
- },
- &stateMachineNames,
- stateMachineNames.size(),
- 4))
- {
- m_AnimationIndex = -1;
- initStateMachine(m_StateMachineIndex);
- }
- if (m_CurrentScene != nullptr) {
-
- ImGui::Columns(2);
- ImGui::SetColumnWidth(0, ImGui::GetWindowWidth() * 0.6666);
-
- for (int i = 0; i < m_CurrentScene->inputCount(); i++) {
- auto inputInstance = m_CurrentScene->input(i);
-
- 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];
- snprintf(label, 256, "##%u", i);
-
- auto number = static_cast<rive::SMINumber*>(inputInstance);
- float v = number->value();
- ImGui::InputFloat(label, &v, 1.0f, 2.0f, "%.3f");
- number->value(v);
- ImGui::NextColumn();
- } 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)) {
- auto trigger = static_cast<rive::SMITrigger*>(inputInstance);
- trigger->fire();
- }
- ImGui::NextColumn();
- } 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];
- snprintf(label, 256, "##%u", i);
- auto boolInput = static_cast<rive::SMIBool*>(inputInstance);
- bool value = boolInput->value();
-
- ImGui::Checkbox(label, &value);
- boolInput->value(value);
- ImGui::NextColumn();
- }
- ImGui::Text("%s", inputInstance->input()->name().c_str());
- ImGui::NextColumn();
- }
-
- ImGui::Columns(1);
- }
- ImGui::End();
-
- } else {
- ImGui::Text("Drop a .riv file to preview.");
- }
- }
-};
-
-std::unique_ptr<ViewerContent> ViewerContent::Scene(const char filename[]) {
- auto bytes = LoadFile(filename);
- if (auto file = rive::File::import(bytes, RiveFactory())) {
- return std::make_unique<SceneContent>(filename, std::move(file));
- }
- return nullptr;
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_content.hpp"
-#include "utils/rive_utf.hpp"
-
-#include "rive/factory.hpp"
-#include "rive/refcnt.hpp"
-#include "rive/render_text.hpp"
-#include "rive/text/line_breaker.hpp"
-
-using RenderFontTextRuns = std::vector<rive::RenderTextRun>;
-using RenderFontGlyphRuns = std::vector<rive::RenderGlyphRun>;
-using RenderFontFactory = rive::rcp<rive::RenderFont> (*)(const rive::Span<const uint8_t>);
-
-static bool ws(rive::Unichar c) { return c <= ' '; }
-
-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;) {
- // skip ws
- while (i < len && ws(chars[i])) {
- ++i;
- }
- breaks.push_back(i); // word start
- // skip non-ws
- while (i < len && !ws(chars[i])) {
- ++i;
- }
- breaks.push_back(i); // word end
- }
- assert(breaks[breaks.size() - 1] == len);
- return breaks;
-}
-
-static void drawrun(rive::Factory* factory,
- rive::Renderer* renderer,
- const rive::RenderGlyphRun& run,
- unsigned startIndex,
- unsigned endIndex,
- 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) {
- auto trans = rive::Mat2D::fromTranslate(origin.x + run.xpos[i], origin.y);
- auto rawpath = font->getPath(run.glyphs[i]);
- rawpath.transformInPlace(trans * scale);
- auto path = factory->makeRenderPath(rawpath, rive::FillRule::nonZero);
- renderer->drawPath(path.get(), paint.get());
- }
-}
-
-static void drawpara(rive::Factory* factory,
- rive::Renderer* renderer,
- rive::Span<const rive::RenderGlyphLine> lines,
- rive::Span<const rive::RenderGlyphRun> runs,
- 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) {
- const auto& run = runs[runIndex];
- int endGIndex = runIndex == line.endRun ? line.endIndex : run.glyphs.size();
- drawrun(factory,
- renderer,
- run,
- startGIndex,
- endGIndex,
- {origin.x - x0, origin.y + line.baseline});
- startGIndex = 0;
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef RIVE_USING_HAFBUZZ_FONTS
-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) {
- printf(" %X", m);
- }
- printf("\n");
-
- if (!gFallbackFont) {
- // TODO: make this more sharable for our test apps
- FILE* fp = fopen("/Users/mike/fonts/Arial Unicode.ttf", "rb");
- if (!fp) {
- return nullptr;
- }
-
- fseek(fp, 0, SEEK_END);
- size_t size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- std::vector<uint8_t> bytes(size);
- size_t bytesRead = fread(bytes.data(), 1, size, fp);
- fclose(fp);
-
- assert(bytesRead == size);
- gFallbackFont = HBRenderFont::Decode(bytes);
- }
- return gFallbackFont;
-}
-#endif
-
-static std::unique_ptr<rive::RenderPath> make_line(rive::Factory* factory,
- rive::Vec2D a,
- rive::Vec2D b) {
- rive::Vec2D pts[] = {a, b};
- rive::PathVerb vbs[] = {rive::PathVerb::move, rive::PathVerb::line};
- return factory->makeRenderPath(pts, vbs, rive::FillRule::nonZero);
-}
-
-static void draw_line(rive::Factory* factory, rive::Renderer* renderer, float x) {
- auto paint = factory->makeRenderPaint();
- paint->style(rive::RenderPaintStyle::stroke);
- paint->thickness(1);
- paint->color(0xFFFFFFFF);
- auto path = make_line(factory, {x, 0}, {x, 1000});
- renderer->drawPath(path.get(), paint.get());
-}
-
-static rive::RenderTextRun append(std::vector<rive::Unichar>* unichars,
- rive::rcp<rive::RenderFont> font,
- float size,
- const char text[]) {
- const uint8_t* ptr = (const uint8_t*)text;
- uint32_t n = 0;
- while (*ptr) {
- unichars->push_back(rive::UTF::NextUTF8(&ptr));
- n += 1;
- }
- return {std::move(font), size, n};
-}
-
-class TextContent : public ViewerContent {
- std::vector<rive::Unichar> m_unichars;
- std::vector<int> m_breaks;
-
- std::vector<RenderFontGlyphRuns> m_gruns;
- rive::Mat2D m_xform;
- float m_width = 300;
-
- RenderFontTextRuns make_truns(RenderFontFactory fact) {
- auto loader = [fact](const char filename[]) -> rive::rcp<rive::RenderFont> {
- auto bytes = ViewerContent::LoadFile(filename);
- if (bytes.size() == 0) {
- assert(false);
- return nullptr;
- }
- return fact(bytes);
- };
-
- const char* fontFiles[] = {
- "../../../test/assets/RobotoFlex.ttf",
- "../../../test/assets/LibreBodoni-Italic-VariableFont_wght.ttf",
- };
-
- auto font0 = loader(fontFiles[0]);
- auto font1 = loader(fontFiles[1]);
- assert(font0);
- assert(font1);
-
- rive::RenderFont::Coord c1 = {'wght', 100.f}, c2 = {'wght', 800.f};
-
- RenderFontTextRuns truns;
-
- truns.push_back(append(&m_unichars, font0->makeAtCoord(c2), 60, "U"));
- truns.push_back(append(&m_unichars, font0->makeAtCoord(c1), 30, "ne漢字asy"));
- truns.push_back(append(&m_unichars, font1, 30, " fits the crown"));
- truns.push_back(append(&m_unichars, font1->makeAtCoord(c1), 30, " that often"));
- truns.push_back(append(&m_unichars, font0, 30, " lies the head."));
-
- m_breaks = compute_word_breaks(m_unichars);
-
- return truns;
- }
-
-public:
- 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) {
- renderer->save();
- renderer->transform(m_xform);
-
- auto lines = rive::RenderGlyphLine::BreakLines(gruns, m_breaks, width);
-
- drawpara(RiveFactory(), renderer, lines, gruns, {0, 0});
- draw_line(RiveFactory(), renderer, width);
-
- renderer->restore();
- }
-
- 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 {
- ImGui::Begin("text", nullptr);
- ImGui::SliderFloat("Width", &m_width, 10, 400);
- ImGui::End();
- }
-};
-
-static bool ends_width(const char str[], const char suffix[]) {
- size_t ln = strlen(str);
- size_t lx = strlen(suffix);
- if (lx > ln) {
- return false;
- }
- 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")) {
- return std::make_unique<TextContent>();
- }
- return nullptr;
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_content.hpp"
-#include "utils/rive_utf.hpp"
-
-#include "rive/refcnt.hpp"
-#include "rive/factory.hpp"
-#include "rive/render_text.hpp"
-#include "rive/math/contour_measure.hpp"
-#include "rive/text/line_breaker.hpp"
-
-using namespace rive;
-
-using RenderFontTextRuns = std::vector<RenderTextRun>;
-using RenderFontGlyphRuns = std::vector<RenderGlyphRun>;
-using RenderFontFactory = rcp<RenderFont> (*)(const Span<const uint8_t>);
-
-template <typename Handler>
-void visit(const std::vector<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);
- path.transformInPlace(mx);
- proc(path);
- }
- }
-}
-
-static Vec2D ave(Vec2D a, Vec2D b) { return (a + b) * 0.5f; }
-
-static RawPath make_quad_path(Span<const Vec2D> pts) {
- const int N = pts.size();
- RawPath path;
- if (N >= 2) {
- path.move(pts[0]);
- if (N == 2) {
- path.line(pts[1]);
- } else if (N == 3) {
- path.quad(pts[1], pts[2]);
- } 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]);
- }
- }
- return path;
-}
-
-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(const RawPath& path) {
- return ViewerContent::RiveFactory()->makeRenderPath(path, FillRule::nonZero);
-}
-
-static void stroke_path(Renderer* renderer, const RawPath& path, float size, ColorInt color) {
- auto paint = ViewerContent::RiveFactory()->makeRenderPaint();
- paint->color(color);
- paint->thickness(size);
- paint->style(RenderPaintStyle::stroke);
- renderer->drawPath(make_rpath(path).get(), paint.get());
-}
-
-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) {
- 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[]) {
- const uint8_t* ptr = (const uint8_t*)text;
- uint32_t n = 0;
- while (*ptr) {
- unichars->push_back(rive::UTF::NextUTF8(&ptr));
- n += 1;
- }
- return {std::move(font), size, n};
-}
-
-class TextPathContent : public ViewerContent {
- std::vector<Unichar> m_unichars;
- RenderFontGlyphRuns m_gruns;
- std::unique_ptr<RenderPaint> m_paint;
- AABB m_gbounds;
-
- std::vector<Vec2D> m_pathpts;
- Vec2D m_lastPt = {0, 0};
- int m_trackingIndex = -1;
- Mat2D m_trans;
-
- Mat2D m_oneLineXform;
- bool m_trackingOneLine = false;
- float m_oneLineX = 0;
- float m_flareRadius = 50;
-
- float m_alignment = 0, m_scaleY = 1, m_offsetY = 0,
- m_windowWidth = 1, // %
- m_windowOffset = 0; // %
-
- RenderFontTextRuns make_truns(RenderFontFactory fact) {
- auto loader = [fact](const char filename[]) -> rcp<RenderFont> {
- auto bytes = ViewerContent::LoadFile(filename);
- if (bytes.size() == 0) {
- assert(false);
- return nullptr;
- }
- return fact(bytes);
- };
-
- const char* fontFiles[] = {
- "../../../test/assets/RobotoFlex.ttf",
- "../../../test/assets/LibreBodoni-Italic-VariableFont_wght.ttf",
- };
-
- auto font0 = loader(fontFiles[0]);
- auto font1 = loader(fontFiles[1]);
- assert(font0);
- assert(font1);
-
- RenderFont::Coord c1 = {'wght', 100.f}, c2 = {'wght', 800.f};
-
- RenderFontTextRuns truns;
-
- truns.push_back(append(&m_unichars, font0->makeAtCoord(c2), 60, "U"));
- truns.push_back(append(&m_unichars, font0->makeAtCoord(c1), 30, "ne漢字asy"));
- truns.push_back(append(&m_unichars, font1, 30, " fits the crown"));
- truns.push_back(append(&m_unichars, font1->makeAtCoord(c1), 30, " that often"));
- truns.push_back(append(&m_unichars, font0, 30, " lies the head."));
-
- return truns;
- }
-
-public:
- TextPathContent() {
- auto compute_bounds = [](const std::vector<RenderGlyphRun>& gruns) {
- AABB bounds = {};
- 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);
- }
- bounds.minX = gruns.front().xpos.front();
- bounds.maxX = gruns.back().xpos.back();
- printf("%g %g %g %g\n", bounds.left(), bounds.top(), bounds.right(), bounds.bottom());
- return bounds;
- };
-
- auto truns = this->make_truns(ViewerContent::DecodeFont);
-
- m_gruns = truns[0].font->shapeText(m_unichars, truns);
-
- m_gbounds = compute_bounds(m_gruns);
- m_oneLineXform = Mat2D::fromScale(2.5, 2.5) * Mat2D::fromTranslate(20, 80);
-
- m_paint = ViewerContent::RiveFactory()->makeRenderPaint();
- m_paint->color(0xFFFFFFFF);
-
- m_pathpts.push_back({20, 300});
- m_pathpts.push_back({220, 100});
- m_pathpts.push_back({420, 500});
- m_pathpts.push_back({620, 100});
- m_pathpts.push_back({820, 300});
-
- m_trans = Mat2D::fromTranslate(200, 200) * Mat2D::fromScale(2, 2);
- }
-
- void draw_warp(Renderer* renderer, const 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) {
- fill_point(renderer, p, r, paint.get());
- }
- }
-
- static size_t count_glyphs(const RenderFontGlyphRuns& gruns) {
- size_t n = 0;
- for (const auto& gr : gruns) {
- n += gr.glyphs.size();
- }
- return n;
- }
-
- void modify(float amount) { m_paint->color(0xFFFFFFFF); }
-
- 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) *
- Mat2D::fromScale(run.size, run.size * m_scaleY));
- return path;
- };
-
- renderer->save();
- renderer->transform(m_trans);
-
- RawPath warp = make_quad_path(m_pathpts);
- this->draw_warp(renderer, warp);
-
- auto meas = ContourMeasureIter(warp).next();
-
- const float warpLength = meas->length();
- const float textLength = gruns.back().xpos.back();
- const float offset = (warpLength - textLength) * m_alignment;
-
- const size_t glyphCount = count_glyphs(gruns);
- 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) {
- 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) {
- this->modify(amount);
- }
-
- auto path = get_path(gr, i, offset);
- warp_in_place(meas.get(), &path);
- renderer->drawPath(make_rpath(path).get(), m_paint.get());
- glyphIndex += 1;
- m_scaleY = scaleY;
- }
- }
- renderer->restore();
- }
-
- void drawOneLine(Renderer* renderer) {
- auto paint = ViewerContent::RiveFactory()->makeRenderPaint();
- paint->color(0xFF88FFFF);
-
- 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};
- paint->shader(ViewerContent::RiveFactory()->makeLinearGradient(m_gbounds.left(),
- 0,
- m_gbounds.right(),
- 0,
- colors,
- stops,
- 5));
- }
-
- struct EaseWindow {
- float center, radius;
-
- float map(float x) const {
- float dist = std::abs(center - x);
- if (dist > radius) {
- return 0;
- }
- float t = (radius - dist) / radius;
- return t * t * (3 - 2 * t);
- }
- };
-
- auto wrap_path = [](const RawPath& src, float x, float rad) {
- return src.morph([x, rad](Vec2D p) {
- Vec2D newpt = p;
- newpt.y = p.y * 4 + 18;
-
- const float t = EaseWindow{x, rad}.map(p.x);
- return Vec2D::lerp(p, newpt, t);
- });
- };
-
- visit(m_gruns, {0, 0}, [&](const RawPath& rp) {
- const RawPath* ptr = &rp;
- RawPath storage;
- if (m_trackingOneLine) {
- storage = wrap_path(rp, m_oneLineX, m_flareRadius);
- ptr = &storage;
- }
- renderer->drawPath(make_rpath(*ptr).get(), paint.get());
- });
- }
-
- void handleDraw(rive::Renderer* renderer, double) override {
- renderer->save();
- this->draw(renderer, m_gruns);
- renderer->restore();
-
- renderer->save();
- renderer->transform(m_oneLineXform);
- this->drawOneLine(renderer);
- renderer->restore();
- }
-
- 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();
- };
-
- // are we on onLine?
- {
- m_trackingOneLine = false;
- auto pos = m_oneLineXform.invertOrIdentity() * Vec2D{x, y};
- if (contains(m_gbounds.inset(-8, 0), pos)) {
- m_trackingOneLine = true;
- m_oneLineX = pos.x;
- return;
- }
- }
-
- // are we on the path?
- m_lastPt = m_trans.invertOrIdentity() * Vec2D{x, y};
- if (m_trackingIndex >= 0) {
- m_pathpts[m_trackingIndex] = m_lastPt;
- }
- }
- 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])) {
- m_trackingIndex = i;
- break;
- }
- }
- }
-
- void handlePointerUp(float x, float y) override { m_trackingIndex = -1; }
-
- void handleResize(int width, int height) 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);
- ImGui::SliderFloat("Offset Y", &m_offsetY, -100, 100);
- ImGui::SliderFloat("Window Offset", &m_windowOffset, -1.1f, 1.1f);
- ImGui::SliderFloat("Window Width", &m_windowWidth, 0, 1.2f);
- ImGui::SliderFloat("Flare radius", &m_flareRadius, 10, 100);
- ImGui::End();
- }
-};
-
-std::unique_ptr<ViewerContent> ViewerContent::TextPath(const char filename[]) {
- return std::make_unique<TextPathContent>();
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_content.hpp"
-#include "rive/factory.hpp"
-#include "rive/renderer.hpp"
-#include "rive/math/contour_measure.hpp"
-
-using namespace rive;
-
-static Vec2D ave(Vec2D a, Vec2D b) { return (a + b) * 0.5f; }
-
-static RawPath make_quad_path(Span<const Vec2D> pts) {
- const int N = pts.size();
- RawPath path;
- if (N >= 2) {
- path.move(pts[0]);
- if (N == 2) {
- path.line(pts[1]);
- } else if (N == 3) {
- path.quad(pts[1], pts[2]);
- } 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]);
- }
- }
- return path;
-}
-
-////////////////////////////////////////////////////////////////////////////////////
-
-static std::unique_ptr<RenderPath> make_rpath(const RawPath& path) {
- return ViewerContent::RiveFactory()->makeRenderPath(path, FillRule::nonZero);
-}
-
-static void stroke_path(Renderer* renderer, const RawPath& path, float size, ColorInt color) {
- auto paint = ViewerContent::RiveFactory()->makeRenderPaint();
- paint->color(color);
- paint->thickness(size);
- paint->style(RenderPaintStyle::stroke);
- renderer->drawPath(make_rpath(path).get(), paint.get());
-}
-
-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) {
- 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) {
- // start and end are 0...1
- auto startD = startT * cm->length();
- auto endD = endT * cm->length();
- if (startD > endD) {
- std::swap(startD, endD);
- }
-
- RawPath path;
- cm->getSegment(startD, endD, &path, true);
- return path;
-}
-
-class TrimPathContent : public ViewerContent {
- std::vector<Vec2D> m_pathpts;
- int m_trackingIndex = -1;
-
- float m_trimFrom = 0, m_trimTo = 1;
-
-public:
- TrimPathContent() {
- m_pathpts.push_back({20, 300});
- m_pathpts.push_back({220, 100});
- m_pathpts.push_back({420, 500});
- m_pathpts.push_back({620, 100});
- m_pathpts.push_back({820, 300});
- }
-
- void handleDraw(rive::Renderer* renderer, double) override {
- auto path = make_quad_path(m_pathpts);
-
- RawPath cubicpath;
- cubicpath.move(m_pathpts[0]);
- cubicpath.cubic(m_pathpts[1], m_pathpts[2], m_pathpts[3]);
- cubicpath.line(m_pathpts[4]);
-
- const RawPath* ps[] = {&path, &cubicpath};
-
- renderer->save();
- for (auto p : ps) {
- renderer->save();
-
- auto cm = ContourMeasureIter(*p, false).next();
- auto p1 = trim(cm.get(), m_trimFrom, m_trimTo);
- stroke_path(renderer, p1, 20, 0xFFFF0000);
-
- stroke_path(renderer, *p, 4, 0xFFFFFFFF);
-
- renderer->restore();
- renderer->translate(0, 500);
- }
- renderer->restore();
-
- auto paint = ViewerContent::RiveFactory()->makeRenderPaint();
- paint->color(0xFF008800);
- const float r = 6;
- for (auto p : m_pathpts) {
- fill_point(renderer, p, r, paint.get());
- }
- }
-
- 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 {
- 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])) {
- m_trackingIndex = i;
- break;
- }
- }
- }
-
- void handlePointerUp(float x, float y) override { m_trackingIndex = -1; }
-
- void handleResize(int width, int height) override {}
-
- void handleImgui() override {
- ImGui::Begin("trim", nullptr);
- ImGui::SliderFloat("From", &m_trimFrom, 0, 1);
- ImGui::SliderFloat("To", &m_trimTo, 0, 1);
- ImGui::End();
- }
-};
-
-std::unique_ptr<ViewerContent> ViewerContent::TrimPath(const char[]) {
- return std::make_unique<TrimPathContent>();
-}
+++ /dev/null
-/*
- * Copyright 2022 Rive
- */
-
-#include "viewer/viewer_content.hpp"
-#include "rive/rive_counter.hpp"
-#include <vector>
-
-ViewerContent::~ViewerContent() { DumpCounters("After deleting content"); }
-
-const char* gCounterNames[] = {
- "file",
- "artboard",
- "animation",
- "machine",
- "buffer",
- "path",
- "paint",
- "shader",
- "image",
-};
-
-std::vector<uint8_t> ViewerContent::LoadFile(const char filename[]) {
- std::vector<uint8_t> bytes;
-
- FILE* fp = fopen(filename, "rb");
- if (!fp) {
- fprintf(stderr, "Can't find file: %s\n", filename);
- return bytes;
- }
-
- fseek(fp, 0, SEEK_END);
- size_t size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- bytes.resize(size);
- size_t bytesRead = fread(bytes.data(), 1, size, fp);
- fclose(fp);
-
- if (bytesRead != size) {
- fprintf(stderr, "Failed to read all of %s\n", filename);
- bytes.resize(0);
- }
- return bytes;
-}
-
-void ViewerContent::DumpCounters(const char label[]) {
- assert(sizeof(gCounterNames) / sizeof(gCounterNames[0]) == rive::Counter::kLastType + 1);
-
- if (label == nullptr) {
- label = "Counters";
- }
- printf("%s:", label);
- for (int i = 0; i <= rive::Counter::kLastType; ++i) {
- printf(" [%s]:%d", gCounterNames[i], rive::Counter::counts[i]);
- }
- printf("\n");
-}
-
-#include "viewer/viewer_host.hpp"
-
-rive::Factory* ViewerContent::RiveFactory() { return ViewerHost::Factory(); }
-
-#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) {
- return CoreTextRenderFont::Decode(span);
-}
-#else
-#include "renderfont_hb.hpp"
-rive::rcp<rive::RenderFont> ViewerContent::DecodeFont(rive::Span<const uint8_t> span) {
- return HBRenderFont::Decode(span);
-}
-#endif