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

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

Issue 24615006: rebaseline drawbitmap gms (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: remove expectation included by mistake in another cl 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
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 "SkPDFCallbacks.h"
11 #include "SkRect.h" 12 #include "SkRect.h"
12 #include "SkRefCnt.h" 13 #include "SkRefCnt.h"
14 #include "SkBitmap.h"
15 #include "SkRect.h"
13 16
14 class SkCanvas; 17 class SkCanvas;
15 class SkWStream; 18 class SkWStream;
16 19
17 /** 20 /**
18 * High-level API for creating a document-based canvas. To use.. 21 * High-level API for creating a document-based canvas. To use..
19 * 22 *
20 * 1. Create a document, specifying a stream to store the output. 23 * 1. Create a document, specifying a stream to store the output.
21 * 2. For each "page" of content: 24 * 2. For each "page" of content:
22 * a. canvas = doc->beginPage(...) 25 * a. canvas = doc->beginPage(...)
(...skipping 21 matching lines...) Expand all
44 * if there is a Done proc provided, it will be called with the stream. 47 * if there is a Done proc provided, it will be called with the stream.
45 * The proc can delete the stream, or whatever it needs to do. 48 * The proc can delete the stream, or whatever it needs to do.
46 */ 49 */
47 static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL); 50 static SkDocument* CreatePDF(SkWStream*, void (*Done)(SkWStream*) = NULL);
48 51
49 /** 52 /**
50 * Begin a new page for the document, returning the canvas that will draw 53 * Begin a new page for the document, returning the canvas that will draw
51 * into the page. The document owns this canvas, and it will go out of 54 * into the page. The document owns this canvas, and it will go out of
52 * scope when endPage() or close() is called, or the document is deleted. 55 * scope when endPage() or close() is called, or the document is deleted.
53 */ 56 */
54 SkCanvas* beginPage(SkScalar width, SkScalar height, 57 SkCanvas* beginPage(const SkSize& trimSize,
55 const SkRect* content = NULL); 58 const SkRect* mediaBox = NULL);
reed1 2013/09/26 17:00:46 // What is stored in the doc if I pass null? Does
edisonn 2013/09/26 19:44:09 added comment
56 59
57 /** 60 /**
58 * Call endPage() when the content for the current page has been drawn 61 * Call endPage() when the content for the current page has been drawn
59 * (into the canvas returned by beginPage()). After this call the canvas 62 * (into the canvas returned by beginPage()). After this call the canvas
60 * returned by beginPage() will be out-of-scope. 63 * returned by beginPage() will be out-of-scope.
61 */ 64 */
62 void endPage(); 65 void endPage();
63 66
64 /** 67 /**
65 * Call close() when all pages have been drawn. This will close the file 68 * Call close() when all pages have been drawn. This will close the file
66 * or stream holding the document's contents. After close() the document 69 * or stream holding the document's contents. After close() the document
67 * can no longer add new pages. Deleting the document will automatically 70 * can no longer add new pages. Deleting the document will automatically
68 * call close() if need be. 71 * call close() if need be.
69 */ 72 */
70 void close(); 73 bool close();
reed1 2013/09/26 17:00:46 // What does returning true of false indicate?
edisonn 2013/09/26 19:44:09 added comment
74
75 /**
76 * Call abort() to stop producing the document immediately.
77 * The stream output must be ignored, and should not be trusted.
78 */
79 void abort();
80
81 /** Sets the DCTEncoder for images.
82 * @param encoder The encoder to encode a bitmap as JPEG (DCT).
83 * Result of encodings are cached, if the encoder changes the
84 * behaivor dynamically and an image is added to a second catalog,
85 * we will likely use the result of the first encoding call.
86 * By returning false from the encoder function, the encoder result
87 * is not used.
88 * Callers might not want to encode small images, as the time spent
89 * encoding and decoding might not be worth the space savings,
90 * if any at all.
91 * Returns false if DCT encoder is not supported in the document.
92 */
93
94 virtual bool setDCTEncoder(EncodeToDCTStream) {
reed1 2013/09/26 17:00:46 1. Lets try very very hard to keep this header cle
edisonn 2013/09/26 19:44:09 Not yet implemented, working on it. For one, I als
95 return false;
96 }
71 97
72 protected: 98 protected:
73 SkDocument(SkWStream*, void (*)(SkWStream*)); 99 SkDocument(SkWStream*, void (*)(SkWStream*));
74 // note: subclasses must call close() in their destructor, as the base class 100 // note: subclasses must call close() in their destructor, as the base class
75 // cannot do this for them. 101 // cannot do this for them.
76 virtual ~SkDocument(); 102 virtual ~SkDocument();
77 103
78 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, 104 virtual SkCanvas* onBeginPage(const SkSize& trimSize,
79 const SkRect& content) = 0; 105 const SkRect* mediaBox) = 0;
80 virtual void onEndPage() = 0; 106 virtual void onEndPage() = 0;
81 virtual void onClose(SkWStream*) = 0; 107 virtual bool onClose(SkWStream*) = 0;
108 virtual void onAbort() = 0;
82 109
83 enum State { 110 enum State {
84 kBetweenPages_State, 111 kBetweenPages_State,
85 kInPage_State, 112 kInPage_State,
86 kClosed_State 113 kClosed_State
87 }; 114 };
88 State getState() const { return fState; } 115 State getState() const { return fState; }
89 116
90 private: 117 private:
91 SkWStream* fStream; 118 SkWStream* fStream;
92 void (*fDoneProc)(SkWStream*); 119 void (*fDoneProc)(SkWStream*);
93 State fState; 120 State fState;
94 121
95 typedef SkRefCnt INHERITED; 122 typedef SkRefCnt INHERITED;
96 }; 123 };
97 124
98 #endif 125 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698