Deindent namespaces

Save the column real estate!

Diffs=
c5d9d854b Deindent namespaces
This commit is contained in:
csmartdalton
2022-08-20 00:42:56 +00:00
parent 1e201df858
commit 000e628e29
341 changed files with 10403 additions and 10540 deletions

View File

@@ -4,63 +4,63 @@
#include <cstddef>
namespace rive {
class Mat2D;
class Mat4 {
private:
float m_Buffer[16];
class Mat2D;
class Mat4 {
private:
float m_Buffer[16];
public:
Mat4() :
m_Buffer{
// clang-format off
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;
// 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
// 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
// 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
} {}
// clang-format on
} {}
Mat4(const Mat2D& mat2d);
Mat4(const Mat2D& mat2d);
inline const float* values() const { return m_Buffer; }
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]; }
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 Mat4& rhs) {
*this = Mat4::multiply(*this, rhs);
return *this;
}
Mat4& operator*=(const Mat2D& 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); }
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

View File

@@ -8,30 +8,30 @@
#include <cstdint>
namespace rive {
class SegmentedContour;
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;
///
/// 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; }
public:
const std::vector<Vec2D>& triangleStrip() const { return m_TriangleStrip; }
void reset();
void resetRenderOffset();
void nextRenderOffset(std::size_t& start, std::size_t& end);
void reset();
void resetRenderOffset();
void nextRenderOffset(std::size_t& start, std::size_t& end);
void extrude(const SegmentedContour* contour,
bool isClosed,
StrokeJoin join,
StrokeCap cap,
float strokeWidth,
const Mat2D& transform);
};
void extrude(const SegmentedContour* contour,
bool isClosed,
StrokeJoin join,
StrokeCap cap,
float strokeWidth,
const Mat2D& transform);
};
} // namespace rive
#endif

View File

@@ -6,39 +6,39 @@
#include <vector>
namespace rive {
class RawPath;
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;
/// 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;
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);
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() const;
SegmentedContour(float threshold);
public:
const Span<const Vec2D> contourPoints() const;
SegmentedContour(float threshold);
float threshold() const;
void threshold(float value);
const AABB& bounds() const;
float threshold() const;
void threshold(float value);
const AABB& bounds() const;
void contour(const RawPath& rawPath);
};
void contour(const RawPath& rawPath);
};
} // namespace rive
#endif

View File

@@ -9,38 +9,38 @@
namespace rive {
class SokolFactory : public Factory {
class SokolFactory : public Factory {
public:
SokolFactory();
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<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> 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> 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;
// 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<RenderPath> makeEmptyRenderPath() override;
std::unique_ptr<RenderPaint> makeRenderPaint() override;
};
std::unique_ptr<RenderPaint> makeRenderPaint() override;
};
} // namespace rive
#endif

View File

@@ -10,35 +10,35 @@
namespace rive {
class SokolRenderImage : public RenderImage {
private:
sg_image m_Image;
class SokolRenderImage : public RenderImage {
private:
sg_image m_Image;
public:
SokolRenderImage(sg_image image);
sg_image image() const { return m_Image; }
};
public:
SokolRenderImage(sg_image image);
sg_image image() const { return m_Image; }
};
class SokolTessRenderer : public TessRenderer {
private:
sg_pipeline m_MeshPipeline;
class SokolTessRenderer : public TessRenderer {
private:
sg_pipeline m_MeshPipeline;
public:
SokolTessRenderer();
void orthographicProjection(float left,
float right,
float bottom,
float top,
float near,
float far) override;
public:
SokolTessRenderer();
void orthographicProjection(float left,
float right,
float bottom,
float top,
float near,
float far) 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 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

View File

@@ -5,20 +5,20 @@
#include "rive/math/mat2d.hpp"
namespace rive {
///
/// A reference to a sub-path added to a ContourRenderPath with its relative
/// transform.
///
class SubPath {
private:
RenderPath* m_Path;
Mat2D m_Transform;
///
/// A reference to a sub-path added to a ContourRenderPath with its relative
/// transform.
///
class SubPath {
private:
RenderPath* m_Path;
Mat2D m_Transform;
public:
SubPath(RenderPath* path, const Mat2D& transform);
public:
SubPath(RenderPath* path, const Mat2D& transform);
RenderPath* path() const;
const Mat2D& transform() const;
};
RenderPath* path() const;
const Mat2D& transform() const;
};
} // namespace rive
#endif

View File

@@ -6,25 +6,25 @@
#include "rive/span.hpp"
namespace rive {
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;
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;
public:
TessRenderPath();
TessRenderPath(Span<const Vec2D> points, Span<const PathVerb> verbs, FillRule fillRule);
~TessRenderPath();
void reset() override;
void fillRule(FillRule value) override;
public:
TessRenderPath();
TessRenderPath(Span<const Vec2D> points, Span<const PathVerb> verbs, FillRule fillRule);
~TessRenderPath();
void reset() override;
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 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

View File

@@ -14,49 +14,49 @@
namespace rive {
struct RenderState {
Mat2D transform;
std::vector<SubPath> clipPaths;
};
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;
std::vector<SubPath> m_ClipPaths;
class TessRenderer : public Renderer {
protected:
Mat4 m_Projection;
std::list<RenderState> m_Stack;
bool m_IsClippingDirty = false;
std::vector<SubPath> m_ClipPaths;
public:
TessRenderer();
public:
TessRenderer();
void projection(const Mat4& value);
virtual void orthographicProjection(float left,
float right,
float bottom,
float top,
float near,
float far) = 0;
void projection(const Mat4& value);
virtual void orthographicProjection(float left,
float right,
float bottom,
float top,
float near,
float far) = 0;
///
/// Checks if clipping is dirty and clears the clipping flag. Hard
/// expectation for whoever checks this to also apply it. That's why
/// it's not marked const.
///
bool needsToApplyClipping();
///
/// Checks if clipping is dirty and clears the clipping flag. Hard
/// expectation for whoever checks this to also apply it. That's why
/// it's not marked const.
///
bool needsToApplyClipping();
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 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 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 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