// the max magnitude for the distance field // distance values are limited to the range (-SK_DistanceFieldMagnitude, SK_DistanceFieldMagnitude] #define SK_DistanceFieldMagnitude 4 // we need to pad around the original glyph to allow our maximum distance of // SK_DistanceFieldMagnitude texels away from any edge #define SK_DistanceFieldPad 4 // the rect we render with is inset from the distance field glyph size to allow for bilerp #define SK_DistanceFieldInset 2
// For the fragment shader: // The distance field is constructed as unsigned char values, // so that the zero value is at 128, and the supported range of distances is [-4 * 127/128, 4]. // Hence our multiplier (width of the range) is 4 * 255/128 and zero threshold is 128/255. #define SK_DistanceFieldMultiplier "7.96875" #define SK_DistanceFieldThreshold "0.50196078431"
/** Given 8-bit mask data, generate the associated distance field
*@paramdistanceFieldThedistancefieldtobegenerated.Shouldalreadybeallocated *bytheclientwiththepaddingabove. *@paramimage8-bitmaskwe'reusingtogeneratethedistancefield. *@paramwWidthoftheoriginalimage. *@paramhHeightoftheoriginalimage. *@paramrowBytesSizeofeachrowintheimage,inbytes
*/ bool SkGenerateDistanceFieldFromA8Image(unsignedchar* distanceField, constunsignedchar* image, int w, int h, size_t rowBytes);
/** Given LCD16 mask data (not a 16-bit image), generate the associated distance field
*@paramdistanceFieldThedistancefieldtobegenerated.Shouldalreadybeallocated *bytheclientwiththepaddingabove. *@paramimage16-bitLCDdatawe'reusingtogeneratethedistancefield. *@paramwWidthoftheoriginalimage. *@paramhHeightoftheoriginalimage. *@paramrowBytesSizeofeachrowintheimage,inbytes
*/ bool SkGenerateDistanceFieldFromLCD16Mask(unsignedchar* distanceField, constunsignedchar* image, int w, int h, size_t rowBytes);
/** Given 1-bit mask data, generate the associated distance field
*@paramdistanceFieldThedistancefieldtobegenerated.Shouldalreadybeallocated *bytheclientwiththepaddingabove. *@paramimage1-bitmaskwe'reusingtogeneratethedistancefield. *@paramwWidthoftheoriginalimage. *@paramhHeightoftheoriginalimage. *@paramrowBytesSizeofeachrowintheimage,inbytes
*/ bool SkGenerateDistanceFieldFromBWImage(unsignedchar* distanceField, constunsignedchar* image, int w, int h, size_t rowBytes);
/** Given width and height of original image, return size (in bytes) of distance field *@paramwWidthoftheoriginalimage. *@paramhHeightoftheoriginalimage.
*/ inline size_t SkComputeDistanceFieldSize(int w, int h) { return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(unsignedchar);
}
#endif// !defined(SK_DISABLE_SDF_TEXT)
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet am 2026-08-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.