1 /* 2 * Copyright 2013 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrGeometryProcessor_DEFINED 9 #define GrGeometryProcessor_DEFINED 10 11 #include "src/gpu/GrPrimitiveProcessor.h" 12 13 /** 14 * A GrGeometryProcessor is a flexible method for rendering a primitive. The GrGeometryProcessor 15 * has complete control over vertex attributes and uniforms(aside from the render target) but it 16 * must obey the same contract as any GrPrimitiveProcessor, specifically it must emit a color and 17 * coverage into the fragment shader. Where this color and coverage come from is completely the 18 * responsibility of the GrGeometryProcessor. 19 */ 20 class GrGeometryProcessor : public GrPrimitiveProcessor { 21 public: GrGeometryProcessor(ClassID classID)22 GrGeometryProcessor(ClassID classID) 23 : INHERITED(classID) 24 , fWillUseGeoShader(false) {} 25 willUseGeoShader()26 bool willUseGeoShader() const final { return fWillUseGeoShader; } 27 28 protected: setWillUseGeoShader()29 void setWillUseGeoShader() { fWillUseGeoShader = true; } 30 31 // GPs that need to use either half-float or ubyte colors can just call this to get a correctly 32 // configured Attribute struct MakeColorAttribute(const char * name,bool wideColor)33 static Attribute MakeColorAttribute(const char* name, bool wideColor) { 34 return { name, 35 wideColor ? kHalf4_GrVertexAttribType : kUByte4_norm_GrVertexAttribType, 36 kHalf4_GrSLType }; 37 } 38 39 private: 40 bool fWillUseGeoShader; 41 42 typedef GrPrimitiveProcessor INHERITED; 43 }; 44 45 #endif 46