When finished, dr->fResult should have some value other than kUnknown_Result. Expects dr->fWhite.fBitmap and dr->fDifference.fBitmap to have the same bounds as dr->fBase.fBitmap and have a valid pixelref.
158 {
159 const int w =
dr->fComparison.fBitmap.width();
160 const int h =
dr->fComparison.fBitmap.height();
161 if (
w !=
dr->fBase.fBitmap.width() ||
h !=
dr->fBase.fBitmap.height()) {
163 return;
164 }
165
166 int mismatchedPixels = 0;
167 int totalMismatchA = 0;
168 int totalMismatchR = 0;
169 int totalMismatchG = 0;
170 int totalMismatchB = 0;
171
172
173
174 dr->fWeightedFraction = 0;
175 for (
int y = 0;
y <
h;
y++) {
176 for (
int x = 0;
x <
w;
x++) {
179 SkPMColor outputDifference = diffFunction(c0, c1);
184 totalMismatchA += thisA;
185 totalMismatchR += thisR;
186 totalMismatchG += thisG;
187 totalMismatchB += thisB;
188
191 if (thisA >
dr->fMaxMismatchA) {
192 dr->fMaxMismatchA = thisA;
193 }
194 if (thisR >
dr->fMaxMismatchR) {
195 dr->fMaxMismatchR = thisR;
196 }
197 if (thisG >
dr->fMaxMismatchG) {
198 dr->fMaxMismatchG = thisG;
199 }
200 if (thisB >
dr->fMaxMismatchB) {
201 dr->fMaxMismatchB = thisB;
202 }
204 mismatchedPixels++;
205 *
dr->fDifference.fBitmap.getAddr32(
x,
y) = outputDifference;
207 } else {
208 *
dr->fDifference.fBitmap.getAddr32(
x,
y) = 0;
210 }
211 }
212 }
213 if (0 == mismatchedPixels) {
215 return;
216 }
218 int pixelCount =
w *
h;
219 dr->fFractionDifference = ((
float) mismatchedPixels) / pixelCount;
220 dr->fWeightedFraction /= pixelCount;
221 dr->fTotalMismatchA = totalMismatchA;
222 dr->fAverageMismatchA = ((
float) totalMismatchA) / pixelCount;
223 dr->fAverageMismatchR = ((
float) totalMismatchR) / pixelCount;
224 dr->fAverageMismatchG = ((
float) totalMismatchG) / pixelCount;
225 dr->fAverageMismatchB = ((
float) totalMismatchB) / pixelCount;
226}
static bool colors_match_thresholded(SkPMColor c0, SkPMColor c1, const int threshold)
const SkPMColor PMCOLOR_BLACK
const SkPMColor PMCOLOR_WHITE
@ kDifferentPixels_Result