blob: 183a42fb33e17c9153fe64b4c5bf26d21e09e442 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrProcOptInfo.h"
#include "GrGeometryProcessor.h"
#include "batches/GrDrawBatch.h"
void GrProcOptInfo::calcWithInitialValues(const GrFragmentProcessor * const processors[],
int cnt,
GrColor startColor,
GrColorComponentFlags flags,
bool areCoverageStages,
bool isLCD) {
GrInitInvariantOutput out;
out.fIsSingleComponent = areCoverageStages;
out.fColor = startColor;
out.fValidFlags = flags;
out.fIsLCDCoverage = isLCD;
fInOut.reset(out);
this->internalCalc(processors, cnt);
}
void GrProcOptInfo::initUsingInvariantOutput(GrInitInvariantOutput invOutput) {
fInOut.reset(invOutput);
}
void GrProcOptInfo::completeCalculations(const GrFragmentProcessor * const processors[], int cnt) {
this->internalCalc(processors, cnt);
}
void GrProcOptInfo::internalCalc(const GrFragmentProcessor* const processors[], int cnt) {
fFirstEffectiveProcessorIndex = 0;
fInputColorIsUsed = true;
fInputColor = fInOut.color();
for (int i = 0; i < cnt; ++i) {
const GrFragmentProcessor* processor = processors[i];
fInOut.resetWillUseInputColor();
processor->computeInvariantOutput(&fInOut);
SkDEBUGCODE(fInOut.validate());
if (!fInOut.willUseInputColor()) {
fFirstEffectiveProcessorIndex = i;
fInputColorIsUsed = false;
}
if (kRGBA_GrColorComponentFlags == fInOut.validFlags()) {
fFirstEffectiveProcessorIndex = i + 1;
fInputColor = fInOut.color();
fInputColorIsUsed = true;
// Since we are clearing all previous color stages we are in a state where we have found
// zero stages that don't multiply the inputColor.
fInOut.resetNonMulStageFound();
}
}
}
|