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

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

Issue 2887123003: Fix required frame bug in APNGs (Closed)
Patch Set: Move comment 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 445
446 // Frames that use the DisposeOverwritePrevious method are effectively
447 // no-ops in terms of changing the starting state of a frame compared to
448 // the starting state of the previous frame, so skip over them.
449 while (prev_buffer->GetDisposalMethod() ==
450 ImageFrame::kDisposeOverwritePrevious) {
451 if (prev_frame == 0) {
452 return kNotFound;
453 }
454 prev_frame--;
455 prev_buffer = &frame_buffer_cache_[prev_frame];
456 }
457
446 switch (prev_buffer->GetDisposalMethod()) { 458 switch (prev_buffer->GetDisposalMethod()) {
447 case ImageFrame::kDisposeNotSpecified: 459 case ImageFrame::kDisposeNotSpecified:
448 case ImageFrame::kDisposeKeep: 460 case ImageFrame::kDisposeKeep:
449 // prevFrame will be used as the starting state for this frame. 461 // prevFrame will be used as the starting state for this frame.
450 // FIXME: Be even smarter by checking the frame sizes and/or 462 // FIXME: Be even smarter by checking the frame sizes and/or
451 // alpha-containing regions. 463 // alpha-containing regions.
452 return prev_frame; 464 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: 465 case ImageFrame::kDisposeOverwriteBgcolor:
460 // If the previous frame fills the whole image, then the current frame 466 // If the previous frame fills the whole image, then the current frame
461 // can be decoded alone. Likewise, if the previous frame could be 467 // can be decoded alone. Likewise, if the previous frame could be
462 // decoded without reference to any prior frame, the starting state for 468 // 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. 469 // this frame is a blank frame, so it can again be decoded alone.
464 // Otherwise, the previous frame contributes to this frame. 470 // Otherwise, the previous frame contributes to this frame.
465 return (prev_buffer->OriginalFrameRect().Contains( 471 return (prev_buffer->OriginalFrameRect().Contains(
466 IntRect(IntPoint(), Size())) || 472 IntRect(IntPoint(), Size())) ||
467 (prev_buffer->RequiredPreviousFrameIndex() == kNotFound)) 473 (prev_buffer->RequiredPreviousFrameIndex() == kNotFound))
468 ? kNotFound 474 ? kNotFound
469 : prev_frame; 475 : prev_frame;
476 case ImageFrame::kDisposeOverwritePrevious:
470 default: 477 default:
471 NOTREACHED(); 478 NOTREACHED();
472 return kNotFound; 479 return kNotFound;
473 } 480 }
474 } 481 }
475 482
476 ImagePlanes::ImagePlanes() { 483 ImagePlanes::ImagePlanes() {
477 for (int i = 0; i < 3; ++i) { 484 for (int i = 0; i < 3; ++i) {
478 planes_[i] = 0; 485 planes_[i] = 0;
479 row_bytes_[i] = 0; 486 row_bytes_[i] = 0;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 583 }
577 584
578 // For color spaces without an identifiable gamut, just fall through to 585 // For color spaces without an identifiable gamut, just fall through to
579 // sRGB. 586 // sRGB.
580 } 587 }
581 588
582 return SkColorSpace::MakeSRGB(); 589 return SkColorSpace::MakeSRGB();
583 } 590 }
584 591
585 } // namespace blink 592 } // 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