| 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 28 matching lines...) Expand all Loading... |
| 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 fRasterDpi(SkFloatToScalar(72.0f)) { | 700 fRasterDpi(SkFloatToScalar(72.0f)) { |
| 709 // just report that PDF does not supports perspective | 701 // Just report that PDF does not supports perspective in the |
| 710 // TODO(edisonn): update the shape when possible | 702 // initial transform. |
| 711 // or dump in an image otherwise | |
| 712 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); | 703 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); |
| 713 | 704 |
| 714 // Skia generally uses the top left as the origin but PDF natively has the | 705 // Skia generally uses the top left as the origin but PDF natively has the |
| 715 // origin at the bottom left. This matrix corrects for that. But that only | 706 // origin at the bottom left. This matrix corrects for that. But that only |
| 716 // needs to be done once, we don't do it when layering. | 707 // needs to be done once, we don't do it when layering. |
| 717 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); | 708 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); |
| 718 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); | 709 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); |
| 719 fInitialTransform.preConcat(initialTransform); | 710 fInitialTransform.preConcat(initialTransform); |
| 720 | 711 |
| 721 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); | 712 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); |
| (...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 } | 2135 } |
| 2145 | 2136 |
| 2146 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 2137 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 2147 SkCanvas::Config8888) { | 2138 SkCanvas::Config8888) { |
| 2148 return false; | 2139 return false; |
| 2149 } | 2140 } |
| 2150 | 2141 |
| 2151 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 2142 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
| 2152 return false; | 2143 return false; |
| 2153 } | 2144 } |
| OLD | NEW |