| 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 bitmap.setConfig(SkBitmap::kNo_Config, abs(contentSize.fWidth), | 665 bitmap.setConfig(SkBitmap::kNo_Config, abs(contentSize.fWidth), |
| 666 abs(contentSize.fHeight)); | 666 abs(contentSize.fHeight)); |
| 667 } | 667 } |
| 668 | 668 |
| 669 return bitmap; | 669 return bitmap; |
| 670 } | 670 } |
| 671 | 671 |
| 672 // TODO(vandebo) change pageSize to SkSize. | 672 // TODO(vandebo) change pageSize to SkSize. |
| 673 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, | 673 SkPDFDevice::SkPDFDevice(const SkISize& pageSize, const SkISize& contentSize, |
| 674 const SkMatrix& initialTransform) | 674 const SkMatrix& initialTransform) |
| 675 : SkDevice(makeContentBitmap(contentSize, &initialTransform)), | 675 : SkRasterDevice(makeContentBitmap(contentSize, &initialTransform)), |
| 676 fPageSize(pageSize), | 676 fPageSize(pageSize), |
| 677 fContentSize(contentSize), | 677 fContentSize(contentSize), |
| 678 fLastContentEntry(NULL), | 678 fLastContentEntry(NULL), |
| 679 fLastMarginContentEntry(NULL), | 679 fLastMarginContentEntry(NULL), |
| 680 fClipStack(NULL), | 680 fClipStack(NULL), |
| 681 fEncoder(NULL) { | 681 fEncoder(NULL) { |
| 682 // Skia generally uses the top left as the origin but PDF natively has the | 682 // 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 | 683 // 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. | 684 // needs to be done once, we don't do it when layering. |
| 685 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); | 685 fInitialTransform.setTranslate(0, SkIntToScalar(pageSize.fHeight)); |
| 686 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); | 686 fInitialTransform.preScale(SK_Scalar1, -SK_Scalar1); |
| 687 fInitialTransform.preConcat(initialTransform); | 687 fInitialTransform.preConcat(initialTransform); |
| 688 | 688 |
| 689 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); | 689 SkIRect existingClip = SkIRect::MakeWH(this->width(), this->height()); |
| 690 fExistingClipRegion.setRect(existingClip); | 690 fExistingClipRegion.setRect(existingClip); |
| 691 | 691 |
| 692 this->init(); | 692 this->init(); |
| 693 } | 693 } |
| 694 | 694 |
| 695 // TODO(vandebo) change layerSize to SkSize. | 695 // TODO(vandebo) change layerSize to SkSize. |
| 696 SkPDFDevice::SkPDFDevice(const SkISize& layerSize, | 696 SkPDFDevice::SkPDFDevice(const SkISize& layerSize, |
| 697 const SkClipStack& existingClipStack, | 697 const SkClipStack& existingClipStack, |
| 698 const SkRegion& existingClipRegion) | 698 const SkRegion& existingClipRegion) |
| 699 : SkDevice(makeContentBitmap(layerSize, NULL)), | 699 : SkRasterDevice(makeContentBitmap(layerSize, NULL)), |
| 700 fPageSize(layerSize), | 700 fPageSize(layerSize), |
| 701 fContentSize(layerSize), | 701 fContentSize(layerSize), |
| 702 fExistingClipStack(existingClipStack), | 702 fExistingClipStack(existingClipStack), |
| 703 fExistingClipRegion(existingClipRegion), | 703 fExistingClipRegion(existingClipRegion), |
| 704 fLastContentEntry(NULL), | 704 fLastContentEntry(NULL), |
| 705 fLastMarginContentEntry(NULL), | 705 fLastMarginContentEntry(NULL), |
| 706 fClipStack(NULL) { | 706 fClipStack(NULL) { |
| 707 fInitialTransform.reset(); | 707 fInitialTransform.reset(); |
| 708 this->init(); | 708 this->init(); |
| 709 } | 709 } |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 if (d.fClip->isEmpty()) { | 1148 if (d.fClip->isEmpty()) { |
| 1149 return; | 1149 return; |
| 1150 } | 1150 } |
| 1151 NOT_IMPLEMENTED("drawVerticies", true); | 1151 NOT_IMPLEMENTED("drawVerticies", true); |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y, | 1154 void SkPDFDevice::drawDevice(const SkDraw& d, SkDevice* device, int x, int y, |
| 1155 const SkPaint& paint) { | 1155 const SkPaint& paint) { |
| 1156 if ((device->getDeviceCapabilities() & kVector_Capability) == 0) { | 1156 if ((device->getDeviceCapabilities() & kVector_Capability) == 0) { |
| 1157 // If we somehow get a raster device, do what our parent would do. | 1157 // If we somehow get a raster device, do what our parent would do. |
| 1158 SkDevice::drawDevice(d, device, x, y, paint); | 1158 INHERITED::drawDevice(d, device, x, y, paint); |
| 1159 return; | 1159 return; |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 // Assume that a vector capable device means that it's a PDF Device. | 1162 // Assume that a vector capable device means that it's a PDF Device. |
| 1163 SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); | 1163 SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); |
| 1164 if (pdfDevice->isContentEmpty()) { | 1164 if (pdfDevice->isContentEmpty()) { |
| 1165 return; | 1165 return; |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 SkMatrix matrix; | 1168 SkMatrix matrix; |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 } | 1920 } |
| 1921 | 1921 |
| 1922 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 1922 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
| 1923 SkCanvas::Config8888) { | 1923 SkCanvas::Config8888) { |
| 1924 return false; | 1924 return false; |
| 1925 } | 1925 } |
| 1926 | 1926 |
| 1927 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 1927 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
| 1928 return false; | 1928 return false; |
| 1929 } | 1929 } |
| OLD | NEW |