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

Side by Side Diff: src/doc/SkDocument_PDF.cpp

Issue 707533003: Simplify canvas calls in SkDocument_PDF (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | 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 #include "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkPDFDocument.h" 9 #include "SkPDFDocument.h"
10 #include "SkPDFDevice.h" 10 #include "SkPDFDevice.h"
(...skipping 26 matching lines...) Expand all
37 mediaBoxSize.set(SkScalarRoundToInt(width), SkScalarRoundToInt(height)); 37 mediaBoxSize.set(SkScalarRoundToInt(width), SkScalarRoundToInt(height));
38 38
39 fDevice = SkNEW_ARGS(SkPDFDevice, (mediaBoxSize, mediaBoxSize, SkMatrix: :I())); 39 fDevice = SkNEW_ARGS(SkPDFDevice, (mediaBoxSize, mediaBoxSize, SkMatrix: :I()));
40 if (fEncoder) { 40 if (fEncoder) {
41 fDevice->setDCTEncoder(fEncoder); 41 fDevice->setDCTEncoder(fEncoder);
42 } 42 }
43 if (fRasterDpi != 0) { 43 if (fRasterDpi != 0) {
44 fDevice->setRasterDpi(fRasterDpi); 44 fDevice->setRasterDpi(fRasterDpi);
45 } 45 }
46 fCanvas = SkNEW_ARGS(SkCanvas, (fDevice)); 46 fCanvas = SkNEW_ARGS(SkCanvas, (fDevice));
47 fCanvas->clipRect(trimBox);
47 fCanvas->translate(trimBox.x(), trimBox.y()); 48 fCanvas->translate(trimBox.x(), trimBox.y());
48 fCanvas->clipRect(SkRect::MakeWH(trimBox.width(), trimBox.height()));
49 return fCanvas; 49 return fCanvas;
50 } 50 }
51 51
52 virtual void onEndPage() SK_OVERRIDE { 52 virtual void onEndPage() SK_OVERRIDE {
53 SkASSERT(fCanvas); 53 SkASSERT(fCanvas);
54 SkASSERT(fDevice); 54 SkASSERT(fDevice);
55 55
56 fCanvas->flush(); 56 fCanvas->flush();
57 fDoc->appendPage(fDevice); 57 fDoc->appendPage(fDevice);
58 58
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 SkDocument* SkDocument::CreatePDF(const char path[], 101 SkDocument* SkDocument::CreatePDF(const char path[],
102 SkPicture::EncodeBitmap enc, 102 SkPicture::EncodeBitmap enc,
103 SkScalar dpi) { 103 SkScalar dpi) {
104 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path)); 104 SkFILEWStream* stream = SkNEW_ARGS(SkFILEWStream, (path));
105 if (!stream->isValid()) { 105 if (!stream->isValid()) {
106 SkDELETE(stream); 106 SkDELETE(stream);
107 return NULL; 107 return NULL;
108 } 108 }
109 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi)); 109 return SkNEW_ARGS(SkDocument_PDF, (stream, delete_wstream, enc, dpi));
110 } 110 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698