Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: tests/PathOpsSkpClipTest.cpp

Issue 15338003: path ops -- rewrite angle sort (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsTestCommon.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "SkBitmap.h" 1 #include "SkBitmap.h"
2 #include "SkDevice.h" 2 #include "SkDevice.h"
3 #include "SkCanvas.h" 3 #include "SkCanvas.h"
4 #include "SkImageDecoder.h"
4 #include "SkImageEncoder.h" 5 #include "SkImageEncoder.h"
5 #include "SkStream.h" 6 #include "SkStream.h"
6 #include "SkOSFile.h" 7 #include "SkOSFile.h"
7 #include "SkPicture.h" 8 #include "SkPicture.h"
8 #include "SkString.h" 9 #include "SkString.h"
9 #include "Test.h" 10 #include "Test.h"
10 11
11 static void make_filepath(SkString* path, const char* dir, const SkString& name) { 12 static void make_filepath(SkString* path, const char* dir, const SkString& name) {
12 size_t len = strlen(dir); 13 size_t len = strlen(dir);
13 path->set(dir); 14 path->set(dir);
14 if (len > 0 && dir[len - 1] != '/') { 15 if (len > 0 && dir[len - 1] != '/') {
15 path->append("\\"); 16 path->append("\\");
16 } 17 }
17 path->append(name); 18 path->append(name);
18 } 19 }
19 20
20 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) { 21 static void PathOpsSkpClipTest(skiatest::Reporter* reporter) {
21 const char pictDir[] = "C:\\Users\\caryclark\\skp"; 22 const char pictDir[] = "D:\\skp";
22 const char outSkpClipDir[] = "C:\\Users\\caryclark\\skpClip"; 23 const char outSkpClipDir[] = "D:\\skpClip";
23 const char outOldClipDir[] = "C:\\Users\\caryclark\\oldClip"; 24 const char outOldClipDir[] = "D:\\oldClip";
24 SkOSFile::Iter iter(pictDir, "skp"); 25 SkOSFile::Iter iter(pictDir, "skp");
25 SkString filename; 26 SkString filename;
26 while (iter.next(&filename)) { 27 while (iter.next(&filename)) {
27 #if 0 28 #if 01
28 if (strcmp(filename.c_str(), "tabl_androidpolice.skp")) { 29 if (strcmp(filename.c_str(), "desk_15min-lt.skp")) {
29 continue; 30 continue;
30 } 31 }
31 #endif 32 #endif
32 SkString path; 33 SkString path;
33 make_filepath(&path, pictDir, filename); 34 make_filepath(&path, pictDir, filename);
34 SkFILEStream stream(path.c_str()); 35 SkFILEStream stream(path.c_str());
35 if (!stream.isValid()) { 36 if (!stream.isValid()) {
36 continue; 37 continue;
37 } 38 }
38 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream)); 39 bool success;
40 SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream, &success, &SkImageDecod er::DecodeMemory));
41 if (!success) {
42 continue;
43 }
39 int width = pic->width(); 44 int width = pic->width();
40 int height = pic->height(); 45 int height = pic->height();
41 SkBitmap bitmap; 46 SkBitmap bitmap;
42 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); 47 bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
43 bitmap.allocPixels(); 48 bitmap.allocPixels();
44 SkCanvas canvas(bitmap); 49 SkCanvas canvas(bitmap);
45 filename.remove(filename.size() - 3, 3); 50 filename.remove(filename.size() - 3, 3);
46 filename.append("png"); 51 filename.append("png");
47 for (int i = 0; i < 2; ++i) { 52 for (int i = 0; i < 2; ++i) {
48 bool useOp = i ? true : false; 53 bool useOp = i ? true : false;
49 canvas.setAllowSimplifyClip(useOp); 54 canvas.setAllowSimplifyClip(useOp);
50 pic->draw(&canvas); 55 pic->draw(&canvas);
51 SkString outFile; 56 SkString outFile;
52 make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, filen ame); 57 make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, filen ame);
53 SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder:: kPNG_Type, 100); 58 SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder:: kPNG_Type, 100);
54 } 59 }
55 SkDELETE(pic); 60 SkDELETE(pic);
56 reporter->bumpTestCount(); 61 reporter->bumpTestCount();
57 } 62 }
58 } 63 }
59 64
60 #include "TestClassDef.h" 65 #include "TestClassDef.h"
61 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest) 66 DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest)
OLDNEW
« no previous file with comments | « tests/PathOpsSimplifyTest.cpp ('k') | tests/PathOpsTestCommon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698