OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkRect.h" | 9 #include "SkRect.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 }; | 155 }; |
156 | 156 |
157 // A function to verify that two bitmaps contain the same pixel values | 157 // A function to verify that two bitmaps contain the same pixel values |
158 // at all coordinates indicated by coords. Simplifies verification of | 158 // at all coordinates indicated by coords. Simplifies verification of |
159 // copied bitmaps. | 159 // copied bitmaps. |
160 static void reportCopyVerification(const SkBitmap& bm1, const SkBitmap& bm2, | 160 static void reportCopyVerification(const SkBitmap& bm1, const SkBitmap& bm2, |
161 Coordinates& coords, | 161 Coordinates& coords, |
162 const char* msg, | 162 const char* msg, |
163 skiatest::Reporter* reporter){ | 163 skiatest::Reporter* reporter){ |
164 bool success = true; | |
165 | |
166 // Confirm all pixels in the list match. | 164 // Confirm all pixels in the list match. |
167 for (int i = 0; i < coords.length; ++i) { | 165 for (int i = 0; i < coords.length; ++i) { |
168 success = success && | 166 uint32_t p1 = getPixel(coords[i]->fX, coords[i]->fY, bm1); |
169 (getPixel(coords[i]->fX, coords[i]->fY, bm1) == | 167 uint32_t p2 = getPixel(coords[i]->fX, coords[i]->fY, bm2); |
170 getPixel(coords[i]->fX, coords[i]->fY, bm2)); | 168 // SkDebugf("[%d] (%d %d) p1=%x p2=%x\n", i, coords[i]->fX, coords[i]->fY
, p1, p2); |
171 } | 169 if (p1 != p2) { |
172 | 170 ERRORF(reporter, "%s [colortype = %s]", msg, gColorTypeName[bm1.colo
rType()]); |
173 if (!success) { | 171 break; |
174 ERRORF(reporter, "%s [colortype = %s]", msg, | 172 } |
175 gColorTypeName[bm1.colorType()]); | |
176 } | 173 } |
177 } | 174 } |
178 | 175 |
179 // Writes unique pixel values at locations specified by coords. | 176 // Writes unique pixel values at locations specified by coords. |
180 static void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) { | 177 static void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) { |
181 for (int i = 0; i < coords.length; ++i) | 178 for (int i = 0; i < coords.length; ++i) |
182 setPixel(coords[i]->fX, coords[i]->fY, i, bm); | 179 setPixel(coords[i]->fX, coords[i]->fY, i, bm); |
183 } | 180 } |
184 | 181 |
185 static const Pair gPairs[] = { | 182 static const Pair gPairs[] = { |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy))
; | 624 REPORTER_ASSERT(reporter, check_4x4_pixel(dstC, sx, sy))
; |
628 } else { | 625 } else { |
629 REPORTER_ASSERT(reporter, 0 == dstC); | 626 REPORTER_ASSERT(reporter, 0 == dstC); |
630 } | 627 } |
631 } | 628 } |
632 } | 629 } |
633 } | 630 } |
634 } | 631 } |
635 } | 632 } |
636 | 633 |
OLD | NEW |