| 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 "SkDevice.h" | 4 #include "SkDevice.h" |
| 5 #include "SkCanvas.h" | 5 #include "SkCanvas.h" |
| 6 #include "SkImageDecoder.h" | 6 #include "SkImageDecoder.h" |
| 7 #include "SkImageEncoder.h" | 7 #include "SkImageEncoder.h" |
| 8 #include "SkStream.h" | 8 #include "SkStream.h" |
| 9 #include "SkOSFile.h" | 9 #include "SkOSFile.h" |
| 10 #include "SkPicture.h" | 10 #include "SkPicture.h" |
| 11 #include "SkString.h" | 11 #include "SkString.h" |
| 12 | 12 |
| 13 static const char pictDir[] = "D:\\skp"; | 13 #ifdef SK_BUILD_FOR_WIN |
| 14 static const char outSkpClipDir[] = "D:\\skpClip"; | 14 #define PATH_SLASH "\\" |
| 15 static const char outOldClipDir[] = "D:\\oldClip"; | 15 #define IN_DIR "D:" PATH_SLASH "skp" |
| 16 #define OUT_DIR "D:" PATH_SLASH |
| 17 #else |
| 18 #define PATH_SLASH "/" |
| 19 #define IN_DIR "/Volumes/Untitled" PATH_SLASH |
| 20 #define OUT_DIR PATH_SLASH |
| 21 #endif |
| 22 |
| 23 static const char pictDir[] = IN_DIR ; |
| 24 static const char outSkpClipDir[] = OUT_DIR "skpClip"; |
| 25 static const char outOldClipDir[] = OUT_DIR "oldClip"; |
| 16 | 26 |
| 17 static void make_filepath(SkString* path, const char* dir, const SkString& name)
{ | 27 static void make_filepath(SkString* path, const char* dir, const SkString& name)
{ |
| 18 size_t len = strlen(dir); | 28 size_t len = strlen(dir); |
| 19 path->set(dir); | 29 path->set(dir); |
| 20 if (len > 0 && dir[len - 1] != '/') { | 30 if (len > 0 && dir[len - 1] != PATH_SLASH[0]) { |
| 21 path->append("\\"); | 31 path->append(PATH_SLASH); |
| 22 } | 32 } |
| 23 path->append(name); | 33 path->append(name); |
| 24 } | 34 } |
| 25 | 35 |
| 26 static void testOne(const SkString& filename) { | 36 static void testOne(const SkString& filename) { |
| 37 #if DEBUG_SHOW_TEST_NAME |
| 38 SkString testName(filename); |
| 39 const char http[] = "http"; |
| 40 if (testName.startsWith(http)) { |
| 41 testName.remove(0, sizeof(http) - 1); |
| 42 } |
| 43 while (testName.startsWith("_")) { |
| 44 testName.remove(0, 1); |
| 45 } |
| 46 const char dotSkp[] = ".skp"; |
| 47 if (testName.endsWith(dotSkp)) { |
| 48 size_t len = testName.size(); |
| 49 testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1); |
| 50 } |
| 51 testName.prepend("skp"); |
| 52 testName.append("1"); |
| 53 strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGT
H); |
| 54 #endif |
| 27 SkString path; | 55 SkString path; |
| 28 make_filepath(&path, pictDir, filename); | 56 make_filepath(&path, pictDir, filename); |
| 29 SkFILEStream stream(path.c_str()); | 57 SkFILEStream stream(path.c_str()); |
| 30 if (!stream.isValid()) { | 58 if (!stream.isValid()) { |
| 31 return; | 59 return; |
| 32 } | 60 } |
| 33 bool success; | 61 bool success; |
| 34 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecoder::
DecodeMemory)); | 62 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecoder::
DecodeMemory)); |
| 35 if (!success) { | 63 if (!success) { |
| 36 SkDebugf("unable to decode %s\n", filename.c_str()); | 64 SkDebugf("unable to decode %s\n", filename.c_str()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 bool useOp = i ? true : false; | 81 bool useOp = i ? true : false; |
| 54 canvas.setAllowSimplifyClip(useOp); | 82 canvas.setAllowSimplifyClip(useOp); |
| 55 pic->draw(&canvas); | 83 pic->draw(&canvas); |
| 56 SkString outFile; | 84 SkString outFile; |
| 57 make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, pngName); | 85 make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, pngName); |
| 58 SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG
_Type, 100); | 86 SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG
_Type, 100); |
| 59 } | 87 } |
| 60 SkDELETE(pic); | 88 SkDELETE(pic); |
| 61 } | 89 } |
| 62 | 90 |
| 91 const char skipBefore[] = "http___health_com.skp"; |
| 92 |
| 63 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { | 93 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { |
| 64 SkOSFile::Iter iter(pictDir, "skp"); | 94 SkOSFile::Iter iter(pictDir, "skp"); |
| 65 SkString filename; | 95 SkString filename; |
| 66 int testCount = 0; | 96 int testCount = 0; |
| 67 while (iter.next(&filename)) { | 97 while (iter.next(&filename)) { |
| 98 if (strcmp(filename.c_str(), skipBefore) < 0) { |
| 99 continue; |
| 100 } |
| 68 testOne(filename); | 101 testOne(filename); |
| 69 if (reporter->verbose()) { | 102 if (reporter->verbose()) { |
| 70 SkDebugf("."); | 103 SkDebugf("."); |
| 71 if (++testCount % 100 == 0) { | 104 if (++testCount % 100 == 0) { |
| 72 SkDebugf("\n"); | 105 SkDebugf("\n"); |
| 73 } | 106 } |
| 74 } | 107 } |
| 75 reporter->bumpTestCount(); | 108 reporter->bumpTestCount(); |
| 76 } | 109 } |
| 77 } | 110 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 88 } | 121 } |
| 89 } | 122 } |
| 90 } | 123 } |
| 91 | 124 |
| 92 static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) { | 125 static void PathOpsSkpClipThreadedTest(skiatest::Reporter* reporter) { |
| 93 int threadCount = initializeTests(reporter, "skpClipThreadedTest"); | 126 int threadCount = initializeTests(reporter, "skpClipThreadedTest"); |
| 94 PathOpsThreadedTestRunner testRunner(reporter, threadCount); | 127 PathOpsThreadedTestRunner testRunner(reporter, threadCount); |
| 95 SkOSFile::Iter iter(pictDir, "skp"); | 128 SkOSFile::Iter iter(pictDir, "skp"); |
| 96 SkString filename; | 129 SkString filename; |
| 97 while (iter.next(&filename)) { | 130 while (iter.next(&filename)) { |
| 131 if (strcmp(filename.c_str(), skipBefore) < 0) { |
| 132 continue; |
| 133 } |
| 98 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, | 134 *testRunner.fRunnables.append() = SkNEW_ARGS(PathOpsThreadedRunnable, |
| 99 (&testSkpClipMain, filename.c_str(), &testRunner)); | 135 (&testSkpClipMain, filename.c_str(), &testRunner)); |
| 100 reporter->bumpTestCount(); | 136 reporter->bumpTestCount(); |
| 101 } | 137 } |
| 102 testRunner.render(); | 138 testRunner.render(); |
| 103 } | 139 } |
| 104 | 140 |
| 105 static void PathOpsSkpClipTestOne(skiatest::Reporter* reporter) { | 141 static void PathOpsSkpClipTestOne(skiatest::Reporter* reporter) { |
| 106 SkString filename("http___9to5employment_com.skp"); | 142 SkString filename(skipBefore); |
| 107 testOne(filename); | 143 testOne(filename); |
| 108 } | 144 } |
| 109 | 145 |
| 110 #include "TestClassDef.h" | 146 #include "TestClassDef.h" |
| 111 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) | 147 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) |
| 112 | 148 |
| 113 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTestOne) | 149 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTestOne) |
| 114 | 150 |
| 115 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest) | 151 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipThreadedTest) |
| OLD | NEW |