OLD | NEW |
---|---|
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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 ColorBehavior::TransformToTargetForTesting()); | 335 ColorBehavior::TransformToTargetForTesting()); |
336 | 336 |
337 SkImageInfo pix_info = SkImageInfo::MakeN32Premul(1, 1); | 337 SkImageInfo pix_info = SkImageInfo::MakeN32Premul(1, 1); |
338 | 338 |
339 size_t row_bytes = pix_info.minRowBytes(); | 339 size_t row_bytes = pix_info.minRowBytes(); |
340 size_t size = pix_info.getSafeSize(row_bytes); | 340 size_t size = pix_info.getSafeSize(row_bytes); |
341 | 341 |
342 Vector<char> storage(size); | 342 Vector<char> storage(size); |
343 SkPixmap pixmap(pix_info, storage.data(), row_bytes); | 343 SkPixmap pixmap(pix_info, storage.data(), row_bytes); |
344 | 344 |
345 // Before decoding, the frame is not known to be opaque. | 345 // Before decoding, the frame's alpha is unknown and assumed to be |
346 // transparent. This works well with partial decoding, which will be | |
347 // transparent until the full first frame is decoded. | |
346 sk_sp<SkImage> frame = decoder->CreateFrameAtIndex(0); | 348 sk_sp<SkImage> frame = decoder->CreateFrameAtIndex(0); |
347 ASSERT_TRUE(frame); | 349 ASSERT_TRUE(frame); |
348 EXPECT_FALSE(frame->isOpaque()); | 350 EXPECT_FALSE(frame->isOpaque()); |
349 | 351 |
350 // Force a lazy decode by reading pixels. | 352 // Force a lazy decode by reading pixels. |
351 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); | 353 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
352 | 354 |
353 // After decoding, the frame is known to be opaque. | 355 // After decoding, the frame is known to be opaque. |
scroggo_chromium
2017/05/08 14:56:36
This line looks to be no longer true.
cblume
2017/05/25 06:52:36
Done.
| |
354 frame = decoder->CreateFrameAtIndex(0); | 356 frame = decoder->CreateFrameAtIndex(0); |
355 ASSERT_TRUE(frame); | 357 ASSERT_TRUE(frame); |
356 EXPECT_TRUE(frame->isOpaque()); | 358 // The GIF file specifies it is opaque. |
359 // Without the file, we remain at the default: transparent | |
scroggo_chromium
2017/05/08 14:56:36
When test_gif is false, it means that data_ is a P
cblume
2017/05/25 06:52:36
Done.
| |
360 EXPECT_EQ(test_gif, frame->isOpaque()); | |
357 | 361 |
358 // Re-generating the opaque-marked frame should not fail. | 362 // Re-generating the opaque-marked frame should not fail. |
359 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); | 363 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
360 } | 364 } |
361 } | 365 } |
362 | 366 |
363 // The DeferredImageDecoder would sometimes assume that a frame was a certain | 367 // The DeferredImageDecoder would sometimes assume that a frame was a certain |
364 // size even if the actual decoder reported it had a size of 0 bytes. This test | 368 // size even if the actual decoder reported it had a size of 0 bytes. This test |
365 // verifies that it's fixed by always checking with the actual decoder when | 369 // verifies that it's fixed by always checking with the actual decoder when |
366 // creating a frame. | 370 // creating a frame. |
(...skipping 16 matching lines...) Expand all Loading... | |
383 SharedBuffer::Create(data_->Data(), data_->size()); | 387 SharedBuffer::Create(data_->Data(), data_->size()); |
384 EXPECT_EQ(original_data->size(), data_->size()); | 388 EXPECT_EQ(original_data->size(), data_->size()); |
385 lazy_decoder_->SetData(original_data, false); | 389 lazy_decoder_->SetData(original_data, false); |
386 RefPtr<SharedBuffer> new_data = lazy_decoder_->Data(); | 390 RefPtr<SharedBuffer> new_data = lazy_decoder_->Data(); |
387 EXPECT_EQ(original_data->size(), new_data->size()); | 391 EXPECT_EQ(original_data->size(), new_data->size()); |
388 EXPECT_EQ(0, std::memcmp(original_data->Data(), new_data->Data(), | 392 EXPECT_EQ(0, std::memcmp(original_data->Data(), new_data->Data(), |
389 new_data->size())); | 393 new_data->size())); |
390 } | 394 } |
391 | 395 |
392 } // namespace blink | 396 } // namespace blink |
OLD | NEW |