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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 | 339 |
340 TEST_F(DeferredImageDecoderTest, frameOpacity) | 340 TEST_F(DeferredImageDecoderTest, frameOpacity) |
341 { | 341 { |
342 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(*m_data, | 342 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(*m_data, |
343 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl
ied); | 343 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl
ied); |
344 OwnPtr<DeferredImageDecoder> decoder = DeferredImageDecoder::createForTestin
g(actualDecoder.release()); | 344 OwnPtr<DeferredImageDecoder> decoder = DeferredImageDecoder::createForTestin
g(actualDecoder.release()); |
345 decoder->setData(*m_data, true); | 345 decoder->setData(*m_data, true); |
346 | 346 |
347 SkImageInfo pixInfo = SkImageInfo::MakeN32Premul(1, 1); | 347 SkImageInfo pixInfo = SkImageInfo::MakeN32Premul(1, 1); |
348 SkAutoPixmapStorage pixels; | 348 |
349 pixels.alloc(pixInfo); | 349 size_t rowBytes = pixInfo.minRowBytes(); |
| 350 size_t size = pixInfo.getSafeSize(rowBytes); |
| 351 |
| 352 SkAutoMalloc storage(size); |
| 353 SkPixmap pixmap(pixInfo, storage.get(), rowBytes); |
350 | 354 |
351 // Before decoding, the frame is not known to be opaque. | 355 // Before decoding, the frame is not known to be opaque. |
352 RefPtr<SkImage> frame = decoder->createFrameAtIndex(0); | 356 RefPtr<SkImage> frame = decoder->createFrameAtIndex(0); |
353 ASSERT_TRUE(frame); | 357 ASSERT_TRUE(frame); |
354 EXPECT_FALSE(frame->isOpaque()); | 358 EXPECT_FALSE(frame->isOpaque()); |
355 | 359 |
356 // Force a lazy decode by reading pixels. | 360 // Force a lazy decode by reading pixels. |
357 EXPECT_TRUE(frame->readPixels(pixels, 0, 0)); | 361 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
358 | 362 |
359 // After decoding, the frame is known to be opaque. | 363 // After decoding, the frame is known to be opaque. |
360 frame = decoder->createFrameAtIndex(0); | 364 frame = decoder->createFrameAtIndex(0); |
361 ASSERT_TRUE(frame); | 365 ASSERT_TRUE(frame); |
362 EXPECT_TRUE(frame->isOpaque()); | 366 EXPECT_TRUE(frame->isOpaque()); |
363 | 367 |
364 // Re-generating the opaque-marked frame should not fail. | 368 // Re-generating the opaque-marked frame should not fail. |
365 EXPECT_TRUE(frame->readPixels(pixels, 0, 0)); | 369 EXPECT_TRUE(frame->readPixels(pixmap, 0, 0)); |
366 } | 370 } |
367 | 371 |
368 } // namespace blink | 372 } // namespace blink |
OLD | NEW |