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

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

Issue 400543004: Rename WebCore namespace to blink in Platform (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 or revised. This service is offered free of charge; please provide us with your 71 or revised. This service is offered free of charge; please provide us with your
72 mailing address. 72 mailing address.
73 */ 73 */
74 74
75 #include "config.h" 75 #include "config.h"
76 #include "platform/image-decoders/gif/GIFImageReader.h" 76 #include "platform/image-decoders/gif/GIFImageReader.h"
77 77
78 #include <string.h> 78 #include <string.h>
79 #include "platform/graphics/ImageSource.h" 79 #include "platform/graphics/ImageSource.h"
80 80
81 using WebCore::GIFImageDecoder; 81 using blink::GIFImageDecoder;
82 82
83 // GETN(n, s) requests at least 'n' bytes available from 'q', at start of state 's'. 83 // GETN(n, s) requests at least 'n' bytes available from 'q', at start of state 's'.
84 // 84 //
85 // Note, the hold will never need to be bigger than 256 bytes to gather up in th e hold, 85 // Note, the hold will never need to be bigger than 256 bytes to gather up in th e hold,
86 // as each GIF block (except colormaps) can never be bigger than 256 bytes. 86 // as each GIF block (except colormaps) can never be bigger than 256 bytes.
87 // Colormaps are directly copied in the resp. global_colormap or dynamically all ocated local_colormap. 87 // Colormaps are directly copied in the resp. global_colormap or dynamically all ocated local_colormap.
88 // So a fixed buffer in GIFImageReader is good enough. 88 // So a fixed buffer in GIFImageReader is good enough.
89 // This buffer is only needed to copy left-over data from one GifWrite call to t he next 89 // This buffer is only needed to copy left-over data from one GifWrite call to t he next
90 #define GETN(n, s) \ 90 #define GETN(n, s) \
91 do { \ 91 do { \
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 m_table.resize(m_colors); 314 m_table.resize(m_colors);
315 for (Table::iterator iter = m_table.begin(); iter != m_table.end(); ++iter) { 315 for (Table::iterator iter = m_table.begin(); iter != m_table.end(); ++iter) {
316 *iter = SkPackARGB32NoCheck(255, srcColormap[0], srcColormap[1], srcColo rmap[2]); 316 *iter = SkPackARGB32NoCheck(255, srcColormap[0], srcColormap[1], srcColo rmap[2]);
317 srcColormap += BYTES_PER_COLORMAP_ENTRY; 317 srcColormap += BYTES_PER_COLORMAP_ENTRY;
318 } 318 }
319 } 319 }
320 320
321 // Perform decoding for this frame. frameDecoded will be true if the entire fram e is decoded. 321 // Perform decoding for this frame. frameDecoded will be true if the entire fram e is decoded.
322 // Returns false if a decoding error occurred. This is a fatal error and causes the GIFImageReader to set the "decode failed" flag. 322 // Returns false if a decoding error occurred. This is a fatal error and causes the GIFImageReader to set the "decode failed" flag.
323 // Otherwise, either not enough data is available to decode further than before, or the new data has been decoded successfully; returns true in this case. 323 // Otherwise, either not enough data is available to decode further than before, or the new data has been decoded successfully; returns true in this case.
324 bool GIFFrameContext::decode(const unsigned char* data, size_t length, WebCore:: GIFImageDecoder* client, bool* frameDecoded) 324 bool GIFFrameContext::decode(const unsigned char* data, size_t length, blink::GI FImageDecoder* client, bool* frameDecoded)
325 { 325 {
326 m_localColorMap.buildTable(data, length); 326 m_localColorMap.buildTable(data, length);
327 327
328 *frameDecoded = false; 328 *frameDecoded = false;
329 if (!m_lzwContext) { 329 if (!m_lzwContext) {
330 // Wait for more data to properly initialize GIFLZWContext. 330 // Wait for more data to properly initialize GIFLZWContext.
331 if (!isDataSizeDefined() || !isHeaderDefined()) 331 if (!isDataSizeDefined() || !isHeaderDefined())
332 return true; 332 return true;
333 333
334 m_lzwContext = adoptPtr(new GIFLZWContext(client, this)); 334 m_lzwContext = adoptPtr(new GIFLZWContext(client, this));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 GIFFrameContext* currentFrame = m_frames.last().get(); 543 GIFFrameContext* currentFrame = m_frames.last().get();
544 if (*currentComponent & 0x1) 544 if (*currentComponent & 0x1)
545 currentFrame->setTransparentPixel(currentComponent[3]); 545 currentFrame->setTransparentPixel(currentComponent[3]);
546 546
547 // We ignore the "user input" bit. 547 // We ignore the "user input" bit.
548 548
549 // NOTE: This relies on the values in the FrameDisposalMethod enum 549 // NOTE: This relies on the values in the FrameDisposalMethod enum
550 // matching those in the GIF spec! 550 // matching those in the GIF spec!
551 int disposalMethod = ((*currentComponent) >> 2) & 0x7; 551 int disposalMethod = ((*currentComponent) >> 2) & 0x7;
552 if (disposalMethod < 4) { 552 if (disposalMethod < 4) {
553 currentFrame->setDisposalMethod(static_cast<WebCore::ImageFrame: :DisposalMethod>(disposalMethod)); 553 currentFrame->setDisposalMethod(static_cast<blink::ImageFrame::D isposalMethod>(disposalMethod));
554 } else if (disposalMethod == 4) { 554 } else if (disposalMethod == 4) {
555 // Some specs say that disposal method 3 is "overwrite previous" , others that setting 555 // Some specs say that disposal method 3 is "overwrite previous" , others that setting
556 // the third bit of the field (i.e. method 4) is. We map both to the same value. 556 // the third bit of the field (i.e. method 4) is. We map both to the same value.
557 currentFrame->setDisposalMethod(WebCore::ImageFrame::DisposeOver writePrevious); 557 currentFrame->setDisposalMethod(blink::ImageFrame::DisposeOverwr itePrevious);
558 } 558 }
559 currentFrame->setDelayTime(GETINT16(currentComponent + 1) * 10); 559 currentFrame->setDelayTime(GETINT16(currentComponent + 1) * 10);
560 GETN(1, GIFConsumeBlock); 560 GETN(1, GIFConsumeBlock);
561 break; 561 break;
562 } 562 }
563 563
564 case GIFCommentExtension: { 564 case GIFCommentExtension: {
565 if (*currentComponent) 565 if (*currentComponent)
566 GETN(*currentComponent, GIFConsumeComment); 566 GETN(*currentComponent, GIFConsumeComment);
567 else 567 else
(...skipping 29 matching lines...) Expand all
597 // Parse netscape-specific application extensions 597 // Parse netscape-specific application extensions
598 case GIFConsumeNetscapeExtension: { 598 case GIFConsumeNetscapeExtension: {
599 int netscapeExtension = currentComponent[0] & 7; 599 int netscapeExtension = currentComponent[0] & 7;
600 600
601 // Loop entire animation specified # of times. Only read the loop co unt during the first iteration. 601 // Loop entire animation specified # of times. Only read the loop co unt during the first iteration.
602 if (netscapeExtension == 1) { 602 if (netscapeExtension == 1) {
603 m_loopCount = GETINT16(currentComponent + 1); 603 m_loopCount = GETINT16(currentComponent + 1);
604 604
605 // Zero loop count is infinite animation loop request. 605 // Zero loop count is infinite animation loop request.
606 if (!m_loopCount) 606 if (!m_loopCount)
607 m_loopCount = WebCore::cAnimationLoopInfinite; 607 m_loopCount = blink::cAnimationLoopInfinite;
608 608
609 GETN(1, GIFNetscapeExtensionBlock); 609 GETN(1, GIFNetscapeExtensionBlock);
610 } else if (netscapeExtension == 2) { 610 } else if (netscapeExtension == 2) {
611 // Wait for specified # of bytes to enter buffer. 611 // Wait for specified # of bytes to enter buffer.
612 612
613 // Don't do this, this extension doesn't exist (isn't used at al l) 613 // Don't do this, this extension doesn't exist (isn't used at al l)
614 // and doesn't do anything, as our streaming/buffering takes car e of it all... 614 // and doesn't do anything, as our streaming/buffering takes car e of it all...
615 // See: http://semmix.pl/color/exgraf/eeg24.htm 615 // See: http://semmix.pl/color/exgraf/eeg24.htm
616 GETN(1, GIFNetscapeExtensionBlock); 616 GETN(1, GIFNetscapeExtensionBlock);
617 } else { 617 } else {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 rowIter = rowBuffer.begin(); 791 rowIter = rowBuffer.begin();
792 rowsRemaining = m_frameContext->height(); 792 rowsRemaining = m_frameContext->height();
793 793
794 // Clearing the whole suffix table lets us be more tolerant of bad data. 794 // Clearing the whole suffix table lets us be more tolerant of bad data.
795 for (int i = 0; i < clearCode; ++i) { 795 for (int i = 0; i < clearCode; ++i) {
796 suffix[i] = i; 796 suffix[i] = i;
797 suffixLength[i] = 1; 797 suffixLength[i] = 1;
798 } 798 }
799 return true; 799 return true;
800 } 800 }
OLDNEW
« no previous file with comments | « Source/platform/image-decoders/gif/GIFImageReader.h ('k') | Source/platform/image-decoders/ico/ICOImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698