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

Side by Side Diff: tests/PDFJpegEmbedTest.cpp

Issue 1133443003: SkPDF: detect YUV-JPEG without relying on ImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/pdf/SkPDFBitmap.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFBitmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698