Given a vector path, generate the associated distance field.
723 {
725
726
727
730
731#ifdef SK_DEBUG
733 path.transform(dfMatrix, &xformPath);
736#endif
737
741 expectPathBounds.
contains(pathBounds));
742
743
744
745
747
748
749
751
752
754 return false;
755 }
756
757
758
760
765 expectPathBounds.
contains(pathBounds));
766
767
771
772
774
775
778 while (
auto e = iter.next()) {
782 break;
783 }
786 break;
788 SkScalar weight = iter.conicWeight();
793 }
794 break;
795 }
798 break;
799 }
800 }
801 }
802
803
805
806
807 for (
int row = 0; row <
height; ++row) {
809 constexpr DFSign kInside = -1;
810 constexpr DFSign kOutside = 1;
811
812 int windingNumber = 0;
813 for (
int col = 0; col <
width; ++col) {
814 int idx = (row *
width) + col;
816
817 DFSign dfSign;
820 dfSign = windingNumber ? kInside : kOutside;
821 break;
823 dfSign = windingNumber ? kOutside : kInside;
824 break;
826 dfSign = (windingNumber % 2) ? kInside : kOutside;
827 break;
829 dfSign = (windingNumber % 2) ? kOutside : kInside;
830 break;
831 }
832
833 const float miniDist =
sqrt(dataPtr[idx].fDistSq);
834 const float dist = dfSign * miniDist;
835
836 unsigned char pixelVal = pack_distance_field_val<SK_DistanceFieldMagnitude>(dist);
837
838 distanceField[(row * rowBytes) + col] = pixelVal;
839 }
840
841
842 if (windingNumber != 0) {
843 SkDEBUGFAIL(
"Winding number should be zero at the end of a scan line.");
844
845 for (
int col = 0; col <
width; ++col) {
846 int idx = (row *
width) + col;
847 DFSign dfSign = workingPath.
contains(col + 0.5, row + 0.5) ? kInside : kOutside;
848 const float miniDist =
sqrt(dataPtr[idx].fDistSq);
849 const float dist = dfSign * miniDist;
850
851 unsigned char pixelVal = pack_distance_field_val<SK_DistanceFieldMagnitude>(dist);
852
853 distanceField[(row * rowBytes) + col] = pixelVal;
854 }
855 continue;
856 }
857 }
858 return true;
859}
static void init_distances(DFData *data, int size)
static void calculate_distance_field_data(PathSegmentArray *segments, DFData *dataPtr, int width, int height)
static void add_quad(const SkPoint pts[3], PathSegmentArray *segments)
static const float kConicTolerance
static void add_line(const SkPoint pts[2], PathSegmentArray *segments)
static void add_cubic(const SkPoint pts[4], PathSegmentArray *segments)
bool IsDistanceFieldSupportedFillType(SkPathFillType fFillType)
#define SkDEBUGFAIL(message)
#define SK_DistanceFieldPad
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
SkPathFillType getFillType() const
const SkRect & getBounds() const
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
bool contains(SkScalar x, SkScalar y) const
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
int32_t fTop
smaller y-axis bounds
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
bool contains(int32_t x, int32_t y) const
void roundOut(SkIRect *dst) const