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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/png/PNGImageDecoder.h

Issue 2386453003: WIP: Implement APNG (Closed)
Patch Set: Implemented feedback on patch set 9 Created 4 years, 1 month 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 /* 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 25 matching lines...) Expand all
36 class PLATFORM_EXPORT PNGImageDecoder final : public ImageDecoder { 36 class PLATFORM_EXPORT PNGImageDecoder final : public ImageDecoder {
37 WTF_MAKE_NONCOPYABLE(PNGImageDecoder); 37 WTF_MAKE_NONCOPYABLE(PNGImageDecoder);
38 38
39 public: 39 public:
40 PNGImageDecoder(AlphaOption, 40 PNGImageDecoder(AlphaOption,
41 ColorSpaceOption, 41 ColorSpaceOption,
42 size_t maxDecodedBytes, 42 size_t maxDecodedBytes,
43 size_t offset = 0); 43 size_t offset = 0);
44 ~PNGImageDecoder() override; 44 ~PNGImageDecoder() override;
45 45
46 enum class PNGParseQuery { PNGSizeQuery, PNGMetaDataQuery };
47
46 // ImageDecoder: 48 // ImageDecoder:
47 String filenameExtension() const override { return "png"; } 49 String filenameExtension() const override { return "png"; }
50 int repetitionCount() const override;
51 bool frameIsCompleteAtIndex(size_t) const override;
52 float frameDurationAtIndex(size_t) const override;
48 53
49 // Callbacks from libpng 54 // Callbacks from libpng
50 void headerAvailable(); 55 void headerAvailable();
51 void rowAvailable(unsigned char* row, unsigned rowIndex, int); 56 void rowAvailable(unsigned char* row, unsigned rowIndex, int);
52 void complete(); 57 void complete();
53 58
59 // Additional methods used for APNG
60 void setRepetitionCount(size_t);
61 // This is called by PNGImageReader when it encounters the IEND chunk
62 // while parsing PNGMetaDataQuery. If m_metaDataDecoded is true, the decoder
63 // does not need to query for meta data again.
64 void setMetaDataDecoded() { m_metaDataDecoded = true; };
65
54 private: 66 private:
55 // ImageDecoder: 67 // ImageDecoder:
56 void decodeSize() override { decode(true); } 68 void decodeSize() override { parse(PNGParseQuery::PNGSizeQuery); }
57 void decode(size_t) override { decode(false); } 69 void decode(size_t) override;
70 size_t decodeFrameCount() override;
71 void initializeNewFrame(size_t) override;
58 72
59 // Decodes the image. If |onlySize| is true, stops decoding after 73 void parse(PNGParseQuery);
60 // calculating the image size. If decoding fails but there is no more
61 // data coming, sets the "decode failure" flag.
62 void decode(bool onlySize);
63 74
64 std::unique_ptr<PNGImageReader> m_reader; 75 std::unique_ptr<PNGImageReader> m_reader;
65 const unsigned m_offset; 76 const unsigned m_offset;
77 bool m_metaDataDecoded;
78 size_t m_frameCount;
79 size_t m_currentFrame;
80 // m_repetitionCount is set to cAnimationLoopOnce by default, so the
81 // DeferredImageDecoder takes into account that this may be an animated
82 // image, but we don't know for sure yet.
83 int m_repetitionCount;
66 }; 84 };
67 85
68 } // namespace blink 86 } // namespace blink
69 87
70 #endif 88 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698