2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 #ifndef SkPDFBitmap_DEFINED
8 #define SkPDFBitmap_DEFINED
10 #include "SkPDFTypes.h"
16 * SkPDFBitmap wraps a SkBitmap and serializes it as an image Xobject.
17 * It is designed to use a minimal amout of memory, aside from refing
18 * the bitmap's pixels, and its emitObject() does not cache any data.
20 * If !bitmap.isImmutable(), then a copy of the bitmap must be made;
21 * there is no way around this.
23 * The SkPDFBitmap::Create function will check the canon for duplicates.
25 class SkPDFBitmap : public SkPDFObject {
27 // Returns NULL on unsupported bitmap;
28 static SkPDFBitmap* Create(SkPDFCanon*, const SkBitmap&);
30 void emitObject(SkWStream*, SkPDFCatalog*) override;
31 void addResources(SkPDFCatalog*) const override;
32 bool equals(const SkBitmap& other) const {
33 return fBitmap.getGenerationID() == other.getGenerationID() &&
34 fBitmap.pixelRefOrigin() == other.pixelRefOrigin() &&
35 fBitmap.dimensions() == other.dimensions();
39 const SkBitmap fBitmap;
40 const SkAutoTUnref<SkPDFObject> fSMask;
41 SkPDFBitmap(const SkBitmap&, SkPDFObject*);
42 void emitDict(SkWStream*, SkPDFCatalog*, size_t) const;
45 #endif // SkPDFBitmap_DEFINED