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

Side by Side Diff: Source/core/platform/image-decoders/gif/GIFImageDecoder.h

Issue 23646005: Improve GIF decoding performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: test data moved to Source/core/platform/image-decoders/testing Created 7 years, 2 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 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #ifndef GIFImageDecoder_h 26 #ifndef GIFImageDecoder_h
27 #define GIFImageDecoder_h 27 #define GIFImageDecoder_h
28 28
29 #include "core/platform/image-decoders/ImageDecoder.h" 29 #include "core/platform/image-decoders/ImageDecoder.h"
30 #include "wtf/OwnPtr.h" 30 #include "wtf/OwnPtr.h"
31 31
32 class GIFImageReader; 32 class GIFImageReader;
33 33
34 typedef Vector<unsigned char> GIFRow;
35
34 namespace WebCore { 36 namespace WebCore {
35 37
36 // This class decodes the GIF image format. 38 // This class decodes the GIF image format.
37 class GIFImageDecoder : public ImageDecoder { 39 class GIFImageDecoder : public ImageDecoder {
38 public: 40 public:
39 GIFImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProf ileOption, size_t maxDecodedBytes); 41 GIFImageDecoder(ImageSource::AlphaOption, ImageSource::GammaAndColorProf ileOption, size_t maxDecodedBytes);
40 virtual ~GIFImageDecoder(); 42 virtual ~GIFImageDecoder();
41 43
42 enum GIFParseQuery { GIFSizeQuery, GIFFrameCountQuery }; 44 enum GIFParseQuery { GIFSizeQuery, GIFFrameCountQuery };
43 45
44 // ImageDecoder 46 // ImageDecoder
45 virtual String filenameExtension() const OVERRIDE { return "gif"; } 47 virtual String filenameExtension() const OVERRIDE { return "gif"; }
46 virtual void setData(SharedBuffer* data, bool allDataReceived) OVERRIDE; 48 virtual void setData(SharedBuffer* data, bool allDataReceived) OVERRIDE;
47 virtual bool isSizeAvailable() OVERRIDE; 49 virtual bool isSizeAvailable() OVERRIDE;
48 virtual size_t frameCount() OVERRIDE; 50 virtual size_t frameCount() OVERRIDE;
49 virtual int repetitionCount() const OVERRIDE; 51 virtual int repetitionCount() const OVERRIDE;
50 virtual ImageFrame* frameBufferAtIndex(size_t) OVERRIDE; 52 virtual ImageFrame* frameBufferAtIndex(size_t) OVERRIDE;
51 virtual bool frameIsCompleteAtIndex(size_t) const OVERRIDE; 53 virtual bool frameIsCompleteAtIndex(size_t) const OVERRIDE;
52 virtual float frameDurationAtIndex(size_t) const OVERRIDE; 54 virtual float frameDurationAtIndex(size_t) const OVERRIDE;
53 virtual size_t clearCacheExceptFrame(size_t) OVERRIDE; 55 virtual size_t clearCacheExceptFrame(size_t) OVERRIDE;
54 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid 56 // CAUTION: setFailed() deletes |m_reader|. Be careful to avoid
55 // accessing deleted memory, especially when calling this from inside 57 // accessing deleted memory, especially when calling this from inside
56 // GIFImageReader! 58 // GIFImageReader!
57 virtual bool setFailed() OVERRIDE; 59 virtual bool setFailed() OVERRIDE;
58 60
59 // Callbacks from the GIF reader. 61 // Callbacks from the GIF reader.
60 bool haveDecodedRow(size_t frameIndex, const Vector<unsigned char>& rowB uffer, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTranspare ntPixels); 62 bool haveDecodedRow(size_t frameIndex, GIFRow::const_iterator rowBegin, size_t width, size_t rowNumber, unsigned repeatCount, bool writeTransparentPixel s);
61 bool frameComplete(size_t frameIndex); 63 bool frameComplete(size_t frameIndex);
62 64
63 // For testing. 65 // For testing.
64 bool parseCompleted() const; 66 bool parseCompleted() const;
65 67
66 private: 68 private:
67 virtual void clearFrameBuffer(size_t frameIndex) OVERRIDE; 69 virtual void clearFrameBuffer(size_t frameIndex) OVERRIDE;
68 70
69 // Parses as much as is needed to answer the query, ignoring bitmap 71 // Parses as much as is needed to answer the query, ignoring bitmap
70 // data. If parsing fails, sets the "decode failure" flag. 72 // data. If parsing fails, sets the "decode failure" flag.
(...skipping 10 matching lines...) Expand all
81 bool initFrameBuffer(size_t frameIndex); 83 bool initFrameBuffer(size_t frameIndex);
82 84
83 bool m_currentBufferSawAlpha; 85 bool m_currentBufferSawAlpha;
84 mutable int m_repetitionCount; 86 mutable int m_repetitionCount;
85 OwnPtr<GIFImageReader> m_reader; 87 OwnPtr<GIFImageReader> m_reader;
86 }; 88 };
87 89
88 } // namespace WebCore 90 } // namespace WebCore
89 91
90 #endif 92 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698