| 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 | * 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). |
| 26 | */ |
| 27 | class GrGeometryProcessor : public GrPrimitiveProcessor { |
| 28 | public: |
| 29 | GrGeometryProcessor(ClassID classID) : INHERITED(classID) {} |
| 30 | |
| 31 | protected: |
| 32 | // GPs that need to use either float or ubyte colors can just call this to get a correctly |
| 33 | // configured Attribute struct |
| 34 | static Attribute MakeColorAttribute(const char* name, bool wideColor) { |
| 35 | return { name, |
| 36 | wideColor ? kFloat4_GrVertexAttribType : kUByte4_norm_GrVertexAttribType, |
| 37 | kHalf4_GrSLType }; |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | typedef GrPrimitiveProcessor INHERITED; |
| 42 | }; |
| 43 | |
| 44 | #endif |
| 45 | |