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