39 ((
float)(
i->fTransposedInAtlas ? -
i->fLocationInAtlas.x() - 1
40 :
i->fLocationInAtlas.x() + 1)) <<
41 (
float)
i->fLocationInAtlas.y() <<
42 (
float)
i->fPathDevIBounds.left() <<
43 (
float)
i->fPathDevIBounds.top() <<
53 args.fVaryingHandler->addVarying(
"atlasCoord", &atlasCoord);
55 const char* atlasAdjustName;
56 *atlasAdjustUniformHandle =
args.fUniformHandler->addUniform(
59 args.fVertBuilder->codeAppendf(
62 "float2 atlasTopLeft = float2(abs(locations.x) - 1, locations.y);"
63 "float2 devTopLeft = locations.zw;"
64 "bool transposed = locations.x < 0;"
65 "float2 atlasCoord = %s - devTopLeft;"
67 "atlasCoord = atlasCoord.yx;"
69 "atlasCoord += atlasTopLeft;"
70 "%s = atlasCoord * %s;", devCoord.
c_str(), atlasCoord.
vsOut(), atlasAdjustName);
74 args.fVaryingHandler->addVarying(
"atlasbounds", &atlasBounds,
76 args.fVertBuilder->codeAppendf(R
"(
77 float4 atlasBounds = atlasTopLeft.xyxy + (transposed ? sizeInAtlas.00yx
79 %s = atlasBounds * %s.xyxy;)", atlasBounds.vsOut(), atlasAdjustName);
81 args.fFragBuilder->codeAppendf(
82 "half atlasCoverage = 0;"
83 "float2 atlasCoord = %s;"
84 "float4 atlasBounds = %s;"
85 "if (all(greaterThan(atlasCoord, atlasBounds.xy)) &&"
86 "all(lessThan(atlasCoord, atlasBounds.zw))) {"
87 "atlasCoverage = ", atlasCoord.
fsIn(), atlasBounds.
fsIn());
88 args.fFragBuilder->appendTextureLookup(
args.fTexSamplers[0],
"atlasCoord");
89 args.fFragBuilder->codeAppendf(R
"(.a;
92 args.fFragBuilder->codeAppendf(
"half atlasCoverage = ");
93 args.fFragBuilder->appendTextureLookup(
args.fTexSamplers[0], atlasCoord.
fsIn());
94 args.fFragBuilder->codeAppendf(
".a;");
98 args.fFragBuilder->codeAppendf(
"%s *= (1 - atlasCoverage);",
args.fOutputCoverage);
100 args.fFragBuilder->codeAppendf(
"%s *= atlasCoverage;",
args.fOutputCoverage);
109 pdman.
set2f(atlasAdjustUniformHandle, 1.f / dimensions.
width(), 1.f / dimensions.
height());
@ kFloat2_GrVertexAttribType
@ kFloat4_GrVertexAttribType
virtual void set2f(UniformHandle, float, float) const =0
const char * vsOut() const
const char * fsIn() const
const char * c_str() const
SkISize backingStoreDimensions() const
bool isInstantiated() const
static constexpr int kNumShaderFlags
void writeInstanceData(VertexWriter *instanceWriter, const Instance *) const
void appendInstanceAttribs(skia_private::TArray< GrGeometryProcessor::Attribute > *instanceAttribs) const
void injectShaderCode(const GrGeometryProcessor::ProgramImpl::EmitArgs &, const GrShaderVar &devCoord, GrGLSLUniformHandler::UniformHandle *atlasAdjustUniformHandle) const
void getKeyBits(KeyBuilder *b) const
void setUniformData(const GrGLSLProgramDataManager &, const GrGLSLUniformHandler::UniformHandle &atlasAdjustUniformHandle) const
T & emplace_back(Args &&... args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
constexpr int32_t width() const
constexpr int32_t height() const
static constexpr SkSize Make(SkScalar w, SkScalar h)
static Conditional< T > If(bool condition, const T &value)