blob: f0f8a7453d3d7b3b06672d729a866de2036d694a [file] [log] [blame]
joshualittb0a8a372014-09-23 09:50:21 -07001/*
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
joshualitt8072caa2015-02-12 14:20:52 -080011#include "GrPrimitiveProcessor.h"
joshualitt9b989322014-12-15 14:16:27 -080012
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 */
20class GrGeometryProcessor : public GrPrimitiveProcessor {
21public:
Ethan Nicholasabff9562017-10-09 10:54:08 -040022 GrGeometryProcessor(ClassID classID)
23 : INHERITED(classID)
Brian Osmana63593a2018-12-06 15:54:53 -050024 , fWillUseGeoShader(false) {}
joshualitt9b989322014-12-15 14:16:27 -080025
Brian Salomon7f235432017-08-16 09:41:48 -040026 bool willUseGeoShader() const final { return fWillUseGeoShader; }
joshualitt74077b92014-10-24 11:26:03 -070027
joshualittb0a8a372014-09-23 09:50:21 -070028protected:
joshualitt74077b92014-10-24 11:26:03 -070029 void setWillUseGeoShader() { fWillUseGeoShader = true; }
ethannicholas28ef4452016-03-25 09:26:03 -070030
Brian Osmanc906d252018-12-04 11:17:46 -050031 // GPs that need to use either half-float or ubyte colors can just call this to get a correctly
32 // configured Attribute struct
33 static Attribute MakeColorAttribute(const char* name, bool wideColor) {
34 return { name,
35 wideColor ? kHalf4_GrVertexAttribType : kUByte4_norm_GrVertexAttribType,
36 kHalf4_GrSLType };
37 }
38
joshualittb0a8a372014-09-23 09:50:21 -070039private:
joshualitt74077b92014-10-24 11:26:03 -070040 bool fWillUseGeoShader;
joshualittb0a8a372014-09-23 09:50:21 -070041
joshualitt290c09b2014-12-19 13:45:20 -080042 typedef GrPrimitiveProcessor INHERITED;
joshualittb0a8a372014-09-23 09:50:21 -070043};
joshualitt56995b52014-12-11 15:44:02 -080044
joshualittb0a8a372014-09-23 09:50:21 -070045#endif