OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGLProgramDesc_DEFINED | 8 #ifndef GrGLProgramDesc_DEFINED |
9 #define GrGLProgramDesc_DEFINED | 9 #define GrGLProgramDesc_DEFINED |
10 | 10 |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
12 #include "GrProgramDesc.h" | 12 #include "GrProgramDesc.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrTypesPriv.h" | 14 #include "GrTypesPriv.h" |
15 | 15 |
16 class GrGLGpu; | 16 class GrGLGpu; |
17 | 17 |
18 /** | 18 /** |
19 * This class can be used to build a GrProgramDesc. It also provides helpers fo
r accessing | 19 * This class can be used to build a GrProgramDesc. It also provides helpers fo
r accessing |
20 * GL specific info in the header. | 20 * GL specific info in the header. |
21 */ | 21 */ |
22 class GrGLProgramDescBuilder { | 22 class GrGLProgramDescBuilder { |
23 public: | 23 public: |
24 struct GLKeyHeader : public GrProgramDesc::KeyHeader { | 24 typedef GrProgramDesc::KeyHeader KeyHeader; |
25 SkBool8 fUseNvpr; | |
26 }; | |
27 | |
28 // The key, stored in fKey, is composed of five parts(first 2 are defined in
the key itself): | 25 // The key, stored in fKey, is composed of five parts(first 2 are defined in
the key itself): |
29 // 1. uint32_t for total key length. | 26 // 1. uint32_t for total key length. |
30 // 2. uint32_t for a checksum. | 27 // 2. uint32_t for a checksum. |
31 // 3. Header struct defined above. | 28 // 3. Header struct defined above. |
32 // 4. Backend-specific information including per-processor keys and their ke
y lengths. | 29 // 4. Backend-specific information including per-processor keys and their ke
y lengths. |
33 // Each processor's key is a variable length array of uint32_t. | 30 // Each processor's key is a variable length array of uint32_t. |
34 enum { | 31 enum { |
35 // Part 3. | 32 // Part 3. |
36 kHeaderOffset = GrProgramDesc::kHeaderOffset, | 33 kHeaderOffset = GrProgramDesc::kHeaderOffset, |
37 kHeaderSize = SkAlign4(sizeof(GLKeyHeader)), | 34 kHeaderSize = SkAlign4(sizeof(KeyHeader)), |
38 // Part 4. | 35 // Part 4. |
39 // This is the offset into the backenend specific part of the key, which
includes | 36 // This is the offset into the backenend specific part of the key, which
includes |
40 // per-processor keys. | 37 // per-processor keys. |
41 kProcessorKeysOffset = kHeaderOffset + kHeaderSize, | 38 kProcessorKeysOffset = kHeaderOffset + kHeaderSize, |
42 }; | 39 }; |
43 | 40 |
44 /** | 41 /** |
45 * Builds a GL specific program descriptor | 42 * Builds a GL specific program descriptor |
46 * | 43 * |
47 * @param GrOptDrawState The optimized drawstate. The descriptor will repr
esent a program | 44 * @param GrOptDrawState The optimized drawstate. The descriptor will repr
esent a program |
48 * which this optstate can use to draw with. The opt
state contains | 45 * which this optstate can use to draw with. The opt
state contains |
49 * general draw information, as well as the specific
color, geometry, | 46 * general draw information, as well as the specific
color, geometry, |
50 * and coverage stages which will be used to generate
the GL Program for | 47 * and coverage stages which will be used to generate
the GL Program for |
51 * this optstate. | 48 * this optstate. |
52 * @param DescInfo A descriptor info struct, generated by the optstate, whi
ch contains a number | 49 * @param DescInfo A descriptor info struct, generated by the optstate, whi
ch contains a number |
53 * of important facts about the program the built descripto
r will represent | 50 * of important facts about the program the built descripto
r will represent |
54 * @param DrawType | 51 * @param DrawType |
55 * @param GrGLGpu A GL Gpu, the caps and Gpu object are used to output proc
essor specific | 52 * @param GrGLGpu A GL Gpu, the caps and Gpu object are used to output proc
essor specific |
56 * parts of the descriptor. | 53 * parts of the descriptor. |
57 * @param GrDeviceCoordTexture A dstCopy texture, which may be null if fram
e buffer fetch is | 54 * @param GrDeviceCoordTexture A dstCopy texture, which may be null if fram
e buffer fetch is |
58 * supported | 55 * supported |
59 * @param GrProgramDesc The built and finalized descriptor | 56 * @param GrProgramDesc The built and finalized descriptor |
60 **/ | 57 **/ |
61 static bool Build(const GrOptDrawState&, | 58 static bool Build(const GrOptDrawState&, |
62 const GrProgramDesc::DescInfo&, | 59 const GrProgramDesc::DescInfo&, |
63 GrGpu::DrawType, | 60 GrGpu::DrawType, |
64 GrGLGpu*, | 61 GrGLGpu*, |
65 GrProgramDesc*); | 62 GrProgramDesc*); |
66 | |
67 static const GLKeyHeader& GetHeader(const GrProgramDesc& desc) { | |
68 return *desc.atOffset<GLKeyHeader, kHeaderOffset>(); | |
69 } | |
70 }; | 63 }; |
71 | 64 |
72 #endif | 65 #endif |
OLD | NEW |