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

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

Issue 2386453003: WIP: Implement APNG (Closed)
Patch Set: Extra tests for invalid images; new image for animation tests Created 4 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
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 21 matching lines...) Expand all
32 namespace blink { 32 namespace blink {
33 33
34 class PNGImageReader; 34 class PNGImageReader;
35 35
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 public: 38 public:
39 PNGImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBy tes, size_t offset = 0); 39 PNGImageDecoder(AlphaOption, GammaAndColorProfileOption, size_t maxDecodedBy tes, size_t offset = 0);
40 ~PNGImageDecoder() override; 40 ~PNGImageDecoder() override;
41 41
42 enum class PNGParseQuery { PNGSizeQuery, PNGMetaDataQuery };
43
42 // ImageDecoder: 44 // ImageDecoder:
43 String filenameExtension() const override { return "png"; } 45 String filenameExtension() const override { return "png"; }
46 int repetitionCount() const override;
44 47
45 // Callbacks from libpng 48 // Callbacks from libpng
46 void headerAvailable(); 49 void headerAvailable();
47 void rowAvailable(unsigned char* row, unsigned rowIndex, int); 50 void rowAvailable(unsigned char* row, unsigned rowIndex, int);
48 void complete(); 51 void complete();
49 52
53 // Additional methods used for APNG
54 void setRepetitionCount(size_t);
55 // This is called by PNGImageReader when it encounters the IEND chunk
56 // while parsing PNGMetaDataQuery. If m_metaDataDecoded is true, the decoder
57 // does not need to query for meta data again.
58 void setMetaDataDecoded() { m_metaDataDecoded = true; };
cblume 2016/10/15 00:30:50 These two methods are public because they get call
scroggo_chromium 2016/10/17 13:24:00 A similar suggestion came up crrev.com/2045293002
cblume 2016/10/17 17:08:16 Okay, I agree. I definitely agree that I dislike
59
50 private: 60 private:
51 // ImageDecoder: 61 // ImageDecoder:
52 void decodeSize() override { decode(true); } 62 void decodeSize() override { parse(PNGParseQuery::PNGSizeQuery); }
53 void decode(size_t) override { decode(false); } 63 void decode(size_t) override;
64 size_t decodeFrameCount() override;
65 void initializeNewFrame(size_t) override;
54 66
55 // Decodes the image. If |onlySize| is true, stops decoding after 67 void parse(PNGParseQuery);
56 // calculating the image size. If decoding fails but there is no more
57 // data coming, sets the "decode failure" flag.
58 void decode(bool onlySize);
59 68
60 std::unique_ptr<PNGImageReader> m_reader; 69 std::unique_ptr<PNGImageReader> m_reader;
61 const unsigned m_offset; 70 const unsigned m_offset;
71 bool m_metaDataDecoded;
72 size_t m_frameCount;
73 int m_repetitionCount;
62 }; 74 };
63 75
64 } // namespace blink 76 } // namespace blink
65 77
66 #endif 78 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698