| 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 "SkDevice.h" | 15 #include "SkDevice.h" |
| 15 #include "SkPaint.h" | 16 #include "SkPaint.h" |
| 16 #include "SkPath.h" | 17 #include "SkPath.h" |
| 17 #include "SkPicture.h" | 18 #include "SkPicture.h" |
| 18 #include "SkRect.h" | 19 #include "SkRect.h" |
| 19 #include "SkRefCnt.h" | 20 #include "SkRefCnt.h" |
| 20 #include "SkStream.h" | 21 #include "SkStream.h" |
| 21 #include "SkTDArray.h" | 22 #include "SkTDArray.h" |
| 22 #include "SkTemplates.h" | 23 #include "SkTemplates.h" |
| 23 | 24 |
| 24 class SkPDFArray; | 25 class SkPDFArray; |
| 25 class SkPDFCanon; | 26 class SkPDFCanon; |
| 26 class SkPDFDevice; | 27 class SkPDFDevice; |
| 27 class SkPDFDict; | 28 class SkPDFDict; |
| 28 class SkPDFFont; | 29 class SkPDFFont; |
| 29 class SkPDFFormXObject; | 30 class SkPDFFormXObject; |
| 30 class SkPDFGlyphSetMap; | 31 class SkPDFGlyphSetMap; |
| 31 class SkPDFGraphicState; | 32 class SkPDFGraphicState; |
| 32 class SkPDFObject; | 33 class SkPDFObject; |
| 33 class SkPDFShader; | 34 class SkPDFShader; |
| 34 class SkPDFStream; | 35 class SkPDFStream; |
| 35 class SkRRect; | 36 class SkRRect; |
| 36 | 37 |
| 37 // Private classes. | 38 // Private classes. |
| 38 struct ContentEntry; | 39 struct ContentEntry; |
| 39 struct GraphicStateEntry; | 40 struct GraphicStateEntry; |
| 40 struct NamedDestination; | |
| 41 struct RectWithData; | |
| 42 | 41 |
| 43 /** \class SkPDFDevice | 42 /** \class SkPDFDevice |
| 44 | 43 |
| 45 The drawing context for the PDF backend. | 44 The drawing context for the PDF backend. |
| 46 */ | 45 */ |
| 47 class SkPDFDevice final : public SkBaseDevice { | 46 class SkPDFDevice final : public SkBaseDevice { |
| 48 public: | 47 public: |
| 49 /** Create a PDF drawing context. SkPDFDevice applies a | 48 /** Create a PDF drawing context. SkPDFDevice applies a |
| 50 * scale-and-translate transform to move the origin from the | 49 * scale-and-translate transform to move the origin from the |
| 51 * bottom left (PDF default) to the top left (Skia default). | 50 * bottom left (PDF default) to the top left (Skia default). |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 SkPDFCanon* getCanon() const { return fCanon; } | 191 SkPDFCanon* getCanon() const { return fCanon; } |
| 193 | 192 |
| 194 protected: | 193 protected: |
| 195 const SkBitmap& onAccessBitmap() override { | 194 const SkBitmap& onAccessBitmap() override { |
| 196 return fLegacyBitmap; | 195 return fLegacyBitmap; |
| 197 } | 196 } |
| 198 | 197 |
| 199 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; | 198 SkSurface* newSurface(const SkImageInfo&, const SkSurfaceProps&) override; |
| 200 | 199 |
| 201 private: | 200 private: |
| 201 struct RectWithData { |
| 202 SkRect rect; |
| 203 SkData* data; |
| 204 RectWithData(const SkRect& rect, SkData* data) |
| 205 : rect(rect), data(SkRef(data)) {} |
| 206 ~RectWithData() { data->unref(); } |
| 207 }; |
| 208 |
| 209 struct NamedDestination { |
| 210 SkData* nameData; |
| 211 SkPoint point; |
| 212 NamedDestination(SkData* nameData, const SkPoint& point) |
| 213 : nameData(SkRef(nameData)), point(point) {} |
| 214 ~NamedDestination() { nameData->unref(); } |
| 215 }; |
| 216 |
| 202 // TODO(vandebo): push most of SkPDFDevice's state into a core object in | 217 // TODO(vandebo): push most of SkPDFDevice's state into a core object in |
| 203 // order to get the right access levels without using friend. | 218 // order to get the right access levels without using friend. |
| 204 friend class ScopedContentEntry; | 219 friend class ScopedContentEntry; |
| 205 | 220 |
| 206 SkISize fPageSize; | 221 SkISize fPageSize; |
| 207 SkISize fContentSize; | 222 SkISize fContentSize; |
| 208 SkMatrix fInitialTransform; | 223 SkMatrix fInitialTransform; |
| 209 SkClipStack fExistingClipStack; | 224 SkClipStack fExistingClipStack; |
| 210 SkRegion fExistingClipRegion; | 225 SkRegion fExistingClipRegion; |
| 211 | 226 |
| 212 SkTDArray<RectWithData*> fLinkToURLs; | 227 SkTArray<RectWithData> fLinkToURLs; |
| 213 SkTDArray<RectWithData*> fLinkToDestinations; | 228 SkTArray<RectWithData> fLinkToDestinations; |
| 214 SkTDArray<NamedDestination*> fNamedDestinations; | 229 SkTArray<NamedDestination> fNamedDestinations; |
| 215 | 230 |
| 216 SkTDArray<SkPDFObject*> fGraphicStateResources; | 231 SkTDArray<SkPDFObject*> fGraphicStateResources; |
| 217 SkTDArray<SkPDFObject*> fXObjectResources; | 232 SkTDArray<SkPDFObject*> fXObjectResources; |
| 218 SkTDArray<SkPDFFont*> fFontResources; | 233 SkTDArray<SkPDFFont*> fFontResources; |
| 219 SkTDArray<SkPDFObject*> fShaderResources; | 234 SkTDArray<SkPDFObject*> fShaderResources; |
| 220 | 235 |
| 221 SkAutoTDelete<ContentEntry> fContentEntries; | 236 SkAutoTDelete<ContentEntry> fContentEntries; |
| 222 ContentEntry* fLastContentEntry; | 237 ContentEntry* fLastContentEntry; |
| 223 SkAutoTDelete<ContentEntry> fMarginContentEntries; | 238 SkAutoTDelete<ContentEntry> fMarginContentEntries; |
| 224 ContentEntry* fLastMarginContentEntry; | 239 ContentEntry* fLastMarginContentEntry; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 325 |
| 311 typedef SkBaseDevice INHERITED; | 326 typedef SkBaseDevice INHERITED; |
| 312 | 327 |
| 313 // 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 |
| 314 // an SkPDFDevice | 329 // an SkPDFDevice |
| 315 //friend class SkDocument_PDF; | 330 //friend class SkDocument_PDF; |
| 316 //friend class SkPDFImageShader; | 331 //friend class SkPDFImageShader; |
| 317 }; | 332 }; |
| 318 | 333 |
| 319 #endif | 334 #endif |
| OLD | NEW |