| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 GrGLProgramDesc* glDesc = (GrGLProgramDesc*) desc; | 99 GrGLProgramDesc* glDesc = (GrGLProgramDesc*) desc; |
| 100 | 100 |
| 101 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); | 101 GR_STATIC_ASSERT(0 == kProcessorKeysOffset % sizeof(uint32_t)); |
| 102 // Make room for everything up to the effect keys. | 102 // Make room for everything up to the effect keys. |
| 103 glDesc->key().reset(); | 103 glDesc->key().reset(); |
| 104 glDesc->key().push_back_n(kProcessorKeysOffset); | 104 glDesc->key().push_back_n(kProcessorKeysOffset); |
| 105 | 105 |
| 106 GrProcessorKeyBuilder b(&glDesc->key()); | 106 GrProcessorKeyBuilder b(&glDesc->key()); |
| 107 | 107 |
| 108 primProc.getGLProcessorKey(batchTracker, gpu->glCaps(), &b); | 108 primProc.getGLProcessorKey(batchTracker, gpu->glCaps(), &b); |
| 109 //**** use glslCaps here? |
| 109 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { | 110 if (!get_meta_key(primProc, gpu->glCaps(), 0, &b)) { |
| 110 glDesc->key().reset(); | 111 glDesc->key().reset(); |
| 111 return false; | 112 return false; |
| 112 } | 113 } |
| 113 | 114 |
| 114 for (int s = 0; s < pipeline.numFragmentStages(); ++s) { | 115 for (int s = 0; s < pipeline.numFragmentStages(); ++s) { |
| 115 const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s); | 116 const GrPendingFragmentStage& fps = pipeline.getFragmentStage(s); |
| 116 const GrFragmentProcessor& fp = *fps.processor(); | 117 const GrFragmentProcessor& fp = *fps.processor(); |
| 117 fp.getGLProcessorKey(gpu->glCaps(), &b); | 118 fp.getGLProcessorKey(gpu->glCaps(), &b); |
| 119 //**** use glslCaps here? |
| 118 if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTr
ansforms()), &b)) { | 120 if (!get_meta_key(fp, gpu->glCaps(), primProc.getTransformKey(fp.coordTr
ansforms()), &b)) { |
| 119 glDesc->key().reset(); | 121 glDesc->key().reset(); |
| 120 return false; | 122 return false; |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 const GrXferProcessor& xp = *pipeline.getXferProcessor(); | 126 const GrXferProcessor& xp = *pipeline.getXferProcessor(); |
| 125 xp.getGLProcessorKey(gpu->glCaps(), &b); | 127 xp.getGLProcessorKey(gpu->glCaps(), &b); |
| 128 //**** use glslCaps here? |
| 126 if (!get_meta_key(xp, gpu->glCaps(), 0, &b)) { | 129 if (!get_meta_key(xp, gpu->glCaps(), 0, &b)) { |
| 127 glDesc->key().reset(); | 130 glDesc->key().reset(); |
| 128 return false; | 131 return false; |
| 129 } | 132 } |
| 130 | 133 |
| 131 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- | 134 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- |
| 132 // Because header is a pointer into the dynamic array, we can't push any new
data into the key | 135 // Because header is a pointer into the dynamic array, we can't push any new
data into the key |
| 133 // below here. | 136 // below here. |
| 134 KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>(); | 137 KeyHeader* header = glDesc->atOffset<KeyHeader, kHeaderOffset>(); |
| 135 | 138 |
| 136 // make sure any padding in the header is zeroed. | 139 // make sure any padding in the header is zeroed. |
| 137 memset(header, 0, kHeaderSize); | 140 memset(header, 0, kHeaderSize); |
| 138 | 141 |
| 139 if (pipeline.readsFragPosition()) { | 142 if (pipeline.readsFragPosition()) { |
| 140 header->fFragPosKey = | 143 header->fFragPosKey = |
| 141 GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRe
nderTarget(), | 144 GrGLFragmentShaderBuilder::KeyForFragmentPosition(pipeline.getRe
nderTarget(), |
| 142 gpu->glCaps())
; | 145 gpu->glCaps())
; |
| 143 } else { | 146 } else { |
| 144 header->fFragPosKey = 0; | 147 header->fFragPosKey = 0; |
| 145 } | 148 } |
| 146 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); | 149 header->fSnapVerticesToPixelCenters = pipeline.snapVerticesToPixelCenters(); |
| 147 header->fColorEffectCnt = pipeline.numColorFragmentStages(); | 150 header->fColorEffectCnt = pipeline.numColorFragmentStages(); |
| 148 header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages(); | 151 header->fCoverageEffectCnt = pipeline.numCoverageFragmentStages(); |
| 149 glDesc->finalize(); | 152 glDesc->finalize(); |
| 150 return true; | 153 return true; |
| 151 } | 154 } |
| OLD | NEW |