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

Side by Side Diff: tests/CodexTest.cpp

Issue 1473673005: Support wbmp that are supported by SkImageDecoder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/codec/SkCodec_wbmp.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 "SkData.h" 12 #include "SkData.h"
13 #include "SkImageDecoder.h"
13 #include "SkMD5.h" 14 #include "SkMD5.h"
14 #include "SkRandom.h" 15 #include "SkRandom.h"
15 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "SkStreamPriv.h"
16 #include "SkPngChunkReader.h" 18 #include "SkPngChunkReader.h"
17 #include "Test.h" 19 #include "Test.h"
18 20
19 #include "png.h" 21 #include "png.h"
20 22
21 static SkStreamAsset* resource(const char path[]) { 23 static SkStreamAsset* resource(const char path[]) {
22 SkString fullPath = GetResourcePath(path); 24 SkString fullPath = GetResourcePath(path);
23 return SkStream::NewFromFile(fullPath.c_str()); 25 return SkStream::NewFromFile(fullPath.c_str());
24 } 26 }
25 27
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); 840 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen());
839 841
840 // Decoding again will read the chunks again. 842 // Decoding again will read the chunks again.
841 chunkReader.reset(); 843 chunkReader.reset();
842 REPORTER_ASSERT(r, !chunkReader.allHaveBeenSeen()); 844 REPORTER_ASSERT(r, !chunkReader.allHaveBeenSeen());
843 result = codec->getPixels(codec->getInfo(), decodedBm.getPixels(), decodedBm .rowBytes()); 845 result = codec->getPixels(codec->getInfo(), decodedBm.getPixels(), decodedBm .rowBytes());
844 REPORTER_ASSERT(r, SkCodec::kSuccess == result); 846 REPORTER_ASSERT(r, SkCodec::kSuccess == result);
845 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen()); 847 REPORTER_ASSERT(r, chunkReader.allHaveBeenSeen());
846 } 848 }
847 #endif // PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 849 #endif // PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
850
851 // SkCodec's wbmp decoder was initially more restrictive than SkImageDecoder.
852 // It required the second byte to be zero. But SkImageDecoder allowed a couple
853 // of bits to be 1 (so long as they do not overlap with 0x9F). Test that
854 // SkCodec now supports an image with these bits set.
855 DEF_TEST(Codec_wbmp, r) {
856 const char* path = "mandrill.wbmp";
msarett 2015/11/30 13:24:55 Did we fail on this image before you made this cha
scroggo 2015/11/30 13:48:13 No. See below - I had to modify the image to make
msarett 2015/11/30 14:00:44 My mistake, it's perfectly clear.
857 SkAutoTDelete<SkStream> stream(resource(path));
858 if (!stream) {
859 SkDebugf("Missing resource '%s'\n", path);
860 return;
861 }
862
863 // Modify the stream to contain a second byte with some bits set.
864 SkAutoTUnref<SkData> data(SkCopyStreamToData(stream));
865 uint8_t* writeableData = static_cast<uint8_t*>(data->writable_data());
866 writeableData[1] = static_cast<uint8_t>(~0x9F);
867
868 // SkImageDecoder supports this.
869 SkBitmap bitmap;
870 REPORTER_ASSERT(r, SkImageDecoder::DecodeMemory(data->data(), data->size(), &bitmap));
871
872 // So SkCodec should, too.
873 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
874 REPORTER_ASSERT(r, codec);
875 if (!codec) {
876 return;
877 }
878 test_info(r, codec, codec->getInfo(), SkCodec::kSuccess, nullptr);
879 }
OLDNEW
« no previous file with comments | « src/codec/SkCodec_wbmp.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698