| 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 697 |
| 698 // TODO(vandebo) change pageSize to SkSize. | 698 // TODO(vandebo) change pageSize to SkSize. |
| 699 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 699 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
| 700 const SkMatrix& initialTransform) | 700 const SkMatrix& initialTransform) |
| 701 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), | 701 : SkBitmapDevice(makeContentBitmap(contentSize, &initialTransform)), |
| 702 fPageSize(pageSize), | 702 fPageSize(pageSize), |
| 703 fContentSize(contentSize), | 703 fContentSize(contentSize), |
| 704 fLastContentEntry(NULL), | 704 fLastContentEntry(NULL), |
| 705 fLastMarginContentEntry(NULL), | 705 fLastMarginContentEntry(NULL), |
| 706 fClipStack(NULL), | 706 fClipStack(NULL), |
| 707 fEncoder(NULL) { | 707 fEncoder(NULL), |
| 708 fRasterDpi(SkFloatToScalar(72.0f)) { |
| 708 // just report that PDF does not supports perspective | 709 // just report that PDF does not supports perspective |
| 709 // TODO(edisonn): update the shape when possible | 710 // TODO(edisonn): update the shape when possible |
| 710 // or dump in an image otherwise | 711 // or dump in an image otherwise |
| 711 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); | 712 NOT_IMPLEMENTED(initialTransform.hasPerspective(), true); |
| 712 | 713 |
| 713 // Skia generally uses the top left as the origin but PDF natively has the | 714 // 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 | 715 // 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. | 716 // needs to be done once, we don't do it when layering. |
| 716 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); | 717 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); |
| 717 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); | 718 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); |
| 718 fInitialTransform.preConcat(initialTransform); | 719 fInitialTransform.preConcat(initialTransform); |
| 719 | 720 |
| 720 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); | 721 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); |
| 721 fExistingClipRegion.setRect(existingClip); | 722 fExistingClipRegion.setRect(existingClip); |
| 722 | 723 |
| 723 this->init(); | 724 this->init(); |
| 724 } | 725 } |
| 725 | 726 |
| 726 // TODO(vandebo) change layerSize to SkSize. | 727 // TODO(vandebo) change layerSize to SkSize. |
| 727 SkPDFDevice::SkPDFDevice(const SkISize& layerSize, | 728 SkPDFDevice::SkPDFDevice(const SkISize& layerSize, |
| 728 const SkClipStack& existingClipStack, | 729 const SkClipStack& existingClipStack, |
| 729 const SkRegion& existingClipRegion) | 730 const SkRegion& existingClipRegion) |
| 730 : SkBitmapDevice(makeContentBitmap(layerSize, NULL)), | 731 : SkBitmapDevice(makeContentBitmap(layerSize, NULL)), |
| 731 fPageSize(layerSize), | 732 fPageSize(layerSize), |
| 732 fContentSize(layerSize), | 733 fContentSize(layerSize), |
| 733 fExistingClipStack(existingClipStack), | 734 fExistingClipStack(existingClipStack), |
| 734 fExistingClipRegion(existingClipRegion), | 735 fExistingClipRegion(existingClipRegion), |
| 735 fLastContentEntry(NULL), | 736 fLastContentEntry(NULL), |
| 736 fLastMarginContentEntry(NULL), | 737 fLastMarginContentEntry(NULL), |
| 737 fClipStack(NULL) { | 738 fClipStack(NULL), |
| 739 fEncoder(NULL), |
| 740 fRasterDpi(SkFloatToScalar(72.0f)) { |
| 738 fInitialTransform.reset(); | 741 fInitialTransform.reset(); |
| 739 this->init(); | 742 this->init(); |
| 740 } | 743 } |
| 741 | 744 |
| 742 SkPDFDevice::~SkPDFDevice() { | 745 SkPDFDevice::~SkPDFDevice() { |
| 743 this->cleanUp(true); | 746 this->cleanUp(true); |
| 744 } | 747 } |
| 745 | 748 |
| 746 void SkPDFDevice::init() { | 749 void SkPDFDevice::init() { |
| 747 fAnnotations = NULL; | 750 fAnnotations = NULL; |
| (...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 } | 2144 } |
| 2142 | 2145 |
| 2143 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 2146 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 2144 SkCanvas::Config8888) { | 2147 SkCanvas::Config8888) { |
| 2145 return false; | 2148 return false; |
| 2146 } | 2149 } |
| 2147 | 2150 |
| 2148 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 2151 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
| 2149 return false; | 2152 return false; |
| 2150 } | 2153 } |
| OLD | NEW |