* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrGLSLGeometryProcessor_DEFINED
#define GrGLSLGeometryProcessor_DEFINED
#include "src/gpu/glsl/GrGLSLPrimitiveProcessor.h"
class GrGLSLGPBuilder;
* If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit
* from this class. Since paths don't have vertices, this class is only meant to be used internally
* by skia, for special cases.
*/
class GrGLSLGeometryProcessor : public GrGLSLPrimitiveProcessor {
public:
void emitCode(EmitArgs&) final;
protected:
void setTransformDataHelper(const SkMatrix& localMatrix,
const GrGLSLProgramDataManager& pdman,
FPCoordTransformIter*);
void emitTransforms(GrGLSLVertexBuilder*,
GrGLSLVaryingHandler*,
GrGLSLUniformHandler*,
const GrShaderVar& localCoordsVar,
const SkMatrix& localMatrix,
FPCoordTransformHandler*);
void emitTransforms(GrGLSLVertexBuilder* vb,
GrGLSLVaryingHandler* varyingHandler,
GrGLSLUniformHandler* uniformHandler,
const GrShaderVar& localCoordsVar,
FPCoordTransformHandler* handler) {
this->emitTransforms(vb, varyingHandler, uniformHandler, localCoordsVar, SkMatrix::I(),
handler);
}
struct GrGPArgs {
GrShaderVar fPositionVar;
};
void writeOutputPosition(GrGLSLVertexBuilder*, GrGPArgs*, const char* posName);
void writeOutputPosition(GrGLSLVertexBuilder*,
GrGLSLUniformHandler* uniformHandler,
GrGPArgs*,
const char* posName,
const SkMatrix& mat,
UniformHandle* viewMatrixUniform);
static uint32_t ComputePosKey(const SkMatrix& mat) {
if (mat.isIdentity()) {
return 0x0;
} else if (!mat.hasPerspective()) {
return 0x01;
} else {
return 0x02;
}
}
private:
virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
struct TransformUniform {
UniformHandle fHandle;
SkMatrix fCurrentValue = SkMatrix::InvalidMatrix();
};
SkTArray<TransformUniform, true> fInstalledTransforms;
typedef GrGLSLPrimitiveProcessor INHERITED;
};
#endif