| OLD | NEW |
| 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 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 // parsed the second frame. | 1271 // parsed the second frame. |
| 1272 decode_frame(r, codec.get(), 1); | 1272 decode_frame(r, codec.get(), 1); |
| 1273 REPORTER_ASSERT(r, stream->getPosition() == positionAfterThirdFrame); | 1273 REPORTER_ASSERT(r, stream->getPosition() == positionAfterThirdFrame); |
| 1274 | 1274 |
| 1275 // This should read the rest of the frames. | 1275 // This should read the rest of the frames. |
| 1276 decode_frame(r, codec.get(), 3); | 1276 decode_frame(r, codec.get(), 3); |
| 1277 const size_t finalPosition = stream->getPosition(); | 1277 const size_t finalPosition = stream->getPosition(); |
| 1278 REPORTER_ASSERT(r, finalPosition > positionAfterThirdFrame); | 1278 REPORTER_ASSERT(r, finalPosition > positionAfterThirdFrame); |
| 1279 | 1279 |
| 1280 // There may be more data in the stream. | 1280 // There may be more data in the stream. |
| 1281 auto frameInfo = codec->getFrameInfo(); | 1281 std::vector<SkCodec::FrameInfo> frameInfo; |
| 1282 REPORTER_ASSERT(r, frameInfo.size() == 4); | 1282 const bool animated = codec->getFrameInfo(&frameInfo, nullptr); |
| 1283 REPORTER_ASSERT(r, stream->getPosition() >= finalPosition); | 1283 if (animated) { |
| 1284 REPORTER_ASSERT(r, frameInfo.size() == 4); |
| 1285 REPORTER_ASSERT(r, stream->getPosition() >= finalPosition); |
| 1286 } else { |
| 1287 ERRORF(r, "Image should be animated!\n"); |
| 1288 } |
| 1284 } | 1289 } |
| 1285 | 1290 |
| 1286 // Only rewinds up to a limit. | 1291 // Only rewinds up to a limit. |
| 1287 class LimitedRewindingStream : public SkStream { | 1292 class LimitedRewindingStream : public SkStream { |
| 1288 public: | 1293 public: |
| 1289 static SkStream* Make(const char path[], size_t limit) { | 1294 static SkStream* Make(const char path[], size_t limit) { |
| 1290 SkStream* stream = GetResourceAsStream(path); | 1295 SkStream* stream = GetResourceAsStream(path); |
| 1291 if (!stream) { | 1296 if (!stream) { |
| 1292 return nullptr; | 1297 return nullptr; |
| 1293 } | 1298 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput); | 1433 REPORTER_ASSERT(r, result == SkCodec::kIncompleteInput); |
| 1429 REPORTER_ASSERT(r, rowsDecoded == 0); | 1434 REPORTER_ASSERT(r, rowsDecoded == 0); |
| 1430 } | 1435 } |
| 1431 | 1436 |
| 1432 DEF_TEST(Codec_IcoIntOverflow, r) { | 1437 DEF_TEST(Codec_IcoIntOverflow, r) { |
| 1433 // ASAN will complain if there is an issue. | 1438 // ASAN will complain if there is an issue. |
| 1434 SkBitmap bitmap; | 1439 SkBitmap bitmap; |
| 1435 const bool success = GetResourceAsBitmap("invalid_images/int_overflow.ico",
&bitmap); | 1440 const bool success = GetResourceAsBitmap("invalid_images/int_overflow.ico",
&bitmap); |
| 1436 REPORTER_ASSERT(r, !success); | 1441 REPORTER_ASSERT(r, !success); |
| 1437 } | 1442 } |
| OLD | NEW |