OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
8 /* | 8 /* |
9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
10 * | 10 * |
11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh | 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh |
12 * to make sure they still pass... you may need to change the expected | 12 * to make sure they still pass... you may need to change the expected |
13 * results of the self-test. | 13 * results of the self-test. |
14 */ | 14 */ |
15 | 15 |
16 #include "gm.h" | 16 #include "gm.h" |
17 #include "gm_error.h" | 17 #include "gm_error.h" |
18 #include "gm_expectations.h" | 18 #include "gm_expectations.h" |
19 #include "system_preferences.h" | 19 #include "system_preferences.h" |
20 #include "SkBitmap.h" | 20 #include "SkBitmap.h" |
21 #include "SkColorPriv.h" | 21 #include "SkColorPriv.h" |
22 #include "SkCommandLineFlags.h" | 22 #include "SkCommandLineFlags.h" |
23 #include "SkData.h" | 23 #include "SkData.h" |
24 #include "SkDeferredCanvas.h" | 24 #include "SkDeferredCanvas.h" |
25 #include "SkDevice.h" | 25 #include "SkDevice.h" |
26 #include "SkDocument.h" | |
26 #include "SkDrawFilter.h" | 27 #include "SkDrawFilter.h" |
27 #include "SkForceLinking.h" | 28 #include "SkForceLinking.h" |
28 #include "SkGPipe.h" | 29 #include "SkGPipe.h" |
29 #include "SkGraphics.h" | 30 #include "SkGraphics.h" |
30 #include "SkImageDecoder.h" | 31 #include "SkImageDecoder.h" |
31 #include "SkImageEncoder.h" | 32 #include "SkImageEncoder.h" |
32 #include "SkOSFile.h" | 33 #include "SkOSFile.h" |
33 #include "SkPDFRasterizer.h" | 34 #include "SkPDFRasterizer.h" |
34 #include "SkPicture.h" | 35 #include "SkPicture.h" |
35 #include "SkRefCnt.h" | 36 #include "SkRefCnt.h" |
37 #include "SkScalar.h" | |
36 #include "SkStream.h" | 38 #include "SkStream.h" |
37 #include "SkTArray.h" | 39 #include "SkTArray.h" |
38 #include "SkTDict.h" | 40 #include "SkTDict.h" |
39 #include "SkTileGridPicture.h" | 41 #include "SkTileGridPicture.h" |
40 #include "SamplePipeControllers.h" | 42 #include "SamplePipeControllers.h" |
41 | 43 |
42 #ifdef SK_DEBUG | 44 #ifdef SK_DEBUG |
43 static const bool kDebugOnly = true; | 45 static const bool kDebugOnly = true; |
44 #else | 46 #else |
45 static const bool kDebugOnly = false; | 47 static const bool kDebugOnly = false; |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 installFilter(&canvas); | 613 installFilter(&canvas); |
612 canvas.scale(scale, scale); | 614 canvas.scale(scale, scale); |
613 canvas.drawPicture(*pict); | 615 canvas.drawPicture(*pict); |
614 complete_bitmap(bitmap); | 616 complete_bitmap(bitmap); |
615 } | 617 } |
616 } | 618 } |
617 | 619 |
618 static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { | 620 static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { |
619 #ifdef SK_SUPPORT_PDF | 621 #ifdef SK_SUPPORT_PDF |
620 SkMatrix initialTransform = gm->getInitialTransform(); | 622 SkMatrix initialTransform = gm->getInitialTransform(); |
621 SkISize pageSize = gm->getISize(); | 623 SkISize pageISize = gm->getISize(); |
622 SkPDFDevice* dev = NULL; | 624 SkSize pageSize = SkSize::Make(SkIntToScalar(pageISize.width()), SkIntTo Scalar(pageISize.height())); |
623 if (initialTransform.isIdentity()) { | 625 SkAutoTUnref<SkDocument> pdfDoc(SkDocument::CreatePDF(&pdf, NULL, encode _to_dct_stream)); |
624 dev = new SkPDFDevice(pageSize, pageSize, initialTransform); | 626 SkCanvas* canvas = NULL; |
625 } else { | 627 canvas = pdfDoc->beginPage(pageSize); |
626 SkRect content = SkRect::MakeWH(SkIntToScalar(pageSize.width()), | 628 canvas->setMatrix(initialTransform); |
vandebo (ex-Chrome)
2013/09/27 15:50:17
Until the old constructor is removed, I think it's
edisonn
2013/10/04 19:40:37
Now SkPDFDeviceFlatenable will call the old constr
vandebo (ex-Chrome)
2013/10/08 23:37:06
It doesn't.
edisonn
2013/10/09 13:25:55
Correct, I do not pass now the initialTransform.
vandebo (ex-Chrome)
2013/10/09 16:52:32
I added a gm (and the ability for the gm to specif
edisonn
2013/10/10 18:35:15
added a new flag to specify if SkDocument will be
| |
627 SkIntToScalar(pageSize.height())); | |
628 initialTransform.mapRect(&content); | |
629 content.intersect(0, 0, SkIntToScalar(pageSize.width()), | |
630 SkIntToScalar(pageSize.height())); | |
631 SkISize contentSize = | |
632 SkISize::Make(SkScalarRoundToInt(content.width()), | |
633 SkScalarRoundToInt(content.height())); | |
634 dev = new SkPDFDevice(pageSize, contentSize, initialTransform); | |
635 } | |
636 dev->setDCTEncoder(encode_to_dct_stream); | |
637 SkAutoUnref aur(dev); | |
638 | 629 |
639 SkCanvas c(dev); | 630 invokeGM(gm, canvas, true, false); |
640 invokeGM(gm, &c, true, false); | |
641 | 631 |
642 SkPDFDocument doc; | 632 pdfDoc->close(); |
643 doc.appendPage(dev); | |
644 doc.emitPDF(&pdf); | |
645 #endif | 633 #endif |
646 } | 634 } |
647 | 635 |
648 static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) { | 636 static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) { |
649 #ifdef SK_SUPPORT_XPS | 637 #ifdef SK_SUPPORT_XPS |
650 SkISize size = gm->getISize(); | 638 SkISize size = gm->getISize(); |
651 | 639 |
652 SkSize trimSize = SkSize::Make(SkIntToScalar(size.width()), | 640 SkSize trimSize = SkSize::Make(SkIntToScalar(size.width()), |
653 SkIntToScalar(size.height())); | 641 SkIntToScalar(size.height())); |
654 static const SkScalar inchesPerMeter = SkScalarDiv(10000, 254); | 642 static const SkScalar inchesPerMeter = SkScalarDiv(10000, 254); |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2254 if (FLAGS_forceBWtext) { | 2242 if (FLAGS_forceBWtext) { |
2255 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2243 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2256 } | 2244 } |
2257 } | 2245 } |
2258 | 2246 |
2259 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2247 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2260 int main(int argc, char * const argv[]) { | 2248 int main(int argc, char * const argv[]) { |
2261 return tool_main(argc, (char**) argv); | 2249 return tool_main(argc, (char**) argv); |
2262 } | 2250 } |
2263 #endif | 2251 #endif |
OLD | NEW |