Flutter Engine
The Flutter Engine
GrGeometryProcessor.h
Go to the documentation of this file.
1/*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrGeometryProcessor_DEFINED
9#define GrGeometryProcessor_DEFINED
10
12#include "src/gpu/Swizzle.h"
22
23#include <unordered_map>
24
29
30/**
31 * The GrGeometryProcessor represents some kind of geometric primitive. This includes the shape
32 * of the primitive and the inherent color of the primitive. The GrGeometryProcessor is
33 * responsible for providing a color and coverage input into the Ganesh rendering pipeline. Through
34 * optimization, Ganesh may decide a different color, no color, and / or no coverage are required
35 * from the GrGeometryProcessor, so the GrGeometryProcessor must be able to support this
36 * functionality.
37 *
38 * There are two feedback loops between the GrFragmentProcessors, the GrXferProcessor, and the
39 * GrGeometryProcessor. These loops run on the CPU and to determine known properties of the final
40 * color and coverage inputs to the GrXferProcessor in order to perform optimizations that preserve
41 * correctness. The GrDrawOp seeds these loops with initial color and coverage, in its
42 * getProcessorAnalysisInputs implementation. These seed values are processed by the
43 * subsequent stages of the rendering pipeline and the output is then fed back into the GrDrawOp
44 * in the applyPipelineOptimizations call, where the op can use the information to inform
45 * decisions about GrGeometryProcessor creation.
46 *
47 * Note that all derived classes should hide their constructors and provide a Make factory
48 * function that takes an arena (except for Tesselation-specific classes). This is because
49 * geometry processors can be created in either the record-time or flush-time arenas which
50 * define their lifetimes (i.e., a DDLs life time in the first case and a single flush in
51 * the second case).
52 */
54public:
55 /**
56 * Every GrGeometryProcessor must be capable of creating a subclass of ProgramImpl. The
57 * ProgramImpl emits the shader code that implements the GrGeometryProcessor, is attached to the
58 * generated backend API pipeline/program and used to extract uniform data from
59 * GrGeometryProcessor instances.
60 */
61 class ProgramImpl;
62
63 class TextureSampler;
64
65 /** Describes a vertex or instance attribute. */
66 class Attribute {
67 public:
68 static constexpr size_t AlignOffset(size_t offset) { return SkAlign4(offset); }
69
70 constexpr Attribute() = default;
71 /**
72 * Makes an attribute whose offset will be implicitly determined by the types and ordering
73 * of an array attributes.
74 */
75 constexpr Attribute(const char* name,
78 : fName(name), fCPUType(cpuType), fGPUType(gpuType) {
80 }
81 /**
82 * Makes an attribute with an explicit offset.
83 */
84 constexpr Attribute(const char* name,
87 size_t offset)
88 : fName(name), fCPUType(cpuType), fGPUType(gpuType), fOffset(SkToU32(offset)) {
91 }
92 constexpr Attribute(const Attribute&) = default;
93
94 Attribute& operator=(const Attribute&) = default;
95
96 constexpr bool isInitialized() const { return fGPUType != SkSLType::kVoid; }
97
98 constexpr const char* name() const { return fName; }
99 constexpr GrVertexAttribType cpuType() const { return fCPUType; }
100 constexpr SkSLType gpuType() const { return fGPUType; }
101 /**
102 * Returns the offset if attributes were specified with explicit offsets. Otherwise,
103 * offsets (and total vertex stride) are implicitly determined from attribute order and
104 * types.
105 */
106 std::optional<size_t> offset() const {
107 if (fOffset != kImplicitOffset) {
108 SkASSERT(AlignOffset(fOffset) == fOffset);
109 return {fOffset};
110 }
111 return std::nullopt;
112 }
113
114 inline constexpr size_t size() const;
115
117 return {fName, fGPUType, GrShaderVar::TypeModifier::In};
118 }
119
120 private:
121 static constexpr uint32_t kImplicitOffset = 1; // 1 is not valid because it isn't aligned.
122
123 const char* fName = nullptr;
125 SkSLType fGPUType = SkSLType::kVoid;
126 uint32_t fOffset = kImplicitOffset;
127 };
128
129 /**
130 * A set of attributes that can iterated. The iterator handles hides two pieces of complexity:
131 * 1) It skips uninitialized attributes.
132 * 2) It always returns an attribute with a known offset.
133 */
135 class Iter {
136 public:
137 Iter() = default;
138 Iter(const Iter& iter) = default;
139 Iter& operator=(const Iter& iter) = default;
140
141 Iter(const Attribute* attrs, int count) : fCurr(attrs), fRemaining(count) {
142 this->skipUninitialized();
143 }
144
145 bool operator!=(const Iter& that) const { return fCurr != that.fCurr; }
146 Attribute operator*() const;
147 void operator++();
148
149 private:
150 void skipUninitialized();
151
152 const Attribute* fCurr = nullptr;
153 int fRemaining = 0;
154 size_t fImplicitOffset = 0;
155 };
156
157 public:
158 Iter begin() const;
159 Iter end() const;
160
161 int count() const { return fCount; }
162 size_t stride() const { return fStride; }
163
164 // Init with implicit offsets and stride. No attributes can have a predetermined stride.
165 void initImplicit(const Attribute* attrs, int count);
166 // Init with explicit offsets and stride. All attributes must be initialized and have
167 // an explicit offset aligned to 4 bytes and with no attribute crossing stride boundaries.
168 void initExplicit(const Attribute* attrs, int count, size_t stride);
169
170 void addToKey(skgpu::KeyBuilder* b) const;
171
172 private:
173 const Attribute* fAttributes = nullptr;
174 int fRawCount = 0;
175 int fCount = 0;
176 size_t fStride = 0;
177 };
178
180
181 int numTextureSamplers() const { return fTextureSamplerCnt; }
182 const TextureSampler& textureSampler(int index) const;
183 int numVertexAttributes() const { return fVertexAttributes.count(); }
184 const AttributeSet& vertexAttributes() const { return fVertexAttributes; }
185 int numInstanceAttributes() const { return fInstanceAttributes.count(); }
186 const AttributeSet& instanceAttributes() const { return fInstanceAttributes; }
187
188 bool hasVertexAttributes() const { return SkToBool(fVertexAttributes.count()); }
189 bool hasInstanceAttributes() const { return SkToBool(fInstanceAttributes.count()); }
190
191 /**
192 * A common practice is to populate the the vertex/instance's memory using an implicit array of
193 * structs. In this case, it is best to assert that:
194 * stride == sizeof(struct)
195 */
196 size_t vertexStride() const { return fVertexAttributes.stride(); }
197 size_t instanceStride() const { return fInstanceAttributes.stride(); }
198
199 /**
200 * Computes a key for the transforms owned by an FP based on the shader code that will be
201 * emitted by the primitive processor to implement them.
202 */
203 static uint32_t ComputeCoordTransformsKey(const GrFragmentProcessor& fp);
204
205 inline static constexpr int kCoordTransformKeyBits = 4;
206
207 /**
208 * Adds a key on the skgpu::KeyBuilder that reflects any variety in the code that the
209 * geometry processor subclass can emit.
210 */
211 virtual void addToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const = 0;
212
214
215 /**
216 * Returns a new instance of the appropriate implementation class for the given
217 * GrGeometryProcessor.
218 */
219 virtual std::unique_ptr<ProgramImpl> makeProgramImpl(const GrShaderCaps&) const = 0;
220
221protected:
222 // GPs that need to use either float or ubyte colors can just call this to get a correctly
223 // configured Attribute struct
224 static Attribute MakeColorAttribute(const char* name, bool wideColor) {
225 return { name,
228 }
229 void setVertexAttributes(const Attribute* attrs, int attrCount, size_t stride) {
230 fVertexAttributes.initExplicit(attrs, attrCount, stride);
231 }
232 void setInstanceAttributes(const Attribute* attrs, int attrCount, size_t stride) {
233 SkASSERT(attrCount >= 0);
234 fInstanceAttributes.initExplicit(attrs, attrCount, stride);
235 }
236
237 void setVertexAttributesWithImplicitOffsets(const Attribute* attrs, int attrCount) {
238 fVertexAttributes.initImplicit(attrs, attrCount);
239 }
240 void setInstanceAttributesWithImplicitOffsets(const Attribute* attrs, int attrCount) {
241 SkASSERT(attrCount >= 0);
242 fInstanceAttributes.initImplicit(attrs, attrCount);
243 }
244 void setTextureSamplerCnt(int cnt) {
245 SkASSERT(cnt >= 0);
246 fTextureSamplerCnt = cnt;
247 }
248
249private:
250 virtual const TextureSampler& onTextureSampler(int) const { SK_ABORT("no texture samplers"); }
251
252 AttributeSet fVertexAttributes;
253 AttributeSet fInstanceAttributes;
254
255 int fTextureSamplerCnt = 0;
256 using INHERITED = GrProcessor;
257};
258
259//////////////////////////////////////////////////////////////////////////////
260
262public:
263 using UniformHandle = GrGLSLProgramDataManager::UniformHandle;
264 using SamplerHandle = GrGLSLUniformHandler::SamplerHandle;
265 /**
266 * Struct of optional varying that replaces the input coords and bool indicating whether the FP
267 * should take a coord param as an argument. The latter may be false if the coords are simply
268 * unused or if the GP has lifted their computation to a varying emitted by the VS.
269 */
271 using FPCoordsMap = std::unordered_map<const GrFragmentProcessor*, FPCoords>;
272
273 virtual ~ProgramImpl() = default;
274
275 struct EmitArgs {
277 GrGLSLFPFragmentBuilder* fragBuilder,
278 GrGLSLVaryingHandler* varyingHandler,
279 GrGLSLUniformHandler* uniformHandler,
280 const GrShaderCaps* caps,
281 const GrGeometryProcessor& geomProc,
282 const char* outputColor,
283 const char* outputCoverage,
284 const SamplerHandle* texSamplers)
285 : fVertBuilder(vertBuilder)
286 , fFragBuilder(fragBuilder)
287 , fVaryingHandler(varyingHandler)
288 , fUniformHandler(uniformHandler)
289 , fShaderCaps(caps)
290 , fGeomProc(geomProc)
291 , fOutputColor(outputColor)
292 , fOutputCoverage(outputCoverage)
293 , fTexSamplers(texSamplers) {}
300 const char* fOutputColor;
301 const char* fOutputCoverage;
303 };
304
305 /**
306 * Emits the code from this geometry processor into the shaders. For any FP in the pipeline that
307 * has its input coords implemented by the GP as a varying, the varying will be accessible in
308 * the returned map and should be used when the FP code is emitted. The FS variable containing
309 * the GP's output local coords is also returned.
310 **/
311 std::tuple<FPCoordsMap, GrShaderVar> emitCode(EmitArgs&, const GrPipeline& pipeline);
312
313 /**
314 * Called after all effect emitCode() functions, to give the processor a chance to write out
315 * additional transformation code now that all uniforms have been emitted.
316 * It generates the final code for assigning transformed coordinates to the varyings recorded
317 * in the call to collectTransforms(). This must happen after FP code emission so that it has
318 * access to any uniforms the FPs registered for uniform sample matrix invocations.
319 */
321
322 /**
323 * A ProgramImpl instance can be reused with any GrGeometryProcessor that produces the same key.
324 * This function reads data from a GrGeometryProcessor and updates any uniform variables
325 * required by the shaders created in emitCode(). The GrGeometryProcessor parameter is
326 * guaranteed to be of the same type and to have an identical processor key as the
327 * GrGeometryProcessor that created this ProgramImpl.
328 */
330 const GrShaderCaps&,
331 const GrGeometryProcessor&) = 0;
332
333 // GPs that use writeOutputPosition and/or writeLocalCoord must incorporate the matrix type
334 // into their key, and should use this function or one of the other related helpers.
335 static uint32_t ComputeMatrixKey(const GrShaderCaps& caps, const SkMatrix& mat) {
336 if (!caps.fReducedShaderMode) {
337 if (mat.isIdentity()) {
338 return 0b00;
339 }
340 if (mat.isScaleTranslate()) {
341 return 0b01;
342 }
343 }
344 if (!mat.hasPerspective()) {
345 return 0b10;
346 }
347 return 0b11;
348 }
349
350 static uint32_t ComputeMatrixKeys(const GrShaderCaps& shaderCaps,
351 const SkMatrix& viewMatrix,
352 const SkMatrix& localMatrix) {
353 return (ComputeMatrixKey(shaderCaps, viewMatrix) << kMatrixKeyBits) |
354 ComputeMatrixKey(shaderCaps, localMatrix);
355 }
356
357 static uint32_t AddMatrixKeys(const GrShaderCaps& shaderCaps,
358 uint32_t flags,
359 const SkMatrix& viewMatrix,
360 const SkMatrix& localMatrix) {
361 // Shifting to make room for the matrix keys shouldn't lose bits
362 SkASSERT(((flags << (2 * kMatrixKeyBits)) >> (2 * kMatrixKeyBits)) == flags);
363 return (flags << (2 * kMatrixKeyBits)) |
364 ComputeMatrixKeys(shaderCaps, viewMatrix, localMatrix);
365 }
366 inline static constexpr int kMatrixKeyBits = 2;
367
368protected:
370 GrGLSLUniformHandler* uniformHandler,
371 const char* outputName,
372 UniformHandle* colorUniform);
373
374 // A helper for setting the matrix on a uniform handle initialized through
375 // writeOutputPosition or writeLocalCoord. Automatically handles elided uniforms,
376 // scale+translate matrices, and state tracking (if provided state pointer is non-null).
377 static void SetTransform(const GrGLSLProgramDataManager&,
378 const GrShaderCaps&,
379 const UniformHandle& uniform,
380 const SkMatrix& matrix,
381 SkMatrix* state = nullptr);
382
383 struct GrGPArgs {
384 // Used to specify the output variable used by the GP to store its device position. It can
385 // either be a float2 or a float3 (in order to handle perspective). The subclass sets this
386 // in its onEmitCode().
388 // Used to specify the variable storing the draw's local coordinates. It can be either a
389 // float2, float3, or void. It can only be void when no FP needs local coordinates. This
390 // variable can be an attribute or local variable, but should not itself be a varying.
391 // ProgramImpl automatically determines if this must be passed to a FS.
393 // The GP can specify the local coord var either in the VS or FS. When either is possible
394 // the VS is preferable. It may allow derived coordinates to be interpolated from the VS
395 // instead of computed in the FS per pixel.
397 };
398
399 // Helpers for adding code to write the transformed vertex position. The first simple version
400 // just writes a variable named by 'posName' into the position output variable with the
401 // assumption that the position is 2D. The second version transforms the input position by a
402 // view matrix and the output variable is 2D or 3D depending on whether the view matrix is
403 // perspective. Both versions declare the output position variable and will set
404 // GrGPArgs::fPositionVar.
405 static void WriteOutputPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
408 const GrShaderCaps&,
409 GrGPArgs*,
410 const char* posName,
411 const SkMatrix& viewMatrix,
412 UniformHandle* viewMatrixUniform);
413
414 // Helper to transform an existing variable by a given local matrix (e.g. the inverse view
415 // matrix). It will declare the transformed local coord variable and will set
416 // GrGPArgs::fLocalCoordVar.
419 const GrShaderCaps&,
420 GrGPArgs*,
421 GrShaderVar localVar,
422 const SkMatrix& localMatrix,
423 UniformHandle* localMatrixUniform);
424
425private:
426 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
427
428 // Iterates over the FPs beginning with the passed iter to register additional varyings and
429 // uniforms to support VS-promoted local coord evaluation for the FPs.
430 //
431 // This must happen before FP code emission so that the FPs can find the appropriate varying
432 // handles they use in place of explicit coord sampling; it is automatically called after
433 // onEmitCode() returns using the value stored in GpArgs::fLocalCoordVar and
434 // GpArgs::fPositionVar.
435 FPCoordsMap collectTransforms(GrGLSLVertexBuilder* vb,
436 GrGLSLVaryingHandler* varyingHandler,
437 GrGLSLUniformHandler* uniformHandler,
438 GrShaderType localCoordsShader,
439 const GrShaderVar& localCoordsVar,
440 const GrShaderVar& positionVar,
441 const GrPipeline& pipeline);
442 struct TransformInfo {
443 // The varying that conveys the coordinates to one or more FPs in the FS.
444 GrGLSLVarying varying;
445 // The coordinate to be transformed. varying is computed from this.
446 GrShaderVar inputCoords;
447 // Used to sort so that ancestor FP varyings are initialized before descendant FP varyings.
448 int traversalOrder;
449 };
450 // Populated by collectTransforms() for use in emitTransformCode(). When we lift the computation
451 // of a FP's input coord to a varying we propagate that varying up the FP tree to the highest
452 // node that shares the same coordinates. This allows multiple FPs in a subtree to share a
453 // varying.
454 std::unordered_map<const GrFragmentProcessor*, TransformInfo> fTransformVaryingsMap;
455
456 // Move back into collectTransforms when /std=c++20 can be used with msvc.
457 enum class BaseCoord { kNone, kLocal, kPosition };
458};
459
460///////////////////////////////////////////////////////////////////////////
461
462/**
463 * Used to capture the properties of the GrTextureProxies required/expected by a primitiveProcessor
464 * along with an associated GrSamplerState. The actual proxies used are stored in either the
465 * fixed or dynamic state arrays. TextureSamplers don't perform any coord manipulation to account
466 * for texture origin.
467 */
469public:
470 TextureSampler() = default;
471
473
476
479
481
482 const GrBackendFormat& backendFormat() const { return fBackendFormat; }
483 GrTextureType textureType() const { return fBackendFormat.textureType(); }
484
485 GrSamplerState samplerState() const { return fSamplerState; }
486 const skgpu::Swizzle& swizzle() const { return fSwizzle; }
487
488 bool isInitialized() const { return fIsInitialized; }
489
490private:
491 GrSamplerState fSamplerState;
492 GrBackendFormat fBackendFormat;
493 skgpu::Swizzle fSwizzle;
494 bool fIsInitialized = false;
495};
496
497//////////////////////////////////////////////////////////////////////////////
498
499/**
500 * Returns the size of the attrib type in bytes.
501 * This was moved from include/private/gpu/ganesh/GrTypesPriv.h in service of Skia dependents that build
502 * with C++11.
503 */
504static constexpr inline size_t GrVertexAttribTypeSize(GrVertexAttribType type) {
505 switch (type) {
507 return sizeof(float);
509 return 2 * sizeof(float);
511 return 3 * sizeof(float);
513 return 4 * sizeof(float);
515 return sizeof(uint16_t);
517 return 2 * sizeof(uint16_t);
519 return 4 * sizeof(uint16_t);
521 return 2 * sizeof(int32_t);
523 return 3 * sizeof(int32_t);
525 return 4 * sizeof(int32_t);
527 return 1 * sizeof(char);
529 return 2 * sizeof(char);
531 return 4 * sizeof(char);
533 return 1 * sizeof(char);
535 return 2 * sizeof(char);
537 return 4 * sizeof(char);
539 return 1 * sizeof(char);
541 return 4 * sizeof(char);
543 return 2 * sizeof(int16_t);
545 return 4 * sizeof(int16_t);
546 case kUShort2_GrVertexAttribType: // fall through
548 return 2 * sizeof(uint16_t);
550 return sizeof(int32_t);
552 return sizeof(uint32_t);
554 return sizeof(uint16_t);
556 return 4 * sizeof(uint16_t);
557 }
558 // GCC fails because SK_ABORT evaluates to non constexpr. clang and cl.exe think this is
559 // unreachable and don't complain.
560#if defined(__clang__) || !defined(__GNUC__)
561 SK_ABORT("Unsupported type conversion");
562#endif
563 return 0;
564}
565
566constexpr size_t GrGeometryProcessor::Attribute::size() const {
567 return GrVertexAttribTypeSize(fCPUType);
568}
569
570#endif
static constexpr size_t GrVertexAttribTypeSize(GrVertexAttribType type)
GrShaderType
Definition: GrTypesPriv.h:276
@ kVertex_GrShaderType
Definition: GrTypesPriv.h:277
GrTextureType
Definition: GrTypesPriv.h:268
GrVertexAttribType
Definition: GrTypesPriv.h:312
@ kUShort_norm_GrVertexAttribType
Definition: GrTypesPriv.h:346
@ kFloat2_GrVertexAttribType
Definition: GrTypesPriv.h:314
@ kUShort2_GrVertexAttribType
Definition: GrTypesPriv.h:340
@ kUInt_GrVertexAttribType
Definition: GrTypesPriv.h:344
@ kUByte4_norm_GrVertexAttribType
Definition: GrTypesPriv.h:334
@ kUByte_GrVertexAttribType
Definition: GrTypesPriv.h:329
@ kShort2_GrVertexAttribType
Definition: GrTypesPriv.h:337
@ kUShort4_norm_GrVertexAttribType
Definition: GrTypesPriv.h:348
@ kInt_GrVertexAttribType
Definition: GrTypesPriv.h:343
@ kByte_GrVertexAttribType
Definition: GrTypesPriv.h:326
@ kByte4_GrVertexAttribType
Definition: GrTypesPriv.h:328
@ kFloat3_GrVertexAttribType
Definition: GrTypesPriv.h:315
@ kFloat_GrVertexAttribType
Definition: GrTypesPriv.h:313
@ kByte2_GrVertexAttribType
Definition: GrTypesPriv.h:327
@ kFloat4_GrVertexAttribType
Definition: GrTypesPriv.h:316
@ kShort4_GrVertexAttribType
Definition: GrTypesPriv.h:338
@ kUShort2_norm_GrVertexAttribType
Definition: GrTypesPriv.h:341
@ kInt3_GrVertexAttribType
Definition: GrTypesPriv.h:322
@ kHalf2_GrVertexAttribType
Definition: GrTypesPriv.h:318
@ kHalf4_GrVertexAttribType
Definition: GrTypesPriv.h:319
@ kUByte4_GrVertexAttribType
Definition: GrTypesPriv.h:331
@ kUByte2_GrVertexAttribType
Definition: GrTypesPriv.h:330
@ kInt4_GrVertexAttribType
Definition: GrTypesPriv.h:323
@ kUByte_norm_GrVertexAttribType
Definition: GrTypesPriv.h:333
@ kInt2_GrVertexAttribType
Definition: GrTypesPriv.h:321
@ kHalf_GrVertexAttribType
Definition: GrTypesPriv.h:317
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkSLType
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
GLenum type
GrTextureType textureType() const
void initImplicit(const Attribute *attrs, int count)
void addToKey(skgpu::KeyBuilder *b) const
void initExplicit(const Attribute *attrs, int count, size_t stride)
constexpr Attribute(const Attribute &)=default
std::optional< size_t > offset() const
constexpr GrVertexAttribType cpuType() const
static constexpr size_t AlignOffset(size_t offset)
constexpr bool isInitialized() const
Attribute & operator=(const Attribute &)=default
constexpr const char * name() const
constexpr size_t size() const
constexpr SkSLType gpuType() const
constexpr Attribute(const char *name, GrVertexAttribType cpuType, SkSLType gpuType)
constexpr Attribute()=default
constexpr Attribute(const char *name, GrVertexAttribType cpuType, SkSLType gpuType, size_t offset)
GrGLSLUniformHandler::SamplerHandle SamplerHandle
void emitTransformCode(GrGLSLVertexBuilder *vb, GrGLSLUniformHandler *uniformHandler)
static uint32_t ComputeMatrixKeys(const GrShaderCaps &shaderCaps, const SkMatrix &viewMatrix, const SkMatrix &localMatrix)
void setupUniformColor(GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLUniformHandler *uniformHandler, const char *outputName, UniformHandle *colorUniform)
virtual void onEmitCode(EmitArgs &, GrGPArgs *)=0
static void WriteOutputPosition(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, const char *posName, const SkMatrix &viewMatrix, UniformHandle *viewMatrixUniform)
GrGLSLProgramDataManager::UniformHandle UniformHandle
static uint32_t AddMatrixKeys(const GrShaderCaps &shaderCaps, uint32_t flags, const SkMatrix &viewMatrix, const SkMatrix &localMatrix)
static void WriteOutputPosition(GrGLSLVertexBuilder *, GrGPArgs *, const char *posName)
std::tuple< FPCoordsMap, GrShaderVar > emitCode(EmitArgs &, const GrPipeline &pipeline)
std::unordered_map< const GrFragmentProcessor *, FPCoords > FPCoordsMap
virtual void setData(const GrGLSLProgramDataManager &, const GrShaderCaps &, const GrGeometryProcessor &)=0
static void WriteLocalCoord(GrGLSLVertexBuilder *, GrGLSLUniformHandler *, const GrShaderCaps &, GrGPArgs *, GrShaderVar localVar, const SkMatrix &localMatrix, UniformHandle *localMatrixUniform)
static uint32_t ComputeMatrixKey(const GrShaderCaps &caps, const SkMatrix &mat)
static void SetTransform(const GrGLSLProgramDataManager &, const GrShaderCaps &, const UniformHandle &uniform, const SkMatrix &matrix, SkMatrix *state=nullptr)
void reset(GrSamplerState, const GrBackendFormat &, const skgpu::Swizzle &)
TextureSampler & operator=(const TextureSampler &)=delete
TextureSampler(TextureSampler &&)=default
const GrBackendFormat & backendFormat() const
TextureSampler & operator=(TextureSampler &&)=default
TextureSampler(const TextureSampler &)=delete
const skgpu::Swizzle & swizzle() const
void setInstanceAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
virtual std::unique_ptr< ProgramImpl > makeProgramImpl(const GrShaderCaps &) const =0
const TextureSampler & textureSampler(int index) const
int numInstanceAttributes() const
void setVertexAttributes(const Attribute *attrs, int attrCount, size_t stride)
size_t vertexStride() const
static constexpr int kCoordTransformKeyBits
void setInstanceAttributes(const Attribute *attrs, int attrCount, size_t stride)
bool hasInstanceAttributes() const
const AttributeSet & vertexAttributes() const
void setTextureSamplerCnt(int cnt)
virtual const TextureSampler & onTextureSampler(int) const
const AttributeSet & instanceAttributes() const
virtual void addToKey(const GrShaderCaps &, skgpu::KeyBuilder *) const =0
static uint32_t ComputeCoordTransformsKey(const GrFragmentProcessor &fp)
void getAttributeKey(skgpu::KeyBuilder *b) const
size_t instanceStride() const
bool hasVertexAttributes() const
static Attribute MakeColorAttribute(const char *name, bool wideColor)
void setVertexAttributesWithImplicitOffsets(const Attribute *attrs, int attrCount)
GrProcessor(ClassID classID)
Definition: GrProcessor.h:132
GrProcessor & operator=(const GrProcessor &)=delete
virtual const char * name() const =0
bool isScaleTranslate() const
Definition: SkMatrix.h:236
bool hasPerspective() const
Definition: SkMatrix.h:312
bool isIdentity() const
Definition: SkMatrix.h:223
static bool b
AtkStateType state
FlutterSemanticsFlag flags
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
const uint32_t fp
bool operator!=(C p1, const scoped_nsprotocol< C > &p2)
constexpr Color operator*(T value, const Color &c)
Definition: color.h:911
EmitArgs(GrGLSLVertexBuilder *vertBuilder, GrGLSLFPFragmentBuilder *fragBuilder, GrGLSLVaryingHandler *varyingHandler, GrGLSLUniformHandler *uniformHandler, const GrShaderCaps *caps, const GrGeometryProcessor &geomProc, const char *outputColor, const char *outputCoverage, const SamplerHandle *texSamplers)
bool fReducedShaderMode
Definition: GrShaderCaps.h:46