OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "GrProcessor.h" | 8 #include "GrProcessor.h" |
9 #include "GrBackendProcessorFactory.h" | 9 #include "GrBackendProcessorFactory.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void GrProcessor::assertEquality(const GrProcessor& other) const { | 81 void GrProcessor::assertEquality(const GrProcessor& other) const { |
82 SkASSERT(this->numTransforms() == other.numTransforms()); | 82 SkASSERT(this->numTransforms() == other.numTransforms()); |
83 for (int i = 0; i < this->numTransforms(); ++i) { | 83 for (int i = 0; i < this->numTransforms(); ++i) { |
84 SkASSERT(this->coordTransform(i) == other.coordTransform(i)); | 84 SkASSERT(this->coordTransform(i) == other.coordTransform(i)); |
85 } | 85 } |
86 SkASSERT(this->numTextures() == other.numTextures()); | 86 SkASSERT(this->numTextures() == other.numTextures()); |
87 for (int i = 0; i < this->numTextures(); ++i) { | 87 for (int i = 0; i < this->numTextures(); ++i) { |
88 SkASSERT(this->textureAccess(i) == other.textureAccess(i)); | 88 SkASSERT(this->textureAccess(i) == other.textureAccess(i)); |
89 } | 89 } |
90 } | 90 } |
91 | |
92 void GrProcessor::InvariantOutput::validate() const { | |
93 if (fIsSingleComponent) { | |
94 SkASSERT(0 == fValidFlags || kRGBA_GrColorComponentFlags == fValidFlags)
; | |
95 if (kRGBA_GrColorComponentFlags == fValidFlags) { | |
96 SkASSERT(this->colorComponentsAllEqual()); | |
97 } | |
98 } | |
99 | |
100 SkASSERT(this->validPreMulColor()); | |
101 } | |
102 | |
103 bool GrProcessor::InvariantOutput::colorComponentsAllEqual() const { | |
104 unsigned colorA = GrColorUnpackA(fColor); | |
105 return(GrColorUnpackR(fColor) == colorA && | |
106 GrColorUnpackG(fColor) == colorA && | |
107 GrColorUnpackB(fColor) == colorA); | |
108 } | |
109 | |
110 bool GrProcessor::InvariantOutput::validPreMulColor() const { | |
111 if (kA_GrColorComponentFlag & fValidFlags) { | |
112 float c[4]; | |
113 GrColorToRGBAFloat(fColor, c); | |
114 if (kR_GrColorComponentFlag & fValidFlags) { | |
115 if (c[0] > c[3]) { | |
116 return false; | |
117 } | |
118 } | |
119 if (kG_GrColorComponentFlag & fValidFlags) { | |
120 if (c[1] > c[3]) { | |
121 return false; | |
122 } | |
123 } | |
124 if (kB_GrColorComponentFlag & fValidFlags) { | |
125 if (c[2] > c[3]) { | |
126 return false; | |
127 } | |
128 } | |
129 } | |
130 return true; | |
131 } | |
132 #endif | 91 #endif |
133 | |
OLD | NEW |