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

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

Issue 794223003: Cheaper thread-safe atomic initialization of static references. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add type check for initial value Created 5 years, 11 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SkCanvas* canvas; 65 SkCanvas* canvas;
66 SkPicture* picture; 66 SkPicture* picture;
67 }; 67 };
68 68
69 } // namespace 69 } // namespace
70 70
71 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder Client { 71 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder Client {
72 public: 72 public:
73 virtual void SetUp() override 73 virtual void SetUp() override
74 { 74 {
75 ImageDecodingStore::instance()->setCacheLimitInBytes(1024 * 1024); 75 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024);
76 DeferredImageDecoder::setEnabled(true); 76 DeferredImageDecoder::setEnabled(true);
77 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); 77 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG));
78 m_frameCount = 1; 78 m_frameCount = 1;
79 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); 79 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this);
80 m_actualDecoder = decoder.get(); 80 m_actualDecoder = decoder.get();
81 m_actualDecoder->setSize(1, 1); 81 m_actualDecoder->setSize(1, 1);
82 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release() ); 82 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release() );
83 m_surface.reset(SkSurface::NewRasterN32Premul(100, 100)); 83 m_surface.reset(SkSurface::NewRasterN32Premul(100, 100));
84 ASSERT_TRUE(m_surface.get()); 84 ASSERT_TRUE(m_surface.get());
85 m_frameBufferRequestCount = 0; 85 m_frameBufferRequestCount = 0;
86 m_repetitionCount = cAnimationNone; 86 m_repetitionCount = cAnimationNone;
87 m_status = ImageFrame::FrameComplete; 87 m_status = ImageFrame::FrameComplete;
88 m_frameDuration = 0; 88 m_frameDuration = 0;
89 m_decodedSize = m_actualDecoder->size(); 89 m_decodedSize = m_actualDecoder->size();
90 } 90 }
91 91
92 virtual void TearDown() override 92 virtual void TearDown() override
93 { 93 {
94 ImageDecodingStore::instance()->clear(); 94 ImageDecodingStore::instance().clear();
95 } 95 }
96 96
97 virtual void decoderBeingDestroyed() override 97 virtual void decoderBeingDestroyed() override
98 { 98 {
99 m_actualDecoder = 0; 99 m_actualDecoder = 0;
100 } 100 }
101 101
102 virtual void frameBufferRequested() override 102 virtual void frameBufferRequested() override
103 { 103 {
104 ++m_frameBufferRequestCount; 104 ++m_frameBufferRequestCount;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); 337 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount());
338 m_frameCount = 2; 338 m_frameCount = 2;
339 m_lazyDecoder->setData(*m_data, false); 339 m_lazyDecoder->setData(*m_data, false);
340 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); 340 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount());
341 m_frameCount = 0; 341 m_frameCount = 0;
342 m_lazyDecoder->setData(*m_data, true); 342 m_lazyDecoder->setData(*m_data, true);
343 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); 343 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount());
344 } 344 }
345 345
346 } // namespace blink 346 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698