Flutter Engine
The Flutter Engine
Typedefs | Functions
GrGeometryProcessor.cpp File Reference
#include "src/gpu/ganesh/GrGeometryProcessor.h"
#include "src/core/SkMatrixPriv.h"
#include "src/gpu/KeyBuilder.h"
#include "src/gpu/ganesh/GrPipeline.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ganesh/glsl/GrGLSLProgramBuilder.h"
#include "src/gpu/ganesh/glsl/GrGLSLUniformHandler.h"
#include "src/gpu/ganesh/glsl/GrGLSLVarying.h"
#include <queue>

Go to the source code of this file.

Typedefs

using ProgramImpl = GrGeometryProcessor::ProgramImpl
 
using Attribute = GrGeometryProcessor::Attribute
 
using AttributeSet = GrGeometryProcessor::AttributeSet
 

Functions

static GrSamplerState::Filter clamp_filter (GrTextureType type, GrSamplerState::Filter requestedFilter)
 
static void write_passthrough_vertex_position (GrGLSLVertexBuilder *vertBuilder, const GrShaderVar &inPos, GrShaderVar *outPos)
 
static void write_vertex_position (GrGLSLVertexBuilder *vertBuilder, GrGLSLUniformHandler *uniformHandler, const GrShaderCaps &shaderCaps, const GrShaderVar &inPos, const SkMatrix &matrix, const char *matrixName, GrShaderVar *outPos, ProgramImpl::UniformHandle *matrixUniform)
 

Typedef Documentation

◆ Attribute

Definition at line 493 of file GrGeometryProcessor.cpp.

◆ AttributeSet

Definition at line 494 of file GrGeometryProcessor.cpp.

◆ ProgramImpl

Definition at line 75 of file GrGeometryProcessor.cpp.

Function Documentation

◆ clamp_filter()

static GrSamplerState::Filter clamp_filter ( GrTextureType  type,
GrSamplerState::Filter  requestedFilter 
)
inlinestatic

Definition at line 46 of file GrGeometryProcessor.cpp.

47 {
49 return std::min(requestedFilter, GrSamplerState::Filter::kLinear);
50 }
51 return requestedFilter;
52}
static bool GrTextureTypeHasRestrictedSampling(GrTextureType type)
Definition: GrTypesPriv.h:294
GLenum type
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ write_passthrough_vertex_position()

static void write_passthrough_vertex_position ( GrGLSLVertexBuilder vertBuilder,
const GrShaderVar inPos,
GrShaderVar outPos 
)
static

Definition at line 363 of file GrGeometryProcessor.cpp.

365 {
367 SkString outName = vertBuilder->newTmpVarName(inPos.getName().c_str());
368 outPos->set(inPos.getType(), outName.c_str());
369 vertBuilder->codeAppendf("float%d %s = %s;",
370 SkSLTypeVecLength(inPos.getType()),
371 outName.c_str(),
372 inPos.getName().c_str());
373}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static constexpr int SkSLTypeVecLength(SkSLType type)
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
SkString newTmpVarName(const char *suffix)
SkSLType getType() const
Definition: GrShaderVar.h:97
void set(SkSLType type, const char *name)
Definition: GrShaderVar.h:78
const SkString & getName() const
Definition: GrShaderVar.h:91
const char * c_str() const
Definition: SkString.h:133

◆ write_vertex_position()

static void write_vertex_position ( GrGLSLVertexBuilder vertBuilder,
GrGLSLUniformHandler uniformHandler,
const GrShaderCaps shaderCaps,
const GrShaderVar inPos,
const SkMatrix matrix,
const char *  matrixName,
GrShaderVar outPos,
ProgramImpl::UniformHandle matrixUniform 
)
static

Definition at line 375 of file GrGeometryProcessor.cpp.

382 {
384 SkString outName = vertBuilder->newTmpVarName(inPos.getName().c_str());
385
386 if (matrix.isIdentity() && !shaderCaps.fReducedShaderMode) {
387 write_passthrough_vertex_position(vertBuilder, inPos, outPos);
388 return;
389 }
390 SkASSERT(matrixUniform);
391
392 bool useCompactTransform = matrix.isScaleTranslate() && !shaderCaps.fReducedShaderMode;
393 const char* mangledMatrixName;
394 *matrixUniform = uniformHandler->addUniform(nullptr,
396 useCompactTransform ? SkSLType::kFloat4
398 matrixName,
399 &mangledMatrixName);
400
401 if (inPos.getType() == SkSLType::kFloat3) {
402 // A float3 stays a float3 whether or not the matrix adds perspective
403 if (useCompactTransform) {
404 vertBuilder->codeAppendf("float3 %s = %s.xz1 * %s + %s.yw0;\n",
405 outName.c_str(),
406 mangledMatrixName,
407 inPos.getName().c_str(),
408 mangledMatrixName);
409 } else {
410 vertBuilder->codeAppendf("float3 %s = %s * %s;\n",
411 outName.c_str(),
412 mangledMatrixName,
413 inPos.getName().c_str());
414 }
415 outPos->set(SkSLType::kFloat3, outName.c_str());
416 return;
417 }
418 if (matrix.hasPerspective()) {
419 // A float2 is promoted to a float3 if we add perspective via the matrix
420 SkASSERT(!useCompactTransform);
421 vertBuilder->codeAppendf("float3 %s = (%s * %s.xy1);",
422 outName.c_str(),
423 mangledMatrixName,
424 inPos.getName().c_str());
425 outPos->set(SkSLType::kFloat3, outName.c_str());
426 return;
427 }
428 if (useCompactTransform) {
429 vertBuilder->codeAppendf("float2 %s = %s.xz * %s + %s.yw;\n",
430 outName.c_str(),
431 mangledMatrixName,
432 inPos.getName().c_str(),
433 mangledMatrixName);
434 } else if (shaderCaps.fNonsquareMatrixSupport) {
435 vertBuilder->codeAppendf("float2 %s = float3x2(%s) * %s.xy1;\n",
436 outName.c_str(),
437 mangledMatrixName,
438 inPos.getName().c_str());
439 } else {
440 vertBuilder->codeAppendf("float2 %s = (%s * %s.xy1).xy;\n",
441 outName.c_str(),
442 mangledMatrixName,
443 inPos.getName().c_str());
444 }
445 outPos->set(SkSLType::kFloat2, outName.c_str());
446}
static void write_passthrough_vertex_position(GrGLSLVertexBuilder *vertBuilder, const GrShaderVar &inPos, GrShaderVar *outPos)
@ kVertex_GrShaderFlag
Definition: GrTypesPriv.h:286
UniformHandle addUniform(const GrProcessor *owner, uint32_t visibility, SkSLType type, const char *name, const char **outName=nullptr)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
bool fReducedShaderMode
Definition: GrShaderCaps.h:46
bool fNonsquareMatrixSupport
Definition: SkSLUtil.h:90