Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skgpu::graphite::BitmapTextRenderStep Class Referencefinal

#include <BitmapTextRenderStep.h>

Inheritance diagram for skgpu::graphite::BitmapTextRenderStep:
skgpu::graphite::RenderStep

Public Member Functions

 BitmapTextRenderStep (bool isLCD)
 
 ~BitmapTextRenderStep () override
 
std::string vertexSkSL () const override
 
std::string texturesAndSamplersSkSL (const ResourceBindingRequirements &, int *nextBindingIndex) const override
 
const char * fragmentCoverageSkSL () const override
 
void writeVertices (DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const override
 
void writeUniformsAndTextures (const DrawParams &, PipelineDataGatherer *) const override
 
- Public Member Functions inherited from skgpu::graphite::RenderStep
virtual ~RenderStep ()=default
 
virtual void writeVertices (DrawWriter *, const DrawParams &, skvx::ushort2 ssboIndices) const =0
 
virtual void writeUniformsAndTextures (const DrawParams &, PipelineDataGatherer *) const =0
 
virtual std::string vertexSkSL () const =0
 
virtual std::string texturesAndSamplersSkSL (const ResourceBindingRequirements &, int *nextBindingIndex) const
 
virtual const char * fragmentCoverageSkSL () const
 
virtual const char * fragmentColorSkSL () const
 
uint32_t uniqueID () const
 
const char * name () const
 
bool requiresMSAA () const
 
bool performsShading () const
 
bool hasTextures () const
 
bool emitsPrimitiveColor () const
 
bool outsetBoundsForAA () const
 
Coverage coverage () const
 
PrimitiveType primitiveType () const
 
size_t vertexStride () const
 
size_t instanceStride () const
 
size_t numUniforms () const
 
size_t numVertexAttributes () const
 
size_t numInstanceAttributes () const
 
SkSpan< const Uniformuniforms () const
 
SkSpan< const AttributevertexAttributes () const
 
SkSpan< const AttributeinstanceAttributes () const
 
SkSpan< const Varyingvaryings () const
 
const DepthStencilSettingsdepthStencilSettings () const
 
SkEnumBitMask< DepthStencilFlagsdepthStencilFlags () const
 

Additional Inherited Members

- Static Public Member Functions inherited from skgpu::graphite::RenderStep
static const char * ssboIndicesAttribute ()
 
static const char * ssboIndicesVarying ()
 
- Protected Types inherited from skgpu::graphite::RenderStep
enum class  Flags : unsigned {
  kNone = 0b0000000 , kRequiresMSAA = 0b0000001 , kPerformsShading = 0b0000010 , kHasTextures = 0b0000100 ,
  kEmitsCoverage = 0b0001000 , kLCDCoverage = 0b0010000 , kEmitsPrimitiveColor = 0b0100000 , kOutsetBoundsForAA = 0b1000000
}
 
- Protected Member Functions inherited from skgpu::graphite::RenderStep
 RenderStep (std::string_view className, std::string_view variantName, SkEnumBitMask< Flags > flags, std::initializer_list< Uniform > uniforms, PrimitiveType primitiveType, DepthStencilSettings depthStencilSettings, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, SkSpan< const Varying > varyings={})
 

Detailed Description

Definition at line 15 of file BitmapTextRenderStep.h.

Constructor & Destructor Documentation

◆ BitmapTextRenderStep()

skgpu::graphite::BitmapTextRenderStep::BitmapTextRenderStep ( bool  isLCD)

Definition at line 35 of file BitmapTextRenderStep.cpp.

36 : RenderStep("BitmapTextRenderStep",
37 "",
41 /*uniforms=*/{{"subRunDeviceMatrix", SkSLType::kFloat4x4},
42 {"deviceToLocal" , SkSLType::kFloat4x4},
43 {"atlasSizeInv" , SkSLType::kFloat2}},
46 /*vertexAttrs=*/ {},
47 /*instanceAttrs=*/
52 {"strikeToSourceScale", VertexAttribType::kFloat, SkSLType::kFloat},
55 /*varyings=*/
56 {{"textureCoords", SkSLType::kFloat2},
57 {"texIndex", SkSLType::kHalf},
58 {"maskFormat", SkSLType::kHalf}}) {}
static bool isLCD(const SkScalerContextRec &rec)
RenderStep(std::string_view className, std::string_view variantName, SkEnumBitMask< Flags > flags, std::initializer_list< Uniform > uniforms, PrimitiveType primitiveType, DepthStencilSettings depthStencilSettings, SkSpan< const Attribute > vertexAttrs, SkSpan< const Attribute > instanceAttrs, SkSpan< const Varying > varyings={})
Definition: Renderer.cpp:19
static constexpr DepthStencilSettings kDirectDepthGEqualPass

◆ ~BitmapTextRenderStep()

skgpu::graphite::BitmapTextRenderStep::~BitmapTextRenderStep ( )
override

Definition at line 60 of file BitmapTextRenderStep.cpp.

60{}

Member Function Documentation

◆ fragmentCoverageSkSL()

const char * skgpu::graphite::BitmapTextRenderStep::fragmentCoverageSkSL ( ) const
overridevirtual

Reimplemented from skgpu::graphite::RenderStep.

Definition at line 94 of file BitmapTextRenderStep.cpp.

94 {
95 // The returned SkSL must write its coverage into a 'half4 outputCoverage' variable (defined in
96 // the calling code) with the actual coverage splatted out into all four channels.
97 static_assert(kNumTextAtlasTextures == 4);
98 return "outputCoverage = bitmap_text_coverage_fn(sample_indexed_atlas(textureCoords, "
99 "int(texIndex), "
100 "text_atlas_0, "
101 "text_atlas_1, "
102 "text_atlas_2, "
103 "text_atlas_3), "
104 "int(maskFormat));";
105}

◆ texturesAndSamplersSkSL()

std::string skgpu::graphite::BitmapTextRenderStep::texturesAndSamplersSkSL ( const ResourceBindingRequirements bindingReqs,
int nextBindingIndex 
) const
overridevirtual

Reimplemented from skgpu::graphite::RenderStep.

Definition at line 82 of file BitmapTextRenderStep.cpp.

83 {
84 std::string result;
85
86 for (unsigned int i = 0; i < kNumTextAtlasTextures; ++i) {
87 result += EmitSamplerLayout(bindingReqs, nextBindingIndex);
88 SkSL::String::appendf(&result, " sampler2D text_atlas_%u;\n", i);
89 }
90
91 return result;
92}
GAsyncResult * result
std::string void appendf(std::string *str, const char *fmt,...) SK_PRINTF_LIKE(2
Definition: SkSLString.cpp:92
std::string EmitSamplerLayout(const ResourceBindingRequirements &bindingReqs, int *binding)

◆ vertexSkSL()

std::string skgpu::graphite::BitmapTextRenderStep::vertexSkSL ( ) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 62 of file BitmapTextRenderStep.cpp.

62 {
63 // Returns the body of a vertex function, which must define a float4 devPosition variable and
64 // must write to an already-defined float2 stepLocalCoords variable.
65 return "texIndex = half(indexAndFlags.x);"
66 "maskFormat = half(indexAndFlags.y);"
67 "float2 unormTexCoords;"
68 "float4 devPosition = text_vertex_fn(float2(sk_VertexID >> 1, sk_VertexID & 1), "
69 "subRunDeviceMatrix, "
70 "deviceToLocal, "
71 "atlasSizeInv, "
72 "float2(size), "
73 "float2(uvPos), "
74 "xyPos, "
75 "strikeToSourceScale, "
76 "depth, "
77 "textureCoords, "
78 "unormTexCoords, "
79 "stepLocalCoords);";
80}

◆ writeUniformsAndTextures()

void skgpu::graphite::BitmapTextRenderStep::writeUniformsAndTextures ( const DrawParams params,
PipelineDataGatherer gatherer 
) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 121 of file BitmapTextRenderStep.cpp.

122 {
123 SkDEBUGCODE(UniformExpectationsValidator uev(gatherer, this->uniforms());)
124
125 const SubRunData& subRunData = params.geometry().subRunData();
126 unsigned int numProxies;
127 Recorder* recorder = subRunData.recorder();
128 const sk_sp<TextureProxy>* proxies =
130 subRunData.subRun()->maskFormat(), &numProxies);
131 SkASSERT(proxies && numProxies > 0);
132
133 // write uniforms
134 gatherer->write(params.transform().matrix()); // subRunDeviceMatrix
135 gatherer->write(subRunData.deviceToLocal());
136 SkV2 atlasDimensionsInverse = {1.f/proxies[0]->dimensions().width(),
137 1.f/proxies[0]->dimensions().height()};
138 gatherer->write(atlasDimensionsInverse);
139
140 // write textures and samplers
141 const SkSamplingOptions kSamplingOptions(SkFilterMode::kNearest);
142 constexpr SkTileMode kTileModes[2] = { SkTileMode::kClamp, SkTileMode::kClamp };
143 for (unsigned int i = 0; i < numProxies; ++i) {
144 gatherer->add(proxies[i], {kSamplingOptions, kTileModes});
145 }
146 // If the atlas has less than 4 active proxies we still need to set up samplers for the shader.
147 for (unsigned int i = numProxies; i < kNumTextAtlasTextures; ++i) {
148 gatherer->add(proxies[0], {kSamplingOptions, kTileModes});
149 }
150}
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
SkTileMode
Definition: SkTileMode.h:13
TextAtlasManager * textAtlasManager() const
Definition: AtlasProvider.h:53
AtlasProvider * atlasProvider()
Definition: RecorderPriv.h:61
SkSpan< const Uniform > uniforms() const
Definition: Renderer.h:143
const sk_sp< TextureProxy > * getProxies(MaskFormat format, unsigned int *numActiveProxies)
const EmbeddedViewParams * params
Definition: SkM44.h:19

◆ writeVertices()

void skgpu::graphite::BitmapTextRenderStep::writeVertices ( DrawWriter dw,
const DrawParams params,
skvx::ushort2  ssboIndices 
) const
overridevirtual

Implements skgpu::graphite::RenderStep.

Definition at line 107 of file BitmapTextRenderStep.cpp.

109 {
110 const SubRunData& subRunData = params.geometry().subRunData();
111
112 subRunData.subRun()->vertexFiller().fillInstanceData(dw,
113 subRunData.startGlyphIndex(),
114 subRunData.glyphCount(),
115 subRunData.subRun()->instanceFlags(),
116 ssboIndices,
117 subRunData.subRun()->glyphs(),
118 params.order().depthAsFloat());
119}

The documentation for this class was generated from the following files: