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

Side by Side Diff: tests/CodexTest.cpp

Issue 1472123002: Make SkCodec support peek() and read() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update SkWebpCodec 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
« src/codec/SkWebpCodec.cpp ('K') | « src/codec/SkWebpCodec.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"
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 REPORTER_ASSERT(r, SkImageDecoder::DecodeMemory(data->data(), data->size(), &bitmap)); 870 REPORTER_ASSERT(r, SkImageDecoder::DecodeMemory(data->data(), data->size(), &bitmap));
871 871
872 // So SkCodec should, too. 872 // So SkCodec should, too.
873 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data)); 873 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
874 REPORTER_ASSERT(r, codec); 874 REPORTER_ASSERT(r, codec);
875 if (!codec) { 875 if (!codec) {
876 return; 876 return;
877 } 877 }
878 test_info(r, codec, codec->getInfo(), SkCodec::kSuccess, nullptr); 878 test_info(r, codec, codec->getInfo(), SkCodec::kSuccess, nullptr);
879 } 879 }
880
881 // wbmp images have a header that can be arbitrarily large, depending on the
882 // size of the image. We cap the size at 65535, meaning we only need to look at
883 // 8 bytes to determine whether we can read the image. This is important
884 // because SkCodec only passes 14 bytes to SkWbmpCodec to determine whether the
885 // image is a wbmp.
886 DEF_TEST(Codec_wbmp_max_size, r) {
887 const unsigned char maxSizeWbmp[] = { 0x00, 0x00, // Header
888 0x83, 0xFF, 0x7F, // W: 65535
889 0x83, 0xFF, 0x7F }; // H: 65535
890 SkAutoTDelete<SkStream> stream(new SkMemoryStream(maxSizeWbmp, sizeof(maxSiz eWbmp), false));
891 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.detach()));
892
893 REPORTER_ASSERT(r, codec);
894 if (!codec) return;
895
896 REPORTER_ASSERT(r, codec->getInfo().width() == 65535);
897 REPORTER_ASSERT(r, codec->getInfo().height() == 65535);
898
899 // Now test an image which is too big. Any image with a larger header (i.e.
900 // has bigger width/height) is also too big.
901 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header
902 0x84, 0x80, 0x00, // W: 65536
903 0x84, 0x80, 0x00 }; // H: 65536
904 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false));
905 codec.reset(SkCodec::NewFromStream(stream.detach()));
906
907 REPORTER_ASSERT(r, !codec);
908 }
OLDNEW
« src/codec/SkWebpCodec.cpp ('K') | « src/codec/SkWebpCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698