| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "SkDocument.h" | 8 #include "SkDocument.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkImageGenerator.h" | 10 #include "SkImageGenerator.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 | 40 |
| 41 static SkData* load_resource( | 41 static SkData* load_resource( |
| 42 skiatest::Reporter* r, const char* test, const char* filename) { | 42 skiatest::Reporter* r, const char* test, const char* filename) { |
| 43 SkString path(GetResourcePath(filename)); | 43 SkString path(GetResourcePath(filename)); |
| 44 SkData* data = SkData::NewFromFileName(path.c_str()); | 44 SkData* data = SkData::NewFromFileName(path.c_str()); |
| 45 if (!data && r->verbose()) { | 45 if (!data && r->verbose()) { |
| 46 SkDebugf("\n%s: Resource '%s' can not be found.\n", | 46 SkDebugf("\n%s: Resource '%s' can not be found.\n", |
| 47 test, filename); | 47 test, filename); |
| 48 } | 48 } |
| 49 return data; // May return NULL. | 49 return data; // May return nullptr. |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Test that for Jpeg files that use the JFIF colorspace, they are | 53 * Test that for Jpeg files that use the JFIF colorspace, they are |
| 54 * directly embedded into the PDF (without re-encoding) when that | 54 * directly embedded into the PDF (without re-encoding) when that |
| 55 * makes sense. | 55 * makes sense. |
| 56 */ | 56 */ |
| 57 DEF_TEST(PDFJpegEmbedTest, r) { | 57 DEF_TEST(PDFJpegEmbedTest, r) { |
| 58 const char test[] = "PDFJpegEmbedTest"; | 58 const char test[] = "PDFJpegEmbedTest"; |
| 59 SkAutoTUnref<SkData> mandrillData( | 59 SkAutoTUnref<SkData> mandrillData( |
| 60 load_resource(r, test, "mandrill_512_q075.jpg")); | 60 load_resource(r, test, "mandrill_512_q075.jpg")); |
| 61 SkAutoTUnref<SkData> cmykData(load_resource(r, test, "CMYK.jpg")); | 61 SkAutoTUnref<SkData> cmykData(load_resource(r, test, "CMYK.jpg")); |
| 62 if (!mandrillData || !cmykData) { | 62 if (!mandrillData || !cmykData) { |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 | 65 |
| 66 SkDynamicMemoryWStream pdf; | 66 SkDynamicMemoryWStream pdf; |
| 67 SkAutoTUnref<SkDocument> document(SkDocument::CreatePDF(&pdf)); | 67 SkAutoTUnref<SkDocument> document(SkDocument::CreatePDF(&pdf)); |
| 68 SkCanvas* canvas = document->beginPage(642, 1028); | 68 SkCanvas* canvas = document->beginPage(642, 1028); |
| 69 | 69 |
| 70 canvas->clear(SK_ColorLTGRAY); | 70 canvas->clear(SK_ColorLTGRAY); |
| 71 | 71 |
| 72 SkBitmap bm1(bitmap_from_data(mandrillData)); | 72 SkBitmap bm1(bitmap_from_data(mandrillData)); |
| 73 canvas->drawBitmap(bm1, 65.0, 0.0, NULL); | 73 canvas->drawBitmap(bm1, 65.0, 0.0, nullptr); |
| 74 SkBitmap bm2(bitmap_from_data(cmykData)); | 74 SkBitmap bm2(bitmap_from_data(cmykData)); |
| 75 canvas->drawBitmap(bm2, 0.0, 512.0, NULL); | 75 canvas->drawBitmap(bm2, 0.0, 512.0, nullptr); |
| 76 | 76 |
| 77 canvas->flush(); | 77 canvas->flush(); |
| 78 document->endPage(); | 78 document->endPage(); |
| 79 document->close(); | 79 document->close(); |
| 80 SkAutoTUnref<SkData> pdfData(pdf.copyToData()); | 80 SkAutoTUnref<SkData> pdfData(pdf.copyToData()); |
| 81 SkASSERT(pdfData); | 81 SkASSERT(pdfData); |
| 82 pdf.reset(); | 82 pdf.reset(); |
| 83 | 83 |
| 84 REPORTER_ASSERT(r, is_subset_of(mandrillData, pdfData)); | 84 REPORTER_ASSERT(r, is_subset_of(mandrillData, pdfData)); |
| 85 | 85 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (kTests[i].type != info.fType) { | 118 if (kTests[i].type != info.fType) { |
| 119 ERRORF(r, "%s failed jfif type test", kTests[i].path); | 119 ERRORF(r, "%s failed jfif type test", kTests[i].path); |
| 120 continue; | 120 continue; |
| 121 } | 121 } |
| 122 if (r->verbose()) { | 122 if (r->verbose()) { |
| 123 SkDebugf("\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, | 123 SkDebugf("\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, |
| 124 info.fWidth, info.fHeight); | 124 info.fWidth, info.fHeight); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 } | 127 } |
| OLD | NEW |