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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 virtual void decoderBeingDestroyed() | 83 virtual void decoderBeingDestroyed() |
84 { | 84 { |
85 ++m_decodersDestroyed; | 85 ++m_decodersDestroyed; |
86 } | 86 } |
87 | 87 |
88 virtual void frameBufferRequested() | 88 virtual void frameBufferRequested() |
89 { | 89 { |
90 ++m_frameBufferRequestCount; | 90 ++m_frameBufferRequestCount; |
91 } | 91 } |
92 | 92 |
93 virtual ImageFrame::FrameStatus frameStatus() | 93 virtual ImageFrame::Status frameStatus() |
94 { | 94 { |
95 ImageFrame::FrameStatus currentStatus = m_frameStatus; | 95 ImageFrame::Status currentStatus = m_frameStatus; |
96 m_frameStatus = m_nextFrameStatus; | 96 m_frameStatus = m_nextFrameStatus; |
97 return currentStatus; | 97 return currentStatus; |
98 } | 98 } |
99 | 99 |
100 virtual size_t frameCount() { return 1; } | 100 virtual size_t frameCount() { return 1; } |
101 virtual int repetitionCount() const { return cAnimationNone; } | 101 virtual int repetitionCount() const { return cAnimationNone; } |
102 virtual float frameDuration() const { return 0; } | 102 virtual float frameDuration() const { return 0; } |
103 | 103 |
104 protected: | 104 protected: |
105 PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size) | 105 PassOwnPtr<ScaledImageFragment> createCompleteImage(const SkISize& size) |
106 { | 106 { |
107 SkBitmap bitmap; | 107 SkBitmap bitmap; |
108 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height( )); | 108 bitmap.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height( )); |
109 bitmap.allocPixels(); | 109 bitmap.allocPixels(); |
110 return ScaledImageFragment::createComplete(size, 0, bitmap); | 110 return ScaledImageFragment::createComplete(size, 0, bitmap); |
111 } | 111 } |
112 | 112 |
113 void addNewData() | 113 void addNewData() |
114 { | 114 { |
115 m_data->append("g", 1); | 115 m_data->append("g", 1); |
116 m_generator->setData(m_data, false); | 116 m_generator->setData(m_data, false); |
117 } | 117 } |
118 | 118 |
119 void setFrameStatus(ImageFrame::FrameStatus status) { m_frameStatus = m_nex tFrameStatus = status; } | 119 void setFrameStatus(ImageFrame::Status status) { m_frameStatus = m_nextFram eStatus = status; } |
120 void setNextFrameStatus(ImageFrame::FrameStatus status) { m_nextFrameStatus = status; } | 120 void setNextFrameStatus(ImageFrame::Status status) { m_nextFrameStatus = st atus; } |
121 | 121 |
122 RefPtr<SharedBuffer> m_data; | 122 RefPtr<SharedBuffer> m_data; |
123 RefPtr<ImageFrameGenerator> m_generator; | 123 RefPtr<ImageFrameGenerator> m_generator; |
124 int m_decodersDestroyed; | 124 int m_decodersDestroyed; |
125 int m_frameBufferRequestCount; | 125 int m_frameBufferRequestCount; |
126 ImageFrame::FrameStatus m_frameStatus; | 126 ImageFrame::Status m_frameStatus; |
127 ImageFrame::FrameStatus m_nextFrameStatus; | 127 ImageFrame::Status m_nextFrameStatus; |
Peter Kasting
2013/08/23 01:14:02
(This can stay as m_nextFrameStatus)
urvang (Google)
2013/08/23 02:34:31
Ack.
| |
128 }; | 128 }; |
129 | 129 |
130 PassOwnPtr<ImageDecoder> MockImageDecoderFactory::create() | 130 PassOwnPtr<ImageDecoder> MockImageDecoderFactory::create() |
131 { | 131 { |
132 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_test); | 132 OwnPtr<MockImageDecoder> decoder = MockImageDecoder::create(m_test); |
133 decoder->setSize(fullSize().width(), fullSize().height()); | 133 decoder->setSize(fullSize().width(), fullSize().height()); |
134 decoder->setFrameHasAlpha(false); | 134 decoder->setFrameHasAlpha(false); |
135 return decoder.release(); | 135 return decoder.release(); |
136 } | 136 } |
137 | 137 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 ASSERT_TRUE(tempDecoder); | 422 ASSERT_TRUE(tempDecoder); |
423 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); | 423 static_cast<MockImageDecoder*>(tempDecoder)->setFrameHasAlpha(false); |
424 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder ); | 424 ImageDecodingStore::instance()->unlockDecoder(m_generator.get(), tempDecoder ); |
425 | 425 |
426 setFrameStatus(ImageFrame::FrameComplete); | 426 setFrameStatus(ImageFrame::FrameComplete); |
427 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 1)); | 427 ImageDecodingStore::instance()->unlockCache(m_generator.get(), m_generator-> decodeAndScale(fullSize(), 1)); |
428 EXPECT_FALSE(m_generator->hasAlpha(1)); | 428 EXPECT_FALSE(m_generator->hasAlpha(1)); |
429 } | 429 } |
430 | 430 |
431 } // namespace | 431 } // namespace |
OLD | NEW |