| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #ifndef SkPDFBitmap_DEFINED | 7 #ifndef SkPDFBitmap_DEFINED |
| 8 #define SkPDFBitmap_DEFINED | 8 #define SkPDFBitmap_DEFINED |
| 9 | 9 |
| 10 #include "SkPDFTypes.h" | 10 #include "SkPDFTypes.h" |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 | 12 |
| 13 class SkPDFCanon; | 13 class SkPDFCanon; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * SkPDFBitmap wraps a SkBitmap and serializes it as an image Xobject. | 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 | 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. | 18 * the bitmap's pixels, and its emitObject() does not cache any data. |
| 19 * | 19 * |
| 20 * As of now, it only supports 8888 bitmaps (the most common case). | 20 * If !bitmap.isImmutable(), then a copy of the bitmap must be made; |
| 21 * there is no way around this. |
| 21 * | 22 * |
| 22 * The SkPDFBitmap::Create function will check the canon for duplicates. | 23 * The SkPDFBitmap::Create function will check the canon for duplicates. |
| 23 */ | 24 */ |
| 24 class SkPDFBitmap : public SkPDFObject { | 25 class SkPDFBitmap : public SkPDFObject { |
| 25 public: | 26 public: |
| 26 // Returns NULL on unsupported bitmap; | 27 // Returns NULL on unsupported bitmap; |
| 27 // TODO(halcanary): support other bitmap colortypes and replace | 28 static SkPDFBitmap* Create(SkPDFCanon*, const SkBitmap&); |
| 28 // SkPDFImage. | |
| 29 static SkPDFBitmap* Create(SkPDFCanon*, | |
| 30 const SkBitmap&, | |
| 31 const SkIRect& subset); | |
| 32 ~SkPDFBitmap(); | 29 ~SkPDFBitmap(); |
| 33 void emitObject(SkWStream*, SkPDFCatalog*) SK_OVERRIDE; | 30 void emitObject(SkWStream*, SkPDFCatalog*) SK_OVERRIDE; |
| 34 void addResources(SkTSet<SkPDFObject*>* resourceSet, | 31 void addResources(SkTSet<SkPDFObject*>* resourceSet, |
| 35 SkPDFCatalog* catalog) const SK_OVERRIDE; | 32 SkPDFCatalog* catalog) const SK_OVERRIDE; |
| 36 bool equals(const SkBitmap& other) const { | 33 bool equals(const SkBitmap& other) const { |
| 37 return fBitmap.getGenerationID() == other.getGenerationID() && | 34 return fBitmap.getGenerationID() == other.getGenerationID() && |
| 38 fBitmap.pixelRefOrigin() == other.pixelRefOrigin() && | 35 fBitmap.pixelRefOrigin() == other.pixelRefOrigin() && |
| 39 fBitmap.dimensions() == other.dimensions(); | 36 fBitmap.dimensions() == other.dimensions(); |
| 40 } | 37 } |
| 41 | 38 |
| 42 private: | 39 private: |
| 43 const SkBitmap fBitmap; | 40 const SkBitmap fBitmap; |
| 44 const SkAutoTUnref<SkPDFObject> fSMask; | 41 const SkAutoTUnref<SkPDFObject> fSMask; |
| 45 SkPDFBitmap(const SkBitmap&, SkPDFObject*); | 42 SkPDFBitmap(const SkBitmap&, SkPDFObject*); |
| 46 void emitDict(SkWStream*, SkPDFCatalog*, size_t, bool) const; | 43 void emitDict(SkWStream*, SkPDFCatalog*, size_t) const; |
| 47 }; | 44 }; |
| 48 | 45 |
| 49 #endif // SkPDFBitmap_DEFINED | 46 #endif // SkPDFBitmap_DEFINED |
| OLD | NEW |