Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: Source/core/platform/image-decoders/ImageDecoderTest.cpp

Issue 23068027: Animated WebP: Optimize decoding in case of seeking (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@add_noblend_image
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 virtual String filenameExtension() const OVERRIDE { return ""; } 49 virtual String filenameExtension() const OVERRIDE { return ""; }
50 virtual ImageFrame* frameBufferAtIndex(size_t) OVERRIDE { return 0; } 50 virtual ImageFrame* frameBufferAtIndex(size_t) OVERRIDE { return 0; }
51 51
52 Vector<ImageFrame, 1>& frameBufferCache() 52 Vector<ImageFrame, 1>& frameBufferCache()
53 { 53 {
54 return m_frameBufferCache; 54 return m_frameBufferCache;
55 } 55 }
56 56
57 void resetRequiredPreviousFrames() 57 void resetRequiredPreviousFrames(bool knownOpaque = false)
58 { 58 {
59 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) 59 for (size_t i = 0; i < m_frameBufferCache.size(); ++i)
60 m_frameBufferCache[i].setRequiredPreviousFrameIndex(findRequiredPrev iousFrame(i)); 60 m_frameBufferCache[i].setRequiredPreviousFrameIndex(findRequiredPrev iousFrame(i, knownOpaque));
61 } 61 }
62 62
63 void initFrames(size_t numFrames, unsigned width = 100, unsigned height = 10 0) 63 void initFrames(size_t numFrames, unsigned width = 100, unsigned height = 10 0)
64 { 64 {
65 setSize(width, height); 65 setSize(width, height);
66 m_frameBufferCache.resize(numFrames); 66 m_frameBufferCache.resize(numFrames);
67 for (size_t i = 0; i < numFrames; ++i) 67 for (size_t i = 0; i < numFrames; ++i)
68 m_frameBufferCache[i].setOriginalFrameRect(IntRect(0, 0, width, heig ht)); 68 m_frameBufferCache[i].setOriginalFrameRect(IntRect(0, 0, width, heig ht));
69 } 69 }
70 }; 70 };
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 decoderFrameBufferCache[0].setOriginalFrameRect(IntRect(50, 50, 50, 50)); 133 decoderFrameBufferCache[0].setOriginalFrameRect(IntRect(50, 50, 50, 50));
134 134
135 decoderFrameBufferCache[0].setDisposalMethod(ImageFrame::DisposeOverwritePre vious); 135 decoderFrameBufferCache[0].setDisposalMethod(ImageFrame::DisposeOverwritePre vious);
136 decoder->resetRequiredPreviousFrames(); 136 decoder->resetRequiredPreviousFrames();
137 EXPECT_EQ(notFound, decoderFrameBufferCache[1].requiredPreviousFrameIndex()) ; 137 EXPECT_EQ(notFound, decoderFrameBufferCache[1].requiredPreviousFrameIndex()) ;
138 decoderFrameBufferCache[0].setDisposalMethod(ImageFrame::DisposeOverwriteBgc olor); 138 decoderFrameBufferCache[0].setDisposalMethod(ImageFrame::DisposeOverwriteBgc olor);
139 decoder->resetRequiredPreviousFrames(); 139 decoder->resetRequiredPreviousFrames();
140 EXPECT_EQ(notFound, decoderFrameBufferCache[1].requiredPreviousFrameIndex()) ; 140 EXPECT_EQ(notFound, decoderFrameBufferCache[1].requiredPreviousFrameIndex()) ;
141 } 141 }
142 142
143 // A full frame with 'blending method == BlendOverwrite' doesn't depend on any p rior frames.
144 TEST(ImageDecoderTest, requiredPreviousFrameIndexFullFrameBlendOverwrite)
145 {
146 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
147 decoder->initFrames(2);
148 Vector<ImageFrame, 1>& decoderFrameBufferCache = decoder->frameBufferCache() ;
149
150 decoderFrameBufferCache[0].setOriginalFrameRect(IntRect(25, 25, 50, 50));
151 decoderFrameBufferCache[1].setBlendingMethod(ImageFrame::BlendOverwrite);
152
153 for (int disposeMethod = ImageFrame::DisposeNotSpecified; disposeMethod <= I mageFrame::DisposeOverwritePrevious; ++disposeMethod) {
154 decoderFrameBufferCache[0].setDisposalMethod(static_cast<ImageFrame::Fra meDisposalMethod>(disposeMethod));
155 decoder->resetRequiredPreviousFrames();
156 EXPECT_EQ(notFound, decoderFrameBufferCache[1].requiredPreviousFrameInde x());
157 }
158 }
159
160 // A full frame that is known to be opaque doesn't depend on any prior frames.
161 TEST(ImageDecoderTest, requiredPreviousFrameIndexFullFrameOpaque)
162 {
163 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
164 decoder->initFrames(2);
165 Vector<ImageFrame, 1>& decoderFrameBufferCache = decoder->frameBufferCache() ;
166
167 decoderFrameBufferCache[0].setOriginalFrameRect(IntRect(25, 25, 50, 50));
168 decoderFrameBufferCache[1].setBlendingMethod(ImageFrame::BlendOverwrite);
169
170 for (int disposeMethod = ImageFrame::DisposeNotSpecified; disposeMethod <= I mageFrame::DisposeOverwritePrevious; ++disposeMethod) {
171 decoderFrameBufferCache[0].setDisposalMethod(static_cast<ImageFrame::Fra meDisposalMethod>(disposeMethod));
172 decoder->resetRequiredPreviousFrames(true); // Opaque.
173 EXPECT_EQ(notFound, decoderFrameBufferCache[1].requiredPreviousFrameInde x());
174 }
175 }
176
143 TEST(ImageDecoderTest, clearCacheExceptFrameDoNothing) 177 TEST(ImageDecoderTest, clearCacheExceptFrameDoNothing)
144 { 178 {
145 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); 179 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
146 decoder->clearCacheExceptFrame(0); 180 decoder->clearCacheExceptFrame(0);
147 181
148 // This should not crash. 182 // This should not crash.
149 decoder->initFrames(20); 183 decoder->initFrames(20);
150 decoder->clearCacheExceptFrame(notFound); 184 decoder->clearCacheExceptFrame(notFound);
151 } 185 }
152 186
(...skipping 26 matching lines...) Expand all
179 decoder->resetRequiredPreviousFrames(); 213 decoder->resetRequiredPreviousFrames();
180 decoder->clearCacheExceptFrame(5); 214 decoder->clearCacheExceptFrame(5);
181 for (size_t i = 0; i < numFrames; ++i) { 215 for (size_t i = 0; i < numFrames; ++i) {
182 SCOPED_TRACE(testing::Message() << i); 216 SCOPED_TRACE(testing::Message() << i);
183 if (i == 5) 217 if (i == 5)
184 EXPECT_EQ(ImageFrame::FrameComplete, decoderFrameBufferCache[i].stat us()); 218 EXPECT_EQ(ImageFrame::FrameComplete, decoderFrameBufferCache[i].stat us());
185 else 219 else
186 EXPECT_EQ(ImageFrame::FrameEmpty, decoderFrameBufferCache[i].status( )); 220 EXPECT_EQ(ImageFrame::FrameEmpty, decoderFrameBufferCache[i].status( ));
187 } 221 }
188 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698