| 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 "SkAnnotationKeys.h" | 10 #include "SkAnnotationKeys.h" |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 // A helper class to automatically finish a ContentEntry at the end of a | 560 // A helper class to automatically finish a ContentEntry at the end of a |
| 561 // drawing method and maintain the state needed between set up and finish. | 561 // drawing method and maintain the state needed between set up and finish. |
| 562 class ScopedContentEntry { | 562 class ScopedContentEntry { |
| 563 public: | 563 public: |
| 564 ScopedContentEntry(SkPDFDevice* device, const SkDraw& draw, | 564 ScopedContentEntry(SkPDFDevice* device, const SkDraw& draw, |
| 565 const SkPaint& paint, bool hasText = false) | 565 const SkPaint& paint, bool hasText = false) |
| 566 : fDevice(device), | 566 : fDevice(device), |
| 567 fContentEntry(nullptr), | 567 fContentEntry(nullptr), |
| 568 fXfermode(SkXfermode::kSrcOver_Mode), | 568 fXfermode(SkXfermode::kSrcOver_Mode), |
| 569 fDstFormXObject(nullptr) { | 569 fDstFormXObject(nullptr) { |
| 570 init(draw.fClipStack, *draw.fClip, *draw.fMatrix, paint, hasText); | 570 init(draw.fClipStack, draw.fRC->bwRgn(), *draw.fMatrix, paint, hasText); |
| 571 } | 571 } |
| 572 ScopedContentEntry(SkPDFDevice* device, const SkClipStack* clipStack, | 572 ScopedContentEntry(SkPDFDevice* device, const SkClipStack* clipStack, |
| 573 const SkRegion& clipRegion, const SkMatrix& matrix, | 573 const SkRegion& clipRegion, const SkMatrix& matrix, |
| 574 const SkPaint& paint, bool hasText = false) | 574 const SkPaint& paint, bool hasText = false) |
| 575 : fDevice(device), | 575 : fDevice(device), |
| 576 fContentEntry(nullptr), | 576 fContentEntry(nullptr), |
| 577 fXfermode(SkXfermode::kSrcOver_Mode), | 577 fXfermode(SkXfermode::kSrcOver_Mode), |
| 578 fDstFormXObject(nullptr) { | 578 fDstFormXObject(nullptr) { |
| 579 init(clipStack, clipRegion, matrix, paint, hasText); | 579 init(clipStack, clipRegion, matrix, paint, hasText); |
| 580 } | 580 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 replace_srcmode_on_opaque_paint(&passedPaint); | 745 replace_srcmode_on_opaque_paint(&passedPaint); |
| 746 | 746 |
| 747 if (count == 0) { | 747 if (count == 0) { |
| 748 return; | 748 return; |
| 749 } | 749 } |
| 750 | 750 |
| 751 // SkDraw::drawPoints converts to multiple calls to fDevice->drawPath. | 751 // SkDraw::drawPoints converts to multiple calls to fDevice->drawPath. |
| 752 // We only use this when there's a path effect because of the overhead | 752 // We only use this when there's a path effect because of the overhead |
| 753 // of multiple calls to setUpContentEntry it causes. | 753 // of multiple calls to setUpContentEntry it causes. |
| 754 if (passedPaint.getPathEffect()) { | 754 if (passedPaint.getPathEffect()) { |
| 755 if (d.fClip->isEmpty()) { | 755 if (d.fRC->isEmpty()) { |
| 756 return; | 756 return; |
| 757 } | 757 } |
| 758 SkDraw pointDraw(d); | 758 SkDraw pointDraw(d); |
| 759 pointDraw.fDevice = this; | 759 pointDraw.fDevice = this; |
| 760 pointDraw.drawPoints(mode, count, points, passedPaint, true); | 760 pointDraw.drawPoints(mode, count, points, passedPaint, true); |
| 761 return; | 761 return; |
| 762 } | 762 } |
| 763 | 763 |
| 764 const SkPaint* paint = &passedPaint; | 764 const SkPaint* paint = &passedPaint; |
| 765 SkPaint modifiedPaint; | 765 SkPaint modifiedPaint; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 869 |
| 870 void SkPDFDevice::drawRect(const SkDraw& d, | 870 void SkPDFDevice::drawRect(const SkDraw& d, |
| 871 const SkRect& rect, | 871 const SkRect& rect, |
| 872 const SkPaint& srcPaint) { | 872 const SkPaint& srcPaint) { |
| 873 SkPaint paint = srcPaint; | 873 SkPaint paint = srcPaint; |
| 874 replace_srcmode_on_opaque_paint(&paint); | 874 replace_srcmode_on_opaque_paint(&paint); |
| 875 SkRect r = rect; | 875 SkRect r = rect; |
| 876 r.sort(); | 876 r.sort(); |
| 877 | 877 |
| 878 if (paint.getPathEffect()) { | 878 if (paint.getPathEffect()) { |
| 879 if (d.fClip->isEmpty()) { | 879 if (d.fRC->isEmpty()) { |
| 880 return; | 880 return; |
| 881 } | 881 } |
| 882 SkPath path; | 882 SkPath path; |
| 883 path.addRect(r); | 883 path.addRect(r); |
| 884 drawPath(d, path, paint, nullptr, true); | 884 drawPath(d, path, paint, nullptr, true); |
| 885 return; | 885 return; |
| 886 } | 886 } |
| 887 | 887 |
| 888 ScopedContentEntry content(this, d, paint); | 888 ScopedContentEntry content(this, d, paint); |
| 889 if (!content.entry()) { | 889 if (!content.entry()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 pathPtr = &modifiedPath; | 931 pathPtr = &modifiedPath; |
| 932 pathIsMutable = true; | 932 pathIsMutable = true; |
| 933 } | 933 } |
| 934 origPath.transform(*prePathMatrix, pathPtr); | 934 origPath.transform(*prePathMatrix, pathPtr); |
| 935 } else { | 935 } else { |
| 936 matrix.preConcat(*prePathMatrix); | 936 matrix.preConcat(*prePathMatrix); |
| 937 } | 937 } |
| 938 } | 938 } |
| 939 | 939 |
| 940 if (paint.getPathEffect()) { | 940 if (paint.getPathEffect()) { |
| 941 if (d.fClip->isEmpty()) { | 941 if (d.fRC->isEmpty()) { |
| 942 return; | 942 return; |
| 943 } | 943 } |
| 944 if (!pathIsMutable) { | 944 if (!pathIsMutable) { |
| 945 pathPtr = &modifiedPath; | 945 pathPtr = &modifiedPath; |
| 946 pathIsMutable = true; | 946 pathIsMutable = true; |
| 947 } | 947 } |
| 948 bool fill = paint.getFillPath(origPath, pathPtr); | 948 bool fill = paint.getFillPath(origPath, pathPtr); |
| 949 | 949 |
| 950 SkPaint noEffectPaint(paint); | 950 SkPaint noEffectPaint(paint); |
| 951 noEffectPaint.setPathEffect(nullptr); | 951 noEffectPaint.setPathEffect(nullptr); |
| 952 if (fill) { | 952 if (fill) { |
| 953 noEffectPaint.setStyle(SkPaint::kFill_Style); | 953 noEffectPaint.setStyle(SkPaint::kFill_Style); |
| 954 } else { | 954 } else { |
| 955 noEffectPaint.setStyle(SkPaint::kStroke_Style); | 955 noEffectPaint.setStyle(SkPaint::kStroke_Style); |
| 956 noEffectPaint.setStrokeWidth(0); | 956 noEffectPaint.setStrokeWidth(0); |
| 957 } | 957 } |
| 958 drawPath(d, *pathPtr, noEffectPaint, nullptr, true); | 958 drawPath(d, *pathPtr, noEffectPaint, nullptr, true); |
| 959 return; | 959 return; |
| 960 } | 960 } |
| 961 | 961 |
| 962 if (handleInversePath(d, origPath, paint, pathIsMutable, prePathMatrix)) { | 962 if (handleInversePath(d, origPath, paint, pathIsMutable, prePathMatrix)) { |
| 963 return; | 963 return; |
| 964 } | 964 } |
| 965 | 965 |
| 966 ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint); | 966 ScopedContentEntry content(this, d.fClipStack, d.fRC->bwRgn(), matrix, paint
); |
| 967 if (!content.entry()) { | 967 if (!content.entry()) { |
| 968 return; | 968 return; |
| 969 } | 969 } |
| 970 bool consumeDegeratePathSegments = | 970 bool consumeDegeratePathSegments = |
| 971 paint.getStyle() == SkPaint::kFill_Style || | 971 paint.getStyle() == SkPaint::kFill_Style || |
| 972 (paint.getStrokeCap() != SkPaint::kRound_Cap && | 972 (paint.getStrokeCap() != SkPaint::kRound_Cap && |
| 973 paint.getStrokeCap() != SkPaint::kSquare_Cap); | 973 paint.getStrokeCap() != SkPaint::kSquare_Cap); |
| 974 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), | 974 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), |
| 975 consumeDegeratePathSegments, | 975 consumeDegeratePathSegments, |
| 976 &content.entry()->fContent); | 976 &content.entry()->fContent); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 989 | 989 |
| 990 void SkPDFDevice::drawBitmap(const SkDraw& d, | 990 void SkPDFDevice::drawBitmap(const SkDraw& d, |
| 991 const SkBitmap& bitmap, | 991 const SkBitmap& bitmap, |
| 992 const SkMatrix& matrix, | 992 const SkMatrix& matrix, |
| 993 const SkPaint& srcPaint) { | 993 const SkPaint& srcPaint) { |
| 994 SkPaint paint = srcPaint; | 994 SkPaint paint = srcPaint; |
| 995 if (bitmap.isOpaque()) { | 995 if (bitmap.isOpaque()) { |
| 996 replace_srcmode_on_opaque_paint(&paint); | 996 replace_srcmode_on_opaque_paint(&paint); |
| 997 } | 997 } |
| 998 | 998 |
| 999 if (d.fClip->isEmpty()) { | 999 if (d.fRC->isEmpty()) { |
| 1000 return; | 1000 return; |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 SkMatrix transform = matrix; | 1003 SkMatrix transform = matrix; |
| 1004 transform.postConcat(*d.fMatrix); | 1004 transform.postConcat(*d.fMatrix); |
| 1005 SkImageBitmap imageBitmap(bitmap); | 1005 SkImageBitmap imageBitmap(bitmap); |
| 1006 this->internalDrawImage( | 1006 this->internalDrawImage( |
| 1007 transform, d.fClipStack, *d.fClip, imageBitmap, paint); | 1007 transform, d.fClipStack, d.fRC->bwRgn(), imageBitmap, paint); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 void SkPDFDevice::drawSprite(const SkDraw& d, | 1010 void SkPDFDevice::drawSprite(const SkDraw& d, |
| 1011 const SkBitmap& bitmap, | 1011 const SkBitmap& bitmap, |
| 1012 int x, | 1012 int x, |
| 1013 int y, | 1013 int y, |
| 1014 const SkPaint& srcPaint) { | 1014 const SkPaint& srcPaint) { |
| 1015 SkPaint paint = srcPaint; | 1015 SkPaint paint = srcPaint; |
| 1016 if (bitmap.isOpaque()) { | 1016 if (bitmap.isOpaque()) { |
| 1017 replace_srcmode_on_opaque_paint(&paint); | 1017 replace_srcmode_on_opaque_paint(&paint); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 if (d.fClip->isEmpty()) { | 1020 if (d.fRC->isEmpty()) { |
| 1021 return; | 1021 return; |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 SkMatrix matrix; | 1024 SkMatrix matrix; |
| 1025 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); | 1025 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); |
| 1026 SkImageBitmap imageBitmap(bitmap); | 1026 SkImageBitmap imageBitmap(bitmap); |
| 1027 this->internalDrawImage( | 1027 this->internalDrawImage( |
| 1028 matrix, d.fClipStack, *d.fClip, imageBitmap, paint); | 1028 matrix, d.fClipStack, d.fRC->bwRgn(), imageBitmap, paint); |
| 1029 } | 1029 } |
| 1030 | 1030 |
| 1031 void SkPDFDevice::drawImage(const SkDraw& draw, | 1031 void SkPDFDevice::drawImage(const SkDraw& draw, |
| 1032 const SkImage* image, | 1032 const SkImage* image, |
| 1033 SkScalar x, | 1033 SkScalar x, |
| 1034 SkScalar y, | 1034 SkScalar y, |
| 1035 const SkPaint& srcPaint) { | 1035 const SkPaint& srcPaint) { |
| 1036 SkPaint paint = srcPaint; | 1036 SkPaint paint = srcPaint; |
| 1037 if (!image) { | 1037 if (!image) { |
| 1038 return; | 1038 return; |
| 1039 } | 1039 } |
| 1040 if (image->isOpaque()) { | 1040 if (image->isOpaque()) { |
| 1041 replace_srcmode_on_opaque_paint(&paint); | 1041 replace_srcmode_on_opaque_paint(&paint); |
| 1042 } | 1042 } |
| 1043 if (draw.fClip->isEmpty()) { | 1043 if (draw.fRC->isEmpty()) { |
| 1044 return; | 1044 return; |
| 1045 } | 1045 } |
| 1046 SkMatrix transform = SkMatrix::MakeTrans(x, y); | 1046 SkMatrix transform = SkMatrix::MakeTrans(x, y); |
| 1047 transform.postConcat(*draw.fMatrix); | 1047 transform.postConcat(*draw.fMatrix); |
| 1048 SkImageBitmap imageBitmap(const_cast<SkImage*>(image)); | 1048 SkImageBitmap imageBitmap(const_cast<SkImage*>(image)); |
| 1049 this->internalDrawImage( | 1049 this->internalDrawImage( |
| 1050 transform, draw.fClipStack, *draw.fClip, imageBitmap, paint); | 1050 transform, draw.fClipStack, draw.fRC->bwRgn(), imageBitmap, paint); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 void SkPDFDevice::drawImageRect(const SkDraw& draw, | 1053 void SkPDFDevice::drawImageRect(const SkDraw& draw, |
| 1054 const SkImage* image, | 1054 const SkImage* image, |
| 1055 const SkRect* src, | 1055 const SkRect* src, |
| 1056 const SkRect& dst, | 1056 const SkRect& dst, |
| 1057 const SkPaint& srcPaint, | 1057 const SkPaint& srcPaint, |
| 1058 SkCanvas::SrcRectConstraint constraint) { | 1058 SkCanvas::SrcRectConstraint constraint) { |
| 1059 SkASSERT(false); | 1059 SkASSERT(false); |
| 1060 } | 1060 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 content.entry()->fContent.writeText(" Tj\n"); | 1270 content.entry()->fContent.writeText(" Tj\n"); |
| 1271 } | 1271 } |
| 1272 content.entry()->fContent.writeText("ET\n"); | 1272 content.entry()->fContent.writeText("ET\n"); |
| 1273 } | 1273 } |
| 1274 | 1274 |
| 1275 void SkPDFDevice::drawVertices(const SkDraw& d, SkCanvas::VertexMode, | 1275 void SkPDFDevice::drawVertices(const SkDraw& d, SkCanvas::VertexMode, |
| 1276 int vertexCount, const SkPoint verts[], | 1276 int vertexCount, const SkPoint verts[], |
| 1277 const SkPoint texs[], const SkColor colors[], | 1277 const SkPoint texs[], const SkColor colors[], |
| 1278 SkXfermode* xmode, const uint16_t indices[], | 1278 SkXfermode* xmode, const uint16_t indices[], |
| 1279 int indexCount, const SkPaint& paint) { | 1279 int indexCount, const SkPaint& paint) { |
| 1280 if (d.fClip->isEmpty()) { | 1280 if (d.fRC->isEmpty()) { |
| 1281 return; | 1281 return; |
| 1282 } | 1282 } |
| 1283 // TODO: implement drawVertices | 1283 // TODO: implement drawVertices |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device, | 1286 void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device, |
| 1287 int x, int y, const SkPaint& paint) { | 1287 int x, int y, const SkPaint& paint) { |
| 1288 // our onCreateCompatibleDevice() always creates SkPDFDevice subclasses. | 1288 // our onCreateCompatibleDevice() always creates SkPDFDevice subclasses. |
| 1289 SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); | 1289 SkPDFDevice* pdfDevice = static_cast<SkPDFDevice*>(device); |
| 1290 | 1290 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1302 SkPoint p = d.point + SkPoint::Make(scalarX, scalarY); | 1302 SkPoint p = d.point + SkPoint::Make(scalarX, scalarY); |
| 1303 fNamedDestinations.emplace_back(d.nameData.get(), p); | 1303 fNamedDestinations.emplace_back(d.nameData.get(), p); |
| 1304 } | 1304 } |
| 1305 | 1305 |
| 1306 if (pdfDevice->isContentEmpty()) { | 1306 if (pdfDevice->isContentEmpty()) { |
| 1307 return; | 1307 return; |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 SkMatrix matrix; | 1310 SkMatrix matrix; |
| 1311 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); | 1311 matrix.setTranslate(SkIntToScalar(x), SkIntToScalar(y)); |
| 1312 ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint); | 1312 ScopedContentEntry content(this, d.fClipStack, d.fRC->bwRgn(), matrix, paint
); |
| 1313 if (!content.entry()) { | 1313 if (!content.entry()) { |
| 1314 return; | 1314 return; |
| 1315 } | 1315 } |
| 1316 if (content.needShape()) { | 1316 if (content.needShape()) { |
| 1317 SkPath shape; | 1317 SkPath shape; |
| 1318 shape.addRect(SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), | 1318 shape.addRect(SkRect::MakeXYWH(SkIntToScalar(x), SkIntToScalar(y), |
| 1319 SkIntToScalar(device->width()), | 1319 SkIntToScalar(device->width()), |
| 1320 SkIntToScalar(device->height()))); | 1320 SkIntToScalar(device->height()))); |
| 1321 content.setShape(shape); | 1321 content.setShape(shape); |
| 1322 } | 1322 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 * either as a (incorrect) fallback or because the path was not inverse | 1427 * either as a (incorrect) fallback or because the path was not inverse |
| 1428 * in the first place. | 1428 * in the first place. |
| 1429 */ | 1429 */ |
| 1430 bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, | 1430 bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, |
| 1431 const SkPaint& paint, bool pathIsMutable, | 1431 const SkPaint& paint, bool pathIsMutable, |
| 1432 const SkMatrix* prePathMatrix) { | 1432 const SkMatrix* prePathMatrix) { |
| 1433 if (!origPath.isInverseFillType()) { | 1433 if (!origPath.isInverseFillType()) { |
| 1434 return false; | 1434 return false; |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 if (d.fClip->isEmpty()) { | 1437 if (d.fRC->isEmpty()) { |
| 1438 return false; | 1438 return false; |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 SkPath modifiedPath; | 1441 SkPath modifiedPath; |
| 1442 SkPath* pathPtr = const_cast<SkPath*>(&origPath); | 1442 SkPath* pathPtr = const_cast<SkPath*>(&origPath); |
| 1443 SkPaint noInversePaint(paint); | 1443 SkPaint noInversePaint(paint); |
| 1444 | 1444 |
| 1445 // Merge stroking operations into final path. | 1445 // Merge stroking operations into final path. |
| 1446 if (SkPaint::kStroke_Style == paint.getStyle() || | 1446 if (SkPaint::kStroke_Style == paint.getStyle() || |
| 1447 SkPaint::kStrokeAndFill_Style == paint.getStyle()) { | 1447 SkPaint::kStrokeAndFill_Style == paint.getStyle()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1463 // (clip bounds are given in device space). | 1463 // (clip bounds are given in device space). |
| 1464 SkRect bounds; | 1464 SkRect bounds; |
| 1465 SkMatrix transformInverse; | 1465 SkMatrix transformInverse; |
| 1466 SkMatrix totalMatrix = *d.fMatrix; | 1466 SkMatrix totalMatrix = *d.fMatrix; |
| 1467 if (prePathMatrix) { | 1467 if (prePathMatrix) { |
| 1468 totalMatrix.preConcat(*prePathMatrix); | 1468 totalMatrix.preConcat(*prePathMatrix); |
| 1469 } | 1469 } |
| 1470 if (!totalMatrix.invert(&transformInverse)) { | 1470 if (!totalMatrix.invert(&transformInverse)) { |
| 1471 return false; | 1471 return false; |
| 1472 } | 1472 } |
| 1473 bounds.set(d.fClip->getBounds()); | 1473 bounds.set(d.fRC->getBounds()); |
| 1474 transformInverse.mapRect(&bounds); | 1474 transformInverse.mapRect(&bounds); |
| 1475 | 1475 |
| 1476 // Extend the bounds by the line width (plus some padding) | 1476 // Extend the bounds by the line width (plus some padding) |
| 1477 // so the edge doesn't cause a visible stroke. | 1477 // so the edge doesn't cause a visible stroke. |
| 1478 bounds.outset(paint.getStrokeWidth() + SK_Scalar1, | 1478 bounds.outset(paint.getStrokeWidth() + SK_Scalar1, |
| 1479 paint.getStrokeWidth() + SK_Scalar1); | 1479 paint.getStrokeWidth() + SK_Scalar1); |
| 1480 | 1480 |
| 1481 if (!calculate_inverse_path(bounds, *pathPtr, &modifiedPath)) { | 1481 if (!calculate_inverse_path(bounds, *pathPtr, &modifiedPath)) { |
| 1482 return false; | 1482 return false; |
| 1483 } | 1483 } |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 // the non-transparent parts of the device and the outlines (shape) of | 1751 // the non-transparent parts of the device and the outlines (shape) of |
| 1752 // all images and devices drawn. | 1752 // all images and devices drawn. |
| 1753 drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst, | 1753 drawFormXObjectWithMask(addXObjectResource(srcFormXObject.get()), dst, |
| 1754 &fExistingClipStack, fExistingClipRegion, | 1754 &fExistingClipStack, fExistingClipRegion, |
| 1755 SkXfermode::kSrcOver_Mode, true); | 1755 SkXfermode::kSrcOver_Mode, true); |
| 1756 } else { | 1756 } else { |
| 1757 sk_sp<SkPDFFormXObject> dstMaskStorage; | 1757 sk_sp<SkPDFFormXObject> dstMaskStorage; |
| 1758 SkPDFFormXObject* dstMask = srcFormXObject.get(); | 1758 SkPDFFormXObject* dstMask = srcFormXObject.get(); |
| 1759 if (shape != nullptr) { | 1759 if (shape != nullptr) { |
| 1760 // Draw shape into a form-xobject. | 1760 // Draw shape into a form-xobject. |
| 1761 SkRasterClip rc(clipRegion); |
| 1761 SkDraw d; | 1762 SkDraw d; |
| 1762 d.fMatrix = &identity; | 1763 d.fMatrix = &identity; |
| 1763 d.fClip = &clipRegion; | 1764 d.fRC = &rc; |
| 1764 d.fClipStack = &clipStack; | 1765 d.fClipStack = &clipStack; |
| 1765 SkPaint filledPaint; | 1766 SkPaint filledPaint; |
| 1766 filledPaint.setColor(SK_ColorBLACK); | 1767 filledPaint.setColor(SK_ColorBLACK); |
| 1767 filledPaint.setStyle(SkPaint::kFill_Style); | 1768 filledPaint.setStyle(SkPaint::kFill_Style); |
| 1768 this->drawPath(d, *shape, filledPaint, nullptr, true); | 1769 this->drawPath(d, *shape, filledPaint, nullptr, true); |
| 1769 | 1770 |
| 1770 dstMaskStorage.reset(createFormXObjectFromDevice()); | 1771 dstMaskStorage.reset(createFormXObjectFromDevice()); |
| 1771 dstMask = dstMaskStorage.get(); | 1772 dstMask = dstMaskStorage.get(); |
| 1772 } | 1773 } |
| 1773 drawFormXObjectWithMask(addXObjectResource(dst), dstMask, | 1774 drawFormXObjectWithMask(addXObjectResource(dst), dstMask, |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 if (!pdfimage) { | 2138 if (!pdfimage) { |
| 2138 return; | 2139 return; |
| 2139 } | 2140 } |
| 2140 fDocument->serialize(pdfimage); // serialize images early. | 2141 fDocument->serialize(pdfimage); // serialize images early. |
| 2141 fDocument->canon()->addPDFBitmap(key, pdfimage); | 2142 fDocument->canon()->addPDFBitmap(key, pdfimage); |
| 2142 } | 2143 } |
| 2143 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> | 2144 // TODO(halcanary): addXObjectResource() should take a sk_sp<SkPDFObject> |
| 2144 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), | 2145 SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), |
| 2145 &content.entry()->fContent); | 2146 &content.entry()->fContent); |
| 2146 } | 2147 } |
| OLD | NEW |