Chromium Code Reviews| 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" |
| 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 |
| 25 class CanvasTestStep; | |
| 24 class SkPDFArray; | 26 class SkPDFArray; |
| 25 class SkPDFDevice; | 27 class SkPDFDevice; |
| 26 class SkPDFDict; | 28 class SkPDFDict; |
| 27 class SkPDFFont; | 29 class SkPDFFont; |
| 28 class SkPDFFormXObject; | 30 class SkPDFFormXObject; |
| 29 class SkPDFGlyphSetMap; | 31 class SkPDFGlyphSetMap; |
| 30 class SkPDFGraphicState; | 32 class SkPDFGraphicState; |
| 31 class SkPDFObject; | 33 class SkPDFObject; |
| 32 class SkPDFResourceDict; | 34 class SkPDFResourceDict; |
| 33 class SkPDFShader; | 35 class SkPDFShader; |
| 34 class SkPDFStream; | 36 class SkPDFStream; |
| 35 template <typename T> class SkTSet; | 37 template <typename T> class SkTSet; |
| 36 | 38 |
| 39 namespace skiatest { | |
| 40 class Reporter; | |
|
reed1
2013/10/07 13:24:54
Why is this declared here?
edisonn
2013/10/07 19:29:06
test code, removed
| |
| 41 } | |
| 42 | |
| 43 namespace sk_tools { | |
| 44 class PdfRenderer; | |
|
reed1
2013/10/07 13:24:54
Why is this declared here?
edisonn
2013/10/07 19:29:06
test code, removed
| |
| 45 } | |
| 37 // Private classes. | 46 // Private classes. |
| 38 struct ContentEntry; | 47 struct ContentEntry; |
| 39 struct GraphicStateEntry; | 48 struct GraphicStateEntry; |
| 40 struct NamedDestination; | 49 struct NamedDestination; |
| 41 | 50 |
| 51 typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, con st SkIRect& rect); | |
|
reed1
2013/10/07 13:24:54
Is this different form the EncodeProc type added t
edisonn
2013/10/07 19:29:06
Unused, removed
vandebo (ex-Chrome)
2013/10/07 22:34:10
remove?
edisonn
2013/10/08 17:55:30
removed
| |
| 52 | |
| 42 /** \class SkPDFDevice | 53 /** \class SkPDFDevice |
| 43 | 54 |
| 44 The drawing context for the PDF backend. | 55 The drawing context for the PDF backend. |
| 45 */ | 56 */ |
| 46 class SkPDFDevice : public SkBitmapDevice { | 57 class SkPDFDevice : public SkBitmapDevice { |
| 47 public: | 58 public: |
| 48 /** Create a PDF drawing context with the given width and height. | 59 /** Create a PDF drawing context with the given width and height. |
| 49 * 72 points/in means letter paper is 612x792. | 60 * 72 points/in means letter paper is 612x792. |
| 50 * @param pageSize Page size in points. | 61 * @param pageSize Page size in points. |
| 51 * @param contentSize The content size of the page in points. This will be | 62 * @param contentSize The content size of the page in points. This will be |
| 52 * combined with the initial transform to determine the drawing area | 63 * combined with the initial transform to determine the drawing area |
| 53 * (as reported by the width and height methods). Anything outside | 64 * (as reported by the width and height methods). Anything outside |
| 54 * of the drawing area will be clipped. | 65 * of the drawing area will be clipped. |
| 55 * @param initialTransform The initial transform to apply to the page. | 66 * @param initialTransform The initial transform to apply to the page. |
| 56 * This may be useful to, for example, move the origin in and | 67 * This may be useful to, for example, move the origin in and |
| 57 * over a bit to account for a margin, scale the canvas, | 68 * over a bit to account for a margin, scale the canvas, |
| 58 * or apply a rotation. Note1: the SkPDFDevice also applies | 69 * or apply a rotation. Note1: the SkPDFDevice also applies |
| 59 * a scale+translate transform to move the origin from the | 70 * a scale+translate transform to move the origin from the |
| 60 * bottom left (PDF default) to the top left. Note2: drawDevice | 71 * bottom left (PDF default) to the top left. Note2: drawDevice |
| 61 * (used by layer restore) draws the device after this initial | 72 * (used by layer restore) draws the device after this initial |
| 62 * transform is applied, so the PDF device does an | 73 * transform is applied, so the PDF device does an |
| 63 * inverse scale+translate to accommodate the one that SkPDFDevice | 74 * inverse scale+translate to accommodate the one that SkPDFDevice |
| 64 * always does. | 75 * always does. |
| 65 */ | 76 */ |
| 66 // TODO(vandebo): The sizes should be SkSize and not SkISize. | 77 // TODO(vandebo): The sizes should be SkSize and not SkISize. |
|
reed1
2013/10/07 13:24:54
lets remove the TODO if this is deprecated
edisonn
2013/10/07 19:29:06
Done.
| |
| 78 // Deprecated, please use SkDocument::CreatePdf() instead. | |
| 67 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 79 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
| 68 const SkMatrix& initialTransform); | 80 const SkMatrix& initialTransform); |
| 69 SK_API virtual ~SkPDFDevice(); | 81 SK_API virtual ~SkPDFDevice(); |
| 70 | 82 |
| 71 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; | 83 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; |
| 72 | 84 |
| 73 virtual void clear(SkColor color) SK_OVERRIDE; | 85 virtual void clear(SkColor color) SK_OVERRIDE; |
| 74 | 86 |
| 75 /** These are called inside the per-device-layer loop for each draw call. | 87 /** These are called inside the per-device-layer loop for each draw call. |
| 76 When these are called, we have already applied any saveLayer operations, | 88 When these are called, we have already applied any saveLayer operations, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 return *(fFontGlyphUsage.get()); | 202 return *(fFontGlyphUsage.get()); |
| 191 } | 203 } |
| 192 | 204 |
| 193 protected: | 205 protected: |
| 194 virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, | 206 virtual bool onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 195 SkCanvas::Config8888) SK_OVERRIDE; | 207 SkCanvas::Config8888) SK_OVERRIDE; |
| 196 | 208 |
| 197 virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE; | 209 virtual bool allowImageFilter(SkImageFilter*) SK_OVERRIDE; |
| 198 | 210 |
| 199 private: | 211 private: |
| 212 SK_API SkPDFDevice(const SkSize& trimBox, const SkRect& mediaBox); | |
| 213 | |
| 200 // TODO(vandebo): push most of SkPDFDevice's state into a core object in | 214 // TODO(vandebo): push most of SkPDFDevice's state into a core object in |
| 201 // order to get the right access levels without using friend. | 215 // order to get the right access levels without using friend. |
| 202 friend class ScopedContentEntry; | 216 friend class ScopedContentEntry; |
| 203 | 217 |
| 204 SkISize fPageSize; | 218 SkISize fPageSize; |
| 205 SkISize fContentSize; | 219 SkISize fContentSize; |
| 206 SkMatrix fInitialTransform; | 220 SkMatrix fInitialTransform; |
| 207 SkClipStack fExistingClipStack; | 221 SkClipStack fExistingClipStack; |
| 208 SkRegion fExistingClipRegion; | 222 SkRegion fExistingClipRegion; |
| 209 SkPDFArray* fAnnotations; | 223 SkPDFArray* fAnnotations; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 const SkMatrix& matrix, const SkPaint& paint); | 317 const SkMatrix& matrix, const SkPaint& paint); |
| 304 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); | 318 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); |
| 305 void handleLinkToURL(SkData* urlData, const SkRect& r, | 319 void handleLinkToURL(SkData* urlData, const SkRect& r, |
| 306 const SkMatrix& matrix); | 320 const SkMatrix& matrix); |
| 307 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, | 321 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, |
| 308 const SkMatrix& matrix); | 322 const SkMatrix& matrix); |
| 309 void defineNamedDestination(SkData* nameData, const SkPoint& point, | 323 void defineNamedDestination(SkData* nameData, const SkPoint& point, |
| 310 const SkMatrix& matrix); | 324 const SkMatrix& matrix); |
| 311 | 325 |
| 312 typedef SkBitmapDevice INHERITED; | 326 typedef SkBitmapDevice INHERITED; |
| 327 | |
| 328 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create | |
| 329 // an SkPDFDevice | |
| 330 friend class SkDocument_PDF; | |
| 331 friend class SkPDFImageShader; | |
| 332 }; | |
| 333 | |
| 334 class SkPDFDeviceFlattener : public SkPDFDevice { | |
|
reed1
2013/10/07 13:24:54
Does this class need to be in this header, or can
edisonn
2013/10/07 19:29:06
I could put all this logic inside PDF, but long te
vandebo (ex-Chrome)
2013/10/07 22:34:10
Flattener is a very generic name. Is this meant t
edisonn
2013/10/08 17:55:30
This class will flatten other properties unsuporte
| |
| 335 private: | |
| 336 typedef SkPDFDevice INHERITED; | |
| 337 | |
| 338 SK_API SkPDFDeviceFlattener(const SkSize& trimBox, const SkRect& mediaBox); | |
| 339 | |
| 340 public: | |
| 341 SK_API virtual ~SkPDFDeviceFlattener(); | |
| 342 | |
| 343 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | |
| 344 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, | |
| 345 size_t count, const SkPoint[], | |
| 346 const SkPaint& paint) SK_OVERRIDE; | |
| 347 virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint); | |
| 348 virtual void drawPath(const SkDraw&, const SkPath& origpath, | |
| 349 const SkPaint& paint, const SkMatrix* prePathMatrix, | |
| 350 bool pathIsMutable) SK_OVERRIDE; | |
| 351 virtual void drawText(const SkDraw&, const void* text, size_t len, | |
| 352 SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE; | |
| 353 virtual void drawPosText(const SkDraw&, const void* text, size_t len, | |
| 354 const SkScalar pos[], SkScalar constY, | |
| 355 int scalarsPerPos, const SkPaint&) SK_OVERRIDE; | |
| 356 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | |
| 357 const SkPath& path, const SkMatrix* matrix, | |
| 358 const SkPaint& paint) SK_OVERRIDE; | |
| 359 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, | |
| 360 int vertexCount, const SkPoint verts[], | |
| 361 const SkPoint texs[], const SkColor colors[], | |
| 362 SkXfermode* xmode, const uint16_t indices[], | |
| 363 int indexCount, const SkPaint& paint) SK_OVERRIDE; | |
| 364 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | |
| 365 const SkPaint&) SK_OVERRIDE; | |
| 366 private: | |
| 367 | |
| 368 bool mustFlatten(const SkDraw& d) const; | |
| 369 bool mustPathText(const SkDraw& d, const SkPaint& paint); | |
| 370 | |
| 371 friend class SkDocument_PDF; | |
| 313 }; | 372 }; |
| 314 | 373 |
| 315 #endif | 374 #endif |
| OLD | NEW |