aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsSkpClipTest.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-07 18:51:31 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-05-07 18:51:31 +0000
commita5e55925ea03e76885804bda77408a1d6f04c335 (patch)
tree346772e0d28a5483ca807742cf5e074cf3fb0bb5 /tests/PathOpsSkpClipTest.cpp
parent3faf1f1fb6157c49bd09cd3c78dc88421e70deb7 (diff)
path ops -- fix skp bugs
This fixes a series of bugs discovered by running the small set of Skia skp files through pathops to flatten the clips. Review URL: https://codereview.chromium.org/14798004 git-svn-id: http://skia.googlecode.com/svn/trunk@9042 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathOpsSkpClipTest.cpp')
-rw-r--r--tests/PathOpsSkpClipTest.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
new file mode 100644
index 0000000000..595a91a99f
--- /dev/null
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -0,0 +1,61 @@
+#include "SkBitmap.h"
+#include "SkDevice.h"
+#include "SkCanvas.h"
+#include "SkImageEncoder.h"
+#include "SkStream.h"
+#include "SkOSFile.h"
+#include "SkPicture.h"
+#include "SkString.h"
+#include "Test.h"
+
+static void make_filepath(SkString* path, const char* dir, const SkString& name) {
+ size_t len = strlen(dir);
+ path->set(dir);
+ if (len > 0 && dir[len - 1] != '/') {
+ path->append("\\");
+ }
+ path->append(name);
+}
+
+static void PathOpsSkpClipTest(skiatest::Reporter* reporter) {
+const char pictDir[] = "C:\\Users\\caryclark\\skp";
+ const char outSkpClipDir[] = "C:\\Users\\caryclark\\skpClip";
+ const char outOldClipDir[] = "C:\\Users\\caryclark\\oldClip";
+ SkOSFile::Iter iter(pictDir, "skp");
+ SkString filename;
+ while (iter.next(&filename)) {
+#if 0
+ if (strcmp(filename.c_str(), "tabl_androidpolice.skp")) {
+ continue;
+ }
+#endif
+ SkString path;
+ make_filepath(&path, pictDir, filename);
+ SkFILEStream stream(path.c_str());
+ if (!stream.isValid()) {
+ continue;
+ }
+ SkPicture* pic = SkNEW_ARGS(SkPicture, (&stream));
+ int width = pic->width();
+ int height = pic->height();
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ bitmap.allocPixels();
+ SkCanvas canvas(bitmap);
+ filename.remove(filename.size() - 3, 3);
+ filename.append("png");
+ for (int i = 0; i < 2; ++i) {
+ bool useOp = i ? true : false;
+ canvas.setAllowSimplifyClip(useOp);
+ pic->draw(&canvas);
+ SkString outFile;
+ make_filepath(&outFile, useOp ? outSkpClipDir : outOldClipDir, filename);
+ SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
+ }
+ SkDELETE(pic);
+ reporter->bumpTestCount();
+ }
+}
+
+#include "TestClassDef.h"
+DEFINE_TESTCLASS_SHORT(PathOpsSkpClipTest)