| 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 "SkCanvas.h" | 14 #include "SkCanvas.h" |
| 14 #include "SkDevice.h" | |
| 15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
| 16 #include "SkPath.h" | 16 #include "SkPath.h" |
| 17 #include "SkRect.h" | 17 #include "SkRect.h" |
| 18 #include "SkRefCnt.h" | 18 #include "SkRefCnt.h" |
| 19 #include "SkStream.h" | 19 #include "SkStream.h" |
| 20 #include "SkTDArray.h" | 20 #include "SkTDArray.h" |
| 21 #include "SkTScopedPtr.h" | 21 #include "SkTScopedPtr.h" |
| 22 | 22 |
| 23 class SkPDFArray; | 23 class SkPDFArray; |
| 24 class SkPDFDevice; | 24 class SkPDFDevice; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 struct ContentEntry; | 37 struct ContentEntry; |
| 38 struct GraphicStateEntry; | 38 struct GraphicStateEntry; |
| 39 struct NamedDestination; | 39 struct NamedDestination; |
| 40 | 40 |
| 41 typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, con
st SkIRect& rect); | 41 typedef bool (*EncodeToDCTStream)(SkWStream* stream, const SkBitmap& bitmap, con
st SkIRect& rect); |
| 42 | 42 |
| 43 /** \class SkPDFDevice | 43 /** \class SkPDFDevice |
| 44 | 44 |
| 45 The drawing context for the PDF backend. | 45 The drawing context for the PDF backend. |
| 46 */ | 46 */ |
| 47 class SkPDFDevice : public SkDevice { | 47 class SkPDFDevice : public SkBitmapDevice { |
| 48 public: | 48 public: |
| 49 /** Create a PDF drawing context with the given width and height. | 49 /** Create a PDF drawing context with the given width and height. |
| 50 * 72 points/in means letter paper is 612x792. | 50 * 72 points/in means letter paper is 612x792. |
| 51 * @param pageSize Page size in points. | 51 * @param pageSize Page size in points. |
| 52 * @param contentSize The content size of the page in points. This will be | 52 * @param contentSize The content size of the page in points. This will be |
| 53 * combined with the initial transform to determine the drawing area | 53 * combined with the initial transform to determine the drawing area |
| 54 * (as reported by the width and height methods). Anything outside | 54 * (as reported by the width and height methods). Anything outside |
| 55 * of the drawing area will be clipped. | 55 * of the drawing area will be clipped. |
| 56 * @param initialTransform The initial transform to apply to the page. | 56 * @param initialTransform The initial transform to apply to the page. |
| 57 * This may be useful to, for example, move the origin in and | 57 * This may be useful to, for example, move the origin in and |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 const SkScalar pos[], SkScalar constY, | 100 const SkScalar pos[], SkScalar constY, |
| 101 int scalarsPerPos, const SkPaint&) SK_OVERRIDE; | 101 int scalarsPerPos, const SkPaint&) SK_OVERRIDE; |
| 102 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, | 102 virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len, |
| 103 const SkPath& path, const SkMatrix* matrix, | 103 const SkPath& path, const SkMatrix* matrix, |
| 104 const SkPaint& paint) SK_OVERRIDE; | 104 const SkPaint& paint) SK_OVERRIDE; |
| 105 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, | 105 virtual void drawVertices(const SkDraw&, SkCanvas::VertexMode, |
| 106 int vertexCount, const SkPoint verts[], | 106 int vertexCount, const SkPoint verts[], |
| 107 const SkPoint texs[], const SkColor colors[], | 107 const SkPoint texs[], const SkColor colors[], |
| 108 SkXfermode* xmode, const uint16_t indices[], | 108 SkXfermode* xmode, const uint16_t indices[], |
| 109 int indexCount, const SkPaint& paint) SK_OVERRIDE; | 109 int indexCount, const SkPaint& paint) SK_OVERRIDE; |
| 110 virtual void drawDevice(const SkDraw&, SkDevice*, int x, int y, | 110 virtual void drawDevice(const SkDraw&, SkBaseDevice*, int x, int y, |
| 111 const SkPaint&) SK_OVERRIDE; | 111 const SkPaint&) SK_OVERRIDE; |
| 112 | 112 |
| 113 virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE; | 113 virtual void onAttachToCanvas(SkCanvas* canvas) SK_OVERRIDE; |
| 114 virtual void onDetachFromCanvas() SK_OVERRIDE; | 114 virtual void onDetachFromCanvas() SK_OVERRIDE; |
| 115 | 115 |
| 116 enum DrawingArea { | 116 enum DrawingArea { |
| 117 kContent_DrawingArea, // Drawing area for the page content. | 117 kContent_DrawingArea, // Drawing area for the page content. |
| 118 kMargin_DrawingArea, // Drawing area for the margin content. | 118 kMargin_DrawingArea, // Drawing area for the margin content. |
| 119 }; | 119 }; |
| 120 | 120 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void setLastContentEntry(ContentEntry* contentEntry); | 230 void setLastContentEntry(ContentEntry* contentEntry); |
| 231 | 231 |
| 232 // Glyph ids used for each font on this device. | 232 // Glyph ids used for each font on this device. |
| 233 SkTScopedPtr<SkPDFGlyphSetMap> fFontGlyphUsage; | 233 SkTScopedPtr<SkPDFGlyphSetMap> fFontGlyphUsage; |
| 234 | 234 |
| 235 EncodeToDCTStream fEncoder; | 235 EncodeToDCTStream fEncoder; |
| 236 | 236 |
| 237 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, | 237 SkPDFDevice(const SkISize& layerSize, const SkClipStack& existingClipStack, |
| 238 const SkRegion& existingClipRegion); | 238 const SkRegion& existingClipRegion); |
| 239 | 239 |
| 240 // override from SkDevice | 240 // override from SkBaseDevice |
| 241 virtual SkDevice* onCreateCompatibleDevice(SkBitmap::Config config, | 241 virtual SkBaseDevice* onCreateCompatibleDevice(SkBitmap::Config config, |
| 242 int width, int height, | 242 int width, int height, |
| 243 bool isOpaque, | 243 bool isOpaque, |
| 244 Usage usage) SK_OVERRIDE; | 244 Usage usage) SK_OVERRIDE; |
| 245 | 245 |
| 246 void init(); | 246 void init(); |
| 247 void cleanUp(bool clearFontUsage); | 247 void cleanUp(bool clearFontUsage); |
| 248 SkPDFFormXObject* createFormXObjectFromDevice(); | 248 SkPDFFormXObject* createFormXObjectFromDevice(); |
| 249 | 249 |
| 250 // Clear the passed clip from all existing content entries. | 250 // Clear the passed clip from all existing content entries. |
| 251 void clearClipFromContent(const SkClipStack* clipStack, | 251 void clearClipFromContent(const SkClipStack* clipStack, |
| 252 const SkRegion& clipRegion); | 252 const SkRegion& clipRegion); |
| 253 void drawFormXObjectWithClip(SkPDFFormXObject* form, | 253 void drawFormXObjectWithClip(SkPDFFormXObject* form, |
| 254 const SkClipStack* clipStack, | 254 const SkClipStack* clipStack, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 bool handlePointAnnotation(const SkPoint* points, size_t count, | 303 bool handlePointAnnotation(const SkPoint* points, size_t count, |
| 304 const SkMatrix& matrix, const SkPaint& paint); | 304 const SkMatrix& matrix, const SkPaint& paint); |
| 305 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); | 305 SkPDFDict* createLinkAnnotation(const SkRect& r, const SkMatrix& matrix); |
| 306 void handleLinkToURL(SkData* urlData, const SkRect& r, | 306 void handleLinkToURL(SkData* urlData, const SkRect& r, |
| 307 const SkMatrix& matrix); | 307 const SkMatrix& matrix); |
| 308 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, | 308 void handleLinkToNamedDest(SkData* nameData, const SkRect& r, |
| 309 const SkMatrix& matrix); | 309 const SkMatrix& matrix); |
| 310 void defineNamedDestination(SkData* nameData, const SkPoint& point, | 310 void defineNamedDestination(SkData* nameData, const SkPoint& point, |
| 311 const SkMatrix& matrix); | 311 const SkMatrix& matrix); |
| 312 | 312 |
| 313 typedef SkDevice INHERITED; | 313 typedef SkBitmapDevice INHERITED; |
| 314 }; | 314 }; |
| 315 | 315 |
| 316 #endif | 316 #endif |
| OLD | NEW |