| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 | 7 |
| 8 #ifndef SkPDFDevice_DEFINED | 8 #ifndef SkPDFDevice_DEFINED |
| 9 #define SkPDFDevice_DEFINED | 9 #define SkPDFDevice_DEFINED |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class SkImageBitmap; | 24 class SkImageBitmap; |
| 25 class SkPath; | 25 class SkPath; |
| 26 class SkPDFArray; | 26 class SkPDFArray; |
| 27 class SkPDFCanon; | 27 class SkPDFCanon; |
| 28 class SkPDFDevice; | 28 class SkPDFDevice; |
| 29 class SkPDFDocument; | 29 class SkPDFDocument; |
| 30 class SkPDFDict; | 30 class SkPDFDict; |
| 31 class SkPDFFont; | 31 class SkPDFFont; |
| 32 class SkPDFFormXObject; | 32 class SkPDFFormXObject; |
| 33 class SkPDFGlyphSetMap; | |
| 34 class SkPDFObject; | 33 class SkPDFObject; |
| 35 class SkRRect; | 34 class SkRRect; |
| 36 | 35 |
| 37 /** \class SkPDFDevice | 36 /** \class SkPDFDevice |
| 38 | 37 |
| 39 The drawing context for the PDF backend. | 38 The drawing context for the PDF backend. |
| 40 */ | 39 */ |
| 41 class SkPDFDevice final : public SkBaseDevice { | 40 class SkPDFDevice final : public SkBaseDevice { |
| 42 public: | 41 public: |
| 43 /** Create a PDF drawing context. SkPDFDevice applies a | 42 /** Create a PDF drawing context. SkPDFDevice applies a |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 */ | 151 */ |
| 153 std::unique_ptr<SkStreamAsset> content() const; | 152 std::unique_ptr<SkStreamAsset> content() const; |
| 154 | 153 |
| 155 /** Writes the page contents to the stream. */ | 154 /** Writes the page contents to the stream. */ |
| 156 void writeContent(SkWStream*) const; | 155 void writeContent(SkWStream*) const; |
| 157 | 156 |
| 158 const SkMatrix& initialTransform() const { | 157 const SkMatrix& initialTransform() const { |
| 159 return fInitialTransform; | 158 return fInitialTransform; |
| 160 } | 159 } |
| 161 | 160 |
| 162 /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font | |
| 163 * that shows on this device. | |
| 164 */ | |
| 165 const SkPDFGlyphSetMap& getFontGlyphUsage() const { | |
| 166 return *(fFontGlyphUsage.get()); | |
| 167 } | |
| 168 | |
| 169 SkPDFCanon* getCanon() const; | 161 SkPDFCanon* getCanon() const; |
| 170 | 162 |
| 171 // It is important to not confuse GraphicStateEntry with SkPDFGraphicState,
the | 163 // It is important to not confuse GraphicStateEntry with SkPDFGraphicState,
the |
| 172 // later being our representation of an object in the PDF file. | 164 // later being our representation of an object in the PDF file. |
| 173 struct GraphicStateEntry { | 165 struct GraphicStateEntry { |
| 174 GraphicStateEntry(); | 166 GraphicStateEntry(); |
| 175 | 167 |
| 176 // Compare the fields we care about when setting up a new content entry. | 168 // Compare the fields we care about when setting up a new content entry. |
| 177 bool compareInitialState(const GraphicStateEntry& b); | 169 bool compareInitialState(const GraphicStateEntry& b); |
| 178 | 170 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 SkTDArray<SkPDFObject*> fShaderResources; | 250 SkTDArray<SkPDFObject*> fShaderResources; |
| 259 | 251 |
| 260 struct ContentEntry { | 252 struct ContentEntry { |
| 261 GraphicStateEntry fState; | 253 GraphicStateEntry fState; |
| 262 SkDynamicMemoryWStream fContent; | 254 SkDynamicMemoryWStream fContent; |
| 263 }; | 255 }; |
| 264 SkSinglyLinkedList<ContentEntry> fContentEntries; | 256 SkSinglyLinkedList<ContentEntry> fContentEntries; |
| 265 | 257 |
| 266 const SkClipStack* fClipStack; | 258 const SkClipStack* fClipStack; |
| 267 | 259 |
| 268 // Glyph ids used for each font on this device. | |
| 269 std::unique_ptr<SkPDFGlyphSetMap> fFontGlyphUsage; | |
| 270 | |
| 271 SkScalar fRasterDpi; | 260 SkScalar fRasterDpi; |
| 272 | 261 |
| 273 SkBitmap fLegacyBitmap; | 262 SkBitmap fLegacyBitmap; |
| 274 | 263 |
| 275 SkPDFDocument* fDocument; | 264 SkPDFDocument* fDocument; |
| 276 //////////////////////////////////////////////////////////////////////////// | 265 //////////////////////////////////////////////////////////////////////////// |
| 277 | 266 |
| 278 SkPDFDevice(SkISize pageSize, | 267 SkPDFDevice(SkISize pageSize, |
| 279 SkScalar rasterDpi, | 268 SkScalar rasterDpi, |
| 280 SkPDFDocument* doc, | 269 SkPDFDocument* doc, |
| 281 bool flip); | 270 bool flip); |
| 282 | 271 |
| 283 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 272 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
| 284 | 273 |
| 285 void init(); | 274 void init(); |
| 286 void cleanUp(bool clearFontUsage); | 275 void cleanUp(); |
| 287 SkPDFFormXObject* createFormXObjectFromDevice(); | 276 SkPDFFormXObject* createFormXObjectFromDevice(); |
| 288 | 277 |
| 289 void drawFormXObjectWithMask(int xObjectIndex, | 278 void drawFormXObjectWithMask(int xObjectIndex, |
| 290 SkPDFFormXObject* mask, | 279 SkPDFFormXObject* mask, |
| 291 const SkClipStack* clipStack, | 280 const SkClipStack* clipStack, |
| 292 const SkRegion& clipRegion, | 281 const SkRegion& clipRegion, |
| 293 SkXfermode::Mode mode, | 282 SkXfermode::Mode mode, |
| 294 bool invertClip); | 283 bool invertClip); |
| 295 | 284 |
| 296 // If the paint or clip is such that we shouldn't draw anything, this | 285 // If the paint or clip is such that we shouldn't draw anything, this |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 325 |
| 337 typedef SkBaseDevice INHERITED; | 326 typedef SkBaseDevice INHERITED; |
| 338 | 327 |
| 339 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create | 328 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create |
| 340 // an SkPDFDevice | 329 // an SkPDFDevice |
| 341 //friend class SkDocument_PDF; | 330 //friend class SkDocument_PDF; |
| 342 //friend class SkPDFImageShader; | 331 //friend class SkPDFImageShader; |
| 343 }; | 332 }; |
| 344 | 333 |
| 345 #endif | 334 #endif |
| OLD | NEW |