Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 paintGamma
 
 SkASSERT (kExpectedDistanceAdjustTableSize==height)
 
AutoTArray< uint8_t > data ((int) size)
 
 if (!SkScalerContext::GetGammaLUTData(contrast, paintGamma, deviceGamma, data.get()))
 
 for (int row=0;row< height;++row)
 
SkMatrix position_matrix (const SkMatrix &drawMatrix, SkPoint drawOrigin)
 
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

SkScalar deviceGamma
 
size_t size
 
SkScalar contrast = SK_GAMMA_CONTRAST
 
SkScalartable = new SkScalar[height]
 
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 310 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
constexpr float x() const

◆ data()

AutoTArray< uint8_t > sktext::gpu::data ( (int size)

◆ 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)
static std::optional< GlyphVector > MakeFromBuffer(SkReadBuffer &buffer, const SkStrikeClient *strikeClient, SubRunAllocator *alloc)
SkFont DefaultFont()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
dst
Definition cp.py:12

◆ 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]
uint16_t SkGlyphID
Definition SkTypes.h:179
constexpr auto SkMakeZip(Ts &&... ts)
Definition SkZip.h:212
#define N
Definition beziers.cpp:19
static GlyphVector Make(SkStrikePromise &&promise, SkSpan< const SkPackedGlyphID > glyphs, SubRunAllocator *alloc)

◆ for()

sktext::gpu::for ( )

Definition at line 82 of file DistanceFieldAdjustTable.cpp.

82 {
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 }
static float2 interp(const float2 &v0, const float2 &v1, const float2 &t)
SI F table(const skcms_Curve *curve, F v)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19
int32_t width

◆ if()

sktext::gpu::if ( SkScalerContext::GetGammaLUTDatacontrast, paintGamma, deviceGamma, data.get())

Definition at line 72 of file DistanceFieldAdjustTable.cpp.

72 {
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 }
int32_t height

◆ 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}
static sk_sp< SlugImpl > Make(const SkMatrix &viewMatrix, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, SkStrikeDeviceInfo strikeDeviceInfo, sktext::StrikeForGPUCacheInterface *strikeCache)
Definition SlugImpl.cpp:74
const Paint & paint

◆ 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

◆ SkASSERT()

sktext::gpu::SkASSERT ( kExpectedDistanceAdjustTableSize  = =height)

◆ SkDEBUGCODE()

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

Variable Documentation

◆ contrast

SkScalar sktext::gpu::contrast = SK_GAMMA_CONTRAST

Definition at line 63 of file DistanceFieldAdjustTable.cpp.

◆ deviceGamma

SkScalar sktext::gpu::deviceGamma

Definition at line 25 of file DistanceFieldAdjustTable.cpp.

◆ 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.

◆ size

sktext::gpu::size
Initial value:
= SkScalerContext::GetGammaLUTSize(contrast, paintGamma, deviceGamma,
static size_t GetGammaLUTSize(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma, int *width, int *height)

Definition at line 62 of file DistanceFieldAdjustTable.cpp.

◆ table

return sktext::gpu::table = new SkScalar[height]

Definition at line 69 of file DistanceFieldAdjustTable.cpp.