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

Side by Side Diff: tests/JpegTest.cpp

Issue 1692053002: Delete SkDecodingImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@noble
Patch Set: Created 4 years, 10 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "SkBitmap.h"
9 #include "SkCodec.h"
10 #include "SkDecodingImageGenerator.h"
11 #include "SkForceLinking.h"
12 #include "SkImageDecoder.h"
13 #include "SkPixelRef.h"
14 #include "Resources.h"
15 #include "SkStream.h"
16 #include "SkTemplates.h"
17 #include "Test.h"
18
19 __SK_FORCE_IMAGE_DECODER_LINKING;
20
21 #define JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING 0 // do not do this for
22 // normal unit testing.
23 static unsigned char goodJpegImage[] = {
24 0xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46,
25 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x8F,
26 0x00, 0x8F, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43,
27 0x00, 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05,
28 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x07,
29 0x0C, 0x08, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0B,
30 0x0B, 0x09, 0x0C, 0x11, 0x0F, 0x12, 0x12, 0x11,
31 0x0F, 0x11, 0x11, 0x13, 0x16, 0x1C, 0x17, 0x13,
32 0x14, 0x1A, 0x15, 0x11, 0x11, 0x18, 0x21, 0x18,
33 0x1A, 0x1D, 0x1D, 0x1F, 0x1F, 0x1F, 0x13, 0x17,
34 0x22, 0x24, 0x22, 0x1E, 0x24, 0x1C, 0x1E, 0x1F,
35 0x1E, 0xFF, 0xDB, 0x00, 0x43, 0x01, 0x05, 0x05,
36 0x05, 0x07, 0x06, 0x07, 0x0E, 0x08, 0x08, 0x0E,
37 0x1E, 0x14, 0x11, 0x14, 0x1E, 0x1E, 0x1E, 0x1E,
38 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
39 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
40 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
41 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
42 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
43 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xFF, 0xC0,
44 0x00, 0x11, 0x08, 0x00, 0x80, 0x00, 0x80, 0x03,
45 0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
46 0x01, 0xFF, 0xC4, 0x00, 0x18, 0x00, 0x01, 0x01,
47 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00,
49 0x08, 0x06, 0x05, 0xFF, 0xC4, 0x00, 0x4C, 0x10,
50 0x00, 0x00, 0x01, 0x07, 0x08, 0x05, 0x08, 0x05,
51 0x0A, 0x03, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00,
52 0x00, 0x01, 0x02, 0x03, 0x04, 0x06, 0x07, 0x11,
53 0x05, 0x08, 0x12, 0x13, 0x14, 0x15, 0x38, 0xB4,
54 0x16, 0x17, 0x21, 0x31, 0x84, 0x18, 0x22, 0x23,
55 0x24, 0x58, 0xA5, 0xA6, 0xD2, 0x32, 0x51, 0x56,
56 0x61, 0xD3, 0x28, 0x33, 0x41, 0x48, 0x67, 0x85,
57 0x86, 0xC3, 0xE4, 0xF0, 0x25, 0x49, 0x55, 0x09,
58 0x34, 0x35, 0x36, 0x53, 0x68, 0x72, 0x81, 0xA7,
59 0xE2, 0xFF, 0xC4, 0x00, 0x14, 0x01, 0x01, 0x00,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
62 0xC4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xDA, 0x00,
65 0x0C, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11,
66 0x00, 0x3F, 0x00, 0xD9, 0x62, 0x10, 0x80, 0x40,
67 0x65, 0xED, 0x62, 0x75, 0xC8, 0x7D, 0xFF, 0x00,
68 0x92, 0x30, 0x33, 0x01, 0x97, 0xB5, 0x89, 0xD7,
69 0x21, 0xF7, 0xFE, 0x48, 0xC0, 0x0C, 0xC2, 0x10,
70 0x80, 0x40, 0x66, 0x64, 0xB8, 0x62, 0x64, 0x78,
71 0xDC, 0xEA, 0x70, 0xCC, 0x06, 0x66, 0x4B, 0x86,
72 0x26, 0x47, 0x8D, 0xCE, 0xA7, 0x00, 0xCC, 0x21,
73 0x08, 0x04, 0x31, 0x9F, 0xF2, 0xC5, 0xFD, 0xFF,
74 0x00, 0x5A, 0x1B, 0x30, 0x63, 0x3F, 0xE5, 0x8B,
75 0xFB, 0xFE, 0xB4, 0x03, 0x66, 0x01, 0x99, 0x92,
76 0xE1, 0x89, 0x91, 0xE3, 0x73, 0xA9, 0xC3, 0x30,
77 0x19, 0x99, 0x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A,
78 0x9C, 0x03, 0x30, 0x84, 0x33, 0x33, 0x92, 0x55,
79 0x7E, 0xCF, 0x29, 0xD8, 0x49, 0x0D, 0xAE, 0xBD,
80 0xAE, 0xAB, 0xC6, 0xBB, 0xAA, 0x68, 0x92, 0x92,
81 0x6A, 0xBA, 0xB4, 0xE9, 0x11, 0x7A, 0x7C, 0xD8,
82 0xC6, 0x84, 0x77, 0x12, 0x11, 0x87, 0xBC, 0x07,
83 0x67, 0xAC, 0x47, 0xED, 0xD9, 0xD3, 0xC6, 0xAA,
84 0x5E, 0x51, 0x6B, 0x11, 0xFB, 0x76, 0x74, 0xF1,
85 0xAA, 0x97, 0x94, 0x33, 0x08, 0x00, 0xCE, 0xB1,
86 0x1F, 0xB7, 0x67, 0x4F, 0x1A, 0xA9, 0x79, 0x41,
87 0x9B, 0xC4, 0x6C, 0xDE, 0xC2, 0xCB, 0xF6, 0x75,
88 0x92, 0x84, 0xA0, 0xE5, 0xEC, 0x12, 0xB2, 0x9D,
89 0xEF, 0x76, 0xC9, 0xBA, 0x50, 0xAA, 0x92, 0xF1,
90 0xA6, 0xAA, 0x69, 0x12, 0xF4, 0xA4, 0x36, 0x8A,
91 0x2A, 0xB3, 0x60, 0x77, 0x3A, 0x34, 0xA3, 0x02,
92 0x6D, 0x1A, 0xC8, 0x0C, 0xBD, 0xAC, 0x4E, 0xB9,
93 0x0F, 0xBF, 0xF2, 0x46, 0x00, 0xB5, 0x88, 0xFD,
94 0xBB, 0x3A, 0x78, 0xD5, 0x4B, 0xCA, 0x2D, 0x62,
95 0x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52, 0xF2, 0x86,
96 0x61, 0x00, 0x19, 0xD6, 0x23, 0xF6, 0xEC, 0xE9,
97 0xE3, 0x55, 0x2F, 0x28, 0x33, 0x9A, 0xE3, 0x66,
98 0xF6, 0x24, 0x97, 0x12, 0xCE, 0xC9, 0xEC, 0xCB,
99 0x97, 0xD2, 0x49, 0x25, 0x15, 0xAA, 0xCF, 0x29,
100 0x69, 0x42, 0xAA, 0xA5, 0x7C, 0x56, 0x92, 0x94,
101 0xEE, 0x88, 0xF3, 0x4A, 0x71, 0xB4, 0x4E, 0x29,
102 0xC6, 0xED, 0xDF, 0x46, 0x3B, 0x8A, 0x35, 0x90,
103 0x19, 0x99, 0x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A,
104 0x9C, 0x01, 0x9B, 0xE4, 0x79, 0x73, 0x93, 0x59,
105 0x69, 0xD9, 0x36, 0x65, 0x99, 0x62, 0x34, 0x1E,
106 0x56, 0x95, 0xAD, 0x96, 0x75, 0x7B, 0xD6, 0x4F,
107 0x94, 0x6F, 0x1A, 0xA3, 0x0C, 0x3C, 0xEE, 0x71,
108 0xE6, 0x51, 0x45, 0x56, 0x6D, 0x22, 0xED, 0x29,
109 0x29, 0x53, 0xFA, 0x4A, 0x41, 0xE2, 0xFC, 0xBB,
110 0x3F, 0x77, 0x28, 0x66, 0x7B, 0x58, 0x9D, 0x72,
111 0x1F, 0x7F, 0xE4, 0x8C, 0x0C, 0xC0, 0x31, 0x9F,
112 0xCB, 0xB3, 0xF7, 0x72, 0x8F, 0x19, 0xB6, 0x76,
113 0x8F, 0x61, 0x8B, 0x99, 0xDA, 0xDA, 0x16, 0x99,
114 0xB7, 0xB0, 0x49, 0x2A, 0x74, 0x2D, 0x0C, 0x9D,
115 0xD4, 0xAA, 0x92, 0x85, 0x39, 0x40, 0xD2, 0x9B,
116 0xD7, 0x0C, 0x3C, 0xA7, 0x16, 0x27, 0x1C, 0x6A,
117 0x5D, 0x91, 0xDF, 0x43, 0x70, 0xDC, 0xA2, 0x01,
118 0x8C, 0xF5, 0xC1, 0xFE, 0xF1, 0x3F, 0xF3, 0x4F,
119 0xFE, 0x07, 0xB5, 0x35, 0xC6, 0x31, 0xEC, 0x4A,
120 0xCE, 0x25, 0x9D, 0x94, 0x19, 0x97, 0xD1, 0xA3,
121 0x72, 0x4A, 0x5B, 0x55, 0x9E, 0x4D, 0xD1, 0x75,
122 0x55, 0xBA, 0x88, 0x2D, 0x25, 0x21, 0xDD, 0x29,
123 0xE7, 0x10, 0xE3, 0xA9, 0x1C, 0x43, 0x8E, 0xDB,
124 0xBA, 0x94, 0x37, 0x10, 0x6B, 0x21, 0x00, 0x19,
125 0xD5, 0xDB, 0xF6, 0xED, 0x17, 0xE0, 0xA5, 0x2F,
126 0x30, 0x33, 0x9A, 0xE3, 0x18, 0xF6, 0x25, 0x67,
127 0x12, 0xCE, 0xCA, 0x0C, 0xCB, 0xE8, 0xD1, 0xB9,
128 0x25, 0x2D, 0xAA, 0xCF, 0x26, 0xE8, 0xBA, 0xAA,
129 0xDD, 0x44, 0x16, 0x92, 0x90, 0xEE, 0x94, 0xF3,
130 0x88, 0x71, 0xD4, 0x8E, 0x21, 0xC7, 0x6D, 0xDD,
131 0x4A, 0x1B, 0x88, 0x35, 0x90, 0x19, 0x99, 0x2E,
132 0x18, 0x99, 0x1E, 0x37, 0x3A, 0x9C, 0x03, 0x30,
133 0x80, 0x04, 0xDB, 0x99, 0x69, 0x09, 0x8B, 0x7E,
134 0xCF, 0x8D, 0x99, 0x66, 0x54, 0x6C, 0x12, 0x4A,
135 0x9D, 0xC7, 0x67, 0x57, 0xAD, 0x3D, 0x25, 0x0A,
136 0x6A, 0xA9, 0x4F, 0x3B, 0x9C, 0x79, 0x4A, 0x71,
137 0x62, 0x71, 0xC7, 0x17, 0x69, 0x4B, 0xBF, 0xD4,
138 0x1F, 0xC0, 0x43, 0x8C, 0x79, 0xAE, 0xB5, 0x84,
139 0x79, 0x57, 0x7E, 0x9A, 0xC8, 0x57, 0xAD, 0xDD,
140 0x5B, 0x64, 0xEB, 0x69, 0xD0, 0xD5, 0xD6, 0x50,
141 0xA7, 0xF3, 0x47, 0x9B, 0x18, 0xD0, 0x33, 0x7C,
142 0x61, 0x0D, 0x9F, 0x48, 0xEC, 0xC0, 0x03, 0x12,
143 0xFB, 0x5E, 0xC3, 0x68, 0xCC, 0x2A, 0x34, 0xCC,
144 0xCB, 0x83, 0xB7, 0xC9, 0x2B, 0x94, 0xEC, 0xEB,
145 0x1A, 0x5E, 0xAA, 0x8E, 0x9D, 0x03, 0xCE, 0x30,
146 0xEE, 0x69, 0xE8, 0xC8, 0x71, 0x20, 0x71, 0xA7,
147 0x13, 0x69, 0x09, 0xBB, 0xD4, 0x03, 0xD9, 0xE4,
148 0xB8, 0xE2, 0x7D, 0x86, 0xEF, 0x65, 0xDF, 0x8C,
149 0x2E, 0x4B, 0x8E, 0x27, 0xD8, 0x6E, 0xF6, 0x5D,
150 0xF8, 0xC2, 0xD6, 0x23, 0xF6, 0xEC, 0xE9, 0xE3,
151 0x55, 0x2F, 0x28, 0xB5, 0x88, 0xFD, 0xBB, 0x3A,
152 0x78, 0xD5, 0x4B, 0xCA, 0x02, 0xE4, 0xB8, 0xE2,
153 0x7D, 0x86, 0xEF, 0x65, 0xDF, 0x8C, 0x0C, 0xE6,
154 0xB8, 0xE1, 0x1D, 0x3B, 0x68, 0xE2, 0x59, 0xD6,
155 0x99, 0xA6, 0x65, 0x2D, 0xF2, 0xB2, 0xE5, 0xAA,
156 0xD0, 0xB1, 0x78, 0x2D, 0x23, 0xA7, 0x41, 0x69,
157 0x29, 0x86, 0xF3, 0x4C, 0x48, 0x43, 0x49, 0x03,
158 0x4D, 0x34, 0x9B, 0x08, 0x4D, 0xDE, 0xB0, 0x99,
159 0xAC, 0x47, 0xED, 0xD9, 0xD3, 0xC6, 0xAA, 0x5E,
160 0x50, 0x67, 0x35, 0xC6, 0xCD, 0xEC, 0x49, 0x2E,
161 0x25, 0x9D, 0x93, 0xD9, 0x97, 0x2F, 0xA4, 0x92,
162 0x4A, 0x2B, 0x55, 0x9E, 0x52, 0xD2, 0x85, 0x55,
163 0x4A, 0xF8, 0xAD, 0x25, 0x29, 0xDD, 0x11, 0xE6,
164 0x94, 0xE3, 0x68, 0x9C, 0x53, 0x8D, 0xDB, 0xBE,
165 0x8C, 0x77, 0x14, 0x04, 0xF1, 0x1C, 0x23, 0xA7,
166 0x92, 0x5F, 0xB3, 0xAC, 0x66, 0x64, 0xF6, 0x52,
167 0xA6, 0x49, 0x97, 0xAF, 0x7B, 0xC9, 0x5E, 0xF0,
168 0x5A, 0x3A, 0xBE, 0xA1, 0x54, 0xD3, 0xD1, 0x73,
169 0x8A, 0x90, 0xA7, 0x1B, 0x44, 0xE2, 0x94, 0xBC,
170 0xD2, 0x92, 0x3F, 0x4C, 0x48, 0x13, 0x39, 0x2E,
171 0x38, 0x9F, 0x61, 0xBB, 0xD9, 0x77, 0xE3, 0x01,
172 0x97, 0xF4, 0xF7, 0x1B, 0xB6, 0x51, 0xE7, 0xBB,
173 0x76, 0xD5, 0xB5, 0x74, 0xB7, 0x15, 0xCD, 0x7A,
174 0x59, 0x15, 0x34, 0x89, 0x02, 0xCD, 0xBA, 0xB9,
175 0x02, 0x34, 0x47, 0xF3, 0xD1, 0x18, 0x5A, 0xBA,
176 0x14, 0x8C, 0x2E, 0xD2, 0x16, 0x95, 0x28, 0x12,
177 0x10, 0x29, 0x46, 0xCC, 0x00, 0x33, 0xC9, 0x71,
178 0xC4, 0xFB, 0x0D, 0xDE, 0xCB, 0xBF, 0x18, 0x5C,
179 0x97, 0x1C, 0x4F, 0xB0, 0xDD, 0xEC, 0xBB, 0xF1,
180 0x83, 0x30, 0x80, 0x0C, 0xF2, 0x5C, 0x71, 0x3E,
181 0xC3, 0x77, 0xB2, 0xEF, 0xC6, 0x17, 0x25, 0xC7,
182 0x13, 0xEC, 0x37, 0x7B, 0x2E, 0xFC, 0x60, 0xCC,
183 0x20, 0x03, 0x3C, 0x97, 0x1C, 0x4F, 0xB0, 0xDD,
184 0xEC, 0xBB, 0xF1, 0x81, 0x9C, 0xD7, 0x1C, 0x23,
185 0xA7, 0x6D, 0x1C, 0x4B, 0x3A, 0xD3, 0x34, 0xCC,
186 0xA5, 0xBE, 0x56, 0x5C, 0xB5, 0x5A, 0x16, 0x2F,
187 0x05, 0xA4, 0x74, 0xE8, 0x2D, 0x25, 0x30, 0xDE,
188 0x69, 0x89, 0x08, 0x69, 0x20, 0x69, 0xA6, 0x93,
189 0x61, 0x09, 0xBB, 0xD6, 0x35, 0x90, 0x19, 0x99,
190 0x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A, 0x9C, 0x07,
191 0x8D, 0x36, 0xE6, 0xA6, 0x42, 0x6D, 0x1F, 0xB3,
192 0xE3, 0x69, 0x99, 0x95, 0xEB, 0x7C, 0x92, 0xB9,
193 0x71, 0xD9, 0xD6, 0x2A, 0x8F, 0x47, 0x4E, 0x82,
194 0xAA, 0x53, 0x0E, 0xE6, 0x9E, 0x42, 0x1C, 0x48,
195 0x1C, 0x69, 0xC4, 0xDA, 0x42, 0x6E, 0xF5, 0x07,
196 0xF1, 0x08, 0x00, 0xCB, 0x40, 0xF7, 0x1B, 0xBD,
197 0x67, 0xB4, 0xEC, 0x53, 0x14, 0xE9, 0x74, 0xAB,
198 0x47, 0x2C, 0x96, 0xB5, 0xBD, 0x22, 0x40, 0xA5,
199 0xFD, 0xE1, 0x01, 0x12, 0x99, 0xCC, 0x4A, 0x67,
200 0xFC, 0xC9, 0xB0, 0xA5, 0xF4, 0x62, 0x58, 0x44,
201 0x84, 0x06, 0x73, 0x5C, 0x6C, 0xDE, 0xC4, 0x92,
202 0xE2, 0x59, 0xD9, 0x3D, 0x99, 0x72, 0xFA, 0x49,
203 0x24, 0xA2, 0xB5, 0x59, 0xE5, 0x2D, 0x28, 0x55,
204 0x54, 0xAF, 0x8A, 0xD2, 0x52, 0x9D, 0xD1, 0x1E,
205 0x69, 0x4E, 0x36, 0x89, 0xC5, 0x38, 0xDD, 0xBB,
206 0xE8, 0xC7, 0x71, 0x42, 0x63, 0xA5, 0xC4, 0xEB,
207 0xEF, 0xFB, 0x83, 0x24, 0x78, 0xA6, 0x4B, 0x86,
208 0x26, 0x47, 0x8D, 0xCE, 0xA7, 0x01, 0x6B, 0x11,
209 0xFB, 0x76, 0x74, 0xF1, 0xAA, 0x97, 0x94, 0x5A,
210 0xC4, 0x7E, 0xDD, 0x9D, 0x3C, 0x6A, 0xA5, 0xE5,
211 0x0C, 0xC2, 0x00, 0x33, 0xAC, 0x47, 0xED, 0xD9,
212 0xD3, 0xC6, 0xAA, 0x5E, 0x50, 0x67, 0x35, 0xC6,
213 0xCD, 0xEC, 0x49, 0x2E, 0x25, 0x9D, 0x93, 0xD9,
214 0x97, 0x2F, 0xA4, 0x92, 0x4A, 0x2B, 0x55, 0x9E,
215 0x52, 0xD2, 0x85, 0x55, 0x4A, 0xF8, 0xAD, 0x25,
216 0x29, 0xDD, 0x11, 0xE6, 0x94, 0xE3, 0x68, 0x9C,
217 0x53, 0x8D, 0xDB, 0xBE, 0x8C, 0x77, 0x14, 0x6B,
218 0x20, 0x33, 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E,
219 0x75, 0x38, 0x0C, 0xCD, 0x3E, 0x76, 0x89, 0xBB,
220 0x97, 0xF4, 0x3B, 0x4D, 0x5D, 0xD6, 0x86, 0xD4,
221 0x5B, 0xAC, 0x9F, 0xC6, 0x90, 0x2F, 0xDA, 0xA9,
222 0x59, 0xE9, 0xFC, 0xD1, 0x09, 0x42, 0x8C, 0x0C,
223 0xDF, 0xBE, 0x9E, 0xCD, 0xC5, 0x1A, 0x67, 0x58,
224 0x8F, 0xDB, 0xB3, 0xA7, 0x8D, 0x54, 0xBC, 0xA3,
225 0x8C, 0xFE, 0xD0, 0x76, 0x16, 0xFF, 0x00, 0x76,
226 0x0A, 0xAD, 0xAD, 0xE9, 0x66, 0xD1, 0x5A, 0x7D,
227 0x52, 0xCF, 0x4E, 0xD5, 0x6A, 0x4E, 0xAC, 0x8B,
228 0xD3, 0xA4, 0x4A, 0x14, 0x61, 0x1D, 0xC7, 0x47,
229 0x76, 0xCD, 0xE2, 0x7D, 0xAA, 0xAF, 0xD9, 0xDA,
230 0xBB, 0x09, 0x5D, 0xB5, 0xD7, 0xB5, 0xEB, 0x77,
231 0x54, 0xF5, 0x4D, 0x12, 0x52, 0x43, 0x59, 0x58,
232 0x9D, 0x1A, 0x2F, 0x4F, 0x9D, 0x08, 0x53, 0x8E,
233 0xE2, 0xC6, 0x10, 0xF7, 0x80, 0xEC, 0xF5, 0x88,
234 0xFD, 0xBB, 0x3A, 0x78, 0xD5, 0x4B, 0xCA, 0x2D,
235 0x62, 0x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52, 0xF2,
236 0x8C, 0x67, 0xCA, 0x8D, 0xFB, 0x7B, 0x73, 0xDD,
237 0x2A, 0x5F, 0x04, 0x5C, 0xA8, 0xDF, 0xB7, 0xB7,
238 0x3D, 0xD2, 0xA5, 0xF0, 0x40, 0x6C, 0xCD, 0x62,
239 0x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52, 0xF2, 0x8B,
240 0x58, 0x8F, 0xDB, 0xB3, 0xA7, 0x8D, 0x54, 0xBC,
241 0xA3, 0x33, 0x3B, 0x27, 0xA5, 0x3B, 0x17, 0x95,
242 0x78, 0x68, 0x54, 0xBB, 0x7A, 0xDD, 0xD5, 0x56,
243 0xBE, 0xA9, 0x25, 0xA1, 0xAB, 0xAC, 0xA7, 0x43,
244 0xE7, 0x4C, 0x36, 0x31, 0xA0, 0x7E, 0xE8, 0xC2,
245 0x1B, 0x7E, 0x81, 0xD9, 0xFC, 0xBB, 0x3F, 0x77,
246 0x28, 0x06, 0x6D, 0x62, 0x3F, 0x6E, 0xCE, 0x9E,
247 0x35, 0x52, 0xF2, 0x83, 0x39, 0xAE, 0x36, 0x6F,
248 0x62, 0x49, 0x71, 0x2C, 0xEC, 0x9E, 0xCC, 0xB9,
249 0x7D, 0x24, 0x92, 0x51, 0x5A, 0xAC, 0xF2, 0x96,
250 0x94, 0x2A, 0xAA, 0x57, 0xC5, 0x69, 0x29, 0x4E,
251 0xE8, 0x8F, 0x34, 0xA7, 0x1B, 0x44, 0xE2, 0x9C,
252 0x6E, 0xDD, 0xF4, 0x63, 0xB8, 0xA3, 0xC5, 0xF9,
253 0x76, 0x7E, 0xEE, 0x51, 0xC6, 0x39, 0x2E, 0x56,
254 0x3A, 0xB0, 0x92, 0x35, 0x69, 0xFE, 0x53, 0xE9,
255 0xAC, 0x1F, 0xE1, 0x7F, 0xEB, 0xA4, 0xAC, 0xF9,
256 0xFE, 0x93, 0xE7, 0x2B, 0x3D, 0x2F, 0xFA, 0xD9,
257 0x00, 0x1B, 0xFC, 0x42, 0x10, 0x0C, 0x9A, 0xD4,
258 0xBE, 0x39, 0x09, 0xCF, 0xBF, 0x67, 0xD5, 0x28,
259 0x4A, 0x08, 0x6D, 0xF2, 0xB2, 0xE5, 0xC3, 0x76,
260 0xC9, 0xB4, 0x8F, 0x47, 0x6B, 0xA0, 0xAA, 0x42,
261 0x25, 0xE9, 0x48, 0x8C, 0xF3, 0x4C, 0xA0, 0x6A,
262 0x42, 0x1D, 0xCE, 0x84, 0x61, 0x02, 0x6D, 0xDC,
263 0x64, 0xE4, 0xA7, 0x5B, 0xAB, 0x57, 0x61, 0x24,
264 0x31, 0x5A, 0x05, 0x7A, 0xDD, 0xD5, 0xDD, 0x6E,
265 0xF7, 0xA9, 0xAC, 0xAC, 0x4E, 0x91, 0x2F, 0xA1,
266 0x52, 0x74, 0x21, 0x4E, 0x1B, 0xCB, 0x18, 0x47,
267 0xDC, 0x34, 0xCC, 0xF6, 0xB0, 0xC4, 0xD7, 0x70,
268 0x59, 0xD4, 0x02, 0x99, 0x2E, 0x18, 0x99, 0x1E,
269 0x37, 0x3A, 0x9C, 0x00, 0xCF, 0x2E, 0x7F, 0xB2,
270 0xEE, 0xFF, 0x00, 0xFD, 0x38, 0xB9, 0x73, 0xFD,
271 0x97, 0x77, 0xFF, 0x00, 0xE9, 0xC6, 0xCC, 0x10,
272 0x0C, 0x67, 0xCB, 0x9F, 0xEC, 0xBB, 0xBF, 0xFF,
273 0x00, 0x4E, 0x38, 0xC7, 0x25, 0x3A, 0xDD, 0x5A,
274 0xBB, 0x09, 0x21, 0x8A, 0xD0, 0x2B, 0xD6, 0xEE,
275 0xAE, 0xEB, 0x77, 0xBD, 0x4D, 0x65, 0x62, 0x74,
276 0x89, 0x7D, 0x0A, 0x93, 0xA1, 0x0A, 0x70, 0xDE,
277 0x58, 0xC2, 0x3E, 0xE1, 0xBF, 0xC0, 0xCC, 0xC9,
278 0x70, 0xC4, 0xC8, 0xF1, 0xB9, 0xD4, 0xE0, 0x33,
279 0x33, 0xED, 0x9D, 0x6E, 0xB2, 0x9D, 0x84, 0xAE,
280 0xC5, 0x68, 0x15, 0xD5, 0x78, 0xD4, 0xF5, 0xBB,
281 0xDE, 0xBA, 0xAE, 0xAD, 0x3A, 0x34, 0xBE, 0x85,
282 0x49, 0xB1, 0x8D, 0x08, 0x6F, 0x24, 0x23, 0x1F,
283 0x70, 0x9F, 0x6C, 0xEB, 0x75, 0x94, 0xEC, 0x25,
284 0x76, 0x2B, 0x40, 0xAE, 0xAB, 0xC6, 0xA7, 0xAD,
285 0xDE, 0xF5, 0xD5, 0x75, 0x69, 0xD1, 0xA5, 0xF4,
286 0x2A, 0x4D, 0x8C, 0x68, 0x43, 0x79, 0x21, 0x18,
287 0xFB, 0x86, 0x99, 0x9E, 0xD6, 0x18, 0x9A, 0xEE,
288 0x0B, 0x3A, 0x80, 0x53, 0xDA, 0xC3, 0x13, 0x5D,
289 0xC1, 0x67, 0x50, 0x00, 0xCC, 0xCE, 0x4A, 0x75,
290 0xBA, 0xB5, 0x76, 0x12, 0x43, 0x15, 0xA0, 0x57,
291 0xAD, 0xDD, 0x5D, 0xD6, 0xEF, 0x7A, 0x9A, 0xCA,
292 0xC4, 0xE9, 0x12, 0xFA, 0x15, 0x27, 0x42, 0x14,
293 0xE1, 0xBC, 0xB1, 0x84, 0x7D, 0xC3, 0xB3, 0xE5,
294 0xCF, 0xF6, 0x5D, 0xDF, 0xFF, 0x00, 0xA7, 0x0C,
295 0xD3, 0x25, 0xC3, 0x13, 0x23, 0xC6, 0xE7, 0x53,
296 0x86, 0x60, 0x18, 0x01, 0x92, 0x9D, 0x6D, 0xC0,
297 0xF3, 0xDB, 0x76, 0xD7, 0x40, 0xAD, 0x3A, 0x55,
298 0x60, 0xEA, 0x97, 0xBD, 0x0B, 0x2D, 0x95, 0x01,
299 0x51, 0x7A, 0x75, 0x25, 0xA7, 0x4A, 0x31, 0xDC,
300 0x6C, 0x37, 0x6D, 0xDE, 0x3B, 0x3E, 0x5C, 0xFF,
301 0x00, 0x65, 0xDD, 0xFF, 0x00, 0xFA, 0x70, 0xCC,
302 0xE9, 0x71, 0x3A, 0xFB, 0xFE, 0xE0, 0xC9, 0x1E,
303 0x19, 0x80, 0x63, 0x3E, 0x5C, 0xFF, 0x00, 0x65,
304 0xDD, 0xFF, 0x00, 0xFA, 0x71, 0xC6, 0x39, 0x29,
305 0xD6, 0xEA, 0xD5, 0xD8, 0x49, 0x0C, 0x56, 0x81,
306 0x5E, 0xB7, 0x75, 0x77, 0x5B, 0xBD, 0xEA, 0x6B,
307 0x2B, 0x13, 0xA4, 0x4B, 0xE8, 0x54, 0x9D, 0x08,
308 0x53, 0x86, 0xF2, 0xC6, 0x11, 0xF7, 0x0D, 0xFE,
309 0x06, 0x66, 0x4B, 0x86, 0x26, 0x47, 0x8D, 0xCE,
310 0xA7, 0x00, 0xCC, 0x21, 0x08, 0x00, 0xCC, 0xF6,
311 0xB0, 0xC4, 0xD7, 0x70, 0x59, 0xD4, 0x02, 0x99,
312 0x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A, 0x9C, 0x53,
313 0xDA, 0xC3, 0x13, 0x5D, 0xC1, 0x67, 0x50, 0x0A,
314 0x64, 0xB8, 0x62, 0x64, 0x78, 0xDC, 0xEA, 0x70,
315 0x0C, 0xC2, 0x10, 0x80, 0x40, 0x66, 0x64, 0xB8,
316 0x62, 0x64, 0x78, 0xDC, 0xEA, 0x70, 0xCC, 0x06,
317 0x66, 0x4B, 0x86, 0x26, 0x47, 0x8D, 0xCE, 0xA7,
318 0x01, 0x4F, 0x6B, 0x0C, 0x4D, 0x77, 0x05, 0x9D,
319 0x40, 0x29, 0xED, 0x61, 0x89, 0xAE, 0xE0, 0xB3,
320 0xA8, 0x05, 0x3D, 0xAC, 0x31, 0x35, 0xDC, 0x16,
321 0x75, 0x00, 0xA7, 0xB5, 0x86, 0x26, 0xBB, 0x82,
322 0xCE, 0xA0, 0x01, 0x4C, 0x97, 0x0C, 0x4C, 0x8F,
323 0x1B, 0x9D, 0x4E, 0x19, 0x86, 0x4D, 0x9A, 0xE3,
324 0xFB, 0x74, 0xEC, 0x5B, 0x89, 0x67, 0x59, 0x96,
325 0x99, 0xAB, 0xB0, 0x4A, 0xCA, 0x76, 0xAB, 0x42,
326 0xBD, 0xDE, 0xB4, 0x92, 0x85, 0x35, 0xA4, 0xA7,
327 0x9B, 0xCE, 0x31, 0x19, 0x4D, 0x2C, 0x4D, 0x38,
328 0xD2, 0xEC, 0x29, 0x77, 0xFA, 0xC2, 0x67, 0x2A,
329 0x37, 0x13, 0xED, 0xCF, 0x74, 0xAE, 0xFC, 0x10,
330 0x03, 0x33, 0x80, 0xFA, 0xCE, 0xFE, 0x13, 0xFC,
331 0xB0, 0xCD, 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E,
332 0x75, 0x38, 0x00, 0x79, 0x2D, 0x4C, 0x84, 0xDA,
333 0x33, 0x13, 0x91, 0x69, 0x99, 0x95, 0xEB, 0x7C,
334 0x92, 0xB9, 0xA2, 0xF6, 0x75, 0x8A, 0xA3, 0xD1,
335 0xD3, 0xA0, 0x79, 0xA6, 0x1D, 0xCD, 0x3C, 0x84,
336 0x38, 0x90, 0x38, 0xD3, 0x89, 0xB4, 0x84, 0xDD,
337 0xEA, 0x0F, 0xF3, 0x25, 0xC3, 0x13, 0x23, 0xC6,
338 0xE7, 0x53, 0x80, 0x66, 0x03, 0x33, 0x25, 0xC3,
339 0x13, 0x23, 0xC6, 0xE7, 0x53, 0x86, 0x60, 0x33,
340 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E, 0x75, 0x38,
341 0x06, 0x61, 0x08, 0x40, 0x06, 0x67, 0xB5, 0x86,
342 0x26, 0xBB, 0x82, 0xCE, 0xA0, 0x14, 0xC9, 0x70,
343 0xC4, 0xC8, 0xF1, 0xB9, 0xD4, 0xE2, 0x9E, 0xD6,
344 0x18, 0x9A, 0xEE, 0x0B, 0x3A, 0x80, 0x53, 0x25,
345 0xC3, 0x13, 0x23, 0xC6, 0xE7, 0x53, 0x80, 0x66,
346 0x10, 0x84, 0x02, 0x03, 0x33, 0x25, 0xC3, 0x13,
347 0x23, 0xC6, 0xE7, 0x53, 0x86, 0x60, 0x33, 0x32,
348 0x5C, 0x31, 0x32, 0x3C, 0x6E, 0x75, 0x38, 0x0A,
349 0x7B, 0x58, 0x62, 0x6B, 0xB8, 0x2C, 0xEA, 0x01,
350 0x4F, 0x6B, 0x0C, 0x4D, 0x77, 0x05, 0x9D, 0x40,
351 0x29, 0xED, 0x61, 0x89, 0xAE, 0xE0, 0xB3, 0xA8,
352 0x05, 0x3D, 0xAC, 0x31, 0x35, 0xDC, 0x16, 0x75,
353 0x00, 0x06, 0x61, 0x08, 0x40, 0x31, 0x9C, 0xEB,
354 0x65, 0x86, 0xEE, 0x5F, 0xD7, 0x2C, 0x93, 0xA6,
355 0x36, 0x66, 0x4D, 0x95, 0xB8, 0xFF, 0x00, 0x82,
356 0xDD, 0x88, 0x0F, 0xB5, 0x5A, 0xAA, 0x4E, 0xF9,
357 0xF8, 0x11, 0x21, 0x94, 0x52, 0x12, 0x9E, 0xF3,
358 0xA3, 0xBB, 0x61, 0x07, 0xB5, 0x35, 0xC6, 0x31,
359 0xEC, 0x4A, 0xCE, 0x25, 0x9D, 0x94, 0x19, 0x97,
360 0xD1, 0xA3, 0x72, 0x4A, 0x5B, 0x55, 0x9E, 0x4D,
361 0xD1, 0x75, 0x55, 0xBA, 0x88, 0x2D, 0x25, 0x21,
362 0xDD, 0x29, 0xE7, 0x10, 0xE3, 0xA9, 0x1C, 0x43,
363 0x8E, 0xDB, 0xBA, 0x94, 0x37, 0x10, 0x78, 0xB3,
364 0x80, 0xFA, 0xCE, 0xFE, 0x13, 0xFC, 0xB0, 0xCD,
365 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E, 0x75, 0x38,
366 0x0B, 0x57, 0x6F, 0xDB, 0xB4, 0x5F, 0x82, 0x94,
367 0xBC, 0xC0, 0xCE, 0x6B, 0x8C, 0x63, 0xD8, 0x95,
368 0x9C, 0x4B, 0x3B, 0x28, 0x33, 0x2F, 0xA3, 0x46,
369 0xE4, 0x94, 0xB6, 0xAB, 0x3C, 0x9B, 0xA2, 0xEA,
370 0xAB, 0x75, 0x10, 0x5A, 0x4A, 0x43, 0xBA, 0x53,
371 0xCE, 0x21, 0xC7, 0x52, 0x38, 0x87, 0x1D, 0xB7,
372 0x75, 0x28, 0x6E, 0x20, 0xD6, 0x40, 0x66, 0x64,
373 0xB8, 0x62, 0x64, 0x78, 0xDC, 0xEA, 0x70, 0x16,
374 0xB1, 0x1F, 0xB7, 0x67, 0x4F, 0x1A, 0xA9, 0x79,
375 0x45, 0xAC, 0x47, 0xED, 0xD9, 0xD3, 0xC6, 0xAA,
376 0x5E, 0x50, 0xCC, 0x20, 0x19, 0x36, 0x74, 0x6D,
377 0x9B, 0xD8, 0x95, 0x9C, 0x4B, 0x45, 0x27, 0xB4,
378 0xCE, 0x5F, 0x46, 0xE4, 0x94, 0xB6, 0x5B, 0x44,
379 0xA5, 0xA5, 0x0A, 0xAB, 0x75, 0x10, 0x5A, 0x44,
380 0x53, 0x7A, 0x23, 0x0D, 0x21, 0xC7, 0x52, 0x38,
381 0x86, 0x9B, 0xB3, 0x75, 0x28, 0xEE, 0x20, 0xA6,
382 0xB8, 0xD9, 0xBD, 0x89, 0x25, 0xC4, 0xB3, 0xB2,
383 0x7B, 0x32, 0xE5, 0xF4, 0x92, 0x49, 0x45, 0x6A,
384 0xB3, 0xCA, 0x5A, 0x50, 0xAA, 0xA9, 0x5F, 0x15,
385 0xA4, 0xA5, 0x3B, 0xA2, 0x3C, 0xD2, 0x9C, 0x6D,
386 0x13, 0x8A, 0x71, 0xBB, 0x77, 0xD1, 0x8E, 0xE2,
387 0x84, 0xC9, 0xED, 0x61, 0x89, 0xAE, 0xE0, 0xB3,
388 0xA8, 0x05, 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E,
389 0x75, 0x38, 0x0B, 0x58, 0x8F, 0xDB, 0xB3, 0xA7,
390 0x8D, 0x54, 0xBC, 0xA2, 0xD6, 0x23, 0xF6, 0xEC,
391 0xE9, 0xE3, 0x55, 0x2F, 0x28, 0x66, 0x10, 0x01,
392 0x9D, 0x62, 0x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52,
393 0xF2, 0x8F, 0x6A, 0x6B, 0x8C, 0xB4, 0xBA, 0xC5,
394 0xB8, 0x96, 0x75, 0x99, 0x69, 0x94, 0x6C, 0x12,
395 0xB2, 0x9D, 0xAA, 0xD0, 0xAF, 0x5A, 0x62, 0x4A,
396 0x14, 0xD6, 0x92, 0x9E, 0x6F, 0x38, 0xC2, 0x94,
397 0xD2, 0xC4, 0xD3, 0x8D, 0x2E, 0xC2, 0x97, 0x7F,
398 0xAC, 0x26, 0x08, 0x00, 0xCC, 0xF6, 0xB0, 0xC4,
399 0xD7, 0x70, 0x59, 0xD4, 0x02, 0x9E, 0xD6, 0x18,
400 0x9A, 0xEE, 0x0B, 0x3A, 0x80, 0x53, 0xDA, 0xC3,
401 0x13, 0x5D, 0xC1, 0x67, 0x50, 0x0A, 0x7B, 0x58,
402 0x62, 0x6B, 0xB8, 0x2C, 0xEA, 0x00, 0x0C, 0xC2,
403 0x10, 0x80, 0x63, 0x39, 0xC0, 0x7D, 0x67, 0x7F,
404 0x09, 0xFE, 0x58, 0x66, 0x99, 0x2E, 0x18, 0x99,
405 0x1E, 0x37, 0x3A, 0x9C, 0x0C, 0xCE, 0x03, 0xEB,
406 0x3B, 0xF8, 0x4F, 0xF2, 0xC3, 0x34, 0xC9, 0x70,
407 0xC4, 0xC8, 0xF1, 0xB9, 0xD4, 0xE0, 0x19, 0x80,
408 0xCC, 0xC9, 0x70, 0xC4, 0xC8, 0xF1, 0xB9, 0xD4,
409 0xE1, 0x98, 0x0C, 0xCC, 0x97, 0x0C, 0x4C, 0x8F,
410 0x1B, 0x9D, 0x4E, 0x03, 0xFF, 0xD9};
411 static const int goodJpegImageWidth = 128;
412 static const int goodJpegImageHeight = 128;
413
414 // https://code.google.com/p/android/issues/detail?id=42382
415 // https://code.google.com/p/android/issues/detail?id=9064
416 // https://code.google.com/p/skia/issues/detail?id=1649
417
418 /**
419 This test will test the ability of the SkImageDecoder to deal with
420 Jpeg files which have been mangled somehow. We want to display as
421 much of the jpeg as possible.
422 */
423 DEF_TEST(Jpeg, reporter) {
424 size_t len = sizeof(goodJpegImage) / 2;
425 // I am explicitly not putting the entire image into the
426 // DecodeMemory. This simulates a network error.
427
428 SkBitmap bm8888;
429 bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
430 static_cast<void *>(goodJpegImage), len, &bm8888);
431 REPORTER_ASSERT(reporter, imageDecodeSuccess);
432 REPORTER_ASSERT(reporter, bm8888.width() == goodJpegImageWidth);
433 REPORTER_ASSERT(reporter, bm8888.height() == goodJpegImageHeight);
434 REPORTER_ASSERT(reporter, !(bm8888.empty()));
435
436 // Pick a few pixels and verify that their colors match the colors
437 // we expect (given the original image).
438 REPORTER_ASSERT(reporter, bm8888.getColor(7, 9) == 0xffffffff);
439 REPORTER_ASSERT(reporter, bm8888.getColor(28, 3) == 0xff000000);
440 REPORTER_ASSERT(reporter, bm8888.getColor(27, 34) == 0xffffffff);
441 REPORTER_ASSERT(reporter, bm8888.getColor(71, 18) == 0xff000000);
442
443 #ifdef SK_BUILD_FOR_IOS // the iOS jpeg decoder fills to gray
444 REPORTER_ASSERT(reporter, bm8888.getColor(127, 127) == 0xff808080
445 || bm8888.getColor(127, 127) == SK_ColorWHITE);
446 #else
447 // This is the fill color
448 REPORTER_ASSERT(reporter, bm8888.getColor(127, 127) == SK_ColorWHITE);
449 #endif
450
451 #if JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING
452 // Check to see that the resulting bitmap is nice
453 bool writeSuccess = (!(bm8888.empty())) && SkImageEncoder::EncodeFile(
454 "HalfOfAJpeg.png", bm8888, SkImageEncoder::kPNG_Type, 100);
455 SkASSERT(writeSuccess);
456 #endif
457 }
458
459 DEF_TEST(Jpeg_YUV, reporter) {
460 size_t len = sizeof(goodJpegImage);
461 SkMemoryStream* stream = new SkMemoryStream(goodJpegImage, len);
462 SkDecodingImageGenerator::Options opts;
463 SkAutoTDelete<SkImageGenerator> gen(SkDecodingImageGenerator::Create(stream, opts));
464 REPORTER_ASSERT(reporter, gen);
465 if (!gen) {
466 return;
467 }
468
469 SkISize yuvSizes[3];
470 bool sizesComputed = gen->getYUV8Planes(yuvSizes, nullptr, nullptr, nullptr) ;
471 REPORTER_ASSERT(reporter, sizesComputed);
472 if (!sizesComputed) {
473 return;
474 }
475
476 // Allocate the memory for YUV
477 size_t totalSize(0);
478 size_t sizes[3], rowBytes[3];
479 const int32_t expected_sizes[] = {128, 64, 64};
480 for (int i = 0; i < 3; ++i) {
481 rowBytes[i] = yuvSizes[i].fWidth;
482 totalSize += sizes[i] = rowBytes[i] * yuvSizes[i].fHeight;
483 REPORTER_ASSERT(reporter, rowBytes[i] == (size_t)expected_sizes[ i]);
484 REPORTER_ASSERT(reporter, yuvSizes[i].fWidth == expected_sizes[i]);
485 REPORTER_ASSERT(reporter, yuvSizes[i].fHeight == expected_sizes[i]);
486 }
487 SkAutoMalloc storage(totalSize);
488 void* planes[3];
489 planes[0] = storage.get();
490 planes[1] = (uint8_t*)planes[0] + sizes[0];
491 planes[2] = (uint8_t*)planes[1] + sizes[1];
492
493 // Get the YUV planes
494 REPORTER_ASSERT(reporter, gen->getYUV8Planes(yuvSizes, planes, rowBytes, nul lptr));
495 }
496
497 static SkStreamAsset* resource(const char path[]) {
498 SkString fullPath = GetResourcePath(path);
499 return SkStream::NewFromFile(fullPath.c_str());
500 }
501
502 static void codec_yuv(skiatest::Reporter* reporter,
503 const char path[],
504 SkISize expectedSizes[3]) {
505 SkAutoTDelete<SkStream> stream(resource(path));
506 if (!stream) {
507 SkDebugf("Missing resource '%s'\n", path);
508 return;
509 }
510 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
511 REPORTER_ASSERT(reporter, codec);
512 if (!codec) {
513 return;
514 }
515
516 // Test queryYUV8()
517 SkCodec::YUVSizeInfo info;
518 bool success = codec->queryYUV8(nullptr, nullptr);
519 REPORTER_ASSERT(reporter, !success);
520 success = codec->queryYUV8(&info, nullptr);
521 REPORTER_ASSERT(reporter, (expectedSizes == nullptr) == !success);
522 if (!success) {
523 return;
524 }
525 REPORTER_ASSERT(reporter,
526 0 == memcmp((const void*) &info, (const void*) expectedSizes, 3 * si zeof(SkISize)));
527 REPORTER_ASSERT(reporter, info.fYWidthBytes == (uint32_t) SkAlign8(info.fYSi ze.width()));
528 REPORTER_ASSERT(reporter, info.fUWidthBytes == (uint32_t) SkAlign8(info.fUSi ze.width()));
529 REPORTER_ASSERT(reporter, info.fVWidthBytes == (uint32_t) SkAlign8(info.fVSi ze.width()));
530 SkYUVColorSpace colorSpace;
531 success = codec->queryYUV8(&info, &colorSpace);
532 REPORTER_ASSERT(reporter,
533 0 == memcmp((const void*) &info, (const void*) expectedSizes, 3 * si zeof(SkISize)));
534 REPORTER_ASSERT(reporter, info.fYWidthBytes == (uint32_t) SkAlign8(info.fYSi ze.width()));
535 REPORTER_ASSERT(reporter, info.fUWidthBytes == (uint32_t) SkAlign8(info.fUSi ze.width()));
536 REPORTER_ASSERT(reporter, info.fVWidthBytes == (uint32_t) SkAlign8(info.fVSi ze.width()));
537 REPORTER_ASSERT(reporter, kJPEG_SkYUVColorSpace == colorSpace);
538
539 // Allocate the memory for the YUV decode
540 size_t totalBytes = info.fYWidthBytes * info.fYSize.height() +
541 info.fUWidthBytes * info.fUSize.height() +
542 info.fVWidthBytes * info.fVSize.height();
543 SkAutoMalloc storage(totalBytes);
544 void* planes[3];
545 planes[0] = storage.get();
546 planes[1] = SkTAddOffset<void>(planes[0], info.fYWidthBytes * info.fYSize.he ight());
547 planes[2] = SkTAddOffset<void>(planes[1], info.fUWidthBytes * info.fUSize.he ight());
548
549 // Test getYUV8Planes()
550 REPORTER_ASSERT(reporter, SkCodec::kInvalidInput ==
551 codec->getYUV8Planes(info, nullptr));
552 REPORTER_ASSERT(reporter, SkCodec::kSuccess ==
553 codec->getYUV8Planes(info, planes));
554 }
555
556 DEF_TEST(Jpeg_YUV_Codec, r) {
557 SkISize sizes[3];
558
559 sizes[0].set(128, 128);
560 sizes[1].set(64, 64);
561 sizes[2].set(64, 64);
562 codec_yuv(r, "color_wheel.jpg", sizes);
563
564 // H2V2
565 sizes[0].set(512, 512);
566 sizes[1].set(256, 256);
567 sizes[2].set(256, 256);
568 codec_yuv(r, "mandrill_512_q075.jpg", sizes);
569
570 // H1V1
571 sizes[1].set(512, 512);
572 sizes[2].set(512, 512);
573 codec_yuv(r, "mandrill_h1v1.jpg", sizes);
574
575 // H2V1
576 sizes[1].set(256, 512);
577 sizes[2].set(256, 512);
578 codec_yuv(r, "mandrill_h2v1.jpg", sizes);
579
580 // Non-power of two dimensions
581 sizes[0].set(439, 154);
582 sizes[1].set(220, 77);
583 sizes[2].set(220, 77);
584 codec_yuv(r, "cropped_mandrill.jpg", sizes);
585
586 sizes[0].set(8, 8);
587 sizes[1].set(4, 4);
588 sizes[2].set(4, 4);
589 codec_yuv(r, "randPixels.jpg", sizes);
590
591 // Progressive images
592 sizes[0].set(512, 512);
593 sizes[1].set(512, 512);
594 sizes[2].set(512, 512);
595 codec_yuv(r, "brickwork-texture.jpg", sizes);
596 codec_yuv(r, "brickwork_normal-map.jpg", sizes);
597
598 // A CMYK encoded image should fail.
599 codec_yuv(r, "CMYK.jpg", nullptr);
600 // A grayscale encoded image should fail.
601 codec_yuv(r, "grayscale.jpg", nullptr);
602 // A PNG should fail.
603 codec_yuv(r, "arrow.png", nullptr);
604 }
OLDNEW
« no previous file with comments | « tests/ImageDecodingTest.cpp ('k') | tests/YUVTest.cpp » ('j') | tests/YUVTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698