Update ObjC formatting to look more similar to the C++
Also update the auto formatter to run on *.m and *.mm files, and effectively ban breaking on return types entirely, as I think this is ugly.
Diffs=
c7d125c7d Update ObjC formatting to look more similar to the C++
diff --git a/.rive_head b/.rive_head
index 859ae8c..30c2abb 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-f1ddd88d4e3b6d33adb85154b50dc86d0c3079fd
+c7d125c7d4efe1233c16c2a95fb7b637b746b010
diff --git a/include/rive/animation/blend_state_transition.hpp b/include/rive/animation/blend_state_transition.hpp
index a406ba9..caf316c 100644
--- a/include/rive/animation/blend_state_transition.hpp
+++ b/include/rive/animation/blend_state_transition.hpp
@@ -16,8 +16,8 @@
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;
};
diff --git a/include/rive/animation/state_transition.hpp b/include/rive/animation/state_transition.hpp
index ce63bbf..3d0529e 100644
--- a/include/rive/animation/state_transition.hpp
+++ b/include/rive/animation/state_transition.hpp
@@ -100,8 +100,8 @@
/// Provide the animation instance to use for computing percentage
/// durations for exit time.
- virtual const LinearAnimationInstance*
- exitTimeAnimationInstance(const StateInstance* from) const;
+ virtual const LinearAnimationInstance* exitTimeAnimationInstance(
+ const StateInstance* from) const;
/// Provide the animation to use for computing percentage durations for
/// exit time.
diff --git a/include/rive/core/reader.h b/include/rive/core/reader.h
index 2c9a2fc..f6969ba 100644
--- a/include/rive/core/reader.h
+++ b/include/rive/core/reader.h
@@ -37,8 +37,10 @@
/* Decodes a string
*/
-inline uint64_t
-decode_string(uint64_t str_len, const uint8_t* buf, const uint8_t* buf_end, char* char_buf)
+inline uint64_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)
diff --git a/include/rive/math/simd_gvec_polyfill.hpp b/include/rive/math/simd_gvec_polyfill.hpp
index 2066060..4885f96 100644
--- a/include/rive/math/simd_gvec_polyfill.hpp
+++ b/include/rive/math/simd_gvec_polyfill.hpp
@@ -27,8 +27,11 @@
{
return (i1 << 5) | (i0 << 3) | sourceVectorLength;
}
-constexpr static Swizzle
-PackSwizzle4(uint32_t sourceVectorLength, uint32_t i0, uint32_t i1, uint32_t i2, uint32_t i3)
+constexpr static Swizzle PackSwizzle4(uint32_t sourceVectorLength,
+ uint32_t i0,
+ uint32_t i1,
+ uint32_t i2,
+ uint32_t i3)
{
return (i3 << 9) | (i2 << 7) | PackSwizzle2(sourceVectorLength, i0, i1);
}
diff --git a/include/rive/shapes/paint/linear_gradient.hpp b/include/rive/shapes/paint/linear_gradient.hpp
index 446997e..83e7bbd 100644
--- a/include/rive/shapes/paint/linear_gradient.hpp
+++ b/include/rive/shapes/paint/linear_gradient.hpp
@@ -34,8 +34,11 @@
void renderOpacityChanged() override;
bool internalIsTranslucent() const override;
- virtual void
- makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count);
+ virtual void makeGradient(Vec2D start,
+ Vec2D end,
+ const ColorInt[],
+ const float[],
+ size_t count);
};
} // namespace rive
diff --git a/include/rive/shapes/paint/radial_gradient.hpp b/include/rive/shapes/paint/radial_gradient.hpp
index 36409f9..0c18bd2 100644
--- a/include/rive/shapes/paint/radial_gradient.hpp
+++ b/include/rive/shapes/paint/radial_gradient.hpp
@@ -6,8 +6,11 @@
class RadialGradient : public RadialGradientBase
{
public:
- void
- makeGradient(Vec2D start, Vec2D end, const ColorInt[], const float[], size_t count) override;
+ void makeGradient(Vec2D start,
+ Vec2D end,
+ const ColorInt[],
+ const float[],
+ size_t count) override;
};
} // namespace rive
diff --git a/include/rive/text_engine.hpp b/include/rive/text_engine.hpp
index 40618c9..4029f5e 100644
--- a/include/rive/text_engine.hpp
+++ b/include/rive/text_engine.hpp
@@ -68,8 +68,10 @@
static SimpleArray<GlyphLine> BreakLines(Span<const GlyphRun> runs, float width);
// Compute values for top/baseline/bottom per line
- static void
- ComputeLineSpacing(Span<GlyphLine>, Span<const GlyphRun>, float width, TextAlign align);
+ static void ComputeLineSpacing(Span<GlyphLine>,
+ Span<const GlyphRun>,
+ float width,
+ TextAlign align);
static float ComputeMaxWidth(Span<GlyphLine> lines, Span<const GlyphRun> runs);
};
diff --git a/src/animation/blend_state_transition.cpp b/src/animation/blend_state_transition.cpp
index 3a44be3..9380ef5 100644
--- a/src/animation/blend_state_transition.cpp
+++ b/src/animation/blend_state_transition.cpp
@@ -8,8 +8,8 @@
using namespace rive;
-const LinearAnimationInstance*
-BlendStateTransition::exitTimeAnimationInstance(const StateInstance* from) const
+const LinearAnimationInstance* BlendStateTransition::exitTimeAnimationInstance(
+ const StateInstance* from) const
{
if (from != nullptr)
{
diff --git a/src/animation/state_transition.cpp b/src/animation/state_transition.cpp
index 0de42e7..caffa41 100644
--- a/src/animation/state_transition.cpp
+++ b/src/animation/state_transition.cpp
@@ -108,8 +108,8 @@
return exitTime() / 1000.0f;
}
-const LinearAnimationInstance*
-StateTransition::exitTimeAnimationInstance(const StateInstance* from) const
+const LinearAnimationInstance* StateTransition::exitTimeAnimationInstance(
+ const StateInstance* from) const
{
return from != nullptr && from->state()->is<AnimationState>()
? static_cast<const AnimationStateInstance*>(from)->animationInstance()
diff --git a/src/math/hit_test.cpp b/src/math/hit_test.cpp
index b803242..77a4c50 100644
--- a/src/math/hit_test.cpp
+++ b/src/math/hit_test.cpp
@@ -47,8 +47,13 @@
template <typename T> T ave(T a, T b) { return lerp(a, b, 0.5f); }
-static void
-append_line(const float height, Point p0, Point p1, float m, int winding, int delta[], int iwidth)
+static void append_line(const float height,
+ Point p0,
+ Point p1,
+ float m,
+ int winding,
+ int delta[],
+ int iwidth)
{
assert(winding == 1 || winding == -1);
diff --git a/src/text/font_hb.cpp b/src/text/font_hb.cpp
index 26b8f22..68da68a 100644
--- a/src/text/font_hb.cpp
+++ b/src/text/font_hb.cpp
@@ -52,13 +52,21 @@
extern "C"
{
- static void
- rpath_move_to(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, float x, float y, void*)
+ static void rpath_move_to(hb_draw_funcs_t*,
+ void* rpath,
+ hb_draw_state_t*,
+ float x,
+ float y,
+ void*)
{
((rive::RawPath*)rpath)->moveTo(x * gInvScale, -y * gInvScale);
}
- static void
- rpath_line_to(hb_draw_funcs_t*, void* rpath, hb_draw_state_t*, float x1, float y1, void*)
+ static void rpath_line_to(hb_draw_funcs_t*,
+ void* rpath,
+ hb_draw_state_t*,
+ float x1,
+ float y1,
+ void*)
{
((rive::RawPath*)rpath)->lineTo(x1 * gInvScale, -y1 * gInvScale);
}
diff --git a/viewer/src/platform/viewer_gl.mm b/viewer/src/platform/viewer_gl.mm
index ae45be5..69ff417 100644
--- a/viewer/src/platform/viewer_gl.mm
+++ b/viewer/src/platform/viewer_gl.mm
@@ -7,11 +7,12 @@
#import "Cocoa/Cocoa.h"
#endif
-void bindGraphicsContext() {
+void bindGraphicsContext()
+{
#ifdef SOKOL_GLCORE33
- NSWindow* window = (NSWindow*)sapp_macos_get_window();
- NSOpenGLView* sokolView = (NSOpenGLView*)window.contentView;
- NSOpenGLContext* ctx = [sokolView openGLContext];
- [ctx makeCurrentContext];
+ 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
diff --git a/viewer/src/skia/viewer_skia_metal.mm b/viewer/src/skia/viewer_skia_metal.mm
index be715d3..2e1b829 100644
--- a/viewer/src/skia/viewer_skia_metal.mm
+++ b/viewer/src/skia/viewer_skia_metal.mm
@@ -17,71 +17,76 @@
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
+ 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];
+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();
+ 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];
+ // 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);
+ // 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;
+ // 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;
+ // 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);
+ return GrDirectContext::MakeMetal(device, commandQueue);
}
-sk_sp<SkSurface> makeSkiaSurface(GrDirectContext* context, int width, int height) {
- NSView* view = skiaView;
- CAMetalLayer* layer = (CAMetalLayer*)view.layer;
+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);
+ 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);
+ 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];
+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