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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoderTest.cpp

Issue 2756463003: Remove opaque alpha channel special case (Closed)
Patch Set: Fix gif detecting if a frame claims to have transparency 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 ColorBehavior::transformToTargetForTesting()); 346 ColorBehavior::transformToTargetForTesting());
347 347
348 SkImageInfo pixInfo = SkImageInfo::MakeN32Premul(1, 1); 348 SkImageInfo pixInfo = SkImageInfo::MakeN32Premul(1, 1);
349 349
350 size_t rowBytes = pixInfo.minRowBytes(); 350 size_t rowBytes = pixInfo.minRowBytes();
351 size_t size = pixInfo.getSafeSize(rowBytes); 351 size_t size = pixInfo.getSafeSize(rowBytes);
352 352
353 Vector<char> storage(size); 353 Vector<char> storage(size);
354 SkPixmap pixmap(pixInfo, storage.data(), rowBytes); 354 SkPixmap pixmap(pixInfo, storage.data(), rowBytes);
355 355
356 // Before decoding, the frame is not known to be opaque. 356 // Before decoding, the frame's alpha is unknown and assumed to be
357 // transparent. This works well with partial decoding, which will be
358 // transparent until the full first frame is decoded.
357 sk_sp<SkImage> frame = decoder->createFrameAtIndex(0); 359 sk_sp<SkImage> frame = decoder->createFrameAtIndex(0);
358 ASSERT_TRUE(frame); 360 ASSERT_TRUE(frame);
359 EXPECT_FALSE(frame->isOpaque()); 361 EXPECT_FALSE(frame->isOpaque());
360 362
361 // Force a lazy decode by reading pixels. 363 // Force a lazy decode by reading pixels.
362 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); 364 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0));
363 365
364 // After decoding, the frame is known to be opaque. 366 // After decoding, the frame is known to be opaque.
365 frame = decoder->createFrameAtIndex(0); 367 frame = decoder->createFrameAtIndex(0);
366 ASSERT_TRUE(frame); 368 ASSERT_TRUE(frame);
367 EXPECT_TRUE(frame->isOpaque()); 369 // The GIF file specifies it is opaque.
370 // Without the file, we remain at the default: transparent
371 EXPECT_EQ(testGIF, frame->isOpaque());
368 372
369 // Re-generating the opaque-marked frame should not fail. 373 // Re-generating the opaque-marked frame should not fail.
370 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); 374 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0));
371 } 375 }
372 } 376 }
373 377
374 // The DeferredImageDecoder would sometimes assume that a frame was a certain 378 // The DeferredImageDecoder would sometimes assume that a frame was a certain
375 // size even if the actual decoder reported it had a size of 0 bytes. This test 379 // size even if the actual decoder reported it had a size of 0 bytes. This test
376 // verifies that it's fixed by always checking with the actual decoder when 380 // verifies that it's fixed by always checking with the actual decoder when
377 // creating a frame. 381 // creating a frame.
(...skipping 16 matching lines...) Expand all
394 SharedBuffer::create(m_data->data(), m_data->size()); 398 SharedBuffer::create(m_data->data(), m_data->size());
395 EXPECT_EQ(originalData->size(), m_data->size()); 399 EXPECT_EQ(originalData->size(), m_data->size());
396 m_lazyDecoder->setData(originalData, false); 400 m_lazyDecoder->setData(originalData, false);
397 RefPtr<SharedBuffer> newData = m_lazyDecoder->data(); 401 RefPtr<SharedBuffer> newData = m_lazyDecoder->data();
398 EXPECT_EQ(originalData->size(), newData->size()); 402 EXPECT_EQ(originalData->size(), newData->size());
399 EXPECT_EQ( 403 EXPECT_EQ(
400 0, std::memcmp(originalData->data(), newData->data(), newData->size())); 404 0, std::memcmp(originalData->data(), newData->data(), newData->size()));
401 } 405 }
402 406
403 } // namespace blink 407 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698