aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/effects/GrBitmapTextGeoProc.cpp
diff options
context:
space:
mode:
authorGravatar Jim Van Verth <jvanverth@google.com>2017-09-07 14:48:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-08 14:17:53 +0000
commit7f754260f7fc2ae0326a072dd2f0429e584f8ca0 (patch)
tree7df7a94cdf828e3832723c6756c3faceab82d9ca /src/gpu/effects/GrBitmapTextGeoProc.cpp
parent7231c50f9c21cb13f428efe2a3bdbcf29543799a (diff)
Add multitexture support to text and path shaders
This does not add additional textures to the atlases, just adds the ability to access those textures in the shaders. Bug: skia:3550 Change-Id: I636b329a6f748b6753f5f92a70066fb412623df2 Reviewed-on: https://skia-review.googlesource.com/43000 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/gpu/effects/GrBitmapTextGeoProc.cpp')
-rw-r--r--src/gpu/effects/GrBitmapTextGeoProc.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp
index c2cf8ebc22..fab0904a4f 100644
--- a/src/gpu/effects/GrBitmapTextGeoProc.cpp
+++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp
@@ -7,6 +7,7 @@
#include "GrBitmapTextGeoProc.h"
+#include "GrAtlasedShaderHelpers.h"
#include "GrTexture.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
#include "glsl/GrGLSLGeometryProcessor.h"
@@ -36,12 +37,11 @@ public:
"AtlasSizeInv",
&atlasSizeInvName);
- GrGLSLVertToFrag v(kVec2f_GrSLType);
- varyingHandler->addVarying("TextureCoords", &v, kHigh_GrSLPrecision);
- vertBuilder->codeAppendf("%s = float2(%s.x, %s.y) * %s;", v.vsOut(),
- btgp.inTextureCoords()->fName,
- btgp.inTextureCoords()->fName,
- atlasSizeInvName);
+ GrGLSLVertToFrag uv(kVec2f_GrSLType);
+ GrGLSLVertToFrag st(kVec2f_GrSLType);
+ GrGLSLVertToFrag texIdx(kFloat_GrSLType);
+ append_index_uv_varyings(args, btgp.inTextureCoords()->fName, atlasSizeInvName,
+ &uv, &st, &texIdx);
GrGLSLPPFragmentBuilder* fragBuilder = args.fFragBuilder;
// Setup pass through color
@@ -64,18 +64,16 @@ public:
btgp.localMatrix(),
args.fFPCoordTransformHandler);
+ fragBuilder->codeAppend("float4 texColor;");
+ append_multitexture_lookup(args, btgp.numTextureSamplers(),
+ texIdx, uv.fsIn(), "texColor");
+
if (btgp.maskFormat() == kARGB_GrMaskFormat) {
- fragBuilder->codeAppendf("%s = ", args.fOutputColor);
- fragBuilder->appendTextureLookupAndModulate(args.fOutputColor,
- args.fTexSamplers[0],
- v.fsIn(),
- kVec2f_GrSLType);
- fragBuilder->codeAppend(";");
+ // modulate by color
+ fragBuilder->codeAppendf("%s = %s * texColor;", args.fOutputColor, args.fOutputColor);
fragBuilder->codeAppendf("%s = float4(1);", args.fOutputCoverage);
} else {
- fragBuilder->codeAppendf("%s = ", args.fOutputCoverage);
- fragBuilder->appendTextureLookup(args.fTexSamplers[0], v.fsIn(), kVec2f_GrSLType);
- fragBuilder->codeAppend(";");
+ fragBuilder->codeAppendf("%s = texColor;", args.fOutputCoverage);
}
}
@@ -89,7 +87,7 @@ public:
fColor = btgp.color();
}
- SkASSERT(btgp.numTextureSamplers() == 1);
+ SkASSERT(btgp.numTextureSamplers() >= 1);
GrTexture* atlas = btgp.textureSampler(0).peekTexture();
SkASSERT(atlas && SkIsPow2(atlas->width()) && SkIsPow2(atlas->height()));
@@ -108,6 +106,7 @@ public:
key |= (btgp.usesLocalCoords() && btgp.localMatrix().hasPerspective()) ? 0x1 : 0x0;
key |= btgp.maskFormat() << 1;
b->add32(key);
+ b->add32(btgp.numTextureSamplers());
}
private: