SkPngChunkReader.h 1.5 KB

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