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

Side by Side Diff: tests/CodecTest.cpp

Issue 2155163004: Revert of Fix rewinding bug in SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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/SkJpegCodec.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 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 // Now test an image which is too big. Any image with a larger header (i.e. 1005 // Now test an image which is too big. Any image with a larger header (i.e.
1006 // has bigger width/height) is also too big. 1006 // has bigger width/height) is also too big.
1007 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header 1007 const unsigned char tooBigWbmp[] = { 0x00, 0x00, // Header
1008 0x84, 0x80, 0x00, // W: 65536 1008 0x84, 0x80, 0x00, // W: 65536
1009 0x84, 0x80, 0x00 }; // H: 65536 1009 0x84, 0x80, 0x00 }; // H: 65536
1010 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false)); 1010 stream.reset(new SkMemoryStream(tooBigWbmp, sizeof(tooBigWbmp), false));
1011 codec.reset(SkCodec::NewFromStream(stream.release())); 1011 codec.reset(SkCodec::NewFromStream(stream.release()));
1012 1012
1013 REPORTER_ASSERT(r, !codec); 1013 REPORTER_ASSERT(r, !codec);
1014 } 1014 }
1015
1016 DEF_TEST(Codec_jpeg_rewind, r) {
1017 const char* path = "mandrill_512_q075.jpg";
1018 SkAutoTDelete<SkStream> stream(resource(path));
1019 if (!stream) {
1020 SkDebugf("Missing resource '%s'\n", path);
1021 return;
1022 }
1023 SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.rel ease()));
1024 if (!codec) {
1025 ERRORF(r, "Unable to create codec '%s'.", path);
1026 return;
1027 }
1028
1029 const int width = codec->getInfo().width();
1030 const int height = codec->getInfo().height();
1031 size_t rowBytes = sizeof(SkPMColor) * width;
1032 SkAutoMalloc pixelStorage(height * rowBytes);
1033
1034 // Perform a sampled decode.
1035 SkAndroidCodec::AndroidOptions opts;
1036 opts.fSampleSize = 12;
1037 codec->getAndroidPixels(codec->getInfo().makeWH(width / 12, height / 12), pi xelStorage.get(),
1038 rowBytes, &opts);
1039
1040 // Rewind the codec and perform a full image decode.
1041 SkCodec::Result result = codec->getPixels(codec->getInfo(), pixelStorage.get (), rowBytes);
1042 REPORTER_ASSERT(r, SkCodec::kSuccess == result);
1043 }
OLDNEW
« no previous file with comments | « src/codec/SkJpegCodec.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698