Skip to content

Commit e74d33e

Browse files
committed
[62.cad] dedicated test case for msdfs + cleanups
1 parent cc4dde7 commit e74d33e

File tree

5 files changed

+234
-300
lines changed

5 files changed

+234
-300
lines changed

62_CAD/DrawResourcesFiller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ DrawResourcesFiller::DrawResourcesFiller(smart_refctd_ptr<IUtilities>&& utils, I
1010

1111
// function is called when buffer is filled and we should submit draws and clear the buffers and continue filling
1212

13-
void DrawResourcesFiller::setSubmitDrawsFunction(SubmitFunc func)
13+
void DrawResourcesFiller::setSubmitDrawsFunction(const SubmitFunc& func)
1414
{
1515
submitDraws = func;
1616
}
@@ -825,12 +825,12 @@ DrawResourcesFiller::msdf_hash DrawResourcesFiller::hashFontGlyph(size_t fontHas
825825
return hash;
826826
}
827827

828-
void DrawResourcesFiller::setGlyphMSDFTextureFunction(GetGlyphMSDFTextureFunc func)
828+
void DrawResourcesFiller::setGlyphMSDFTextureFunction(const GetGlyphMSDFTextureFunc& func)
829829
{
830830
getGlyphMSDF = func;
831831
}
832832

833-
void DrawResourcesFiller::setHatchFillMSDFTextureFunction(GetHatchFillPatternMSDFTextureFunc func)
833+
void DrawResourcesFiller::setHatchFillMSDFTextureFunction(const GetHatchFillPatternMSDFTextureFunc& func)
834834
{
835835
getHatchFillPatternMSDF = func;
836836
}

62_CAD/DrawResourcesFiller.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct DrawResourcesFiller
4444
DrawResourcesFiller(smart_refctd_ptr<IUtilities>&& utils, IQueue* copyQueue);
4545

4646
typedef std::function<void(SIntendedSubmitInfo&)> SubmitFunc;
47-
void setSubmitDrawsFunction(SubmitFunc func);
47+
void setSubmitDrawsFunction(const SubmitFunc& func);
4848

4949
void allocateIndexBuffer(ILogicalDevice* logicalDevice, uint32_t indices);
5050

@@ -62,8 +62,8 @@ struct DrawResourcesFiller
6262
// it's up to user to return cached or generate on the fly.
6363
typedef std::function<core::smart_refctd_ptr<ICPUBuffer>(nbl::ext::TextRendering::FontFace* /*face*/, uint32_t /*glyphIdx*/)> GetGlyphMSDFTextureFunc;
6464
typedef std::function<core::smart_refctd_ptr<ICPUBuffer>(HatchFillPattern/*pattern*/)> GetHatchFillPatternMSDFTextureFunc;
65-
void setGlyphMSDFTextureFunction(GetGlyphMSDFTextureFunc func);
66-
void setHatchFillMSDFTextureFunction(GetHatchFillPatternMSDFTextureFunc func);
65+
void setGlyphMSDFTextureFunction(const GetGlyphMSDFTextureFunc& func);
66+
void setHatchFillMSDFTextureFunction(const GetHatchFillPatternMSDFTextureFunc& func);
6767

6868
//! this function fills buffers required for drawing a polyline and submits a draw through provided callback when there is not enough memory.
6969
void drawPolyline(const CPolylineBase& polyline, const LineStyleInfo& lineStyleInfo, SIntendedSubmitInfo& intendedNextSubmit);

62_CAD/Hatch.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ std::array<double, 2> Hatch::Segment::intersect(const Segment& other) const
133133
return result;
134134
}
135135

136-
Hatch::Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t& debugStep, std::function<void(CPolyline, LineStyleInfo)> debugOutput /* tmp */)
136+
Hatch::Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t* debugStepPtr, const std::function<void(CPolyline, LineStyleInfo)>& debugOutput)
137137
{
138138
intersectionAmounts = std::vector<uint32_t>();
139139
// this threshsold is used to decide when to consider minor position to be
@@ -150,8 +150,11 @@ Hatch::Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t& deb
150150

151151
int major = (int)majorAxis;
152152
int minor = 1-major; // Minor = Opposite of major (X)
153-
153+
154154
#ifdef DEBUG_HATCH_VISUALLY
155+
int32_t debugStepDefault = 0u;
156+
int32_t& debugStep = (debugStepPtr) ? *debugStepPtr : debugStepDefault;
157+
155158
auto drawDebugBezier = [&](QuadraticBezier bezier, float32_t4 color)
156159
{
157160
CPolyline outputPolyline;

62_CAD/Hatch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class Hatch
7575
// checks if it's a straight line e.g. if you're sweeping along y axis the it's a line parallel to x
7676
bool isStraightLineConstantMajor() const;
7777
};
78-
Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t& debugStep, std::function<void(CPolyline, LineStyleInfo)> debugOutput /* tmp */);
78+
79+
Hatch(std::span<CPolyline> lines, const MajorAxis majorAxis, int32_t* debugStep = nullptr, const std::function<void(CPolyline, LineStyleInfo)>& debugOutput = {});
7980

8081
// (temporary)
8182
Hatch(std::vector<CurveHatchBox>&& in_hatchBoxes) :

0 commit comments

Comments
 (0)