diff --git a/examples/FillRule.cpp b/examples/FillRule.cpp index b3604596..b1e698ff 100644 --- a/examples/FillRule.cpp +++ b/examples/FillRule.cpp @@ -41,7 +41,7 @@ struct UserExample : tvgexam::Example shape1->lineTo(80, 355); shape1->close(); shape1->fill(255, 255, 255); - shape1->fill(tvg::FillRule::Winding); //Fill all winding shapes + shape1->fill(tvg::FillRule::NonZero); //Fill all winding shapes canvas->push(shape1); diff --git a/inc/thorvg.h b/inc/thorvg.h index 1c35a4d3..48616cc2 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -156,7 +156,7 @@ enum class FillSpread : uint8_t */ enum class FillRule : uint8_t { - Winding = 0, ///< A line from the point to a location outside the shape is drawn. The intersections of the line with the path segment of the shape are counted. Starting from zero, if the path segment of the shape crosses the line clockwise, one is added, otherwise one is subtracted. If the resulting sum is non zero, the point is inside the shape. + NonZero = 0, ///< A line from the point to a location outside the shape is drawn. The intersections of the line with the path segment of the shape are counted. Starting from zero, if the path segment of the shape crosses the line clockwise, one is added, otherwise one is subtracted. If the resulting sum is non zero, the point is inside the shape. EvenOdd ///< A line from the point to a location outside the shape is drawn and its intersections with the path segments of the shape are counted. If the number of intersections is an odd number, the point is inside the shape. }; @@ -1136,7 +1136,7 @@ public: /** * @brief Sets the fill rule for the Shape object. * - * @param[in] r The fill rule value. The default value is @c FillRule::Winding. + * @param[in] r The fill rule value. The default value is @c FillRule::NonZero. */ Result fill(FillRule r) noexcept; diff --git a/src/bindings/capi/thorvg_capi.h b/src/bindings/capi/thorvg_capi.h index 4e9f6577..99a11b42 100644 --- a/src/bindings/capi/thorvg_capi.h +++ b/src/bindings/capi/thorvg_capi.h @@ -275,7 +275,7 @@ typedef enum { * @brief Enumeration specifying the algorithm used to establish which parts of the shape are treated as the inside of the shape. */ typedef enum { - TVG_FILL_RULE_WINDING = 0, ///< A line from the point to a location outside the shape is drawn. The intersections of the line with the path segment of the shape are counted. Starting from zero, if the path segment of the shape crosses the line clockwise, one is added, otherwise one is subtracted. If the resulting sum is non zero, the point is inside the shape. + TVG_FILL_RULE_NON_ZERO = 0, ///< A line from the point to a location outside the shape is drawn. The intersections of the line with the path segment of the shape are counted. Starting from zero, if the path segment of the shape crosses the line clockwise, one is added, otherwise one is subtracted. If the resulting sum is non zero, the point is inside the shape. TVG_FILL_RULE_EVEN_ODD ///< A line from the point to a location outside the shape is drawn and its intersections with the path segments of the shape are counted. If the number of intersections is an odd number, the point is inside the shape. } Tvg_Fill_Rule; @@ -1509,7 +1509,7 @@ TVG_API Tvg_Result tvg_shape_get_fill_color(const Tvg_Paint* paint, uint8_t* r, * @brief Sets the shape's fill rule. * * @param[in] paint A Tvg_Paint pointer to the shape object. -* @param[in] rule The fill rule value. The default value is @c TVG_FILL_RULE_WINDING. +* @param[in] rule The fill rule value. The default value is @c TVG_FILL_RULE_NON_ZERO. * * @return Tvg_Result enumeration. * @retval TVG_RESULT_INVALID_ARGUMENT An invalid Tvg_Paint pointer. diff --git a/src/loaders/lottie/tvgLottieModel.h b/src/loaders/lottie/tvgLottieModel.h index e213b765..301e1321 100644 --- a/src/loaders/lottie/tvgLottieModel.h +++ b/src/loaders/lottie/tvgLottieModel.h @@ -621,7 +621,7 @@ struct LottieSolidFill : LottieSolid } } - FillRule rule = FillRule::Winding; + FillRule rule = FillRule::NonZero; }; @@ -682,7 +682,7 @@ struct LottieGradientFill : LottieGradient LottieObject::type = LottieObject::GradientFill; } - FillRule rule = FillRule::Winding; + FillRule rule = FillRule::NonZero; }; diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index 8fd0516b..8cdf923f 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -122,7 +122,7 @@ RGB24 LottieParser::getColor(const char *str) FillRule LottieParser::getFillRule() { switch (getInt()) { - case 1: return FillRule::Winding; + case 1: return FillRule::NonZero; default: return FillRule::EvenOdd; } } diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 4e394574..7ae7b72a 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -318,7 +318,7 @@ static constexpr struct }; -_PARSE_TAG(FillRule, fillRule, FillRule, fillRuleTags, FillRule::Winding) +_PARSE_TAG(FillRule, fillRule, FillRule, fillRuleTags, FillRule::NonZero) /* parse the dash pattern used during stroking a path. @@ -1367,7 +1367,7 @@ static SvgNode* _createNode(SvgNode* parent, SvgNodeType type) node->style->fill.paint.curColor = false; node->style->curColorSet = false; //Default fill rule is nonzero - node->style->fill.fillRule = FillRule::Winding; + node->style->fill.fillRule = FillRule::NonZero; //Default stroke is none node->style->stroke.paint.none = true; diff --git a/src/loaders/svg/tvgSvgLoaderCommon.h b/src/loaders/svg/tvgSvgLoaderCommon.h index e64d7afb..0bc98ed2 100644 --- a/src/loaders/svg/tvgSvgLoaderCommon.h +++ b/src/loaders/svg/tvgSvgLoaderCommon.h @@ -198,12 +198,6 @@ constexpr SvgGradientFlags operator |(SvgGradientFlags a, SvgGradientFlags b) return SvgGradientFlags(int(a) | int(b)); } -enum class SvgFillRule -{ - Winding = 0, - OddEven = 1 -}; - enum class SvgMaskType { Luminance = 0, diff --git a/src/renderer/gl_engine/tvgGlCommon.h b/src/renderer/gl_engine/tvgGlCommon.h index 337ad69d..718a7d47 100644 --- a/src/renderer/gl_engine/tvgGlCommon.h +++ b/src/renderer/gl_engine/tvgGlCommon.h @@ -64,7 +64,7 @@ static inline float getScaleFactor(const Matrix& m) enum class GlStencilMode { None, - FillWinding, + FillNonZero, FillEvenOdd, Stroke, }; diff --git a/src/renderer/gl_engine/tvgGlGeometry.cpp b/src/renderer/gl_engine/tvgGlGeometry.cpp index 213f099f..138f875b 100644 --- a/src/renderer/gl_engine/tvgGlGeometry.cpp +++ b/src/renderer/gl_engine/tvgGlGeometry.cpp @@ -179,7 +179,7 @@ GlStencilMode GlGeometry::getStencilMode(RenderUpdateFlag flag) if (flag & RenderUpdateFlag::GradientStroke) return GlStencilMode::Stroke; if (flag & RenderUpdateFlag::Image) return GlStencilMode::None; - if (mFillRule == FillRule::Winding) return GlStencilMode::FillWinding; + if (mFillRule == FillRule::NonZero) return GlStencilMode::FillNonZero; if (mFillRule == FillRule::EvenOdd) return GlStencilMode::FillEvenOdd; return GlStencilMode::None; diff --git a/src/renderer/gl_engine/tvgGlGeometry.h b/src/renderer/gl_engine/tvgGlGeometry.h index c2275b77..e7c64442 100644 --- a/src/renderer/gl_engine/tvgGlGeometry.h +++ b/src/renderer/gl_engine/tvgGlGeometry.h @@ -108,7 +108,7 @@ private: Array strokeIndex = {}; Matrix mMatrix = {}; - FillRule mFillRule = FillRule::Winding; + FillRule mFillRule = FillRule::NonZero; RenderRegion mBounds = {}; }; diff --git a/src/renderer/gl_engine/tvgGlTessellator.cpp b/src/renderer/gl_engine/tvgGlTessellator.cpp index fd88e05d..ec0f039c 100644 --- a/src/renderer/gl_engine/tvgGlTessellator.cpp +++ b/src/renderer/gl_engine/tvgGlTessellator.cpp @@ -884,7 +884,7 @@ bool Tessellator::tessellate(const RenderShape *rshape, bool antialias) void Tessellator::tessellate(const Array &shapes) { - this->fillRule = FillRule::Winding; + this->fillRule = FillRule::NonZero; for (uint32_t i = 0; i < shapes.count; i++) { auto cmds = shapes[i]->path.cmds.data; @@ -1247,7 +1247,7 @@ bool Tessellator::tessMesh() bool Tessellator::matchFillRule(int32_t winding) { - if (fillRule == FillRule::Winding) { + if (fillRule == FillRule::NonZero) { return winding != 0; } else { return (winding & 0x1) != 0; diff --git a/src/renderer/gl_engine/tvgGlTessellator.h b/src/renderer/gl_engine/tvgGlTessellator.h index 672bf8aa..112a577c 100644 --- a/src/renderer/gl_engine/tvgGlTessellator.h +++ b/src/renderer/gl_engine/tvgGlTessellator.h @@ -62,7 +62,7 @@ private: void emitPoly(MonotonePolygon* poly); void emitTriangle(Vertex* p1, Vertex* p2, Vertex* p3); - FillRule fillRule = FillRule::Winding; + FillRule fillRule = FillRule::NonZero; std::unique_ptr pHeap; Array outlines; VertexList* pMesh; diff --git a/src/renderer/tvgRender.h b/src/renderer/tvgRender.h index f4268de8..6442b89a 100644 --- a/src/renderer/tvgRender.h +++ b/src/renderer/tvgRender.h @@ -181,7 +181,7 @@ struct RenderShape Fill *fill = nullptr; RenderColor color{}; RenderStroke *stroke = nullptr; - FillRule rule = FillRule::Winding; + FillRule rule = FillRule::NonZero; ~RenderShape() { diff --git a/src/renderer/tvgShape.h b/src/renderer/tvgShape.h index bcdac7eb..e2fb7c9c 100644 --- a/src/renderer/tvgShape.h +++ b/src/renderer/tvgShape.h @@ -479,7 +479,7 @@ struct Shape::Impl : Paint::Impl rs.path.pts.clear(); rs.color.a = 0; - rs.rule = FillRule::Winding; + rs.rule = FillRule::NonZero; delete(rs.stroke); rs.stroke = nullptr; diff --git a/src/renderer/wg_engine/tvgWgCompositor.cpp b/src/renderer/wg_engine/tvgWgCompositor.cpp index 318cf811..404290e5 100755 --- a/src/renderer/wg_engine/tvgWgCompositor.cpp +++ b/src/renderer/wg_engine/tvgWgCompositor.cpp @@ -271,7 +271,7 @@ void WgCompositor::drawShape(WgContext& context, WgRenderDataShape* renderData) if ((renderData->viewport.w <= 0) || (renderData->viewport.h <= 0)) return; wgpuRenderPassEncoderSetScissorRect(renderPassEncoder, renderData->viewport.x, renderData->viewport.y, renderData->viewport.w, renderData->viewport.h); // setup stencil rules - WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::Winding) ? pipelines.winding : pipelines.evenodd; + WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::NonZero) ? pipelines.nonzero : pipelines.evenodd; wgpuRenderPassEncoderSetStencilReference(renderPassEncoder, 0); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 0, bindGroupViewMat, 0, nullptr); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 1, renderData->bindGroupPaint, 0, nullptr); @@ -318,7 +318,7 @@ void WgCompositor::blendShape(WgContext& context, WgRenderDataShape* renderData, // render shape with blend settings wgpuRenderPassEncoderSetScissorRect(renderPassEncoder, renderData->viewport.x, renderData->viewport.y, renderData->viewport.w, renderData->viewport.h); // setup stencil rules - WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::Winding) ? pipelines.winding : pipelines.evenodd; + WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::NonZero) ? pipelines.nonzero : pipelines.evenodd; wgpuRenderPassEncoderSetStencilReference(renderPassEncoder, 0); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 0, bindGroupViewMat, 0, nullptr); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 1, renderData->bindGroupPaint, 0, nullptr); @@ -358,7 +358,7 @@ void WgCompositor::clipShape(WgContext& context, WgRenderDataShape* renderData) if ((renderData->viewport.w <= 0) || (renderData->viewport.h <= 0)) return; wgpuRenderPassEncoderSetScissorRect(renderPassEncoder, renderData->viewport.x, renderData->viewport.y, renderData->viewport.w, renderData->viewport.h); // setup stencil rules - WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::Winding) ? pipelines.winding : pipelines.evenodd; + WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::NonZero) ? pipelines.nonzero : pipelines.evenodd; wgpuRenderPassEncoderSetStencilReference(renderPassEncoder, 0); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 0, bindGroupViewMat, 0, nullptr); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 1, renderData->bindGroupPaint, 0, nullptr); @@ -658,7 +658,7 @@ void WgCompositor::renderClipPath(WgContext& context, WgRenderDataPaint* paint) // set transformations wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 0, bindGroupViewMat, 0, nullptr); // markup stencil - WGPURenderPipeline stencilPipeline = (renderData0->fillRule == FillRule::Winding) ? pipelines.winding : pipelines.evenodd; + WGPURenderPipeline stencilPipeline = (renderData0->fillRule == FillRule::NonZero) ? pipelines.nonzero : pipelines.evenodd; wgpuRenderPassEncoderSetStencilReference(renderPassEncoder, 0); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 1, renderData0->bindGroupPaint, 0, nullptr); wgpuRenderPassEncoderSetPipeline(renderPassEncoder, stencilPipeline); @@ -675,7 +675,7 @@ void WgCompositor::renderClipPath(WgContext& context, WgRenderDataPaint* paint) // get render data WgRenderDataShape* renderData = (WgRenderDataShape*)paint->clips[clipIndex]; // markup stencil - WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::Winding) ? pipelines.winding : pipelines.evenodd; + WGPURenderPipeline stencilPipeline = (renderData->fillRule == FillRule::NonZero) ? pipelines.nonzero : pipelines.evenodd; wgpuRenderPassEncoderSetStencilReference(renderPassEncoder, 0); wgpuRenderPassEncoderSetBindGroup(renderPassEncoder, 1, renderData->bindGroupPaint, 0, nullptr); wgpuRenderPassEncoderSetPipeline(renderPassEncoder, stencilPipeline); diff --git a/src/renderer/wg_engine/tvgWgPipelines.cpp b/src/renderer/wg_engine/tvgWgPipelines.cpp index 657f92e5..f0768446 100755 --- a/src/renderer/wg_engine/tvgWgPipelines.cpp +++ b/src/renderer/wg_engine/tvgWgPipelines.cpp @@ -185,7 +185,7 @@ void WgPipelines::initialize(WgContext& context) const WGPUBindGroupLayout bindGroupLayoutsBlit[] { layouts.layoutTexSampled }; // depth stencil state markup - const WGPUDepthStencilState depthStencilStateWinding = makeDepthStencilState(WGPUCompareFunction_Always, false, WGPUCompareFunction_Always, WGPUStencilOperation_IncrementWrap, WGPUCompareFunction_Always, WGPUStencilOperation_DecrementWrap); + const WGPUDepthStencilState depthStencilStateNonZero = makeDepthStencilState(WGPUCompareFunction_Always, false, WGPUCompareFunction_Always, WGPUStencilOperation_IncrementWrap, WGPUCompareFunction_Always, WGPUStencilOperation_DecrementWrap); const WGPUDepthStencilState depthStencilStateEvenOdd = makeDepthStencilState(WGPUCompareFunction_Always, false, WGPUCompareFunction_Always, WGPUStencilOperation_Invert); const WGPUDepthStencilState depthStencilStateDirect = makeDepthStencilState(WGPUCompareFunction_Always, false, WGPUCompareFunction_Always, WGPUStencilOperation_Replace); // depth stencil state clip path @@ -237,13 +237,13 @@ void WgPipelines::initialize(WgContext& context) // layout blit layout_blit = createPipelineLayout(context.device, bindGroupLayoutsBlit, 1); - // render pipeline winding - winding = createRenderPipeline( - context.device, "The render pipeline winding", + // render pipeline nonzero + nonzero = createRenderPipeline( + context.device, "The render pipeline nonzero", shader_stencil, "vs_main", "fs_main", layout_stencil, vertexBufferLayoutsShape, 1, WGPUColorWriteMask_None, offscreenTargetFormat, blendStateSrc, - depthStencilStateWinding, multisampleState); + depthStencilStateNonZero, multisampleState); // render pipeline even-odd evenodd = createRenderPipeline( context.device, "The render pipeline even-odd", @@ -471,7 +471,7 @@ void WgPipelines::releaseGraphicHandles(WgContext& context) // pipelines stencil markup releaseRenderPipeline(direct); releaseRenderPipeline(evenodd); - releaseRenderPipeline(winding); + releaseRenderPipeline(nonzero); // layouts releasePipelineLayout(layout_blit); releasePipelineLayout(layout_scene_compose); diff --git a/src/renderer/wg_engine/tvgWgPipelines.h b/src/renderer/wg_engine/tvgWgPipelines.h index c2de880f..af496855 100755 --- a/src/renderer/wg_engine/tvgWgPipelines.h +++ b/src/renderer/wg_engine/tvgWgPipelines.h @@ -66,7 +66,7 @@ private: WGPUPipelineLayout layout_blit{}; public: // pipelines stencil markup - WGPURenderPipeline winding{}; + WGPURenderPipeline nonzero{}; WGPURenderPipeline evenodd{}; WGPURenderPipeline direct{}; // pipelines clip path markup diff --git a/test/testShape.cpp b/test/testShape.cpp index 79539962..f50df9a7 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -216,7 +216,7 @@ TEST_CASE("Shape Filling", "[tvgShape]") REQUIRE(a == 5); //Fill Rule - REQUIRE(shape->fillRule() == FillRule::Winding); + REQUIRE(shape->fillRule() == FillRule::NonZero); REQUIRE(shape->fill(FillRule::EvenOdd) == Result::Success); REQUIRE(shape->fillRule() == FillRule::EvenOdd); }