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

Side by Side Diff: Source/core/platform/image-decoders/webp/WEBPImageDecoderTest.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: Fix assert fail on debug Created 7 years, 3 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
« no previous file with comments | « Source/core/platform/image-decoders/webp/WEBPImageDecoder.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 175 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
176 176
177 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web p-animated.webp"); 177 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web p-animated.webp");
178 ASSERT_TRUE(data.get()); 178 ASSERT_TRUE(data.get());
179 decoder->setData(data.get(), true); 179 decoder->setData(data.get(), true);
180 180
181 const int canvasWidth = 11; 181 const int canvasWidth = 11;
182 const int canvasHeight = 29; 182 const int canvasHeight = 29;
183 const struct AnimParam { 183 const struct AnimParam {
184 int xOffset, yOffset, width, height; 184 int xOffset, yOffset, width, height;
185 ImageFrame::FrameDisposalMethod dispose; 185 ImageFrame::DisposalMethod disposalMethod;
186 ImageFrame::AlphaBlendSource alphaBlendSource;
186 unsigned duration; 187 unsigned duration;
187 bool hasAlpha; 188 bool hasAlpha;
188 } frameParameters[] = { 189 } frameParameters[] = {
189 { 0, 0, 11, 29, ImageFrame::DisposeKeep, 1000u, true }, 190 { 0, 0, 11, 29, ImageFrame::DisposeKeep, ImageFrame::BlendAtopPreviousFr ame, 1000u, true },
190 { 2, 10, 7, 17, ImageFrame::DisposeKeep, 500u, true }, 191 { 2, 10, 7, 17, ImageFrame::DisposeKeep, ImageFrame::BlendAtopPreviousFr ame, 500u, true },
191 { 2, 2, 7, 16, ImageFrame::DisposeKeep, 1000u, true }, 192 { 2, 2, 7, 16, ImageFrame::DisposeKeep, ImageFrame::BlendAtopPreviousFra me, 1000u, true },
192 }; 193 };
193 194
194 for (size_t i = 0; i < ARRAY_SIZE(frameParameters); ++i) { 195 for (size_t i = 0; i < ARRAY_SIZE(frameParameters); ++i) {
195 const ImageFrame* const frame = decoder->frameBufferAtIndex(i); 196 const ImageFrame* const frame = decoder->frameBufferAtIndex(i);
196 EXPECT_EQ(ImageFrame::FrameComplete, frame->status()); 197 EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
197 EXPECT_EQ(canvasWidth, frame->getSkBitmap().width()); 198 EXPECT_EQ(canvasWidth, frame->getSkBitmap().width());
198 EXPECT_EQ(canvasHeight, frame->getSkBitmap().height()); 199 EXPECT_EQ(canvasHeight, frame->getSkBitmap().height());
199 EXPECT_EQ(frameParameters[i].xOffset, frame->originalFrameRect().x()); 200 EXPECT_EQ(frameParameters[i].xOffset, frame->originalFrameRect().x());
200 EXPECT_EQ(frameParameters[i].yOffset, frame->originalFrameRect().y()); 201 EXPECT_EQ(frameParameters[i].yOffset, frame->originalFrameRect().y());
201 EXPECT_EQ(frameParameters[i].width, frame->originalFrameRect().width()); 202 EXPECT_EQ(frameParameters[i].width, frame->originalFrameRect().width());
202 EXPECT_EQ(frameParameters[i].height, frame->originalFrameRect().height() ); 203 EXPECT_EQ(frameParameters[i].height, frame->originalFrameRect().height() );
203 EXPECT_EQ(frameParameters[i].dispose, frame->disposalMethod()); 204 EXPECT_EQ(frameParameters[i].disposalMethod, frame->disposalMethod());
205 EXPECT_EQ(frameParameters[i].alphaBlendSource, frame->alphaBlendSource() );
204 EXPECT_EQ(frameParameters[i].duration, frame->duration()); 206 EXPECT_EQ(frameParameters[i].duration, frame->duration());
205 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha()); 207 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha());
206 } 208 }
207 209
208 EXPECT_EQ(ARRAY_SIZE(frameParameters), decoder->frameCount()); 210 EXPECT_EQ(ARRAY_SIZE(frameParameters), decoder->frameCount());
209 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 211 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
210 } 212 }
211 213
212 TEST_F(AnimatedWebPTests, verifyAnimationParametersOpaqueFramesTransparentBackgr ound) 214 TEST_F(AnimatedWebPTests, verifyAnimationParametersOpaqueFramesTransparentBackgr ound)
213 { 215 {
214 OwnPtr<WEBPImageDecoder> decoder = createDecoder(); 216 OwnPtr<WEBPImageDecoder> decoder = createDecoder();
215 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount()); 217 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
216 218
217 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web p-animated-opaque.webp"); 219 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web p-animated-opaque.webp");
218 ASSERT_TRUE(data.get()); 220 ASSERT_TRUE(data.get());
219 decoder->setData(data.get(), true); 221 decoder->setData(data.get(), true);
220 222
221 const int canvasWidth = 94; 223 const int canvasWidth = 94;
222 const int canvasHeight = 87; 224 const int canvasHeight = 87;
223 const struct AnimParam { 225 const struct AnimParam {
224 int xOffset, yOffset, width, height; 226 int xOffset, yOffset, width, height;
225 ImageFrame::FrameDisposalMethod dispose; 227 ImageFrame::DisposalMethod disposalMethod;
228 ImageFrame::AlphaBlendSource alphaBlendSource;
226 unsigned duration; 229 unsigned duration;
227 bool hasAlpha; 230 bool hasAlpha;
228 } frameParameters[] = { 231 } frameParameters[] = {
229 { 4, 10, 33, 32, ImageFrame::DisposeOverwriteBgcolor, 1000u, true }, 232 { 4, 10, 33, 32, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::BlendA topPreviousFrame, 1000u, true },
230 { 34, 30, 33, 32, ImageFrame::DisposeOverwriteBgcolor, 1000u, true }, 233 { 34, 30, 33, 32, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::Blend AtopPreviousFrame, 1000u, true },
231 { 62, 50, 32, 32, ImageFrame::DisposeOverwriteBgcolor, 1000u, true }, 234 { 62, 50, 32, 32, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::Blend AtopPreviousFrame, 1000u, true },
232 { 10, 54, 32, 33, ImageFrame::DisposeOverwriteBgcolor, 1000u, true }, 235 { 10, 54, 32, 33, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::Blend AtopPreviousFrame, 1000u, true },
233 }; 236 };
234 237
235 for (size_t i = 0; i < ARRAY_SIZE(frameParameters); ++i) { 238 for (size_t i = 0; i < ARRAY_SIZE(frameParameters); ++i) {
236 const ImageFrame* const frame = decoder->frameBufferAtIndex(i); 239 const ImageFrame* const frame = decoder->frameBufferAtIndex(i);
237 EXPECT_EQ(ImageFrame::FrameComplete, frame->status()); 240 EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
238 EXPECT_EQ(canvasWidth, frame->getSkBitmap().width()); 241 EXPECT_EQ(canvasWidth, frame->getSkBitmap().width());
239 EXPECT_EQ(canvasHeight, frame->getSkBitmap().height()); 242 EXPECT_EQ(canvasHeight, frame->getSkBitmap().height());
240 EXPECT_EQ(frameParameters[i].xOffset, frame->originalFrameRect().x()); 243 EXPECT_EQ(frameParameters[i].xOffset, frame->originalFrameRect().x());
241 EXPECT_EQ(frameParameters[i].yOffset, frame->originalFrameRect().y()); 244 EXPECT_EQ(frameParameters[i].yOffset, frame->originalFrameRect().y());
242 EXPECT_EQ(frameParameters[i].width, frame->originalFrameRect().width()); 245 EXPECT_EQ(frameParameters[i].width, frame->originalFrameRect().width());
243 EXPECT_EQ(frameParameters[i].height, frame->originalFrameRect().height() ); 246 EXPECT_EQ(frameParameters[i].height, frame->originalFrameRect().height() );
244 EXPECT_EQ(frameParameters[i].dispose, frame->disposalMethod()); 247 EXPECT_EQ(frameParameters[i].disposalMethod, frame->disposalMethod());
248 EXPECT_EQ(frameParameters[i].alphaBlendSource, frame->alphaBlendSource() );
245 EXPECT_EQ(frameParameters[i].duration, frame->duration()); 249 EXPECT_EQ(frameParameters[i].duration, frame->duration());
246 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha()); 250 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha());
247 } 251 }
252
253 EXPECT_EQ(ARRAY_SIZE(frameParameters), decoder->frameCount());
254 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
255 }
256
257 TEST_F(AnimatedWebPTests, verifyAnimationParametersBlendOverwrite)
258 {
259 OwnPtr<WEBPImageDecoder> decoder = createDecoder();
260 EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
261
262 RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/web p-animated-no-blend.webp");
263 ASSERT_TRUE(data.get());
264 decoder->setData(data.get(), true);
265
266 const int canvasWidth = 94;
267 const int canvasHeight = 87;
268 const struct AnimParam {
269 int xOffset, yOffset, width, height;
270 ImageFrame::DisposalMethod disposalMethod;
271 ImageFrame::AlphaBlendSource alphaBlendSource;
272 unsigned duration;
273 bool hasAlpha;
274 } frameParameters[] = {
275 { 4, 10, 33, 32, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::BlendA topBgcolor, 1000u, true },
276 { 34, 30, 33, 32, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::Blend AtopBgcolor, 1000u, true },
277 { 62, 50, 32, 32, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::Blend AtopBgcolor, 1000u, true },
278 { 10, 54, 32, 33, ImageFrame::DisposeOverwriteBgcolor, ImageFrame::Blend AtopBgcolor, 1000u, true },
279 };
280
281 for (size_t i = 0; i < ARRAY_SIZE(frameParameters); ++i) {
282 const ImageFrame* const frame = decoder->frameBufferAtIndex(i);
283 EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
284 EXPECT_EQ(canvasWidth, frame->getSkBitmap().width());
285 EXPECT_EQ(canvasHeight, frame->getSkBitmap().height());
286 EXPECT_EQ(frameParameters[i].xOffset, frame->originalFrameRect().x());
287 EXPECT_EQ(frameParameters[i].yOffset, frame->originalFrameRect().y());
288 EXPECT_EQ(frameParameters[i].width, frame->originalFrameRect().width());
289 EXPECT_EQ(frameParameters[i].height, frame->originalFrameRect().height() );
290 EXPECT_EQ(frameParameters[i].disposalMethod, frame->disposalMethod());
291 EXPECT_EQ(frameParameters[i].alphaBlendSource, frame->alphaBlendSource() );
292 EXPECT_EQ(frameParameters[i].duration, frame->duration());
293 EXPECT_EQ(frameParameters[i].hasAlpha, frame->hasAlpha());
294 }
248 295
249 EXPECT_EQ(ARRAY_SIZE(frameParameters), decoder->frameCount()); 296 EXPECT_EQ(ARRAY_SIZE(frameParameters), decoder->frameCount());
250 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount()); 297 EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
251 } 298 }
252 299
253 TEST_F(AnimatedWebPTests, parseAndDecodeByteByByte) 300 TEST_F(AnimatedWebPTests, parseAndDecodeByteByByte)
254 { 301 {
255 const struct TestImage { 302 const struct TestImage {
256 const char* filename; 303 const char* filename;
257 unsigned frameCount; 304 unsigned frameCount;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0); 497 ImageFrame* firstFrame = decoder->frameBufferAtIndex(0);
451 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status()); 498 EXPECT_EQ(ImageFrame::FrameComplete, firstFrame->status());
452 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap())); 499 EXPECT_EQ(baselineHashes[0], hashSkBitmap(firstFrame->getSkBitmap()));
453 } 500 }
454 501
455 TEST_F(AnimatedWebPTests, decodeAfterReallocatingData) 502 TEST_F(AnimatedWebPTests, decodeAfterReallocatingData)
456 { 503 {
457 testDecodeAfterReallocatingData("/LayoutTests/fast/images/resources/webp-ani mated.webp"); 504 testDecodeAfterReallocatingData("/LayoutTests/fast/images/resources/webp-ani mated.webp");
458 testDecodeAfterReallocatingData("/LayoutTests/fast/images/resources/webp-ani mated-icc-xmp.webp"); 505 testDecodeAfterReallocatingData("/LayoutTests/fast/images/resources/webp-ani mated-icc-xmp.webp");
459 } 506 }
OLDNEW
« no previous file with comments | « Source/core/platform/image-decoders/webp/WEBPImageDecoder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698