| 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 #include "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLFragmentShaderBuilder.h" |
| 9 #include "GrGLProgramDesc.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 | 14 |
| 15 #include "SkChecksum.h" | 15 #include "SkChecksum.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 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 size_t size = b->size(); | 171 size_t size = b->size(); |
| 172 if (size > SK_MaxU16) { | 172 if (size > SK_MaxU16) { |
| 173 *processorKeySize = 0; // suppresses a warning. | 173 *processorKeySize = 0; // suppresses a warning. |
| 174 return false; | 174 return false; |
| 175 } | 175 } |
| 176 *processorKeySize = SkToU16(size); | 176 *processorKeySize = SkToU16(size); |
| 177 uint32_t* key = get_processor_meta_key(stage, useExplicitLocalCoords, caps,
b); | 177 uint32_t* key = get_processor_meta_key(stage, useExplicitLocalCoords, caps,
b); |
| 178 if (NULL == key) { | 178 if (NULL == key) { |
| 179 return false; | 179 return false; |
| 180 } | 180 } |
| 181 uint32_t attribKey = gen_attrib_key(stage.getGeometryProcessor()); | 181 uint32_t attribKey = gen_attrib_key(stage.getProcessor()); |
| 182 | 182 |
| 183 // Currently we allow 16 bits for each of the above portions of the meta-key
. Fail if they | 183 // Currently we allow 16 bits for each of the above portions of the meta-key
. Fail if they |
| 184 // don't fit. | 184 // don't fit. |
| 185 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); | 185 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); |
| 186 if ((attribKey) & kMetaKeyInvalidMask) { | 186 if ((attribKey) & kMetaKeyInvalidMask) { |
| 187 return false; | 187 return false; |
| 188 } | 188 } |
| 189 | 189 |
| 190 key[1] |= attribKey; | 190 key[1] |= attribKey; |
| 191 return true; | 191 return true; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 SkASSERT(!header->fUseFragShaderOnly); | 341 SkASSERT(!header->fUseFragShaderOnly); |
| 342 } | 342 } |
| 343 | 343 |
| 344 if (optState.readsDst()) { | 344 if (optState.readsDst()) { |
| 345 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); | 345 SkASSERT(dstCopy || gpu->caps()->dstReadInShaderSupport()); |
| 346 const GrTexture* dstCopyTexture = NULL; | 346 const GrTexture* dstCopyTexture = NULL; |
| 347 if (dstCopy) { | 347 if (dstCopy) { |
| 348 dstCopyTexture = dstCopy->texture(); | 348 dstCopyTexture = dstCopy->texture(); |
| 349 } | 349 } |
| 350 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, | 350 header->fDstReadKey = GrGLFragmentShaderBuilder::KeyForDstRead(dstCopyTe
xture, |
| 351 gpu->glCaps()); | 351 gpu->glCa
ps()); |
| 352 SkASSERT(0 != header->fDstReadKey); | 352 SkASSERT(0 != header->fDstReadKey); |
| 353 } else { | 353 } else { |
| 354 header->fDstReadKey = 0; | 354 header->fDstReadKey = 0; |
| 355 } | 355 } |
| 356 | 356 |
| 357 if (optState.readsFragPosition()) { | 357 if (optState.readsFragPosition()) { |
| 358 header->fFragPosKey = GrGLFragmentShaderBuilder::KeyForFragmentPosition( | 358 header->fFragPosKey = |
| 359 optState.getRenderTarget(), gpu->glCaps()); | 359 GrGLFragmentShaderBuilder::KeyForFragmentPosition(optState.getRe
nderTarget(), |
| 360 gpu->glCaps())
; |
| 360 } else { | 361 } else { |
| 361 header->fFragPosKey = 0; | 362 header->fFragPosKey = 0; |
| 362 } | 363 } |
| 363 | 364 |
| 364 // Record attribute indices | 365 // Record attribute indices |
| 365 header->fPositionAttributeIndex = optState.positionAttributeIndex(); | 366 header->fPositionAttributeIndex = optState.positionAttributeIndex(); |
| 366 header->fLocalCoordAttributeIndex = optState.localCoordAttributeIndex(); | 367 header->fLocalCoordAttributeIndex = optState.localCoordAttributeIndex(); |
| 367 | 368 |
| 368 // For constant color and coverage we need an attribute with an index beyond
those already set | 369 // For constant color and coverage we need an attribute with an index beyond
those already set |
| 369 int availableAttributeIndex = optState.getVertexAttribCount(); | 370 int availableAttributeIndex = optState.getVertexAttribCount(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 *checksum = 0; | 413 *checksum = 0; |
| 413 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 414 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
| 414 } | 415 } |
| 415 | 416 |
| 416 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 417 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
| 417 size_t keyLength = other.keyLength(); | 418 size_t keyLength = other.keyLength(); |
| 418 fKey.reset(keyLength); | 419 fKey.reset(keyLength); |
| 419 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 420 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
| 420 return *this; | 421 return *this; |
| 421 } | 422 } |
| OLD | NEW |