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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 ColorBehavior::TransformToTargetForTesting()); | 339 ColorBehavior::TransformToTargetForTesting()); |
340 | 340 |
341 SkImageInfo pix_info = SkImageInfo::MakeN32Premul(1, 1); | 341 SkImageInfo pix_info = SkImageInfo::MakeN32Premul(1, 1); |
342 | 342 |
343 size_t row_bytes = pix_info.minRowBytes(); | 343 size_t row_bytes = pix_info.minRowBytes(); |
344 size_t size = pix_info.getSafeSize(row_bytes); | 344 size_t size = pix_info.getSafeSize(row_bytes); |
345 | 345 |
346 Vector<char> storage(size); | 346 Vector<char> storage(size); |
347 SkPixmap pixmap(pix_info, storage.data(), row_bytes); | 347 SkPixmap pixmap(pix_info, storage.data(), row_bytes); |
348 | 348 |
349 // Before decoding, the frame is not known to be opaque. | 349 // Before decoding, the frame's alpha is unknown and assumed to be |
350 // transparent. This works well with partial decoding, which will be | |
351 // transparent until the full first frame is decoded. | |
350 sk_sp<SkImage> frame = decoder->CreateFrameAtIndex(0); | 352 sk_sp<SkImage> frame = decoder->CreateFrameAtIndex(0); |
351 ASSERT_TRUE(frame); | 353 ASSERT_TRUE(frame); |
352 EXPECT_FALSE(frame->isOpaque()); | 354 EXPECT_FALSE(frame->isOpaque()); |
353 | 355 |
354 // Force a lazy decode by reading pixels. | 356 // Force a lazy decode by reading pixels. |
355 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); | 357 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
356 | 358 |
357 // After decoding, the frame is known to be opaque. | |
358 frame = decoder->CreateFrameAtIndex(0); | 359 frame = decoder->CreateFrameAtIndex(0); |
359 ASSERT_TRUE(frame); | 360 ASSERT_TRUE(frame); |
360 EXPECT_TRUE(frame->isOpaque()); | 361 // The GIF file used by this test is opaque. |
362 // The PNG file used by this test (when test_gif is false) is transparent. | |
scroggo_chromium
2017/05/31 14:27:50
The PNG file is actually an opaque white 1x1 image
cblume
2017/05/31 18:09:04
Ooooh THAT is what you were saying.
Okay, I'll upd
| |
363 EXPECT_EQ(test_gif, frame->isOpaque()); | |
361 | 364 |
362 // Re-generating the opaque-marked frame should not fail. | 365 // Re-generating the opaque-marked frame should not fail. |
363 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); | 366 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
364 } | 367 } |
365 } | 368 } |
366 | 369 |
367 // The DeferredImageDecoder would sometimes assume that a frame was a certain | 370 // The DeferredImageDecoder would sometimes assume that a frame was a certain |
368 // size even if the actual decoder reported it had a size of 0 bytes. This test | 371 // size even if the actual decoder reported it had a size of 0 bytes. This test |
369 // verifies that it's fixed by always checking with the actual decoder when | 372 // verifies that it's fixed by always checking with the actual decoder when |
370 // creating a frame. | 373 // creating a frame. |
(...skipping 16 matching lines...) Expand all Loading... | |
387 SharedBuffer::Create(data_->Data(), data_->size()); | 390 SharedBuffer::Create(data_->Data(), data_->size()); |
388 EXPECT_EQ(original_data->size(), data_->size()); | 391 EXPECT_EQ(original_data->size(), data_->size()); |
389 lazy_decoder_->SetData(original_data, false); | 392 lazy_decoder_->SetData(original_data, false); |
390 RefPtr<SharedBuffer> new_data = lazy_decoder_->Data(); | 393 RefPtr<SharedBuffer> new_data = lazy_decoder_->Data(); |
391 EXPECT_EQ(original_data->size(), new_data->size()); | 394 EXPECT_EQ(original_data->size(), new_data->size()); |
392 EXPECT_EQ(0, std::memcmp(original_data->Data(), new_data->Data(), | 395 EXPECT_EQ(0, std::memcmp(original_data->Data(), new_data->Data(), |
393 new_data->size())); | 396 new_data->size())); |
394 } | 397 } |
395 | 398 |
396 } // namespace blink | 399 } // namespace blink |
OLD | NEW |