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

Side by Side Diff: tests/ImageDecodingTest.cpp

Issue 105443005: Fix Red/Blue decoding problem in WebP. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/images/SkImageDecoder_libwebp.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 2013 Google Inc. 2 * Copyright 2013 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 "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkData.h" 12 #include "SkData.h"
13 #include "SkDecodingImageGenerator.h"
13 #include "SkForceLinking.h" 14 #include "SkForceLinking.h"
14 #include "SkGradientShader.h" 15 #include "SkGradientShader.h"
15 #include "SkImageDecoder.h" 16 #include "SkImageDecoder.h"
16 #include "SkImageEncoder.h" 17 #include "SkImageEncoder.h"
17 #include "SkOSFile.h" 18 #include "SkOSFile.h"
18 #include "SkPoint.h" 19 #include "SkPoint.h"
19 #include "SkShader.h" 20 #include "SkShader.h"
20 #include "SkStream.h" 21 #include "SkStream.h"
21 #include "SkString.h" 22 #include "SkString.h"
22 #include "Test.h" 23 #include "Test.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 test_unpremul(reporter); 233 test_unpremul(reporter);
233 #ifdef SK_DEBUG 234 #ifdef SK_DEBUG
234 test_stream_life(); 235 test_stream_life();
235 test_row_proc_choice(); 236 test_row_proc_choice();
236 #endif 237 #endif
237 } 238 }
238 239
239 #include "TestClassDef.h" 240 #include "TestClassDef.h"
240 DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass, 241 DEFINE_TESTCLASS("ImageDecoding", ImageDecodingTestClass,
241 test_imageDecodingTests) 242 test_imageDecodingTests)
243
244
245 DEF_TEST(WebP, reporter) {
246 const unsigned char encodedWebP[] = {
247 0x52, 0x49, 0x46, 0x46, 0x2c, 0x01, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50,
248 0x56, 0x50, 0x38, 0x4c, 0x20, 0x01, 0x00, 0x00, 0x2f, 0x07, 0xc0, 0x01,
249 0x00, 0xff, 0x01, 0x45, 0x03, 0x00, 0xe2, 0xd5, 0xae, 0x60, 0x2b, 0xad,
250 0xd9, 0x68, 0x76, 0xb6, 0x8d, 0x6a, 0x1d, 0xc0, 0xe6, 0x19, 0xd6, 0x16,
251 0xb7, 0xb4, 0xef, 0xcf, 0xc3, 0x15, 0x6c, 0xb3, 0xbd, 0x77, 0x0d, 0x85,
252 0x6d, 0x1b, 0xa9, 0xb1, 0x2b, 0xdc, 0x3d, 0x83, 0xdb, 0x00, 0x00, 0xc8,
253 0x26, 0xe5, 0x01, 0x99, 0x8a, 0xd5, 0xdd, 0xfc, 0x82, 0xcd, 0xcd, 0x9a,
254 0x8c, 0x13, 0xcc, 0x1b, 0xba, 0xf5, 0x05, 0xdb, 0xee, 0x6a, 0xdb, 0x38,
255 0x60, 0xfe, 0x43, 0x2c, 0xd4, 0x6a, 0x99, 0x4d, 0xc6, 0xc0, 0xd3, 0x28,
256 0x1b, 0xc1, 0xb1, 0x17, 0x4e, 0x43, 0x0e, 0x3d, 0x27, 0xe9, 0xe4, 0x84,
257 0x4f, 0x24, 0x62, 0x69, 0x85, 0x43, 0x8d, 0xc2, 0x04, 0x00, 0x07, 0x59,
258 0x60, 0xfd, 0x8b, 0x4d, 0x60, 0x32, 0x72, 0xcf, 0x88, 0x0c, 0x2f, 0x2f,
259 0xad, 0x62, 0xbd, 0x27, 0x09, 0x16, 0x70, 0x78, 0x6c, 0xd9, 0x82, 0xef,
260 0x1a, 0xa2, 0xcc, 0xf0, 0xf1, 0x6f, 0xd8, 0x78, 0x2e, 0x39, 0xa1, 0xcf,
261 0x14, 0x4b, 0x89, 0xb4, 0x1b, 0x48, 0x15, 0x7c, 0x48, 0x6f, 0x8c, 0x20,
262 0xb7, 0x00, 0xcf, 0xfc, 0xdb, 0xd0, 0xe9, 0xe7, 0x42, 0x09, 0xa4, 0x03,
263 0x40, 0xac, 0xda, 0x40, 0x01, 0x00, 0x5f, 0xa1, 0x3d, 0x64, 0xe1, 0xf4,
264 0x03, 0x45, 0x29, 0xe0, 0xe2, 0x4a, 0xc3, 0xa2, 0xe8, 0xe0, 0x25, 0x12,
265 0x74, 0xc6, 0xe8, 0xfb, 0x93, 0x4f, 0x9f, 0x5e, 0xc0, 0xa6, 0x91, 0x1b,
266 0xa4, 0x24, 0x82, 0xc3, 0x61, 0x07, 0x4c, 0x49, 0x4f, 0x53, 0xae, 0x5f,
267 0x5d, 0x39, 0x36, 0xc0, 0x5b, 0x57, 0x54, 0x60, 0x10, 0x00, 0x00, 0xd1,
268 0x68, 0xb6, 0x6d, 0xdb, 0x36, 0x22, 0xfa, 0x1f, 0x35, 0x75, 0x22, 0xec,
269 0x31, 0xbc, 0x5d, 0x8f, 0x87, 0x53, 0xa2, 0x05, 0x8c, 0x2f, 0xcd, 0xa8,
270 0xa7, 0xf3, 0xa3, 0xbd, 0x83, 0x8b, 0x2a, 0xc8, 0x58, 0xf5, 0xac, 0x80,
271 0xe3, 0xfe, 0x66, 0xa4, 0x7c, 0x1b, 0x6c, 0xd1, 0xa9, 0xd8, 0x14, 0xd0,
272 0xc5, 0xb5, 0x39, 0x71, 0x97, 0x19, 0x19, 0x1b
273 };
274 const SkColor thePixels[] = {
275 0xffbba570, 0xff395f5d, 0xffe25c39, 0xff197666,
276 0xff3cba27, 0xffdefcb0, 0xffc13874, 0xfffa0093,
277 0xffbda60e, 0xffc01db6, 0xff2bd688, 0xff9362d4,
278 0xffc641b2, 0xffa5cede, 0xff606eba, 0xff8f4bf3,
279 0xff3bf742, 0xff8f02a8, 0xff5509df, 0xffc7027e,
280 0xff24aa8a, 0xff886c96, 0xff625481, 0xff403689,
281 0xffc52152, 0xff78ccd6, 0xffdcb4ab, 0xff09d27d,
282 0xffca00f3, 0xff605d47, 0xff446fb2, 0xff576e46,
283 0xff273df9, 0xffb41a83, 0xfff812c3, 0xffccab67,
284 0xff034218, 0xff7db9a7, 0xff821048, 0xfffe4ab4,
285 0xff6fac98, 0xff941d27, 0xff5fe411, 0xfffbb283,
286 0xffd86e99, 0xff169162, 0xff71128c, 0xff39cab4,
287 0xffa7fe63, 0xff4c956b, 0xffbc22e0, 0xffb272e4,
288 0xff129f4a, 0xffe34513, 0xff3d3742, 0xffbd190a,
289 0xffb07222, 0xff2e23f8, 0xfff089d9, 0xffb35738,
290 0xffa86022, 0xff3340fe, 0xff95fe71, 0xff6a71df
291 };
292 SkAutoDataUnref encoded(SkData::NewWithCopy(encodedWebP,
293 sizeof(encodedWebP)));
294 SkBitmap bm;
295 bool success = SkDecodingImageGenerator::Install(encoded, &bm, NULL);
296 REPORTER_ASSERT(reporter, success);
297 if (!success) {
298 return;
299 }
300 SkAutoLockPixels alp(bm);
301 bool rightSize = SK_ARRAY_COUNT(thePixels) == bm.width() * bm.height();
302 REPORTER_ASSERT(reporter, rightSize);
303 if (rightSize) {
304 bool error = false;
305 const SkColor* correctPixel = thePixels;
scroggo 2013/12/11 19:59:04 The test looks fine, although we run other tests s
306 for (int y = 0; y < bm.height(); ++y) {
307 for (int x = 0; x < bm.width(); ++x) {
308 error |= (*correctPixel != bm.getColor(x, y));
309 ++correctPixel;
310 }
311 }
312 REPORTER_ASSERT(reporter, !error);
313 }
314 }
OLDNEW
« no previous file with comments | « src/images/SkImageDecoder_libwebp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698