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

Unified Diff: tests/skpdf_opaquesrcmodetosrcover.cpp

Issue 1159763004: SkPDF: with opaque draws, treat SRC mode as SRC_OVER (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unify with blitter code Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« src/core/SkXfermodeInterpretation.h ('K') | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/skpdf_opaquesrcmodetosrcover.cpp
diff --git a/tests/skpdf_opaquesrcmodetosrcover.cpp b/tests/skpdf_opaquesrcmodetosrcover.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f742f3ddd65bb7cb773a778c123939488e216433
--- /dev/null
+++ b/tests/skpdf_opaquesrcmodetosrcover.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "SkCanvas.h"
+#include "SkDocument.h"
+#include "SkStream.h"
+#include "Test.h"
+
+static void run_test(SkWStream* out, SkXfermode::Mode mode, U8CPU alpha) {
+ SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(out));
+ SkCanvas* c = pdfDoc->beginPage(612.0f, 792.0f);
+ SkPaint black;
+ SkPaint background;
+ background.setColor(SK_ColorWHITE);
+ background.setAlpha(alpha);
+ background.setXfermodeMode(mode);
+ c->drawRect(SkRect::MakeWH(612.0f, 792.0f), background);
+ c->drawRect(SkRect::MakeXYWH(36.0f, 36.0f, 9.0f, 9.0f), black);
+ c->drawRect(SkRect::MakeXYWH(72.0f, 72.0f, 468.0f, 648.0f), background);
+ c->drawRect(SkRect::MakeXYWH(108.0f, 108.0f, 9.0f, 9.0f), black);
+ pdfDoc->close();
+}
+
+// http://crbug.com/473572
+DEF_TEST(SkPDF_OpaqueSrcModeToSrcOver, r) {
+ SkDynamicMemoryWStream srcMode;
+ SkDynamicMemoryWStream srcOverMode;
+
+ U8CPU alpha = SK_AlphaOPAQUE;
+ run_test(&srcMode, SkXfermode::kSrc_Mode, alpha);
+ run_test(&srcOverMode, SkXfermode::kSrcOver_Mode, alpha);
+ REPORTER_ASSERT(r, srcMode.getOffset() == srcOverMode.getOffset());
+ // The two PDFs should be equal because they have an opaque alpha.
+
+ srcMode.reset();
+ srcOverMode.reset();
+
+ alpha = 0x80;
+ run_test(&srcMode, SkXfermode::kSrc_Mode, alpha);
+ run_test(&srcOverMode, SkXfermode::kSrcOver_Mode, alpha);
+ REPORTER_ASSERT(r, srcMode.getOffset() > srcOverMode.getOffset());
+ // The two PDFs should not be equal because they have a non-opaque alpha.
+}
« src/core/SkXfermodeInterpretation.h ('K') | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698