| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 struct Rasterizer { | 63 struct Rasterizer { |
| 64 SkCanvas* canvas; | 64 SkCanvas* canvas; |
| 65 SkPicture* picture; | 65 SkPicture* picture; |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder
Client { | 70 class DeferredImageDecoderTest : public ::testing::Test, public MockImageDecoder
Client { |
| 71 public: | 71 public: |
| 72 virtual void SetUp() OVERRIDE | 72 virtual void SetUp() override |
| 73 { | 73 { |
| 74 ImageDecodingStore::instance()->setCacheLimitInBytes(1024 * 1024); | 74 ImageDecodingStore::instance()->setCacheLimitInBytes(1024 * 1024); |
| 75 DeferredImageDecoder::setEnabled(true); | 75 DeferredImageDecoder::setEnabled(true); |
| 76 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); | 76 m_data = SharedBuffer::create(whitePNG, sizeof(whitePNG)); |
| 77 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); | 77 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(this); |
| 78 m_actualDecoder = decoder.get(); | 78 m_actualDecoder = decoder.get(); |
| 79 m_actualDecoder->setSize(1, 1); | 79 m_actualDecoder->setSize(1, 1); |
| 80 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); | 80 m_lazyDecoder = DeferredImageDecoder::createForTesting(decoder.release()
); |
| 81 m_canvas.reset(SkCanvas::NewRasterN32(100, 100)); | 81 m_canvas.reset(SkCanvas::NewRasterN32(100, 100)); |
| 82 ASSERT_TRUE(m_canvas.get()); | 82 ASSERT_TRUE(m_canvas.get()); |
| 83 m_frameBufferRequestCount = 0; | 83 m_frameBufferRequestCount = 0; |
| 84 m_frameCount = 1; | 84 m_frameCount = 1; |
| 85 m_repetitionCount = cAnimationNone; | 85 m_repetitionCount = cAnimationNone; |
| 86 m_status = ImageFrame::FrameComplete; | 86 m_status = ImageFrame::FrameComplete; |
| 87 m_frameDuration = 0; | 87 m_frameDuration = 0; |
| 88 m_decodedSize = m_actualDecoder->size(); | 88 m_decodedSize = m_actualDecoder->size(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 virtual void TearDown() OVERRIDE | 91 virtual void TearDown() override |
| 92 { | 92 { |
| 93 ImageDecodingStore::instance()->clear(); | 93 ImageDecodingStore::instance()->clear(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void decoderBeingDestroyed() OVERRIDE | 96 virtual void decoderBeingDestroyed() override |
| 97 { | 97 { |
| 98 m_actualDecoder = 0; | 98 m_actualDecoder = 0; |
| 99 } | 99 } |
| 100 | 100 |
| 101 virtual void frameBufferRequested() OVERRIDE | 101 virtual void frameBufferRequested() override |
| 102 { | 102 { |
| 103 ++m_frameBufferRequestCount; | 103 ++m_frameBufferRequestCount; |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual size_t frameCount() OVERRIDE | 106 virtual size_t frameCount() override |
| 107 { | 107 { |
| 108 return m_frameCount; | 108 return m_frameCount; |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual int repetitionCount() const OVERRIDE | 111 virtual int repetitionCount() const override |
| 112 { | 112 { |
| 113 return m_repetitionCount; | 113 return m_repetitionCount; |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual ImageFrame::Status status() OVERRIDE | 116 virtual ImageFrame::Status status() override |
| 117 { | 117 { |
| 118 return m_status; | 118 return m_status; |
| 119 } | 119 } |
| 120 | 120 |
| 121 virtual float frameDuration() const OVERRIDE | 121 virtual float frameDuration() const override |
| 122 { | 122 { |
| 123 return m_frameDuration; | 123 return m_frameDuration; |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual IntSize decodedSize() const OVERRIDE | 126 virtual IntSize decodedSize() const override |
| 127 { | 127 { |
| 128 return m_decodedSize; | 128 return m_decodedSize; |
| 129 } | 129 } |
| 130 | 130 |
| 131 protected: | 131 protected: |
| 132 void useMockImageDecoderFactory() | 132 void useMockImageDecoderFactory() |
| 133 { | 133 { |
| 134 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); | 134 m_lazyDecoder->frameGenerator()->setImageDecoderFactory(MockImageDecoder
Factory::create(this, m_decodedSize)); |
| 135 } | 135 } |
| 136 | 136 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); | 336 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); |
| 337 m_frameCount = 2; | 337 m_frameCount = 2; |
| 338 m_lazyDecoder->setData(*m_data, false); | 338 m_lazyDecoder->setData(*m_data, false); |
| 339 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); | 339 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); |
| 340 m_frameCount = 0; | 340 m_frameCount = 0; |
| 341 m_lazyDecoder->setData(*m_data, true); | 341 m_lazyDecoder->setData(*m_data, true); |
| 342 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); | 342 EXPECT_EQ(m_frameCount, m_lazyDecoder->frameCount()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace blink | 345 } // namespace blink |
| OLD | NEW |