Index: src/pdf/SkPDFBitmap.h |
diff --git a/src/pdf/SkPDFBitmap.h b/src/pdf/SkPDFBitmap.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a522112f8ce0ae224891e559dc1b607e7a582a30 |
--- /dev/null |
+++ b/src/pdf/SkPDFBitmap.h |
@@ -0,0 +1,45 @@ |
+/* |
+ * Copyright 2015 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+#ifndef SkPDFBitmap_DEFINED |
+#define SkPDFBitmap_DEFINED |
+ |
+#include "SkPDFTypes.h" |
+#include "SkBitmap.h" |
+ |
+/** |
+ * This is a replacement for SkPDFImage. As of now, it only supports |
mtklein
2015/02/12 00:21:46
Let's write this comment first as if SkPDFImage di
hal.canary
2015/02/12 21:28:03
Done.
|
+ * 8888 bitmaps (the most common case). This onbect takes very little |
mtklein
2015/02/12 00:21:46
object
|
+ * extra memory (aside from refing the bitmap's pixels), and its |
+ * emitObject() does not cache any data. |
+ * |
+ * The SkPDFBitmap::Create function will check the canon for duplicates. |
+ */ |
+class SkPDFBitmap : public SkPDFObject { |
+public: |
+ // Returns NULL on unsupported bitmap; |
+ // TODO(halcanary): support other bitmap colortypes and replace |
+ // SkPDFImage. |
+ static SkPDFBitmap* Create(const SkBitmap&, |
+ const SkIRect& subset); |
mtklein
2015/02/12 00:21:46
Does passing a subset here have any different effe
hal.canary
2015/02/12 21:28:03
It's only here to match the calling site.
|
+ ~SkPDFBitmap(); |
+ void emitObject(SkWStream*, SkPDFCatalog*) SK_OVERRIDE; |
+ void addResources(SkTSet<SkPDFObject*>* resourceSet, |
+ SkPDFCatalog* catalog) const SK_OVERRIDE; |
+ bool equals(const SkBitmap& other) const { |
+ return fBitmap.getGenerationID() == other.getGenerationID() && |
+ fBitmap.pixelRefOrigin() == other.pixelRefOrigin() && |
+ fBitmap.dimensions() == other.dimensions() && !fIsAlpha; |
mtklein
2015/02/12 00:21:46
What's the deal with && !fIsAlpha? That deserves
hal.canary
2015/02/12 21:28:03
When IsAlpha is true, the SkPDFBitmap represents t
|
+ } |
+ |
+private: |
+ SkBitmap fBitmap; |
+ SkAutoTUnref<SkPDFBitmap> fSMask; |
+ bool fIsAlpha; |
+ SkPDFBitmap(const SkBitmap&, bool isAlpha, SkPDFBitmap* smask); |
+}; |
+ |
+#endif // SkPDFBitmap_DEFINED |