OLD | NEW |
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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 enum_must_match_value); | 560 enum_must_match_value); |
561 SK_COMPILE_ASSERT(SkPaint::kStrokeAndFill_Style == 2, | 561 SK_COMPILE_ASSERT(SkPaint::kStrokeAndFill_Style == 2, |
562 enum_must_match_value); | 562 enum_must_match_value); |
563 fContentStream->writeDecAsText(state.fTextFill); | 563 fContentStream->writeDecAsText(state.fTextFill); |
564 fContentStream->writeText(" Tr\n"); | 564 fContentStream->writeText(" Tr\n"); |
565 currentEntry()->fTextFill = state.fTextFill; | 565 currentEntry()->fTextFill = state.fTextFill; |
566 } | 566 } |
567 } | 567 } |
568 } | 568 } |
569 | 569 |
570 SkBaseDevice* SkPDFDevice::onCreateCompatibleDevice(const CreateInfo& cinfo) { | 570 SkBaseDevice* SkPDFDevice::onCreateDevice(const SkImageInfo& info, Usage usage)
{ |
571 // PDF does not support image filters, so render them on CPU. | 571 // PDF does not support image filters, so render them on CPU. |
572 // Note that this rendering is done at "screen" resolution (100dpi), not | 572 // Note that this rendering is done at "screen" resolution (100dpi), not |
573 // printer resolution. | 573 // printer resolution. |
574 // FIXME: It may be possible to express some filters natively using PDF | 574 // FIXME: It may be possible to express some filters natively using PDF |
575 // to improve quality and file size (http://skbug.com/3043) | 575 // to improve quality and file size (http://skbug.com/3043) |
576 if (kImageFilter_Usage == cinfo.fUsage) { | 576 if (kImageFilter_Usage == usage) { |
577 return SkBitmapDevice::Create(cinfo.fInfo); | 577 return SkBitmapDevice::Create(info); |
578 } | 578 } |
579 | 579 |
580 SkMatrix initialTransform; | 580 SkMatrix initialTransform; |
581 initialTransform.reset(); | 581 initialTransform.reset(); |
582 SkISize size = SkISize::Make(cinfo.fInfo.width(), cinfo.fInfo.height()); | 582 SkISize size = SkISize::Make(info.width(), info.height()); |
583 return SkNEW_ARGS(SkPDFDevice, (size, size, initialTransform)); | 583 return SkNEW_ARGS(SkPDFDevice, (size, size, initialTransform)); |
584 } | 584 } |
585 | 585 |
586 | 586 |
587 struct ContentEntry { | 587 struct ContentEntry { |
588 GraphicStateEntry fState; | 588 GraphicStateEntry fState; |
589 SkDynamicMemoryWStream fContent; | 589 SkDynamicMemoryWStream fContent; |
590 SkAutoTDelete<ContentEntry> fNext; | 590 SkAutoTDelete<ContentEntry> fNext; |
591 | 591 |
592 // If the stack is too deep we could get Stack Overflow. | 592 // If the stack is too deep we could get Stack Overflow. |
(...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2203 SkAutoTUnref<SkPDFObject> image( | 2203 SkAutoTUnref<SkPDFObject> image( |
2204 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); | 2204 SkPDFCreateImageObject(*bitmap, subset, fEncoder)); |
2205 if (!image) { | 2205 if (!image) { |
2206 return; | 2206 return; |
2207 } | 2207 } |
2208 | 2208 |
2209 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2209 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
2210 &content.entry()->fContent); | 2210 &content.entry()->fContent); |
2211 } | 2211 } |
2212 | 2212 |
OLD | NEW |