blob: fd1fcf64552f550ae0ec4244ec74f7925386d2aa [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
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "src/gpu/GrPrimitiveProcessor.h"
joshualitt9b989322014-12-15 14:16:27 -080012
13/**
14 * A GrGeometryProcessor is a flexible method for rendering a primitive. The GrGeometryProcessor
Robert Phillips7cd0bfe2019-11-20 16:08:10 -050015 * has complete control over vertex attributes and uniforms (aside from the render target) but it
joshualitt9b989322014-12-15 14:16:27 -080016 * 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 Phillips7cd0bfe2019-11-20 16:08:10 -050019 *
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).
joshualitt9b989322014-12-15 14:16:27 -080026 */
27class GrGeometryProcessor : public GrPrimitiveProcessor {
28public:
Chris Dalton5a2f9622019-12-27 14:56:38 -070029 GrGeometryProcessor(ClassID classID) : INHERITED(classID) {}
joshualitt74077b92014-10-24 11:26:03 -070030
joshualittb0a8a372014-09-23 09:50:21 -070031protected:
Brian Osman2715bf52019-12-06 14:38:47 -050032 // GPs that need to use either float or ubyte colors can just call this to get a correctly
Brian Osmanc906d252018-12-04 11:17:46 -050033 // configured Attribute struct
34 static Attribute MakeColorAttribute(const char* name, bool wideColor) {
35 return { name,
Brian Osman2715bf52019-12-06 14:38:47 -050036 wideColor ? kFloat4_GrVertexAttribType : kUByte4_norm_GrVertexAttribType,
Brian Osmanc906d252018-12-04 11:17:46 -050037 kHalf4_GrSLType };
38 }
39
joshualittb0a8a372014-09-23 09:50:21 -070040private:
joshualitt290c09b2014-12-19 13:45:20 -080041 typedef GrPrimitiveProcessor INHERITED;
joshualittb0a8a372014-09-23 09:50:21 -070042};
joshualitt56995b52014-12-11 15:44:02 -080043
joshualittb0a8a372014-09-23 09:50:21 -070044#endif