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

Side by Side Diff: src/pdf/SkPDFDocument.cpp

Issue 1812063002: SkPDF: Add SkPDFCanvas to intercept some draw calls (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-03-21 (Monday) 15:44:28 EDT Created 4 years, 9 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
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | 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 2011 Google Inc. 2 * Copyright 2011 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 "SkPDFCanon.h" 8 #include "SkPDFCanon.h"
9 #include "SkPDFCanvas.h"
9 #include "SkPDFDevice.h" 10 #include "SkPDFDevice.h"
10 #include "SkPDFDocument.h" 11 #include "SkPDFDocument.h"
11 #include "SkPDFFont.h" 12 #include "SkPDFFont.h"
12 #include "SkPDFMetadata.h" 13 #include "SkPDFMetadata.h"
13 #include "SkPDFStream.h" 14 #include "SkPDFStream.h"
14 #include "SkPDFTypes.h" 15 #include "SkPDFTypes.h"
15 #include "SkPDFUtils.h" 16 #include "SkPDFUtils.h"
16 #include "SkStream.h" 17 #include "SkStream.h"
17 18
18 static void emit_pdf_header(SkWStream* stream) { 19 static void emit_pdf_header(SkWStream* stream) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 327
327 protected: 328 protected:
328 SkCanvas* onBeginPage(SkScalar width, SkScalar height, 329 SkCanvas* onBeginPage(SkScalar width, SkScalar height,
329 const SkRect& trimBox) override { 330 const SkRect& trimBox) override {
330 SkASSERT(!fCanvas.get()); 331 SkASSERT(!fCanvas.get());
331 332
332 SkISize pageSize = SkISize::Make( 333 SkISize pageSize = SkISize::Make(
333 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); 334 SkScalarRoundToInt(width), SkScalarRoundToInt(height));
334 sk_sp<SkPDFDevice> device( 335 sk_sp<SkPDFDevice> device(
335 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); 336 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
336 fCanvas.reset(new SkCanvas(device.get())); 337 fCanvas = sk_make_sp<SkPDFCanvas>(device);
337 fPageDevices.push_back(std::move(device)); 338 fPageDevices.push_back(std::move(device));
338 fCanvas->clipRect(trimBox); 339 fCanvas->clipRect(trimBox);
339 fCanvas->translate(trimBox.x(), trimBox.y()); 340 fCanvas->translate(trimBox.x(), trimBox.y());
340 return fCanvas.get(); 341 return fCanvas.get();
341 } 342 }
342 343
343 void onEndPage() override { 344 void onEndPage() override {
344 SkASSERT(fCanvas.get()); 345 SkASSERT(fCanvas.get());
345 fCanvas->flush(); 346 fCanvas->flush();
346 fCanvas.reset(nullptr); 347 fCanvas.reset(nullptr);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release(); 397 return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release();
397 } 398 }
398 399
399 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 400 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
400 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; 401 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
401 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path)); 402 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
402 return stream->isValid() 403 return stream->isValid()
403 ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).rele ase() 404 ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).rele ase()
404 : nullptr; 405 : nullptr;
405 } 406 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698