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

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

Issue 988413003: Change device creation to see the (optional) layer-paint (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments Created 5 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
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 "SkPDFDevice.h" 8 #include "SkPDFDevice.h"
9 9
10 #include "SkAnnotation.h" 10 #include "SkAnnotation.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 enum_must_match_value); 559 enum_must_match_value);
560 SK_COMPILE_ASSERT(SkPaint::kStrokeAndFill_Style == 2, 560 SK_COMPILE_ASSERT(SkPaint::kStrokeAndFill_Style == 2,
561 enum_must_match_value); 561 enum_must_match_value);
562 fContentStream->writeDecAsText(state.fTextFill); 562 fContentStream->writeDecAsText(state.fTextFill);
563 fContentStream->writeText(" Tr\n"); 563 fContentStream->writeText(" Tr\n");
564 currentEntry()->fTextFill = state.fTextFill; 564 currentEntry()->fTextFill = state.fTextFill;
565 } 565 }
566 } 566 }
567 } 567 }
568 568
569 SkBaseDevice* SkPDFDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) { 569 static bool not_supported_for_layers(const SkPaint& layerPaint) {
570 // PDF does not support image filters, so render them on CPU. 570 // PDF does not support image filters, so render them on CPU.
571 // Note that this rendering is done at "screen" resolution (100dpi), not 571 // Note that this rendering is done at "screen" resolution (100dpi), not
572 // printer resolution. 572 // printer resolution.
573 // FIXME: It may be possible to express some filters natively using PDF 573 // FIXME: It may be possible to express some filters natively using PDF
574 // to improve quality and file size (http://skbug.com/3043) 574 // to improve quality and file size (http://skbug.com/3043)
575 if (kImageFilter_Usage == cinfo.fUsage) { 575
576 // TODO: should we return true if there is a colorfilter?
577 return layerPaint.getImageFilter() != NULL;
578 }
579
580 SkBaseDevice* SkPDFDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint * layerPaint) {
581 if (layerPaint && not_supported_for_layers(*layerPaint)) {
576 return SkBitmapDevice::Create(cinfo.fInfo); 582 return SkBitmapDevice::Create(cinfo.fInfo);
577 } 583 }
578 SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height()); 584 SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height());
579 return SkPDFDevice::Create(size, fRasterDpi, fCanon); 585 return SkPDFDevice::Create(size, fRasterDpi, fCanon);
580 } 586 }
581 587
582 588
583 struct ContentEntry { 589 struct ContentEntry {
584 GraphicStateEntry fState; 590 GraphicStateEntry fState;
585 SkDynamicMemoryWStream fContent; 591 SkDynamicMemoryWStream fContent;
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2130 2136
2131 SkAutoTUnref<SkPDFObject> image( 2137 SkAutoTUnref<SkPDFObject> image(
2132 SkPDFCreateImageObject(fCanon, *bitmap, subset)); 2138 SkPDFCreateImageObject(fCanon, *bitmap, subset));
2133 if (!image) { 2139 if (!image) {
2134 return; 2140 return;
2135 } 2141 }
2136 2142
2137 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), 2143 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()),
2138 &content.entry()->fContent); 2144 &content.entry()->fContent);
2139 } 2145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698