aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-08-23 09:02:12 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-08-23 09:02:12 -0700
commitafdc177e77a4d083a23f709113ca97e4905df9ff (patch)
tree52f92865726e8acb23e16aac6a3149687194d467 /src/pdf
parenta2d2f386000acdc0e10bd38757ece8d6ab78bc25 (diff)
SkPDF: PDFDevice cleanup.
Remove unused fContentSize. Combine SkPDFDevice::writeContent and SkPDFDevice::content. Remove unused SkPDFDevice::initialTransform(). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2264113003 Review-Url: https://codereview.chromium.org/2264113003
Diffstat (limited to 'src/pdf')
-rw-r--r--src/pdf/SkPDFDevice.cpp34
-rw-r--r--src/pdf/SkPDFDevice.h8
2 files changed, 10 insertions, 32 deletions
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 73d41b1c36..9b9b16b04e 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -562,7 +562,6 @@ SkPDFDevice::SkPDFDevice(SkISize pageSize, SkScalar rasterDpi, SkPDFDocument* do
: INHERITED(SkImageInfo::MakeUnknown(pageSize.width(), pageSize.height()),
SkSurfaceProps(0, kUnknown_SkPixelGeometry))
, fPageSize(pageSize)
- , fContentSize(pageSize)
, fExistingClipRegion(SkIRect::MakeSize(pageSize))
, fRasterDpi(rasterDpi)
, fDocument(doc) {
@@ -1325,29 +1324,11 @@ sk_sp<SkPDFArray> SkPDFDevice::copyMediaBox() const {
std::unique_ptr<SkStreamAsset> SkPDFDevice::content() const {
SkDynamicMemoryWStream buffer;
- this->writeContent(&buffer);
- return std::unique_ptr<SkStreamAsset>(
- buffer.bytesWritten() > 0
- ? buffer.detachAsStream()
- : new SkMemoryStream);
-}
-
-void SkPDFDevice::writeContent(SkWStream* out) const {
if (fInitialTransform.getType() != SkMatrix::kIdentity_Mask) {
- SkPDFUtils::AppendTransform(fInitialTransform, out);
+ SkPDFUtils::AppendTransform(fInitialTransform, &buffer);
}
- // 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,
- // we have to clip to the content area; we've already applied the
- // initial transform, so just clip to the device size.
- if (fPageSize != fContentSize) {
- SkRect r = SkRect::MakeWH(SkIntToScalar(this->width()),
- SkIntToScalar(this->height()));
- emit_clip(nullptr, &r, out);
- }
-
- GraphicStackState gsState(fExistingClipStack, fExistingClipRegion, out);
+ GraphicStackState gsState(fExistingClipStack, fExistingClipRegion, &buffer);
for (const auto& entry : fContentEntries) {
SkPoint translation;
translation.iset(this->getOrigin());
@@ -1357,9 +1338,14 @@ void SkPDFDevice::writeContent(SkWStream* out) const {
gsState.updateMatrix(entry.fState.fMatrix);
gsState.updateDrawingState(entry.fState);
- entry.fContent.writeToStream(out);
+ entry.fContent.writeToStream(&buffer);
}
gsState.drainStack();
+
+ return std::unique_ptr<SkStreamAsset>(
+ buffer.bytesWritten() > 0
+ ? buffer.detachAsStream()
+ : new SkMemoryStream);
}
/* Draws an inverse filled path by using Path Ops to compute the positive
@@ -1499,8 +1485,8 @@ void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) const {
sk_sp<SkPDFObject> SkPDFDevice::makeFormXObjectFromDevice() {
SkMatrix inverseTransform = SkMatrix::I();
- if (!this->initialTransform().isIdentity()) {
- if (!this->initialTransform().invert(&inverseTransform)) {
+ if (!fInitialTransform.isIdentity()) {
+ if (!fInitialTransform.invert(&inverseTransform)) {
SkDEBUGFAIL("Layer initial transform should be invertible.");
inverseTransform.reset();
}
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 6588efb8d1..b9ef501518 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -143,13 +143,6 @@ public:
*/
std::unique_ptr<SkStreamAsset> content() const;
- /** Writes the page contents to the stream. */
- void writeContent(SkWStream*) const;
-
- const SkMatrix& initialTransform() const {
- return fInitialTransform;
- }
-
SkPDFCanon* getCanon() const;
// It is important to not confuse GraphicStateEntry with SkPDFGraphicState, the
@@ -218,7 +211,6 @@ private:
friend class ScopedContentEntry;
SkISize fPageSize;
- SkISize fContentSize;
SkMatrix fInitialTransform;
SkClipStack fExistingClipStack;
SkRegion fExistingClipRegion;