/* * Copyright 2021 Google LLC. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "src/gpu/tessellate/Tessellation.h" #include "include/core/SkPath.h" #include "include/core/SkPathTypes.h" #include "include/core/SkRect.h" #include "include/private/base/SkFloatingPoint.h" #include "include/private/base/SkTArray.h" #include "src/base/SkUtils.h" #include "src/base/SkVx.h" #include "src/core/SkGeometry.h" #include "src/core/SkPathPriv.h" #include "src/gpu/tessellate/CullTest.h" #include "src/gpu/tessellate/WangsFormula.h" usingnamespaceskia_private; namespace skgpu::tess { namespace { float2; float4; // This value only protects us against getting stuck in infinite recursion due to fp32 precision // issues. Mathematically, every curve should reduce to manageable visible sections in O(log N) // chops, where N is the the magnitude of its control points. // // But, to define a protective upper bound, a cubic can enter or exit the viewport as many as 6 // times. So we may need to refine the curve (via binary search chopping at T=.5) up to 6 times. // // Furthermore, chopping a cubic at T=.5 may only reduce its length by 1/8 (.5^3), so we may require // up to 6 chops in order to reduce the length by 1/2. constexpr static int kMaxChopsPerCurve = …/*max number of viewport boundary crosses*/; // Writes a new path, chopping as necessary so no verbs require more segments than // kMaxTessellationSegmentsPerCurve. Curves completely outside the viewport are flattened into // lines. class PathChopper { … }; } // namespace SkPath PreChopPathCurves(float tessellationPrecision, const SkPath& path, const SkMatrix& matrix, const SkRect& viewport) { … } int FindCubicConvex180Chops(const SkPoint pts[], float T[2], bool* areCusps) { … } } // namespace skgpu::tess