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

Side by Side Diff: tests/CodexTest.cpp

Issue 1487683004: Create an SkCodecImageGenerator (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move to src/codec and codec.gyp Created 4 years, 11 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/codec/SkCodecImageGenerator.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 2015 Google Inc. 2 * Copyright 2015 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 "Resources.h" 8 #include "Resources.h"
9 #include "SkAndroidCodec.h" 9 #include "SkAndroidCodec.h"
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
11 #include "SkCodec.h" 11 #include "SkCodec.h"
12 #include "SkCodecImageGenerator.h"
12 #include "SkData.h" 13 #include "SkData.h"
13 #include "SkImageDecoder.h" 14 #include "SkImageDecoder.h"
14 #include "SkMD5.h" 15 #include "SkMD5.h"
15 #include "SkRandom.h" 16 #include "SkRandom.h"
16 #include "SkStream.h" 17 #include "SkStream.h"
17 #include "SkStreamPriv.h" 18 #include "SkStreamPriv.h"
18 #include "SkPngChunkReader.h" 19 #include "SkPngChunkReader.h"
19 #include "Test.h" 20 #include "Test.h"
20 21
21 #include "png.h" 22 #include "png.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 ERRORF(r, "Unable to decode '%s'", path); 373 ERRORF(r, "Unable to decode '%s'", path);
373 return; 374 return;
374 } 375 }
375 376
376 SkBitmap bm; 377 SkBitmap bm;
377 SkMD5::Digest scaledCodecDigest; 378 SkMD5::Digest scaledCodecDigest;
378 test_android_codec(r, codec, bm, info, size, expectedResult, 379 test_android_codec(r, codec, bm, info, size, expectedResult,
379 &scaledCodecDigest, &codecDigest); 380 &scaledCodecDigest, &codecDigest);
380 } 381 }
381 382
383 // Test SkCodecImageGenerator
384 if (!isIncomplete) {
385 SkAutoTDelete<SkStream> stream(resource(path));
386 SkAutoTUnref<SkData> fullData(SkData::NewFromStream(stream, stream->getL ength()));
387 SkAutoTDelete<SkImageGenerator> gen(SkCodecImageGenerator::NewFromEncode dCodec(fullData));
388 SkBitmap bm;
389 bm.allocPixels(info);
390 SkAutoLockPixels autoLockPixels(bm);
391 REPORTER_ASSERT(r, gen->getPixels(info, bm.getPixels(), bm.rowBytes()));
392 compare_to_good_digest(r, codecDigest, bm);
393 }
394
382 // If we've just tested incomplete decodes, let's run the same test again on full decodes. 395 // If we've just tested incomplete decodes, let's run the same test again on full decodes.
383 if (isIncomplete) { 396 if (isIncomplete) {
384 check(r, path, size, supportsScanlineDecoding, supportsSubsetDecoding, f alse); 397 check(r, path, size, supportsScanlineDecoding, supportsSubsetDecoding, f alse);
385 } 398 }
386 } 399 }
387 400
388 DEF_TEST(Codec, r) { 401 DEF_TEST(Codec, r) {
389 // WBMP 402 // WBMP
390 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false); 403 check(r, "mandrill.wbmp", SkISize::Make(512, 512), true, false);
391 404
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 // Now test an image which is too big. Any image with a larger header (i.e. 960 // Now test an image which is too big. Any image with a larger header (i.e.
948 // has bigger width/height) is also too big. 961 // has bigger width/height) is also too big.
949 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header 962 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header
950 0x84, 0x80, 0x00, // W: 65536 963 0x84, 0x80, 0x00, // W: 65536
951 0x84, 0x80, 0x00 }; // H: 65536 964 0x84, 0x80, 0x00 }; // H: 65536
952 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); 965 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false));
953 codec.reset(SkCodec::NewFromStream(stream.detach())); 966 codec.reset(SkCodec::NewFromStream(stream.detach()));
954 967
955 REPORTER_ASSERT(r, !codec); 968 REPORTER_ASSERT(r, !codec);
956 } 969 }
OLDNEW
« no previous file with comments | « src/codec/SkCodecImageGenerator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698