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; |
(...skipping 22 matching lines...) Expand all Loading... | |
56 * This may be useful to, for example, move the origin in and | 58 * This may be useful to, for example, move the origin in and |
57 * over a bit to account for a margin, scale the canvas, | 59 * over a bit to account for a margin, scale the canvas, |
58 * or apply a rotation. Note1: the SkPDFDevice also applies | 60 * or apply a rotation. Note1: the SkPDFDevice also applies |
59 * a scale+translate transform to move the origin from the | 61 * a scale+translate transform to move the origin from the |
60 * bottom left (PDF default) to the top left. Note2: drawDevice | 62 * bottom left (PDF default) to the top left. Note2: drawDevice |
61 * (used by layer restore) draws the device after this initial | 63 * (used by layer restore) draws the device after this initial |
62 * transform is applied, so the PDF device does an | 64 * transform is applied, so the PDF device does an |
63 * inverse scale+translate to accommodate the one that SkPDFDevice | 65 * inverse scale+translate to accommodate the one that SkPDFDevice |
64 * always does. | 66 * always does. |
65 */ | 67 */ |
66 // TODO(vandebo): The sizes should be SkSize and not SkISize. | 68 // Deprecated, please use SkDocument::CreatePdf() instead. |
67 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 69 SK_API SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
68 const SkMatrix& initialTransform); | 70 const SkMatrix& initialTransform); |
69 SK_API virtual ~SkPDFDevice(); | 71 SK_API virtual ~SkPDFDevice(); |
70 | 72 |
71 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; | 73 virtual uint32_t getDeviceCapabilities() SK_OVERRIDE; |
72 | 74 |
73 virtual void clear(SkColor color) SK_OVERRIDE; | 75 virtual void clear(SkColor color) SK_OVERRIDE; |
74 | 76 |
75 /** These are called inside the per-device-layer loop for each draw call. | 77 /** 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, | 78 When these are called, we have already applied any saveLayer operations, |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 const SkMatrix& matrix, const SkPaint& paint); | 306 const SkMatrix& matrix, const SkPaint& paint); |
305 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); | 307 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); |
306 void handleLinkToURL(SkData* urlData, const SkRect& r, | 308 void handleLinkToURL(SkData* urlData, const SkRect& r, |
307 const SkMatrix& matrix); | 309 const SkMatrix& matrix); |
308 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, | 310 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, |
309 const SkMatrix& matrix); | 311 const SkMatrix& matrix); |
310 void defineNamedDestination(SkData* nameData, const SkPoint& point, | 312 void defineNamedDestination(SkData* nameData, const SkPoint& point, |
311 const SkMatrix& matrix); | 313 const SkMatrix& matrix); |
312 | 314 |
313 typedef SkBitmapDevice INHERITED; | 315 typedef SkBitmapDevice INHERITED; |
316 | |
317 // TODO(edisonn): Only SkDocument_PDF and SkPDFImageShader should be able to create | |
318 // an SkPDFDevice | |
319 friend class SkDocument_PDF; | |
320 friend class SkPDFImageShader; | |
321 }; | |
322 | |
323 class SkPDFDeviceFlattener : public SkPDFDevice { | |
reed1
2013/10/07 19:39:42
If there is no need to make this public, I think i
edisonn
2013/10/08 17:55:31
Done.
| |
324 private: | |
325 typedef SkPDFDevice INHERITED; | |
326 | |
327 SK_API SkPDFDeviceFlattener(const SkSize& trimBox, const SkRect& mediaBox); | |
328 | |
329 public: | |
330 SK_API virtual ~SkPDFDeviceFlattener(); | |
331 | |
332 virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE; | |
333 virtual void drawPoints(const SkDraw&, SkCanvas::PointMode mode, | |
334 size_t count, const SkPoint[], | |
335 const SkPaint& paint) SK_OVERRIDE; | |
336 virtual void drawRect(const SkDraw&, const SkRect& r, const SkPaint& paint); | |
337 virtual void drawPath(const SkDraw&, const SkPath& origpath, | |
338 const SkPaint& paint, const SkMatrix* prePathMatrix, | |
339 bool pathIsMutable) SK_OVERRIDE; | |
340 virtual void drawText(const SkDraw&, const void* text, size_t len, | |
341 SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE; | |
342 virtual void drawPosText(const SkDraw&, const void* text, size_t len, | |
343 const SkScalar pos[], SkScalar constY, | |
344 int scalarsPerPos, const SkPaint&) SK_OVERRIDE; | |
345 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | |
346 const SkPath& path, const SkMatrix* matrix, | |
347 const SkPaint& paint) SK_OVERRIDE; | |
348 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, | |
349 int vertexCount, const SkPoint verts[], | |
350 const SkPoint texs[], const SkColor colors[], | |
351 SkXfermode* xmode, const uint16_t indices[], | |
352 int indexCount, const SkPaint& paint) SK_OVERRIDE; | |
353 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, | |
354 const SkPaint&) SK_OVERRIDE; | |
355 private: | |
356 | |
357 bool mustFlatten(const SkDraw& d) const; | |
358 bool mustPathText(const SkDraw& d, const SkPaint& paint); | |
359 | |
360 friend class SkDocument_PDF; | |
314 }; | 361 }; |
315 | 362 |
316 #endif | 363 #endif |
OLD | NEW |