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

Side by Side Diff: tests/CodecPartialTest.cpp

Issue 2447863002: Report repetition count in SkCodec (Closed)
Patch Set: Return a bool, with multiple out parameters Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 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 "SkCodec.h" 9 #include "SkCodec.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 const SkCodec::Result result = fullCodec->getPixels(info, frame.getPixel s(), 209 const SkCodec::Result result = fullCodec->getPixels(info, frame.getPixel s(),
210 frame.rowBytes(), &opts, nullptr, nullptr); 210 frame.rowBytes(), &opts, nullptr, nullptr);
211 211
212 if (result == SkCodec::kIncompleteInput) { 212 if (result == SkCodec::kIncompleteInput) {
213 frameByteCounts.push_back(stream->getPosition() - lastOffset); 213 frameByteCounts.push_back(stream->getPosition() - lastOffset);
214 214
215 // We need to distinguish between a partial frame and no more frames . 215 // We need to distinguish between a partial frame and no more frames .
216 // getFrameInfo lets us do this, since it tells the number of frames 216 // getFrameInfo lets us do this, since it tells the number of frames
217 // not considering whether they are complete. 217 // not considering whether they are complete.
218 // FIXME: Should we use a different Result? 218 // FIXME: Should we use a different Result?
219 if (fullCodec->getFrameInfo().size() > i) { 219 const size_t frameCount = [&fullCodec]() -> size_t {
220 std::vector<SkCodec::FrameInfo> frameInfos;
221 if (!fullCodec->getFrameInfo(&frameInfos, nullptr)) {
222 return 0;
223 }
224 return frameInfos.size();
225 }();
226
227 if (frameCount > i) {
220 // This is a partial frame. 228 // This is a partial frame.
221 frames.push_back(frame); 229 frames.push_back(frame);
222 } 230 }
223 break; 231 break;
224 } 232 }
225 233
226 if (result != SkCodec::kSuccess) { 234 if (result != SkCodec::kSuccess) {
227 ERRORF(r, "Failed to decode frame %i from %s", i, path); 235 ERRORF(r, "Failed to decode frame %i from %s", i, path);
228 return; 236 return;
229 } 237 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Now incremental decode will fail 321 // Now incremental decode will fail
314 result = partialCodec->incrementalDecode(); 322 result = partialCodec->incrementalDecode();
315 REPORTER_ASSERT(r, result == SkCodec::kInvalidParameters); 323 REPORTER_ASSERT(r, result == SkCodec::kInvalidParameters);
316 } 324 }
317 325
318 DEF_TEST(Codec_rewind, r) { 326 DEF_TEST(Codec_rewind, r) {
319 test_interleaved(r, "plane.png"); 327 test_interleaved(r, "plane.png");
320 test_interleaved(r, "plane_interlaced.png"); 328 test_interleaved(r, "plane_interlaced.png");
321 test_interleaved(r, "box.gif"); 329 test_interleaved(r, "box.gif");
322 } 330 }
OLDNEW
« include/codec/SkCodec.h ('K') | « tests/CodecAnimTest.cpp ('k') | tests/CodecTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698