Flutter Engine
The Flutter Engine
Classes | Typedefs | Enumerations | Functions | Variables
sktext::gpu Namespace Reference

Classes

struct  AtlasPt
 
class  AtlasSubRun
 
class  BagOfBytes
 
class  DistanceFieldAdjustTable
 
class  Glyph
 
class  GlyphVector
 
class  GlyphVectorTestingPeer
 
struct  RendererData
 
class  SDFMaskFilter
 
class  SDFMaskFilterImpl
 
class  SDFTControl
 
class  SDFTMatrixRange
 
class  Slug
 
class  SlugImpl
 
class  StrikeCache
 
class  STSubRunAllocator
 
class  SubRun
 
class  SubRunAllocator
 
class  SubRunContainer
 
class  SubRunInitializer
 
class  SubRunList
 
class  TextBlob
 
class  TextBlobRedrawCoordinator
 
class  TextBlobTools
 
class  TextStrike
 
class  VertexFiller
 

Typedefs

using Rect = skgpu::graphite::Rect
 
using Transform = skgpu::graphite::Transform
 
using DrawAtlas = skgpu::graphite::DrawAtlas
 
using RegenerateAtlasDelegate = std::function< std::tuple< bool, int >(GlyphVector *, int begin, int end, skgpu::MaskFormat, int padding)>
 
using AtlasDrawDelegate = std::function< void(const sktext::gpu::AtlasSubRun *subRun, SkPoint drawOrigin, const SkPaint &paint, sk_sp< SkRefCnt > subRunStorage, sktext::gpu::RendererData)>
 
using SubRunOwner = std::unique_ptr< SubRun, SubRunAllocator::Destroyer >
 
using SubRunContainerOwner = std::unique_ptr< SubRunContainer, SubRunAllocator::Destroyer >
 

Enumerations

enum  FillerType { kIsDirect , kIsTransformed }
 

Functions

 SkDEBUGCODE (static const int kExpectedDistanceAdjustTableSize=8;) SkScalar *build_distance_adjust_table(SkScalar deviceGamma)
 
SkMatrix position_matrix (const SkMatrix &drawMatrix, SkPoint drawOrigin)
 
SkScalar find_maximum_glyph_dimension (StrikeForGPU *strike, SkSpan< const SkGlyphID > glyphs)
 
std::tuple< SkZip< const SkPackedGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint >, SkRectprepare_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 SkPackedGlyphID, const SkPoint, const SkMask::Format >, SkZip< SkGlyphID, SkPoint >, SkRectprepare_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 >, SkRectprepare_for_mask_drawing (StrikeForGPU *strike, const SkMatrix &creationMatrix, SkZip< const SkGlyphID, const SkPoint > source, SkZip< SkPackedGlyphID, SkPoint, SkMask::Format > acceptedBuffer, SkZip< SkGlyphID, SkPoint > rejectedBuffer)
 
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 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)
 
static std::tuple< SkStrikeSpec, SkScalar, sktext::gpu::SDFTMatrixRangemake_sdft_strike_spec (const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, const SkMatrix &deviceMatrix, const SkPoint &textLocation, const sktext::gpu::SDFTControl &control)
 
SkSpan< SkPointMakePointsFromBuffer (SkReadBuffer &buffer, SubRunAllocator *alloc)
 
sk_sp< SlugMakeSlug (const SkMatrix &drawMatrix, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, SkStrikeDeviceInfo strikeDeviceInfo, sktext::StrikeForGPUCacheInterface *strikeCache)
 
static std::tuple< bool, SkVectorcan_use_direct (const SkMatrix &creationMatrix, const SkMatrix &positionMatrix)
 
 DEF_TEST (GlyphVector_Serialization, r)
 
 DEF_TEST (GlyphVector_BadLengths, r)
 

Variables

static const int kSmallDFFontLimit = 32
 
static const int kMediumDFFontLimit = 72
 
static const int kLargeDFFontLimit = 162
 

Typedef Documentation

◆ AtlasDrawDelegate

using sktext::gpu::AtlasDrawDelegate = typedef std::function<void(const sktext::gpu::AtlasSubRun* subRun, SkPoint drawOrigin, const SkPaint& paint, sk_sp<SkRefCnt> subRunStorage, sktext::gpu::RendererData)>

Definition at line 119 of file SubRunContainer.h.

◆ DrawAtlas

Definition at line 321 of file TextAtlasManager.cpp.

◆ Rect

Definition at line 51 of file GraphiteVertexFiller.cpp.

◆ RegenerateAtlasDelegate

using sktext::gpu::RegenerateAtlasDelegate = typedef std::function<std::tuple<bool, int>(GlyphVector*, int begin, int end, skgpu::MaskFormat, int padding)>

Definition at line 57 of file SubRunContainer.h.

◆ SubRunContainerOwner

Definition at line 204 of file SubRunContainer.h.

◆ SubRunOwner

using sktext::gpu::SubRunOwner = typedef std::unique_ptr<SubRun, SubRunAllocator::Destroyer>

Definition at line 129 of file SubRunContainer.h.

◆ Transform

Definition at line 52 of file GraphiteVertexFiller.cpp.

Enumeration Type Documentation

◆ FillerType

Enumerator
kIsDirect 
kIsTransformed 

Definition at line 45 of file VertexFiller.h.

45 {
48};

Function Documentation

◆ can_use_direct()

static std::tuple< bool, SkVector > sktext::gpu::can_use_direct ( const SkMatrix creationMatrix,
const SkMatrix positionMatrix 
)
static

Definition at line 98 of file VertexFiller.cpp.

99 {
100 // The existing direct glyph info can be used if the creationMatrix, and the
101 // positionMatrix have the same 2x2, the translation between them is integer, and no
102 // perspective is involved. Calculate the translation in source space to a translation in
103 // device space by mapping (0, 0) through both the creationMatrix and the positionMatrix;
104 // take the difference.
105 SkVector translation = positionMatrix.mapOrigin() - creationMatrix.mapOrigin();
106 return {creationMatrix.getScaleX() == positionMatrix.getScaleX() &&
107 creationMatrix.getScaleY() == positionMatrix.getScaleY() &&
108 creationMatrix.getSkewX() == positionMatrix.getSkewX() &&
109 creationMatrix.getSkewY() == positionMatrix.getSkewY() &&
110 !positionMatrix.hasPerspective() && !creationMatrix.hasPerspective() &&
111 SkScalarIsInt(translation.x()) && SkScalarIsInt(translation.y()),
112 translation};
113}
static bool SkScalarIsInt(SkScalar x)
Definition: SkScalar.h:80
SkScalar getSkewY() const
Definition: SkMatrix.h:430
SkScalar getSkewX() const
Definition: SkMatrix.h:438
SkScalar getScaleX() const
Definition: SkMatrix.h:415
SkScalar getScaleY() const
Definition: SkMatrix.h:422
SkPoint mapOrigin() const
Definition: SkMatrix.h:1437
bool hasPerspective() const
Definition: SkMatrix.h:312
constexpr float y() const
Definition: SkPoint_impl.h:187
constexpr float x() const
Definition: SkPoint_impl.h:181

◆ DEF_TEST() [1/2]

sktext::gpu::DEF_TEST ( GlyphVector_BadLengths  ,
 
)

Definition at line 79 of file GrGlyphVectorTest.cpp.

79 {
81
82 // Strike to keep in the strike cache.
83 auto strike = strikeSpec.findOrCreateStrike();
84
85 // Be sure to keep the strike alive. The promise to serialize as the first part of the
86 // GlyphVector.
87 SkStrikePromise promise{sk_sp<SkStrike>(strike)};
88 {
89 // Make broken stream by hand - zero length
90 SkBinaryWriteBuffer wBuffer({});
91 promise.flatten(wBuffer);
92 wBuffer.write32(0); // length
93 auto data = wBuffer.snapshotAsData();
94 SkReadBuffer rBuffer{data->data(), data->size()};
95 SubRunAllocator alloc;
96 auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
97 REPORTER_ASSERT(r, !dst.has_value());
98 }
99
100 {
101 // Make broken stream by hand - zero length
102 SkBinaryWriteBuffer wBuffer({});
103 promise.flatten(wBuffer);
104 // Make broken stream by hand - stream is too short
105 wBuffer.write32(5); // length
106 wBuffer.writeUInt(12); // random data
107 wBuffer.writeUInt(12); // random data
108 wBuffer.writeUInt(12); // random data
109 auto data = wBuffer.snapshotAsData();
110 SkReadBuffer rBuffer{data->data(), data->size()};
111 SubRunAllocator alloc;
112 auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
113 REPORTER_ASSERT(r, !dst.has_value());
114 }
115
116 {
117 // Make broken stream by hand - length out of range of safe calculations
118 SkBinaryWriteBuffer wBuffer({});
119 promise.flatten(wBuffer);
120 wBuffer.write32(INT_MAX - 10); // length
121 wBuffer.writeUInt(12); // random data
122 wBuffer.writeUInt(12); // random data
123 wBuffer.writeUInt(12); // random data
124 auto data = wBuffer.snapshotAsData();
125 SkReadBuffer rBuffer{data->data(), data->size()};
126 SubRunAllocator alloc;
127 auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
128 REPORTER_ASSERT(r, !dst.has_value());
129 }
130}
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
static std::tuple< SkStrikeSpec, SkScalar > MakeCanonicalized(const SkFont &font, const SkPaint *paint=nullptr)
void write32(int32_t value)
Definition: SkWriteBuffer.h:63
static std::optional< GlyphVector > MakeFromBuffer(SkReadBuffer &buffer, const SkStrikeClient *strikeClient, SubRunAllocator *alloc)
Definition: GlyphVector.cpp:50
SkFont DefaultFont()
dst
Definition: cp.py:12
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ DEF_TEST() [2/2]

sktext::gpu::DEF_TEST ( GlyphVector_Serialization  ,
 
)

Definition at line 45 of file GrGlyphVectorTest.cpp.

45 {
47 auto [strikeSpec, _] = SkStrikeSpec::MakeCanonicalized(font);
48
49 SubRunAllocator alloc;
50
51 const int N = 10;
53 for (int i = 0; i < N; i++) {
55 }
56
57 SkStrikePromise promise{strikeSpec.findOrCreateStrike()};
58
59 GlyphVector src = GlyphVector::Make(std::move(promise), SkSpan(glyphs, N), &alloc);
60
61 SkBinaryWriteBuffer wBuffer({});
62 src.flatten(wBuffer);
63
64 auto data = wBuffer.snapshotAsData();
65 SkReadBuffer rBuffer{data->data(), data->size()};
66 auto dst = GlyphVector::MakeFromBuffer(rBuffer, nullptr, &alloc);
67 REPORTER_ASSERT(r, dst.has_value());
69 GlyphVectorTestingPeer::GetDescriptor(src) ==
70 GlyphVectorTestingPeer::GetDescriptor(*dst));
71
72 auto srcGlyphs = GlyphVectorTestingPeer::GetGlyphs(src);
73 auto dstGlyphs = GlyphVectorTestingPeer::GetGlyphs(*dst);
74 for (auto [srcGlyphID, dstGlyphID] : SkMakeZip(srcGlyphs, dstGlyphs)) {
75 REPORTER_ASSERT(r, srcGlyphID.packedGlyphID == dstGlyphID.packedGlyphID);
76 }
77}
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
uint16_t SkGlyphID
Definition: SkTypes.h:179
constexpr auto SkMakeZip(Ts &&... ts)
Definition: SkZip.h:212
#define N
Definition: beziers.cpp:19
Definition: SkFont.h:35
static GlyphVector Make(SkStrikePromise &&promise, SkSpan< const SkPackedGlyphID > glyphs, SubRunAllocator *alloc)
Definition: GlyphVector.cpp:38
font
Font Metadata and Metrics.

◆ find_maximum_glyph_dimension()

SkScalar sktext::gpu::find_maximum_glyph_dimension ( StrikeForGPU strike,
SkSpan< const SkGlyphID glyphs 
)

Definition at line 1431 of file SubRunContainer.cpp.

1431 {
1432 StrikeMutationMonitor m{strike};
1433 SkScalar maxDimension = 0;
1434 for (SkGlyphID glyphID : glyphs) {
1435 SkGlyphDigest digest = strike->digestFor(kMask, SkPackedGlyphID{glyphID});
1436 maxDimension = std::max(static_cast<SkScalar>(digest.maxDimension()), maxDimension);
1437 }
1438
1439 return maxDimension;
1440}
uint16_t maxDimension() const
Definition: SkGlyph.h:349
virtual SkGlyphDigest digestFor(skglyph::ActionType, SkPackedGlyphID)=0
float SkScalar
Definition: extension.cpp:12
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ make_sdft_strike_spec()

static std::tuple< SkStrikeSpec, SkScalar, sktext::gpu::SDFTMatrixRange > sktext::gpu::make_sdft_strike_spec ( const SkFont font,
const SkPaint paint,
const SkSurfaceProps surfaceProps,
const SkMatrix deviceMatrix,
const SkPoint textLocation,
const sktext::gpu::SDFTControl control 
)
static

Definition at line 1637 of file SubRunContainer.cpp.

1639 {
1640 // Add filter to the paint which creates the SDFT data for A8 masks.
1641 SkPaint dfPaint{paint};
1642 dfPaint.setMaskFilter(sktext::gpu::SDFMaskFilter::Make());
1643
1644 auto [dfFont, strikeToSourceScale, matrixRange] = control.getSDFFont(font, deviceMatrix,
1645 textLocation);
1646
1647 // Adjust the stroke width by the scale factor for drawing the SDFT.
1648 dfPaint.setStrokeWidth(paint.getStrokeWidth() / strikeToSourceScale);
1649
1650 // Check for dashing and adjust the intervals.
1651 if (SkPathEffect* pathEffect = paint.getPathEffect(); pathEffect != nullptr) {
1652 SkPathEffect::DashInfo dashInfo;
1653 if (pathEffect->asADash(&dashInfo) == SkPathEffect::kDash_DashType) {
1654 if (dashInfo.fCount > 0) {
1655 // Allocate the intervals.
1656 std::vector<SkScalar> scaledIntervals(dashInfo.fCount);
1657 dashInfo.fIntervals = scaledIntervals.data();
1658 // Call again to get the interval data.
1659 (void)pathEffect->asADash(&dashInfo);
1660 for (SkScalar& interval : scaledIntervals) {
1661 interval /= strikeToSourceScale;
1662 }
1663 auto scaledDashes = SkDashPathEffect::Make(scaledIntervals.data(),
1664 scaledIntervals.size(),
1665 dashInfo.fPhase / strikeToSourceScale);
1666 dfPaint.setPathEffect(scaledDashes);
1667 }
1668 }
1669 }
1670
1671 // Fake-gamma and subpixel antialiasing are applied in the shader, so we ignore the
1672 // passed-in scaler context flags. (It's only used when we fall-back to bitmap text).
1674 SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask(dfFont, dfPaint, surfaceProps, flags,
1675 SkMatrix::I());
1676
1677 return std::make_tuple(std::move(strikeSpec), strikeToSourceScale, matrixRange);
1678}
SkScalerContextFlags
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static const SkMatrix & I()
Definition: SkMatrix.cpp:1544
@ kDash_DashType
fills in all of the info parameter
Definition: SkPathEffect.h:62
static SkStrikeSpec MakeMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
static sk_sp< SkMaskFilter > Make()
std::tuple< SkFont, SkScalar, SDFTMatrixRange > getSDFFont(const SkFont &font, const SkMatrix &viewMatrix, const SkPoint &textLocation) const
Definition: SDFTControl.cpp:83
const Paint & paint
Definition: color_source.cc:38
FlutterSemanticsFlag flags
SkScalar fPhase
Offset into the dashed interval pattern.
Definition: SkPathEffect.h:73
int32_t fCount
Number of intervals in the dash. Should be even number.
Definition: SkPathEffect.h:72
SkScalar * fIntervals
Length of on/off intervals for dashed lines.
Definition: SkPathEffect.h:70

◆ MakePointsFromBuffer()

SkSpan< SkPoint > sktext::gpu::MakePointsFromBuffer ( SkReadBuffer buffer,
SubRunAllocator alloc 
)

Definition at line 1996 of file SubRunContainer.cpp.

1996 {
1997 uint32_t glyphCount = buffer.getArrayCount();
1998
1999 // Zero indicates a problem with serialization.
2000 if (!buffer.validate(glyphCount != 0)) { return {}; }
2001
2002 // Check that the count will not overflow the arena.
2003 if (!buffer.validate(glyphCount <= INT_MAX &&
2004 BagOfBytes::WillCountFit<SkPoint>(glyphCount))) { return {}; }
2005
2006 SkPoint* positionsData = alloc->makePODArray<SkPoint>(glyphCount);
2007 if (!buffer.readPointArray(positionsData, glyphCount)) { return {}; }
2008 return {positionsData, glyphCount};
2009}
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ MakeSlug()

sk_sp< sktext::gpu::Slug > sktext::gpu::MakeSlug ( const SkMatrix drawMatrix,
const sktext::GlyphRunList glyphRunList,
const SkPaint paint,
SkStrikeDeviceInfo  strikeDeviceInfo,
sktext::StrikeForGPUCacheInterface strikeCache 
)

Definition at line 255 of file TextBlob.cpp.

259 {
260 return SlugImpl::Make(drawMatrix, glyphRunList, paint, strikeDeviceInfo, strikeCache);
261}
SK_API sk_sp< SkDocument > Make(SkWStream *dst, const SkSerialProcs *=nullptr, std::function< void(const SkPicture *)> onEndPage=nullptr)

◆ position_matrix()

SkMatrix sktext::gpu::position_matrix ( const SkMatrix drawMatrix,
SkPoint  drawOrigin 
)

Definition at line 69 of file SlugImpl.cpp.

69 {
70 SkMatrix position_matrix = drawMatrix;
71 return position_matrix.preTranslate(drawOrigin.x(), drawOrigin.y());
72}
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:263
SkMatrix position_matrix(const SkMatrix &drawMatrix, SkPoint drawOrigin)
Definition: SlugImpl.cpp:69

◆ prepare_for_direct_mask_drawing()

std::tuple< SkZip< const SkPackedGlyphID, const SkPoint, const SkMask::Format >, SkZip< SkGlyphID, SkPoint >, SkRect > sktext::gpu::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 
)

Definition at line 1490 of file SubRunContainer.cpp.

1494 {
1495 const SkIPoint mask = strike->roundingSpec().ignorePositionFieldMask;
1496 const SkPoint halfSampleFreq = strike->roundingSpec().halfAxisSampleFreq;
1497
1498 // Build up the mapping from source space to device space. Add the rounding constant
1499 // halfSampleFreq, so we just need to floor to get the device result.
1500 SkMatrix positionMatrixWithRounding = positionMatrix;
1501 positionMatrixWithRounding.postTranslate(halfSampleFreq.x(), halfSampleFreq.y());
1502
1503 int acceptedSize = 0,
1504 rejectedSize = 0;
1505 SkGlyphRect boundingRect = skglyph::empty_rect();
1506 StrikeMutationMonitor m{strike};
1507 for (auto [glyphID, pos] : source) {
1508 if (!SkIsFinite(pos.x(), pos.y())) {
1509 continue;
1510 }
1511
1512 const SkPoint mappedPos = positionMatrixWithRounding.mapPoint(pos);
1513 const SkPackedGlyphID packedID{glyphID, mappedPos, mask};
1514 switch (const SkGlyphDigest digest = strike->digestFor(skglyph::kDirectMask, packedID);
1516 case GlyphAction::kAccept: {
1517 const SkPoint roundedPos{SkScalarFloorToScalar(mappedPos.x()),
1518 SkScalarFloorToScalar(mappedPos.y())};
1519 const SkGlyphRect glyphBounds = digest.bounds().offset(roundedPos);
1520 boundingRect = skglyph::rect_union(boundingRect, glyphBounds);
1521 acceptedBuffer[acceptedSize++] =
1522 std::make_tuple(packedID, glyphBounds.leftTop(), digest.maskFormat());
1523 break;
1524 }
1525 case GlyphAction::kReject:
1526 rejectedBuffer[rejectedSize++] = std::make_tuple(glyphID, pos);
1527 break;
1528 default:
1529 break;
1530 }
1531 }
1532
1533 return {acceptedBuffer.first(acceptedSize),
1534 rejectedBuffer.first(rejectedSize),
1535 boundingRect.rect()};
1536}
SkPoint pos
static bool SkIsFinite(T x, Pack... values)
#define SkScalarFloorToScalar(x)
Definition: SkScalar.h:30
skglyph::GlyphAction actionFor(skglyph::ActionType actionType) const
Definition: SkGlyph.h:343
SkPoint leftTop() const
Definition: SkGlyph.h:275
SkRect rect() const
Definition: SkGlyph.h:259
SkGlyphRect offset(SkScalar x, SkScalar y) const
Definition: SkGlyph.h:262
SkMatrix & postTranslate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.cpp:281
SkPoint mapPoint(SkPoint pt) const
Definition: SkMatrix.h:1374
constexpr SkZip first(size_t n) const
Definition: SkZip.h:86
virtual const SkGlyphPositionRoundingSpec & roundingSpec() const =0
SkBitmap source
Definition: examples.cpp:28
SkGlyphRect empty_rect()
Definition: SkGlyph.h:289
SkGlyphRect rect_union(SkGlyphRect, SkGlyphRect)
Definition: SkGlyph.h:297
@ kDirectMask
Definition: SkGlyph.h:313
const SkVector halfAxisSampleFreq
Definition: SkGlyph.h:233
const SkIPoint ignorePositionFieldMask
Definition: SkGlyph.h:235

◆ prepare_for_drawable_drawing()

std::tuple< SkZip< const SkGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint > > sktext::gpu::prepare_for_drawable_drawing ( StrikeForGPU strike,
SkZip< const SkGlyphID, const SkPoint source,
SkZip< SkGlyphID, SkPoint acceptedBuffer,
SkZip< SkGlyphID, SkPoint rejectedBuffer 
)

Definition at line 1608 of file SubRunContainer.cpp.

1611 {
1612 int acceptedSize = 0;
1613 int rejectedSize = 0;
1614 StrikeMutationMonitor m{strike};
1615 for (const auto [glyphID, pos] : source) {
1616 if (!SkIsFinite(pos.x(), pos.y())) {
1617 continue;
1618 }
1619
1620 switch (strike->digestFor(skglyph::kDrawable, SkPackedGlyphID{glyphID})
1622 case GlyphAction::kAccept:
1623 acceptedBuffer[acceptedSize++] = std::make_tuple(glyphID, pos);
1624 break;
1625 case GlyphAction::kReject:
1626 rejectedBuffer[rejectedSize++] = std::make_tuple(glyphID, pos);
1627 break;
1628 default:
1629 break;
1630 }
1631 }
1632 return {acceptedBuffer.first(acceptedSize), rejectedBuffer.first(rejectedSize)};
1633}
@ kDrawable
Definition: SkGlyph.h:318

◆ prepare_for_mask_drawing()

std::tuple< SkZip< const SkPackedGlyphID, const SkPoint, const SkMask::Format >, SkZip< SkGlyphID, SkPoint >, SkRect > sktext::gpu::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 
)

Definition at line 1541 of file SubRunContainer.cpp.

1545 {
1546 int acceptedSize = 0,
1547 rejectedSize = 0;
1548 SkGlyphRect boundingRect = skglyph::empty_rect();
1549 StrikeMutationMonitor m{strike};
1550 for (auto [glyphID, pos] : source) {
1551 if (!SkIsFinite(pos.x(), pos.y())) {
1552 continue;
1553 }
1554
1555 const SkPackedGlyphID packedID{glyphID};
1556 switch (const SkGlyphDigest digest = strike->digestFor(kMask, packedID);
1557 digest.actionFor(kMask)) {
1558 case GlyphAction::kAccept: {
1559 const SkPoint mappedPos = creationMatrix.mapPoint(pos);
1560 const SkGlyphRect glyphBounds = digest.bounds().offset(mappedPos);
1561 boundingRect = skglyph::rect_union(boundingRect, glyphBounds);
1562 acceptedBuffer[acceptedSize++] =
1563 std::make_tuple(packedID, glyphBounds.leftTop(), digest.maskFormat());
1564 break;
1565 }
1566 case GlyphAction::kReject:
1567 rejectedBuffer[rejectedSize++] = std::make_tuple(glyphID, pos);
1568 break;
1569 default:
1570 break;
1571 }
1572 }
1573
1574 return {acceptedBuffer.first(acceptedSize),
1575 rejectedBuffer.first(rejectedSize),
1576 boundingRect.rect()};
1577}

◆ prepare_for_path_drawing()

std::tuple< SkZip< const SkGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint > > sktext::gpu::prepare_for_path_drawing ( StrikeForGPU strike,
SkZip< const SkGlyphID, const SkPoint source,
SkZip< SkGlyphID, SkPoint acceptedBuffer,
SkZip< SkGlyphID, SkPoint rejectedBuffer 
)

Definition at line 1580 of file SubRunContainer.cpp.

1583 {
1584 int acceptedSize = 0;
1585 int rejectedSize = 0;
1586 StrikeMutationMonitor m{strike};
1587 for (const auto [glyphID, pos] : source) {
1588 if (!SkIsFinite(pos.x(), pos.y())) {
1589 continue;
1590 }
1591
1592 switch (strike->digestFor(skglyph::kPath, SkPackedGlyphID{glyphID})
1594 case GlyphAction::kAccept:
1595 acceptedBuffer[acceptedSize++] = std::make_tuple(glyphID, pos);
1596 break;
1597 case GlyphAction::kReject:
1598 rejectedBuffer[rejectedSize++] = std::make_tuple(glyphID, pos);
1599 break;
1600 default:
1601 break;
1602 }
1603 }
1604 return {acceptedBuffer.first(acceptedSize), rejectedBuffer.first(rejectedSize)};
1605}
@ kPath
Definition: SkGlyph.h:317

◆ prepare_for_SDFT_drawing()

std::tuple< SkZip< const SkPackedGlyphID, const SkPoint >, SkZip< SkGlyphID, SkPoint >, SkRect > sktext::gpu::prepare_for_SDFT_drawing ( StrikeForGPU strike,
const SkMatrix creationMatrix,
SkZip< const SkGlyphID, const SkPoint source,
SkZip< SkPackedGlyphID, SkPoint acceptedBuffer,
SkZip< SkGlyphID, SkPoint rejectedBuffer 
)

Definition at line 1444 of file SubRunContainer.cpp.

1448 {
1449 int acceptedSize = 0,
1450 rejectedSize = 0;
1451 SkGlyphRect boundingRect = skglyph::empty_rect();
1452 StrikeMutationMonitor m{strike};
1453 for (const auto [glyphID, pos] : source) {
1454 if (!SkIsFinite(pos.x(), pos.y())) {
1455 continue;
1456 }
1457
1458 const SkPackedGlyphID packedID{glyphID};
1459 switch (const SkGlyphDigest digest = strike->digestFor(skglyph::kSDFT, packedID);
1460 digest.actionFor(skglyph::kSDFT)) {
1461 case GlyphAction::kAccept: {
1462 SkPoint mappedPos = creationMatrix.mapPoint(pos);
1463 const SkGlyphRect glyphBounds =
1464 digest.bounds()
1465 // The SDFT glyphs have 2-pixel wide padding that should
1466 // not be used in calculating the source rectangle.
1468 .offset(mappedPos);
1469 boundingRect = skglyph::rect_union(boundingRect, glyphBounds);
1470 acceptedBuffer[acceptedSize++] = std::make_tuple(packedID, glyphBounds.leftTop());
1471 break;
1472 }
1473 case GlyphAction::kReject:
1474 rejectedBuffer[rejectedSize++] = std::make_tuple(glyphID, pos);
1475 break;
1476 default:
1477 break;
1478 }
1479 }
1480
1481 return {acceptedBuffer.first(acceptedSize),
1482 rejectedBuffer.first(rejectedSize),
1483 boundingRect.rect()};
1484}
#define SK_DistanceFieldInset
SkGlyphRect inset(SkScalar dx, SkScalar dy) const
Definition: SkGlyph.h:272
@ kSDFT
Definition: SkGlyph.h:316

◆ SkDEBUGCODE()

sktext::gpu::SkDEBUGCODE ( static const int  kExpectedDistanceAdjustTableSize = 8;)

Definition at line 23 of file DistanceFieldAdjustTable.cpp.

25 {
26 // This is used for an approximation of the mask gamma hack, used by raster and bitmap
27 // text. The mask gamma hack is based off of guessing what the blend color is going to
28 // be, and adjusting the mask so that when run through the linear blend will
29 // produce the value closest to the desired result. However, in practice this means
30 // that the 'adjusted' mask is just increasing or decreasing the coverage of
31 // the mask depending on what it is thought it will blit against. For black (on
32 // assumed white) this means that coverages are decreased (on a curve). For white (on
33 // assumed black) this means that coverages are increased (on a a curve). At
34 // middle (perceptual) gray (which could be blit against anything) the coverages
35 // remain the same.
36 //
37 // The idea here is that instead of determining the initial (real) coverage and
38 // then adjusting that coverage, we determine an adjusted coverage directly by
39 // essentially manipulating the geometry (in this case, the distance to the glyph
40 // edge). So for black (on assumed white) this thins a bit; for white (on
41 // assumed black) this fake bolds the geometry a bit.
42 //
43 // The distance adjustment is calculated by determining the actual coverage value which
44 // when fed into in the mask gamma table gives us an 'adjusted coverage' value of 0.5. This
45 // actual coverage value (assuming it's between 0 and 1) corresponds to a distance from the
46 // actual edge. So by subtracting this distance adjustment and computing without the
47 // the coverage adjustment we should get 0.5 coverage at the same point.
48 //
49 // This has several implications:
50 // For non-gray lcd smoothed text, each subpixel essentially is using a
51 // slightly different geometry.
52 //
53 // For black (on assumed white) this may not cover some pixels which were
54 // previously covered; however those pixels would have been only slightly
55 // covered and that slight coverage would have been decreased anyway. Also, some pixels
56 // which were previously fully covered may no longer be fully covered.
57 //
58 // For white (on assumed black) this may cover some pixels which weren't
59 // previously covered at all.
60
61 int width, height;
62 size_t size;
63 SkScalar contrast = SK_GAMMA_CONTRAST;
64
65 size = SkScalerContext::GetGammaLUTSize(contrast, deviceGamma,
66 &width, &height);
67
68 SkASSERT(kExpectedDistanceAdjustTableSize == height);
70
72 if (!SkScalerContext::GetGammaLUTData(contrast, deviceGamma, data.get())) {
73 // if no valid data is available simply do no adjustment
74 for (int row = 0; row < height; ++row) {
75 table[row] = 0;
76 }
77 return table;
78 }
79
80 // find the inverse points where we cross 0.5
81 // binsearch might be better, but we only need to do this once on creation
82 for (int row = 0; row < height; ++row) {
83 uint8_t* rowPtr = data.get() + row*width;
84 for (int col = 0; col < width - 1; ++col) {
85 if (rowPtr[col] <= 127 && rowPtr[col + 1] >= 128) {
86 // compute point where a mask value will give us a result of 0.5
87 float interp = (127.5f - rowPtr[col]) / (rowPtr[col + 1] - rowPtr[col]);
88 float borderAlpha = (col + interp) / 255.f;
89
90 // compute t value for that alpha
91 // this is an approximate inverse for smoothstep()
92 float t = borderAlpha*(borderAlpha*(4.0f*borderAlpha - 6.0f) + 5.0f) / 3.0f;
93
94 // compute distance which gives us that t value
95 const float kDistanceFieldAAFactor = 0.65f; // should match SK_DistanceFieldAAFactor
96 float d = 2.0f*kDistanceFieldAAFactor*t - kDistanceFieldAAFactor;
97
98 table[row] = d;
99 break;
100 }
101 }
102 }
103
104 return table;
105}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static float2 interp(const float2 &v0, const float2 &v1, const float2 &t)
Definition: SkGeometry.cpp:169
#define SK_GAMMA_CONTRAST
Definition: SkTypes.h:94
SI F table(const skcms_Curve *curve, F v)
static size_t GetGammaLUTSize(SkScalar contrast, SkScalar deviceGamma, int *width, int *height)
static bool GetGammaLUTData(SkScalar contrast, SkScalar deviceGamma, uint8_t *data)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
int32_t height
int32_t width

Variable Documentation

◆ kLargeDFFontLimit

const int sktext::gpu::kLargeDFFontLimit = 162
static

Definition at line 32 of file SDFTControl.cpp.

◆ kMediumDFFontLimit

const int sktext::gpu::kMediumDFFontLimit = 72
static

Definition at line 31 of file SDFTControl.cpp.

◆ kSmallDFFontLimit

const int sktext::gpu::kSmallDFFontLimit = 32
static

Definition at line 30 of file SDFTControl.cpp.