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

Unified Diff: src/pdf/SkPDFDevice.cpp

Issue 958433003: SkPDF: replace SkPDFDevice::copyContentToData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFFormXObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFDevice.cpp
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index b6acf34becd61b72cc3782e478bf47c63b2a0a6b..99f3ce1188d555dc2f797b128e8e66ef40a5f31a 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -1301,10 +1301,10 @@ SkPDFArray* SkPDFDevice::copyMediaBox() const {
return mediaBox;
}
-SkStream* SkPDFDevice::content() const {
- SkMemoryStream* result = new SkMemoryStream;
- result->setData(this->copyContentToData())->unref();
- return result;
+SkStreamAsset* SkPDFDevice::content() const {
+ SkDynamicMemoryWStream buffer;
+ this->writeContent(&buffer);
+ return buffer.detachAsStream();
}
void SkPDFDevice::copyContentEntriesToData(ContentEntry* entry,
@@ -1327,10 +1327,9 @@ void SkPDFDevice::copyContentEntriesToData(ContentEntry* entry,
gsState.drainStack();
}
-SkData* SkPDFDevice::copyContentToData() const {
- SkDynamicMemoryWStream data;
+void SkPDFDevice::writeContent(SkWStream* out) const {
if (fInitialTransform.getType() != SkMatrix::kIdentity_Mask) {
- SkPDFUtils::AppendTransform(fInitialTransform, &data);
+ SkPDFUtils::AppendTransform(fInitialTransform, out);
}
// TODO(aayushkumar): Apply clip along the margins. Currently, webkit
@@ -1338,7 +1337,7 @@ SkData* SkPDFDevice::copyContentToData() const {
// that currently acts as our clip.
// Also, think about adding a transform here (or assume that the values
// sent across account for that)
- SkPDFDevice::copyContentEntriesToData(fMarginContentEntries.get(), &data);
+ SkPDFDevice::copyContentEntriesToData(fMarginContentEntries.get(), out);
// If the content area is the entire page, then we don't need to clip
// the content area (PDF area clips to the page size). Otherwise,
@@ -1347,14 +1346,10 @@ SkData* SkPDFDevice::copyContentToData() const {
if (fPageSize != fContentSize) {
SkRect r = SkRect::MakeWH(SkIntToScalar(this->width()),
SkIntToScalar(this->height()));
- emit_clip(NULL, &r, &data);
+ emit_clip(NULL, &r, out);
}
- SkPDFDevice::copyContentEntriesToData(fContentEntries.get(), &data);
-
- // potentially we could cache this SkData, and only rebuild it if we
- // see that our state has changed.
- return data.copyToData();
+ SkPDFDevice::copyContentEntriesToData(fContentEntries.get(), out);
}
#ifdef SK_PDF_USE_PATHOPS
« no previous file with comments | « src/pdf/SkPDFDevice.h ('k') | src/pdf/SkPDFFormXObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698