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

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

Issue 2556723003: Merge color options into ColorBehavior (Closed)
Patch Set: Feedback Created 4 years 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 28 matching lines...) Expand all
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( 49 return wrapUnique(
50 ImageDecoder::AlphaNotPremultiplied, ImageDecoder::ColorSpaceTransformed, 50 new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied,
51 ImageDecoder::targetColorSpaceForTesting(), 51 ColorBehavior::transformToTargetForTesting(),
52 ImageDecoder::noDecodedImageByteLimit)); 52 ImageDecoder::noDecodedImageByteLimit));
53 } 53 }
54 54
55 void testRepetitionCount(const char* dir, 55 void testRepetitionCount(const char* dir,
56 const char* file, 56 const char* file,
57 int expectedRepetitionCount) { 57 int expectedRepetitionCount) {
58 std::unique_ptr<ImageDecoder> decoder = createDecoder(); 58 std::unique_ptr<ImageDecoder> decoder = createDecoder();
59 RefPtr<SharedBuffer> data = readFile(dir, file); 59 RefPtr<SharedBuffer> data = readFile(dir, file);
60 ASSERT_TRUE(data.get()); 60 ASSERT_TRUE(data.get());
61 decoder->setData(data.get(), true); 61 decoder->setData(data.get(), true);
62 EXPECT_EQ(cAnimationLoopOnce, 62 EXPECT_EQ(cAnimationLoopOnce,
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 ASSERT_TRUE(fullData.get()); 360 ASSERT_TRUE(fullData.get());
361 361
362 // Empirically chosen truncation size: 362 // Empirically chosen truncation size:
363 // a) large enough to produce a partial frame && 363 // a) large enough to produce a partial frame &&
364 // b) small enough to not fully decode the frame 364 // b) small enough to not fully decode the frame
365 const size_t kTruncateSize = 800; 365 const size_t kTruncateSize = 800;
366 ASSERT_TRUE(kTruncateSize < fullData->size()); 366 ASSERT_TRUE(kTruncateSize < fullData->size());
367 RefPtr<SharedBuffer> partialData = 367 RefPtr<SharedBuffer> partialData =
368 SharedBuffer::create(fullData->data(), kTruncateSize); 368 SharedBuffer::create(fullData->data(), kTruncateSize);
369 369
370 std::unique_ptr<ImageDecoder> premulDecoder = wrapUnique(new GIFImageDecoder( 370 std::unique_ptr<ImageDecoder> premulDecoder = wrapUnique(
371 ImageDecoder::AlphaPremultiplied, ImageDecoder::ColorSpaceTransformed, 371 new GIFImageDecoder(ImageDecoder::AlphaPremultiplied,
372 ImageDecoder::targetColorSpaceForTesting(), 372 ColorBehavior::transformToTargetForTesting(),
373 ImageDecoder::noDecodedImageByteLimit)); 373 ImageDecoder::noDecodedImageByteLimit));
374 std::unique_ptr<ImageDecoder> unpremulDecoder = 374 std::unique_ptr<ImageDecoder> unpremulDecoder = wrapUnique(
375 wrapUnique(new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied, 375 new GIFImageDecoder(ImageDecoder::AlphaNotPremultiplied,
376 ImageDecoder::ColorSpaceTransformed, 376 ColorBehavior::transformToTargetForTesting(),
377 ImageDecoder::targetColorSpaceForTesting(), 377 ImageDecoder::noDecodedImageByteLimit));
378 ImageDecoder::noDecodedImageByteLimit));
379 378
380 // Partially decoded frame => the frame alpha type is unknown and should 379 // Partially decoded frame => the frame alpha type is unknown and should
381 // reflect the requested format. 380 // reflect the requested format.
382 premulDecoder->setData(partialData.get(), false); 381 premulDecoder->setData(partialData.get(), false);
383 ASSERT_TRUE(premulDecoder->frameCount()); 382 ASSERT_TRUE(premulDecoder->frameCount());
384 unpremulDecoder->setData(partialData.get(), false); 383 unpremulDecoder->setData(partialData.get(), false);
385 ASSERT_TRUE(unpremulDecoder->frameCount()); 384 ASSERT_TRUE(unpremulDecoder->frameCount());
386 ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0); 385 ImageFrame* premulFrame = premulDecoder->frameBufferAtIndex(0);
387 EXPECT_TRUE(premulFrame && 386 EXPECT_TRUE(premulFrame &&
388 premulFrame->getStatus() != ImageFrame::FrameComplete); 387 premulFrame->getStatus() != ImageFrame::FrameComplete);
(...skipping 12 matching lines...) Expand all
401 EXPECT_TRUE(premulFrame && 400 EXPECT_TRUE(premulFrame &&
402 premulFrame->getStatus() == ImageFrame::FrameComplete); 401 premulFrame->getStatus() == ImageFrame::FrameComplete);
403 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 402 EXPECT_EQ(premulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
404 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0); 403 unpremulFrame = unpremulDecoder->frameBufferAtIndex(0);
405 EXPECT_TRUE(unpremulFrame && 404 EXPECT_TRUE(unpremulFrame &&
406 unpremulFrame->getStatus() == ImageFrame::FrameComplete); 405 unpremulFrame->getStatus() == ImageFrame::FrameComplete);
407 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType); 406 EXPECT_EQ(unpremulFrame->bitmap().alphaType(), kOpaque_SkAlphaType);
408 } 407 }
409 408
410 } // namespace blink 409 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698