Skip to content

Commit

Permalink
Drop the ColumnLimit to 80 for clang-format
Browse files Browse the repository at this point in the history
This gives better support for smaller screens and side-by-side windows.

Also standardize the formatting check on GitHub on version 17.

Diffs=
e52e9fff29 Drop the ColumnLimit to 80 for clang-format (#8320)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Oct 11, 2024
1 parent 71fd5c4 commit 163f1be
Show file tree
Hide file tree
Showing 846 changed files with 417,973 additions and 308,236 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52913023ba59036aa8f96685f1df5d9173551f72
e52e9fff2973ce63a689e9d11ea283214109ca18
4 changes: 3 additions & 1 deletion cg_renderer/include/cg_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ namespace rive
class CGFactory : public Factory
{
public:
rcp<RenderBuffer> makeRenderBuffer(RenderBufferType, RenderBufferFlags, size_t) override;
rcp<RenderBuffer> makeRenderBuffer(RenderBufferType,
RenderBufferFlags,
size_t) override;

rcp<RenderShader> makeLinearGradient(float sx,
float sy,
Expand Down
107 changes: 76 additions & 31 deletions cg_renderer/src/cg_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ class CGRenderPath : public lite_rtti_override<RenderPath, CGRenderPath>
p += 1;
break;
case PathVerb::quad:
CGPathAddQuadCurveToPoint(m_path, nullptr, p[0].x, p[0].y, p[1].x, p[1].y);
CGPathAddQuadCurveToPoint(m_path,
nullptr,
p[0].x,
p[0].y,
p[1].x,
p[1].y);
p += 2;
break;
case PathVerb::cubic:
Expand Down Expand Up @@ -144,12 +149,20 @@ class CGRenderPath : public lite_rtti_override<RenderPath, CGRenderPath>
}
void fillRule(FillRule value) override
{
m_fillMode = (value == FillRule::nonZero) ? CGPathDrawingMode::kCGPathFill
: CGPathDrawingMode::kCGPathEOFill;
m_fillMode = (value == FillRule::nonZero)
? CGPathDrawingMode::kCGPathFill
: CGPathDrawingMode::kCGPathEOFill;
}
void moveTo(float x, float y) override { CGPathMoveToPoint(m_path, nullptr, x, y); }
void lineTo(float x, float y) override { CGPathAddLineToPoint(m_path, nullptr, x, y); }
void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override
void 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);
}
Expand Down Expand Up @@ -190,14 +203,22 @@ class CGRenderPaint : public lite_rtti_override<RenderPaint, CGRenderPaint>
{
if (m_isStroke)
{
CGContextSetRGBStrokeColor(ctx, m_rgba[0], m_rgba[1], m_rgba[2], m_rgba[3]);
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]);
CGContextSetRGBFillColor(ctx,
m_rgba[0],
m_rgba[1],
m_rgba[2],
m_rgba[3]);
}
CGContextSetBlendMode(ctx, m_blend);
}
Expand All @@ -218,7 +239,9 @@ class CGRenderPaint : public lite_rtti_override<RenderPaint, CGRenderPaint>
void invalidateStroke() override {}
};

static CGGradientRef convert(const ColorInt colors[], const float stops[], size_t count)
static CGGradientRef convert(const ColorInt colors[],
const float stops[],
size_t count)
{
AutoCF space = CGColorSpaceCreateDeviceRGB();
std::vector<CGFloat> floats(count * 5); // colors[4] + stops[1]
Expand Down Expand Up @@ -273,7 +296,13 @@ class CGRadialGradientRenderShader : public CGRenderShader

void draw(CGContextRef ctx) override
{
CGContextDrawRadialGradient(ctx, m_grad, m_center, 0, m_center, m_radius, clampOptions);
CGContextDrawRadialGradient(ctx,
m_grad,
m_center,
0,
m_center,
m_radius,
clampOptions);
}
};

Expand Down Expand Up @@ -307,7 +336,8 @@ class CGRenderImage : public lite_rtti_override<RenderImage, CGRenderImage>
public:
AutoCF<CGImageRef> m_image;

CGRenderImage(const Span<const uint8_t> span) : m_image(CGRenderer::DecodeToCGImage(span))
CGRenderImage(const Span<const uint8_t> span) :
m_image(CGRenderer::DecodeToCGImage(span))
{
if (m_image)
{
Expand All @@ -320,7 +350,9 @@ class CGRenderImage : public lite_rtti_override<RenderImage, CGRenderImage>

void applyLocalMatrix(CGContextRef ctx) const
{
CGContextConcatCTM(ctx, CGAffineTransformMake(1, 0, 0, -1, 0, (float)m_Height));
CGContextConcatCTM(
ctx,
CGAffineTransformMake(1, 0, 0, -1, 0, (float)m_Height));
}
};

Expand All @@ -342,7 +374,10 @@ 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::transform(const Mat2D& m)
{
CGContextConcatCTM(m_ctx, convert(m));
}

void CGRenderer::drawPath(RenderPath* path, RenderPaint* paint)
{
Expand Down Expand Up @@ -386,7 +421,9 @@ void CGRenderer::clipPath(RenderPath* path)
CGContextClip(m_ctx);
}

void CGRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity)
void CGRenderer::drawImage(const RenderImage* image,
BlendMode blendMode,
float opacity)
{
LITE_RTTI_CAST_OR_RETURN(cgimg, const CGRenderImage*, image);

Expand Down Expand Up @@ -463,8 +500,8 @@ void CGRenderer::drawImageMesh(const RenderImage* image,
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;
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);

Expand All @@ -483,24 +520,26 @@ rcp<RenderBuffer> CGFactory::makeRenderBuffer(RenderBufferType type,
return make_rcp<DataRenderBuffer>(type, flags, sizeInBytes);
}

rcp<RenderShader> CGFactory::makeLinearGradient(float sx,
float sy,
float ex,
float ey,
const ColorInt colors[], // [count]
const float stops[], // [count]
size_t count)
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)
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));
Expand All @@ -511,9 +550,15 @@ rcp<RenderPath> CGFactory::makeRenderPath(RawPath& rawPath, FillRule fillRule)
return make_rcp<CGRenderPath>(rawPath.points(), rawPath.verbs(), fillRule);
}

rcp<RenderPath> CGFactory::makeEmptyRenderPath() { return make_rcp<CGRenderPath>(); }
rcp<RenderPath> CGFactory::makeEmptyRenderPath()
{
return make_rcp<CGRenderPath>();
}

rcp<RenderPaint> CGFactory::makeRenderPaint() { return make_rcp<CGRenderPaint>(); }
rcp<RenderPaint> CGFactory::makeRenderPaint()
{
return make_rcp<CGRenderPaint>();
}

rcp<RenderImage> CGFactory::decodeImage(Span<const uint8_t> encoded)
{
Expand Down
13 changes: 10 additions & 3 deletions decoders/include/rive/decoders/bitmap_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class Bitmap
PixelFormat pixelFormat,
std::unique_ptr<const uint8_t[]> bytes);

Bitmap(uint32_t width, uint32_t height, PixelFormat pixelFormat, const uint8_t* bytes);
Bitmap(uint32_t width,
uint32_t height,
PixelFormat pixelFormat,
const uint8_t* bytes);

private:
uint32_t m_Width;
Expand All @@ -35,12 +38,16 @@ class Bitmap
uint32_t height() const { return m_Height; }
PixelFormat pixelFormat() const { return m_PixelFormat; }
const uint8_t* bytes() const { return m_Bytes.get(); }
std::unique_ptr<const uint8_t[]> detachBytes() { return std::move(m_Bytes); }
std::unique_ptr<const uint8_t[]> detachBytes()
{
return std::move(m_Bytes);
}
size_t byteSize() const;
size_t byteSize(PixelFormat format) const;
size_t bytesPerPixel(PixelFormat format) const;

static std::unique_ptr<Bitmap> decode(const uint8_t bytes[], size_t byteCount);
static std::unique_ptr<Bitmap> decode(const uint8_t bytes[],
size_t byteCount);

// Change the pixel format (note this will resize bytes).
void pixelFormat(PixelFormat format);
Expand Down
13 changes: 10 additions & 3 deletions decoders/src/bitmap_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ 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))
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::Bitmap(uint32_t width,
uint32_t height,
PixelFormat pixelFormat,
const uint8_t* bytes) :
Bitmap(width, height, pixelFormat, std::unique_ptr<const uint8_t[]>(bytes))
{}

Expand Down Expand Up @@ -55,7 +61,8 @@ void Bitmap::pixelFormat(PixelFormat format)
{
for (size_t j = 0; j < toBytesPerPixel; j++)
{
nextBytes[writeIndex++] = j < fromBytesPerPixel ? m_Bytes[readIndex++] : 255;
nextBytes[writeIndex++] =
j < fromBytesPerPixel ? m_Bytes[readIndex++] : 255;
}
}

Expand Down
13 changes: 8 additions & 5 deletions decoders/src/bitmap_decoder_cg.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#include <string.h>
#include <vector>

// Represents raw, premultiplied, RGBA image data with tightly packed rows (width * 4 bytes).
// Represents raw, premultiplied, RGBA image data with tightly packed rows
// (width * 4 bytes).
struct PlatformCGImage
{
uint32_t width = 0;
Expand All @@ -35,7 +36,8 @@ bool cg_image_decode(const uint8_t* encodedBytes,
size_t encodedSizeInBytes,
PlatformCGImage* platformImage)
{
AutoCF data = CFDataCreate(kCFAllocatorDefault, encodedBytes, encodedSizeInBytes);
AutoCF data =
CFDataCreate(kCFAllocatorDefault, encodedBytes, encodedSizeInBytes);
if (!data)
{
return false;
Expand Down Expand Up @@ -84,8 +86,8 @@ bool cg_image_decode(const uint8_t* encodedBytes,
std::unique_ptr<uint8_t[]> pixels(new uint8_t[size]);

AutoCF cs = CGColorSpaceCreateDeviceRGB();
AutoCF cg =
CGBitmapContextCreate(pixels.get(), width, height, bitsPerComponent, rowBytes, cs, cgInfo);
AutoCF cg = CGBitmapContextCreate(
pixels.get(), width, height, bitsPerComponent, rowBytes, cs, cgInfo);
if (!cg)
{
return false;
Expand Down Expand Up @@ -125,7 +127,8 @@ bool cg_image_decode(const uint8_t* encodedBytes,
auto twoPixels = rive::simd::load<uint8_t, 8>(&image.pixels[i]);
auto a0 = twoPixels[3];
auto a1 = twoPixels[7];
// Avoid computation if both pixels are either fully transparent or opaque pixels
// Avoid computation if both pixels are either fully transparent or
// opaque pixels
if ((a0 > 0 && a0 < 255) || (a1 > 0 && a1 < 255))
{
// Avoid potential division by zero
Expand Down
11 changes: 7 additions & 4 deletions decoders/src/bitmap_decoder_thirdparty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ std::unique_ptr<Bitmap> DecodePng(const uint8_t bytes[], size_t byteCount);
std::unique_ptr<Bitmap> DecodeJpeg(const uint8_t bytes[], size_t byteCount);
std::unique_ptr<Bitmap> DecodeWebP(const uint8_t bytes[], size_t byteCount);

using BitmapDecoder = std::unique_ptr<Bitmap> (*)(const uint8_t bytes[], size_t byteCount);
using BitmapDecoder = std::unique_ptr<Bitmap> (*)(const uint8_t bytes[],
size_t byteCount);
struct ImageFormat
{
const char* name;
Expand Down Expand Up @@ -51,8 +52,8 @@ std::unique_ptr<Bitmap> Bitmap::decode(const uint8_t bytes[], size_t byteCount)
continue;
}

// If the fingerprint doesn't match, discrd this decoder. These are all bytes so .size() is
// fine here.
// If the fingerprint doesn't match, discrd this decoder. These are all
// bytes so .size() is fine here.
if (memcmp(fingerprint.data(), bytes, fingerprint.size()) != 0)
{
continue;
Expand All @@ -61,7 +62,9 @@ std::unique_ptr<Bitmap> Bitmap::decode(const uint8_t bytes[], size_t byteCount)
auto bitmap = recognizer.decodeImage(bytes, byteCount);
if (!bitmap)
{
fprintf(stderr, "Bitmap::decode - failed to decode a %s.\n", recognizer.name);
fprintf(stderr,
"Bitmap::decode - failed to decode a %s.\n",
recognizer.name);
}
return bitmap;
}
Expand Down
8 changes: 6 additions & 2 deletions decoders/src/decode_jpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ std::unique_ptr<Bitmap> DecodeJpeg(const uint8_t bytes[], size_t byteCount)
if (setjmp(jerr.setjmp_buffer))
{
// If we get here, the JPEG code has signaled an error.
// We need to clean up the JPEG object, close the input file, and return.
// We need to clean up the JPEG object, close the input file, and
// return.
jpeg_destroy_decompress(&cinfo);
return nullptr;
}
Expand Down Expand Up @@ -88,7 +89,10 @@ std::unique_ptr<Bitmap> DecodeJpeg(const uint8_t bytes[], size_t byteCount)
// Samples per row in output buffer
row_stride = cinfo.output_width * cinfo.output_components;
// Make a one-row-high sample array that will go away when done with image
buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, row_stride, 1);
buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo,
JPOOL_IMAGE,
row_stride,
1);

// Step 6: while (scan lines remain to be read)
// jpeg_read_scanlines(...);
Expand Down
Loading

0 comments on commit 163f1be

Please sign in to comment.