1689 {
1692
1694
1696 return container;
1697 }
1698
1701#if !defined(SK_DISABLE_SDF_TEXT)
1704#else
1706#endif
1707
1708
1709
1711
1712
1717 acceptedPackedGlyphIDs.
resize(maxGlyphRunSize);
1718 acceptedGlyphIDs.
resize(maxGlyphRunSize);
1719 acceptedPositions.
resize(maxGlyphRunSize);
1720 acceptedFormats.
resize(maxGlyphRunSize);
1721
1722
1725 rejectedGlyphIDs.
resize(maxGlyphRunSize);
1726 rejectedPositions.
resize(maxGlyphRunSize);
1727 const auto rejectedBuffer =
SkMakeZip(rejectedGlyphIDs, rejectedPositions);
1728
1730
1731
1732 for (auto& glyphRun : glyphRunList) {
1734 const SkFont& runFont = glyphRun.font();
1735
1736 const SkScalar approximateDeviceTextSize =
1737
1738
1740 glyphRunListLocation);
1741
1742
1743
1745 approximateDeviceTextSize < maxMaskSize) {
1746
1747#if !defined(SK_DISABLE_SDF_TEXT)
1748
1750
1751 const auto& [strikeSpec, strikeToSourceScale, matrixRange] =
1753 runFont, runPaint, deviceProps, positionMatrix,
1755
1758
1759
1760
1761
1762
1763
1764
1765
1766
1769
1770 auto acceptedBuffer =
SkMakeZip(acceptedPackedGlyphIDs, acceptedPositions);
1772 strike.
get(), creationMatrix,
source, acceptedBuffer, rejectedBuffer);
1774
1775 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1777 accepted,
1778 runFont,
1779 strike->strikePromise(),
1780 creationMatrix,
1781 creationBounds,
1782 matrixRange,
1783 alloc));
1784 }
1785 }
1786 }
1787#endif
1788
1789
1790
1792
1793
1794
1795
1797 runFont, runPaint, deviceProps, scalerContextFlags, positionMatrix);
1798
1800
1801 auto acceptedBuffer =
SkMakeZip(acceptedPackedGlyphIDs,
1802 acceptedPositions,
1803 acceptedFormats);
1805 strike.
get(), positionMatrix,
source, acceptedBuffer, rejectedBuffer);
1807
1808 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1809 auto addGlyphsWithSameFormat =
1810 [&,
bounds = creationBounds](
1813 container->fSubRuns.append(
1815 subrun,
1816 container->initialPosition(),
1817 strike->strikePromise(),
1819 alloc));
1820 };
1821 add_multi_mask_format(addGlyphsWithSameFormat, accepted);
1822 }
1823 }
1824 }
1825
1826
1827
1829 auto [strikeSpec, strikeToSourceScale] =
1831
1834
1835 auto acceptedBuffer =
SkMakeZip(acceptedGlyphIDs, acceptedPositions);
1836 auto [accepted, rejected] =
1839
1840 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1841 container->fSubRuns.append(
1843 accepted,
1844 strikeToSourceScale,
1845 strike->strikePromise(),
1846 alloc));
1847 }
1848 }
1849 }
1850
1851
1852
1854 auto [strikeSpec, strikeToSourceScale] =
1856
1859
1860 auto acceptedBuffer =
SkMakeZip(acceptedGlyphIDs, acceptedPositions);
1861 auto [accepted, rejected] =
1864
1865 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1866 container->fSubRuns.append(
1868 has_some_antialiasing(runFont),
1869 strikeToSourceScale,
1870 strike->strikePromise(),
1871 alloc));
1872 }
1873 }
1874 }
1875
1876
1877
1878
1879
1881
1882
1883
1884
1885 SkMatrix creationMatrix = positionMatrix;
1886
1887
1889
1895 }
1896
1897
1898
1899 creationMatrix =
SkMatrix::Scale(perspectiveFactor, perspectiveFactor);
1900 }
1901
1902
1903 static const constexpr SkScalar kMaxBilerpAtlasDimension =
1905
1906
1907
1909
1910
1911 auto maxGlyphDimension = [&](
const SkMatrix&
m) {
1913 runFont, runPaint, deviceProps, scalerContextFlags,
m);
1918
1919
1920
1921
1922
1923
1924 return maxDimension;
1925 };
1926
1927
1928 for (
SkScalar maxDimension = maxGlyphDimension(creationMatrix);
1929 kMaxBilerpAtlasDimension < maxDimension;
1930 maxDimension = maxGlyphDimension(creationMatrix))
1931 {
1932
1933
1934
1935
1936 SkScalar reductionFactor = kMaxBilerpAtlasDimension / maxDimension;
1937 creationMatrix.
postScale(reductionFactor, reductionFactor);
1938 }
1939
1940
1942 runFont, runPaint, deviceProps, scalerContextFlags, creationMatrix);
1943
1945
1946 auto acceptedBuffer =
1947 SkMakeZip(acceptedPackedGlyphIDs, acceptedPositions, acceptedFormats);
1948 auto [accepted, rejected, creationBounds] =
1950 strike.
get(), creationMatrix,
source, acceptedBuffer, rejectedBuffer);
1952
1953 if (creationBehavior ==
kAddSubRuns && !accepted.empty()) {
1954
1955 auto addGlyphsWithSameFormat =
1956 [&,
bounds = creationBounds](
1959 container->fSubRuns.append(
1961 container->initialPosition(),
1962 strike->strikePromise(),
1963 creationMatrix,
1966 alloc));
1967 };
1968 add_multi_mask_format(addGlyphsWithSameFormat, accepted);
1969 }
1970 }
1971 }
1972
1973 return container;
1974}
static bool SkIsFinite(T x, Pack... values)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
constexpr auto SkMakeZip(Ts &&... ts)
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
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)
Optional< SkRect > bounds
std::tuple< SkZip< const SkPackedGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint >, SkRect > prepare_for_SDFT_drawing(StrikeForGPU *strike, const SkMatrix &creationMatrix, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkPackedGlyphID, SkPoint > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
std::tuple< SkZip< const SkGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint > > prepare_for_drawable_drawing(StrikeForGPU *strike, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkGlyphID, SkPoint > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
SkScalar find_maximum_glyph_dimension(StrikeForGPU *strike, SkSpan< const SkGlyphID > glyphs)
std::tuple< SkZip< const SkGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint > > prepare_for_path_drawing(StrikeForGPU *strike, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkGlyphID, SkPoint > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
std::tuple< SkZip< const SkPackedGlyphID, const SkPoint, const SkMask::Format >, SkZip< SkGlyphID, SkPoint >, SkRect > prepare_for_direct_mask_drawing(StrikeForGPU *strike, const SkMatrix &positionMatrix, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkPackedGlyphID, SkPoint, SkMask::Format > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
std::tuple< SkZip< const SkPackedGlyphID, const SkPoint, const SkMask::Format >, SkZip< SkGlyphID, SkPoint >, SkRect > prepare_for_mask_drawing(StrikeForGPU *strike, const SkMatrix &creationMatrix, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkPackedGlyphID, SkPoint, SkMask::Format > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
static std::tuple< SkStrikeSpec, SkScalar, sktext::gpu::SDFTMatrixRange > make_sdft_strike_spec(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, const SkMatrix &deviceMatrix, const SkPoint &textLocation, const sktext::gpu::SDFTControl &control)
constexpr SkPoint center() const
const SkSurfaceProps fSurfaceProps
const SkScalerContextFlags fScalerContextFlags
const sktext::gpu::SDFTControl *const fSDFTControl