| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 MockImageDecoder(MockImageDecoderClient* client) | 54 MockImageDecoder(MockImageDecoderClient* client) |
| 55 : ImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndCol
orProfileApplied, noDecodedImageByteLimit) | 55 : ImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndCol
orProfileApplied, noDecodedImageByteLimit) |
| 56 , m_client(client) | 56 , m_client(client) |
| 57 { } | 57 { } |
| 58 | 58 |
| 59 ~MockImageDecoder() | 59 ~MockImageDecoder() |
| 60 { | 60 { |
| 61 m_client->decoderBeingDestroyed(); | 61 m_client->decoderBeingDestroyed(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual IntSize decodedSize() const OVERRIDE | 64 virtual IntSize decodedSize() const override |
| 65 { | 65 { |
| 66 return m_client->decodedSize().isEmpty() ? size() : m_client->decodedSiz
e(); | 66 return m_client->decodedSize().isEmpty() ? size() : m_client->decodedSiz
e(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual bool setSize(unsigned width, unsigned height) OVERRIDE | 69 virtual bool setSize(unsigned width, unsigned height) override |
| 70 { | 70 { |
| 71 ImageDecoder::setSize(width, height); | 71 ImageDecoder::setSize(width, height); |
| 72 m_frameBufferCache.resize(1); | 72 m_frameBufferCache.resize(1); |
| 73 m_frameBufferCache[0].setSize(width, height); | 73 m_frameBufferCache[0].setSize(width, height); |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual String filenameExtension() const OVERRIDE | 77 virtual String filenameExtension() const override |
| 78 { | 78 { |
| 79 return "mock"; | 79 return "mock"; |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual size_t frameCount() OVERRIDE | 82 virtual size_t frameCount() override |
| 83 { | 83 { |
| 84 return m_client->frameCount(); | 84 return m_client->frameCount(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual int repetitionCount() const OVERRIDE | 87 virtual int repetitionCount() const override |
| 88 { | 88 { |
| 89 return m_client->repetitionCount(); | 89 return m_client->repetitionCount(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual ImageFrame* frameBufferAtIndex(size_t) OVERRIDE | 92 virtual ImageFrame* frameBufferAtIndex(size_t) override |
| 93 { | 93 { |
| 94 m_client->frameBufferRequested(); | 94 m_client->frameBufferRequested(); |
| 95 | 95 |
| 96 m_frameBufferCache[0].setStatus(m_client->status()); | 96 m_frameBufferCache[0].setStatus(m_client->status()); |
| 97 return &m_frameBufferCache[0]; | 97 return &m_frameBufferCache[0]; |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual bool frameIsCompleteAtIndex(size_t) const OVERRIDE | 100 virtual bool frameIsCompleteAtIndex(size_t) const override |
| 101 { | 101 { |
| 102 return m_client->status() == ImageFrame::FrameComplete; | 102 return m_client->status() == ImageFrame::FrameComplete; |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual float frameDurationAtIndex(size_t) const OVERRIDE | 105 virtual float frameDurationAtIndex(size_t) const override |
| 106 { | 106 { |
| 107 return m_client->frameDuration(); | 107 return m_client->frameDuration(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void setFrameHasAlpha(bool hasAlpha) { m_frameBufferCache[0].setHasAlpha(has
Alpha); } | 110 void setFrameHasAlpha(bool hasAlpha) { m_frameBufferCache[0].setHasAlpha(has
Alpha); } |
| 111 | 111 |
| 112 private: | 112 private: |
| 113 MockImageDecoderClient* m_client; | 113 MockImageDecoderClient* m_client; |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 class MockImageDecoderFactory : public ImageDecoderFactory { | 116 class MockImageDecoderFactory : public ImageDecoderFactory { |
| 117 public: | 117 public: |
| 118 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) | 118 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) |
| 119 { | 119 { |
| 120 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); | 120 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); |
| 121 } | 121 } |
| 122 | 122 |
| 123 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const IntSize& decodedSize) | 123 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const IntSize& decodedSize) |
| 124 { | 124 { |
| 125 return adoptPtr(new MockImageDecoderFactory(client, decodedSize)); | 125 return adoptPtr(new MockImageDecoderFactory(client, decodedSize)); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual PassOwnPtr<ImageDecoder> create() OVERRIDE | 128 virtual PassOwnPtr<ImageDecoder> create() override |
| 129 { | 129 { |
| 130 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_client); | 130 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_client); |
| 131 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); | 131 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); |
| 132 decoder->setFrameHasAlpha(false); | 132 decoder->setFrameHasAlpha(false); |
| 133 return decoder.release(); | 133 return decoder.release(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod
edSize) | 137 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod
edSize) |
| 138 : m_client(client) | 138 : m_client(client) |
| 139 , m_decodedSize(decodedSize) | 139 , m_decodedSize(decodedSize) |
| 140 { | 140 { |
| 141 } | 141 } |
| 142 | 142 |
| 143 MockImageDecoderClient* m_client; | 143 MockImageDecoderClient* m_client; |
| 144 IntSize m_decodedSize; | 144 IntSize m_decodedSize; |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 } // namespace blink | 147 } // namespace blink |
| 148 | 148 |
| 149 #endif // MockImageDecoder_h | 149 #endif // MockImageDecoder_h |
| OLD | NEW |