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/GrGLFragmentShaderBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.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.getProcessor()); | 181 uint32_t attribKey = gen_attrib_key(stage.getGeometryProcessor()); |
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->glCa
ps()); | 351 gpu->glCaps()); |
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 = | 358 header->fFragPosKey = GrGLFragmentShaderBuilder::KeyForFragmentPosition( |
359 GrGLFragmentShaderBuilder::KeyForFragmentPosition(optState.getRe
nderTarget(), | 359 optState.getRenderTarget(), gpu->glCaps()); |
360 gpu->glCaps())
; | |
361 } else { | 360 } else { |
362 header->fFragPosKey = 0; | 361 header->fFragPosKey = 0; |
363 } | 362 } |
364 | 363 |
365 // Record attribute indices | 364 // Record attribute indices |
366 header->fPositionAttributeIndex = optState.positionAttributeIndex(); | 365 header->fPositionAttributeIndex = optState.positionAttributeIndex(); |
367 header->fLocalCoordAttributeIndex = optState.localCoordAttributeIndex(); | 366 header->fLocalCoordAttributeIndex = optState.localCoordAttributeIndex(); |
368 | 367 |
369 // For constant color and coverage we need an attribute with an index beyond
those already set | 368 // For constant color and coverage we need an attribute with an index beyond
those already set |
370 int availableAttributeIndex = optState.getVertexAttribCount(); | 369 int availableAttributeIndex = optState.getVertexAttribCount(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 *checksum = 0; | 412 *checksum = 0; |
414 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); | 413 *checksum = SkChecksum::Compute(reinterpret_cast<uint32_t*>(fKey.begin()), k
eyLength); |
415 } | 414 } |
416 | 415 |
417 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 416 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
418 size_t keyLength = other.keyLength(); | 417 size_t keyLength = other.keyLength(); |
419 fKey.reset(keyLength); | 418 fKey.reset(keyLength); |
420 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 419 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
421 return *this; | 420 return *this; |
422 } | 421 } |
OLD | NEW |