| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 | 
| 86     // This JPEG uses a nonstandard colorspace - it can not be | 86     // This JPEG uses a nonstandard colorspace - it can not be | 
| 87     // embedded into the PDF directly. | 87     // embedded into the PDF directly. | 
| 88     REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData)); | 88     REPORTER_ASSERT(r, !is_subset_of(cmykData, pdfData)); | 
| 89 } | 89 } | 
|  | 90 | 
|  | 91 #include "SkJpegInfo.h" | 
|  | 92 | 
|  | 93 DEF_TEST(JpegIdentification, r) { | 
|  | 94     static struct { | 
|  | 95         const char* path; | 
|  | 96         bool isJfif; | 
|  | 97         SkJFIFInfo::Type type; | 
|  | 98     } kTests[] = {{"CMYK.jpg", false, SkJFIFInfo::kGrayscale}, | 
|  | 99                   {"color_wheel.jpg", true, SkJFIFInfo::kYCbCr}, | 
|  | 100                   {"grayscale.jpg", true, SkJFIFInfo::kGrayscale}, | 
|  | 101                   {"mandrill_512_q075.jpg", true, SkJFIFInfo::kYCbCr}, | 
|  | 102                   {"randPixels.jpg", true, SkJFIFInfo::kYCbCr}}; | 
|  | 103     for (size_t i = 0; i < SK_ARRAY_COUNT(kTests); ++i) { | 
|  | 104         SkAutoTUnref<SkData> data( | 
|  | 105                 load_resource(r, "JpegIdentification", kTests[i].path)); | 
|  | 106         if (!data) { | 
|  | 107             continue; | 
|  | 108         } | 
|  | 109         SkJFIFInfo info; | 
|  | 110         bool isJfif = SkIsJFIF(data, &info); | 
|  | 111         if (isJfif != kTests[i].isJfif) { | 
|  | 112             ERRORF(r, "%s failed isJfif test", kTests[i].path); | 
|  | 113             continue; | 
|  | 114         } | 
|  | 115         if (!isJfif) { | 
|  | 116             continue;  // not applicable | 
|  | 117         } | 
|  | 118         if (kTests[i].type != info.fType) { | 
|  | 119             ERRORF(r, "%s failed jfif type test", kTests[i].path); | 
|  | 120             continue; | 
|  | 121         } | 
|  | 122         if (r->verbose()) { | 
|  | 123             SkDebugf("\nJpegIdentification: %s [%d x %d]\n", kTests[i].path, | 
|  | 124                      info.fWidth, info.fHeight); | 
|  | 125         } | 
|  | 126     } | 
|  | 127 } | 
| OLD | NEW | 
|---|