separate arrays for color and coverage effects.
R=robertphillips@google.com
Review URL: https://codereview.chromium.org/16180006
git-svn-id: http://skia.googlecode.com/svn/trunk@9465 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGLProgramDesc.cpp b/src/gpu/gl/GrGLProgramDesc.cpp
index d040658..4f00118 100644
--- a/src/gpu/gl/GrGLProgramDesc.cpp
+++ b/src/gpu/gl/GrGLProgramDesc.cpp
@@ -21,8 +21,12 @@
GrBlendCoeff dstCoeff,
const GrGpuGL* gpu,
const GrDeviceCoordTexture* dstCopy,
- const GrEffectStage* stages[],
+ SkTArray<const GrEffectStage*, true>* colorStages,
+ SkTArray<const GrEffectStage*, true>* coverageStages,
GrGLProgramDesc* desc) {
+ colorStages->reset();
+ coverageStages->reset();
+
// This should already have been caught
GrAssert(!(GrDrawState::kSkipDraw_BlendOptFlag & blendOpts));
@@ -51,26 +55,22 @@
// effects as color in desc. Two things will allow simplication of this mess: GrDrawState will
// have tight lists of color and coverage stages rather than a fixed size array with NULLS and
// the xfermode-color filter will be removed.
- int colorEffectCnt = 0;
- int coverageEffectCnt = 0;
if (!skipColor) {
for (int s = 0; s < drawState.getFirstCoverageStage(); ++s) {
if (drawState.isStageEnabled(s)) {
- stages[colorEffectCnt] = &drawState.getStage(s);
- ++colorEffectCnt;
+ colorStages->push_back(&drawState.getStage(s));
}
}
}
if (!skipCoverage) {
for (int s = drawState.getFirstCoverageStage(); s < GrDrawState::kNumStages; ++s) {
if (drawState.isStageEnabled(s)) {
- stages[colorEffectCnt + coverageEffectCnt] = &drawState.getStage(s);
- ++coverageEffectCnt;
+ coverageStages->push_back(&drawState.getStage(s));
}
}
}
- size_t newKeyLength = KeyLength(colorEffectCnt + coverageEffectCnt);
+ size_t newKeyLength = KeyLength(colorStages->count() + coverageStages->count());
bool allocChanged;
desc->fKey.reset(newKeyLength, SkAutoMalloc::kAlloc_OnShrink, &allocChanged);
if (allocChanged || !desc->fInitialized) {
@@ -189,7 +189,7 @@
// If we do have coverage determine whether it matters.
bool separateCoverageFromColor = false;
- if (!drawState.isCoverageDrawing() && (coverageEffectCnt > 0 || requiresCoverageAttrib)) {
+ if (!drawState.isCoverageDrawing() && (coverageStages->count() > 0 || requiresCoverageAttrib)) {
// color filter is applied between color/coverage computation
if (SkXfermode::kDst_Mode != header->fColorFilterXfermode) {
separateCoverageFromColor = true;
@@ -225,11 +225,13 @@
}
}
if (separateCoverageFromColor) {
- header->fColorEffectCnt = colorEffectCnt;
- header->fCoverageEffectCnt = coverageEffectCnt;
+ header->fColorEffectCnt = colorStages->count();
+ header->fCoverageEffectCnt = coverageStages->count();
} else {
- header->fColorEffectCnt = colorEffectCnt + coverageEffectCnt;
+ header->fColorEffectCnt = colorStages->count() + coverageStages->count();
header->fCoverageEffectCnt = 0;
+ colorStages->push_back_n(coverageStages->count(), coverageStages->begin());
+ coverageStages->reset();
}
*desc->checksum() = 0;