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

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

Issue 1647703006: Track positions of dimensions in image files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated GIF dimensions UMA logic Created 4 years, 10 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 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK ***** 2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * 4 *
5 * The contents of this file are subject to the Mozilla Public License Version 5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with 6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at 7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/ 8 * http://www.mozilla.org/MPL/
9 * 9 *
10 * Software distributed under the License is distributed on an "AS IS" basis, 10 * Software distributed under the License is distributed on an "AS IS" basis,
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 reader.getConsecutiveData(currentComponentPosition, 5, readB uffer)); 456 reader.getConsecutiveData(currentComponentPosition, 5, readB uffer));
457 457
458 // This is the height and width of the "screen" or frame into which 458 // This is the height and width of the "screen" or frame into which
459 // images are rendered. The individual images can be smaller than 459 // images are rendered. The individual images can be smaller than
460 // the screen size and located with an origin anywhere within the 460 // the screen size and located with an origin anywhere within the
461 // screen. 461 // screen.
462 // Note that we don't inform the client of the size yet, as it might 462 // Note that we don't inform the client of the size yet, as it might
463 // change after we read the first frame's image header. 463 // change after we read the first frame's image header.
464 m_screenWidth = GETINT16(currentComponent); 464 m_screenWidth = GETINT16(currentComponent);
465 m_screenHeight = GETINT16(currentComponent + 2); 465 m_screenHeight = GETINT16(currentComponent + 2);
466 466 m_client->setSizeOffsetOptimized(currentComponentPosition + 4);
467 const size_t globalColorMapColors = 2 << (currentComponent[4] & 0x07 ); 467 const size_t globalColorMapColors = 2 << (currentComponent[4] & 0x07 );
468 468
469 if ((currentComponent[4] & 0x80) && globalColorMapColors > 0) { /* g lobal map */ 469 if ((currentComponent[4] & 0x80) && globalColorMapColors > 0) { /* g lobal map */
470 m_globalColorMap.setTablePositionAndSize(dataPosition, globalCol orMapColors); 470 m_globalColorMap.setTablePositionAndSize(dataPosition, globalCol orMapColors);
471 GETN(BYTES_PER_COLORMAP_ENTRY * globalColorMapColors, GIFGlobalC olormap); 471 GETN(BYTES_PER_COLORMAP_ENTRY * globalColorMapColors, GIFGlobalC olormap);
472 break; 472 break;
473 } 473 }
474 474
475 GETN(1, GIFImageStart); 475 GETN(1, GIFImageStart);
476 break; 476 break;
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 // the image size to allow the frame to be visible. We can't do 682 // the image size to allow the frame to be visible. We can't do
683 // this on subsequent frames because the rest of the decoding 683 // this on subsequent frames because the rest of the decoding
684 // infrastructure assumes the image size won't change as we 684 // infrastructure assumes the image size won't change as we
685 // continue decoding, so any subsequent frames that are even 685 // continue decoding, so any subsequent frames that are even
686 // larger will be cropped. 686 // larger will be cropped.
687 // Luckily, handling just the first frame is sufficient to deal 687 // Luckily, handling just the first frame is sufficient to deal
688 // with most cases, e.g. ones where the image size is erroneously 688 // with most cases, e.g. ones where the image size is erroneously
689 // set to zero, since usually the first frame completely fills 689 // set to zero, since usually the first frame completely fills
690 // the image. 690 // the image.
691 if (currentFrameIsFirstFrame()) { 691 if (currentFrameIsFirstFrame()) {
692 bool updated = (m_screenHeight < yOffset + height || m_screenWid th < yOffset + width);
693 if (updated)
694 m_client->setSizeOffsetOptimized(0);
695 m_client->setSizeOffset(currentComponentPosition + 8);
692 m_screenHeight = std::max(m_screenHeight, yOffset + height); 696 m_screenHeight = std::max(m_screenHeight, yOffset + height);
693 m_screenWidth = std::max(m_screenWidth, xOffset + width); 697 m_screenWidth = std::max(m_screenWidth, xOffset + width);
694 } 698 }
695 699
696 // Inform the client of the final size. 700 // Inform the client of the final size.
697 if (!m_sentSizeToClient && m_client && !m_client->setSize(m_screenWi dth, m_screenHeight)) 701 if (!m_sentSizeToClient && m_client && !m_client->setSize(m_screenWi dth, m_screenHeight))
698 return false; 702 return false;
699 m_sentSizeToClient = true; 703 m_sentSizeToClient = true;
700 704
701 if (query == GIFImageDecoder::GIFSizeQuery) { 705 if (query == GIFImageDecoder::GIFSizeQuery) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 rowIter = rowBuffer.begin(); 844 rowIter = rowBuffer.begin();
841 rowsRemaining = m_frameContext->height(); 845 rowsRemaining = m_frameContext->height();
842 846
843 // Clearing the whole suffix table lets us be more tolerant of bad data. 847 // Clearing the whole suffix table lets us be more tolerant of bad data.
844 for (int i = 0; i < clearCode; ++i) { 848 for (int i = 0; i < clearCode; ++i) {
845 suffix[i] = i; 849 suffix[i] = i;
846 suffixLength[i] = 1; 850 suffixLength[i] = 1;
847 } 851 }
848 return true; 852 return true;
849 } 853 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698