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

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: use SkScalar instead of double Created 7 years, 1 month 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') | no next file with comments »
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_ScalarDefaultDPI 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).
reed1 2013/10/21 13:10:24 What does DPI mean to the client when they draw in
edisonn 2013/10/21 14:40:58 No Does it affect internal
38 */ 42 */
39 static SkDocument* CreatePDF(const char filename[], 43 static SkDocument* CreatePDF(const char filename[],
40 SkPicture::EncodeBitmap encoder = NULL); 44 SkPicture::EncodeBitmap encoder = NULL,
45 SkScalar dpi = SK_ScalarDefaultDPI);
41 46
42 /** 47 /**
43 * Create a PDF-backed document, writing the results into a stream. 48 * Create a PDF-backed document, writing the results into a stream.
44 * If there is an error trying to create the doc, returns NULL. 49 * If there is an error trying to create the doc, returns NULL.
45 * 50 *
46 * The document may write to the stream at anytime during its lifetime, 51 * 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() 52 * 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, 53 * 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. 54 * 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. 55 * The proc can delete the stream, or whatever it needs to do.
51 * encoder sets the DCTEncoder for images, to encode a bitmap 56 * encoder sets the DCTEncoder for images, to encode a bitmap
52 * as JPEG (DCT). 57 * as JPEG (DCT).
53 */ 58 */
54 static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL, 59 static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL,
55 SkPicture::EncodeBitmap encoder = NULL); 60 SkPicture::EncodeBitmap encoder = NULL,
61 SkScalar dpi = SK_ScalarDefaultDPI);
56 62
57 /** 63 /**
58 * Begin a new page for the document, returning the canvas that will draw 64 * 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 65 * 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. 66 * scope when endPage() or close() is called, or the document is deleted.
61 */ 67 */
62 SkCanvas* beginPage(SkScalar width, SkScalar height, 68 SkCanvas* beginPage(SkScalar width, SkScalar height,
63 const SkRect* content = NULL); 69 const SkRect* content = NULL);
64 70
65 /** 71 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 111
106 private: 112 private:
107 SkWStream* fStream; 113 SkWStream* fStream;
108 void (*fDoneProc)(SkWStream*); 114 void (*fDoneProc)(SkWStream*);
109 State fState; 115 State fState;
110 116
111 typedef SkRefCnt INHERITED; 117 typedef SkRefCnt INHERITED;
112 }; 118 };
113 119
114 #endif 120 #endif
OLDNEW
« no previous file with comments | « no previous file | include/pdf/SkPDFDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698