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

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

Issue 1972683002: Early reporting of opaqueness by decoders. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 decoder->setData(data.get(), true); 145 decoder->setData(data.get(), true);
146 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 146 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
147 147
148 // This call will parse the entire file. 148 // This call will parse the entire file.
149 EXPECT_EQ(2u, decoder->frameCount()); 149 EXPECT_EQ(2u, decoder->frameCount());
150 150
151 ImageFrame* frame = decoder->frameBufferAtIndex(0); 151 ImageFrame* frame = decoder->frameBufferAtIndex(0);
152 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 152 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
153 EXPECT_EQ(16, frame->getSkBitmap().width()); 153 EXPECT_EQ(16, frame->getSkBitmap().width());
154 EXPECT_EQ(16, frame->getSkBitmap().height()); 154 EXPECT_EQ(16, frame->getSkBitmap().height());
155 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(0));
156 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(1));
155 157
156 frame = decoder->frameBufferAtIndex(1); 158 frame = decoder->frameBufferAtIndex(1);
157 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus()); 159 EXPECT_EQ(ImageFrame::FrameComplete, frame->getStatus());
158 EXPECT_EQ(16, frame->getSkBitmap().width()); 160 EXPECT_EQ(16, frame->getSkBitmap().width());
159 EXPECT_EQ(16, frame->getSkBitmap().height()); 161 EXPECT_EQ(16, frame->getSkBitmap().height());
160 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 162 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
163 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(0));
164 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(1));
161 } 165 }
162 166
163 TEST(GIFImageDecoderTest, parseByteByByte) 167 TEST(GIFImageDecoderTest, parseByteByByte)
164 { 168 {
165 OwnPtr<ImageDecoder> decoder = createDecoder(); 169 OwnPtr<ImageDecoder> decoder = createDecoder();
166 170
167 RefPtr<SharedBuffer> data = readFile(layoutTestResourcesDir, "animated.gif") ; 171 RefPtr<SharedBuffer> data = readFile(layoutTestResourcesDir, "animated.gif") ;
168 ASSERT_TRUE(data.get()); 172 ASSERT_TRUE(data.get());
169 173
170 size_t frameCount = 0; 174 size_t frameCount = 0;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 ASSERT_TRUE(data.get()); 325 ASSERT_TRUE(data.get());
322 326
323 ASSERT_GE(data->size(), 10u); 327 ASSERT_GE(data->size(), 10u);
324 RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->siz e() - 10); 328 RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->siz e() - 10);
325 decoder->setData(tempData.get(), false); 329 decoder->setData(tempData.get(), false);
326 330
327 EXPECT_EQ(2u, decoder->frameCount()); 331 EXPECT_EQ(2u, decoder->frameCount());
328 EXPECT_FALSE(decoder->failed()); 332 EXPECT_FALSE(decoder->failed());
329 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); 333 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0));
330 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1)); 334 EXPECT_FALSE(decoder->frameIsCompleteAtIndex(1));
335 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(0));
336 EXPECT_TRUE(decoder->frameHasAlphaAtIndex(1));
337 EXPECT_TRUE(decoder->frameHasAlphaAtIndex(2));
331 338
332 decoder->setData(data.get(), true); 339 decoder->setData(data.get(), true);
333 EXPECT_EQ(2u, decoder->frameCount()); 340 EXPECT_EQ(2u, decoder->frameCount());
334 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0)); 341 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(0));
335 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1)); 342 EXPECT_TRUE(decoder->frameIsCompleteAtIndex(1));
343 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(0));
344 EXPECT_FALSE(decoder->frameHasAlphaAtIndex(1));
345 EXPECT_TRUE(decoder->frameHasAlphaAtIndex(2));
336 } 346 }
337 347
338 TEST(GIFImageDecoderTest, badTerminator) 348 TEST(GIFImageDecoderTest, badTerminator)
339 { 349 {
340 RefPtr<SharedBuffer> referenceData = readFile(decodersTestingDir, "radient.g if"); 350 RefPtr<SharedBuffer> referenceData = readFile(decodersTestingDir, "radient.g if");
341 RefPtr<SharedBuffer> testData = readFile(decodersTestingDir, "radient-bad-te rminator.gif"); 351 RefPtr<SharedBuffer> testData = readFile(decodersTestingDir, "radient-bad-te rminator.gif");
342 ASSERT_TRUE(referenceData.get()); 352 ASSERT_TRUE(referenceData.get());
343 ASSERT_TRUE(testData.get()); 353 ASSERT_TRUE(testData.get());
344 354
345 OwnPtr<ImageDecoder> referenceDecoder = createDecoder(); 355 OwnPtr<ImageDecoder> referenceDecoder = createDecoder();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 ASSERT_TRUE(unpremulDecoder->frameCount()); 566 ASSERT_TRUE(unpremulDecoder->frameCount());
557 premulFrame = premulDecoder->frameBufferAtIndex(0); 567 premulFrame = premulDecoder->frameBufferAtIndex(0);
558 EXPECT_TRUE(premulFrame && premulFrame->getStatus() == ImageFrame::FrameComp lete); 568 EXPECT_TRUE(premulFrame && premulFrame->getStatus() == ImageFrame::FrameComp lete);
559 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 569 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
560 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); 570 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0);
561 EXPECT_TRUE(unpremulFrame && unpremulFrame->getStatus() == ImageFrame::Frame Complete); 571 EXPECT_TRUE(unpremulFrame && unpremulFrame->getStatus() == ImageFrame::Frame Complete);
562 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 572 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
563 } 573 }
564 574
565 } // namespace blink 575 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698