Create GLSLUniformHandler class for gpu backend
BUG=skia: Review URL: https://codereview.chromium.org/1490283004
This commit is contained in:
parent
73063dc517
commit
7ea439b220
@ -22,8 +22,8 @@
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#endif
|
||||
|
||||
static const int kBlockSize = 256;
|
||||
@ -758,19 +758,20 @@ GrGLPerlinNoise2::GrGLPerlinNoise2(const GrProcessor& processor)
|
||||
|
||||
void GrGLPerlinNoise2::emitCode(EmitArgs& args) {
|
||||
GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
|
||||
fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fBaseFrequencyUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"baseFrequency");
|
||||
const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
|
||||
const char* baseFrequencyUni = uniformHandler->getUniformCStr(fBaseFrequencyUni);
|
||||
|
||||
const char* stitchDataUni = nullptr;
|
||||
if (fStitchTiles) {
|
||||
fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fStitchDataUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"stitchData");
|
||||
stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni);
|
||||
stitchDataUni = uniformHandler->getUniformCStr(fStitchDataUni);
|
||||
}
|
||||
|
||||
// There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8
|
||||
@ -1171,22 +1172,23 @@ GrGLImprovedPerlinNoise::GrGLImprovedPerlinNoise(const GrProcessor& processor)
|
||||
|
||||
void GrGLImprovedPerlinNoise::emitCode(EmitArgs& args) {
|
||||
GrGLSLFragmentBuilder* fsBuilder = args.fFragBuilder;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
SkString vCoords = fsBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
|
||||
fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fBaseFrequencyUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"baseFrequency");
|
||||
const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
|
||||
const char* baseFrequencyUni = uniformHandler->getUniformCStr(fBaseFrequencyUni);
|
||||
|
||||
fOctavesUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fOctavesUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"octaves");
|
||||
const char* octavesUni = args.fBuilder->getUniformCStr(fOctavesUni);
|
||||
const char* octavesUni = uniformHandler->getUniformCStr(fOctavesUni);
|
||||
|
||||
fZUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fZUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"z");
|
||||
const char* zUni = args.fBuilder->getUniformCStr(fZUni);
|
||||
const char* zUni = uniformHandler->getUniformCStr(fZUni);
|
||||
|
||||
// fade function
|
||||
static const GrGLSLShaderVar fadeArgs[] = {
|
||||
|
@ -340,6 +340,8 @@
|
||||
'<(skia_src_path)/gpu/gl/GrGLTransferBuffer.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLUtil.cpp',
|
||||
'<(skia_src_path)/gpu/gl/GrGLUtil.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLUniformHandler.cpp',
|
||||
'<(skia_src_path)/gpu/gl/GrGLUniformHandler.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLVaryingHandler.cpp',
|
||||
'<(skia_src_path)/gpu/gl/GrGLVaryingHandler.h',
|
||||
'<(skia_src_path)/gpu/gl/GrGLVertexArray.cpp',
|
||||
@ -380,6 +382,7 @@
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLShaderBuilder.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLShaderVar.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLTextureSampler.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLUniformHandler.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLUtil.cpp',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLUtil.h',
|
||||
'<(skia_src_path)/gpu/glsl/GrGLSLVarying.cpp',
|
||||
|
@ -129,11 +129,12 @@ private:
|
||||
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTextureAccess.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "SkGr.h"
|
||||
#include "SkGrPriv.h"
|
||||
|
||||
@ -180,25 +181,26 @@ public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// add uniforms
|
||||
const char* lightDirUniName = nullptr;
|
||||
fLightDirUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fLightDirUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"LightDir", &lightDirUniName);
|
||||
|
||||
const char* lightColorUniName = nullptr;
|
||||
fLightColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fLightColorUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"LightColor", &lightColorUniName);
|
||||
|
||||
const char* ambientColorUniName = nullptr;
|
||||
fAmbientColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fAmbientColorUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"AmbientColor", &ambientColorUniName);
|
||||
|
||||
const char* xformUniName = nullptr;
|
||||
fXformUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fXformUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Xform", &xformUniName);
|
||||
|
||||
|
@ -11,12 +11,13 @@
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "GrContext.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTextureProvider.h"
|
||||
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class GrGLCircleBlurFragmentProcessor : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
@ -40,7 +41,7 @@ void GrGLCircleBlurFragmentProcessor::emitCode(EmitArgs& args) {
|
||||
// x,y - the center of the circle
|
||||
// z - the distance at which the intensity starts falling off (e.g., the start of the table)
|
||||
// w - the size of the profile texture
|
||||
fDataUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDataUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"data",
|
||||
|
@ -59,8 +59,8 @@ SkImageFilter* SkAlphaThresholdFilter::Create(const SkRegion& region,
|
||||
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class AlphaThresholdEffect : public GrFragmentProcessor {
|
||||
|
||||
@ -139,10 +139,11 @@ private:
|
||||
};
|
||||
|
||||
void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
|
||||
fInnerThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fInnerThresholdVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"inner_threshold");
|
||||
fOuterThresholdVar = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fOuterThresholdVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"outer_threshold");
|
||||
|
||||
@ -160,9 +161,9 @@ void GrGLAlphaThresholdEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend(";\n");
|
||||
|
||||
fragBuilder->codeAppendf("\t\tfloat inner_thresh = %s;\n",
|
||||
args.fBuilder->getUniformCStr(fInnerThresholdVar));
|
||||
uniformHandler->getUniformCStr(fInnerThresholdVar));
|
||||
fragBuilder->codeAppendf("\t\tfloat outer_thresh = %s;\n",
|
||||
args.fBuilder->getUniformCStr(fOuterThresholdVar));
|
||||
uniformHandler->getUniformCStr(fOuterThresholdVar));
|
||||
fragBuilder->codeAppend("\t\tfloat mask = mask_color.a;\n");
|
||||
|
||||
fragBuilder->codeAppend("vec4 color = input_color;\n");
|
||||
|
@ -15,8 +15,8 @@
|
||||
#include "GrTexture.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
static const bool gUseUnpremul = false;
|
||||
@ -65,10 +65,10 @@ public:
|
||||
SkString dstColor("dstColor");
|
||||
this->emitChild(0, nullptr, &dstColor, args);
|
||||
|
||||
fKUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"k");
|
||||
const char* kUni = args.fBuilder->getUniformCStr(fKUni);
|
||||
const char* kUni = args.fUniformHandler->getUniformCStr(fKUni);
|
||||
|
||||
add_arithmetic_code(fragBuilder,
|
||||
args.fInputColor,
|
||||
@ -210,18 +210,18 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
|
||||
GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const char* srcColor,
|
||||
const char* srcCoverage,
|
||||
const char* dstColor,
|
||||
const char* outColor,
|
||||
const char* outColorSecondary,
|
||||
const GrXferProcessor& proc) override {
|
||||
fKUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"k");
|
||||
const char* kUni = pb->getUniformCStr(fKUni);
|
||||
const char* kUni = uniformHandler->getUniformCStr(fKUni);
|
||||
|
||||
add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor);
|
||||
|
||||
|
@ -29,9 +29,9 @@
|
||||
#include "effects/GrSimpleTextureEffect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLTextureSampler.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#endif
|
||||
|
||||
SkScalar SkBlurMaskFilter::ConvertRadiusToSigma(SkScalar radius) {
|
||||
@ -720,17 +720,18 @@ void GrGLRectBlurEffect::GenKey(GrSLPrecision precision, GrProcessorKeyBuilder*
|
||||
|
||||
|
||||
void GrGLRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
const char *rectName;
|
||||
const char *profileSizeName;
|
||||
|
||||
const char* precisionString = GrGLSLShaderVar::PrecisionString(args.fGLSLCaps, fPrecision);
|
||||
fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
fPrecision,
|
||||
"proxyRect",
|
||||
&rectName);
|
||||
fProfileSizeUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fProfileSizeUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"profileSize",
|
||||
@ -1063,20 +1064,21 @@ void GrGLRRectBlurEffect::emitCode(EmitArgs& args) {
|
||||
const char *cornerRadiusName;
|
||||
const char *blurRadiusName;
|
||||
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
// The proxy rect has left, top, right, and bottom edges correspond to
|
||||
// components x, y, z, and w, respectively.
|
||||
|
||||
fProxyRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fProxyRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"proxyRect",
|
||||
&rectName);
|
||||
fCornerRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCornerRadiusUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"cornerRadius",
|
||||
&cornerRadiusName);
|
||||
fBlurRadiusUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fBlurRadiusUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"blurRadius",
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "SkGr.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -246,14 +246,15 @@ void GrColorCubeEffect::GLSLProcessor::emitCode(EmitArgs& args) {
|
||||
args.fInputColor = "vec4(1)";
|
||||
}
|
||||
|
||||
fColorCubeSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fColorCubeSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Size");
|
||||
const char* colorCubeSizeUni = args.fBuilder->getUniformCStr(fColorCubeSizeUni);
|
||||
fColorCubeInvSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
const char* colorCubeSizeUni = uniformHandler->getUniformCStr(fColorCubeSizeUni);
|
||||
fColorCubeInvSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"InvSize");
|
||||
const char* colorCubeInvSizeUni = args.fBuilder->getUniformCStr(fColorCubeInvSizeUni);
|
||||
const char* colorCubeInvSizeUni = uniformHandler->getUniformCStr(fColorCubeInvSizeUni);
|
||||
|
||||
const char* nonZeroAlpha = "nonZeroAlpha";
|
||||
const char* unPMColor = "unPMColor";
|
||||
|
@ -387,8 +387,8 @@ SkColorFilter* SkColorMatrixFilter::newComposed(const SkColorFilter* innerFilter
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class ColorMatrixEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
@ -408,10 +408,11 @@ public:
|
||||
GLSLProcessor(const GrProcessor&) {}
|
||||
|
||||
virtual void emitCode(EmitArgs& args) override {
|
||||
fMatrixHandle = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fMatrixHandle = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kMat44f_GrSLType, kDefault_GrSLPrecision,
|
||||
"ColorMatrix");
|
||||
fVectorHandle = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fVectorHandle = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"ColorMatrixVector");
|
||||
|
||||
@ -426,9 +427,9 @@ public:
|
||||
args.fInputColor);
|
||||
fragBuilder->codeAppendf("\t%s = %s * vec4(%s.rgb / nonZeroAlpha, nonZeroAlpha) + %s;\n",
|
||||
args.fOutputColor,
|
||||
args.fBuilder->getUniformCStr(fMatrixHandle),
|
||||
uniformHandler->getUniformCStr(fMatrixHandle),
|
||||
args.fInputColor,
|
||||
args.fBuilder->getUniformCStr(fVectorHandle));
|
||||
uniformHandler->getUniformCStr(fVectorHandle));
|
||||
fragBuilder->codeAppendf("\t%s = clamp(%s, 0.0, 1.0);\n",
|
||||
args.fOutputColor, args.fOutputColor);
|
||||
fragBuilder->codeAppendf("\t%s.rgb *= %s.a;\n", args.fOutputColor, args.fOutputColor);
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "effects/GrTextureDomain.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -549,9 +549,9 @@ GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
|
||||
void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
|
||||
const GrTextureDomain& domain = args.fFp.cast<GrDisplacementMapEffect>().domain();
|
||||
|
||||
fScaleUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fScaleUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision, "Scale");
|
||||
const char* scaleUni = args.fBuilder->getUniformCStr(fScaleUni);
|
||||
const char* scaleUni = args.fUniformHandler->getUniformCStr(fScaleUni);
|
||||
const char* dColor = "dColor";
|
||||
const char* cCoords = "cCoords";
|
||||
const char* nearZero = "1e-6"; // Since 6.10352e−5 is the smallest half float, use
|
||||
@ -610,6 +610,7 @@ void GrGLDisplacementMapEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend("-vec2(0.5));\t\t");
|
||||
|
||||
fGLDomain.sampleTexture(fragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
domain,
|
||||
args.fOutputColor,
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class GrGLDiffuseLightingEffect;
|
||||
class GrGLSpecularLightingEffect;
|
||||
@ -599,7 +599,7 @@ public:
|
||||
* This is called by GrGLLightingEffect::emitCode() before either of the two virtual functions
|
||||
* below. It adds a vec3f uniform visible in the FS that represents the constant light color.
|
||||
*/
|
||||
void emitLightColorUniform(GrGLSLFPBuilder*);
|
||||
void emitLightColorUniform(GrGLSLUniformHandler*);
|
||||
|
||||
/**
|
||||
* These two functions are called from GrGLLightingEffect's emitCode() function.
|
||||
@ -609,8 +609,10 @@ public:
|
||||
* the FS. The default of emitLightColor appends the name of the constant light color uniform
|
||||
* and so this function only needs to be overridden if the light color varies spatially.
|
||||
*/
|
||||
virtual void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) = 0;
|
||||
virtual void emitLightColor(GrGLSLFPBuilder*,
|
||||
virtual void emitSurfaceToLight(GrGLSLUniformHandler*,
|
||||
GrGLSLFragmentBuilder*,
|
||||
const char* z) = 0;
|
||||
virtual void emitLightColor(GrGLSLUniformHandler*,
|
||||
GrGLSLFragmentBuilder*,
|
||||
const char *surfaceToLight);
|
||||
|
||||
@ -637,7 +639,7 @@ class GrGLDistantLight : public GrGLLight {
|
||||
public:
|
||||
virtual ~GrGLDistantLight() {}
|
||||
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
|
||||
void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) override;
|
||||
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
|
||||
|
||||
private:
|
||||
typedef GrGLLight INHERITED;
|
||||
@ -650,7 +652,7 @@ class GrGLPointLight : public GrGLLight {
|
||||
public:
|
||||
virtual ~GrGLPointLight() {}
|
||||
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
|
||||
void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) override;
|
||||
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
|
||||
|
||||
private:
|
||||
typedef GrGLLight INHERITED;
|
||||
@ -663,8 +665,8 @@ class GrGLSpotLight : public GrGLLight {
|
||||
public:
|
||||
virtual ~GrGLSpotLight() {}
|
||||
void setData(const GrGLSLProgramDataManager&, const SkImageFilterLight* light) const override;
|
||||
void emitSurfaceToLight(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, const char* z) override;
|
||||
void emitLightColor(GrGLSLFPBuilder*,
|
||||
void emitSurfaceToLight(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, const char* z) override;
|
||||
void emitLightColor(GrGLSLUniformHandler*,
|
||||
GrGLSLFragmentBuilder*,
|
||||
const char *surfaceToLight) override;
|
||||
|
||||
@ -1528,7 +1530,9 @@ protected:
|
||||
*/
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
|
||||
virtual void emitLightFunc(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, SkString* funcName) = 0;
|
||||
virtual void emitLightFunc(GrGLSLUniformHandler*,
|
||||
GrGLSLFragmentBuilder*,
|
||||
SkString* funcName) = 0;
|
||||
|
||||
private:
|
||||
typedef GrGLSLFragmentProcessor INHERITED;
|
||||
@ -1544,7 +1548,7 @@ private:
|
||||
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLDiffuseLightingEffect(const GrProcessor&);
|
||||
void emitLightFunc(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, SkString* funcName) override;
|
||||
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, SkString* funcName) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
@ -1560,7 +1564,7 @@ private:
|
||||
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLSpecularLightingEffect(const GrProcessor&);
|
||||
void emitLightFunc(GrGLSLFPBuilder*, GrGLSLFragmentBuilder*, SkString* funcName) override;
|
||||
void emitLightFunc(GrGLSLUniformHandler*, GrGLSLFragmentBuilder*, SkString* funcName) override;
|
||||
|
||||
protected:
|
||||
void onSetData(const GrGLSLProgramDataManager&, const GrProcessor&) override;
|
||||
@ -1657,16 +1661,17 @@ GrGLLightingEffect::~GrGLLightingEffect() {
|
||||
}
|
||||
|
||||
void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"ImageIncrement");
|
||||
fSurfaceScaleUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fSurfaceScaleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"SurfaceScale");
|
||||
fLight->emitLightColorUniform(args.fBuilder);
|
||||
fLight->emitLightColorUniform(uniformHandler);
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString lightFunc;
|
||||
this->emitLightFunc(args.fBuilder, fragBuilder, &lightFunc);
|
||||
this->emitLightFunc(uniformHandler, fragBuilder, &lightFunc);
|
||||
static const GrGLSLShaderVar gSobelArgs[] = {
|
||||
GrGLSLShaderVar("a", kFloat_GrSLType),
|
||||
GrGLSLShaderVar("b", kFloat_GrSLType),
|
||||
@ -1716,8 +1721,8 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppend("\t\tfloat m[9];\n");
|
||||
|
||||
const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni);
|
||||
const char* surfScale = args.fBuilder->getUniformCStr(fSurfaceScaleUni);
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
const char* surfScale = uniformHandler->getUniformCStr(fSurfaceScaleUni);
|
||||
|
||||
int index = 0;
|
||||
for (int dy = 1; dy >= -1; dy--) {
|
||||
@ -1732,11 +1737,11 @@ void GrGLLightingEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppend("\t\tvec3 surfaceToLight = ");
|
||||
SkString arg;
|
||||
arg.appendf("%s * m[4]", surfScale);
|
||||
fLight->emitSurfaceToLight(args.fBuilder, fragBuilder, arg.c_str());
|
||||
fLight->emitSurfaceToLight(uniformHandler, fragBuilder, arg.c_str());
|
||||
fragBuilder->codeAppend(";\n");
|
||||
fragBuilder->codeAppendf("\t\t%s = %s(%s(m, %s), surfaceToLight, ",
|
||||
args.fOutputColor, lightFunc.c_str(), normalName.c_str(), surfScale);
|
||||
fLight->emitLightColor(args.fBuilder, fragBuilder, "surfaceToLight");
|
||||
fLight->emitLightColor(uniformHandler, fragBuilder, "surfaceToLight");
|
||||
fragBuilder->codeAppend(");\n");
|
||||
SkString modulate;
|
||||
GrGLSLMulVarBy4f(&modulate, args.fOutputColor, args.fInputColor);
|
||||
@ -1769,11 +1774,11 @@ GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrProcessor& proc)
|
||||
: INHERITED(proc) {
|
||||
}
|
||||
|
||||
void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder,
|
||||
void GrGLDiffuseLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
SkString* funcName) {
|
||||
const char* kd;
|
||||
fKDUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKDUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"KD", &kd);
|
||||
|
||||
@ -1853,15 +1858,15 @@ GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrProcessor& proc)
|
||||
: INHERITED(proc) {
|
||||
}
|
||||
|
||||
void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLFPBuilder* builder,
|
||||
void GrGLSpecularLightingEffect::emitLightFunc(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
SkString* funcName) {
|
||||
const char* ks;
|
||||
const char* shininess;
|
||||
|
||||
fKSUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKSUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision, "KS", &ks);
|
||||
fShininessUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fShininessUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Shininess",
|
||||
@ -1894,16 +1899,16 @@ void GrGLSpecularLightingEffect::onSetData(const GrGLSLProgramDataManager& pdman
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void GrGLLight::emitLightColorUniform(GrGLSLFPBuilder* builder) {
|
||||
fColorUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
void GrGLLight::emitLightColorUniform(GrGLSLUniformHandler* uniformHandler) {
|
||||
fColorUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"LightColor");
|
||||
}
|
||||
|
||||
void GrGLLight::emitLightColor(GrGLSLFPBuilder* builder,
|
||||
void GrGLLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
const char *surfaceToLight) {
|
||||
fragBuilder->codeAppend(builder->getUniformCStr(this->lightColorUni()));
|
||||
fragBuilder->codeAppend(uniformHandler->getUniformCStr(this->lightColorUni()));
|
||||
}
|
||||
|
||||
void GrGLLight::setData(const GrGLSLProgramDataManager& pdman,
|
||||
@ -1922,11 +1927,11 @@ void GrGLDistantLight::setData(const GrGLSLProgramDataManager& pdman,
|
||||
setUniformNormal3(pdman, fDirectionUni, distantLight->direction());
|
||||
}
|
||||
|
||||
void GrGLDistantLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
|
||||
void GrGLDistantLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
const char* z) {
|
||||
const char* dir;
|
||||
fDirectionUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDirectionUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"LightDirection", &dir);
|
||||
fragBuilder->codeAppend(dir);
|
||||
@ -1942,11 +1947,11 @@ void GrGLPointLight::setData(const GrGLSLProgramDataManager& pdman,
|
||||
setUniformPoint3(pdman, fLocationUni, pointLight->location());
|
||||
}
|
||||
|
||||
void GrGLPointLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
|
||||
void GrGLPointLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
const char* z) {
|
||||
const char* loc;
|
||||
fLocationUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fLocationUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"LightLocation", &loc);
|
||||
fragBuilder->codeAppendf("normalize(%s - vec3(%s.xy, %s))",
|
||||
@ -1968,11 +1973,11 @@ void GrGLSpotLight::setData(const GrGLSLProgramDataManager& pdman,
|
||||
setUniformNormal3(pdman, fSUni, spotLight->s());
|
||||
}
|
||||
|
||||
void GrGLSpotLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
|
||||
void GrGLSpotLight::emitSurfaceToLight(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
const char* z) {
|
||||
const char* location;
|
||||
fLocationUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fLocationUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"LightLocation", &location);
|
||||
|
||||
@ -1980,30 +1985,30 @@ void GrGLSpotLight::emitSurfaceToLight(GrGLSLFPBuilder* builder,
|
||||
location, fragBuilder->fragmentPosition(), z);
|
||||
}
|
||||
|
||||
void GrGLSpotLight::emitLightColor(GrGLSLFPBuilder* builder,
|
||||
void GrGLSpotLight::emitLightColor(GrGLSLUniformHandler* uniformHandler,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
const char *surfaceToLight) {
|
||||
|
||||
const char* color = builder->getUniformCStr(this->lightColorUni()); // created by parent class.
|
||||
const char* color = uniformHandler->getUniformCStr(this->lightColorUni()); // created by parent class.
|
||||
|
||||
const char* exponent;
|
||||
const char* cosInner;
|
||||
const char* cosOuter;
|
||||
const char* coneScale;
|
||||
const char* s;
|
||||
fExponentUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fExponentUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Exponent", &exponent);
|
||||
fCosInnerConeAngleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCosInnerConeAngleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"CosInnerConeAngle", &cosInner);
|
||||
fCosOuterConeAngleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCosOuterConeAngleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"CosOuterConeAngle", &cosOuter);
|
||||
fConeScaleUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fConeScaleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"ConeScale", &coneScale);
|
||||
fSUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fSUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision, "S", &s);
|
||||
|
||||
static const GrGLSLShaderVar gLightColorArgs[] = {
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#endif
|
||||
|
||||
void SkLumaColorFilter::filterSpan(const SkPMColor src[], int count,
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "effects/GrSingleTextureEffect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class GrMagnifierEffect : public GrSingleTextureEffect {
|
||||
|
||||
@ -120,31 +120,32 @@ GrGLMagnifierEffect::GrGLMagnifierEffect(const GrProcessor&) {
|
||||
}
|
||||
|
||||
void GrGLMagnifierEffect::emitCode(EmitArgs& args) {
|
||||
fOffsetVar = args.fBuilder->addUniform(
|
||||
GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision, "Offset");
|
||||
fInvZoomVar = args.fBuilder->addUniform(
|
||||
GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision, "InvZoom");
|
||||
fInvInsetVar = args.fBuilder->addUniform(
|
||||
GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision, "InvInset");
|
||||
fBoundsVar = args.fBuilder->addUniform(
|
||||
GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision, "Bounds");
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fOffsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Offset");
|
||||
fInvZoomVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"InvZoom");
|
||||
fInvInsetVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"InvInset");
|
||||
fBoundsVar = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Bounds");
|
||||
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
fragBuilder->codeAppendf("\t\tvec2 coord = %s;\n", coords2D.c_str());
|
||||
fragBuilder->codeAppendf("\t\tvec2 zoom_coord = %s + %s * %s;\n",
|
||||
args.fBuilder->getUniformCStr(fOffsetVar),
|
||||
uniformHandler->getUniformCStr(fOffsetVar),
|
||||
coords2D.c_str(),
|
||||
args.fBuilder->getUniformCStr(fInvZoomVar));
|
||||
const char* bounds = args.fBuilder->getUniformCStr(fBoundsVar);
|
||||
uniformHandler->getUniformCStr(fInvZoomVar));
|
||||
const char* bounds = uniformHandler->getUniformCStr(fBoundsVar);
|
||||
fragBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
|
||||
fragBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n");
|
||||
fragBuilder->codeAppendf("\t\tdelta = delta * %s;\n",
|
||||
args.fBuilder->getUniformCStr(fInvInsetVar));
|
||||
uniformHandler->getUniformCStr(fInvInsetVar));
|
||||
|
||||
fragBuilder->codeAppend("\t\tfloat weight = 0.0;\n");
|
||||
fragBuilder->codeAppend("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include "effects/Gr1DKernelEffect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#endif
|
||||
|
||||
SkMorphologyImageFilter::SkMorphologyImageFilter(int radiusX,
|
||||
@ -288,14 +288,15 @@ GrGLMorphologyEffect::GrGLMorphologyEffect(const GrProcessor& proc) {
|
||||
}
|
||||
|
||||
void GrGLMorphologyEffect::emitCode(EmitArgs& args) {
|
||||
fPixelSizeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fPixelSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"PixelSize");
|
||||
const char* pixelSizeInc = args.fBuilder->getUniformCStr(fPixelSizeUni);
|
||||
fRangeUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
const char* pixelSizeInc = uniformHandler->getUniformCStr(fPixelSizeUni);
|
||||
fRangeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Range");
|
||||
const char* range = args.fBuilder->getUniformCStr(fRangeUni);
|
||||
const char* range = uniformHandler->getUniformCStr(fRangeUni);
|
||||
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#endif
|
||||
|
||||
static const int kBlockSize = 256;
|
||||
@ -621,19 +621,20 @@ GrGLPerlinNoise::GrGLPerlinNoise(const GrProcessor& processor)
|
||||
|
||||
void GrGLPerlinNoise::emitCode(EmitArgs& args) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
SkString vCoords = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
|
||||
fBaseFrequencyUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fBaseFrequencyUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"baseFrequency");
|
||||
const char* baseFrequencyUni = args.fBuilder->getUniformCStr(fBaseFrequencyUni);
|
||||
const char* baseFrequencyUni = uniformHandler->getUniformCStr(fBaseFrequencyUni);
|
||||
|
||||
const char* stitchDataUni = nullptr;
|
||||
if (fStitchTiles) {
|
||||
fStitchDataUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fStitchDataUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"stitchData");
|
||||
stitchDataUni = args.fBuilder->getUniformCStr(fStitchDataUni);
|
||||
stitchDataUni = uniformHandler->getUniformCStr(fStitchDataUni);
|
||||
}
|
||||
|
||||
// There are 4 lines, so the center of each line is 1/8, 3/8, 5/8 and 7/8
|
||||
|
@ -337,8 +337,8 @@ SkColorFilter* SkTable_ColorFilter::newComposed(const SkColorFilter* innerFilter
|
||||
#include "effects/GrTextureStripAtlas.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class ColorTableEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
@ -415,7 +415,7 @@ void GLColorTableEffect::onSetData(const GrGLSLProgramDataManager& pdm, const Gr
|
||||
|
||||
void GLColorTableEffect::emitCode(EmitArgs& args) {
|
||||
const char* yoffsets;
|
||||
fRGBAYValuesUni = args.fBuilder->addUniform(GrGLSLFPBuilder::kFragment_Visibility,
|
||||
fRGBAYValuesUni = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"yoffsets", &yoffsets);
|
||||
static const float kColorScaleFactor = 255.0f / 256.0f;
|
||||
|
@ -910,8 +910,8 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
GrGLGradientEffect::GrGLGradientEffect()
|
||||
@ -920,29 +920,30 @@ GrGLGradientEffect::GrGLGradientEffect()
|
||||
|
||||
GrGLGradientEffect::~GrGLGradientEffect() { }
|
||||
|
||||
void GrGLGradientEffect::emitUniforms(GrGLSLFPBuilder* builder, const GrGradientEffect& ge) {
|
||||
void GrGLGradientEffect::emitUniforms(GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGradientEffect& ge) {
|
||||
|
||||
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()) { // 2 Color case
|
||||
fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorStartUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"GradientStartColor");
|
||||
fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorEndUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"GradientEndColor");
|
||||
|
||||
} else if (SkGradientShaderBase::kThree_GpuColorType == ge.getColorType()) { // 3 Color Case
|
||||
fColorStartUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorStartUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"GradientStartColor");
|
||||
fColorMidUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorMidUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"GradientMidColor");
|
||||
fColorEndUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorEndUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"GradientEndColor");
|
||||
|
||||
} else { // if not a fast case
|
||||
fFSYUni = builder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fFSYUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"GradientYCoordFS");
|
||||
}
|
||||
@ -1026,8 +1027,8 @@ uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrProcessor& processor) {
|
||||
return key;
|
||||
}
|
||||
|
||||
void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
void GrGLGradientEffect::emitColor(GrGLSLFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* glslCaps,
|
||||
const GrGradientEffect& ge,
|
||||
const char* gradientTValue,
|
||||
@ -1036,8 +1037,8 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
|
||||
const TextureSamplerArray& samplers) {
|
||||
if (SkGradientShaderBase::kTwo_GpuColorType == ge.getColorType()){
|
||||
fragBuilder->codeAppendf("\tvec4 colorTemp = mix(%s, %s, clamp(%s, 0.0, 1.0));\n",
|
||||
builder->getUniformVariable(fColorStartUni).c_str(),
|
||||
builder->getUniformVariable(fColorEndUni).c_str(),
|
||||
uniformHandler->getUniformVariable(fColorStartUni).c_str(),
|
||||
uniformHandler->getUniformVariable(fColorEndUni).c_str(),
|
||||
gradientTValue);
|
||||
// Note that we could skip this step if both colors are known to be opaque. Two
|
||||
// considerations:
|
||||
@ -1055,20 +1056,20 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
|
||||
fragBuilder->codeAppendf("\tfloat oneMinus2t = 1.0 - (2.0 * (%s));\n",
|
||||
gradientTValue);
|
||||
fragBuilder->codeAppendf("\tvec4 colorTemp = clamp(oneMinus2t, 0.0, 1.0) * %s;\n",
|
||||
builder->getUniformVariable(fColorStartUni).c_str());
|
||||
uniformHandler->getUniformVariable(fColorStartUni).c_str());
|
||||
if (!glslCaps->canUseMinAndAbsTogether()) {
|
||||
// The Tegra3 compiler will sometimes never return if we have
|
||||
// min(abs(oneMinus2t), 1.0), or do the abs first in a separate expression.
|
||||
fragBuilder->codeAppend("\tfloat minAbs = abs(oneMinus2t);\n");
|
||||
fragBuilder->codeAppend("\tminAbs = minAbs > 1.0 ? 1.0 : minAbs;\n");
|
||||
fragBuilder->codeAppendf("\tcolorTemp += (1.0 - minAbs) * %s;\n",
|
||||
builder->getUniformVariable(fColorMidUni).c_str());
|
||||
uniformHandler->getUniformVariable(fColorMidUni).c_str());
|
||||
} else {
|
||||
fragBuilder->codeAppendf("\tcolorTemp += (1.0 - min(abs(oneMinus2t), 1.0)) * %s;\n",
|
||||
builder->getUniformVariable(fColorMidUni).c_str());
|
||||
uniformHandler->getUniformVariable(fColorMidUni).c_str());
|
||||
}
|
||||
fragBuilder->codeAppendf("\tcolorTemp += clamp(-oneMinus2t, 0.0, 1.0) * %s;\n",
|
||||
builder->getUniformVariable(fColorEndUni).c_str());
|
||||
uniformHandler->getUniformVariable(fColorEndUni).c_str());
|
||||
if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) {
|
||||
fragBuilder->codeAppend("\tcolorTemp.rgb *= colorTemp.a;\n");
|
||||
}
|
||||
@ -1078,7 +1079,7 @@ void GrGLGradientEffect::emitColor(GrGLSLFPBuilder* builder,
|
||||
} else {
|
||||
fragBuilder->codeAppendf("\tvec2 coord = vec2(%s, %s);\n",
|
||||
gradientTValue,
|
||||
builder->getUniformVariable(fFSYUni).c_str());
|
||||
uniformHandler->getUniformVariable(fFSYUni).c_str());
|
||||
fragBuilder->codeAppendf("\t%s = ", outputColor);
|
||||
fragBuilder->appendTextureLookupAndModulate(inputColor,
|
||||
samplers[0],
|
||||
|
@ -419,14 +419,14 @@ protected:
|
||||
|
||||
// Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
|
||||
// should call this method from their emitCode().
|
||||
void emitUniforms(GrGLSLFPBuilder* builder, const GrGradientEffect&);
|
||||
void emitUniforms(GrGLSLUniformHandler*, const GrGradientEffect&);
|
||||
|
||||
|
||||
// emit code that gets a fragment's color from an expression for t; Has branches for 3 separate
|
||||
// control flows inside -- 2 color gradients, 3 color symmetric gradients (both using
|
||||
// native GLSL mix), and 4+ color gradients that use the traditional texture lookup.
|
||||
void emitColor(GrGLSLFPBuilder* builder,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
void emitColor(GrGLSLFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* caps,
|
||||
const GrGradientEffect&,
|
||||
const char* gradientTValue,
|
||||
|
@ -516,7 +516,8 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "SkGr.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
@ -604,11 +605,11 @@ const GrFragmentProcessor* GrLinearGradient::TestCreate(GrProcessorTestData* d)
|
||||
|
||||
void GrGLLinearGradient::emitCode(EmitArgs& args) {
|
||||
const GrLinearGradient& ge = args.fFp.cast<GrLinearGradient>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
this->emitUniforms(args.fUniformHandler, ge);
|
||||
SkString t = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
t.append(".x");
|
||||
this->emitColor(args.fBuilder,
|
||||
args.fFragBuilder,
|
||||
this->emitColor(args.fFragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge, t.c_str(),
|
||||
args.fOutputColor,
|
||||
|
@ -415,7 +415,8 @@ void SkRadialGradient::RadialGradientContext::shadeSpan(int x, int y,
|
||||
#if SK_SUPPORT_GPU
|
||||
|
||||
#include "SkGr.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
|
||||
class GrGLRadialGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
@ -499,12 +500,12 @@ const GrFragmentProcessor* GrRadialGradient::TestCreate(GrProcessorTestData* d)
|
||||
|
||||
void GrGLRadialGradient::emitCode(EmitArgs& args) {
|
||||
const GrRadialGradient& ge = args.fFp.cast<GrRadialGradient>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
this->emitUniforms(args.fUniformHandler, ge);
|
||||
SkString t("length(");
|
||||
t.append(args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0));
|
||||
t.append(")");
|
||||
this->emitColor(args.fBuilder,
|
||||
args.fFragBuilder,
|
||||
this->emitColor(args.fFragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge, t.c_str(),
|
||||
args.fOutputColor,
|
||||
|
@ -168,7 +168,8 @@ void SkSweepGradient::SweepGradientContext::shadeSpan16(int x, int y, uint16_t*
|
||||
|
||||
#include "SkGr.h"
|
||||
#include "gl/GrGLContext.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
|
||||
class GrGLSweepGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
@ -247,7 +248,7 @@ const GrFragmentProcessor* GrSweepGradient::TestCreate(GrProcessorTestData* d) {
|
||||
|
||||
void GrGLSweepGradient::emitCode(EmitArgs& args) {
|
||||
const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
this->emitUniforms(args.fUniformHandler, ge);
|
||||
SkString coords2D = args.fFragBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
SkString t;
|
||||
// 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi]
|
||||
@ -260,8 +261,8 @@ void GrGLSweepGradient::emitCode(EmitArgs& args) {
|
||||
t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5",
|
||||
coords2D.c_str(), coords2D.c_str());
|
||||
}
|
||||
this->emitColor(args.fBuilder,
|
||||
args.fFragBuilder,
|
||||
this->emitColor(args.fFragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge, t.c_str(),
|
||||
args.fOutputColor,
|
||||
|
@ -11,10 +11,12 @@
|
||||
#include "SkTwoPointConicalGradient.h"
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrPaint.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
// For brevity
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
@ -223,8 +225,9 @@ GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrProcessor&)
|
||||
|
||||
void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
const Edge2PtConicalEffect& ge = args.fFp.cast<Edge2PtConicalEffect>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
fParamUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
this->emitUniforms(uniformHandler, ge);
|
||||
fParamUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSParams", 3);
|
||||
|
||||
@ -234,9 +237,9 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
SkString p1; // start radius squared
|
||||
SkString p2; // difference in radii (r1 - r0)
|
||||
|
||||
args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
|
||||
args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
|
||||
args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
|
||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
|
||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
|
||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(2, &p2);
|
||||
|
||||
// We interpolate the linear component in coords[1].
|
||||
SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType());
|
||||
@ -270,8 +273,8 @@ void GLEdge2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(),
|
||||
p2.c_str(), p0.c_str());
|
||||
fragBuilder->codeAppend("\t");
|
||||
this->emitColor(args.fBuilder,
|
||||
fragBuilder,
|
||||
this->emitColor(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge,
|
||||
tName.c_str(),
|
||||
@ -505,16 +508,17 @@ GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrProcessor
|
||||
|
||||
void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
const FocalOutside2PtConicalEffect& ge = args.fFp.cast<FocalOutside2PtConicalEffect>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
fParamUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
this->emitUniforms(uniformHandler, ge);
|
||||
fParamUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSParams", 2);
|
||||
SkString tName("t");
|
||||
SkString p0; // focalX
|
||||
SkString p1; // 1 - focalX * focalX
|
||||
|
||||
args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
|
||||
args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
|
||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(0, &p0);
|
||||
uniformHandler->getUniformVariable(fParamUni).appendArrayAccess(1, &p1);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -543,8 +547,8 @@ void GLFocalOutside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
|
||||
fragBuilder->codeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str());
|
||||
fragBuilder->codeAppend("\t\t");
|
||||
this->emitColor(args.fBuilder,
|
||||
fragBuilder,
|
||||
this->emitColor(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge,
|
||||
tName.c_str(),
|
||||
@ -714,15 +718,16 @@ GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrProcessor&)
|
||||
|
||||
void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
const FocalInside2PtConicalEffect& ge = args.fFp.cast<FocalInside2PtConicalEffect>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
fFocalUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
this->emitUniforms(uniformHandler, ge);
|
||||
fFocalUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
// this is the distance along x-axis from the end center to focal point in
|
||||
// transformed coordinates
|
||||
GrGLSLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni);
|
||||
GrGLSLShaderVar focal = uniformHandler->getUniformVariable(fFocalUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -733,8 +738,8 @@ void GLFocalInside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_str(),
|
||||
coords2D, focal.c_str(), coords2D);
|
||||
|
||||
this->emitColor(args.fBuilder,
|
||||
fragBuilder,
|
||||
this->emitColor(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge,
|
||||
tName.c_str(),
|
||||
@ -965,20 +970,21 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrProcessor
|
||||
|
||||
void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
const CircleInside2PtConicalEffect& ge = args.fFp.cast<CircleInside2PtConicalEffect>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
fCenterUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
this->emitUniforms(uniformHandler, ge);
|
||||
fCenterUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSCenter");
|
||||
fParamUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fParamUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
|
||||
GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
|
||||
// params.x = A
|
||||
// params.y = B
|
||||
// params.z = C
|
||||
GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
|
||||
GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -999,8 +1005,8 @@ void GLCircleInside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\n",
|
||||
tName.c_str(), params.c_str(), params.c_str());
|
||||
|
||||
this->emitColor(args.fBuilder,
|
||||
fragBuilder,
|
||||
this->emitColor(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge,
|
||||
tName.c_str(),
|
||||
@ -1201,20 +1207,21 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrProcess
|
||||
|
||||
void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
const CircleOutside2PtConicalEffect& ge = args.fFp.cast<CircleOutside2PtConicalEffect>();
|
||||
this->emitUniforms(args.fBuilder, ge);
|
||||
fCenterUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
this->emitUniforms(uniformHandler, ge);
|
||||
fCenterUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSCenter");
|
||||
fParamUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fParamUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Conical2FSParams");
|
||||
SkString tName("t");
|
||||
|
||||
GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni);
|
||||
GrGLSLShaderVar center = uniformHandler->getUniformVariable(fCenterUni);
|
||||
// params.x = A
|
||||
// params.y = B
|
||||
// params.z = C
|
||||
GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni);
|
||||
GrGLSLShaderVar params = uniformHandler->getUniformVariable(fParamUni);
|
||||
|
||||
// if we have a vec3 from being in perspective, convert it to a vec2 first
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
@ -1248,10 +1255,11 @@ void GLCircleOutside2PtConicalEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str());
|
||||
}
|
||||
|
||||
fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_str(), params.c_str());
|
||||
fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n",
|
||||
tName.c_str(), params.c_str());
|
||||
fragBuilder->codeAppend("\t\t");
|
||||
this->emitColor(args.fBuilder,
|
||||
fragBuilder,
|
||||
this->emitColor(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
ge,
|
||||
tName.c_str(),
|
||||
|
@ -10,9 +10,9 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLUtil.h"
|
||||
|
||||
/*
|
||||
@ -64,10 +64,10 @@ public:
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
||||
const DefaultGeoProc& gp = args.fGP.cast<DefaultGeoProc>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(gp);
|
||||
@ -77,13 +77,14 @@ public:
|
||||
if (gp.hasVertexColor()) {
|
||||
varyingHandler->addPassThroughAttribute(gp.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
@ -91,9 +92,9 @@ public:
|
||||
|
||||
if (gp.hasExplicitLocalCoords()) {
|
||||
// emit transforms with explicit local coords
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
gp.inLocalCoords()->fName,
|
||||
gp.localMatrix(),
|
||||
@ -101,17 +102,16 @@ public:
|
||||
args.fTransformsOut);
|
||||
} else if(gp.hasTransformedLocalCoords()) {
|
||||
// transforms have already been applied to vertex attributes on the cpu
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
gp.inLocalCoords()->fName,
|
||||
args.fTransformsIn,
|
||||
args.fTransformsOut);
|
||||
} else {
|
||||
// emit transforms with position
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
gp.inPosition()->fName,
|
||||
gp.localMatrix(),
|
||||
@ -129,7 +129,8 @@ public:
|
||||
fragBuilder->codeAppendf("%s = vec4(1);", args.fOutputCoverage);
|
||||
} else {
|
||||
const char* fragCoverage;
|
||||
fCoverageUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCoverageUniform = uniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Coverage",
|
||||
|
@ -8,10 +8,12 @@
|
||||
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcOptInfo.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "effects/GrXfermodeFragmentProcessor.h"
|
||||
|
||||
@ -226,7 +228,8 @@ const GrFragmentProcessor* GrFragmentProcessor::OverrideInput(const GrFragmentPr
|
||||
GLFP() : fHaveSetColor(false) {}
|
||||
void emitCode(EmitArgs& args) override {
|
||||
const char* colorName;
|
||||
fColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorUni = args.fUniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Color", &colorName);
|
||||
this->emitChild(0, colorName, args);
|
||||
|
@ -23,10 +23,10 @@
|
||||
#include "effects/GrRRectEffect.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLUtil.h"
|
||||
|
||||
// TODO(joshualitt) - Break this file up during GrBatch post implementation cleanup
|
||||
@ -98,9 +98,9 @@ public:
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const CircleEdgeEffect& ce = args.fGP.cast<CircleEdgeEffect>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(ce);
|
||||
@ -112,16 +112,17 @@ public:
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// setup pass through color
|
||||
if (!ce.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, vertBuilder, gpArgs, ce.inPosition()->fName);
|
||||
this->setupPosition(vertBuilder, gpArgs, ce.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
ce.inPosition()->fName,
|
||||
ce.localMatrix(),
|
||||
@ -254,9 +255,9 @@ public:
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const EllipseEdgeEffect& ee = args.fGP.cast<EllipseEdgeEffect>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(ee);
|
||||
@ -274,16 +275,17 @@ public:
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// setup pass through color
|
||||
if (!ee.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, vertBuilder, gpArgs, ee.inPosition()->fName);
|
||||
this->setupPosition(vertBuilder, gpArgs, ee.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
ee.inPosition()->fName,
|
||||
ee.localMatrix(),
|
||||
@ -436,9 +438,9 @@ public:
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
||||
const DIEllipseEdgeEffect& ee = args.fGP.cast<DIEllipseEdgeEffect>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(ee);
|
||||
@ -456,21 +458,22 @@ public:
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// setup pass through color
|
||||
if (!ee.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
ee.inPosition()->fName,
|
||||
ee.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
ee.inPosition()->fName,
|
||||
args.fTransformsIn,
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProcessorTypes.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
|
||||
class GrGLPathProcessor : public GrGLSLPrimitiveProcessor {
|
||||
@ -26,7 +26,6 @@ public:
|
||||
}
|
||||
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrPathProcessor& pathProc = args.fGP.cast<GrPathProcessor>();
|
||||
|
||||
@ -36,7 +35,8 @@ public:
|
||||
// Setup uniform color
|
||||
if (pathProc.overrides().readsColor()) {
|
||||
const char* stagedLocalVarName;
|
||||
fColorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fColorUniform = args.fUniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Color",
|
||||
|
@ -25,10 +25,12 @@
|
||||
#include "SkString.h"
|
||||
#include "SkTraceEvent.h"
|
||||
#include "batches/GrVertexBatch.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
GrAAConvexPathRenderer::GrAAConvexPathRenderer() {
|
||||
}
|
||||
@ -549,9 +551,9 @@ public:
|
||||
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
||||
const QuadEdgeEffect& qe = args.fGP.cast<QuadEdgeEffect>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(qe);
|
||||
@ -563,16 +565,17 @@ public:
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// Setup pass through color
|
||||
if (!qe.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, vertBuilder, gpArgs, qe.inPosition()->fName);
|
||||
this->setupPosition(vertBuilder, gpArgs, qe.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
qe.inPosition()->fName,
|
||||
qe.localMatrix(),
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "SkPathPriv.h"
|
||||
#include "batches/GrVertexBatch.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
|
||||
static const int DEFAULT_BUFFER_SIZE = 100;
|
||||
|
||||
|
@ -7,11 +7,13 @@
|
||||
|
||||
#include "GrBezierEffect.h"
|
||||
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLUtil.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
class GrGLConicEffect : public GrGLSLGeometryProcessor {
|
||||
public:
|
||||
@ -73,10 +75,10 @@ GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor)
|
||||
}
|
||||
|
||||
void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
const GrConicEffect& gp = args.fGP.cast<GrConicEffect>();
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(gp);
|
||||
@ -88,21 +90,21 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// Setup pass through color
|
||||
if (!gp.colorIgnored()) {
|
||||
this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
gp.inPosition()->fName,
|
||||
gp.localMatrix(),
|
||||
@ -168,7 +170,8 @@ void GrGLConicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
// TODO should we really be doing this?
|
||||
if (gp.coverageScale() != 0xff) {
|
||||
const char* coverageScale;
|
||||
fCoverageScaleUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCoverageScaleUniform = uniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Coverage",
|
||||
@ -301,10 +304,10 @@ GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor)
|
||||
}
|
||||
|
||||
void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
const GrQuadEffect& gp = args.fGP.cast<GrQuadEffect>();
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(gp);
|
||||
@ -316,21 +319,21 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// Setup pass through color
|
||||
if (!gp.colorIgnored()) {
|
||||
this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
gp.inPosition()->fName,
|
||||
gp.localMatrix(),
|
||||
@ -384,7 +387,8 @@ void GrGLQuadEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
|
||||
if (0xff != gp.coverageScale()) {
|
||||
const char* coverageScale;
|
||||
fCoverageScaleUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCoverageScaleUniform = uniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Coverage",
|
||||
@ -507,6 +511,7 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
const GrCubicEffect& gp = args.fGP.cast<GrCubicEffect>();
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(gp);
|
||||
@ -518,21 +523,21 @@ void GrGLCubicEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// Setup pass through color
|
||||
if (!gp.colorIgnored()) {
|
||||
this->setupUniformColor(args.fPB, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(args.fPB,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
gp.inPosition()->fName,
|
||||
gp.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms with position
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
gp.inPosition()->fName,
|
||||
args.fTransformsIn,
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "GrBicubicEffect.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
#define DS(x) SkDoubleToScalar(x)
|
||||
|
||||
@ -52,15 +52,16 @@ GrGLBicubicEffect::GrGLBicubicEffect(const GrProcessor&) {
|
||||
void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
const GrTextureDomain& domain = args.fFp.cast<GrBicubicEffect>().domain();
|
||||
|
||||
fCoefficientsUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fCoefficientsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kMat44f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Coefficients");
|
||||
fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"ImageIncrement");
|
||||
|
||||
const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni);
|
||||
const char* coeff = args.fBuilder->getUniformCStr(fCoefficientsUni);
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
const char* coeff = uniformHandler->getUniformCStr(fCoefficientsUni);
|
||||
|
||||
SkString cubicBlendName;
|
||||
|
||||
@ -98,6 +99,7 @@ void GrGLBicubicEffect::emitCode(EmitArgs& args) {
|
||||
SkString sampleVar;
|
||||
sampleVar.printf("rowColors[%d]", x);
|
||||
fDomain.sampleTexture(fragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
domain,
|
||||
sampleVar.c_str(),
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "GrTexture.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
@ -22,9 +22,9 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override {
|
||||
const GrBitmapTextGeoProc& cte = args.fGP.cast<GrBitmapTextGeoProc>();
|
||||
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(cte);
|
||||
@ -49,17 +49,18 @@ public:
|
||||
if (cte.hasVertexColor()) {
|
||||
varyingHandler->addPassThroughAttribute(cte.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, vertBuilder, gpArgs, cte.inPosition()->fName);
|
||||
this->setupPosition(vertBuilder, gpArgs, cte.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
cte.inPosition()->fName,
|
||||
cte.localMatrix(),
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "SkMatrix.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
|
||||
class GrGLConfigConversionEffect : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
|
@ -6,10 +6,11 @@
|
||||
*/
|
||||
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class GLConstColorProcessor : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
@ -18,8 +19,9 @@ public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const char* colorUni;
|
||||
fColorUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kMedium_GrSLPrecision, "constantColor",
|
||||
fColorUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kMedium_GrSLPrecision,
|
||||
"constantColor",
|
||||
&colorUni);
|
||||
GrConstColorProcessor::InputMode mode = args.fFp.cast<GrConstColorProcessor>().inputMode();
|
||||
if (!args.fInputColor) {
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "SkPathPriv.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
class AARectEffect : public GrFragmentProcessor {
|
||||
@ -105,7 +105,7 @@ void GLAARectEffect::emitCode(EmitArgs& args) {
|
||||
const char *rectName;
|
||||
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
|
||||
// respectively.
|
||||
fRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fRectUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"rect",
|
||||
@ -191,7 +191,7 @@ void GrGLConvexPolyEffect::emitCode(EmitArgs& args) {
|
||||
const GrConvexPolyEffect& cpe = args.fFp.cast<GrConvexPolyEffect>();
|
||||
|
||||
const char *edgeArrayName;
|
||||
fEdgeUniform = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fEdgeUniform = args.fUniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"edges",
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "GrConvolutionEffect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
// For brevity
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -48,15 +48,16 @@ GrGLConvolutionEffect::GrGLConvolutionEffect(const GrProcessor& processor) {
|
||||
}
|
||||
|
||||
void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"ImageIncrement");
|
||||
if (this->useBounds()) {
|
||||
fBoundsUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fBoundsUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"Bounds");
|
||||
}
|
||||
fKernelUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKernelUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Kernel", this->width());
|
||||
|
||||
@ -66,8 +67,8 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
fragBuilder->codeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", args.fOutputColor);
|
||||
|
||||
int width = this->width();
|
||||
const GrGLSLShaderVar& kernel = args.fBuilder->getUniformVariable(fKernelUni);
|
||||
const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni);
|
||||
const GrGLSLShaderVar& kernel = uniformHandler->getUniformVariable(fKernelUni);
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
|
||||
fragBuilder->codeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords2D.c_str(), fRadius, imgInc);
|
||||
|
||||
@ -82,7 +83,7 @@ void GrGLConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
// We used to compute a bool indicating whether we're in bounds or not, cast it to a
|
||||
// float, and then mul weight*texture_sample by the float. However, the Adreno 430 seems
|
||||
// to have a bug that caused corruption.
|
||||
const char* bounds = args.fBuilder->getUniformCStr(fBoundsUni);
|
||||
const char* bounds = uniformHandler->getUniformCStr(fBoundsUni);
|
||||
const char* component = this->direction() == Gr1DKernelEffect::kY_Direction ? "y" : "x";
|
||||
fragBuilder->codeAppendf("if (coord.%s >= %s.x && coord.%s <= %s.y) {",
|
||||
component, bounds, component, bounds);
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "GrProcessor.h"
|
||||
#include "GrProcOptInfo.h"
|
||||
#include "glsl/GrGLSLBlend.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
class CoverageSetOpXP : public GrXferProcessor {
|
||||
@ -200,8 +200,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
|
||||
GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const char* srcColor,
|
||||
const char* srcCoverage,
|
||||
const char* dstColor,
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
|
||||
@ -158,8 +158,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
|
||||
GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const char* srcColor,
|
||||
const char* srcCoverage,
|
||||
const char* dstColor,
|
||||
|
@ -23,8 +23,8 @@
|
||||
#include "batches/GrVertexBatch.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
@ -863,9 +863,9 @@ GLDashingCircleEffect::GLDashingCircleEffect() {
|
||||
|
||||
void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const DashingCircleEffect& dce = args.fGP.cast<DashingCircleEffect>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(dce);
|
||||
@ -883,16 +883,16 @@ void GLDashingCircleEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// Setup pass through color
|
||||
if (!dce.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, vertBuilder, gpArgs, dce.inPosition()->fName);
|
||||
this->setupPosition(vertBuilder, gpArgs, dce.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
dce.inPosition()->fName,
|
||||
dce.localMatrix(),
|
||||
@ -1075,10 +1075,10 @@ GLDashingLineEffect::GLDashingLineEffect() {
|
||||
|
||||
void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
const DashingLineEffect& de = args.fGP.cast<DashingLineEffect>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(de);
|
||||
@ -1097,16 +1097,16 @@ void GLDashingLineEffect::onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
// Setup pass through color
|
||||
if (!de.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb, vertBuilder, gpArgs, de.inPosition()->fName);
|
||||
this->setupPosition(vertBuilder, gpArgs, de.inPosition()->fName);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(args.fPB,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
de.inPosition()->fName,
|
||||
de.localMatrix(),
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "effects/GrDisableColorXP.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLUtil.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
@ -35,13 +35,13 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrDistanceFieldA8TextGeoProc& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldA8TextGeoProc>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkAssertResult(fragBuilder->enableFeature(
|
||||
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
|
||||
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(dfTexEffect);
|
||||
@ -50,7 +50,7 @@ public:
|
||||
// adjust based on gamma
|
||||
const char* distanceAdjustUniName = nullptr;
|
||||
// width, height, 1/(3*width)
|
||||
fDistanceAdjustUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDistanceAdjustUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"DistanceAdjust", &distanceAdjustUniName);
|
||||
#endif
|
||||
@ -60,22 +60,23 @@ public:
|
||||
if (dfTexEffect.hasVertexColor()) {
|
||||
varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
args.fTransformsIn,
|
||||
@ -296,13 +297,13 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrDistanceFieldPathGeoProc& dfTexEffect = args.fGP.cast<GrDistanceFieldPathGeoProc>();
|
||||
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkAssertResult(fragBuilder->enableFeature(
|
||||
GrGLSLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature));
|
||||
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(dfTexEffect);
|
||||
@ -315,30 +316,31 @@ public:
|
||||
if (dfTexEffect.hasVertexColor()) {
|
||||
varyingHandler->addPassThroughAttribute(dfTexEffect.inColor(), args.fOutputColor);
|
||||
} else {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor,
|
||||
&fColorUniform);
|
||||
}
|
||||
}
|
||||
vertBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoords()->fName);
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
args.fTransformsIn,
|
||||
args.fTransformsOut);
|
||||
|
||||
const char* textureSizeUniName = nullptr;
|
||||
fTextureSizeUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fTextureSizeUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"TextureSize", &textureSizeUniName);
|
||||
|
||||
@ -521,10 +523,10 @@ public:
|
||||
void onEmitCode(EmitArgs& args, GrGPArgs* gpArgs) override{
|
||||
const GrDistanceFieldLCDTextGeoProc& dfTexEffect =
|
||||
args.fGP.cast<GrDistanceFieldLCDTextGeoProc>();
|
||||
GrGLSLGPBuilder* pb = args.fPB;
|
||||
|
||||
GrGLSLVertexBuilder* vertBuilder = args.fVertBuilder;
|
||||
GrGLSLVaryingHandler* varyingHandler = args.fVaryingHandler;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
|
||||
// emit attributes
|
||||
varyingHandler->emitAttributes(dfTexEffect);
|
||||
@ -533,21 +535,21 @@ public:
|
||||
|
||||
// setup pass through color
|
||||
if (!dfTexEffect.colorIgnored()) {
|
||||
this->setupUniformColor(pb, fragBuilder, args.fOutputColor, &fColorUniform);
|
||||
this->setupUniformColor(fragBuilder, uniformHandler, args.fOutputColor, &fColorUniform);
|
||||
}
|
||||
|
||||
// Setup position
|
||||
this->setupPosition(pb,
|
||||
vertBuilder,
|
||||
this->setupPosition(vertBuilder,
|
||||
uniformHandler,
|
||||
gpArgs,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
dfTexEffect.viewMatrix(),
|
||||
&fViewMatrixUniform);
|
||||
|
||||
// emit transforms
|
||||
this->emitTransforms(pb,
|
||||
vertBuilder,
|
||||
this->emitTransforms(vertBuilder,
|
||||
varyingHandler,
|
||||
uniformHandler,
|
||||
gpArgs->fPositionVar,
|
||||
dfTexEffect.inPosition()->fName,
|
||||
args.fTransformsIn,
|
||||
@ -628,7 +630,7 @@ public:
|
||||
|
||||
// adjust width based on gamma
|
||||
const char* distanceAdjustUniName = nullptr;
|
||||
fDistanceAdjustUni = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDistanceAdjustUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec3f_GrSLType, kDefault_GrSLPrecision,
|
||||
"DistanceAdjust", &distanceAdjustUniName);
|
||||
fragBuilder->codeAppendf("distance -= %s;", distanceAdjustUniName);
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "SkRect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -6,8 +6,9 @@
|
||||
*/
|
||||
#include "GrMatrixConvolutionEffect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
class GrGLMatrixConvolutionEffect : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
@ -42,25 +43,27 @@ GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrProcessor& proc
|
||||
|
||||
void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
const GrTextureDomain& domain = args.fFp.cast<GrMatrixConvolutionEffect>().domain();
|
||||
fImageIncrementUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
fImageIncrementUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"ImageIncrement");
|
||||
fKernelUni = args.fBuilder->addUniformArray(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKernelUni = uniformHandler->addUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"Kernel",
|
||||
fKernelSize.width() * fKernelSize.height());
|
||||
fKernelOffsetUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision, "KernelOffset");
|
||||
fGainUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fKernelOffsetUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kDefault_GrSLPrecision,
|
||||
"KernelOffset");
|
||||
fGainUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision, "Gain");
|
||||
fBiasUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fBiasUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision, "Bias");
|
||||
|
||||
const char* kernelOffset = args.fBuilder->getUniformCStr(fKernelOffsetUni);
|
||||
const char* imgInc = args.fBuilder->getUniformCStr(fImageIncrementUni);
|
||||
const char* kernel = args.fBuilder->getUniformCStr(fKernelUni);
|
||||
const char* gain = args.fBuilder->getUniformCStr(fGainUni);
|
||||
const char* bias = args.fBuilder->getUniformCStr(fBiasUni);
|
||||
const char* kernelOffset = uniformHandler->getUniformCStr(fKernelOffsetUni);
|
||||
const char* imgInc = uniformHandler->getUniformCStr(fImageIncrementUni);
|
||||
const char* kernel = uniformHandler->getUniformCStr(fKernelUni);
|
||||
const char* gain = uniformHandler->getUniformCStr(fGainUni);
|
||||
const char* bias = uniformHandler->getUniformCStr(fBiasUni);
|
||||
int kWidth = fKernelSize.width();
|
||||
int kHeight = fKernelSize.height();
|
||||
|
||||
@ -77,6 +80,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
SkString coord;
|
||||
coord.printf("coord + vec2(%d, %d) * %s", x, y, imgInc);
|
||||
fDomain.sampleTexture(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
domain,
|
||||
"c",
|
||||
@ -95,6 +99,7 @@ void GrGLMatrixConvolutionEffect::emitCode(EmitArgs& args) {
|
||||
args.fOutputColor, args.fOutputColor, args.fOutputColor);
|
||||
} else {
|
||||
fDomain.sampleTexture(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fGLSLCaps,
|
||||
domain,
|
||||
"c",
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "SkRect.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -119,7 +119,7 @@ void GLCircleEffect::emitCode(EmitArgs& args) {
|
||||
const char *circleName;
|
||||
// The circle uniform is (center.x, center.y, radius + 0.5, 1 / (radius + 0.5)) for regular
|
||||
// fills and (..., radius - 0.5, 1 / (radius - 0.5)) for inverse fills.
|
||||
fCircleUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fCircleUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"circle",
|
||||
&circleName);
|
||||
@ -291,7 +291,7 @@ void GLEllipseEffect::emitCode(EmitArgs& args) {
|
||||
const char *ellipseName;
|
||||
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
|
||||
// The last two terms can underflow on mediump, so we use highp.
|
||||
fEllipseUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fEllipseUniform = args.fUniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kHigh_GrSLPrecision,
|
||||
"ellipse",
|
||||
&ellipseName);
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include "GrXferProcessor.h"
|
||||
#include "glsl/GrGLSLBlend.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLXferProcessor.h"
|
||||
|
||||
/**
|
||||
@ -545,8 +545,8 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
|
||||
GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const char* srcColor,
|
||||
const char* srcCoverage,
|
||||
const char* dstColor,
|
||||
|
@ -12,10 +12,11 @@
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrOvalEffect.h"
|
||||
#include "SkRRect.h"
|
||||
#include "SkTLazy.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
// The effects defined here only handle rrect radii >= kRadiusMin.
|
||||
static const SkScalar kRadiusMin = SK_ScalarHalf;
|
||||
@ -150,17 +151,18 @@ GLCircularRRectEffect::GLCircularRRectEffect(const GrProcessor& ) {
|
||||
|
||||
void GLCircularRRectEffect::emitCode(EmitArgs& args) {
|
||||
const CircularRRectEffect& crre = args.fFp.cast<CircularRRectEffect>();
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
const char *rectName;
|
||||
const char *radiusPlusHalfName;
|
||||
// The inner rect is the rrect bounds inset by the radius. Its left, top, right, and bottom
|
||||
// edges correspond to components x, y, z, and w, respectively. When a side of the rrect has
|
||||
// only rectangular corners, that side's value corresponds to the rect edge's value outset by
|
||||
// half a pixel.
|
||||
fInnerRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fInnerRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"innerRect",
|
||||
&rectName);
|
||||
fRadiusPlusHalfUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fRadiusPlusHalfUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
"radiusPlusHalf",
|
||||
&radiusPlusHalfName);
|
||||
@ -504,9 +506,10 @@ GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrProcessor& effect) {
|
||||
|
||||
void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
|
||||
const EllipticalRRectEffect& erre = args.fFp.cast<EllipticalRRectEffect>();
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
const char *rectName;
|
||||
// The inner rect is the rrect bounds inset by the x/y radii
|
||||
fInnerRectUniform = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fInnerRectUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
"innerRect",
|
||||
&rectName);
|
||||
@ -531,8 +534,8 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
|
||||
switch (erre.getRRect().getType()) {
|
||||
case SkRRect::kSimple_Type: {
|
||||
const char *invRadiiXYSqdName;
|
||||
fInvRadiiSqdUniform = args.fBuilder->addUniform(
|
||||
GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fInvRadiiSqdUniform = uniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType, kHigh_GrSLPrecision,
|
||||
"invRadiiXY",
|
||||
&invRadiiXYSqdName);
|
||||
@ -543,8 +546,8 @@ void GLEllipticalRRectEffect::emitCode(EmitArgs& args) {
|
||||
}
|
||||
case SkRRect::kNinePatch_Type: {
|
||||
const char *invRadiiLTRBSqdName;
|
||||
fInvRadiiSqdUniform = args.fBuilder->addUniform(
|
||||
GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fInvRadiiSqdUniform = uniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kHigh_GrSLPrecision,
|
||||
"invRadiiLTRB",
|
||||
&invRadiiLTRBSqdName);
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "GrTexture.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
|
||||
class GrGLSimpleTextureEffect : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
|
@ -10,9 +10,11 @@
|
||||
#include "GrSimpleTextureEffect.h"
|
||||
#include "SkFloatingPoint.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLShaderBuilder.h"
|
||||
#include "glsl/GrGLSLTextureSampler.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
|
||||
: fIndex(index) {
|
||||
@ -42,6 +44,7 @@ GrTextureDomain::GrTextureDomain(const SkRect& domain, Mode mode, int index)
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* glslCaps,
|
||||
const GrTextureDomain& textureDomain,
|
||||
const char* outColor,
|
||||
@ -51,15 +54,13 @@ void GrTextureDomain::GLDomain::sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
SkASSERT((Mode)-1 == fMode || textureDomain.mode() == fMode);
|
||||
SkDEBUGCODE(fMode = textureDomain.mode();)
|
||||
|
||||
GrGLSLProgramBuilder* program = builder->getProgramBuilder();
|
||||
|
||||
if (textureDomain.mode() != kIgnore_Mode && !fDomainUni.isValid()) {
|
||||
const char* name;
|
||||
SkString uniName("TexDom");
|
||||
if (textureDomain.fIndex >= 0) {
|
||||
uniName.appendS32(textureDomain.fIndex);
|
||||
}
|
||||
fDomainUni = program->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDomainUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType, kDefault_GrSLPrecision,
|
||||
uniName.c_str(), &name);
|
||||
fDomainName = name;
|
||||
@ -199,6 +200,7 @@ void GrGLTextureDomainEffect::emitCode(EmitArgs& args) {
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString coords2D = fragBuilder->ensureFSCoords2D(args.fCoords, 0);
|
||||
fGLDomain.sampleTexture(fragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
domain,
|
||||
args.fOutputColor,
|
||||
|
@ -16,6 +16,7 @@ class GrGLProgramBuilder;
|
||||
class GrGLSLShaderBuilder;
|
||||
class GrInvariantOutput;
|
||||
class GrGLSLTextureSampler;
|
||||
class GrGLSLUniformHandler;
|
||||
struct SkRect;
|
||||
|
||||
/**
|
||||
@ -114,6 +115,7 @@ public:
|
||||
* expression before being written to outColor.
|
||||
*/
|
||||
void sampleTexture(GrGLSLShaderBuilder* builder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* glslCaps,
|
||||
const GrTextureDomain& textureDomain,
|
||||
const char* outColor,
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include "effects/GrXfermodeFragmentProcessor.h"
|
||||
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "effects/GrConstColorProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLBlend.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "SkGrPriv.h"
|
||||
|
||||
class ComposeTwoFragmentProcessor : public GrFragmentProcessor {
|
||||
|
@ -8,12 +8,13 @@
|
||||
#include "GrYUVtoRGBEffect.h"
|
||||
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -67,7 +68,8 @@ public:
|
||||
GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
|
||||
const char* yuvMatrix = nullptr;
|
||||
fMatrixUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fMatrixUni = args.fUniformHandler->addUniform(
|
||||
GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kMat44f_GrSLType, kDefault_GrSLPrecision,
|
||||
"YUVMatrix", &yuvMatrix);
|
||||
fragBuilder->codeAppendf("\t%s = vec4(\n\t\t", args.fOutputColor);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "GrGLTexture.h"
|
||||
#include "GrGLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
#include "SkString.h"
|
||||
#include "SkXfermode.h"
|
||||
@ -35,7 +36,7 @@ class GrPipeline;
|
||||
*/
|
||||
class GrGLProgram : public SkRefCnt {
|
||||
public:
|
||||
typedef GrGLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles;
|
||||
typedef GrGLSLProgramBuilder::BuiltinUniformHandles BuiltinUniformHandles;
|
||||
|
||||
~GrGLProgram();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "SkMatrix.h"
|
||||
#include "gl/GrGLProgramDataManager.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
#define ASSERT_ARRAY_UPLOAD_IN_BOUNDS(UNI, COUNT) \
|
||||
SkASSERT(arrayCount <= uni.fArrayCount || \
|
||||
@ -31,12 +32,12 @@ GrGLProgramDataManager::GrGLProgramDataManager(GrGLGpu* gpu, GrGLuint programID,
|
||||
);
|
||||
// TODO: Move the Xoom uniform array in both FS and VS bug workaround here.
|
||||
|
||||
if (GrGLProgramBuilder::kVertex_Visibility & builderUniform.fVisibility) {
|
||||
if (GrGLSLUniformHandler::kVertex_Visibility & builderUniform.fVisibility) {
|
||||
uniform.fVSLocation = builderUniform.fLocation;
|
||||
} else {
|
||||
uniform.fVSLocation = kUnusedUniform;
|
||||
}
|
||||
if (GrGLProgramBuilder::kFragment_Visibility & builderUniform.fVisibility) {
|
||||
if (GrGLSLUniformHandler::kFragment_Visibility & builderUniform.fVisibility) {
|
||||
uniform.fFSLocation = builderUniform.fLocation;
|
||||
} else {
|
||||
uniform.fFSLocation = kUnusedUniform;
|
||||
|
@ -19,7 +19,6 @@
|
||||
class GrGLGpu;
|
||||
class SkMatrix;
|
||||
class GrGLProgram;
|
||||
class GrGLProgramBuilder;
|
||||
|
||||
/** Manages the resources used by a shader program.
|
||||
* The resources are objects the program uses to communicate with the
|
||||
|
90
src/gpu/gl/GrGLUniformHandler.cpp
Normal file
90
src/gpu/gl/GrGLUniformHandler.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "gl/GrGLUniformHandler.h"
|
||||
|
||||
#include "gl/GrGLCaps.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
|
||||
#define GL_CALL(X) GR_GL_CALL(this->glGpu()->glInterface(), X)
|
||||
#define GL_CALL_RET(R, X) GR_GL_CALL_RET(this->glGpu()->glInterface(), R, X)
|
||||
|
||||
GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||
uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
const char** outName) {
|
||||
SkASSERT(name && strlen(name));
|
||||
SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFragment_Visibility);
|
||||
SkASSERT(0 == (~kVisibilityMask & visibility));
|
||||
SkASSERT(0 != visibility);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
uni.fVariable.setType(type);
|
||||
uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
|
||||
// TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
|
||||
// the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
|
||||
// exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
|
||||
// the names will mismatch. I think the correct solution is to have all GPs which need the
|
||||
// uniform view matrix, they should upload the view matrix in their setData along with regular
|
||||
// uniforms.
|
||||
char prefix = 'u';
|
||||
if ('u' == name[0]) {
|
||||
prefix = '\0';
|
||||
}
|
||||
fProgramBuilder->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
|
||||
uni.fVariable.setArrayCount(arrayCount);
|
||||
uni.fVisibility = visibility;
|
||||
uni.fVariable.setPrecision(precision);
|
||||
|
||||
if (outName) {
|
||||
*outName = uni.fVariable.c_str();
|
||||
}
|
||||
return GrGLSLUniformHandler::UniformHandle(fUniforms.count() - 1);
|
||||
}
|
||||
|
||||
void GrGLUniformHandler::appendUniformDecls(ShaderVisibility visibility, SkString* out) const {
|
||||
for (int i = 0; i < fUniforms.count(); ++i) {
|
||||
if (fUniforms[i].fVisibility & visibility) {
|
||||
fUniforms[i].fVariable.appendDecl(fProgramBuilder->glslCaps(), out);
|
||||
out->append(";\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLUniformHandler::bindUniformLocations(GrGLuint programID, const GrGLCaps& caps) {
|
||||
if (caps.bindUniformLocationSupport()) {
|
||||
int count = fUniforms.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_str()));
|
||||
fUniforms[i].fLocation = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLUniformHandler::getUniformLocations(GrGLuint programID, const GrGLCaps& caps) {
|
||||
if (!caps.bindUniformLocationSupport()) {
|
||||
int count = fUniforms.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
GrGLint location;
|
||||
GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVariable.c_str()));
|
||||
fUniforms[i].fLocation = location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const GrGLGpu* GrGLUniformHandler::glGpu() const {
|
||||
GrGLProgramBuilder* glPB = (GrGLProgramBuilder*) fProgramBuilder;
|
||||
return glPB->gpu();
|
||||
}
|
||||
|
||||
|
61
src/gpu/gl/GrGLUniformHandler.h
Normal file
61
src/gpu/gl/GrGLUniformHandler.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrGLUniformHandler_DEFINED
|
||||
#define GrGLUniformHandler_DEFINED
|
||||
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
#include "gl/GrGLProgramDataManager.h"
|
||||
|
||||
class GrGLCaps;
|
||||
|
||||
static const int kUniformsPerBlock = 8;
|
||||
|
||||
class GrGLUniformHandler : public GrGLSLUniformHandler {
|
||||
public:
|
||||
const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
return fUniforms[u.toIndex()].fVariable;
|
||||
}
|
||||
|
||||
const char* getUniformCStr(UniformHandle u) const override {
|
||||
return this->getUniformVariable(u).c_str();
|
||||
}
|
||||
private:
|
||||
explicit GrGLUniformHandler(GrGLSLProgramBuilder* program)
|
||||
: INHERITED(program)
|
||||
, fUniforms(kUniformsPerBlock) {}
|
||||
|
||||
UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
const char** outName) override;
|
||||
|
||||
void appendUniformDecls(ShaderVisibility, SkString*) const override;
|
||||
|
||||
// Manually set uniform locations for all our uniforms.
|
||||
void bindUniformLocations(GrGLuint programID, const GrGLCaps& caps);
|
||||
|
||||
// Updates the loction of the Uniforms if we cannot bind uniform locations manually
|
||||
void getUniformLocations(GrGLuint programID, const GrGLCaps& caps);
|
||||
|
||||
const GrGLGpu* glGpu() const;
|
||||
|
||||
typedef GrGLProgramDataManager::UniformInfo UniformInfo;
|
||||
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
|
||||
|
||||
UniformInfoArray fUniforms;
|
||||
|
||||
friend class GrGLProgramBuilder;
|
||||
|
||||
typedef GrGLSLUniformHandler INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
@ -55,56 +55,9 @@ GrGLProgramBuilder::GrGLProgramBuilder(GrGLGpu* gpu, const DrawArgs& args)
|
||||
, fGeometryProcessor(nullptr)
|
||||
, fXferProcessor(nullptr)
|
||||
, fGpu(gpu)
|
||||
, fUniforms(kVarsPerBlock)
|
||||
, fSamplerUniforms(4)
|
||||
, fVaryingHandler(this) {
|
||||
}
|
||||
|
||||
GrGLSLProgramDataManager::UniformHandle GrGLProgramBuilder::internalAddUniformArray(
|
||||
uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int count,
|
||||
const char** outName) {
|
||||
SkASSERT(name && strlen(name));
|
||||
SkDEBUGCODE(static const uint32_t kVisibilityMask = kVertex_Visibility | kFragment_Visibility);
|
||||
SkASSERT(0 == (~kVisibilityMask & visibility));
|
||||
SkASSERT(0 != visibility);
|
||||
SkASSERT(kDefault_GrSLPrecision == precision || GrSLTypeIsFloatType(type));
|
||||
|
||||
UniformInfo& uni = fUniforms.push_back();
|
||||
uni.fVariable.setType(type);
|
||||
uni.fVariable.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier);
|
||||
// TODO this is a bit hacky, lets think of a better way. Basically we need to be able to use
|
||||
// the uniform view matrix name in the GP, and the GP is immutable so it has to tell the PB
|
||||
// exactly what name it wants to use for the uniform view matrix. If we prefix anythings, then
|
||||
// the names will mismatch. I think the correct solution is to have all GPs which need the
|
||||
// uniform view matrix, they should upload the view matrix in their setData along with regular
|
||||
// uniforms.
|
||||
char prefix = 'u';
|
||||
if ('u' == name[0]) {
|
||||
prefix = '\0';
|
||||
}
|
||||
this->nameVariable(uni.fVariable.accessName(), prefix, name, mangleName);
|
||||
uni.fVariable.setArrayCount(count);
|
||||
uni.fVisibility = visibility;
|
||||
uni.fVariable.setPrecision(precision);
|
||||
|
||||
if (outName) {
|
||||
*outName = uni.fVariable.c_str();
|
||||
}
|
||||
return GrGLSLProgramDataManager::UniformHandle(fUniforms.count() - 1);
|
||||
}
|
||||
|
||||
void GrGLProgramBuilder::onAppendUniformDecls(ShaderVisibility visibility, SkString* out) const {
|
||||
for (int i = 0; i < fUniforms.count(); ++i) {
|
||||
if (fUniforms[i].fVisibility & visibility) {
|
||||
fUniforms[i].fVariable.appendDecl(this->glslCaps(), out);
|
||||
out->append(";\n");
|
||||
}
|
||||
}
|
||||
, fVaryingHandler(this)
|
||||
, fUniformHandler(this) {
|
||||
}
|
||||
|
||||
const GrGLSLCaps* GrGLProgramBuilder::glslCaps() const {
|
||||
@ -220,8 +173,8 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrFragmentProcessor& fp,
|
||||
SkSTArray<4, GrGLSLTextureSampler> samplers(fp.numTextures());
|
||||
this->emitSamplers(fp, &samplers, ifp);
|
||||
|
||||
GrGLSLFragmentProcessor::EmitArgs args(this,
|
||||
&fFS,
|
||||
GrGLSLFragmentProcessor::EmitArgs args(&fFS,
|
||||
&fUniformHandler,
|
||||
this->glslCaps(),
|
||||
fp,
|
||||
outColor,
|
||||
@ -247,10 +200,10 @@ void GrGLProgramBuilder::emitAndInstallProc(const GrPrimitiveProcessor& gp,
|
||||
SkSTArray<4, GrGLSLTextureSampler> samplers(gp.numTextures());
|
||||
this->emitSamplers(gp, &samplers, fGeometryProcessor);
|
||||
|
||||
GrGLSLGeometryProcessor::EmitArgs args(this,
|
||||
&fVS,
|
||||
GrGLSLGeometryProcessor::EmitArgs args(&fVS,
|
||||
&fFS,
|
||||
&fVaryingHandler,
|
||||
&fUniformHandler,
|
||||
this->glslCaps(),
|
||||
gp,
|
||||
outColor,
|
||||
@ -293,8 +246,8 @@ void GrGLProgramBuilder::emitAndInstallXferProc(const GrXferProcessor& xp,
|
||||
SkSTArray<4, GrGLSLTextureSampler> samplers(xp.numTextures());
|
||||
this->emitSamplers(xp, &samplers, fXferProcessor);
|
||||
|
||||
GrGLSLXferProcessor::EmitArgs args(this,
|
||||
&fFS,
|
||||
GrGLSLXferProcessor::EmitArgs args(&fFS,
|
||||
&fUniformHandler,
|
||||
this->glslCaps(),
|
||||
xp, colorIn.c_str(),
|
||||
ignoresCoverage ? nullptr : coverageIn.c_str(),
|
||||
@ -342,7 +295,8 @@ void GrGLProgramBuilder::emitSamplers(const GrProcessor& processor,
|
||||
for (int t = 0; t < numTextures; ++t) {
|
||||
name.printf("Sampler%d", t);
|
||||
GrSLType samplerType = get_sampler_type(processor.textureAccess(t));
|
||||
localSamplerUniforms[t] = this->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
localSamplerUniforms[t] =
|
||||
fUniformHandler.addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
samplerType, kDefault_GrSLPrecision,
|
||||
name.c_str());
|
||||
SkNEW_APPEND_TO_TARRAY(outSamplers, GrGLSLTextureSampler,
|
||||
@ -389,7 +343,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
|
||||
|
||||
// compile shaders and bind attributes / uniforms
|
||||
SkTDArray<GrGLuint> shadersToDelete;
|
||||
fVS.finalize(kVertex_Visibility);
|
||||
fVS.finalize(GrGLSLUniformHandler::kVertex_Visibility);
|
||||
if (!this->compileAndAttachShaders(fVS, programID, GR_GL_VERTEX_SHADER, &shadersToDelete)) {
|
||||
this->cleanupProgram(programID, shadersToDelete);
|
||||
return nullptr;
|
||||
@ -406,7 +360,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
|
||||
}
|
||||
}
|
||||
|
||||
fFS.finalize(kFragment_Visibility);
|
||||
fFS.finalize(GrGLSLUniformHandler::kFragment_Visibility);
|
||||
if (!this->compileAndAttachShaders(fFS, programID, GR_GL_FRAGMENT_SHADER, &shadersToDelete)) {
|
||||
this->cleanupProgram(programID, shadersToDelete);
|
||||
return nullptr;
|
||||
@ -432,13 +386,7 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
|
||||
}
|
||||
|
||||
void GrGLProgramBuilder::bindProgramResourceLocations(GrGLuint programID) {
|
||||
if (fGpu->glCaps().bindUniformLocationSupport()) {
|
||||
int count = fUniforms.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
GL_CALL(BindUniformLocation(programID, i, fUniforms[i].fVariable.c_str()));
|
||||
fUniforms[i].fLocation = i;
|
||||
}
|
||||
}
|
||||
fUniformHandler.bindUniformLocations(programID, fGpu->glCaps());
|
||||
|
||||
const GrGLCaps& caps = this->gpu()->glCaps();
|
||||
if (fFS.hasCustomColorOutput() && caps.bindFragDataLocationSupport()) {
|
||||
@ -488,14 +436,7 @@ bool GrGLProgramBuilder::checkLinkStatus(GrGLuint programID) {
|
||||
}
|
||||
|
||||
void GrGLProgramBuilder::resolveProgramResourceLocations(GrGLuint programID) {
|
||||
if (!fGpu->glCaps().bindUniformLocationSupport()) {
|
||||
int count = fUniforms.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
GrGLint location;
|
||||
GL_CALL_RET(location, GetUniformLocation(programID, fUniforms[i].fVariable.c_str()));
|
||||
fUniforms[i].fLocation = location;
|
||||
}
|
||||
}
|
||||
fUniformHandler.getUniformLocations(programID, fGpu->glCaps());
|
||||
|
||||
// handle NVPR separable varyings
|
||||
if (!fGpu->glCaps().shaderCaps()->pathRenderingSupport() ||
|
||||
@ -524,9 +465,15 @@ void GrGLProgramBuilder::cleanupShaders(const SkTDArray<GrGLuint>& shaderIDs) {
|
||||
}
|
||||
|
||||
GrGLProgram* GrGLProgramBuilder::createProgram(GrGLuint programID) {
|
||||
return new GrGLProgram(fGpu, this->desc(), fUniformHandles, programID, fUniforms,
|
||||
return new GrGLProgram(fGpu,
|
||||
this->desc(),
|
||||
fUniformHandles,
|
||||
programID,
|
||||
fUniformHandler.fUniforms,
|
||||
fVaryingHandler.fPathProcVaryingInfos,
|
||||
fGeometryProcessor, fXferProcessor, fFragmentProcessors.get(),
|
||||
fGeometryProcessor,
|
||||
fXferProcessor,
|
||||
fFragmentProcessors.get(),
|
||||
&fSamplerUniforms);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "GrPipeline.h"
|
||||
#include "gl/GrGLProgramDataManager.h"
|
||||
#include "gl/GrGLUniformHandler.h"
|
||||
#include "gl/GrGLVaryingHandler.h"
|
||||
#include "glsl/GrGLSLPrimitiveProcessor.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
@ -58,32 +59,13 @@ public:
|
||||
*/
|
||||
static GrGLProgram* CreateProgram(const DrawArgs&, GrGLGpu*);
|
||||
|
||||
const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override {
|
||||
return fUniforms[u.toIndex()].fVariable;
|
||||
}
|
||||
|
||||
const char* getUniformCStr(UniformHandle u) const override {
|
||||
return this->getUniformVariable(u).c_str();
|
||||
}
|
||||
|
||||
const GrGLSLCaps* glslCaps() const override;
|
||||
|
||||
GrGLGpu* gpu() const { return fGpu; }
|
||||
|
||||
private:
|
||||
typedef GrGLProgramDataManager::UniformInfo UniformInfo;
|
||||
typedef GrGLProgramDataManager::UniformInfoArray UniformInfoArray;
|
||||
|
||||
GrGLProgramBuilder(GrGLGpu*, const DrawArgs&);
|
||||
|
||||
UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
const char** outName) override;
|
||||
|
||||
// Generates a possibly mangled name for a stage variable and writes it to the fragment shader.
|
||||
// If GrGLSLExpr4 has a valid name then it will use that instead
|
||||
void nameExpression(GrGLSLExpr4*, const char* baseName);
|
||||
@ -133,8 +115,8 @@ private:
|
||||
// Subclasses create different programs
|
||||
GrGLProgram* createProgram(GrGLuint programID);
|
||||
|
||||
void onAppendUniformDecls(ShaderVisibility visibility, SkString* out) const override;
|
||||
|
||||
GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; }
|
||||
const GrGLSLUniformHandler* uniformHandler() const override { return &fUniformHandler; }
|
||||
GrGLSLVaryingHandler* varyingHandler() override { return &fVaryingHandler; }
|
||||
|
||||
// reset is called by program creator between each processor's emit code. It increments the
|
||||
@ -164,14 +146,13 @@ private:
|
||||
SkAutoTUnref<GrGLInstalledFragProcs> fFragmentProcessors;
|
||||
|
||||
GrGLGpu* fGpu;
|
||||
UniformInfoArray fUniforms;
|
||||
GrGLSLPrimitiveProcessor::TransformsIn fCoordTransforms;
|
||||
GrGLSLPrimitiveProcessor::TransformsOut fOutCoords;
|
||||
typedef GrGLSLUniformHandler::UniformHandle UniformHandle;
|
||||
SkTArray<UniformHandle> fSamplerUniforms;
|
||||
|
||||
GrGLVaryingHandler fVaryingHandler;
|
||||
|
||||
friend class GrGLVaryingHandler;
|
||||
GrGLUniformHandler fUniformHandler;
|
||||
|
||||
typedef GrGLSLProgramBuilder INHERITED;
|
||||
};
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "GrFragmentProcessor.h"
|
||||
#include "GrProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
void GrGLSLFragmentProcessor::setData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& processor) {
|
||||
@ -93,8 +93,8 @@ void GrGLSLFragmentProcessor::internalEmitChild(int childIndex, const char* inpu
|
||||
fragBuilder->codeAppend("{\n");
|
||||
fragBuilder->codeAppendf("// Child Index %d (mangle: %s): %s\n", childIndex,
|
||||
fragBuilder->getMangleString().c_str(), childProc.name());
|
||||
EmitArgs childArgs(args.fBuilder,
|
||||
fragBuilder,
|
||||
EmitArgs childArgs(fragBuilder,
|
||||
args.fUniformHandler,
|
||||
args.fGLSLCaps,
|
||||
childProc,
|
||||
outputColor,
|
||||
|
@ -14,9 +14,10 @@
|
||||
|
||||
class GrProcessor;
|
||||
class GrProcessorKeyBuilder;
|
||||
class GrGLSLCaps;
|
||||
class GrGLSLFPBuilder;
|
||||
class GrGLSLFragmentBuilder;
|
||||
class GrGLSLCaps;
|
||||
class GrGLSLUniformHandler;
|
||||
|
||||
class GrGLSLFragmentProcessor {
|
||||
public:
|
||||
@ -51,24 +52,24 @@ public:
|
||||
*/
|
||||
|
||||
struct EmitArgs {
|
||||
EmitArgs(GrGLSLFPBuilder* builder,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
EmitArgs(GrGLSLFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* caps,
|
||||
const GrFragmentProcessor& fp,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const GrGLSLTransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers)
|
||||
: fBuilder(builder)
|
||||
, fFragBuilder(fragBuilder)
|
||||
: fFragBuilder(fragBuilder)
|
||||
, fUniformHandler(uniformHandler)
|
||||
, fGLSLCaps(caps)
|
||||
, fFp(fp)
|
||||
, fOutputColor(outputColor)
|
||||
, fInputColor(inputColor)
|
||||
, fCoords(coords)
|
||||
, fSamplers(samplers) {}
|
||||
GrGLSLFPBuilder* fBuilder;
|
||||
GrGLSLFragmentBuilder* fFragBuilder;
|
||||
GrGLSLUniformHandler* fUniformHandler;
|
||||
const GrGLSLCaps* fGLSLCaps;
|
||||
const GrFragmentProcessor& fFp;
|
||||
const char* fOutputColor;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "glsl/GrGLSL.h"
|
||||
#include "glsl/GrGLSLCaps.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
|
||||
const char* GrGLSLFragmentShaderBuilder::kDstTextureColorName = "_dstColor";
|
||||
@ -136,15 +137,9 @@ const char* GrGLSLFragmentShaderBuilder::fragmentPosition() {
|
||||
static const char* kTempName = "tmpXYFragCoord";
|
||||
static const char* kCoordName = "fragCoordYDown";
|
||||
if (!fSetupFragPosition) {
|
||||
SkASSERT(!fProgramBuilder->fUniformHandles.fRTHeightUni.isValid());
|
||||
const char* rtHeightName;
|
||||
|
||||
fProgramBuilder->fUniformHandles.fRTHeightUni =
|
||||
fProgramBuilder->addFragPosUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
kFloat_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"RTHeight",
|
||||
&rtHeightName);
|
||||
fProgramBuilder->addRTHeightUniform("RTHeight", &rtHeightName);
|
||||
|
||||
// The Adreno compiler seems to be very touchy about access to "gl_FragCoord".
|
||||
// Accessing glFragCoord.zw can cause a program to fail to link. Additionally,
|
||||
|
@ -7,9 +7,10 @@
|
||||
|
||||
#include "GrGLSLGeometryProcessor.h"
|
||||
|
||||
#include "GrCoordTransform.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProcessorTypes.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
@ -20,9 +21,9 @@ void GrGLSLGeometryProcessor::emitCode(EmitArgs& args) {
|
||||
vBuilder->transformToNormalizedDeviceSpace(gpArgs.fPositionVar);
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
|
||||
GrGLSLVertexBuilder* vb,
|
||||
void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
|
||||
GrGLSLVaryingHandler* varyingHandler,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrShaderVar& posVar,
|
||||
const char* localCoords,
|
||||
const SkMatrix& localMatrix,
|
||||
@ -49,7 +50,7 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
|
||||
|
||||
const char* uniName;
|
||||
fInstalledTransforms[i][t].fHandle =
|
||||
pb->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
|
||||
uniformHandler->addUniform(GrGLSLUniformHandler::kVertex_Visibility,
|
||||
kMat33f_GrSLType, precision,
|
||||
strUniName.c_str(),
|
||||
&uniName).toIndex();
|
||||
@ -94,8 +95,7 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
|
||||
GrGLSLVertexBuilder* vb,
|
||||
void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
|
||||
GrGLSLVaryingHandler* varyingHandler,
|
||||
const char* localCoords,
|
||||
const TransformsIn& tin,
|
||||
@ -124,16 +124,15 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLGPBuilder* pb,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb,
|
||||
GrGLSLVertexBuilder* vertBuilder,
|
||||
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName) {
|
||||
gpArgs->fPositionVar.set(kVec2f_GrSLType, "pos2");
|
||||
vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
}
|
||||
|
||||
void GrGLSLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb,
|
||||
GrGLSLVertexBuilder* vertBuilder,
|
||||
void GrGLSLGeometryProcessor::setupPosition(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
GrGPArgs* gpArgs,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
@ -143,7 +142,7 @@ void GrGLSLGeometryProcessor::setupPosition(GrGLSLGPBuilder* pb,
|
||||
vertBuilder->codeAppendf("vec2 %s = %s;", gpArgs->fPositionVar.c_str(), posName);
|
||||
} else {
|
||||
const char* viewMatrixName;
|
||||
*viewMatrixUniform = pb->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
|
||||
*viewMatrixUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kVertex_Visibility,
|
||||
kMat33f_GrSLType, kHigh_GrSLPrecision,
|
||||
"uViewM",
|
||||
&viewMatrixName);
|
||||
|
@ -42,20 +42,21 @@ public:
|
||||
|
||||
protected:
|
||||
// Emit a uniform matrix for each coord transform.
|
||||
void emitTransforms(GrGLSLGPBuilder* gp,
|
||||
GrGLSLVertexBuilder* vb,
|
||||
void emitTransforms(GrGLSLVertexBuilder* vb,
|
||||
GrGLSLVaryingHandler* varyingHandler,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrShaderVar& posVar,
|
||||
const char* localCoords,
|
||||
const TransformsIn& tin,
|
||||
TransformsOut* tout) {
|
||||
this->emitTransforms(gp, vb, varyingHandler, posVar, localCoords, SkMatrix::I(), tin, tout);
|
||||
this->emitTransforms(vb, varyingHandler, uniformHandler,
|
||||
posVar, localCoords, SkMatrix::I(), tin, tout);
|
||||
}
|
||||
|
||||
// Emit pre-transformed coords as a vertex attribute per coord-transform.
|
||||
void emitTransforms(GrGLSLGPBuilder*,
|
||||
GrGLSLVertexBuilder*,
|
||||
void emitTransforms(GrGLSLVertexBuilder*,
|
||||
GrGLSLVaryingHandler*,
|
||||
GrGLSLUniformHandler*,
|
||||
const GrShaderVar& posVar,
|
||||
const char* localCoords,
|
||||
const SkMatrix& localMatrix,
|
||||
@ -63,8 +64,7 @@ protected:
|
||||
TransformsOut*);
|
||||
|
||||
// caller has emitted transforms via attributes
|
||||
void emitTransforms(GrGLSLGPBuilder*,
|
||||
GrGLSLVertexBuilder*,
|
||||
void emitTransforms(GrGLSLVertexBuilder*,
|
||||
GrGLSLVaryingHandler*,
|
||||
const char* localCoords,
|
||||
const TransformsIn& tin,
|
||||
@ -77,9 +77,9 @@ protected:
|
||||
};
|
||||
|
||||
// Create the correct type of position variable given the CTM
|
||||
void setupPosition(GrGLSLGPBuilder*, GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
|
||||
void setupPosition(GrGLSLGPBuilder*,
|
||||
GrGLSLVertexBuilder*,
|
||||
void setupPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
|
||||
void setupPosition(GrGLSLVertexBuilder*,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
GrGPArgs*,
|
||||
const char* posName,
|
||||
const SkMatrix& mat,
|
||||
|
@ -7,8 +7,10 @@
|
||||
|
||||
#include "GrGLSLPrimitiveProcessor.h"
|
||||
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatrix,
|
||||
const GrCoordTransform& coordTransform) {
|
||||
@ -32,13 +34,13 @@ SkMatrix GrGLSLPrimitiveProcessor::GetTransformMatrix(const SkMatrix& localMatri
|
||||
return combined;
|
||||
}
|
||||
|
||||
void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLGPBuilder* pb,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
void GrGLSLPrimitiveProcessor::setupUniformColor(GrGLSLFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const char* outputName,
|
||||
UniformHandle* colorUniform) {
|
||||
SkASSERT(colorUniform);
|
||||
const char* stagedLocalVarName;
|
||||
*colorUniform = pb->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
*colorUniform = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"Color",
|
||||
|
@ -18,6 +18,7 @@ class GrPrimitiveProcessor;
|
||||
class GrGLSLCaps;
|
||||
class GrGLSLFragmentBuilder;
|
||||
class GrGLSLGPBuilder;
|
||||
class GrGLSLUniformHandler;
|
||||
class GrGLSLVaryingHandler;
|
||||
class GrGLSLVertexBuilder;
|
||||
|
||||
@ -33,10 +34,10 @@ public:
|
||||
typedef SkSTArray<8, GrGLSLTransformedCoordsArray> TransformsOut;
|
||||
|
||||
struct EmitArgs {
|
||||
EmitArgs(GrGLSLGPBuilder* pb,
|
||||
GrGLSLVertexBuilder* vertBuilder,
|
||||
EmitArgs(GrGLSLVertexBuilder* vertBuilder,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
GrGLSLVaryingHandler* varyingHandler,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* caps,
|
||||
const GrPrimitiveProcessor& gp,
|
||||
const char* outputColor,
|
||||
@ -44,10 +45,10 @@ public:
|
||||
const TextureSamplerArray& samplers,
|
||||
const TransformsIn& transformsIn,
|
||||
TransformsOut* transformsOut)
|
||||
: fPB(pb)
|
||||
, fVertBuilder(vertBuilder)
|
||||
: fVertBuilder(vertBuilder)
|
||||
, fFragBuilder(fragBuilder)
|
||||
, fVaryingHandler(varyingHandler)
|
||||
, fUniformHandler(uniformHandler)
|
||||
, fGLSLCaps(caps)
|
||||
, fGP(gp)
|
||||
, fOutputColor(outputColor)
|
||||
@ -55,10 +56,10 @@ public:
|
||||
, fSamplers(samplers)
|
||||
, fTransformsIn(transformsIn)
|
||||
, fTransformsOut(transformsOut) {}
|
||||
GrGLSLGPBuilder* fPB;
|
||||
GrGLSLVertexBuilder* fVertBuilder;
|
||||
GrGLSLFragmentBuilder* fFragBuilder;
|
||||
GrGLSLVaryingHandler* fVaryingHandler;
|
||||
GrGLSLUniformHandler* fUniformHandler;
|
||||
const GrGLSLCaps* fGLSLCaps;
|
||||
const GrPrimitiveProcessor& fGP;
|
||||
const char* fOutputColor;
|
||||
@ -91,8 +92,8 @@ public:
|
||||
const SkTArray<const GrCoordTransform*, true>& transforms) = 0;
|
||||
|
||||
protected:
|
||||
void setupUniformColor(GrGLSLGPBuilder* pb,
|
||||
GrGLSLFragmentBuilder* fragBuilder,
|
||||
void setupUniformColor(GrGLSLFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const char* outputName,
|
||||
UniformHandle* colorUniform);
|
||||
|
||||
|
@ -34,6 +34,27 @@ void GrGLSLProgramBuilder::nameVariable(SkString* out, char prefix, const char*
|
||||
|
||||
void GrGLSLProgramBuilder::appendUniformDecls(ShaderVisibility visibility,
|
||||
SkString* out) const {
|
||||
this->onAppendUniformDecls(visibility, out);
|
||||
this->uniformHandler()->appendUniformDecls(visibility, out);
|
||||
}
|
||||
|
||||
void GrGLSLProgramBuilder::addRTAdjustmentUniform(GrSLPrecision precision,
|
||||
const char* name,
|
||||
const char** outName) {
|
||||
SkASSERT(!fUniformHandles.fRTAdjustmentUni.isValid());
|
||||
fUniformHandles.fRTAdjustmentUni =
|
||||
this->uniformHandler()->addUniform(GrGLSLUniformHandler::kVertex_Visibility,
|
||||
kVec4f_GrSLType,
|
||||
precision,
|
||||
name,
|
||||
outName);
|
||||
}
|
||||
|
||||
void GrGLSLProgramBuilder::addRTHeightUniform(const char* name, const char** outName) {
|
||||
SkASSERT(!fUniformHandles.fRTHeightUni.isValid());
|
||||
GrGLSLUniformHandler* uniformHandler = this->uniformHandler();
|
||||
fUniformHandles.fRTHeightUni =
|
||||
uniformHandler->internalAddUniformArray(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kFloat_GrSLType, kDefault_GrSLPrecision,
|
||||
name, false, 0, outName);
|
||||
}
|
||||
|
||||
|
@ -13,105 +13,30 @@
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLGeometryShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVertexShaderBuilder.h"
|
||||
|
||||
class GrGLSLCaps;
|
||||
class GrGLSLShaderVar;
|
||||
class GrGLSLVaryingHandler;
|
||||
|
||||
// Enough precision to represent 1 / 2048 accurately in printf
|
||||
#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
|
||||
|
||||
class GrGLSLUniformBuilder {
|
||||
public:
|
||||
enum ShaderVisibility {
|
||||
kVertex_Visibility = 1 << kVertex_GrShaderType,
|
||||
kGeometry_Visibility = 1 << kGeometry_GrShaderType,
|
||||
kFragment_Visibility = 1 << kFragment_GrShaderType,
|
||||
};
|
||||
|
||||
virtual ~GrGLSLUniformBuilder() {}
|
||||
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
/** Add a uniform variable to the current program, that has visibility in one or more shaders.
|
||||
visibility is a bitfield of ShaderVisibility values indicating from which shaders the
|
||||
uniform should be accessible. At least one bit must be set. Geometry shader uniforms are not
|
||||
supported at this time. The actual uniform name will be mangled. If outName is not nullptr
|
||||
then it will refer to the final uniform name after return. Use the addUniformArray variant
|
||||
to add an array of uniforms. */
|
||||
UniformHandle addUniform(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
const char** outName = nullptr) {
|
||||
return this->addUniformArray(visibility, type, precision, name, 0, outName);
|
||||
}
|
||||
|
||||
UniformHandle addUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
int arrayCount,
|
||||
const char** outName = nullptr) {
|
||||
return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount,
|
||||
outName);
|
||||
}
|
||||
|
||||
virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
|
||||
/**
|
||||
* Shortcut for getUniformVariable(u).c_str()
|
||||
*/
|
||||
virtual const char* getUniformCStr(UniformHandle u) const = 0;
|
||||
|
||||
/*
|
||||
* *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
|
||||
*/
|
||||
protected:
|
||||
virtual UniformHandle internalAddUniformArray(
|
||||
uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
const char** outName) = 0;
|
||||
};
|
||||
|
||||
/* a specialization of the above for GPs. Lets the user add uniforms, varyings, and VS / FS code */
|
||||
class GrGLSLGPBuilder : public virtual GrGLSLUniformBuilder {
|
||||
public:
|
||||
/*
|
||||
* *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
/* a specializations for FPs. Lets the user add uniforms and FS code */
|
||||
class GrGLSLFPBuilder : public virtual GrGLSLUniformBuilder {
|
||||
public:
|
||||
/*
|
||||
* *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
|
||||
*/
|
||||
};
|
||||
|
||||
/* a specializations for XPs. Lets the user add uniforms and FS code */
|
||||
class GrGLSLXPBuilder : public virtual GrGLSLUniformBuilder {
|
||||
public:
|
||||
/*
|
||||
* *NOTE* NO MEMBERS ALLOWED, MULTIPLE INHERITANCE
|
||||
*/
|
||||
};
|
||||
|
||||
class GrGLSLProgramBuilder : public GrGLSLGPBuilder,
|
||||
public GrGLSLFPBuilder,
|
||||
public GrGLSLXPBuilder {
|
||||
class GrGLSLProgramBuilder {
|
||||
public:
|
||||
typedef GrGpu::DrawArgs DrawArgs;
|
||||
typedef GrGLSLUniformHandler::ShaderVisibility ShaderVisibility;
|
||||
typedef GrGLSLUniformHandler::UniformHandle UniformHandle;
|
||||
|
||||
virtual ~GrGLSLProgramBuilder() {}
|
||||
|
||||
virtual const GrGLSLCaps* glslCaps() const = 0;
|
||||
|
||||
const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrimitiveProcessor; }
|
||||
const GrPipeline& pipeline() const { return *fArgs.fPipeline; }
|
||||
const GrProgramDesc& desc() const { return *fArgs.fDesc; }
|
||||
const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(); }
|
||||
|
||||
void appendUniformDecls(ShaderVisibility, SkString*) const;
|
||||
|
||||
// Handles for program uniforms (other than per-effect uniforms)
|
||||
struct BuiltinUniformHandles {
|
||||
UniformHandle fRTAdjustmentUni;
|
||||
@ -121,33 +46,21 @@ public:
|
||||
UniformHandle fRTHeightUni;
|
||||
};
|
||||
|
||||
protected:
|
||||
explicit GrGLSLProgramBuilder(const DrawArgs& args);
|
||||
|
||||
const GrPrimitiveProcessor& primitiveProcessor() const { return *fArgs.fPrimitiveProcessor; }
|
||||
const GrPipeline& pipeline() const { return *fArgs.fPipeline; }
|
||||
const GrProgramDesc& desc() const { return *fArgs.fDesc; }
|
||||
const GrProgramDesc::KeyHeader& header() const { return fArgs.fDesc->header(); }
|
||||
|
||||
void appendUniformDecls(ShaderVisibility, SkString*) const;
|
||||
|
||||
// Used to add a uniform for frag position without mangling the name of the uniform inside of a
|
||||
// stage.
|
||||
UniformHandle addFragPosUniform(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
const char** outName) {
|
||||
return this->internalAddUniformArray(visibility, type, precision, name, false, 0, outName);
|
||||
}
|
||||
|
||||
// Used to add a uniform in the vertex shader for transforming into normalized device space.
|
||||
void addRTAdjustmentUniform(GrSLPrecision precision, const char* name, const char** outName);
|
||||
const char* rtAdjustment() const { return "rtAdjustment"; }
|
||||
|
||||
// Used to add a uniform for the RenderTarget height (used for frag position) without mangling
|
||||
// the name of the uniform inside of a stage.
|
||||
void addRTHeightUniform(const char* name, const char** outName);
|
||||
|
||||
// Generates a name for a variable. The generated string will be name prefixed by the prefix
|
||||
// char (unless the prefix is '\0'). It also will mangle the name to be stage-specific unless
|
||||
// explicitly asked not to.
|
||||
void nameVariable(SkString* out, char prefix, const char* name, bool mangle = true);
|
||||
|
||||
virtual GrGLSLUniformHandler* uniformHandler() = 0;
|
||||
virtual const GrGLSLUniformHandler* uniformHandler() const = 0;
|
||||
virtual GrGLSLVaryingHandler* varyingHandler() = 0;
|
||||
|
||||
// number of each input/output type in a single allocation block, used by many builders
|
||||
@ -159,18 +72,12 @@ protected:
|
||||
|
||||
int fStageIndex;
|
||||
|
||||
BuiltinUniformHandles fUniformHandles;
|
||||
|
||||
const DrawArgs& fArgs;
|
||||
|
||||
private:
|
||||
virtual void onAppendUniformDecls(ShaderVisibility visibility, SkString* out) const = 0;
|
||||
BuiltinUniformHandles fUniformHandles;
|
||||
|
||||
friend class GrGLSLShaderBuilder;
|
||||
friend class GrGLSLVertexBuilder;
|
||||
friend class GrGLSLFragmentShaderBuilder;
|
||||
friend class GrGLSLGeometryBuilder;
|
||||
friend class GrGLSLVaryingHandler;
|
||||
protected:
|
||||
explicit GrGLSLProgramBuilder(const DrawArgs& args);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -117,9 +117,10 @@ void GrGLSLShaderBuilder::appendTextureLookup(SkString* out,
|
||||
const GrGLSLTextureSampler& sampler,
|
||||
const char* coordName,
|
||||
GrSLType varyingType) const {
|
||||
GrGLSLUniformHandler* uniformHandler = fProgramBuilder->uniformHandler();
|
||||
append_texture_lookup(out,
|
||||
fProgramBuilder->glslCaps(),
|
||||
fProgramBuilder->getUniformCStr(sampler.fSamplerUniform),
|
||||
uniformHandler->getUniformCStr(sampler.fSamplerUniform),
|
||||
coordName,
|
||||
sampler.config(),
|
||||
sampler.swizzle(),
|
||||
@ -187,7 +188,7 @@ void GrGLSLShaderBuilder::finalize(uint32_t visibility) {
|
||||
this->versionDecl() = fProgramBuilder->glslCaps()->versionDeclString();
|
||||
this->compileAndAppendLayoutQualifiers();
|
||||
SkASSERT(visibility);
|
||||
fProgramBuilder->appendUniformDecls((GrGLSLProgramBuilder::ShaderVisibility) visibility,
|
||||
fProgramBuilder->appendUniformDecls((GrGLSLUniformHandler::ShaderVisibility) visibility,
|
||||
&this->uniforms());
|
||||
this->appendDecls(fInputs, &this->inputs());
|
||||
this->appendDecls(fOutputs, &this->outputs());
|
||||
|
79
src/gpu/glsl/GrGLSLUniformHandler.h
Normal file
79
src/gpu/glsl/GrGLSLUniformHandler.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2015 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrGLSLUniformHandler_DEFINED
|
||||
#define GrGLSLUniformHandler_DEFINED
|
||||
|
||||
#include "GrGLSLProgramDataManager.h"
|
||||
#include "GrGLSLShaderVar.h"
|
||||
|
||||
class GrGLSLProgramBuilder;
|
||||
|
||||
class GrGLSLUniformHandler {
|
||||
public:
|
||||
enum ShaderVisibility {
|
||||
kVertex_Visibility = 1 << kVertex_GrShaderType,
|
||||
kGeometry_Visibility = 1 << kGeometry_GrShaderType,
|
||||
kFragment_Visibility = 1 << kFragment_GrShaderType,
|
||||
};
|
||||
|
||||
virtual ~GrGLSLUniformHandler() {}
|
||||
|
||||
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
/** Add a uniform variable to the current program, that has visibility in one or more shaders.
|
||||
visibility is a bitfield of ShaderVisibility values indicating from which shaders the
|
||||
uniform should be accessible. At least one bit must be set. Geometry shader uniforms are not
|
||||
supported at this time. The actual uniform name will be mangled. If outName is not nullptr
|
||||
then it will refer to the final uniform name after return. Use the addUniformArray variant
|
||||
to add an array of uniforms. */
|
||||
UniformHandle addUniform(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
const char** outName = nullptr) {
|
||||
return this->addUniformArray(visibility, type, precision, name, 0, outName);
|
||||
}
|
||||
|
||||
UniformHandle addUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
int arrayCount,
|
||||
const char** outName = nullptr) {
|
||||
return this->internalAddUniformArray(visibility, type, precision, name, true, arrayCount,
|
||||
outName);
|
||||
}
|
||||
|
||||
virtual const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const = 0;
|
||||
|
||||
/**
|
||||
* Shortcut for getUniformVariable(u).c_str()
|
||||
*/
|
||||
virtual const char* getUniformCStr(UniformHandle u) const = 0;
|
||||
protected:
|
||||
explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuilder(program) {}
|
||||
|
||||
// This is not owned by the class
|
||||
GrGLSLProgramBuilder* fProgramBuilder;
|
||||
|
||||
private:
|
||||
virtual UniformHandle internalAddUniformArray(uint32_t visibility,
|
||||
GrSLType type,
|
||||
GrSLPrecision precision,
|
||||
const char* name,
|
||||
bool mangleName,
|
||||
int arrayCount,
|
||||
const char** outName) = 0;
|
||||
|
||||
virtual void appendUniformDecls(ShaderVisibility, SkString*) const = 0;
|
||||
|
||||
friend class GrGLSLProgramBuilder;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "GrGLSLVertexShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
#include "glsl/GrGLSLVarying.h"
|
||||
|
||||
GrGLSLVertexBuilder::GrGLSLVertexBuilder(GrGLSLProgramBuilder* program)
|
||||
@ -23,9 +24,7 @@ void GrGLSLVertexBuilder::transformToNormalizedDeviceSpace(const GrShaderVar& po
|
||||
}
|
||||
|
||||
// setup RT Uniform
|
||||
fProgramBuilder->fUniformHandles.fRTAdjustmentUni =
|
||||
fProgramBuilder->addUniform(GrGLSLProgramBuilder::kVertex_Visibility,
|
||||
kVec4f_GrSLType, precision,
|
||||
fProgramBuilder->addRTAdjustmentUniform(precision,
|
||||
fProgramBuilder->rtAdjustment(),
|
||||
&fRtAdjustName);
|
||||
if (this->getProgramBuilder()->desc().header().fSnapVerticesToPixelCenters) {
|
||||
|
@ -13,6 +13,9 @@
|
||||
|
||||
class GrGLSLVarying;
|
||||
|
||||
// Enough precision to represent 1 / 2048 accurately in printf
|
||||
#define GR_SIGNIFICANT_POW2_DECIMAL_DIG 11
|
||||
|
||||
class GrGLSLVertexBuilder : public GrGLSLShaderBuilder {
|
||||
public:
|
||||
GrGLSLVertexBuilder(GrGLSLProgramBuilder* program);
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
#include "GrXferProcessor.h"
|
||||
#include "glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "glsl/GrGLSLProgramBuilder.h"
|
||||
#include "glsl/GrGLSLProgramDataManager.h"
|
||||
#include "glsl/GrGLSLUniformHandler.h"
|
||||
|
||||
void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
|
||||
if (!args.fXP.willReadDstColor()) {
|
||||
@ -19,6 +19,7 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
|
||||
}
|
||||
|
||||
GrGLSLXPFragmentBuilder* fragBuilder = args.fXPFragBuilder;
|
||||
GrGLSLUniformHandler* uniformHandler = args.fUniformHandler;
|
||||
const char* dstColor = fragBuilder->dstColor();
|
||||
|
||||
if (args.fXP.getDstTexture()) {
|
||||
@ -35,12 +36,12 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
|
||||
const char* dstTopLeftName;
|
||||
const char* dstCoordScaleName;
|
||||
|
||||
fDstTopLeftUni = args.fPB->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDstTopLeftUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"DstTextureUpperLeft",
|
||||
&dstTopLeftName);
|
||||
fDstScaleUni = args.fPB->addUniform(GrGLSLProgramBuilder::kFragment_Visibility,
|
||||
fDstScaleUni = uniformHandler->addUniform(GrGLSLUniformHandler::kFragment_Visibility,
|
||||
kVec2f_GrSLType,
|
||||
kDefault_GrSLPrecision,
|
||||
"DstTextureCoordScale",
|
||||
@ -60,8 +61,8 @@ void GrGLSLXferProcessor::emitCode(const EmitArgs& args) {
|
||||
fragBuilder->codeAppend(";");
|
||||
}
|
||||
|
||||
this->emitBlendCodeForDstRead(args.fPB,
|
||||
fragBuilder,
|
||||
this->emitBlendCodeForDstRead(fragBuilder,
|
||||
uniformHandler,
|
||||
args.fInputColor,
|
||||
args.fInputCoverage,
|
||||
dstColor,
|
||||
|
@ -12,9 +12,10 @@
|
||||
#include "glsl/GrGLSLTextureSampler.h"
|
||||
|
||||
class GrXferProcessor;
|
||||
class GrGLSLCaps;
|
||||
class GrGLSLUniformHandler;
|
||||
class GrGLSLXPBuilder;
|
||||
class GrGLSLXPFragmentBuilder;
|
||||
class GrGLSLCaps;
|
||||
|
||||
class GrGLSLXferProcessor {
|
||||
public:
|
||||
@ -23,8 +24,8 @@ public:
|
||||
|
||||
typedef GrGLSLTextureSampler::TextureSamplerArray TextureSamplerArray;
|
||||
struct EmitArgs {
|
||||
EmitArgs(GrGLSLXPBuilder* pb,
|
||||
GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
EmitArgs(GrGLSLXPFragmentBuilder* fragBuilder,
|
||||
GrGLSLUniformHandler* uniformHandler,
|
||||
const GrGLSLCaps* caps,
|
||||
const GrXferProcessor& xp,
|
||||
const char* inputColor,
|
||||
@ -32,8 +33,8 @@ public:
|
||||
const char* outputPrimary,
|
||||
const char* outputSecondary,
|
||||
const TextureSamplerArray& samplers)
|
||||
: fPB(pb)
|
||||
, fXPFragBuilder(fragBuilder)
|
||||
: fXPFragBuilder(fragBuilder)
|
||||
, fUniformHandler(uniformHandler)
|
||||
, fGLSLCaps(caps)
|
||||
, fXP(xp)
|
||||
, fInputColor(inputColor)
|
||||
@ -42,8 +43,8 @@ public:
|
||||
, fOutputSecondary(outputSecondary)
|
||||
, fSamplers(samplers) {}
|
||||
|
||||
GrGLSLXPBuilder* fPB;
|
||||
GrGLSLXPFragmentBuilder* fXPFragBuilder;
|
||||
GrGLSLUniformHandler* fUniformHandler;
|
||||
const GrGLSLCaps* fGLSLCaps;
|
||||
const GrXferProcessor& fXP;
|
||||
const char* fInputColor;
|
||||
@ -82,8 +83,8 @@ private:
|
||||
* the blending logic. The base class applies coverage. A subclass only needs to implement this
|
||||
* method if it can construct a GrXferProcessor that reads the dst color.
|
||||
*/
|
||||
virtual void emitBlendCodeForDstRead(GrGLSLXPBuilder*,
|
||||
GrGLSLXPFragmentBuilder*,
|
||||
virtual void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder*,
|
||||
GrGLSLUniformHandler*,
|
||||
const char* srcColor,
|
||||
const char* srcCoverage,
|
||||
const char* dstColor,
|
||||
|
Loading…
Reference in New Issue
Block a user