OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkPngChunkReader_DEFINED | 8 #ifndef SkPngChunkReader_DEFINED |
9 #define SkPngChunkReader_DEFINED | 9 #define SkPngChunkReader_DEFINED |
10 | 10 |
11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
12 #include "SkRefCnt.h" | 12 #include "SkRefCnt.h" |
13 | 13 |
14 /** | 14 /** |
15 * SkPngChunkReader | 15 * SkPngChunkReader |
16 * | 16 * |
17 * Base class for optional callbacks to retrieve meta/chunk data out of a PNG | 17 * Base class for optional callbacks to retrieve meta/chunk data out of a PNG |
18 * encoded image as it is being decoded. | 18 * encoded image as it is being decoded. |
19 * Used by SkCodec. | 19 * Used by SkImageDecoder and SkCodec. |
20 */ | 20 */ |
21 class SkPngChunkReader : public SkRefCnt { | 21 class SkPngChunkReader : public SkRefCnt { |
22 public: | 22 public: |
23 /** | 23 /** |
24 * This will be called by the decoder when it sees an unknown chunk. | 24 * This will be called by the decoder when it sees an unknown chunk. |
25 * | 25 * |
26 * Use by SkCodec: | 26 * Use by SkCodec: |
27 * Depending on the location of the unknown chunks, this callback may be | 27 * Depending on the location of the unknown chunks, this callback may be |
28 * called by | 28 * called by |
29 * - the factory (NewFromStream/NewFromData) | 29 * - the factory (NewFromStream/NewFromData) |
30 * - getPixels | 30 * - getPixels |
31 * - startScanlineDecode | 31 * - startScanlineDecode |
32 * - the first call to getScanlines/skipScanlines | 32 * - the first call to getScanlines/skipScanlines |
33 * The callback may be called from a different thread (e.g. if the SkCodec | 33 * The callback may be called from a different thread (e.g. if the SkCodec |
34 * is passed to another thread), and it may be called multiple times, if | 34 * is passed to another thread), and it may be called multiple times, if |
35 * the SkCodec is used multiple times. | 35 * the SkCodec is used multiple times. |
36 * | 36 * |
37 * @param tag Name for this type of chunk. | 37 * @param tag Name for this type of chunk. |
38 * @param data Data to be interpreted by the subclass. | 38 * @param data Data to be interpreted by the subclass. |
39 * @param length Number of bytes of data in the chunk. | 39 * @param length Number of bytes of data in the chunk. |
40 * @return true to continue decoding, or false to indicate an error, which | 40 * @return true to continue decoding, or false to indicate an error, which |
41 * will cause the decoder to not return the image. | 41 * will cause the decoder to not return the image. |
42 */ | 42 */ |
43 virtual bool readChunk(const char tag[], const void* data, size_t length) =
0; | 43 virtual bool readChunk(const char tag[], const void* data, size_t length) =
0; |
44 }; | 44 }; |
45 #endif // SkPngChunkReader_DEFINED | 45 #endif // SkPngChunkReader_DEFINED |
OLD | NEW |