aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkPngCodec.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-08-24 12:22:32 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-24 12:22:32 -0700
commit6dc5b9a9b79b9d71e772c47a4346fde31f3e7bfb (patch)
tree2903dd2744294f09f2609d76d75c0e6a857645ec /src/codec/SkPngCodec.h
parent8c99eabdd92d4fbdbcb74e979b527cdbf066b138 (diff)
SkPngCodec: voidp instead of forward-declares for png.h types.
Diffstat (limited to 'src/codec/SkPngCodec.h')
-rw-r--r--src/codec/SkPngCodec.h27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h
index 7bb833d10d..e4df823076 100644
--- a/src/codec/SkPngCodec.h
+++ b/src/codec/SkPngCodec.h
@@ -14,12 +14,6 @@
#include "SkRefCnt.h"
#include "SkSwizzler.h"
-// Instead of including png.h here, forward declare the few types we refer to.
-struct png_struct_def;
-struct png_info_def;
-typedef png_struct_def png_struct;
-typedef png_info_def png_info;
-
class SkStream;
class SkPngCodec : public SkCodec {
@@ -32,6 +26,19 @@ public:
virtual ~SkPngCodec();
protected:
+ // We hold the png_ptr and info_ptr as voidp to avoid having to include png.h
+ // or forward declare their types here. voidp auto-casts to the real pointer types.
+ struct voidp {
+ voidp(void* ptr) : fPtr(ptr) {}
+
+ template <typename T>
+ operator T*() const { return (T*)fPtr; }
+
+ explicit operator bool() const { return fPtr != nullptr; }
+
+ void* fPtr;
+ };
+
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*, int*)
override;
SkEncodedFormat onGetEncodedFormat() const override { return kPNG_SkEncodedFormat; }
@@ -51,11 +58,11 @@ protected:
int startRow) = 0;
SkPngCodec(const SkEncodedInfo&, const SkImageInfo&, SkStream*, SkPngChunkReader*,
- png_struct*, png_info*, int, int);
+ void* png_ptr, void* info_ptr, int, int);
- SkAutoTUnref<SkPngChunkReader> fPngChunkReader;
- png_struct* fPng_ptr;
- png_info* fInfo_ptr;
+ SkAutoTUnref<SkPngChunkReader> fPngChunkReader;
+ voidp fPng_ptr;
+ voidp fInfo_ptr;
// These are stored here so they can be used both by normal decoding and scanline decoding.
SkAutoTUnref<SkColorTable> fColorTable; // May be unpremul.