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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 ContentEntry* entry() { return fContentEntry; } | 641 ContentEntry* entry() { return fContentEntry; } |
642 private: | 642 private: |
643 SkPDFDevice* fDevice; | 643 SkPDFDevice* fDevice; |
644 ContentEntry* fContentEntry; | 644 ContentEntry* fContentEntry; |
645 SkXfermode::Mode fXfermode; | 645 SkXfermode::Mode fXfermode; |
646 SkPDFFormXObject* fDstFormXObject; | 646 SkPDFFormXObject* fDstFormXObject; |
647 | 647 |
648 void init(const SkClipStack* clipStack, const SkRegion& clipRegion, | 648 void init(const SkClipStack* clipStack, const SkRegion& clipRegion, |
649 const SkMatrix& matrix, const SkPaint& paint, bool hasText) { | 649 const SkMatrix& matrix, const SkPaint& paint, bool hasText) { |
650 fDstFormXObject = NULL; | 650 fDstFormXObject = NULL; |
651 // Shape has to be flatten before we get here. | 651 if (matrix.hasPerspective() || |
652 NOT_IMPLEMENTED(!matrix.hasPerspective(), false); | 652 (paint.getShader() && |
| 653 paint.getShader()->getLocalMatrix().hasPerspective())) { |
| 654 // Just report that PDF does not supports perspective |
| 655 // TODO(edisonn): update the shape when possible |
| 656 // or dump in an image otherwise |
| 657 NOT_IMPLEMENTED(true, false); |
| 658 return; |
| 659 } |
| 660 |
653 if (paint.getXfermode()) { | 661 if (paint.getXfermode()) { |
654 paint.getXfermode()->asMode(&fXfermode); | 662 paint.getXfermode()->asMode(&fXfermode); |
655 } | 663 } |
656 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, | 664 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, |
657 matrix, paint, hasText, | 665 matrix, paint, hasText, |
658 &fDstFormXObject); | 666 &fDstFormXObject); |
659 } | 667 } |
660 }; | 668 }; |
661 | 669 |
662 //////////////////////////////////////////////////////////////////////////////// | 670 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 27 matching lines...) Expand all Loading... |
690 // TODO(vandebo) change pageSize to SkSize. | 698 // TODO(vandebo) change pageSize to SkSize. |
691 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 699 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
692 const SkMatrix& initialTransform) | 700 const SkMatrix& initialTransform) |
693 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), | 701 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), |
694 fPageSize(pageSize), | 702 fPageSize(pageSize), |
695 fContentSize(contentSize), | 703 fContentSize(contentSize), |
696 fLastContentEntry(NULL), | 704 fLastContentEntry(NULL), |
697 fLastMarginContentEntry(NULL), | 705 fLastMarginContentEntry(NULL), |
698 fClipStack(NULL), | 706 fClipStack(NULL), |
699 fEncoder(NULL) { | 707 fEncoder(NULL) { |
700 // Just report that PDF does not supports perspective in the | 708 // just report that PDF does not supports perspective |
701 // initial transform. | 709 // TODO(edisonn): update the shape when possible |
| 710 // or dump in an image otherwise |
702 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); | 711 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); |
703 | 712 |
704 // Skia generally uses the top left as the origin but PDF natively has the | 713 // Skia generally uses the top left as the origin but PDF natively has the |
705 // origin at the bottom left. This matrix corrects for that. But that only | 714 // origin at the bottom left. This matrix corrects for that. But that only |
706 // needs to be done once, we don't do it when layering. | 715 // needs to be done once, we don't do it when layering. |
707 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); | 716 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); |
708 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); | 717 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); |
709 fInitialTransform.preConcat(initialTransform); | 718 fInitialTransform.preConcat(initialTransform); |
710 | 719 |
711 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); | 720 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2132 } | 2141 } |
2133 | 2142 |
2134 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 2143 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
2135 SkCanvas::Config8888) { | 2144 SkCanvas::Config8888) { |
2136 return false; | 2145 return false; |
2137 } | 2146 } |
2138 | 2147 |
2139 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 2148 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
2140 return false; | 2149 return false; |
2141 } | 2150 } |
OLD | NEW |