Chromium Code Reviews| 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 |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 13 #include "SkClipStack.h" | 13 #include "SkClipStack.h" |
| 14 #include "SkData.h" | 14 #include "SkData.h" |
| 15 #include "SkDevice.h" | 15 #include "SkDevice.h" |
| 16 #include "SkPaint.h" | 16 #include "SkPaint.h" |
| 17 #include "SkPath.h" | 17 #include "SkPath.h" |
| 18 #include "SkPicture.h" | 18 #include "SkPicture.h" |
| 19 #include "SkRect.h" | 19 #include "SkRect.h" |
| 20 #include "SkRefCnt.h" | 20 #include "SkRefCnt.h" |
| 21 #include "SkStream.h" | 21 #include "SkStream.h" |
| 22 #include "SkTDArray.h" | 22 #include "SkTDArray.h" |
| 23 #include "SkTemplates.h" | 23 #include "SkTemplates.h" |
| 24 | 24 |
| 25 class SkPDFArray; | 25 class SkPDFArray; |
| 26 class SkPDFCanon; | 26 class SkPDFCanon; |
| 27 class SkPDFDevice; | 27 class SkPDFDevice; |
| 28 class SkPDFDocument; | |
| 28 class SkPDFDict; | 29 class SkPDFDict; |
| 29 class SkPDFFont; | 30 class SkPDFFont; |
| 30 class SkPDFFormXObject; | 31 class SkPDFFormXObject; |
| 31 class SkPDFGlyphSetMap; | 32 class SkPDFGlyphSetMap; |
| 32 class SkPDFGraphicState; | 33 class SkPDFGraphicState; |
| 33 class SkPDFObject; | 34 class SkPDFObject; |
| 34 class SkPDFShader; | 35 class SkPDFShader; |
| 35 class SkPDFStream; | 36 class SkPDFStream; |
| 36 class SkRRect; | 37 class SkRRect; |
| 37 | 38 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 52 * 1 point == 127/360 mm == 1/72 inch | 53 * 1 point == 127/360 mm == 1/72 inch |
| 53 * @param rasterDpi the DPI at which features without native PDF | 54 * @param rasterDpi the DPI at which features without native PDF |
| 54 * support will be rasterized (e.g. draw image with | 55 * support will be rasterized (e.g. draw image with |
| 55 * perspective, draw text with perspective, ...). A | 56 * perspective, draw text with perspective, ...). A |
| 56 * larger DPI would create a PDF that reflects the | 57 * larger DPI would create a PDF that reflects the |
| 57 * original intent with better fidelity, but it can make | 58 * original intent with better fidelity, but it can make |
| 58 * for larger PDF files too, which would use more memory | 59 * for larger PDF files too, which would use more memory |
| 59 * while rendering, and it would be slower to be processed | 60 * while rendering, and it would be slower to be processed |
| 60 * or sent online or to printer. A good choice is | 61 * or sent online or to printer. A good choice is |
| 61 * SK_ScalarDefaultRasterDPI(72.0f). | 62 * SK_ScalarDefaultRasterDPI(72.0f). |
| 62 * @param SkPDFCanon. Should be non-null, and shared by all | 63 * @param SkPDFDocument. Should be non-null, and shared by all |
| 63 * devices in a document. | 64 * devices in a document. |
|
tomhudson
2016/03/21 14:49:48
This comment doesn't explain to me why. In the old
hal.canary
2016/03/21 21:06:02
better?
@param SkPDFDocument. A non-null pointer
tomhudson
2016/03/21 21:09:56
Yes, thanks.
| |
| 64 */ | 65 */ |
| 65 static SkPDFDevice* Create(SkISize pageSize, | 66 static SkPDFDevice* Create(SkISize pageSize, |
| 66 SkScalar rasterDpi, | 67 SkScalar rasterDpi, |
| 67 SkPDFCanon* canon) { | 68 SkPDFDocument* doc) { |
| 68 return new SkPDFDevice(pageSize, rasterDpi, canon, true); | 69 return new SkPDFDevice(pageSize, rasterDpi, doc, true); |
| 69 } | 70 } |
| 70 | 71 |
| 71 /** Create a PDF drawing context without fipping the y-axis. */ | 72 /** Create a PDF drawing context without fipping the y-axis. */ |
| 72 static SkPDFDevice* CreateUnflipped(SkISize pageSize, | 73 static SkPDFDevice* CreateUnflipped(SkISize pageSize, |
| 73 SkScalar rasterDpi, | 74 SkScalar rasterDpi, |
| 74 SkPDFCanon* canon) { | 75 SkPDFDocument* doc) { |
| 75 return new SkPDFDevice(pageSize, rasterDpi, canon, false); | 76 return new SkPDFDevice(pageSize, rasterDpi, doc, false); |
| 76 } | 77 } |
| 77 | 78 |
| 78 virtual ~SkPDFDevice(); | 79 virtual ~SkPDFDevice(); |
| 79 | 80 |
| 80 /** These are called inside the per-device-layer loop for each draw call. | 81 /** These are called inside the per-device-layer loop for each draw call. |
| 81 When these are called, we have already applied any saveLayer operations, | 82 When these are called, we have already applied any saveLayer operations, |
| 82 and are handling any looping from the paint, and any effects from the | 83 and are handling any looping from the paint, and any effects from the |
| 83 DrawFilter. | 84 DrawFilter. |
| 84 */ | 85 */ |
| 85 void drawPaint(const SkDraw&, const SkPaint& paint) override; | 86 void drawPaint(const SkDraw&, const SkPaint& paint) override; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 return fInitialTransform; | 178 return fInitialTransform; |
| 178 } | 179 } |
| 179 | 180 |
| 180 /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font | 181 /** Returns a SkPDFGlyphSetMap which represents glyph usage of every font |
| 181 * that shows on this device. | 182 * that shows on this device. |
| 182 */ | 183 */ |
| 183 const SkPDFGlyphSetMap& getFontGlyphUsage() const { | 184 const SkPDFGlyphSetMap& getFontGlyphUsage() const { |
| 184 return *(fFontGlyphUsage.get()); | 185 return *(fFontGlyphUsage.get()); |
| 185 } | 186 } |
| 186 | 187 |
| 187 SkPDFCanon* getCanon() const { return fCanon; } | 188 SkPDFCanon* getCanon() const; |
| 188 | 189 |
| 189 protected: | 190 protected: |
| 190 const SkBitmap& onAccessBitmap() override { | 191 const SkBitmap& onAccessBitmap() override { |
| 191 return fLegacyBitmap; | 192 return fLegacyBitmap; |
| 192 } | 193 } |
| 193 | 194 |
| 194 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; | 195 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
| 195 | 196 |
| 196 void drawAnnotation(const SkDraw&, const SkRect&, const char key[], SkData* value) override; | 197 void drawAnnotation(const SkDraw&, const SkRect&, const char key[], SkData* value) override; |
| 197 | 198 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // Accessor and setter functions based on the current DrawingArea. | 255 // Accessor and setter functions based on the current DrawingArea. |
| 255 SkAutoTDelete<ContentEntry>* getContentEntries(); | 256 SkAutoTDelete<ContentEntry>* getContentEntries(); |
| 256 | 257 |
| 257 // Glyph ids used for each font on this device. | 258 // Glyph ids used for each font on this device. |
| 258 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; | 259 SkAutoTDelete<SkPDFGlyphSetMap> fFontGlyphUsage; |
| 259 | 260 |
| 260 SkScalar fRasterDpi; | 261 SkScalar fRasterDpi; |
| 261 | 262 |
| 262 SkBitmap fLegacyBitmap; | 263 SkBitmap fLegacyBitmap; |
| 263 | 264 |
| 264 SkPDFCanon* fCanon; // Owned by SkDocument_PDF | 265 SkPDFDocument* fDocument; |
| 265 //////////////////////////////////////////////////////////////////////////// | 266 //////////////////////////////////////////////////////////////////////////// |
| 266 | 267 |
| 267 SkPDFDevice(SkISize pageSize, | 268 SkPDFDevice(SkISize pageSize, |
| 268 SkScalar rasterDpi, | 269 SkScalar rasterDpi, |
| 269 SkPDFCanon* canon, | 270 SkPDFDocument* doc, |
| 270 bool flip); | 271 bool flip); |
| 271 | 272 |
| 272 ContentEntry* getLastContentEntry(); | 273 ContentEntry* getLastContentEntry(); |
| 273 void setLastContentEntry(ContentEntry* contentEntry); | 274 void setLastContentEntry(ContentEntry* contentEntry); |
| 274 | 275 |
| 275 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; | 276 SkBaseDevice* onCreateDevice(const CreateInfo&, const SkPaint*) override; |
| 276 | 277 |
| 277 void init(); | 278 void init(); |
| 278 void cleanUp(bool clearFontUsage); | 279 void cleanUp(bool clearFontUsage); |
| 279 SkPDFFormXObject* createFormXObjectFromDevice(); | 280 SkPDFFormXObject* createFormXObjectFromDevice(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 | 334 |
| 334 typedef SkBaseDevice INHERITED; | 335 typedef SkBaseDevice INHERITED; |
| 335 | 336 |
| 336 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create | 337 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create |
| 337 // an SkPDFDevice | 338 // an SkPDFDevice |
| 338 //friend class SkDocument_PDF; | 339 //friend class SkDocument_PDF; |
| 339 //friend class SkPDFImageShader; | 340 //friend class SkPDFImageShader; |
| 340 }; | 341 }; |
| 341 | 342 |
| 342 #endif | 343 #endif |
| OLD | NEW |