OLD | NEW |
1 #include "PathOpsExtendedTest.h" | 1 #include "PathOpsExtendedTest.h" |
2 #include "PathOpsThreadedCommon.h" | 2 #include "PathOpsThreadedCommon.h" |
3 #include "SkBitmap.h" | 3 #include "SkBitmap.h" |
| 4 #include "SkColor.h" |
4 #include "SkDevice.h" | 5 #include "SkDevice.h" |
5 #include "SkCanvas.h" | 6 #include "SkCanvas.h" |
6 #include "SkImageDecoder.h" | 7 #include "SkImageDecoder.h" |
7 #include "SkImageEncoder.h" | 8 #include "SkImageEncoder.h" |
8 #include "SkStream.h" | 9 #include "SkStream.h" |
9 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
10 #include "SkPicture.h" | 11 #include "SkPicture.h" |
11 #include "SkString.h" | 12 #include "SkString.h" |
12 | 13 |
13 #ifdef SK_BUILD_FOR_WIN | 14 #ifdef SK_BUILD_FOR_WIN |
14 #define PATH_SLASH "\\" | 15 #define PATH_SLASH "\\" |
15 #define IN_DIR "D:" PATH_SLASH "skp" | 16 #define IN_DIR "D:" PATH_SLASH "skp" |
16 #define OUT_DIR "D:" PATH_SLASH | 17 #define OUT_DIR "D:" PATH_SLASH |
17 #else | 18 #else |
18 #define PATH_SLASH "/" | 19 #define PATH_SLASH "/" |
19 #define IN_DIR "/Volumes/Untitled" PATH_SLASH | 20 #if 1 |
20 #define OUT_DIR PATH_SLASH | 21 #define IN_DIR "/usr/local/google/home/caryclark/new10k" PATH_SLASH |
| 22 #define OUT_DIR "/usr/local/google/home/caryclark/out10k" PATH_SLASH |
| 23 #else |
| 24 #define IN_DIR "/usr/local/google/home/caryclark/6-18-13" PATH_SLASH |
| 25 #define OUT_DIR "/usr/local/google/home/caryclark" PATH_SLASH |
| 26 #endif |
21 #endif | 27 #endif |
22 | 28 |
23 static const char pictDir[] = IN_DIR ; | 29 static const char pictDir[] = IN_DIR ; |
24 static const char outSkpClipDir[] = OUT_DIR "skpClip"; | 30 static const char outSkpClipDir[] = OUT_DIR "skpClip"; |
25 static const char outOldClipDir[] = OUT_DIR "oldClip"; | 31 static const char outOldClipDir[] = OUT_DIR "oldClip"; |
26 | 32 |
27 static void make_filepath(SkString* path, const char* dir, const SkString& name)
{ | 33 static SkString make_filepath(const char* dir, const SkString& name) { |
| 34 SkString path(dir); |
28 size_t len = strlen(dir); | 35 size_t len = strlen(dir); |
29 path->set(dir); | |
30 if (len > 0 && dir[len - 1] != PATH_SLASH[0]) { | 36 if (len > 0 && dir[len - 1] != PATH_SLASH[0]) { |
31 path->append(PATH_SLASH); | 37 path.append(PATH_SLASH); |
32 } | 38 } |
33 path->append(name); | 39 path.append(name); |
| 40 return path; |
| 41 } |
| 42 |
| 43 static SkString make_png_name(const SkString& filename) { |
| 44 SkString pngName = SkString(filename); |
| 45 pngName.remove(pngName.size() - 3, 3); |
| 46 pngName.append("png"); |
| 47 return pngName; |
34 } | 48 } |
35 | 49 |
36 static void testOne(const SkString& filename) { | 50 static void testOne(const SkString& filename) { |
| 51 if (filename == SkString("http___migracioncolombia_gov_co.skp") |
| 52 || filename == SkString("http___miuki_info.skp") |
| 53 ) { |
| 54 return; |
| 55 } |
37 #if DEBUG_SHOW_TEST_NAME | 56 #if DEBUG_SHOW_TEST_NAME |
38 SkString testName(filename); | 57 SkString testName(filename); |
39 const char http[] = "http"; | 58 const char http[] = "http"; |
40 if (testName.startsWith(http)) { | 59 if (testName.startsWith(http)) { |
41 testName.remove(0, sizeof(http) - 1); | 60 testName.remove(0, sizeof(http) - 1); |
42 } | 61 } |
43 while (testName.startsWith("_")) { | 62 while (testName.startsWith("_")) { |
44 testName.remove(0, 1); | 63 testName.remove(0, 1); |
45 } | 64 } |
46 const char dotSkp[] = ".skp"; | 65 const char dotSkp[] = ".skp"; |
47 if (testName.endsWith(dotSkp)) { | 66 if (testName.endsWith(dotSkp)) { |
48 size_t len = testName.size(); | 67 size_t len = testName.size(); |
49 testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1); | 68 testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1); |
50 } | 69 } |
51 testName.prepend("skp"); | 70 testName.prepend("skp"); |
52 testName.append("1"); | 71 testName.append("1"); |
53 strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGT
H); | 72 strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGT
H); |
54 #endif | 73 #endif |
55 SkString path; | 74 SkString path = make_filepath(pictDir, filename); |
56 make_filepath(&path, pictDir, filename); | |
57 SkFILEStream stream(path.c_str()); | 75 SkFILEStream stream(path.c_str()); |
58 if (!stream.isValid()) { | 76 if (!stream.isValid()) { |
59 return; | 77 return; |
60 } | 78 } |
61 SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::Decod
eMemory); | 79 SkPicture* pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::Decod
eMemory); |
62 if (!pic) { | 80 if (!pic) { |
63 SkDebugf("unable to decode %s\n", filename.c_str()); | 81 SkDebugf("unable to decode %s\n", filename.c_str()); |
64 return; | 82 return; |
65 } | 83 } |
66 int width = pic->width(); | 84 int width = pic->width(); |
67 int height = pic->height(); | 85 int height = pic->height(); |
| 86 |
68 SkBitmap bitmap; | 87 SkBitmap bitmap; |
69 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 88 int scale = 1; |
70 bool success = bitmap.allocPixels(); | 89 do { |
71 if (!success) { | 90 bitmap.setConfig(SkBitmap::kARGB_8888_Config, (width + scale - 1) / scal
e, |
72 SkDebugf("unable to allocate bitmap for %s\n", filename.c_str()); | 91 (height + scale - 1) / scale); |
| 92 bool success = bitmap.allocPixels(); |
| 93 bitmap.eraseColor(SK_ColorWHITE); |
| 94 if (success) { |
| 95 break; |
| 96 } |
| 97 SkDebugf("-%d-", scale); |
| 98 } while ((scale *= 2) < 32); |
| 99 if (scale >= 32) { |
| 100 SkDebugf("unable to allocate bitmap for %s (w=%d h=%d)\n", filename.c_st
r(), |
| 101 width, height); |
73 return; | 102 return; |
74 } | 103 } |
75 SkCanvas canvas(bitmap); | 104 SkCanvas canvas(bitmap); |
76 SkString pngName(filename); | 105 canvas.scale(1.0f / scale, 1.0f / scale); |
77 pngName.remove(pngName.size() - 3, 3); | 106 SkString pngName = make_png_name(filename); |
78 pngName.append("png"); | |
79 for (int i = 0; i < 2; ++i) { | 107 for (int i = 0; i < 2; ++i) { |
80 bool useOp = i ? true : false; | 108 bool useOp = i ? true : false; |
81 canvas.setAllowSimplifyClip(useOp); | 109 canvas.setAllowSimplifyClip(useOp); |
82 pic->draw(&canvas); | 110 pic->draw(&canvas); |
83 SkString outFile; | 111 SkString outFile = make_filepath(useOp ? outSkpClipDir : outOldClipDir,
pngName); |
84 make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, pngName); | 112 if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder:
:kPNG_Type, |
85 SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG
_Type, 100); | 113 100)) { |
| 114 SkDebugf("unable to encode %s (width=%d height=%d)\n", pngName.c_str
(), |
| 115 bitmap.width(), bitmap.height()); |
| 116 } |
86 } | 117 } |
87 SkDELETE(pic); | 118 SkDELETE(pic); |
88 } | 119 } |
89 | 120 |
90 const char skipBefore[] = "http___kkiste_to.skp"; | 121 const char* tryFixed[] = { |
| 122 0 |
| 123 }; |
| 124 |
| 125 size_t tryFixedCount = sizeof(tryFixed) / sizeof(tryFixed[0]); |
| 126 |
| 127 const char* skipOver[] = { |
| 128 "http___carpetplanet_ru.skp", // cubic/cubic intersect |
| 129 "http___carrot_is.skp", // bridgeOp() SkASSERT(unsortable || !current->don
e()); |
| 130 |
| 131 /*!*/"http___dotsrc_org.skp", // asserts in png decode |
| 132 "http___frauen_magazin_com.skp", // bridgeOp() SkASSERT(unsortable || !cur
rent->done()); |
| 133 "http___i_gino_com.skp", // unexpected cubic/quad coincidence |
| 134 // {61, 857, 61, 789.06897, 116.068977, 734, 184, 73
4} |
| 135 // {184, 734, 133.051727, 734, 97.0258636, 770.02587
9} |
| 136 "http___ilkoora_com.skp", // assert wind sum != min32 from markDoneBinary /
findNextOp #28k |
| 137 /*!*/"http___migracioncolombia_gov_co.skp", // crashes on picture decode |
| 138 "http___mm4everfriends_com.skp", // bumpSpan/addTCoincident (from calcParti
alCoincidentWinding) |
| 139 "http___mtrk_uz.skp", // checkEnds() assert #36.3k |
| 140 "http___pchappy_com_au.skp", // bridgeOp() assert unsortable || ! empty #37
.2k |
| 141 "http___sciality_com.skp", // bridgeOp() SkASSERT(unsortable || !current->
done()); #32.4k |
| 142 /*!*/"http___sozialticker_com.skp", // asserts in png decode |
| 143 "http___sudoestenegocios_com.skp", // assert fT < 1 in addTCoincident |
| 144 "http___thesuburbanite_com.skp", // bridgeOp() SkASSERT(unsortable || !cur
rent->done()); |
| 145 |
| 146 "http___fluentin3months_com.skp", // calcCommonCoincidentWinding from calcPa
rtialCoincidentWinding #38.3k |
| 147 "http___teachersbadi_blogspot_in.skp", // calcCommonCoincidentWinding from
calcPartialCoincidentWinding #53.4k |
| 148 "http___wsms_ru.skp", // assert wind sum != min32 from markDoneBinary / fin
dNextOp #49.5k |
| 149 "http___voycer_de.skp", // calcCommonCoincidentWinding from calcPartialCoin
cidentWinding #47k |
| 150 "http___77hz_jp.skp", // addTCancel from calcCoincidentWinding #47.1k |
| 151 |
| 152 "http___hostloco_com.skp", // t < 0 AddIntersectsT |
| 153 /*!*/"http___oggicronaca_it.skp", // asserts in png decode |
| 154 "http___sergeychunkevich_com.skp", // t < 0 AddIntersectsT |
| 155 "http___tracksflow_com.skp", // assert otherEnd >= 0 from nextChase |
| 156 "http___autobutler_dk.skp", // t < 0 AddIntersectsT |
| 157 "http___onlinecollege_org.skp", // bridgeOp() assert unsortable || ! empty
#100.1k |
| 158 "http___national_com_au.skp", // bridgeOp() assert unsortable || ! empty #1
10.2k |
| 159 /*!*/"http___anitadongre_com.skp", // exceptionally large width and height |
| 160 "http___rentacheat_com.skp", // bridgeOp() assert unsortable || ! empty #11
0.8k |
| 161 /*!*/"http___gruesse_de.skp", // asserts in png decode |
| 162 /*!*/"http___crn_in.png", // width=1250047 |
| 163 "http___breakmystyle_com.skp", // assert qPt == lPt in quad intersection |
| 164 "http___naoxrane_ru.skp", // assert t4+...t0 == 0 in quartic roots #128.3k |
| 165 "http___tcmevents_org.skp", // assert in addTCoincident (from calcPartialCo
incidentWinding) #143.3k |
| 166 /*!*/"http___listbuildingcashsecrets_com.skp", // asserts in png decode #152.7k |
| 167 /*!*/"http___skyscraperpage_com.skp", // asserts in png decode #155.5k |
| 168 "http___mlk_com.skp", // bridgeOp() assert unsortable || ! empty #158.7k |
| 169 "http___sd_graphic_net.skp", // bridgeOp() assert unsortable || ! empty #16
3.3k |
| 170 "http___kopepasah_com.skp", // checkEnds() assert #188.2k |
| 171 /*!*/"http___darkreloaded_com.skp", // asserts in png decode #188.4k |
| 172 "http___redbullskatearcade_es.skp", // bridgeOp() assert unsortable || ! em
pty #192.5k |
| 173 "http___partainasdemo250_org.skp", // bridgeOp() assert unsortable || ! em
pty #200.2k |
| 174 |
| 175 // these failures are from the new 10k set |
| 176 "http___www_freerepublic_com_.skp", // assert in opangle < |
| 177 "http___www_lavoixdunord_fr_.skp", // bridgeOp() assert unsortable || ! emp
ty |
| 178 "http___www_booking_com_.skp", // bridgeOp() assert unsortable || ! empty |
| 179 "http___www_fj_p_com_.skp", // markWinding assert from findChaseOp |
| 180 "http___www_leadpages_net_.skp", // assert in opangle < |
| 181 "http___www_despegar_com_mx_.skp", // bridgeOp() assert unsortable || ! emp
ty |
| 182 }; |
| 183 |
| 184 size_t skipOverCount = sizeof(skipOver) / sizeof(skipOver[0]); |
91 | 185 |
92 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { | 186 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { |
93 SkOSFile::Iter iter(pictDir, "skp"); | 187 SkOSFile::Iter iter(pictDir, "skp"); |
94 SkString filename; | 188 SkString filename; |
95 int testCount = 0; | 189 int testCount = 0; |
96 while (iter.next(&filename)) { | 190 while (iter.next(&filename)) { |
97 if (strcmp(filename.c_str(), skipBefore) < 0) { | 191 SkString pngName = make_png_name(filename); |
| 192 SkString oldPng = make_filepath(outOldClipDir, pngName); |
| 193 SkString newPng = make_filepath(outSkpClipDir, pngName); |
| 194 if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) { |
| 195 reporter->bumpTestCount(); |
98 continue; | 196 continue; |
99 } | 197 } |
| 198 for (size_t index = 0; index < skipOverCount; ++index) { |
| 199 if (skipOver[index] && strcmp(filename.c_str(), skipOver[index]) ==
0) { |
| 200 reporter->bumpTestCount(); |
| 201 goto skipOver; |
| 202 } |
| 203 } |
100 testOne(filename); | 204 testOne(filename); |
101 if (reporter->verbose()) { | 205 if (reporter->verbose()) { |
102 SkDebugf("."); | 206 SkDebugf("."); |
103 if (++testCount % 100 == 0) { | 207 if (++testCount % 100 == 0) { |
104 SkDebugf("\n"); | 208 SkDebugf("%d\n", testCount); |
105 } | 209 } |
106 } | 210 } |
| 211 skipOver: |
107 reporter->bumpTestCount(); | 212 reporter->bumpTestCount(); |
108 } | 213 } |
109 } | 214 } |
110 | 215 |
| 216 static void bumpCount(skiatest::Reporter* reporter, bool skipping) { |
| 217 if (reporter->verbose()) { |
| 218 static int threadTestCount; |
| 219 if (!skipping) { |
| 220 SkDebugf("."); |
| 221 } |
| 222 sk_atomic_inc(&threadTestCount); |
| 223 if (!skipping && threadTestCount % 100 == 0) { |
| 224 SkDebugf("%d\n", threadTestCount); |
| 225 } |
| 226 if (skipping && threadTestCount % 10000 == 0) { |
| 227 SkDebugf("%d\n", threadTestCount); |
| 228 } |
| 229 } |
| 230 } |
| 231 |
111 static void testSkpClipMain(PathOpsThreadState* data) { | 232 static void testSkpClipMain(PathOpsThreadState* data) { |
112 SkString str(data->fSerialNo); | 233 SkString str(data->fSerialNo); |
113 testOne(str); | 234 testOne(str); |
114 if (data->fReporter->verbose()) { | 235 bumpCount(data->fReporter, false); |
115 SkDebugf("."); | 236 data->fReporter->bumpTestCount(); |
116 static int threadTestCount; | |
117 sk_atomic_inc(&threadTestCount); | |
118 if (threadTestCount % 100 == 0) { | |
119 SkDebugf("\n"); | |
120 } | |
121 } | |
122 } | 237 } |
123 | 238 |
124 static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) { | 239 static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) { |
125 int threadCount = initializeTests(reporter, "skpClipThreadedTest"); | 240 int threadCount = initializeTests(reporter, "skpClipThreadedTest"); |
126 PathOpsThreadedTestRunner testRunner(reporter, threadCount); | 241 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
127 SkOSFile::Iter iter(pictDir, "skp"); | 242 SkOSFile::Iter iter(pictDir, "skp"); |
128 SkString filename; | 243 SkString filename; |
129 while (iter.next(&filename)) { | 244 while (iter.next(&filename)) { |
130 if (strcmp(filename.c_str(), skipBefore) < 0) { | 245 SkString pngName = make_png_name(filename); |
| 246 SkString oldPng = make_filepath(outOldClipDir, pngName); |
| 247 SkString newPng = make_filepath(outSkpClipDir, pngName); |
| 248 if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) { |
| 249 bumpCount(reporter, true); |
131 continue; | 250 continue; |
132 } | 251 } |
| 252 for (size_t index = 0; index < skipOverCount; ++index) { |
| 253 if (skipOver[index] && strcmp(filename.c_str(), skipOver[index]) ==
0) { |
| 254 bumpCount(reporter, true); |
| 255 goto skipOver; |
| 256 } |
| 257 } |
133 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, | 258 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, |
134 (&testSkpClipMain, filename.c_str(), &testRunner)); | 259 (&testSkpClipMain, filename.c_str(), &testRunner)); |
135 reporter->bumpTestCount(); | 260 skipOver: |
| 261 ; |
136 } | 262 } |
137 testRunner.render(); | 263 testRunner.render(); |
138 } | 264 } |
139 | 265 |
| 266 static void PathOpsSkpClipFixedTest(skiatest::Reporter* reporter) { |
| 267 for (size_t index = 0; index < tryFixedCount; ) { |
| 268 SkString filename(tryFixed[index]); |
| 269 testOne(filename); |
| 270 ++index; |
| 271 if (reporter->verbose()) { |
| 272 SkDebugf("."); |
| 273 if (index % 100 == 0) { |
| 274 SkDebugf("\n"); |
| 275 } |
| 276 } |
| 277 reporter->bumpTestCount(); |
| 278 } |
| 279 } |
| 280 |
140 static void PathOpsSkpClipOneOffTest(skiatest::Reporter* reporter) { | 281 static void PathOpsSkpClipOneOffTest(skiatest::Reporter* reporter) { |
141 SkString filename(skipBefore); | 282 SkString filename("http___78_cn_.skp"); |
142 testOne(filename); | 283 testOne(filename); |
143 } | 284 } |
144 | 285 |
145 #include "TestClassDef.h" | 286 #include "TestClassDef.h" |
146 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) | 287 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) |
147 | 288 |
| 289 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipFixedTest) |
| 290 |
148 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipOneOffTest) | 291 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipOneOffTest) |
149 | 292 |
150 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest) | 293 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest) |
OLD | NEW |