| Index: src/gpu/gl/GrGLProgramDesc.cpp
|
| diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
|
| index 2c260cda52b16e3808fc03534b76e6d640ef49fc..27a1fab1e0e1a3e892c1f8866aa38077c64493b7 100644
|
| --- a/src/gpu/gl/GrGLProgramDesc.cpp
|
| +++ b/src/gpu/gl/GrGLProgramDesc.cpp
|
| @@ -14,13 +14,14 @@
|
|
|
| #include "SkChecksum.h"
|
|
|
| -static inline bool get_key_and_update_stats(const GrEffectStage& stage,
|
| - const GrGLCaps& caps,
|
| - bool useExplicitLocalCoords,
|
| - GrEffectKeyBuilder* b,
|
| - bool* setTrueIfReadsDst,
|
| - bool* setTrueIfReadsPos,
|
| - bool* setTrueIfHasVertexCode) {
|
| +bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage,
|
| + const GrGLCaps& caps,
|
| + bool useExplicitLocalCoords,
|
| + GrEffectKeyBuilder* b,
|
| + uint16_t* effectKeySize,
|
| + bool* setTrueIfReadsDst,
|
| + bool* setTrueIfReadsPos,
|
| + bool* setTrueIfHasVertexCode) {
|
| const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
|
| GrDrawEffect drawEffect(stage, useExplicitLocalCoords);
|
| if (stage.getEffect()->willReadDstColor()) {
|
| @@ -32,7 +33,17 @@ static inline bool get_key_and_update_stats(const GrEffectStage& stage,
|
| if (stage.getEffect()->hasVertexCode()) {
|
| *setTrueIfHasVertexCode = true;
|
| }
|
| - return factory.getGLEffectKey(drawEffect, caps, b);
|
| + factory.getGLEffectKey(drawEffect, caps, b);
|
| + size_t size = b->size();
|
| + if (size > SK_MaxU16) {
|
| + *effectKeySize = 0; // suppresses a warning.
|
| + return false;
|
| + }
|
| + *effectKeySize = SkToU16(size);
|
| + if (!GrGLProgramEffects::GenEffectMetaKey(drawEffect, caps, b)) {
|
| + return false;
|
| + }
|
| + return true;
|
| }
|
|
|
| bool GrGLProgramDesc::Build(const GrDrawState& drawState,
|
| @@ -105,43 +116,54 @@ bool GrGLProgramDesc::Build(const GrDrawState& drawState,
|
| if (!skipCoverage) {
|
| numStages += drawState.numCoverageStages() - firstEffectiveCoverageStage;
|
| }
|
| - 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.
|
| desc->fKey.reset();
|
| - desc->fKey.push_back_n(kEffectKeyLengthsOffset + sizeof(uint32_t) * numStages);
|
| + desc->fKey.push_back_n(kEffectKeyOffsetsAndLengthOffset + 2 * sizeof(uint16_t) * numStages);
|
|
|
| - size_t offset = desc->fKey.count();
|
| - int offsetIndex = 0;
|
| + int offsetAndSizeIndex = 0;
|
|
|
| bool effectKeySuccess = true;
|
| if (!skipColor) {
|
| for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); ++s) {
|
| - uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(desc->fKey.begin() +
|
| - kEffectKeyLengthsOffset +
|
| - offsetIndex * sizeof(uint32_t));
|
| - *offsetLocation = offset;
|
| - ++offsetIndex;
|
| + uint16_t* offsetAndSize =
|
| + reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
|
| + offsetAndSizeIndex * 2 * sizeof(uint16_t));
|
|
|
| GrEffectKeyBuilder b(&desc->fKey);
|
| - effectKeySuccess |= get_key_and_update_stats(drawState.getColorStage(s), gpu->glCaps(),
|
| - requiresLocalCoordAttrib, &b, &readsDst,
|
| - &readFragPosition, &hasVertexCode);
|
| - offset += b.size();
|
| + uint16_t effectKeySize;
|
| + uint32_t effectOffset = desc->fKey.count();
|
| + effectKeySuccess |= GetEffectKeyAndUpdateStats(
|
| + drawState.getColorStage(s), gpu->glCaps(),
|
| + requiresLocalCoordAttrib, &b,
|
| + &effectKeySize, &readsDst,
|
| + &readFragPosition, &hasVertexCode);
|
| + effectKeySuccess |= (effectOffset <= SK_MaxU16);
|
| +
|
| + offsetAndSize[0] = SkToU16(effectOffset);
|
| + offsetAndSize[1] = effectKeySize;
|
| + ++offsetAndSizeIndex;
|
| }
|
| }
|
| if (!skipCoverage) {
|
| for (int s = firstEffectiveCoverageStage; s < drawState.numCoverageStages(); ++s) {
|
| - uint32_t* offsetLocation = reinterpret_cast<uint32_t*>(desc->fKey.begin() +
|
| - kEffectKeyLengthsOffset +
|
| - offsetIndex * sizeof(uint32_t));
|
| - *offsetLocation = offset;
|
| - ++offsetIndex;
|
| + uint16_t* offsetAndSize =
|
| + reinterpret_cast<uint16_t*>(desc->fKey.begin() + kEffectKeyOffsetsAndLengthOffset +
|
| + offsetAndSizeIndex * 2 * sizeof(uint16_t));
|
| +
|
| GrEffectKeyBuilder b(&desc->fKey);
|
| - effectKeySuccess |= get_key_and_update_stats(drawState.getCoverageStage(s),
|
| - gpu->glCaps(), requiresLocalCoordAttrib,
|
| - &b, &readsDst, &readFragPosition,
|
| - &hasVertexCode);
|
| - offset += b.size();
|
| + uint16_t effectKeySize;
|
| + uint32_t effectOffset = desc->fKey.count();
|
| + effectKeySuccess |= GetEffectKeyAndUpdateStats(
|
| + drawState.getCoverageStage(s), gpu->glCaps(),
|
| + requiresLocalCoordAttrib, &b,
|
| + &effectKeySize, &readsDst,
|
| + &readFragPosition, &hasVertexCode);
|
| + effectKeySuccess |= (effectOffset <= SK_MaxU16);
|
| +
|
| + offsetAndSize[0] = SkToU16(effectOffset);
|
| + offsetAndSize[1] = effectKeySize;
|
| + ++offsetAndSizeIndex;
|
| }
|
| }
|
| if (!effectKeySuccess) {
|
|
|