joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 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 | |
joshualitt | 8072caa | 2015-02-12 14:20:52 -0800 | [diff] [blame] | 11 | #include "GrPrimitiveProcessor.h" |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 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: |
Ethan Nicholas | abff956 | 2017-10-09 10:54:08 -0400 | [diff] [blame] | 22 | GrGeometryProcessor(ClassID classID) |
| 23 | : INHERITED(classID) |
Brian Osman | a63593a | 2018-12-06 15:54:53 -0500 | [diff] [blame] | 24 | , fWillUseGeoShader(false) {} |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 25 | |
Brian Salomon | 7f23543 | 2017-08-16 09:41:48 -0400 | [diff] [blame] | 26 | bool willUseGeoShader() const final { return fWillUseGeoShader; } |
joshualitt | 74077b9 | 2014-10-24 11:26:03 -0700 | [diff] [blame] | 27 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 28 | protected: |
joshualitt | 74077b9 | 2014-10-24 11:26:03 -0700 | [diff] [blame] | 29 | void setWillUseGeoShader() { fWillUseGeoShader = true; } |
ethannicholas | 28ef445 | 2016-03-25 09:26:03 -0700 | [diff] [blame] | 30 | |
Brian Osman | c906d25 | 2018-12-04 11:17:46 -0500 | [diff] [blame] | 31 | // 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 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 39 | private: |
joshualitt | 74077b9 | 2014-10-24 11:26:03 -0700 | [diff] [blame] | 40 | bool fWillUseGeoShader; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 41 | |
joshualitt | 290c09b | 2014-12-19 13:45:20 -0800 | [diff] [blame] | 42 | typedef GrPrimitiveProcessor INHERITED; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 43 | }; |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 44 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 45 | #endif |