| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #ifndef GrProcOptInfo_DEFINED | 8 #ifndef GrProcOptInfo_DEFINED |
| 9 #define GrProcOptInfo_DEFINED | 9 #define GrProcOptInfo_DEFINED |
| 10 | 10 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrInvariantOutput.h" | 12 #include "GrInvariantOutput.h" |
| 13 #include "GrStagedProcessor.h" |
| 13 | 14 |
| 14 class GrDrawBatch; | 15 class GrDrawBatch; |
| 15 class GrFragmentProcessor; | 16 class GrFragmentProcessor; |
| 16 class GrPrimitiveProcessor; | 17 class GrPrimitiveProcessor; |
| 17 class GrProcessor; | 18 class GrProcessor; |
| 18 | 19 |
| 19 /** | 20 /** |
| 20 * GrProcOptInfo gathers invariant data from a set of processor stages.It is use
d to recognize | 21 * GrProcOptInfo gathers invariant data from a set of processor stages.It is use
d to recognize |
| 21 * optimizations related to eliminating stages and vertex attributes that aren't
necessary for a | 22 * optimizations related to eliminating stages and vertex attributes that aren't
necessary for a |
| 22 * draw. | 23 * draw. |
| 23 */ | 24 */ |
| 24 class GrProcOptInfo { | 25 class GrProcOptInfo { |
| 25 public: | 26 public: |
| 26 GrProcOptInfo() | 27 GrProcOptInfo() |
| 27 : fInOut(0, static_cast<GrColorComponentFlags>(0), false) | 28 : fInOut(0, static_cast<GrColorComponentFlags>(0), false) |
| 28 , fFirstEffectiveProcessorIndex(0) | 29 , fFirstEffectStageIndex(0) |
| 29 , fInputColorIsUsed(true) | 30 , fInputColorIsUsed(true) |
| 30 , fInputColor(0) | 31 , fInputColor(0) |
| 31 , fReadsFragPosition(false) {} | 32 , fReadsFragPosition(false) {} |
| 32 | 33 |
| 33 void calcWithInitialValues(const GrFragmentProcessor* const *, int cnt, GrCo
lor startColor, | 34 void calcWithInitialValues(const GrFragmentStage*, int stageCount, GrColor s
tartColor, |
| 34 GrColorComponentFlags, bool areCoverageStages); | 35 GrColorComponentFlags flags, bool areCoverageStag
es); |
| 35 | 36 |
| 36 void calcColorWithBatch(const GrDrawBatch*, const GrFragmentProcessor* const
[], int cnt); | 37 void calcColorWithBatch(const GrDrawBatch*, const GrFragmentStage*, int stag
ecount); |
| 37 void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentProcessor* co
nst[], int cnt); | 38 void calcCoverageWithBatch(const GrDrawBatch*, const GrFragmentStage*, int s
tagecount); |
| 38 | 39 |
| 39 // TODO delete these when batch is everywhere | 40 // TODO delete these when batch is everywhere |
| 40 void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentProc
essor* const[], | 41 void calcColorWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentStag
e*, int stagecount); |
| 41 int cnt); | 42 void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentS
tage*, |
| 42 void calcCoverageWithPrimProc(const GrPrimitiveProcessor*, const GrFragmentP
rocessor* const[], | 43 int stagecount); |
| 43 int cnt); | |
| 44 | 44 |
| 45 bool isSolidWhite() const { return fInOut.isSolidWhite(); } | 45 bool isSolidWhite() const { return fInOut.isSolidWhite(); } |
| 46 bool isOpaque() const { return fInOut.isOpaque(); } | 46 bool isOpaque() const { return fInOut.isOpaque(); } |
| 47 bool isSingleComponent() const { return fInOut.isSingleComponent(); } | 47 bool isSingleComponent() const { return fInOut.isSingleComponent(); } |
| 48 bool allStagesMultiplyInput() const { return fInOut.allStagesMulInput(); } | 48 bool allStagesMultiplyInput() const { return fInOut.allStagesMulInput(); } |
| 49 | 49 |
| 50 // TODO: Once texture pixel configs quaries are updated, we no longer need t
his function. | 50 // TODO: Once texture pixel configs quaries are updated, we no longer need t
his function. |
| 51 // For now this function will correctly tell us if we are using LCD text or
not and should only | 51 // For now this function will correctly tell us if we are using LCD text or
not and should only |
| 52 // be called when looking at the coverage output. | 52 // be called when looking at the coverage output. |
| 53 bool isFourChannelOutput() const { return !fInOut.isSingleComponent() && | 53 bool isFourChannelOutput() const { return !fInOut.isSingleComponent() && |
| 54 fInOut.isLCDCoverage(); } | 54 fInOut.isLCDCoverage(); } |
| 55 | 55 |
| 56 GrColor color() const { return fInOut.color(); } | 56 GrColor color() const { return fInOut.color(); } |
| 57 | 57 |
| 58 GrColorComponentFlags validFlags() const { | 58 GrColorComponentFlags validFlags() const { |
| 59 return static_cast<GrColorComponentFlags>(fInOut.validFlags()); | 59 return static_cast<GrColorComponentFlags>(fInOut.validFlags()); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * Returns the index of the first effective color processor. If an intermedi
ate processor | 63 * Returns the index of the first effective color stage. If an intermediate
stage doesn't read |
| 64 * doesn't read its input or has a known output, then we can ignore all earl
ier processors | 64 * its input or has a known output, then we can ignore all earlier stages si
nce they will not |
| 65 * since they will not affect the final output. Thus the first effective pro
cessors index is | 65 * affect the final output. Thus the first effective stage index is the inde
x to the first stage |
| 66 * the index to the first processor that will have an effect on the final ou
tput. | 66 * that will have an effect on the final output. |
| 67 * | 67 * |
| 68 * If processors before the firstEffectiveProcessorIndex() are removed, corr
esponding values | 68 * If stages before the firstEffectiveStageIndex are removed, corresponding
values from |
| 69 * from inputColorIsUsed(), inputColorToEffectiveProcessor(), removeVertexAt
tribs(), and | 69 * inputColorIsUsed(), inputColorToEffectiveStage(), removeVertexAttribs(),
and readsDst() must |
| 70 * readsDst() must be used when setting up the draw to ensure correct drawin
g. | 70 * be used when setting up the draw to ensure correct drawing. |
| 71 */ | 71 */ |
| 72 int firstEffectiveProcessorIndex() const { return fFirstEffectiveProcessorIn
dex; } | 72 int firstEffectiveStageIndex() const { return fFirstEffectStageIndex; } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * True if the first effective processor reads its input, false otherwise. | 75 * True if the first effective stage reads its input, false otherwise. |
| 76 */ | 76 */ |
| 77 bool inputColorIsUsed() const { return fInputColorIsUsed; } | 77 bool inputColorIsUsed() const { return fInputColorIsUsed; } |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * If input color is used and per-vertex colors are not used, this is the in
put color to the | 80 * If input color is used and per-vertex colors are not used, this is the in
put color to the |
| 81 * first effective processor. | 81 * first effective stage. |
| 82 */ | 82 */ |
| 83 GrColor inputColorToFirstEffectiveProccesor() const { return fInputColor; } | 83 GrColor inputColorToEffectiveStage() const { return fInputColor; } |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Returns true if any of the processor preserved by GrProcOptInfo read the
frag position. | 86 * Returns true if any of the stages preserved by GrProcOptInfo read the fra
g position. |
| 87 */ | 87 */ |
| 88 bool readsFragPosition() const { return fReadsFragPosition; } | 88 bool readsFragPosition() const { return fReadsFragPosition; } |
| 89 | 89 |
| 90 private: | 90 private: |
| 91 void internalCalc(const GrFragmentProcessor* const[], int cnt, bool initWill
ReadFragPosition); | 91 void internalCalc(const GrFragmentStage*, int stagecount, bool initWillReadF
ragPosition); |
| 92 | 92 |
| 93 GrInvariantOutput fInOut; | 93 GrInvariantOutput fInOut; |
| 94 int fFirstEffectiveProcessorIndex; | 94 int fFirstEffectStageIndex; |
| 95 bool fInputColorIsUsed; | 95 bool fInputColorIsUsed; |
| 96 GrColor fInputColor; | 96 GrColor fInputColor; |
| 97 bool fReadsFragPosition; | 97 bool fReadsFragPosition; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 #endif | 100 #endif |
| OLD | NEW |