23 {
25
26
27
28
29 if (
args.fShaderCaps->fIntegerSupport) {
30 if (numTextureSamplers <= 1) {
31 args.fVertBuilder->codeAppendf(
32 "int texIdx = 0;"
33 "float2 unormTexCoords = float2(%s.x, %s.y);"
34 , inTexCoordsName, inTexCoordsName);
35 } else {
36 args.fVertBuilder->codeAppendf(
37 "int2 coords = int2(%s.x, %s.y);"
38 "int texIdx = coords.x >> 13;"
39 "float2 unormTexCoords = float2(coords.x & 0x1FFF, coords.y);"
40 , inTexCoordsName, inTexCoordsName);
41 }
42 } else {
43 if (numTextureSamplers <= 1) {
44 args.fVertBuilder->codeAppendf(
45 "float texIdx = 0;"
46 "float2 unormTexCoords = float2(%s.x, %s.y);"
47 , inTexCoordsName, inTexCoordsName);
48 } else {
49 args.fVertBuilder->codeAppendf(
50 "float2 coord = float2(%s.x, %s.y);"
51 "float texIdx = floor(coord.x * exp2(-13));"
52 "float2 unormTexCoords = float2(coord.x - texIdx * exp2(13), coord.y);"
53 , inTexCoordsName, inTexCoordsName);
54 }
55 }
56
57
59 args.fVaryingHandler->addVarying(
"TextureCoords", uv);
60 args.fVertBuilder->codeAppendf(
61 "%s = unormTexCoords * %s;", uv->
vsOut(), atlasDimensionsInvName);
62
63
64
66
67 const char*
cast =
args.fShaderCaps->fIntegerSupport ?
"float" :
"";
68 args.fVaryingHandler->addVarying(
"TexIndex", texIdx, Interpolation::kCanBeFlat);
69 args.fVertBuilder->codeAppendf(
"%s = %s(texIdx);", texIdx->
vsOut(),
cast);
70
71 if (st) {
73 args.fVaryingHandler->addVarying(
"IntTextureCoords", st);
74 args.fVertBuilder->codeAppendf(
"%s = unormTexCoords;", st->
vsOut());
75 }
76}
const char * vsOut() const
void reset(SkSLType type, Scope scope=Scope::kVertToFrag)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args