OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "SkCanvas.h" | 7 #include "SkCanvas.h" |
8 #include "SkDocument.h" | 8 #include "SkDocument.h" |
9 #include "SkStream.h" | 9 #include "SkStream.h" |
10 #include "Test.h" | 10 #include "Test.h" |
11 | 11 |
| 12 #if SK_SUPPORT_PDF |
| 13 |
12 static void run_test(SkWStream* out, SkXfermode::Mode mode, U8CPU alpha) { | 14 static void run_test(SkWStream* out, SkXfermode::Mode mode, U8CPU alpha) { |
13 SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(out)); | 15 SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(out)); |
14 SkCanvas* c = pdfDoc->beginPage(612.0f, 792.0f); | 16 SkCanvas* c = pdfDoc->beginPage(612.0f, 792.0f); |
15 SkPaint black; | 17 SkPaint black; |
16 SkPaint background; | 18 SkPaint background; |
17 background.setColor(SK_ColorWHITE); | 19 background.setColor(SK_ColorWHITE); |
18 background.setAlpha(alpha); | 20 background.setAlpha(alpha); |
19 background.setXfermodeMode(mode); | 21 background.setXfermodeMode(mode); |
20 c->drawRect(SkRect::MakeWH(612.0f, 792.0f), background); | 22 c->drawRect(SkRect::MakeWH(612.0f, 792.0f), background); |
21 c->drawRect(SkRect::MakeXYWH(36.0f, 36.0f, 9.0f, 9.0f), black); | 23 c->drawRect(SkRect::MakeXYWH(36.0f, 36.0f, 9.0f, 9.0f), black); |
(...skipping 15 matching lines...) Expand all Loading... |
37 | 39 |
38 srcMode.reset(); | 40 srcMode.reset(); |
39 srcOverMode.reset(); | 41 srcOverMode.reset(); |
40 | 42 |
41 alpha = 0x80; | 43 alpha = 0x80; |
42 run_test(&srcMode, SkXfermode::kSrc_Mode, alpha); | 44 run_test(&srcMode, SkXfermode::kSrc_Mode, alpha); |
43 run_test(&srcOverMode, SkXfermode::kSrcOver_Mode, alpha); | 45 run_test(&srcOverMode, SkXfermode::kSrcOver_Mode, alpha); |
44 REPORTER_ASSERT(r, srcMode.getOffset() > srcOverMode.getOffset()); | 46 REPORTER_ASSERT(r, srcMode.getOffset() > srcOverMode.getOffset()); |
45 // The two PDFs should not be equal because they have a non-opaque alpha. | 47 // The two PDFs should not be equal because they have a non-opaque alpha. |
46 } | 48 } |
| 49 #endif // SK_SUPPORT_PDF |
OLD | NEW |