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 29 matching lines...) Expand all Loading... |
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 decodersTestingDir[] = "Source/platform/image-decoders/testing"; | 46 const char decodersTestingDir[] = "Source/platform/image-decoders/testing"; |
47 const char layoutTestResourcesDir[] = "LayoutTests/fast/images/resources"; | 47 const char layoutTestResourcesDir[] = "LayoutTests/fast/images/resources"; |
48 | 48 |
49 std::unique_ptr<ImageDecoder> createDecoder() { | 49 std::unique_ptr<ImageDecoder> createDecoder() { |
50 return wrapUnique( | 50 return wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, |
51 new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, | 51 ImageDecoder::ColorSpaceApplied, |
52 ImageDecoder::GammaAndColorProfileApplied, | 52 ImageDecoder::noDecodedImageByteLimit)); |
53 ImageDecoder::noDecodedImageByteLimit)); | |
54 } | 53 } |
55 | 54 |
56 void testRandomFrameDecode(const char* dir, const char* gifFile) { | 55 void testRandomFrameDecode(const char* dir, const char* gifFile) { |
57 SCOPED_TRACE(gifFile); | 56 SCOPED_TRACE(gifFile); |
58 | 57 |
59 RefPtr<SharedBuffer> fullData = readFile(dir, gifFile); | 58 RefPtr<SharedBuffer> fullData = readFile(dir, gifFile); |
60 ASSERT_TRUE(fullData.get()); | 59 ASSERT_TRUE(fullData.get()); |
61 Vector<unsigned> baselineHashes; | 60 Vector<unsigned> baselineHashes; |
62 createDecodingBaseline(&createDecoder, fullData.get(), &baselineHashes); | 61 createDecodingBaseline(&createDecoder, fullData.get(), &baselineHashes); |
63 size_t frameCount = baselineHashes.size(); | 62 size_t frameCount = baselineHashes.size(); |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 ASSERT_TRUE(fullData.get()); | 535 ASSERT_TRUE(fullData.get()); |
537 | 536 |
538 // Empirically chosen truncation size: | 537 // Empirically chosen truncation size: |
539 // a) large enough to produce a partial frame && | 538 // a) large enough to produce a partial frame && |
540 // b) small enough to not fully decode the frame | 539 // b) small enough to not fully decode the frame |
541 const size_t kTruncateSize = 800; | 540 const size_t kTruncateSize = 800; |
542 ASSERT_TRUE(kTruncateSize < fullData->size()); | 541 ASSERT_TRUE(kTruncateSize < fullData->size()); |
543 RefPtr<SharedBuffer> partialData = | 542 RefPtr<SharedBuffer> partialData = |
544 SharedBuffer::create(fullData->data(), kTruncateSize); | 543 SharedBuffer::create(fullData->data(), kTruncateSize); |
545 | 544 |
546 std::unique_ptr<ImageDecoder> premulDecoder = | 545 std::unique_ptr<ImageDecoder> premulDecoder = wrapUnique(new GIFImageDecoder( |
547 wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaPremultiplied, | 546 ImageDecoder::AlphaPremultiplied, ImageDecoder::ColorSpaceApplied, |
548 ImageDecoder::GammaAndColorProfileApplied, | 547 ImageDecoder::noDecodedImageByteLimit)); |
549 ImageDecoder::noDecodedImageByteLimit)); | |
550 std::unique_ptr<ImageDecoder> unpremulDecoder = | 548 std::unique_ptr<ImageDecoder> unpremulDecoder = |
551 wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, | 549 wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, |
552 ImageDecoder::GammaAndColorProfileApplied, | 550 ImageDecoder::ColorSpaceApplied, |
553 ImageDecoder::noDecodedImageByteLimit)); | 551 ImageDecoder::noDecodedImageByteLimit)); |
554 | 552 |
555 // Partially decoded frame => the frame alpha type is unknown and should | 553 // Partially decoded frame => the frame alpha type is unknown and should |
556 // reflect the requested format. | 554 // reflect the requested format. |
557 premulDecoder->setData(partialData.get(), false); | 555 premulDecoder->setData(partialData.get(), false); |
558 ASSERT_TRUE(premulDecoder->frameCount()); | 556 ASSERT_TRUE(premulDecoder->frameCount()); |
559 unpremulDecoder->setData(partialData.get(), false); | 557 unpremulDecoder->setData(partialData.get(), false); |
560 ASSERT_TRUE(unpremulDecoder->frameCount()); | 558 ASSERT_TRUE(unpremulDecoder->frameCount()); |
561 ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0); | 559 ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0); |
562 EXPECT_TRUE(premulFrame && | 560 EXPECT_TRUE(premulFrame && |
(...skipping 13 matching lines...) Expand all Loading... |
576 EXPECT_TRUE(premulFrame && | 574 EXPECT_TRUE(premulFrame && |
577 premulFrame->getStatus() == ImageFrame::FrameComplete); | 575 premulFrame->getStatus() == ImageFrame::FrameComplete); |
578 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); | 576 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); |
579 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); | 577 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); |
580 EXPECT_TRUE(unpremulFrame && | 578 EXPECT_TRUE(unpremulFrame && |
581 unpremulFrame->getStatus() == ImageFrame::FrameComplete); | 579 unpremulFrame->getStatus() == ImageFrame::FrameComplete); |
582 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); | 580 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); |
583 } | 581 } |
584 | 582 |
585 } // namespace blink | 583 } // namespace blink |
OLD | NEW |