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

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

Issue 1981823002: Remove OwnPtr::release() calls in platform/ (part 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 public: 96 public:
97 void SetUp() override 97 void SetUp() override
98 { 98 {
99 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); 99 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024);
100 DeferredImageDecoder::setEnabled(true); 100 DeferredImageDecoder::setEnabled(true);
101 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); 101 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG));
102 m_frameCount = 1; 102 m_frameCount = 1;
103 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); 103 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this);
104 m_actualDecoder = decoder.get(); 104 m_actualDecoder = decoder.get();
105 m_actualDecoder->setSize(1, 1); 105 m_actualDecoder->setSize(1, 1);
106 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release() ); 106 m_lazyDecoder = DeferredImageDecoder::createForTesting(std::move(decoder ));
107 m_surface = SkSurface::MakeRasterN32Premul(100, 100); 107 m_surface = SkSurface::MakeRasterN32Premul(100, 100);
108 ASSERT_TRUE(m_surface.get()); 108 ASSERT_TRUE(m_surface.get());
109 m_decodeRequestCount = 0; 109 m_decodeRequestCount = 0;
110 m_repetitionCount = cAnimationNone; 110 m_repetitionCount = cAnimationNone;
111 m_status = ImageFrame::FrameComplete; 111 m_status = ImageFrame::FrameComplete;
112 m_frameDuration = 0; 112 m_frameDuration = 0;
113 m_decodedSize = m_actualDecoder->size(); 113 m_decodedSize = m_actualDecoder->size();
114 } 114 }
115 115
116 void TearDown() override 116 void TearDown() override
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); 354 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount());
355 m_frameCount = 0; 355 m_frameCount = 0;
356 m_lazyDecoder->setData(*m_data, true); 356 m_lazyDecoder->setData(*m_data, true);
357 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); 357 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount());
358 } 358 }
359 359
360 TEST_F(DeferredImageDecoderTest, frameOpacity) 360 TEST_F(DeferredImageDecoderTest, frameOpacity)
361 { 361 {
362 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(*m_data, 362 OwnPtr<ImageDecoder> actualDecoder = ImageDecoder::create(*m_data,
363 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied); 363 ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileAppl ied);
364 OwnPtr<DeferredImageDecoder> decoder = DeferredImageDecoder::createForTestin g(actualDecoder.release()); 364 OwnPtr<DeferredImageDecoder> decoder = DeferredImageDecoder::createForTestin g(std::move(actualDecoder));
365 decoder->setData(*m_data, true); 365 decoder->setData(*m_data, true);
366 366
367 SkImageInfo pixInfo = SkImageInfo::MakeN32Premul(1, 1); 367 SkImageInfo pixInfo = SkImageInfo::MakeN32Premul(1, 1);
368 368
369 size_t rowBytes = pixInfo.minRowBytes(); 369 size_t rowBytes = pixInfo.minRowBytes();
370 size_t size = pixInfo.getSafeSize(rowBytes); 370 size_t size = pixInfo.getSafeSize(rowBytes);
371 371
372 SkAutoMalloc storage(size); 372 SkAutoMalloc storage(size);
373 SkPixmap pixmap(pixInfo, storage.get(), rowBytes); 373 SkPixmap pixmap(pixInfo, storage.get(), rowBytes);
374 374
(...skipping 27 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698