Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "GrGLSL.h" | 8 #include "GrGLSL.h" |
| 9 #include "GrGLEffect.h" | 9 #include "GrGLEffect.h" |
| 10 #include "GrCoordTransform.h" | |
| 10 #include "GrDrawEffect.h" | 11 #include "GrDrawEffect.h" |
| 11 | 12 |
| 12 GrGLEffect::GrGLEffect(const GrBackendEffectFactory& factory) | 13 GrGLEffect::GrGLEffect(const GrBackendEffectFactory& factory) |
| 13 : fFactory(factory) { | 14 : fFactory(factory) { |
| 14 } | 15 } |
| 15 | 16 |
| 16 GrGLEffect::~GrGLEffect() { | 17 GrGLEffect::~GrGLEffect() { |
| 17 } | 18 } |
| 18 | 19 |
| 19 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
| 20 | 21 |
| 21 void GrGLEffect::setData(const GrGLUniformManager&, const GrDrawEffect&) { | 22 void GrGLEffect::setData(const GrGLUniformManager&, const GrDrawEffect&) { |
| 22 } | 23 } |
| 23 | 24 |
| 24 GrGLEffect::EffectKey GrGLEffect::GenTextureKey(const GrDrawEffect& drawEffect, | 25 GrGLEffect::EffectKey GrGLEffect::GenTextureKey(const GrDrawEffect& drawEffect, |
| 25 const GrGLCaps& caps) { | 26 const GrGLCaps& caps) { |
| 26 EffectKey key = 0; | 27 EffectKey key = 0; |
| 27 int numTextures = (*drawEffect.effect())->numTextures(); | 28 int numTextures = (*drawEffect.effect())->numTextures(); |
| 28 for (int index = 0; index < numTextures; ++index) { | 29 for (int index = 0; index < numTextures; ++index) { |
| 29 const GrTextureAccess& access = (*drawEffect.effect())->textureAccess(in dex); | 30 const GrTextureAccess& access = (*drawEffect.effect())->textureAccess(in dex); |
| 30 EffectKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) < < index; | 31 EffectKey value = GrGLShaderBuilder::KeyForTextureAccess(access, caps) < < index; |
| 31 SkASSERT(0 == (value & key)); // keys for each access ought not to overl ap | 32 SkASSERT(0 == (value & key)); // keys for each access ought not to overl ap |
| 32 key |= value; | 33 key |= value; |
| 33 } | 34 } |
| 34 return key; | 35 return key; |
| 35 } | 36 } |
| 36 | 37 |
| 38 GrGLEffect::EffectKey GrGLEffect::GenTransformKey(const GrDrawEffect& drawEffect ) { | |
| 39 EffectKey key = 0; | |
| 40 int numTransforms = (*drawEffect.effect())->numTransforms(); | |
| 41 for (int index = 0; index < numTransforms; ++index) { | |
| 42 const GrCoordTransform& transform = (*drawEffect.effect())->coordTransfo rm(index); | |
| 43 EffectKey value = GrGLCoordTransform::GenKey(transform.getMatrix(), | |
| 44 drawEffect, | |
| 45 transform.sourceCoords(), | |
| 46 transform.reverseY()); | |
| 47 value <<= index * GrGLCoordTransform::kKeyBits; | |
| 48 SkASSERT(0 == (value & key)); // keys for each access ought not to overl ap | |
|
bsalomon
2013/09/27 20:04:25
keys for each *transform*...
Chris Dalton
2013/09/27 23:33:45
Done.
| |
| 49 key |= value; | |
| 50 } | |
| 51 return key; | |
| 52 } | |
| 53 | |
| 37 GrGLEffect::EffectKey GrGLEffect::GenAttribKey(const GrDrawEffect& drawEffect) { | 54 GrGLEffect::EffectKey GrGLEffect::GenAttribKey(const GrDrawEffect& drawEffect) { |
| 38 EffectKey key = 0; | 55 EffectKey key = 0; |
| 39 | 56 |
| 40 int numAttributes = drawEffect.getVertexAttribIndexCount(); | 57 int numAttributes = drawEffect.getVertexAttribIndexCount(); |
| 41 SkASSERT(numAttributes <= 2); | 58 SkASSERT(numAttributes <= 2); |
| 42 const int* attributeIndices = drawEffect.getVertexAttribIndices(); | 59 const int* attributeIndices = drawEffect.getVertexAttribIndices(); |
| 43 for (int index = 0; index < numAttributes; ++index) { | 60 for (int index = 0; index < numAttributes; ++index) { |
| 44 EffectKey value = attributeIndices[index] << 3*index; | 61 EffectKey value = attributeIndices[index] << 3*index; |
| 45 SkASSERT(0 == (value & key)); // keys for each attribute ought not to ov erlap | 62 SkASSERT(0 == (value & key)); // keys for each attribute ought not to ov erlap |
| 46 key |= value; | 63 key |= value; |
| 47 } | 64 } |
| 48 | 65 |
| 49 return key; | 66 return key; |
| 50 } | 67 } |
| OLD | NEW |