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

Unified Diff: src/pdf/SkPDFBitmap.h

Issue 918813002: PDF: Add (low-memory) SkPDFBitmap class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mutable bitmaps get copied Created 5 years, 10 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 | « src/pdf/SkDeflateWStream.cpp ('k') | src/pdf/SkPDFBitmap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFBitmap.h
diff --git a/src/pdf/SkPDFBitmap.h b/src/pdf/SkPDFBitmap.h
new file mode 100644
index 0000000000000000000000000000000000000000..922db8f1c10d0fd276e40d74dab585dfab67a92f
--- /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"
+
+/**
+ * SkPDFBitmap wraps a SkBitmap and serializes it as an image Xobject.
+ * It is designed to use a minimal amout of memory, aside from refing
+ * the bitmap's pixels, and its emitObject() does not cache any data.
+ *
+ * As of now, it only supports 8888 bitmaps (the most common case).
+ *
+ * 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);
+ ~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();
+ }
+
+private:
+ const SkBitmap fBitmap;
+ const SkAutoTUnref<SkPDFObject> fSMask;
+ SkPDFBitmap(const SkBitmap&, SkPDFObject*);
+ void emitDict(SkWStream*, SkPDFCatalog*, size_t, bool) const;
+};
+
+#endif // SkPDFBitmap_DEFINED
« no previous file with comments | « src/pdf/SkDeflateWStream.cpp ('k') | src/pdf/SkPDFBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698