Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 *sk_bmp->getAddr32(x,y) = OFF; | 56 *sk_bmp->getAddr32(x,y) = OFF; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 static bool test_bmp(skiatest::Reporter* reporter, | 62 static bool test_bmp(skiatest::Reporter* reporter, |
| 63 const SkBitmap* bmp1, const SkBitmap* bmp2, | 63 const SkBitmap* bmp1, const SkBitmap* bmp2, |
| 64 int h, int w) { | 64 int h, int w) { |
| 65 for (int y = 0; y < h; ++y) { // loop through all pixels | 65 for (int y = 0; y < h; ++y) { // loop through all pixels |
| 66 for (int x = 0; x < w; ++x) { | 66 for (int x = 0; x < w; ++x) { |
|
robertphillips
2013/07/13 17:01:08
This change seems correct but makes the test fail
| |
| 67 REPORTER_ASSERT( reporter, *bmp1->getAddr32(x,y) == *bmp1->getAddr32 (x,y) ); | 67 REPORTER_ASSERT( reporter, *bmp1->getAddr32(x,y) == *bmp2->getAddr32 (x,y) ); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 | 72 |
| 73 static void test_path_eq(skiatest::Reporter* reporter, const SkPath* path, | 73 static void test_path_eq(skiatest::Reporter* reporter, const SkPath* path, |
| 74 const SkBitmap* truth, int h, int w){ | 74 const SkBitmap* truth, int h, int w){ |
| 75 // make paint | 75 // make paint |
| 76 SkPaint bmpPaint; | 76 SkPaint bmpPaint; |
| 77 bmpPaint.setAntiAlias(true); // Black paint for bitmap | 77 bmpPaint.setAntiAlias(true); // Black paint for bitmap |
| 78 bmpPaint.setStyle(SkPaint::kFill_Style); | 78 bmpPaint.setStyle(SkPaint::kFill_Style); |
| 79 bmpPaint.setColor(SK_ColorBLACK); | 79 bmpPaint.setColor(SK_ColorBLACK); |
| 80 | 80 |
| 81 // make bmp | 81 // make bmp |
| 82 SkBitmap bmp; | 82 SkBitmap bmp; |
| 83 bmp.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 83 bmp.setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 84 bmp.allocPixels(); | 84 bmp.allocPixels(); |
| 85 SkCanvas(bmp).drawPath(*path, bmpPaint); | 85 SkCanvas canvas(bmp); |
| 86 canvas.clear(0xFFFFFFFF); | |
| 87 canvas.drawPath(*path, bmpPaint); | |
| 86 | 88 |
| 87 // test bmp | 89 // test bmp |
| 88 test_bmp(reporter, &bmp, truth, h, w); | 90 test_bmp(reporter, &bmp, truth, h, w); |
| 89 } | 91 } |
| 90 | 92 |
| 91 static void test_path(skiatest::Reporter* reporter, const SkBitmap* truth, | 93 static void test_path(skiatest::Reporter* reporter, const SkBitmap* truth, |
| 92 const char* bin_bmp, int h, int w, int stride){ | 94 const char* bin_bmp, int h, int w, int stride){ |
| 93 // make path | 95 // make path |
| 94 SkPath path; | 96 SkPath path; |
| 95 SkPathUtils::BitsToPath_Path(&path, bin_bmp, h, w, stride); | 97 SkPathUtils::BitsToPath_Path(&path, bin_bmp, h, w, stride); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 bin2SkBitmap(bin_bmp, &bmpTruth, h, w[i], stride); | 132 bin2SkBitmap(bin_bmp, &bmpTruth, h, w[i], stride); |
| 131 | 133 |
| 132 test_path(reporter, &bmpTruth, bin_bmp, h, w[i], stride); | 134 test_path(reporter, &bmpTruth, bin_bmp, h, w[i], stride); |
| 133 test_region(reporter, &bmpTruth, bin_bmp, h, w[i], stride); | 135 test_region(reporter, &bmpTruth, bin_bmp, h, w[i], stride); |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 } | 138 } |
| 137 | 139 |
| 138 #include "TestClassDef.h" | 140 #include "TestClassDef.h" |
| 139 DEFINE_TESTCLASS("PathUtils", PathUtils, TestPathUtils) | 141 DEFINE_TESTCLASS("PathUtils", PathUtils, TestPathUtils) |
| OLD | NEW |