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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 2887123003: Fix required frame bug in APNGs (Closed)
Patch Set: Add a LayoutTest Created 3 years, 7 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 | « third_party/WebKit/LayoutTests/images/resources/green.png ('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) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 const ImageFrame* curr_buffer = &frame_buffer_cache_[frame_index]; 435 const ImageFrame* curr_buffer = &frame_buffer_cache_[frame_index];
436 if ((frame_rect_is_opaque || 436 if ((frame_rect_is_opaque ||
437 curr_buffer->GetAlphaBlendSource() == ImageFrame::kBlendAtopBgcolor) && 437 curr_buffer->GetAlphaBlendSource() == ImageFrame::kBlendAtopBgcolor) &&
438 curr_buffer->OriginalFrameRect().Contains(IntRect(IntPoint(), Size()))) 438 curr_buffer->OriginalFrameRect().Contains(IntRect(IntPoint(), Size())))
439 return kNotFound; 439 return kNotFound;
440 440
441 // The starting state for this frame depends on the previous frame's 441 // The starting state for this frame depends on the previous frame's
442 // disposal method. 442 // disposal method.
443 size_t prev_frame = frame_index - 1; 443 size_t prev_frame = frame_index - 1;
444 const ImageFrame* prev_buffer = &frame_buffer_cache_[prev_frame]; 444 const ImageFrame* prev_buffer = &frame_buffer_cache_[prev_frame];
445 while (prev_buffer->GetDisposalMethod() ==
446 ImageFrame::kDisposeOverwritePrevious) {
447 // Frames that use the DisposeOverwritePrevious method are effectively
Peter Kasting 2017/05/17 23:30:53 Nit: I'd put this comment above the loop rather th
scroggo_chromium 2017/05/18 12:24:05 Done.
448 // no-ops in terms of changing the starting state of a frame compared to
449 // the starting state of the previous frame, so skip over them.
450 if (prev_frame == 0) {
451 return kNotFound;
452 }
453 prev_frame--;
454 prev_buffer = &frame_buffer_cache_[prev_frame];
455 }
445 456
446 switch (prev_buffer->GetDisposalMethod()) { 457 switch (prev_buffer->GetDisposalMethod()) {
447 case ImageFrame::kDisposeNotSpecified: 458 case ImageFrame::kDisposeNotSpecified:
448 case ImageFrame::kDisposeKeep: 459 case ImageFrame::kDisposeKeep:
449 // prevFrame will be used as the starting state for this frame. 460 // prevFrame will be used as the starting state for this frame.
450 // FIXME: Be even smarter by checking the frame sizes and/or 461 // FIXME: Be even smarter by checking the frame sizes and/or
451 // alpha-containing regions. 462 // alpha-containing regions.
452 return prev_frame; 463 return prev_frame;
453 case ImageFrame::kDisposeOverwritePrevious:
454 // Frames that use the DisposeOverwritePrevious method are effectively
455 // no-ops in terms of changing the starting state of a frame compared to
456 // the starting state of the previous frame, so skip over them and
457 // return the required previous frame of it.
458 return prev_buffer->RequiredPreviousFrameIndex();
459 case ImageFrame::kDisposeOverwriteBgcolor: 464 case ImageFrame::kDisposeOverwriteBgcolor:
460 // If the previous frame fills the whole image, then the current frame 465 // If the previous frame fills the whole image, then the current frame
461 // can be decoded alone. Likewise, if the previous frame could be 466 // can be decoded alone. Likewise, if the previous frame could be
462 // decoded without reference to any prior frame, the starting state for 467 // decoded without reference to any prior frame, the starting state for
463 // this frame is a blank frame, so it can again be decoded alone. 468 // this frame is a blank frame, so it can again be decoded alone.
464 // Otherwise, the previous frame contributes to this frame. 469 // Otherwise, the previous frame contributes to this frame.
465 return (prev_buffer->OriginalFrameRect().Contains( 470 return (prev_buffer->OriginalFrameRect().Contains(
466 IntRect(IntPoint(), Size())) || 471 IntRect(IntPoint(), Size())) ||
467 (prev_buffer->RequiredPreviousFrameIndex() == kNotFound)) 472 (prev_buffer->RequiredPreviousFrameIndex() == kNotFound))
468 ? kNotFound 473 ? kNotFound
469 : prev_frame; 474 : prev_frame;
475 case ImageFrame::kDisposeOverwritePrevious:
470 default: 476 default:
471 NOTREACHED(); 477 NOTREACHED();
472 return kNotFound; 478 return kNotFound;
473 } 479 }
474 } 480 }
475 481
476 ImagePlanes::ImagePlanes() { 482 ImagePlanes::ImagePlanes() {
477 for (int i = 0; i < 3; ++i) { 483 for (int i = 0; i < 3; ++i) {
478 planes_[i] = 0; 484 planes_[i] = 0;
479 row_bytes_[i] = 0; 485 row_bytes_[i] = 0;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 582 }
577 583
578 // For color spaces without an identifiable gamut, just fall through to 584 // For color spaces without an identifiable gamut, just fall through to
579 // sRGB. 585 // sRGB.
580 } 586 }
581 587
582 return SkColorSpace::MakeSRGB(); 588 return SkColorSpace::MakeSRGB();
583 } 589 }
584 590
585 } // namespace blink 591 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/images/resources/green.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698