| OLD | NEW |
| 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 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 * The stream output must be ignored, and should not be trusted. | 124 * The stream output must be ignored, and should not be trusted. |
| 125 */ | 125 */ |
| 126 void abort(); | 126 void abort(); |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * Set the document's metadata, if supported by the document | 129 * Set the document's metadata, if supported by the document |
| 130 * type. The creationDate and modifiedDate parameters can be | 130 * type. The creationDate and modifiedDate parameters can be |
| 131 * nullptr. For example: | 131 * nullptr. For example: |
| 132 * | 132 * |
| 133 * SkDocument* make_doc(SkWStream* output) { | 133 * SkDocument* make_doc(SkWStream* output) { |
| 134 * SkTArray<SkDocument::Attribute> info; | 134 * std::vector<SkDocument::Attribute> info; |
| 135 * info.emplace_back(SkString("Title"), SkString("...")); | 135 * info.emplace_back(SkString("Title"), SkString("...")); |
| 136 * info.emplace_back(SkString("Author"), SkString("...")); | 136 * info.emplace_back(SkString("Author"), SkString("...")); |
| 137 * info.emplace_back(SkString("Subject"), SkString("...")); | 137 * info.emplace_back(SkString("Subject"), SkString("...")); |
| 138 * info.emplace_back(SkString("Keywords"), SkString("...")); | 138 * info.emplace_back(SkString("Keywords"), SkString("...")); |
| 139 * info.emplace_back(SkString("Creator"), SkString("...")); | 139 * info.emplace_back(SkString("Creator"), SkString("...")); |
| 140 * SkTime::DateTime now; | 140 * SkTime::DateTime now; |
| 141 * SkTime::GetDateTime(&now); | 141 * SkTime::GetDateTime(&now); |
| 142 * SkDocument* doc = SkDocument::CreatePDF(output); | 142 * SkDocument* doc = SkDocument::CreatePDF(output); |
| 143 * doc->setMetadata(info, &now, &now); | 143 * doc->setMetadata(&info[0], (int)info.size(), &now, &now); |
| 144 * return doc; | 144 * return doc; |
| 145 * } | 145 * } |
| 146 */ | 146 */ |
| 147 struct Attribute { | 147 struct Attribute { |
| 148 SkString fKey, fValue; | 148 SkString fKey, fValue; |
| 149 Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {} | 149 Attribute(const SkString& k, const SkString& v) : fKey(k), fValue(v) {} |
| 150 }; | 150 }; |
| 151 virtual void setMetadata(const SkTArray<SkDocument::Attribute>&, | 151 virtual void setMetadata(const SkDocument::Attribute[], |
| 152 int /* attributeCount */, |
| 152 const SkTime::DateTime* /* creationDate */, | 153 const SkTime::DateTime* /* creationDate */, |
| 153 const SkTime::DateTime* /* modifiedDate */) {} | 154 const SkTime::DateTime* /* modifiedDate */) {} |
| 154 | 155 |
| 156 // This version is deprecated. |
| 157 void setMetadata(const SkTArray<SkDocument::Attribute>& att, |
| 158 const SkTime::DateTime* creation, |
| 159 const SkTime::DateTime* modified) { |
| 160 this->setMetadata(&att[0], att.count(), creation, modified); |
| 161 } |
| 162 |
| 155 protected: | 163 protected: |
| 156 SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted)); | 164 SkDocument(SkWStream*, void (*)(SkWStream*, bool aborted)); |
| 157 | 165 |
| 158 // note: subclasses must call close() in their destructor, as the base class | 166 // note: subclasses must call close() in their destructor, as the base class |
| 159 // cannot do this for them. | 167 // cannot do this for them. |
| 160 virtual ~SkDocument(); | 168 virtual ~SkDocument(); |
| 161 | 169 |
| 162 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, | 170 virtual SkCanvas* onBeginPage(SkScalar width, SkScalar height, |
| 163 const SkRect& content) = 0; | 171 const SkRect& content) = 0; |
| 164 virtual void onEndPage() = 0; | 172 virtual void onEndPage() = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 177 | 185 |
| 178 private: | 186 private: |
| 179 SkWStream* fStream; | 187 SkWStream* fStream; |
| 180 void (*fDoneProc)(SkWStream*, bool aborted); | 188 void (*fDoneProc)(SkWStream*, bool aborted); |
| 181 State fState; | 189 State fState; |
| 182 | 190 |
| 183 typedef SkRefCnt INHERITED; | 191 typedef SkRefCnt INHERITED; |
| 184 }; | 192 }; |
| 185 | 193 |
| 186 #endif | 194 #endif |
| OLD | NEW |