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 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
966 noEffectPaint.setStyle(SkPaint::kFill_Style); | 966 noEffectPaint.setStyle(SkPaint::kFill_Style); |
967 } else { | 967 } else { |
968 noEffectPaint.setStyle(SkPaint::kStroke_Style); | 968 noEffectPaint.setStyle(SkPaint::kStroke_Style); |
969 noEffectPaint.setStrokeWidth(0); | 969 noEffectPaint.setStrokeWidth(0); |
970 } | 970 } |
971 drawPath(d, *pathPtr, noEffectPaint, NULL, true); | 971 drawPath(d, *pathPtr, noEffectPaint, NULL, true); |
972 return; | 972 return; |
973 } | 973 } |
974 | 974 |
975 #ifdef SK_PDF_USE_PATHOPS | 975 #ifdef SK_PDF_USE_PATHOPS |
976 if (handleInversePath(d, origPath, paint, pathIsMutable)) { | 976 if (handleInversePath(d, origPath, paint, pathIsMutable, prePathMatrix)) { |
977 return; | 977 return; |
978 } | 978 } |
979 #endif | 979 #endif |
980 | 980 |
981 if (handleRectAnnotation(pathPtr->getBounds(), *d.fMatrix, paint)) { | 981 if (handleRectAnnotation(pathPtr->getBounds(), matrix, paint)) { |
982 return; | 982 return; |
983 } | 983 } |
984 | 984 |
985 ScopedContentEntry content(this, d, paint); | 985 ScopedContentEntry content(this, d.fClipStack, *d.fClip, matrix, paint); |
986 if (!content.entry()) { | 986 if (!content.entry()) { |
987 return; | 987 return; |
988 } | 988 } |
989 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), | 989 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), |
990 &content.entry()->fContent); | 990 &content.entry()->fContent); |
991 SkPDFUtils::PaintPath(paint.getStyle(), pathPtr->getFillType(), | 991 SkPDFUtils::PaintPath(paint.getStyle(), pathPtr->getFillType(), |
992 &content.entry()->fContent); | 992 &content.entry()->fContent); |
993 } | 993 } |
994 | 994 |
995 void SkPDFDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, | 995 void SkPDFDevice::drawBitmapRect(const SkDraw& draw, const SkBitmap& bitmap, |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1478 | 1478 |
1479 #ifdef SK_PDF_USE_PATHOPS | 1479 #ifdef SK_PDF_USE_PATHOPS |
1480 /* Draws an inverse filled path by using Path Ops to compute the positive | 1480 /* Draws an inverse filled path by using Path Ops to compute the positive |
1481 * inverse using the current clip as the inverse bounds. | 1481 * inverse using the current clip as the inverse bounds. |
1482 * Return true if this was an inverse path and was properly handled, | 1482 * Return true if this was an inverse path and was properly handled, |
1483 * otherwise returns false and the normal drawing routine should continue, | 1483 * otherwise returns false and the normal drawing routine should continue, |
1484 * either as a (incorrect) fallback or because the path was not inverse | 1484 * either as a (incorrect) fallback or because the path was not inverse |
1485 * in the first place. | 1485 * in the first place. |
1486 */ | 1486 */ |
1487 bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, | 1487 bool SkPDFDevice::handleInversePath(const SkDraw& d, const SkPath& origPath, |
1488 const SkPaint& paint, bool pathIsMutable) { | 1488 const SkPaint& paint, bool pathIsMutable, |
1489 const SkMatrix* prePathMatrix) { | |
1489 if (!origPath.isInverseFillType()) { | 1490 if (!origPath.isInverseFillType()) { |
1490 return false; | 1491 return false; |
1491 } | 1492 } |
1492 | 1493 |
1493 if (d.fClip->isEmpty()) { | 1494 if (d.fClip->isEmpty()) { |
1494 return false; | 1495 return false; |
1495 } | 1496 } |
1496 | 1497 |
1497 SkPath modifiedPath; | 1498 SkPath modifiedPath; |
1498 SkPath* pathPtr = const_cast<SkPath*>(&origPath); | 1499 SkPath* pathPtr = const_cast<SkPath*>(&origPath); |
(...skipping 13 matching lines...) Expand all Loading... | |
1512 modifiedPath.toggleInverseFillType(); | 1513 modifiedPath.toggleInverseFillType(); |
1513 drawPath(d, modifiedPath, paint, NULL, true); | 1514 drawPath(d, modifiedPath, paint, NULL, true); |
1514 return true; | 1515 return true; |
1515 } | 1516 } |
1516 } | 1517 } |
1517 | 1518 |
1518 // Get bounds of clip in current transform space | 1519 // Get bounds of clip in current transform space |
1519 // (clip bounds are given in device space). | 1520 // (clip bounds are given in device space). |
1520 SkRect bounds; | 1521 SkRect bounds; |
1521 SkMatrix transformInverse; | 1522 SkMatrix transformInverse; |
1522 if (!d.fMatrix->invert(&transformInverse)) { | 1523 SkMatrix totalMatrix = *d.fMatrix; |
1524 if (prePathMatrix) { | |
1525 totalMatrix.preConcat(*prePathMatrix); | |
1526 } | |
1527 if (!totalMatrix.invert(&transformInverse)) { | |
1523 return false; | 1528 return false; |
1524 } | 1529 } |
1525 bounds.set(d.fClip->getBounds()); | 1530 bounds.set(d.fClip->getBounds()); |
1526 transformInverse.mapRect(&bounds); | 1531 transformInverse.mapRect(&bounds); |
1527 | 1532 |
1528 // Extend the bounds by the line width (plus some padding) | 1533 // Extend the bounds by the line width (plus some padding) |
1529 // so the edge doesn't cause a visible stroke. | 1534 // so the edge doesn't cause a visible stroke. |
1530 bounds.outset(paint.getStrokeWidth() + SK_Scalar1, | 1535 bounds.outset(paint.getStrokeWidth() + SK_Scalar1, |
1531 paint.getStrokeWidth() + SK_Scalar1); | 1536 paint.getStrokeWidth() + SK_Scalar1); |
1532 | 1537 |
1533 if (!calculate_inverse_path(bounds, *pathPtr, &modifiedPath)) { | 1538 if (!calculate_inverse_path(bounds, *pathPtr, &modifiedPath)) { |
1534 return false; | 1539 return false; |
1535 } | 1540 } |
1536 | 1541 |
1537 drawPath(d, modifiedPath, noInversePaint, NULL, true); | 1542 drawPath(d, modifiedPath, noInversePaint, &totalMatrix, true); |
vandebo (ex-Chrome)
2013/10/04 18:40:21
Shouldn't this be the prePathMatrix?
edisonn
2013/10/04 18:46:23
Done.
| |
1538 return true; | 1543 return true; |
1539 } | 1544 } |
1540 #endif | 1545 #endif |
1541 | 1546 |
1542 bool SkPDFDevice::handleRectAnnotation(const SkRect& r, const SkMatrix& matrix, | 1547 bool SkPDFDevice::handleRectAnnotation(const SkRect& r, const SkMatrix& matrix, |
1543 const SkPaint& p) { | 1548 const SkPaint& p) { |
1544 SkAnnotation* annotationInfo = p.getAnnotation(); | 1549 SkAnnotation* annotationInfo = p.getAnnotation(); |
1545 if (!annotationInfo) { | 1550 if (!annotationInfo) { |
1546 return false; | 1551 return false; |
1547 } | 1552 } |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2058 } | 2063 } |
2059 | 2064 |
2060 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 2065 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
2061 SkCanvas::Config8888) { | 2066 SkCanvas::Config8888) { |
2062 return false; | 2067 return false; |
2063 } | 2068 } |
2064 | 2069 |
2065 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 2070 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
2066 return false; | 2071 return false; |
2067 } | 2072 } |
OLD | NEW |