| 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 SkPDFCanon_DEFINED | 7 #ifndef SkPDFCanon_DEFINED |
| 8 #define SkPDFCanon_DEFINED | 8 #define SkPDFCanon_DEFINED |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 * SkPDFCanon. | 42 * SkPDFCanon. |
| 43 * | 43 * |
| 44 * The addFoo() methods will ref the Foo; the canon's destructor will | 44 * The addFoo() methods will ref the Foo; the canon's destructor will |
| 45 * call foo->unref() on all of these objects. | 45 * call foo->unref() on all of these objects. |
| 46 * | 46 * |
| 47 * The findFoo() methods do not change the ref count of the Foo | 47 * The findFoo() methods do not change the ref count of the Foo |
| 48 * objects. | 48 * objects. |
| 49 */ | 49 */ |
| 50 class SkPDFCanon : SkNoncopyable { | 50 class SkPDFCanon : SkNoncopyable { |
| 51 public: | 51 public: |
| 52 SkPDFCanon() : fEncoder(nullptr) {} |
| 52 ~SkPDFCanon() { this->reset(); } | 53 ~SkPDFCanon() { this->reset(); } |
| 53 | 54 |
| 54 // reset to original setting, unrefs all objects. | 55 // reset to original setting, unrefs all objects. |
| 55 void reset(); | 56 void reset(); |
| 56 | 57 |
| 57 // Returns exact match if there is one. If not, it returns nullptr. | 58 // Returns exact match if there is one. If not, it returns nullptr. |
| 58 // If there is no exact match, but there is a related font, we | 59 // If there is no exact match, but there is a related font, we |
| 59 // still return nullptr, but also set *relatedFont. | 60 // still return nullptr, but also set *relatedFont. |
| 60 SkPDFFont* findFont(uint32_t fontID, | 61 SkPDFFont* findFont(uint32_t fontID, |
| 61 uint16_t glyphID, | 62 uint16_t glyphID, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 | 74 |
| 74 const SkPDFGraphicState* findGraphicState(const SkPDFGraphicState&) const; | 75 const SkPDFGraphicState* findGraphicState(const SkPDFGraphicState&) const; |
| 75 void addGraphicState(const SkPDFGraphicState*); | 76 void addGraphicState(const SkPDFGraphicState*); |
| 76 | 77 |
| 77 SkPDFObject* findPDFBitmap(const SkImage* image) const; | 78 SkPDFObject* findPDFBitmap(const SkImage* image) const; |
| 78 void addPDFBitmap(uint32_t imageUniqueID, SkPDFObject*); | 79 void addPDFBitmap(uint32_t imageUniqueID, SkPDFObject*); |
| 79 const SkImage* bitmapToImage(const SkBitmap&); | 80 const SkImage* bitmapToImage(const SkBitmap&); |
| 80 | 81 |
| 81 SkTHashMap<uint32_t, bool> fCanEmbedTypeface; | 82 SkTHashMap<uint32_t, bool> fCanEmbedTypeface; |
| 82 | 83 |
| 84 SkData* (*fEncoder)(const SkPixmap&); |
| 85 |
| 83 private: | 86 private: |
| 84 struct FontRec { | 87 struct FontRec { |
| 85 SkPDFFont* fFont; | 88 SkPDFFont* fFont; |
| 86 uint32_t fFontID; | 89 uint32_t fFontID; |
| 87 uint16_t fGlyphID; | 90 uint16_t fGlyphID; |
| 88 }; | 91 }; |
| 89 SkTDArray<FontRec> fFontRecords; | 92 SkTDArray<FontRec> fFontRecords; |
| 90 | 93 |
| 91 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords; | 94 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords; |
| 92 | 95 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 108 return w.fPtr->hash(); | 111 return w.fPtr->hash(); |
| 109 } | 112 } |
| 110 }; | 113 }; |
| 111 }; | 114 }; |
| 112 SkTHashSet<WrapGS, WrapGS::Hash> fGraphicStateRecords; | 115 SkTHashSet<WrapGS, WrapGS::Hash> fGraphicStateRecords; |
| 113 | 116 |
| 114 SkTHashMap<SkBitmapKey, const SkImage*> fBitmapToImageMap; | 117 SkTHashMap<SkBitmapKey, const SkImage*> fBitmapToImageMap; |
| 115 SkTHashMap<uint32_t /*ImageUniqueID*/, SkPDFObject*> fPDFBitmapMap; | 118 SkTHashMap<uint32_t /*ImageUniqueID*/, SkPDFObject*> fPDFBitmapMap; |
| 116 }; | 119 }; |
| 117 #endif // SkPDFCanon_DEFINED | 120 #endif // SkPDFCanon_DEFINED |
| OLD | NEW |