diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index dfeb0104..da04ce1c 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -637,6 +637,7 @@ void Group::DrawFilledPaths(Canvas *canvas) { SPolygon sp = {}; sbls.MakePwlInto(&sp); canvas->DrawPolygon(sp, hcf); + sp.Clear(); } } diff --git a/src/render/render.cpp b/src/render/render.cpp index 62f01b35..a1e14dd4 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -144,6 +144,11 @@ bool Canvas::Fill::Equals(const Fill &other) const { pattern == other.pattern); } +void Canvas::Clear() { + strokes.Clear(); + fills.Clear(); +} + Canvas::hStroke Canvas::GetStroke(const Stroke &stroke) { for(const Stroke &s : strokes) { if(s.Equals(stroke)) return s.h; diff --git a/src/render/render.h b/src/render/render.h index f74b522b..87fb0218 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -98,6 +98,7 @@ public: StipplePattern stipplePattern; double stippleScale; + void Clear() { *this = {}; } bool Equals(const Stroke &other) const; }; @@ -114,13 +115,15 @@ public: RgbaColor color; FillPattern pattern; + void Clear() { *this = {}; } bool Equals(const Fill &other) const; }; IdList strokes; IdList fills; - Canvas() : strokes(), fills() {}; + Canvas() : strokes(), fills() {} + virtual void Clear(); hStroke GetStroke(const Stroke &stroke); hFill GetFill(const Fill &fill); @@ -226,7 +229,7 @@ public: BBox bbox; SurfaceRenderer() : camera(), lighting(), chordTolerance(), mesh(), bbox() {} - virtual void Clear(); + void Clear() override; // Canvas interface. const Camera &GetCamera() const override { return camera; } diff --git a/src/render/render2d.cpp b/src/render/render2d.cpp index 53c29522..6ce1c009 100644 --- a/src/render/render2d.cpp +++ b/src/render/render2d.cpp @@ -352,6 +352,8 @@ void SurfaceRenderer::OutputInPaintOrder() { if(tr.meta.color.IsEmpty()) continue; OutputTriangle(tr); } + + mp.Clear(); } for(auto eit : edges) { @@ -382,6 +384,8 @@ void SurfaceRenderer::OutputInPaintOrder() { } void SurfaceRenderer::Clear() { + Canvas::Clear(); + for(auto &eit : edges) { SEdgeList &el = eit.second; el.l.Clear(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 096f1192..c0ed0d20 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,7 +2,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) + ${CMAKE_CURRENT_BINARY_DIR} + ${CAIRO_INCLUDE_DIRS}) set(testsuite_SOURCES harness.cpp diff --git a/test/harness.cpp b/test/harness.cpp index 4547cd8a..b819596a 100644 --- a/test/harness.cpp +++ b/test/harness.cpp @@ -5,6 +5,7 @@ //----------------------------------------------------------------------------- #include "harness.h" #include +#include #if defined(WIN32) #include #else @@ -310,11 +311,15 @@ int main(int argc, char **argv) { if(failTally > 0) { fprintf(stderr, "Failure! %u checks failed\n", (unsigned)failTally); - return 1; } else { fprintf(stderr, "Success! %u test cases (%u skipped), %u checks, %.3fs\n", (unsigned)ranTally, (unsigned)skippedTally, (unsigned)checkTally, testTime.count()); - return 0; } + + // At last, try to reset all caches we or our dependencies have, to make SNR + // of memory checking tools like valgrind higher. + cairo_debug_reset_static_data(); + + return (failTally > 0); }