@@ -53,13 +53,11 @@ GeometryResult FillPathGeometry::GetPositionBuffer(
5353 const ContentContext& renderer,
5454 const Entity& entity,
5555 RenderPass& pass) {
56- auto tolerance =
57- kDefaultCurveTolerance / entity.GetTransformation ().GetMaxBasisLength ();
58-
5956 VertexBuffer vertex_buffer;
6057 auto & host_buffer = pass.GetTransientsBuffer ();
6158 auto tesselation_result = renderer.GetTessellator ()->Tessellate (
62- path_.GetFillType (), path_.CreatePolyline (tolerance),
59+ path_.GetFillType (),
60+ path_.CreatePolyline (entity.GetTransformation ().GetMaxBasisLength ()),
6361 [&vertex_buffer, &host_buffer](
6462 const float * vertices, size_t vertices_count, const uint16_t * indices,
6563 size_t indices_count) {
@@ -151,7 +149,7 @@ StrokePathGeometry::JoinProc StrokePathGeometry::GetJoinProc(Join stroke_join) {
151149 join_proc = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
152150 const Point& position, const Point& start_offset,
153151 const Point& end_offset, Scalar miter_limit,
154- Scalar tolerance ) {
152+ Scalar scale ) {
155153 CreateBevelAndGetDirection (vtx_builder, position, start_offset,
156154 end_offset);
157155 };
@@ -160,7 +158,7 @@ StrokePathGeometry::JoinProc StrokePathGeometry::GetJoinProc(Join stroke_join) {
160158 join_proc = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
161159 const Point& position, const Point& start_offset,
162160 const Point& end_offset, Scalar miter_limit,
163- Scalar tolerance ) {
161+ Scalar scale ) {
164162 Point start_normal = start_offset.Normalize ();
165163 Point end_normal = end_offset.Normalize ();
166164
@@ -189,7 +187,7 @@ StrokePathGeometry::JoinProc StrokePathGeometry::GetJoinProc(Join stroke_join) {
189187 join_proc = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
190188 const Point& position, const Point& start_offset,
191189 const Point& end_offset, Scalar miter_limit,
192- Scalar tolerance ) {
190+ Scalar scale ) {
193191 Point start_normal = start_offset.Normalize ();
194192 Point end_normal = end_offset.Normalize ();
195193
@@ -216,7 +214,7 @@ StrokePathGeometry::JoinProc StrokePathGeometry::GetJoinProc(Join stroke_join) {
216214
217215 auto arc_points = CubicPathComponent (start_offset, start_handle,
218216 middle_handle, middle)
219- .CreatePolyline (tolerance );
217+ .CreatePolyline (scale );
220218
221219 VS::PerVertexData vtx;
222220 for (const auto & point : arc_points) {
@@ -238,8 +236,7 @@ StrokePathGeometry::CapProc StrokePathGeometry::GetCapProc(Cap stroke_cap) {
238236 switch (stroke_cap) {
239237 case Cap::kButt :
240238 cap_proc = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
241- const Point& position, const Point& offset,
242- Scalar tolerance) {
239+ const Point& position, const Point& offset, Scalar scale) {
243240 VS::PerVertexData vtx;
244241 vtx.position = position + offset;
245242 vtx_builder.AppendVertex (vtx);
@@ -249,8 +246,7 @@ StrokePathGeometry::CapProc StrokePathGeometry::GetCapProc(Cap stroke_cap) {
249246 break ;
250247 case Cap::kRound :
251248 cap_proc = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
252- const Point& position, const Point& offset,
253- Scalar tolerance) {
249+ const Point& position, const Point& offset, Scalar scale) {
254250 VS::PerVertexData vtx;
255251
256252 Point forward (offset.y , -offset.x );
@@ -260,7 +256,7 @@ StrokePathGeometry::CapProc StrokePathGeometry::GetCapProc(Cap stroke_cap) {
260256 CubicPathComponent (
261257 offset, offset + forward * PathBuilder::kArcApproximationMagic ,
262258 forward + offset * PathBuilder::kArcApproximationMagic , forward)
263- .CreatePolyline (tolerance );
259+ .CreatePolyline (scale );
264260
265261 vtx.position = position + offset;
266262 vtx_builder.AppendVertex (vtx);
@@ -276,8 +272,7 @@ StrokePathGeometry::CapProc StrokePathGeometry::GetCapProc(Cap stroke_cap) {
276272 break ;
277273 case Cap::kSquare :
278274 cap_proc = [](VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
279- const Point& position, const Point& offset,
280- Scalar tolerance) {
275+ const Point& position, const Point& offset, Scalar scale) {
281276 VS::PerVertexData vtx;
282277
283278 Point forward (offset.y , -offset.x );
@@ -305,9 +300,9 @@ VertexBuffer StrokePathGeometry::CreateSolidStrokeVertices(
305300 Cap cap,
306301 const StrokePathGeometry::JoinProc& join_proc,
307302 const StrokePathGeometry::CapProc& cap_proc,
308- Scalar tolerance ) {
303+ Scalar scale ) {
309304 VertexBufferBuilder<VS::PerVertexData> vtx_builder;
310- auto polyline = path.CreatePolyline ();
305+ auto polyline = path.CreatePolyline (scale );
311306
312307 VS::PerVertexData vtx;
313308
@@ -333,8 +328,8 @@ VertexBuffer StrokePathGeometry::CreateSolidStrokeVertices(
333328 switch (contour_end_point_i - contour_start_point_i) {
334329 case 1 : {
335330 Point p = polyline.points [contour_start_point_i];
336- cap_proc (vtx_builder, p, {-stroke_width * 0 .5f , 0 }, tolerance );
337- cap_proc (vtx_builder, p, {stroke_width * 0 .5f , 0 }, tolerance );
331+ cap_proc (vtx_builder, p, {-stroke_width * 0 .5f , 0 }, scale );
332+ cap_proc (vtx_builder, p, {stroke_width * 0 .5f , 0 }, scale );
338333 continue ;
339334 }
340335 case 0 :
@@ -381,7 +376,7 @@ VertexBuffer StrokePathGeometry::CreateSolidStrokeVertices(
381376 }
382377 auto cap_offset = direction * stroke_width * 0.5 ;
383378 cap_proc (vtx_builder, polyline.points [contour_start_point_i], cap_offset,
384- tolerance );
379+ scale );
385380 }
386381
387382 // Generate contour geometry.
@@ -402,7 +397,7 @@ VertexBuffer StrokePathGeometry::CreateSolidStrokeVertices(
402397
403398 // Generate join from the current line to the next line.
404399 join_proc (vtx_builder, polyline.points [point_i], previous_offset,
405- offset, scaled_miter_limit, tolerance );
400+ offset, scaled_miter_limit, scale );
406401 }
407402 }
408403
@@ -412,10 +407,10 @@ VertexBuffer StrokePathGeometry::CreateSolidStrokeVertices(
412407 Vector2 (-contour.end_direction .y , contour.end_direction .x ) *
413408 stroke_width * 0.5 ;
414409 cap_proc (vtx_builder, polyline.points [contour_end_point_i - 1 ],
415- cap_offset, tolerance );
410+ cap_offset, scale );
416411 } else {
417412 join_proc (vtx_builder, polyline.points [contour_start_point_i], offset,
418- contour_first_offset, scaled_miter_limit, tolerance );
413+ contour_first_offset, scaled_miter_limit, scale );
419414 }
420415 }
421416
@@ -437,15 +432,11 @@ GeometryResult StrokePathGeometry::GetPositionBuffer(
437432 Scalar min_size = 1 .0f / sqrt (std::abs (determinant));
438433 Scalar stroke_width = std::max (stroke_width_, min_size);
439434
440- auto tolerance =
441- kDefaultCurveTolerance /
442- (stroke_width_ * entity.GetTransformation ().GetMaxBasisLength ());
443-
444435 auto & host_buffer = pass.GetTransientsBuffer ();
445436 auto vertex_buffer = CreateSolidStrokeVertices (
446437 path_, host_buffer, stroke_width, miter_limit_ * stroke_width_ * 0.5 ,
447438 stroke_cap_, GetJoinProc (stroke_join_), GetCapProc (stroke_cap_),
448- tolerance );
439+ entity. GetTransformation (). GetMaxBasisLength () );
449440
450441 return GeometryResult{
451442 .type = PrimitiveType::kTriangleStrip ,
0 commit comments