OLD | NEW |
---|---|
(Empty) | |
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 "GrProcessor.h" | |
12 class GrBackendGeometryProcessorFactory; | |
bsalomon
2014/09/22 14:56:38
Can this file live in src/gpu?
joshua.litt
2014/09/22 18:14:44
I will move it in a future CL, along with the fact
| |
13 | |
14 /** | |
15 * If an effect needs specialized vertex shader code, then it must inherit from this class. | |
bsalomon
2014/09/22 14:56:38
How about something like:
A GrGeomteryProcessor i
| |
16 * Otherwise it won't be able to add vertex attribs, and it might be given a ver texless shader | |
17 * program in emitCode. | |
18 */ | |
19 class GrGeometryProcessor : public GrProcessor { | |
20 public: | |
21 GrGeometryProcessor() {} | |
22 | |
23 virtual const GrBackendGeometryProcessorFactory& getFactory() const = 0; | |
24 | |
25 static const int kMaxVertexAttribs = 2; | |
26 typedef SkSTArray<kMaxVertexAttribs, GrShaderVar, true> VertexAttribArray; | |
bsalomon
2014/09/22 14:56:38
Is it really a max of two? Why use a dynamic array
joshua.litt
2014/09/22 18:14:44
This is just because of GLProgramsTest. Eventuall
| |
27 | |
28 const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; } | |
29 | |
30 protected: | |
31 /** | |
32 * Subclasses call this from their constructor to register vertex attributes (at most | |
33 * kMaxVertexAttribs). This must only be called from the constructor because GrProcessors are | |
34 * immutable. | |
35 */ | |
36 const GrShaderVar& addVertexAttrib(const GrShaderVar& var) { | |
37 SkASSERT(fVertexAttribs.count() < kMaxVertexAttribs); | |
38 return fVertexAttribs.push_back(var); | |
39 } | |
40 | |
41 private: | |
42 VertexAttribArray fVertexAttribs; | |
43 | |
44 typedef GrProcessor INHERITED; | |
45 }; | |
46 | |
47 /** | |
48 * This creates an effect outside of the effect memory pool. The effect's destru ctor will be called | |
49 * at global destruction time. NAME will be the name of the created GrProcessor. | |
50 */ | |
51 #define GR_CREATE_STATIC_GEOMETRY_PROCESSOR(NAME, GP_CLASS, ARGS) \ | |
52 static SkAlignedSStorage<sizeof(GP_CLASS)> g_##NAME##_Storage; \ | |
53 static GrGeometryProcessor* NAME SkNEW_PLACEMENT_ARGS(g_##NAME##_Storage.get(), GP_CLASS, ARGS); \ | |
54 static SkAutoTDestroy<GrGeometryProcessor> NAME##_ad(NAME); | |
55 | |
56 #endif | |
OLD | NEW |