2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrGLGeometryProcessor_DEFINED
9 #define GrGLGeometryProcessor_DEFINED
11 #include "GrGLPrimitiveProcessor.h"
16 * If a GL effect needs a GrGLFullShaderBuilder* object to emit vertex code, then it must inherit
17 * from this class. Since paths don't have vertices, this class is only meant to be used internally
18 * by skia, for special cases.
20 class GrGLGeometryProcessor : public GrGLPrimitiveProcessor {
22 /* Any general emit code goes in the base class emitCode. Subclasses override onEmitCode */
23 void emitCode(EmitArgs&) override;
25 void setTransformData(const GrPrimitiveProcessor&,
26 const GrGLProgramDataManager&,
28 const SkTArray<const GrCoordTransform*, true>& transforms);
31 // Many GrGeometryProcessors do not need explicit local coords
32 void emitTransforms(GrGLGPBuilder* gp,
33 const GrShaderVar& posVar,
34 const SkMatrix& localMatrix,
35 const TransformsIn& tin,
36 TransformsOut* tout) {
37 this->emitTransforms(gp, posVar, posVar.c_str(), localMatrix, tin, tout);
40 void emitTransforms(GrGLGPBuilder*,
41 const GrShaderVar& posVar,
42 const char* localCoords,
43 const SkMatrix& localMatrix,
48 // The variable used by a GP to store its position. It can be
49 // either a vec2 or a vec3 depending on the presence of perspective.
50 GrShaderVar fPositionVar;
53 // Create the correct type of position variable given the CTM
54 void setupPosition(GrGLGPBuilder* pb,
59 static uint32_t ComputePosKey(const SkMatrix& mat) {
60 if (mat.isIdentity()) {
62 } else if (!mat.hasPerspective()) {
70 virtual void onEmitCode(EmitArgs&, GrGPArgs*) = 0;
72 typedef GrGLPrimitiveProcessor INHERITED;