Chromium Code Reviews| 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 "GrGLProgramEffects.h" | 8 #include "GrGLProgramEffects.h" |
| 9 #include "GrDrawEffect.h" | 9 #include "GrDrawEffect.h" |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 combined.set(SkMatrix::kMTransY, | 107 combined.set(SkMatrix::kMTransY, |
| 108 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); | 108 combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); |
| 109 } | 109 } |
| 110 return combined; | 110 return combined; |
| 111 } | 111 } |
| 112 | 112 |
| 113 } | 113 } |
| 114 | 114 |
| 115 //////////////////////////////////////////////////////////////////////////////// | 115 //////////////////////////////////////////////////////////////////////////////// |
| 116 | 116 |
| 117 bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps, | |
| 118 GrEffectKeyBuilder* b) { | |
| 119 | |
| 120 EffectKey textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps); | |
| 121 EffectKey transformKey = GrGLProgramEffects::GenTransformKey(drawEffect); | |
| 122 EffectKey attribKey = GrGLProgramEffects::GenAttribKey(drawEffect); | |
| 123 uint32_t classID = drawEffect.effect()->getFactory().effectClassID(); | |
| 124 | |
|
robertphillips
2014/07/11 17:24:58
Currently ?
bsalomon
2014/07/11 17:52:56
Done.
| |
| 125 // Currenlty we allow 16 bits for each of the above portions of the meta-key . Fail if they | |
| 126 // don't fit. | |
| 127 static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); | |
| 128 if ((textureKey | transformKey | attribKey | classID) & kMetaKeyInvalidMask) { | |
| 129 return false; | |
| 130 } | |
| 131 | |
| 132 uint32_t* key = b->add32n(2); | |
| 133 key[0] = (textureKey << 16 | transformKey); | |
| 134 key[1] = (classID << 16 | attribKey); | |
| 135 return true; | |
| 136 } | |
| 137 | |
| 117 EffectKey GrGLProgramEffects::GenAttribKey(const GrDrawEffect& drawEffect) { | 138 EffectKey GrGLProgramEffects::GenAttribKey(const GrDrawEffect& drawEffect) { |
| 118 EffectKey key = 0; | 139 EffectKey key = 0; |
| 119 int numAttributes = drawEffect.getVertexAttribIndexCount(); | 140 int numAttributes = drawEffect.getVertexAttribIndexCount(); |
| 120 SkASSERT(numAttributes <= 2); | 141 SkASSERT(numAttributes <= 2); |
| 121 const int* attributeIndices = drawEffect.getVertexAttribIndices(); | 142 const int* attributeIndices = drawEffect.getVertexAttribIndices(); |
| 122 for (int a = 0; a < numAttributes; ++a) { | 143 for (int a = 0; a < numAttributes; ++a) { |
| 123 EffectKey value = attributeIndices[a] << 3 * a; | 144 EffectKey value = attributeIndices[a] << 3 * a; |
| 124 SkASSERT(0 == (value & key)); // keys for each attribute ought not to ov erlap | 145 SkASSERT(0 == (value & key)); // keys for each attribute ought not to ov erlap |
| 125 key |= value; | 146 key |= value; |
| 126 } | 147 } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 } | 502 } |
| 482 | 503 |
| 483 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, | 504 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, |
| 484 GrGLProgramEffects::EffectK ey key, | 505 GrGLProgramEffects::EffectK ey key, |
| 485 const char* outColor, | 506 const char* outColor, |
| 486 const char* inColor, | 507 const char* inColor, |
| 487 int stageIndex) { | 508 int stageIndex) { |
| 488 SkASSERT(NULL != fProgramEffects.get()); | 509 SkASSERT(NULL != fProgramEffects.get()); |
| 489 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn dex); | 510 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn dex); |
| 490 } | 511 } |
| OLD | NEW |