| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef MockImageDecoder_h | 26 #ifndef MockImageDecoder_h |
| 27 | 27 |
| 28 #include "platform/image-decoders/ImageDecoder.h" | 28 #include "platform/image-decoders/ImageDecoder.h" |
| 29 #include "wtf/PassOwnPtr.h" | 29 #include "wtf/PtrUtil.h" |
| 30 #include <memory> |
| 30 | 31 |
| 31 namespace blink { | 32 namespace blink { |
| 32 | 33 |
| 33 class MockImageDecoderClient { | 34 class MockImageDecoderClient { |
| 34 public: | 35 public: |
| 35 MockImageDecoderClient() | 36 MockImageDecoderClient() |
| 36 : m_firstFrameForcedToBeEmpty(false) | 37 : m_firstFrameForcedToBeEmpty(false) |
| 37 { | 38 { |
| 38 } | 39 } |
| 39 | 40 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 bool firstFrameForcedToBeEmpty() const { return m_firstFrameForcedToBeEmpty;
} | 61 bool firstFrameForcedToBeEmpty() const { return m_firstFrameForcedToBeEmpty;
} |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 bool m_firstFrameForcedToBeEmpty; | 64 bool m_firstFrameForcedToBeEmpty; |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 class MockImageDecoder : public ImageDecoder { | 67 class MockImageDecoder : public ImageDecoder { |
| 67 public: | 68 public: |
| 68 static PassOwnPtr<MockImageDecoder> create(MockImageDecoderClient* client) {
return adoptPtr(new MockImageDecoder(client)); } | 69 static std::unique_ptr<MockImageDecoder> create(MockImageDecoderClient* clie
nt) { return wrapUnique(new MockImageDecoder(client)); } |
| 69 | 70 |
| 70 MockImageDecoder(MockImageDecoderClient* client) | 71 MockImageDecoder(MockImageDecoderClient* client) |
| 71 : ImageDecoder(AlphaPremultiplied, GammaAndColorProfileApplied, noDecode
dImageByteLimit) | 72 : ImageDecoder(AlphaPremultiplied, GammaAndColorProfileApplied, noDecode
dImageByteLimit) |
| 72 , m_client(client) | 73 , m_client(client) |
| 73 { } | 74 { } |
| 74 | 75 |
| 75 ~MockImageDecoder() | 76 ~MockImageDecoder() |
| 76 { | 77 { |
| 77 m_client->decoderBeingDestroyed(); | 78 m_client->decoderBeingDestroyed(); |
| 78 } | 79 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 { | 131 { |
| 131 m_frameBufferCache[index].setSize(size().width(), size().height()); | 132 m_frameBufferCache[index].setSize(size().width(), size().height()); |
| 132 m_frameBufferCache[index].setHasAlpha(false); | 133 m_frameBufferCache[index].setHasAlpha(false); |
| 133 } | 134 } |
| 134 | 135 |
| 135 MockImageDecoderClient* m_client; | 136 MockImageDecoderClient* m_client; |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 class MockImageDecoderFactory : public ImageDecoderFactory { | 139 class MockImageDecoderFactory : public ImageDecoderFactory { |
| 139 public: | 140 public: |
| 140 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) | 141 static std::unique_ptr<MockImageDecoderFactory> create(MockImageDecoderClien
t* client, const SkISize& decodedSize) |
| 141 { | 142 { |
| 142 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); | 143 return wrapUnique(new MockImageDecoderFactory(client, IntSize(decodedSiz
e.width(), decodedSize.height()))); |
| 143 } | 144 } |
| 144 | 145 |
| 145 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const IntSize& decodedSize) | 146 static std::unique_ptr<MockImageDecoderFactory> create(MockImageDecoderClien
t* client, const IntSize& decodedSize) |
| 146 { | 147 { |
| 147 return adoptPtr(new MockImageDecoderFactory(client, decodedSize)); | 148 return wrapUnique(new MockImageDecoderFactory(client, decodedSize)); |
| 148 } | 149 } |
| 149 | 150 |
| 150 PassOwnPtr<ImageDecoder> create() override | 151 std::unique_ptr<ImageDecoder> create() override |
| 151 { | 152 { |
| 152 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_client); | 153 std::unique_ptr<MockImageDecoder> decoder = MockImageDecoder::create(m_c
lient); |
| 153 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); | 154 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); |
| 154 return std::move(decoder); | 155 return std::move(decoder); |
| 155 } | 156 } |
| 156 | 157 |
| 157 private: | 158 private: |
| 158 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod
edSize) | 159 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod
edSize) |
| 159 : m_client(client) | 160 : m_client(client) |
| 160 , m_decodedSize(decodedSize) | 161 , m_decodedSize(decodedSize) |
| 161 { | 162 { |
| 162 } | 163 } |
| 163 | 164 |
| 164 MockImageDecoderClient* m_client; | 165 MockImageDecoderClient* m_client; |
| 165 IntSize m_decodedSize; | 166 IntSize m_decodedSize; |
| 166 }; | 167 }; |
| 167 | 168 |
| 168 } // namespace blink | 169 } // namespace blink |
| 169 | 170 |
| 170 #endif // MockImageDecoder_h | 171 #endif // MockImageDecoder_h |
| OLD | NEW |