| 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 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 ContentEntry* entry() { return fContentEntry; } | 625 ContentEntry* entry() { return fContentEntry; } |
| 626 private: | 626 private: |
| 627 SkPDFDevice* fDevice; | 627 SkPDFDevice* fDevice; |
| 628 ContentEntry* fContentEntry; | 628 ContentEntry* fContentEntry; |
| 629 SkXfermode::Mode fXfermode; | 629 SkXfermode::Mode fXfermode; |
| 630 SkPDFFormXObject* fDstFormXObject; | 630 SkPDFFormXObject* fDstFormXObject; |
| 631 | 631 |
| 632 void init(const SkClipStack* clipStack, const SkRegion& clipRegion, | 632 void init(const SkClipStack* clipStack, const SkRegion& clipRegion, |
| 633 const SkMatrix& matrix, const SkPaint& paint, bool hasText) { | 633 const SkMatrix& matrix, const SkPaint& paint, bool hasText) { |
| 634 fDstFormXObject = NULL; | 634 fDstFormXObject = NULL; |
| 635 if (matrix.hasPerspective() || |
| 636 (paint.getShader() && |
| 637 paint.getShader()->getLocalMatrix().hasPerspective())) { |
| 638 // Just report that PDF does not supports perspective |
| 639 // TODO(edisonn): update the shape when possible |
| 640 // or dump in an image otherwise |
| 641 NOT_IMPLEMENTED(true, false); |
| 642 return; |
| 643 } |
| 644 |
| 635 if (paint.getXfermode()) { | 645 if (paint.getXfermode()) { |
| 636 paint.getXfermode()->asMode(&fXfermode); | 646 paint.getXfermode()->asMode(&fXfermode); |
| 637 } | 647 } |
| 638 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, | 648 fContentEntry = fDevice->setUpContentEntry(clipStack, clipRegion, |
| 639 matrix, paint, hasText, | 649 matrix, paint, hasText, |
| 640 &fDstFormXObject); | 650 &fDstFormXObject); |
| 641 } | 651 } |
| 642 }; | 652 }; |
| 643 | 653 |
| 644 //////////////////////////////////////////////////////////////////////////////// | 654 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 27 matching lines...) Expand all Loading... |
| 672 // TODO(vandebo) change pageSize to SkSize. | 682 // TODO(vandebo) change pageSize to SkSize. |
| 673 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 683 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
| 674 const SkMatrix& initialTransform) | 684 const SkMatrix& initialTransform) |
| 675 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), | 685 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), |
| 676 fPageSize(pageSize), | 686 fPageSize(pageSize), |
| 677 fContentSize(contentSize), | 687 fContentSize(contentSize), |
| 678 fLastContentEntry(NULL), | 688 fLastContentEntry(NULL), |
| 679 fLastMarginContentEntry(NULL), | 689 fLastMarginContentEntry(NULL), |
| 680 fClipStack(NULL), | 690 fClipStack(NULL), |
| 681 fEncoder(NULL) { | 691 fEncoder(NULL) { |
| 692 // just report that PDF does not supports perspective |
| 693 // TODO(edisonn): update the shape when possible |
| 694 // or dump in an image otherwise |
| 695 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); |
| 696 |
| 682 // Skia generally uses the top left as the origin but PDF natively has the | 697 // Skia generally uses the top left as the origin but PDF natively has the |
| 683 // origin at the bottom left. This matrix corrects for that. But that only | 698 // origin at the bottom left. This matrix corrects for that. But that only |
| 684 // needs to be done once, we don't do it when layering. | 699 // needs to be done once, we don't do it when layering. |
| 685 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); | 700 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); |
| 686 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); | 701 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); |
| 687 fInitialTransform.preConcat(initialTransform); | 702 fInitialTransform.preConcat(initialTransform); |
| 688 | 703 |
| 689 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); | 704 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); |
| 690 fExistingClipRegion.setRect(existingClip); | 705 fExistingClipRegion.setRect(existingClip); |
| 691 | 706 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 SkMatrix matrix = *d.fMatrix; | 923 SkMatrix matrix = *d.fMatrix; |
| 909 if (prePathMatrix) { | 924 if (prePathMatrix) { |
| 910 if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) { | 925 if (paint.getPathEffect() || paint.getStyle() != SkPaint::kFill_Style) { |
| 911 if (!pathIsMutable) { | 926 if (!pathIsMutable) { |
| 912 pathPtr = &modifiedPath; | 927 pathPtr = &modifiedPath; |
| 913 pathIsMutable = true; | 928 pathIsMutable = true; |
| 914 } | 929 } |
| 915 origPath.transform(*prePathMatrix, pathPtr); | 930 origPath.transform(*prePathMatrix, pathPtr); |
| 916 } else { | 931 } else { |
| 917 if (!matrix.preConcat(*prePathMatrix)) { | 932 if (!matrix.preConcat(*prePathMatrix)) { |
| 933 // TODO(edisonn): report somehow why we failed? |
| 918 return; | 934 return; |
| 919 } | 935 } |
| 920 } | 936 } |
| 921 } | 937 } |
| 922 | 938 |
| 923 if (paint.getPathEffect()) { | 939 if (paint.getPathEffect()) { |
| 924 if (d.fClip->isEmpty()) { | 940 if (d.fClip->isEmpty()) { |
| 925 return; | 941 return; |
| 926 } | 942 } |
| 927 if (!pathIsMutable) { | 943 if (!pathIsMutable) { |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 } | 1938 } |
| 1923 | 1939 |
| 1924 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 1940 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 1925 SkCanvas::Config8888) { | 1941 SkCanvas::Config8888) { |
| 1926 return false; | 1942 return false; |
| 1927 } | 1943 } |
| 1928 | 1944 |
| 1929 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 1945 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
| 1930 return false; | 1946 return false; |
| 1931 } | 1947 } |
| OLD | NEW |