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 | 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(m_client->frameCount()); |
73 m_frameBufferCache[0].setSize(width, height); | 73 for (size_t index = 0; index < m_client->frameCount(); ++index) |
| 74 m_frameBufferCache[index].setSize(width, height); |
74 return true; | 75 return true; |
75 } | 76 } |
76 | 77 |
77 virtual String filenameExtension() const override | 78 virtual String filenameExtension() const override |
78 { | 79 { |
79 return "mock"; | 80 return "mock"; |
80 } | 81 } |
81 | 82 |
82 virtual size_t frameCount() override | 83 virtual size_t frameCount() override |
83 { | 84 { |
84 return m_client->frameCount(); | 85 return m_client->frameCount(); |
85 } | 86 } |
86 | 87 |
87 virtual int repetitionCount() const override | 88 virtual int repetitionCount() const override |
88 { | 89 { |
89 return m_client->repetitionCount(); | 90 return m_client->repetitionCount(); |
90 } | 91 } |
91 | 92 |
92 virtual ImageFrame* frameBufferAtIndex(size_t) override | 93 virtual ImageFrame* frameBufferAtIndex(size_t index) override |
93 { | 94 { |
94 m_client->frameBufferRequested(); | 95 m_client->frameBufferRequested(); |
95 | 96 |
96 m_frameBufferCache[0].setStatus(m_client->status()); | 97 m_frameBufferCache[index].setStatus(m_client->status()); |
97 return &m_frameBufferCache[0]; | 98 return &m_frameBufferCache[index]; |
98 } | 99 } |
99 | 100 |
100 virtual bool frameIsCompleteAtIndex(size_t) const override | 101 virtual bool frameIsCompleteAtIndex(size_t) const override |
101 { | 102 { |
102 return m_client->status() == ImageFrame::FrameComplete; | 103 return m_client->status() == ImageFrame::FrameComplete; |
103 } | 104 } |
104 | 105 |
105 virtual float frameDurationAtIndex(size_t) const override | 106 virtual float frameDurationAtIndex(size_t) const override |
106 { | 107 { |
107 return m_client->frameDuration(); | 108 return m_client->frameDuration(); |
108 } | 109 } |
109 | 110 |
110 void setFrameHasAlpha(bool hasAlpha) { m_frameBufferCache[0].setHasAlpha(has
Alpha); } | 111 void setFrameHasAlpha(bool hasAlpha) |
| 112 { |
| 113 for (size_t index = 0; index < m_client->frameCount(); ++index) |
| 114 m_frameBufferCache[index].setHasAlpha(hasAlpha); |
| 115 } |
| 116 |
| 117 virtual size_t clearCacheExceptFrame(size_t) override { return 0; } |
111 | 118 |
112 private: | 119 private: |
113 MockImageDecoderClient* m_client; | 120 MockImageDecoderClient* m_client; |
114 }; | 121 }; |
115 | 122 |
116 class MockImageDecoderFactory : public ImageDecoderFactory { | 123 class MockImageDecoderFactory : public ImageDecoderFactory { |
117 public: | 124 public: |
118 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) | 125 static PassOwnPtr<MockImageDecoderFactory> create(MockImageDecoderClient* cl
ient, const SkISize& decodedSize) |
119 { | 126 { |
120 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); | 127 return adoptPtr(new MockImageDecoderFactory(client, IntSize(decodedSize.
width(), decodedSize.height()))); |
(...skipping 19 matching lines...) Expand all Loading... |
140 { | 147 { |
141 } | 148 } |
142 | 149 |
143 MockImageDecoderClient* m_client; | 150 MockImageDecoderClient* m_client; |
144 IntSize m_decodedSize; | 151 IntSize m_decodedSize; |
145 }; | 152 }; |
146 | 153 |
147 } // namespace blink | 154 } // namespace blink |
148 | 155 |
149 #endif // MockImageDecoder_h | 156 #endif // MockImageDecoder_h |
OLD | NEW |