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

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

Powered by Google App Engine
This is Rietveld 408576698