| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 SkPictureRecorder recorder; | 240 SkPictureRecorder recorder; |
| 241 SkCanvas* tempCanvas = recorder.beginRecording(100, 100, 0, 0); | 241 SkCanvas* tempCanvas = recorder.beginRecording(100, 100, 0, 0); |
| 242 tempCanvas->drawImage(image.get(), 0, 0); | 242 tempCanvas->drawImage(image.get(), 0, 0); |
| 243 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); | 243 sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture(); |
| 244 EXPECT_EQ(0, m_decodeRequestCount); | 244 EXPECT_EQ(0, m_decodeRequestCount); |
| 245 | 245 |
| 246 // Create a thread to rasterize SkPicture. | 246 // Create a thread to rasterize SkPicture. |
| 247 OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThread("Raste
rThread")); | 247 OwnPtr<WebThread> thread = adoptPtr(Platform::current()->createThread("Raste
rThread")); |
| 248 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&raster
izeMain, AllowCrossThreadAccess(m_surface->getCanvas()), AllowCrossThreadAccess(
picture.get()))); | 248 thread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, threadSafeBind(&raster
izeMain, AllowCrossThreadAccess(m_surface->getCanvas()), AllowCrossThreadAccess(
picture.get()))); |
| 249 thread.clear(); | 249 thread.reset(); |
| 250 EXPECT_EQ(0, m_decodeRequestCount); | 250 EXPECT_EQ(0, m_decodeRequestCount); |
| 251 | 251 |
| 252 SkBitmap canvasBitmap; | 252 SkBitmap canvasBitmap; |
| 253 canvasBitmap.allocN32Pixels(100, 100); | 253 canvasBitmap.allocN32Pixels(100, 100); |
| 254 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); | 254 ASSERT_TRUE(m_surface->getCanvas()->readPixels(&canvasBitmap, 0, 0)); |
| 255 SkAutoLockPixels autoLock(canvasBitmap); | 255 SkAutoLockPixels autoLock(canvasBitmap); |
| 256 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); | 256 EXPECT_EQ(SkColorSetARGB(255, 255, 255, 255), canvasBitmap.getColor(0, 0)); |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) | 259 TEST_F(DeferredImageDecoderTest, singleFrameImageLoading) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 m_lazyDecoder->createFrameAtIndex(0); | 402 m_lazyDecoder->createFrameAtIndex(0); |
| 403 m_lazyDecoder->createFrameAtIndex(1); | 403 m_lazyDecoder->createFrameAtIndex(1); |
| 404 m_lazyDecoder->setData(*m_data, true); | 404 m_lazyDecoder->setData(*m_data, true); |
| 405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't | 405 // Clears only the first frame (0 bytes). If DeferredImageDecoder doesn't |
| 406 // check with the actual decoder it reports 4 bytes instead. | 406 // check with the actual decoder it reports 4 bytes instead. |
| 407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); | 407 size_t frameBytesCleared = m_lazyDecoder->clearCacheExceptFrame(1); |
| 408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); | 408 EXPECT_EQ(static_cast<size_t>(0), frameBytesCleared); |
| 409 } | 409 } |
| 410 | 410 |
| 411 } // namespace blink | 411 } // namespace blink |
| OLD | NEW |