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

Unified Diff: src/codec/SkPngCodec.h

Issue 2277903002: SkPngCodec: voidp instead of forward-declares for png.h types. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkPngCodec.h
diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h
index 7bb833d10d836fc45f7663b1c1af92063306f2e8..e4df8230766a53f6928a3f750fb6044e28674f14 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.
« no previous file with comments | « no previous file | src/codec/SkPngCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698