Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 495 of file GrGeometryProcessor.cpp.

◆ AttributeSet

Definition at line 496 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)

◆ write_passthrough_vertex_position()

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

Definition at line 365 of file GrGeometryProcessor.cpp.

367 {
369 SkString outName = vertBuilder->newTmpVarName(inPos.getName().c_str());
370 outPos->set(inPos.getType(), outName.c_str());
371 vertBuilder->codeAppendf("float%d %s = %s;",
372 SkSLTypeVecLength(inPos.getType()),
373 outName.c_str(),
374 inPos.getName().c_str());
375}
#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 377 of file GrGeometryProcessor.cpp.

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