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

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

Issue 1505763003: SkDocument::setDCTEncoder() for old versions of webkit (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove compile flag; unit test Created 5 years 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
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 "SkDocument.h" 8 #include "SkDocument.h"
9 #include "SkPDFCanon.h" 9 #include "SkPDFCanon.h"
10 #include "SkPDFDevice.h" 10 #include "SkPDFDevice.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 void (*doneProc)(SkWStream*, bool), 324 void (*doneProc)(SkWStream*, bool),
325 SkScalar rasterDpi) 325 SkScalar rasterDpi)
326 : SkDocument(stream, doneProc) 326 : SkDocument(stream, doneProc)
327 , fRasterDpi(rasterDpi) {} 327 , fRasterDpi(rasterDpi) {}
328 328
329 virtual ~SkDocument_PDF() { 329 virtual ~SkDocument_PDF() {
330 // subclasses must call close() in their destructors 330 // subclasses must call close() in their destructors
331 this->close(); 331 this->close();
332 } 332 }
333 333
334 void setDCTEncoder(SkData* (*encoder)(const SkPixmap&)) override {
335 fCanon.fEncoder = encoder;
336 }
337
334 protected: 338 protected:
335 SkCanvas* onBeginPage(SkScalar width, SkScalar height, 339 SkCanvas* onBeginPage(SkScalar width, SkScalar height,
336 const SkRect& trimBox) override { 340 const SkRect& trimBox) override {
337 SkASSERT(!fCanvas.get()); 341 SkASSERT(!fCanvas.get());
338 342
339 SkISize pageSize = SkISize::Make( 343 SkISize pageSize = SkISize::Make(
340 SkScalarRoundToInt(width), SkScalarRoundToInt(height)); 344 SkScalarRoundToInt(width), SkScalarRoundToInt(height));
341 SkAutoTUnref<SkPDFDevice> device( 345 SkAutoTUnref<SkPDFDevice> device(
342 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); 346 SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
343 fCanvas.reset(new SkCanvas(device.get())); 347 fCanvas.reset(new SkCanvas(device.get()));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 395
392 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) { 396 SkDocument* SkDocument::CreatePDF(const char path[], SkScalar dpi) {
393 SkFILEWStream* stream = new SkFILEWStream(path); 397 SkFILEWStream* stream = new SkFILEWStream(path);
394 if (!stream->isValid()) { 398 if (!stream->isValid()) {
395 delete stream; 399 delete stream;
396 return nullptr; 400 return nullptr;
397 } 401 }
398 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; }; 402 auto delete_wstream = [](SkWStream* stream, bool) { delete stream; };
399 return new SkDocument_PDF(stream, delete_wstream, dpi); 403 return new SkDocument_PDF(stream, delete_wstream, dpi);
400 } 404 }
OLDNEW
« no previous file with comments | « include/core/SkDocument.h ('k') | src/pdf/SkPDFBitmap.h » ('j') | tests/PDFDocumentTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698