aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GLProgramsTest.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-07-15 19:41:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-15 19:41:17 -0700
commitc0ea398aff8254e31152cbb94c9ab6150428e252 (patch)
tree9d6679780751b74228ba1613a65beb6e9daa3078 /tests/GLProgramsTest.cpp
parent8339371f1ec3c57a0741932fd96bff32c53d4e54 (diff)
Makes GrGLProgramDesc's key store the lengths as well as offsets of the effect keys.
Makes it possible to use GrBackendEffectFactories other than GrTBEF by moving meta-key generation out of GrTBEF. Cleans up docs around GrBackendEffectFactory. R=robertphillips@google.com, jvanverth@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/379113004
Diffstat (limited to 'tests/GLProgramsTest.cpp')
-rw-r--r--tests/GLProgramsTest.cpp39
1 files changed, 15 insertions, 24 deletions
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index dd0f80f42f..2264385902 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -35,42 +35,33 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
int numStages = numColorStages + numCoverageStages;
fKey.reset();
- GR_STATIC_ASSERT(0 == kEffectKeyLengthsOffset % sizeof(uint32_t));
+ GR_STATIC_ASSERT(0 == kEffectKeyOffsetsAndLengthOffset % sizeof(uint32_t));
// Make room for everything up to and including the array of offsets to effect keys.
- fKey.push_back_n(kEffectKeyLengthsOffset + sizeof(uint32_t) * numStages);
-
- size_t offset = fKey.count();
- int offsetIndex = 0;
+ fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
bool dstRead = false;
bool fragPos = false;
bool vertexCode = false;
for (int s = 0; s < numStages; ++s) {
- uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(fKey.begin() +
- kEffectKeyLengthsOffset +
- offsetIndex * sizeof(uint32_t));
- *offsetLocation = offset;
- ++offsetIndex;
-
- const GrBackendEffectFactory& factory = stages[s]->getEffect()->getFactory();
+ uint16_t* offsetAndSize = reinterpret_cast<uint16_t*>(fKey.begin() +
+ kEffectKeyOffsetsAndLengthOffset +
+ s * 2 * sizeof(uint16_t));
+ uint32_t effectKeyOffset = fKey.count();
+ if (effectKeyOffset > SK_MaxU16) {
+ fKey.reset();
+ return false;
+ }
GrDrawEffect drawEffect(*stages[s], useLocalCoords);
GrEffectKeyBuilder b(&fKey);
- if (!factory.getGLEffectKey(drawEffect, gpu->glCaps(), &b)) {
+ uint16_t effectKeySize;
+ if (!GetEffectKeyAndUpdateStats(*stages[s], gpu->glCaps(), useLocalCoords, &b,
+ &effectKeySize, &dstRead, &fragPos, &vertexCode)) {
fKey.reset();
return false;
}
- if (stages[s]->getEffect()->willReadDstColor()) {
- dstRead = true;
- }
- if (stages[s]->getEffect()->willReadFragmentPosition()) {
- fragPos = true;
- }
- if (stages[s]->getEffect()->hasVertexCode()) {
- vertexCode = true;
- }
-
- offset += b.size();
+ offsetAndSize[0] = effectKeyOffset;
+ offsetAndSize[1] = effectKeySize;
}
KeyHeader* header = this->header();