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

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

Issue 2618633004: Add support for Animated PNG (Closed)
Patch Set: Fix LayoutTest due to accept header change Created 3 years, 9 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 premulFrame = premulDecoder->frameBufferAtIndex(0); 399 premulFrame = premulDecoder->frameBufferAtIndex(0);
400 EXPECT_TRUE(premulFrame && 400 EXPECT_TRUE(premulFrame &&
401 premulFrame->getStatus() == ImageFrame::FrameComplete); 401 premulFrame->getStatus() == ImageFrame::FrameComplete);
402 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 402 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
403 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); 403 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0);
404 EXPECT_TRUE(unpremulFrame && 404 EXPECT_TRUE(unpremulFrame &&
405 unpremulFrame->getStatus() == ImageFrame::FrameComplete); 405 unpremulFrame->getStatus() == ImageFrame::FrameComplete);
406 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 406 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
407 } 407 }
408 408
409 namespace {
410 // Needed to exercise ImageDecoder::setMemoryAllocator, but still does the
411 // default allocation.
412 class Allocator final : public SkBitmap::Allocator {
413 bool allocPixelRef(SkBitmap* dst, SkColorTable* ctable) override {
414 return dst->tryAllocPixels(ctable);
415 }
416 };
417 }
418
419 // Ensure that calling setMemoryAllocator does not short-circuit
420 // initializeNewFrame.
421 TEST(GIFImageDecoderTest, externalAllocator) {
422 auto data = readFile(layoutTestResourcesDir, "boston.gif");
423 ASSERT_TRUE(data.get());
424
425 auto decoder = createDecoder();
426 decoder->setData(data.get(), true);
427
428 Allocator allocator;
429 decoder->setMemoryAllocator(&allocator);
430 EXPECT_EQ(1u, decoder->frameCount());
431 ImageFrame* frame = decoder->frameBufferAtIndex(0);
432 decoder->setMemoryAllocator(nullptr);
433
434 ASSERT_TRUE(frame);
435 EXPECT_EQ(IntRect(IntPoint(), decoder->size()), frame->originalFrameRect());
436 EXPECT_FALSE(frame->hasAlpha());
437 }
438
409 } // namespace blink 439 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698