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 #include "SkAnnotationKeys.h" | 9 #include "SkAnnotationKeys.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } | 646 } |
647 }; | 647 }; |
648 | 648 |
649 //////////////////////////////////////////////////////////////////////////////// | 649 //////////////////////////////////////////////////////////////////////////////// |
650 | 650 |
651 SkPDFDevice::SkPDFDevice(SkISize pageSize, SkScalar rasterDpi, SkPDFDocument* do
c, bool flip) | 651 SkPDFDevice::SkPDFDevice(SkISize pageSize, SkScalar rasterDpi, SkPDFDocument* do
c, bool flip) |
652 : INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry)) | 652 : INHERITED(SkSurfaceProps(0, kUnknown_SkPixelGeometry)) |
653 , fPageSize(pageSize) | 653 , fPageSize(pageSize) |
654 , fContentSize(pageSize) | 654 , fContentSize(pageSize) |
655 , fExistingClipRegion(SkIRect::MakeSize(pageSize)) | 655 , fExistingClipRegion(SkIRect::MakeSize(pageSize)) |
656 , fClipStack(nullptr) | |
657 , fRasterDpi(rasterDpi) | 656 , fRasterDpi(rasterDpi) |
658 , fDocument(doc) { | 657 , fDocument(doc) { |
659 SkASSERT(pageSize.width() > 0); | 658 SkASSERT(pageSize.width() > 0); |
660 SkASSERT(pageSize.height() > 0); | 659 SkASSERT(pageSize.height() > 0); |
661 | 660 |
662 if (flip) { | 661 if (flip) { |
663 // Skia generally uses the top left as the origin but PDF | 662 // Skia generally uses the top left as the origin but PDF |
664 // natively has the origin at the bottom left. This matrix | 663 // natively has the origin at the bottom left. This matrix |
665 // corrects for that. But that only needs to be done once, we | 664 // corrects for that. But that only needs to be done once, we |
666 // don't do it when layering. | 665 // don't do it when layering. |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 auto xObject = sk_make_sp<SkPDFFormXObject>(pdfDevice); | 1397 auto xObject = sk_make_sp<SkPDFFormXObject>(pdfDevice); |
1399 SkPDFUtils::DrawFormXObject(this->addXObjectResource(xObject.get()), | 1398 SkPDFUtils::DrawFormXObject(this->addXObjectResource(xObject.get()), |
1400 &content.entry()->fContent); | 1399 &content.entry()->fContent); |
1401 } | 1400 } |
1402 | 1401 |
1403 SkImageInfo SkPDFDevice::imageInfo() const { | 1402 SkImageInfo SkPDFDevice::imageInfo() const { |
1404 SkImageInfo info = SkImageInfo::MakeUnknown(fPageSize.width(), fPageSize.hei
ght()); | 1403 SkImageInfo info = SkImageInfo::MakeUnknown(fPageSize.width(), fPageSize.hei
ght()); |
1405 return info; | 1404 return info; |
1406 } | 1405 } |
1407 | 1406 |
1408 void SkPDFDevice::onAttachToCanvas(SkCanvas* canvas) { | |
1409 INHERITED::onAttachToCanvas(canvas); | |
1410 | |
1411 // Canvas promises that this ptr is valid until onDetachFromCanvas is called | |
1412 fClipStack = canvas->getClipStack(); | |
1413 } | |
1414 | |
1415 void SkPDFDevice::onDetachFromCanvas() { | |
1416 INHERITED::onDetachFromCanvas(); | |
1417 | |
1418 fClipStack = nullptr; | |
1419 } | |
1420 | |
1421 sk_sp<SkSurface> SkPDFDevice::makeSurface(const SkImageInfo& info, const SkSurfa
ceProps& props) { | 1407 sk_sp<SkSurface> SkPDFDevice::makeSurface(const SkImageInfo& info, const SkSurfa
ceProps& props) { |
1422 return SkSurface::MakeRaster(info, &props); | 1408 return SkSurface::MakeRaster(info, &props); |
1423 } | 1409 } |
1424 | 1410 |
1425 | 1411 |
1426 sk_sp<SkPDFDict> SkPDFDevice::makeResourceDict() const { | 1412 sk_sp<SkPDFDict> SkPDFDevice::makeResourceDict() const { |
1427 SkTDArray<SkPDFObject*> fonts; | 1413 SkTDArray<SkPDFObject*> fonts; |
1428 fonts.setReserve(fFontResources.count()); | 1414 fonts.setReserve(fFontResources.count()); |
1429 for (SkPDFFont* font : fFontResources) { | 1415 for (SkPDFFont* font : fFontResources) { |
1430 fonts.push(font); | 1416 fonts.push(font); |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 } | 2241 } |
2256 | 2242 |
2257 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { | 2243 sk_sp<SkSpecialImage> SkPDFDevice::makeSpecial(const SkImage* image) { |
2258 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), | 2244 return SkSpecialImage::MakeFromImage(SkIRect::MakeWH(image->width(), image->
height()), |
2259 image->makeNonTextureImage()); | 2245 image->makeNonTextureImage()); |
2260 } | 2246 } |
2261 | 2247 |
2262 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { | 2248 sk_sp<SkSpecialImage> SkPDFDevice::snapSpecial() { |
2263 return nullptr; | 2249 return nullptr; |
2264 } | 2250 } |
OLD | NEW |