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

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: 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
« src/pdf/SkPDFCanvas.cpp ('K') | « 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 326
326 protected: 327 protected:
327 SkCanvas* onBeginPage(SkScalar width, SkScalar height, 328 SkCanvas* onBeginPage(SkScalar width, SkScalar height,
328 const SkRect& trimBox) override { 329 const SkRect& trimBox) override {
329 SkASSERT(!fCanvas.get()); 330 SkASSERT(!fCanvas.get());
330 331
331 SkISize pageSize = SkISize::Make( 332 SkISize pageSize = SkISize::Make(
332 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); 333 SkScalarRoundToInt(width), SkScalarRoundToInt(height));
333 sk_sp<SkPDFDevice> device( 334 sk_sp<SkPDFDevice> device(
334 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); 335 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
335 fCanvas.reset(new SkCanvas(device.get())); 336 fCanvas.reset(new SkPDFCanvas(device.get()));
336 fPageDevices.push_back(std::move(device)); 337 fPageDevices.push_back(std::move(device));
337 fCanvas->clipRect(trimBox); 338 fCanvas->clipRect(trimBox);
338 fCanvas->translate(trimBox.x(), trimBox.y()); 339 fCanvas->translate(trimBox.x(), trimBox.y());
339 return fCanvas.get(); 340 return fCanvas.get();
340 } 341 }
341 342
342 void onEndPage() override { 343 void onEndPage() override {
343 SkASSERT(fCanvas.get()); 344 SkASSERT(fCanvas.get());
344 fCanvas->flush(); 345 fCanvas->flush();
345 fCanvas.reset(nullptr); 346 fCanvas.reset(nullptr);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release(); 396 return SkPDFMakeDocument(stream, nullptr, dpi, jpegEncoder).release();
396 } 397 }
397 398
398 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 399 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
399 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; 400 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
400 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path)); 401 SkAutoTDelete<SkFILEWStream> stream(new SkFILEWStream(path));
401 return stream->isValid() 402 return stream->isValid()
402 ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).rele ase() 403 ? SkPDFMakeDocument(stream.release(), delete_wstream, dpi, nullptr).rele ase()
403 : nullptr; 404 : nullptr;
404 } 405 }
OLDNEW
« src/pdf/SkPDFCanvas.cpp ('K') | « src/pdf/SkPDFDevice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698