Drop the ColumnLimit to 80 for clang-format

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 <99840794+csmartdalton@users.noreply.github.com>
This commit is contained in:
csmartdalton
2024-10-11 19:22:48 +00:00
parent 71fd5c47b0
commit 163f1beef3
846 changed files with 417947 additions and 308210 deletions

View File

@@ -111,7 +111,8 @@ void RiveFont::load(sk_sp<SkTypeface> tf, const char str[], size_t len)
SkFont font(std::move(tf), 1.0f);
uint16_t glyphIDs[len];
int glyphCount = font.textToGlyphs(str, len, SkTextEncoding::kUTF8, glyphIDs, len);
int glyphCount =
font.textToGlyphs(str, len, SkTextEncoding::kUTF8, glyphIDs, len);
assert(glyphCount == (int)len);
struct Rec
@@ -133,9 +134,10 @@ void RiveFont::load(sk_sp<SkTypeface> tf, const char str[], size_t len)
{
// gonna add code -- now see if its glyph is unique
uint16_t srcGlyph = glyphIDs[i];
auto it2 = std::find_if(rec.begin(), rec.end(), [srcGlyph](const auto& r) {
return r.srcGlyph == srcGlyph;
});
auto it2 =
std::find_if(rec.begin(), rec.end(), [srcGlyph](const auto& r) {
return r.srcGlyph == srcGlyph;
});
uint16_t dstGlyph;
if (it2 == rec.end())
{
@@ -155,7 +157,11 @@ void RiveFont::load(sk_sp<SkTypeface> tf, const char str[], size_t len)
});
for (const auto& r : rec)
{
printf("'%c' [%d] %d -> %d\n", r.charCode, r.charCode, r.srcGlyph, r.dstGlyph);
printf("'%c' [%d] %d -> %d\n",
r.charCode,
r.charCode,
r.srcGlyph,
r.dstGlyph);
fCMap.push_back({r.charCode, r.dstGlyph});
}
@@ -176,8 +182,9 @@ void RiveFont::load(sk_sp<SkTypeface> tf, const char str[], size_t len)
append_glyph(0); // missing glyph
for (int i = 1; i < newDstGlyphID; ++i)
{ // walk through our glyphs
auto iter =
std::find_if(rec.begin(), rec.end(), [i](const auto& r) { return r.dstGlyph == i; });
auto iter = std::find_if(rec.begin(), rec.end(), [i](const auto& r) {
return r.dstGlyph == i;
});
assert(iter != rec.end());
append_glyph(iter->srcGlyph);
}
@@ -228,7 +235,10 @@ struct ByteBuilder
{
this->add(v.data(), v.size() * sizeof(T));
}
void add(const ByteBuilder& bb) { this->add(bb.bytes.data(), bb.bytes.size()); }
void add(const ByteBuilder& bb)
{
this->add(bb.bytes.data(), bb.bytes.size());
}
void add(sk_sp<SkData> data) { this->add(data->data(), data->size()); }
void padTo16()
@@ -353,7 +363,8 @@ sk_sp<SkData> RiveFont::encode() const
InfoTable itable;
itable.glyphCount = fGlyphs.size();
itable.upem = upem;
dir.push_back({kInfo_TableTag, SkData::MakeWithCopy(&itable, sizeof(itable))});
dir.push_back(
{kInfo_TableTag, SkData::MakeWithCopy(&itable, sizeof(itable))});
}
{
@@ -382,7 +393,8 @@ sk_sp<SkData> RiveFont::encode() const
offsets.push_back(paths.length()); // store N+1 offsets
dir.push_back(
{kOffsets_TableTag, SkData::MakeWithCopy(offsets.data(), offsets.size() * 4)});
{kOffsets_TableTag,
SkData::MakeWithCopy(offsets.data(), offsets.size() * 4)});
dir.push_back({kPaths_TableTag, paths.detach()});
dir.push_back({kAdvances_TableTag, advances.detach()});
}
@@ -545,7 +557,13 @@ static SkPath decode_path(const void* data, size_t length, float scale)
pts16 += 2;
}
return SkPath::Make(pts, pointCount, verbs, verbCount, nullptr, 0, SkPathFillType::kWinding);
return SkPath::Make(pts,
pointCount,
verbs,
verbCount,
nullptr,
0,
SkPathFillType::kWinding);
}
bool RiveFont::decode(const void* data, size_t length)
@@ -605,8 +623,10 @@ bool RiveFont::decode(const void* data, size_t length)
uint32_t end = offsets[i + 1];
assert(start <= end);
fGlyphs.push_back(
{(start == end) ? SkPath() : decode_path(paths + start, end - start, scale), adv});
fGlyphs.push_back({(start == end)
? SkPath()
: decode_path(paths + start, end - start, scale),
adv});
}
return true;
}

View File

@@ -12,13 +12,24 @@ class FontArguments
public:
FontArguments(int argc, const char** argv) :
m_Parser("Convert a font file into the rive format.", "Experimental....")
m_Parser("Convert a font file into the rive format.",
"Experimental....")
{
args::HelpFlag help(m_Parser, "help", "Display this help menu", {'h', "help"});
args::Group required(m_Parser, "required arguments:", args::Group::Validators::All);
args::Group optional(m_Parser, "optional arguments:", args::Group::Validators::DontCare);
args::HelpFlag help(m_Parser,
"help",
"Display this help menu",
{'h', "help"});
args::Group required(m_Parser,
"required arguments:",
args::Group::Validators::All);
args::Group optional(m_Parser,
"optional arguments:",
args::Group::Validators::DontCare);
args::ValueFlag<std::string> source(required, "path", "source filename", {'s', "source"});
args::ValueFlag<std::string> source(required,
"path",
"source filename",
{'s', "source"});
args::ValueFlag<std::string> destination(required,
"path",
"destination filename",

View File

@@ -9,8 +9,8 @@
#ifndef PNGPREFIX_H
#define PNGPREFIX_H
/*
* This is necessary to build multiple copies of libpng. We need this while Skia has its own copy
* of libpng.
* This is necessary to build multiple copies of libpng. We need this while
* Skia has its own copy of libpng.
*/
#define png_access_version_number sk_png_access_version_number
#define png_app_error sk_png_app_error
@@ -37,7 +37,8 @@
#define png_colorspace_set_chromaticities sk_png_colorspace_set_chromaticities
#define png_colorspace_set_endpoints sk_png_colorspace_set_endpoints
#define png_colorspace_set_gamma sk_png_colorspace_set_gamma
#define png_colorspace_set_rgb_coefficients sk_png_colorspace_set_rgb_coefficients
#define png_colorspace_set_rgb_coefficients \
sk_png_colorspace_set_rgb_coefficients
#define png_colorspace_set_sRGB sk_png_colorspace_set_sRGB
#define png_colorspace_sync sk_png_colorspace_sync
#define png_colorspace_sync_info sk_png_colorspace_sync_info
@@ -404,7 +405,8 @@
#define png_set_text_compression_mem_level sk_png_set_text_compression_mem_level
#define png_set_text_compression_method sk_png_set_text_compression_method
#define png_set_text_compression_strategy sk_png_set_text_compression_strategy
#define png_set_text_compression_window_bits sk_png_set_text_compression_window_bits
#define png_set_text_compression_window_bits \
sk_png_set_text_compression_window_bits
#define png_set_unknown_chunk_location sk_png_set_unknown_chunk_location
#define png_set_unknown_chunks sk_png_set_unknown_chunks
#define png_set_user_limits sk_png_set_user_limits

View File

@@ -11,7 +11,8 @@ namespace rive
{
struct CGSkiaFactory : public SkiaFactory
{
std::vector<uint8_t> platformDecode(Span<const uint8_t>, SkiaFactory::ImageInfo*) override;
std::vector<uint8_t> platformDecode(Span<const uint8_t>,
SkiaFactory::ImageInfo*) override;
};
} // namespace rive

View File

@@ -14,7 +14,9 @@ namespace rive
class SkiaFactory : 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,
@@ -62,10 +64,12 @@ public:
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)
// 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
}

View File

@@ -31,7 +31,10 @@ public:
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 SkPathFillType convert(FillRule value) {

View File

@@ -62,8 +62,13 @@ std::vector<uint8_t> CGSkiaFactory::platformDecode(Span<const uint8_t> span,
pixels.resize(size);
AutoCF cs = CGColorSpaceCreateDeviceRGB();
AutoCF cg =
CGBitmapContextCreate(pixels.data(), width, height, bitsPerComponent, rowBytes, cs, cgInfo);
AutoCF cg = CGBitmapContextCreate(pixels.data(),
width,
height,
bitsPerComponent,
rowBytes,
cs,
cgInfo);
if (!cg)
{
pixels.clear();

View File

@@ -22,7 +22,8 @@
using namespace rive;
// skia's has/had bugs in trilerp, so backing down to nearest mip
const SkSamplingOptions gSampling(SkFilterMode::kLinear, SkMipmapMode::kNearest);
const SkSamplingOptions gSampling(SkFilterMode::kLinear,
SkMipmapMode::kNearest);
class SkiaRenderPath : public lite_rtti_override<RenderPath, SkiaRenderPath>
{
@@ -40,7 +41,8 @@ public:
void fillRule(FillRule value) override;
void moveTo(float x, float y) override;
void lineTo(float x, float y) override;
void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
void cubicTo(float ox, float oy, float ix, float iy, float x, float y)
override;
virtual void close() override;
};
@@ -75,7 +77,8 @@ public:
sk_sp<SkImage> skImage() const { return m_SkImage; }
};
class SkiaRenderShader : public lite_rtti_override<RenderShader, SkiaRenderShader>
class SkiaRenderShader
: public lite_rtti_override<RenderShader, SkiaRenderShader>
{
public:
SkiaRenderShader(sk_sp<SkShader> sh) : shader(std::move(sh)) {}
@@ -83,7 +86,10 @@ public:
sk_sp<SkShader> shader;
};
void SkiaRenderPath::fillRule(FillRule value) { m_Path.setFillType(ToSkia::convert(value)); }
void SkiaRenderPath::fillRule(FillRule value)
{
m_Path.setFillType(ToSkia::convert(value));
}
void SkiaRenderPath::rewind() { m_Path.rewind(); }
void SkiaRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform)
@@ -94,7 +100,12 @@ void SkiaRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform)
void SkiaRenderPath::moveTo(float x, float y) { m_Path.moveTo(x, y); }
void SkiaRenderPath::lineTo(float x, float y) { m_Path.lineTo(x, y); }
void SkiaRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y)
void SkiaRenderPath::cubicTo(float ox,
float oy,
float ix,
float iy,
float x,
float y)
{
m_Path.cubicTo(ox, oy, ix, iy, x, y);
}
@@ -116,10 +127,19 @@ void SkiaRenderPaint::style(RenderPaintStyle style)
}
void SkiaRenderPaint::color(unsigned int value) { m_Paint.setColor(value); }
void SkiaRenderPaint::thickness(float value) { m_Paint.setStrokeWidth(value); }
void SkiaRenderPaint::join(StrokeJoin value) { m_Paint.setStrokeJoin(ToSkia::convert(value)); }
void SkiaRenderPaint::cap(StrokeCap value) { m_Paint.setStrokeCap(ToSkia::convert(value)); }
void SkiaRenderPaint::join(StrokeJoin value)
{
m_Paint.setStrokeJoin(ToSkia::convert(value));
}
void SkiaRenderPaint::cap(StrokeCap value)
{
m_Paint.setStrokeCap(ToSkia::convert(value));
}
void SkiaRenderPaint::blendMode(BlendMode value) { m_Paint.setBlendMode(ToSkia::convert(value)); }
void SkiaRenderPaint::blendMode(BlendMode value)
{
m_Paint.setBlendMode(ToSkia::convert(value));
}
void SkiaRenderPaint::shader(rcp<RenderShader> rsh)
{
@@ -146,7 +166,9 @@ void SkiaRenderer::clipPath(RenderPath* path)
m_Canvas->clipPath(skPath->path(), true);
}
void SkiaRenderer::drawImage(const RenderImage* image, BlendMode blendMode, float opacity)
void SkiaRenderer::drawImage(const RenderImage* image,
BlendMode blendMode,
float opacity)
{
LITE_RTTI_CAST_OR_RETURN(skiaImage, const SkiaRenderImage*, image);
SkPaint paint;
@@ -181,12 +203,13 @@ void SkiaRenderer::drawImageMesh(const RenderImage* image,
auto uvs = (const SkPoint*)skUVCoords->vecs();
#ifdef SKIA_BUG_13047
// The local matrix is ignored for drawVertices, so we have to manually scale
// the UVs to match Skia's convention...
// The local matrix is ignored for drawVertices, so we have to manually
// scale the UVs to match Skia's convention...
std::vector<SkPoint> scaledUVs(vertexCount);
for (uint32_t i = 0; i < vertexCount; ++i)
{
scaledUVs[i] = {uvs[i].fX * image->width(), uvs[i].fY * image->height()};
scaledUVs[i] = {uvs[i].fX * image->width(),
uvs[i].fY * image->height()};
}
uvs = scaledUVs.data();
#else
@@ -198,7 +221,10 @@ void SkiaRenderer::drawImageMesh(const RenderImage* image,
#endif
auto skiaImage = skImage->skImage();
auto shader = skiaImage->makeShader(SkTileMode::kClamp, SkTileMode::kClamp, gSampling, &scaleM);
auto shader = skiaImage->makeShader(SkTileMode::kClamp,
SkTileMode::kClamp,
gSampling,
&scaleM);
SkPaint paint;
paint.setAlphaf(opacity);
@@ -219,7 +245,8 @@ void SkiaRenderer::drawImageMesh(const RenderImage* image,
m_Canvas->drawVertices(vt, SkBlendMode::kModulate, paint);
}
SkiaRenderImage::SkiaRenderImage(sk_sp<SkImage> image) : m_SkImage(std::move(image))
SkiaRenderImage::SkiaRenderImage(sk_sp<SkImage> image) :
m_SkImage(std::move(image))
{
m_Width = m_SkImage->width();
m_Height = m_SkImage->height();
@@ -234,26 +261,31 @@ rcp<RenderBuffer> SkiaFactory::makeRenderBuffer(RenderBufferType type,
return make_rcp<DataRenderBuffer>(type, flags, sizeInBytes);
}
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]
size_t count)
{
const SkPoint pts[] = {{sx, sy}, {ex, ey}};
auto sh =
SkGradientShader::MakeLinear(pts, (const SkColor*)colors, stops, count, SkTileMode::kClamp);
auto sh = SkGradientShader::MakeLinear(pts,
(const SkColor*)colors,
stops,
count,
SkTileMode::kClamp);
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)
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,
@@ -280,9 +312,15 @@ rcp<RenderPath> SkiaFactory::makeRenderPath(RawPath& rawPath, FillRule fillRule)
isVolatile));
}
rcp<RenderPath> SkiaFactory::makeEmptyRenderPath() { return make_rcp<SkiaRenderPath>(); }
rcp<RenderPath> SkiaFactory::makeEmptyRenderPath()
{
return make_rcp<SkiaRenderPath>();
}
rcp<RenderPaint> SkiaFactory::makeRenderPaint() { return make_rcp<SkiaRenderPaint>(); }
rcp<RenderPaint> SkiaFactory::makeRenderPaint()
{
return make_rcp<SkiaRenderPaint>();
}
rcp<RenderImage> SkiaFactory::decodeImage(Span<const uint8_t> encoded)
{
@@ -302,12 +340,14 @@ rcp<RenderImage> SkiaFactory::decodeImage(Span<const uint8_t> encoded)
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 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});
image =
SkImage::MakeRasterCopy({skinfo, pixels.data(), info.rowBytes});
}
}

View File

@@ -96,7 +96,8 @@ int main(int argc, char* argv[])
auto artboard = file->artboardDefault();
artboard->advance(0.0f);
sk_sp<SkSurface> rasterSurface = SkSurface::MakeRasterN32Premul(width, height);
sk_sp<SkSurface> rasterSurface =
SkSurface::MakeRasterN32Premul(width, height);
SkCanvas* rasterCanvas = rasterSurface->getCanvas();
rive::SkiaRenderer renderer(rasterCanvas);