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 #include "GrGLProgramDesc.h" | 7 #include "GrGLProgramDesc.h" |
8 | 8 |
9 #include "GrGLProcessor.h" | 9 #include "GrGLProcessor.h" |
10 #include "GrProcessor.h" | 10 #include "GrProcessor.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 if (processorKeySize > SK_MaxU16) { | 79 if (processorKeySize > SK_MaxU16) { |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 uint32_t* key = b->add32n(2); | 83 uint32_t* key = b->add32n(2); |
84 key[0] = (textureKey << 16 | transformKey); | 84 key[0] = (textureKey << 16 | transformKey); |
85 key[1] = (classID << 16 | SkToU16(processorKeySize)); | 85 key[1] = (classID << 16 | SkToU16(processorKeySize)); |
86 return true; | 86 return true; |
87 } | 87 } |
88 | 88 |
89 bool GrGLProgramDescBuilder::Build(const GrOptDrawState& optState, | 89 bool GrGLProgramDescBuilder::Build(GrProgramDesc* desc, |
| 90 const GrPrimitiveProcessor& primProc, |
| 91 const GrOptDrawState& optState, |
90 const GrProgramDesc::DescInfo& descInfo, | 92 const GrProgramDesc::DescInfo& descInfo, |
91 GrGpu::DrawType drawType, | 93 GrGpu::DrawType drawType, |
92 GrGLGpu* gpu, | 94 const GrGLGpu* gpu, |
93 GrProgramDesc* desc) { | 95 const GrBatchTracker& batchTracker) { |
94 // The descriptor is used as a cache key. Thus when a field of the | 96 // The descriptor is used as a cache key. Thus when a field of the |
95 // descriptor will not affect program generation (because of the attribute | 97 // descriptor will not affect program generation (because of the attribute |
96 // bindings in use or other descriptor field settings) it should be set | 98 // bindings in use or other descriptor field settings) it should be set |
97 // to a canonical value to avoid duplicate programs with different keys. | 99 // to a canonical value to avoid duplicate programs with different keys. |
98 | 100 |
99 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); | 101 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); |
100 // Make room for everything up to the effect keys. | 102 // Make room for everything up to the effect keys. |
101 desc->fKey.reset(); | 103 desc->fKey.reset(); |
102 desc->fKey.push_back_n(kProcessorKeysOffset); | 104 desc->fKey.push_back_n(kProcessorKeysOffset); |
103 | 105 |
104 GrProcessorKeyBuilder b(&desc->fKey); | 106 GrProcessorKeyBuilder b(&desc->fKey); |
105 | 107 |
106 const GrPrimitiveProcessor& primProc = *optState.getPrimitiveProcessor(); | 108 primProc.getGLProcessorKey(batchTracker, gpu->glCaps(), &b); |
107 primProc.getGLProcessorKey(optState.getBatchTracker(), gpu->glCaps(), &b); | |
108 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { | 109 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { |
109 desc->fKey.reset(); | 110 desc->fKey.reset(); |
110 return false; | 111 return false; |
111 } | 112 } |
112 | 113 |
113 for (int s = 0; s < optState.numFragmentStages(); ++s) { | 114 for (int s = 0; s < optState.numFragmentStages(); ++s) { |
114 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); | 115 const GrPendingFragmentStage& fps = optState.getFragmentStage(s); |
115 const GrFragmentProcessor& fp = *fps.processor(); | 116 const GrFragmentProcessor& fp = *fps.processor(); |
116 fp.getGLProcessorKey(gpu->glCaps(), &b); | 117 fp.getGLProcessorKey(gpu->glCaps(), &b); |
117 if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTr
ansforms()), &b)) { | 118 if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTr
ansforms()), &b)) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 gpu->glCaps())
; | 156 gpu->glCaps())
; |
156 } else { | 157 } else { |
157 header->fFragPosKey = 0; | 158 header->fFragPosKey = 0; |
158 } | 159 } |
159 | 160 |
160 header->fColorEffectCnt = optState.numColorStages(); | 161 header->fColorEffectCnt = optState.numColorStages(); |
161 header->fCoverageEffectCnt = optState.numCoverageStages(); | 162 header->fCoverageEffectCnt = optState.numCoverageStages(); |
162 desc->finalize(); | 163 desc->finalize(); |
163 return true; | 164 return true; |
164 } | 165 } |
OLD | NEW |