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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/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 |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 15 | * has complete control over vertex attributes and uniforms (aside from the render target) but it |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 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. |
Robert Phillips | 7cd0bfe | 2019-11-20 16:08:10 -0500 | [diff] [blame] | 19 | * |
| 20 | * Note that all derived classes should hide their constructors and provide a Make factory |
| 21 | * function that takes an arena (except for CCPR-specific classes). This is because |
| 22 | * GrGeometryProcessor's are not ref-counted to must have some other mechanism for managing |
| 23 | * their lifetime. In particular, geometry processors can be created in either the |
| 24 | * record-time or flush-time arenas which defined their lifetimes (i.e., a DDLs life time in |
| 25 | * the first case and a single flush in the second case). |
joshualitt | 9b98932 | 2014-12-15 14:16:27 -0800 | [diff] [blame] | 26 | */ |
| 27 | class GrGeometryProcessor : public GrPrimitiveProcessor { |
| 28 | public: |
Chris Dalton | 5a2f962 | 2019-12-27 14:56:38 -0700 | [diff] [blame] | 29 | GrGeometryProcessor(ClassID classID) : INHERITED(classID) {} |
joshualitt | 74077b9 | 2014-10-24 11:26:03 -0700 | [diff] [blame] | 30 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 31 | protected: |
Brian Osman | 2715bf5 | 2019-12-06 14:38:47 -0500 | [diff] [blame] | 32 | // GPs that need to use either float or ubyte colors can just call this to get a correctly |
Brian Osman | c906d25 | 2018-12-04 11:17:46 -0500 | [diff] [blame] | 33 | // configured Attribute struct |
| 34 | static Attribute MakeColorAttribute(const char* name, bool wideColor) { |
| 35 | return { name, |
Brian Osman | 2715bf5 | 2019-12-06 14:38:47 -0500 | [diff] [blame] | 36 | wideColor ? kFloat4_GrVertexAttribType : kUByte4_norm_GrVertexAttribType, |
Brian Osman | c906d25 | 2018-12-04 11:17:46 -0500 | [diff] [blame] | 37 | kHalf4_GrSLType }; |
| 38 | } |
| 39 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 40 | private: |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 41 | using INHERITED = GrPrimitiveProcessor; |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 42 | }; |
joshualitt | 56995b5 | 2014-12-11 15:44:02 -0800 | [diff] [blame] | 43 | |
joshualitt | b0a8a37 | 2014-09-23 09:50:21 -0700 | [diff] [blame] | 44 | #endif |