| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #ifndef SkPDFDevice_DEFINED | 10 #ifndef SkPDFDevice_DEFINED |
| 11 #define SkPDFDevice_DEFINED | 11 #define SkPDFDevice_DEFINED |
| 12 | 12 |
| 13 #include "SkBitmapDevice.h" | 13 #include "SkBitmapDevice.h" |
| 14 #include "SkBitmap.h" |
| 14 #include "SkCanvas.h" | 15 #include "SkCanvas.h" |
| 15 #include "SkPaint.h" | 16 #include "SkPaint.h" |
| 16 #include "SkPath.h" | 17 #include "SkPath.h" |
| 18 #include "SkPDFCallbacks.h" |
| 17 #include "SkRect.h" | 19 #include "SkRect.h" |
| 18 #include "SkRefCnt.h" | 20 #include "SkRefCnt.h" |
| 19 #include "SkStream.h" | 21 #include "SkStream.h" |
| 20 #include "SkTDArray.h" | 22 #include "SkTDArray.h" |
| 21 #include "SkTemplates.h" | 23 #include "SkTemplates.h" |
| 22 | 24 |
| 25 class CanvasTestStep; |
| 23 class SkPDFArray; | 26 class SkPDFArray; |
| 24 class SkPDFDevice; | 27 class SkPDFDevice; |
| 25 class SkPDFDict; | 28 class SkPDFDict; |
| 26 class SkPDFFont; | 29 class SkPDFFont; |
| 27 class SkPDFFormXObject; | 30 class SkPDFFormXObject; |
| 28 class SkPDFGlyphSetMap; | 31 class SkPDFGlyphSetMap; |
| 29 class SkPDFGraphicState; | 32 class SkPDFGraphicState; |
| 30 class SkPDFObject; | 33 class SkPDFObject; |
| 31 class SkPDFResourceDict; | 34 class SkPDFResourceDict; |
| 32 class SkPDFShader; | 35 class SkPDFShader; |
| 33 class SkPDFStream; | 36 class SkPDFStream; |
| 34 template <typename T> class SkTSet; | 37 template <typename T> class SkTSet; |
| 35 | 38 |
| 39 namespace skiatest { |
| 40 class Reporter; |
| 41 } |
| 42 |
| 43 namespace sk_tools { |
| 44 class PdfRenderer; |
| 45 } |
| 36 // Private classes. | 46 // Private classes. |
| 37 struct ContentEntry; | 47 struct ContentEntry; |
| 38 struct GraphicStateEntry; | 48 struct GraphicStateEntry; |
| 39 struct NamedDestination; | 49 struct NamedDestination; |
| 40 | 50 |
| 41 typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, con
st SkIRect& rect); | |
| 42 | |
| 43 /** \class SkPDFDevice | 51 /** \class SkPDFDevice |
| 44 | 52 |
| 45 The drawing context for the PDF backend. | 53 The drawing context for the PDF backend. |
| 46 */ | 54 */ |
| 47 class SkPDFDevice : public SkBitmapDevice { | 55 class SkPDFDevice : public SkBitmapDevice { |
| 48 public: | 56 public: |
| 49 /** Create a PDF drawing context with the given width and height. | 57 /** Create a PDF drawing context with the given width and height. |
| 50 * 72 points/in means letter paper is 612x792. | 58 * 72 points/in means letter paper is 612x792. |
| 51 * @param pageSize Page size in points. | 59 * @param pageSize Page size in points. |
| 52 * @param contentSize The content size of the page in points. This will be | 60 * @param contentSize The content size of the page in points. This will be |
| 53 * combined with the initial transform to determine the drawing area | 61 * combined with the initial transform to determine the drawing area |
| 54 * (as reported by the width and height methods). Anything outside | 62 * (as reported by the width and height methods). Anything outside |
| 55 * of the drawing area will be clipped. | 63 * of the drawing area will be clipped. |
| 56 * @param initialTransform The initial transform to apply to the page. | 64 * @param initialTransform The initial transform to apply to the page. |
| 57 * This may be useful to, for example, move the origin in and | 65 * This may be useful to, for example, move the origin in and |
| 58 * over a bit to account for a margin, scale the canvas, | 66 * over a bit to account for a margin, scale the canvas, |
| 59 * or apply a rotation. Note1: the SkPDFDevice also applies | 67 * or apply a rotation. Note1: the SkPDFDevice also applies |
| 60 * a scale+translate transform to move the origin from the | 68 * a scale+translate transform to move the origin from the |
| 61 * bottom left (PDF default) to the top left. Note2: drawDevice | 69 * bottom left (PDF default) to the top left. Note2: drawDevice |
| 62 * (used by layer restore) draws the device after this initial | 70 * (used by layer restore) draws the device after this initial |
| 63 * transform is applied, so the PDF device does an | 71 * transform is applied, so the PDF device does an |
| 64 * inverse scale+translate to accommodate the one that SkPDFDevice | 72 * inverse scale+translate to accommodate the one that SkPDFDevice |
| 65 * always does. | 73 * always does. |
| 66 */ | 74 */ |
| 67 // TODO(vandebo): The sizes should be SkSize and not SkISize. | 75 // TODO(vandebo): The sizes should be SkSize and not SkISize. |
| 76 // Deprecated, please use SkDocument::CreatePdf() instead! |
| 68 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 77 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
| 69 const SkMatrix& initialTransform); | 78 const SkMatrix& initialTransform); |
| 70 SK_API virtual ~SkPDFDevice(); | 79 SK_API virtual ~SkPDFDevice(); |
| 71 | 80 |
| 72 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; | 81 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; |
| 73 | 82 |
| 74 virtual void clear(SkColor color) SK_OVERRIDE; | 83 virtual void clear(SkColor color) SK_OVERRIDE; |
| 75 | 84 |
| 76 /** These are called inside the per-device-layer loop for each draw call. | 85 /** These are called inside the per-device-layer loop for each draw call. |
| 77 When these are called, we have already applied any saveLayer operations, | 86 When these are called, we have already applied any saveLayer operations, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 return *(fFontGlyphUsage.get()); | 200 return *(fFontGlyphUsage.get()); |
| 192 } | 201 } |
| 193 | 202 |
| 194 protected: | 203 protected: |
| 195 virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, | 204 virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 196 SkCanvas::Config8888) SK_OVERRIDE; | 205 SkCanvas::Config8888) SK_OVERRIDE; |
| 197 | 206 |
| 198 virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE; | 207 virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE; |
| 199 | 208 |
| 200 private: | 209 private: |
| 210 SK_API SkPDFDevice(const SkSize& trimBox, const SkRect& mediaBox); |
| 211 |
| 201 // TODO(vandebo): push most of SkPDFDevice's state into a core object in | 212 // TODO(vandebo): push most of SkPDFDevice's state into a core object in |
| 202 // order to get the right access levels without using friend. | 213 // order to get the right access levels without using friend. |
| 203 friend class ScopedContentEntry; | 214 friend class ScopedContentEntry; |
| 204 | 215 |
| 205 SkISize fPageSize; | 216 SkISize fPageSize; |
| 206 SkISize fContentSize; | 217 SkISize fContentSize; |
| 207 SkMatrix fInitialTransform; | 218 SkMatrix fInitialTransform; |
| 208 SkClipStack fExistingClipStack; | 219 SkClipStack fExistingClipStack; |
| 209 SkRegion fExistingClipRegion; | 220 SkRegion fExistingClipRegion; |
| 210 SkPDFArray* fAnnotations; | 221 SkPDFArray* fAnnotations; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 const SkMatrix& matrix, const SkPaint& paint); | 315 const SkMatrix& matrix, const SkPaint& paint); |
| 305 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); | 316 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); |
| 306 void handleLinkToURL(SkData* urlData, const SkRect& r, | 317 void handleLinkToURL(SkData* urlData, const SkRect& r, |
| 307 const SkMatrix& matrix); | 318 const SkMatrix& matrix); |
| 308 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, | 319 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, |
| 309 const SkMatrix& matrix); | 320 const SkMatrix& matrix); |
| 310 void defineNamedDestination(SkData* nameData, const SkPoint& point, | 321 void defineNamedDestination(SkData* nameData, const SkPoint& point, |
| 311 const SkMatrix& matrix); | 322 const SkMatrix& matrix); |
| 312 | 323 |
| 313 typedef SkBitmapDevice INHERITED; | 324 typedef SkBitmapDevice INHERITED; |
| 325 |
| 326 |
| 327 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to
create |
| 328 // an SkPDFDevice |
| 329 friend class SkDocument_PDF; |
| 330 friend class SkPDFImageShader; |
| 331 |
| 332 // TODO(edisonn): these are the entry points building a SkPDFDevice, which i
s about to get |
| 333 // removed. Listed here for future reference when we will remove the SkPDFDe
vice's constructor. |
| 334 // friend class SampleWindow; |
| 335 // friend void test_pdf_link_annotations(skiatest::Reporter* reporter); |
| 336 // friend void test_named_destination_annotations(skiatest::Reporter* reporte
r); |
| 337 // friend void TestPdfDevice(skiatest::Reporter* reporter, CanvasTestStep* te
stStep); |
| 338 // friend void test_issue1083(); |
| 339 // friend void TestImage(skiatest::Reporter* reporter, const SkBitmap& bitmap
, |
| 340 // const char* expected, bool useDCTEncoder); |
| 314 }; | 341 }; |
| 315 | 342 |
| 316 #endif | 343 #endif |
| OLD | NEW |