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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Issue 2565323003: Move gif image decoder to SkCodec (Closed)
Patch Set: Fixing the alpha, not changing frame between init and decode. Created 3 years, 11 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
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 } // anonymous namespace 74 } // anonymous namespace
75 75
76 TEST(GIFImageDecoderTest, decodeTwoFrames) { 76 TEST(GIFImageDecoderTest, decodeTwoFrames) {
77 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 77 std::unique_ptr<ImageDecoder> decoder = createDecoder();
78 78
79 RefPtr<SharedBuffer> data = readFile(layoutTestResourcesDir, "animated.gif"); 79 RefPtr<SharedBuffer> data = readFile(layoutTestResourcesDir, "animated.gif");
80 ASSERT_TRUE(data.get()); 80 ASSERT_TRUE(data.get());
81 decoder->setData(data.get(), true); 81 decoder->setData(data.get(), true);
82 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
cblume 2017/01/09 04:11:22 This test *used* to assert that we hadn't yet seen
83 82
84 ImageFrame* frame = decoder->frameBufferAtIndex(0); 83 ImageFrame* frame = decoder->frameBufferAtIndex(0);
85 uint32_t generationID0 = frame->bitmap().getGenerationID(); 84 uint32_t generationID0 = frame->bitmap().getGenerationID();
86 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 85 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
87 EXPECT_EQ(16, frame->bitmap().width()); 86 EXPECT_EQ(16, frame->bitmap().width());
88 EXPECT_EQ(16, frame->bitmap().height()); 87 EXPECT_EQ(16, frame->bitmap().height());
89 88
90 frame = decoder->frameBufferAtIndex(1); 89 frame = decoder->frameBufferAtIndex(1);
91 uint32_t generationID1 = frame->bitmap().getGenerationID(); 90 uint32_t generationID1 = frame->bitmap().getGenerationID();
92 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 91 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ASSERT_TRUE(data.get()); 315 ASSERT_TRUE(data.get());
317 decoder->setData(data.get(), true); 316 decoder->setData(data.get(), true);
318 317
319 EXPECT_EQ(2u, decoder->frameCount()); 318 EXPECT_EQ(2u, decoder->frameCount());
320 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious. 319 // Disposal method 4 is converted to ImageFrame::DisposeOverwritePrevious.
321 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious, 320 EXPECT_EQ(ImageFrame::DisposeOverwritePrevious,
322 decoder->frameBufferAtIndex(0)->getDisposalMethod()); 321 decoder->frameBufferAtIndex(0)->getDisposalMethod());
323 // Disposal method 5 is ignored. 322 // Disposal method 5 is ignored.
324 EXPECT_EQ(ImageFrame::DisposeNotSpecified, 323 EXPECT_EQ(ImageFrame::DisposeNotSpecified,
325 decoder->frameBufferAtIndex(1)->getDisposalMethod()); 324 decoder->frameBufferAtIndex(1)->getDisposalMethod());
326 } 325 }
cblume 2017/01/09 08:06:48 SkGifCodec is the one that is now responsible for
cblume 2017/01/30 07:35:48 I spoke with Leon and we agreed that this is reall
327 326
328 TEST(GIFImageDecoderTest, firstFrameHasGreaterSizeThanScreenSize) { 327 TEST(GIFImageDecoderTest, firstFrameHasGreaterSizeThanScreenSize) {
329 RefPtr<SharedBuffer> fullData = readFile( 328 RefPtr<SharedBuffer> fullData = readFile(
330 decodersTestingDir, "first-frame-has-greater-size-than-screen-size.gif"); 329 decodersTestingDir, "first-frame-has-greater-size-than-screen-size.gif");
331 ASSERT_TRUE(fullData.get()); 330 ASSERT_TRUE(fullData.get());
332 331
333 std::unique_ptr<ImageDecoder> decoder; 332 std::unique_ptr<ImageDecoder> decoder;
334 IntSize frameSize; 333 IntSize frameSize;
335 334
336 // Compute hashes when the file is truncated. 335 // Compute hashes when the file is truncated.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 EXPECT_TRUE(premulFrame && 399 EXPECT_TRUE(premulFrame &&
401 premulFrame->getStatus() == ImageFrame::FrameComplete); 400 premulFrame->getStatus() == ImageFrame::FrameComplete);
402 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 401 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
403 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); 402 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0);
404 EXPECT_TRUE(unpremulFrame && 403 EXPECT_TRUE(unpremulFrame &&
405 unpremulFrame->getStatus() == ImageFrame::FrameComplete); 404 unpremulFrame->getStatus() == ImageFrame::FrameComplete);
406 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 405 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
407 } 406 }
408 407
409 } // namespace blink 408 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698