| 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 | 8 |
| 8 #include "gl/builders/GrGLFragmentShaderBuilder.h" | 9 #include "GrGLProcessor.h" |
| 9 #include "GrGLProgramDesc.h" | |
| 10 #include "GrBackendProcessorFactory.h" | 10 #include "GrBackendProcessorFactory.h" |
| 11 #include "GrProcessor.h" | 11 #include "GrProcessor.h" |
| 12 #include "GrGpuGL.h" | 12 #include "GrGpuGL.h" |
| 13 #include "GrOptDrawState.h" | 13 #include "GrOptDrawState.h" |
| 14 | |
| 15 #include "SkChecksum.h" | 14 #include "SkChecksum.h" |
| 15 #include "gl/builders/GrGLFragmentShaderBuilder.h" |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * The key for an individual coord transform is made up of a matrix type and a b
it that | 18 * The key for an individual coord transform is made up of a matrix type and a b
it that |
| 19 * indicates the source of the input coords. | 19 * indicates the source of the input coords. |
| 20 */ | 20 */ |
| 21 enum { | 21 enum { |
| 22 kMatrixTypeKeyBits = 1, | 22 kMatrixTypeKeyBits = 1, |
| 23 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, | 23 kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, |
| 24 kPositionCoords_Flag = (1 << kMatrixTypeKeyBits), | 24 kPositionCoords_Flag = (1 << kMatrixTypeKeyBits), |
| 25 kTransformKeyBits = kMatrixTypeKeyBits + 1, | 25 kTransformKeyBits = kMatrixTypeKeyBits + 1, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 b, keySize); | 172 b, keySize); |
| 173 } | 173 } |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 | 176 |
| 177 template <class ProcessorKeyBuilder> | 177 template <class ProcessorKeyBuilder> |
| 178 bool | 178 bool |
| 179 GrGLProgramDesc::BuildStagedProcessorKey(const typename ProcessorKeyBuilder::Sta
gedProcessor& stage, | 179 GrGLProgramDesc::BuildStagedProcessorKey(const typename ProcessorKeyBuilder::Sta
gedProcessor& stage, |
| 180 const GrGLCaps& caps, | 180 const GrGLCaps& caps, |
| 181 bool requiresLocalCoordAttrib, | 181 bool requiresLocalCoordAttrib, |
| 182 GrGLProgramDesc* desc, | 182 GrProgramDesc* desc, |
| 183 int* offsetAndSizeIndex) { | 183 int* offsetAndSizeIndex) { |
| 184 GrProcessorKeyBuilder b(&desc->fKey); | 184 GrProcessorKeyBuilder b(&desc->fKey); |
| 185 uint16_t processorKeySize; | 185 uint16_t processorKeySize; |
| 186 uint32_t processorOffset = desc->fKey.count(); | 186 uint32_t processorOffset = desc->fKey.count(); |
| 187 if (processorOffset > SK_MaxU16 || | 187 if (processorOffset > SK_MaxU16 || |
| 188 !ProcessorKeyBuilder::GetProcessorKey(stage, caps, requiresLocalCoor
dAttrib, &b, | 188 !ProcessorKeyBuilder::GetProcessorKey(stage, caps, requiresLocalCoor
dAttrib, &b, |
| 189 &processorKeySize)){ | 189 &processorKeySize)){ |
| 190 desc->fKey.reset(); | 190 desc->fKey.reset(); |
| 191 return false; | 191 return false; |
| 192 } | 192 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 requiresLocalC
oordAttrib, | 241 requiresLocalC
oordAttrib, |
| 242 desc, | 242 desc, |
| 243 &offsetAndSize
Index)) { | 243 &offsetAndSize
Index)) { |
| 244 return false; | 244 return false; |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 | 247 |
| 248 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- | 248 // --------DO NOT MOVE HEADER ABOVE THIS LINE-------------------------------
------------------- |
| 249 // Because header is a pointer into the dynamic array, we can't push any new
data into the key | 249 // Because header is a pointer into the dynamic array, we can't push any new
data into the key |
| 250 // below here. | 250 // below here. |
| 251 KeyHeader* header = desc->header(); | 251 GLKeyHeader* header = desc->atOffset<GLKeyHeader, kHeaderOffset>(); |
| 252 | 252 |
| 253 // make sure any padding in the header is zeroed. | 253 // make sure any padding in the header is zeroed. |
| 254 memset(header, 0, kHeaderSize); | 254 memset(header, 0, kHeaderSize); |
| 255 | 255 |
| 256 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); | 256 header->fHasGeometryProcessor = optState.hasGeometryProcessor(); |
| 257 | 257 |
| 258 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; | 258 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; |
| 259 | 259 |
| 260 if (gpu->caps()->pathRenderingSupport() && | 260 if (gpu->caps()->pathRenderingSupport() && |
| 261 GrGpu::IsPathRenderingDrawType(drawType) && | 261 GrGpu::IsPathRenderingDrawType(drawType) && |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 void GrGLProgramDesc::finalize() { | 348 void GrGLProgramDesc::finalize() { |
| 349 int keyLength = fKey.count(); | 349 int keyLength = fKey.count(); |
| 350 SkASSERT(0 == (keyLength % 4)); | 350 SkASSERT(0 == (keyLength % 4)); |
| 351 *this->atOffset<uint32_t, kLengthOffset>() = SkToU32(keyLength); | 351 *this->atOffset<uint32_t, kLengthOffset>() = SkToU32(keyLength); |
| 352 | 352 |
| 353 uint32_t* checksum = this->atOffset<uint32_t, kChecksumOffset>(); | 353 uint32_t* checksum = this->atOffset<uint32_t, kChecksumOffset>(); |
| 354 *checksum = 0; | 354 *checksum = 0; |
| 355 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 355 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
| 356 } | 356 } |
| 357 | 357 |
| 358 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | |
| 359 size_t keyLength = other.keyLength(); | |
| 360 fKey.reset(keyLength); | |
| 361 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | |
| 362 return *this; | |
| 363 } | |
| OLD | NEW |