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 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 String filenameExtension() const override | 69 String filenameExtension() const override |
70 { | 70 { |
71 return "mock"; | 71 return "mock"; |
72 } | 72 } |
73 | 73 |
74 virtual int repetitionCount() const override | 74 int repetitionCount() const override |
75 { | 75 { |
76 return m_client->repetitionCount(); | 76 return m_client->repetitionCount(); |
77 } | 77 } |
78 | 78 |
79 virtual bool frameIsCompleteAtIndex(size_t) const override | 79 bool frameIsCompleteAtIndex(size_t) const override |
80 { | 80 { |
81 return m_client->status() == ImageFrame::FrameComplete; | 81 return m_client->status() == ImageFrame::FrameComplete; |
82 } | 82 } |
83 | 83 |
84 virtual float frameDurationAtIndex(size_t) const override | 84 float frameDurationAtIndex(size_t) const override |
85 { | 85 { |
86 return m_client->frameDuration(); | 86 return m_client->frameDuration(); |
87 } | 87 } |
88 | 88 |
89 virtual size_t clearCacheExceptFrame(size_t) override { return 0; } | 89 size_t clearCacheExceptFrame(size_t) override { return 0; } |
90 | 90 |
91 private: | 91 private: |
92 virtual void decodeSize() override { } | 92 void decodeSize() override { } |
93 | 93 |
94 virtual size_t decodeFrameCount() override { return m_client->frameCount();
} | 94 size_t decodeFrameCount() override { return m_client->frameCount(); } |
95 | 95 |
96 virtual void decode(size_t index) override | 96 void decode(size_t index) override |
97 { | 97 { |
98 m_client->decodeRequested(); | 98 m_client->decodeRequested(); |
99 m_frameBufferCache[index].setStatus(m_client->status()); | 99 m_frameBufferCache[index].setStatus(m_client->status()); |
100 } | 100 } |
101 | 101 |
102 virtual void initializeNewFrame(size_t index) override | 102 void initializeNewFrame(size_t index) override |
103 { | 103 { |
104 m_frameBufferCache[index].setSize(size().width(), size().height()); | 104 m_frameBufferCache[index].setSize(size().width(), size().height()); |
105 m_frameBufferCache[index].setHasAlpha(false); | 105 m_frameBufferCache[index].setHasAlpha(false); |
106 } | 106 } |
107 | 107 |
108 MockImageDecoderClient* m_client; | 108 MockImageDecoderClient* m_client; |
109 }; | 109 }; |
110 | 110 |
111 class MockImageDecoderFactory : public ImageDecoderFactory { | 111 class MockImageDecoderFactory : public ImageDecoderFactory { |
112 public: | 112 public: |
113 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) | 113 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) |
114 { | 114 { |
115 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); | 115 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); |
116 } | 116 } |
117 | 117 |
118 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const IntSize& decodedSize) | 118 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const IntSize& decodedSize) |
119 { | 119 { |
120 return adoptPtr(new MockImageDecoderFactory(client, decodedSize)); | 120 return adoptPtr(new MockImageDecoderFactory(client, decodedSize)); |
121 } | 121 } |
122 | 122 |
123 virtual PassOwnPtr<ImageDecoder> create() override | 123 PassOwnPtr<ImageDecoder> create() override |
124 { | 124 { |
125 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_client); | 125 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_client); |
126 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); | 126 decoder->setSize(m_decodedSize.width(), m_decodedSize.height()); |
127 return decoder.release(); | 127 return decoder.release(); |
128 } | 128 } |
129 | 129 |
130 private: | 130 private: |
131 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod
edSize) | 131 MockImageDecoderFactory(MockImageDecoderClient* client, const IntSize& decod
edSize) |
132 : m_client(client) | 132 : m_client(client) |
133 , m_decodedSize(decodedSize) | 133 , m_decodedSize(decodedSize) |
134 { | 134 { |
135 } | 135 } |
136 | 136 |
137 MockImageDecoderClient* m_client; | 137 MockImageDecoderClient* m_client; |
138 IntSize m_decodedSize; | 138 IntSize m_decodedSize; |
139 }; | 139 }; |
140 | 140 |
141 } // namespace blink | 141 } // namespace blink |
142 | 142 |
143 #endif // MockImageDecoder_h | 143 #endif // MockImageDecoder_h |
OLD | NEW |