OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "wtf/Vector.h" | 39 #include "wtf/Vector.h" |
40 #include <memory> | 40 #include <memory> |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 namespace { | 44 namespace { |
45 | 45 |
46 const char layoutTestResourcesDir[] = "LayoutTests/images/resources"; | 46 const char layoutTestResourcesDir[] = "LayoutTests/images/resources"; |
47 | 47 |
48 std::unique_ptr<ImageDecoder> createDecoder() { | 48 std::unique_ptr<ImageDecoder> createDecoder() { |
49 return wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, | 49 return wrapUnique(new GIFImageDecoder( |
50 ImageDecoder::ColorSpaceApplied, | 50 ImageDecoder::AlphaNotPremultiplied, ImageDecoder::ColorSpaceTransformed, |
51 ImageDecoder::noDecodedImageByteLimit)); | 51 ImageDecoder::targetColorSpaceForTesting(), |
| 52 ImageDecoder::noDecodedImageByteLimit)); |
52 } | 53 } |
53 | 54 |
54 void testRepetitionCount(const char* dir, | 55 void testRepetitionCount(const char* dir, |
55 const char* file, | 56 const char* file, |
56 int expectedRepetitionCount) { | 57 int expectedRepetitionCount) { |
57 std::unique_ptr<ImageDecoder> decoder = createDecoder(); | 58 std::unique_ptr<ImageDecoder> decoder = createDecoder(); |
58 RefPtr<SharedBuffer> data = readFile(dir, file); | 59 RefPtr<SharedBuffer> data = readFile(dir, file); |
59 ASSERT_TRUE(data.get()); | 60 ASSERT_TRUE(data.get()); |
60 decoder->setData(data.get(), true); | 61 decoder->setData(data.get(), true); |
61 EXPECT_EQ(cAnimationLoopOnce, | 62 EXPECT_EQ(cAnimationLoopOnce, |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 441 |
441 // Empirically chosen truncation size: | 442 // Empirically chosen truncation size: |
442 // a) large enough to produce a partial frame && | 443 // a) large enough to produce a partial frame && |
443 // b) small enough to not fully decode the frame | 444 // b) small enough to not fully decode the frame |
444 const size_t kTruncateSize = 800; | 445 const size_t kTruncateSize = 800; |
445 ASSERT_TRUE(kTruncateSize < fullData->size()); | 446 ASSERT_TRUE(kTruncateSize < fullData->size()); |
446 RefPtr<SharedBuffer> partialData = | 447 RefPtr<SharedBuffer> partialData = |
447 SharedBuffer::create(fullData->data(), kTruncateSize); | 448 SharedBuffer::create(fullData->data(), kTruncateSize); |
448 | 449 |
449 std::unique_ptr<ImageDecoder> premulDecoder = wrapUnique(new GIFImageDecoder( | 450 std::unique_ptr<ImageDecoder> premulDecoder = wrapUnique(new GIFImageDecoder( |
450 ImageDecoder::AlphaPremultiplied, ImageDecoder::ColorSpaceApplied, | 451 ImageDecoder::AlphaPremultiplied, ImageDecoder::ColorSpaceTransformed, |
| 452 ImageDecoder::targetColorSpaceForTesting(), |
451 ImageDecoder::noDecodedImageByteLimit)); | 453 ImageDecoder::noDecodedImageByteLimit)); |
452 std::unique_ptr<ImageDecoder> unpremulDecoder = | 454 std::unique_ptr<ImageDecoder> unpremulDecoder = |
453 wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, | 455 wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, |
454 ImageDecoder::ColorSpaceApplied, | 456 ImageDecoder::ColorSpaceTransformed, |
| 457 ImageDecoder::targetColorSpaceForTesting(), |
455 ImageDecoder::noDecodedImageByteLimit)); | 458 ImageDecoder::noDecodedImageByteLimit)); |
456 | 459 |
457 // Partially decoded frame => the frame alpha type is unknown and should | 460 // Partially decoded frame => the frame alpha type is unknown and should |
458 // reflect the requested format. | 461 // reflect the requested format. |
459 premulDecoder->setData(partialData.get(), false); | 462 premulDecoder->setData(partialData.get(), false); |
460 ASSERT_TRUE(premulDecoder->frameCount()); | 463 ASSERT_TRUE(premulDecoder->frameCount()); |
461 unpremulDecoder->setData(partialData.get(), false); | 464 unpremulDecoder->setData(partialData.get(), false); |
462 ASSERT_TRUE(unpremulDecoder->frameCount()); | 465 ASSERT_TRUE(unpremulDecoder->frameCount()); |
463 ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0); | 466 ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0); |
464 EXPECT_TRUE(premulFrame && | 467 EXPECT_TRUE(premulFrame && |
(...skipping 13 matching lines...) Expand all Loading... |
478 EXPECT_TRUE(premulFrame && | 481 EXPECT_TRUE(premulFrame && |
479 premulFrame->getStatus() == ImageFrame::FrameComplete); | 482 premulFrame->getStatus() == ImageFrame::FrameComplete); |
480 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); | 483 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); |
481 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); | 484 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); |
482 EXPECT_TRUE(unpremulFrame && | 485 EXPECT_TRUE(unpremulFrame && |
483 unpremulFrame->getStatus() == ImageFrame::FrameComplete); | 486 unpremulFrame->getStatus() == ImageFrame::FrameComplete); |
484 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); | 487 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); |
485 } | 488 } |
486 | 489 |
487 } // namespace blink | 490 } // namespace blink |
OLD | NEW |