Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: include/core/SkDocument.h

Issue 32233003: Add DPI stettings to SkDocument::CreatePDF(). Tests will be added in a future cl, once DPI will be … (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add comments Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | include/pdf/SkPDFDevice.h » ('j') | include/pdf/SkPDFDevice.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 SkDocument_DEFINED 8 #ifndef SkDocument_DEFINED
9 #define SkDocument_DEFINED 9 #define SkDocument_DEFINED
10 10
11 #include "SkBitmap.h" 11 #include "SkBitmap.h"
12 #include "SkPicture.h" 12 #include "SkPicture.h"
13 #include "SkRect.h" 13 #include "SkRect.h"
14 #include "SkRefCnt.h" 14 #include "SkRefCnt.h"
15 15
16 class SkCanvas; 16 class SkCanvas;
17 class SkWStream; 17 class SkWStream;
18 18
19 /** SK_ScalarDefaultDPI is 72 DPI.
20 */
21 #define SK_ScalarDefaultRasterDPI SkFloatToScalar(72.0f)
22
19 /** 23 /**
20 * High-level API for creating a document-based canvas. To use.. 24 * High-level API for creating a document-based canvas. To use..
21 * 25 *
22 * 1. Create a document, specifying a stream to store the output. 26 * 1. Create a document, specifying a stream to store the output.
23 * 2. For each "page" of content: 27 * 2. For each "page" of content:
24 * a. canvas = doc->beginPage(...) 28 * a. canvas = doc->beginPage(...)
25 * b. draw_my_content(canvas); 29 * b. draw_my_content(canvas);
26 * c. doc->endPage(); 30 * c. doc->endPage();
27 * 3. Close the document with doc->close(). 31 * 3. Close the document with doc->close().
28 */ 32 */
29 class SkDocument : public SkRefCnt { 33 class SkDocument : public SkRefCnt {
30 public: 34 public:
31 SK_DECLARE_INST_COUNT(SkDocument) 35 SK_DECLARE_INST_COUNT(SkDocument)
32 36
33 /** 37 /**
34 * Create a PDF-backed document, writing the results into a file. 38 * Create a PDF-backed document, writing the results into a file.
35 * If there is an error trying to create the doc, returns NULL. 39 * If there is an error trying to create the doc, returns NULL.
36 * encoder sets the DCTEncoder for images, to encode a bitmap 40 * encoder sets the DCTEncoder for images, to encode a bitmap
37 * as JPEG (DCT). 41 * as JPEG (DCT).
42 * rasterDpi - the DPI at which features without native PDF support
43 * will be rasterized (e.g. draw image with perspective,
44 * draw text with perspective, ...)
45 * A larger DPI would create a PDF that reflects the original
46 * intent with better fidelity, but it can make for larger
47 * PDF files too, which would use more memory while rendering,
48 * and it would be slower to be processed or sent online or
49 * to printer.
38 */ 50 */
39 static SkDocument* CreatePDF(const char filename[], 51 static SkDocument* CreatePDF(
40 SkPicture::EncodeBitmap encoder = NULL); 52 const char filename[],
53 SkPicture::EncodeBitmap encoder = NULL,
54 SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
41 55
42 /** 56 /**
43 * Create a PDF-backed document, writing the results into a stream. 57 * Create a PDF-backed document, writing the results into a stream.
44 * If there is an error trying to create the doc, returns NULL. 58 * If there is an error trying to create the doc, returns NULL.
45 * 59 *
46 * The document may write to the stream at anytime during its lifetime, 60 * The document may write to the stream at anytime during its lifetime,
47 * until either close() is called or the document is deleted. Once close() 61 * until either close() is called or the document is deleted. Once close()
48 * has been called, and all of the data has been written to the stream, 62 * has been called, and all of the data has been written to the stream,
49 * if there is a Done proc provided, it will be called with the stream. 63 * if there is a Done proc provided, it will be called with the stream.
50 * The proc can delete the stream, or whatever it needs to do. 64 * The proc can delete the stream, or whatever it needs to do.
51 * encoder sets the DCTEncoder for images, to encode a bitmap 65 * encoder sets the DCTEncoder for images, to encode a bitmap
52 * as JPEG (DCT). 66 * as JPEG (DCT).
53 */ 67 * rasterDpi - the DPI at which features without native PDF support
54 static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL, 68 * will be rasterized (e.g. draw image with perspective,
55 SkPicture::EncodeBitmap encoder = NULL); 69 * draw text with perspective, ...)
70 * A larger DPI would create a PDF that reflects the original
71 * intent with better fidelity, but it can make for larger
72 * PDF files too, which would use more memory while rendering,
73 * and it would be slower to be processed or sent online or
74 * to printer. */
75 static SkDocument* CreatePDF(
76 SkWStream*, void (*Done)(SkWStream*) = NULL,
77 SkPicture::EncodeBitmap encoder = NULL,
78 SkScalar rasterDpi = SK_ScalarDefaultRasterDPI);
56 79
57 /** 80 /**
58 * Begin a new page for the document, returning the canvas that will draw 81 * Begin a new page for the document, returning the canvas that will draw
59 * into the page. The document owns this canvas, and it will go out of 82 * into the page. The document owns this canvas, and it will go out of
60 * scope when endPage() or close() is called, or the document is deleted. 83 * scope when endPage() or close() is called, or the document is deleted.
61 */ 84 */
62 SkCanvas* beginPage(SkScalar width, SkScalar height, 85 SkCanvas* beginPage(SkScalar width, SkScalar height,
63 const SkRect* content = NULL); 86 const SkRect* content = NULL);
64 87
65 /** 88 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 128
106 private: 129 private:
107 SkWStream* fStream; 130 SkWStream* fStream;
108 void (*fDoneProc)(SkWStream*); 131 void (*fDoneProc)(SkWStream*);
109 State fState; 132 State fState;
110 133
111 typedef SkRefCnt INHERITED; 134 typedef SkRefCnt INHERITED;
112 }; 135 };
113 136
114 #endif 137 #endif
OLDNEW
« no previous file with comments | « no previous file | include/pdf/SkPDFDevice.h » ('j') | include/pdf/SkPDFDevice.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698