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