1688 {
1691
1693
1695 return container;
1696 }
1697
1700#if !defined(SK_DISABLE_SDF_TEXT)
1703#else
1705#endif
1706
1707
1708
1710
1711
1716 acceptedPackedGlyphIDs.
resize(maxGlyphRunSize);
1717 acceptedGlyphIDs.
resize(maxGlyphRunSize);
1718 acceptedPositions.
resize(maxGlyphRunSize);
1719 acceptedFormats.
resize(maxGlyphRunSize);
1720
1721
1724 rejectedGlyphIDs.
resize(maxGlyphRunSize);
1725 rejectedPositions.
resize(maxGlyphRunSize);
1726 const auto rejectedBuffer =
SkMakeZip(rejectedGlyphIDs, rejectedPositions);
1727
1729
1730
1731 for (auto& glyphRun : glyphRunList) {
1733 const SkFont& runFont = glyphRun.font();
1734
1735 const SkScalar approximateDeviceTextSize =
1736
1737
1739 glyphRunListLocation);
1740
1741
1742
1744 approximateDeviceTextSize < maxMaskSize) {
1745
1746#if !defined(SK_DISABLE_SDF_TEXT)
1747
1749
1750 const auto& [strikeSpec, strikeToSourceScale, matrixRange] =
1751 make_sdft_strike_spec(
1752 runFont, runPaint, deviceProps, positionMatrix,
1754
1757
1758
1759
1760
1761
1762
1763
1764
1765
1768
1769 auto acceptedBuffer =
SkMakeZip(acceptedPackedGlyphIDs, acceptedPositions);
1770 auto [accepted, rejected, creationBounds] = prepare_for_SDFT_drawing(
1771 strike.
get(), creationMatrix,
source, acceptedBuffer, rejectedBuffer);
1773
1774 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1775 container->fSubRuns.append(SDFTSubRun::Make(
1776 accepted,
1777 runFont,
1778 strike->strikePromise(),
1779 creationMatrix,
1780 creationBounds,
1781 matrixRange,
1782 alloc));
1783 }
1784 }
1785 }
1786#endif
1787
1788
1789
1791
1792
1793
1794
1796 runFont, runPaint, deviceProps, scalerContextFlags, positionMatrix);
1797
1799
1800 auto acceptedBuffer =
SkMakeZip(acceptedPackedGlyphIDs,
1801 acceptedPositions,
1802 acceptedFormats);
1803 auto [accepted, rejected, creationBounds] = prepare_for_direct_mask_drawing(
1804 strike.
get(), positionMatrix,
source, acceptedBuffer, rejectedBuffer);
1806
1807 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1808 auto addGlyphsWithSameFormat =
1809 [&,
bounds = creationBounds](
1812 container->fSubRuns.append(
1813 DirectMaskSubRun::Make(bounds,
1814 subrun,
1815 container->initialPosition(),
1816 strike->strikePromise(),
1818 alloc));
1819 };
1820 add_multi_mask_format(addGlyphsWithSameFormat, accepted);
1821 }
1822 }
1823 }
1824
1825
1826
1828 auto [strikeSpec, strikeToSourceScale] =
1830
1833
1834 auto acceptedBuffer =
SkMakeZip(acceptedGlyphIDs, acceptedPositions);
1835 auto [accepted, rejected] =
1836 prepare_for_drawable_drawing(strike.
get(),
source, acceptedBuffer, rejectedBuffer);
1838
1839 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1840 container->fSubRuns.append(
1841 DrawableSubRun::Make(
1842 accepted,
1843 strikeToSourceScale,
1844 strike->strikePromise(),
1845 alloc));
1846 }
1847 }
1848 }
1849
1850
1851
1853 auto [strikeSpec, strikeToSourceScale] =
1855
1858
1859 auto acceptedBuffer =
SkMakeZip(acceptedGlyphIDs, acceptedPositions);
1860 auto [accepted, rejected] =
1861 prepare_for_path_drawing(strike.
get(),
source, acceptedBuffer, rejectedBuffer);
1863
1864 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1865 container->fSubRuns.append(
1866 PathSubRun::Make(accepted,
1867 has_some_antialiasing(runFont),
1868 strikeToSourceScale,
1869 strike->strikePromise(),
1870 alloc));
1871 }
1872 }
1873 }
1874
1875
1876
1877
1878
1880
1881
1882
1883
1884 SkMatrix creationMatrix = positionMatrix;
1885
1886
1888
1894 }
1895
1896
1897
1898 creationMatrix =
SkMatrix::Scale(perspectiveFactor, perspectiveFactor);
1899 }
1900
1901
1902 static const constexpr SkScalar kMaxBilerpAtlasDimension =
1904
1905
1906
1908
1909
1910 auto maxGlyphDimension = [&](
const SkMatrix&
m) {
1912 runFont, runPaint, deviceProps, scalerContextFlags, m);
1916 find_maximum_glyph_dimension(gaugingStrike.
get(),
glyphs);
1917
1918
1919
1920
1921
1922
1923 return maxDimension;
1924 };
1925
1926
1927 for (
SkScalar maxDimension = maxGlyphDimension(creationMatrix);
1928 kMaxBilerpAtlasDimension < maxDimension;
1929 maxDimension = maxGlyphDimension(creationMatrix))
1930 {
1931
1932
1933
1934
1935 SkScalar reductionFactor = kMaxBilerpAtlasDimension / maxDimension;
1936 creationMatrix.
postScale(reductionFactor, reductionFactor);
1937 }
1938
1939
1941 runFont, runPaint, deviceProps, scalerContextFlags, creationMatrix);
1942
1944
1945 auto acceptedBuffer =
1946 SkMakeZip(acceptedPackedGlyphIDs, acceptedPositions, acceptedFormats);
1947 auto [accepted, rejected, creationBounds] =
1948 prepare_for_mask_drawing(
1949 strike.
get(), creationMatrix,
source, acceptedBuffer, rejectedBuffer);
1951
1952 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1953
1954 auto addGlyphsWithSameFormat =
1955 [&,
bounds = creationBounds](
1958 container->fSubRuns.append(
1959 TransformedMaskSubRun::Make(subrun,
1960 container->initialPosition(),
1961 strike->strikePromise(),
1962 creationMatrix,
1963 bounds,
1965 alloc));
1966 };
1967 add_multi_mask_format(addGlyphsWithSameFormat, accepted);
1968 }
1969 }
1970 }
1971
1972 return container;
1973}
static bool SkIsFinite(T x, Pack... values)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
constexpr auto SkMakeZip(Ts &&... ts)
static SkScalar center(float pos0, float pos1)
static SkScalar ApproximateTransformedTextSize(const SkFont &font, const SkMatrix &matrix, const SkPoint &textLocation)
static constexpr uint16_t kSkSideTooBigForAtlas
static SkScalar DifferentialAreaScale(const SkMatrix &m, const SkPoint &p)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
bool hasPerspective() const
@ kStroke_Style
set to stroke geometry
SkScalar getStrokeWidth() const
sk_sp< sktext::StrikeForGPU > findOrCreateScopedStrike(sktext::StrikeForGPUCacheInterface *cache) const
static SkStrikeSpec MakeTransformMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
static SkStrikeSpec MakeMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
static std::tuple< SkStrikeSpec, SkScalar > MakePath(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags)
void resize(size_t count)
SkRect sourceBounds() const
size_t maxGlyphRunSize() const
bool isSDFT(SkScalar approximateDeviceTextSize, const SkPaint &paint, const SkMatrix &matrix) const
uint32_t uint32_t * format
Optional< SkRect > bounds
constexpr SkPoint center() const
const SkSurfaceProps fSurfaceProps
const SkScalerContextFlags fScalerContextFlags
const sktext::gpu::SDFTControl *const fSDFTControl