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" |
11 #include "SkColor.h" | 11 #include "SkColor.h" |
12 #include "SkClipStack.h" | 12 #include "SkClipStack.h" |
13 #include "SkData.h" | 13 #include "SkData.h" |
14 #include "SkDraw.h" | 14 #include "SkDraw.h" |
15 #include "SkFontHost.h" | 15 #include "SkFontHost.h" |
16 #include "SkGlyphCache.h" | 16 #include "SkGlyphCache.h" |
17 #include "SkPaint.h" | 17 #include "SkPaint.h" |
18 #include "SkPath.h" | 18 #include "SkPath.h" |
19 #include "SkPathOps.h" | |
19 #include "SkPDFFont.h" | 20 #include "SkPDFFont.h" |
20 #include "SkPDFFormXObject.h" | 21 #include "SkPDFFormXObject.h" |
21 #include "SkPDFGraphicState.h" | 22 #include "SkPDFGraphicState.h" |
22 #include "SkPDFImage.h" | 23 #include "SkPDFImage.h" |
23 #include "SkPDFResourceDict.h" | 24 #include "SkPDFResourceDict.h" |
24 #include "SkPDFShader.h" | 25 #include "SkPDFShader.h" |
25 #include "SkPDFStream.h" | 26 #include "SkPDFStream.h" |
26 #include "SkPDFTypes.h" | 27 #include "SkPDFTypes.h" |
27 #include "SkPDFUtils.h" | 28 #include "SkPDFUtils.h" |
28 #include "SkRect.h" | 29 #include "SkRect.h" |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
819 } | 820 } |
820 } | 821 } |
821 } | 822 } |
822 | 823 |
823 if (paint.getPathEffect()) { | 824 if (paint.getPathEffect()) { |
824 if (d.fClip->isEmpty()) { | 825 if (d.fClip->isEmpty()) { |
825 return; | 826 return; |
826 } | 827 } |
827 if (!pathIsMutable) { | 828 if (!pathIsMutable) { |
828 pathPtr = &modifiedPath; | 829 pathPtr = &modifiedPath; |
829 pathIsMutable = true; | |
ducky
2013/07/25 03:32:20
This code really doesn't do anything (I think, at
| |
830 } | 830 } |
831 bool fill = paint.getFillPath(origPath, pathPtr); | 831 bool fill = paint.getFillPath(origPath, pathPtr); |
832 | 832 |
833 SkPaint noEffectPaint(paint); | 833 SkPaint noEffectPaint(paint); |
834 noEffectPaint.setPathEffect(NULL); | 834 noEffectPaint.setPathEffect(NULL); |
835 if (fill) { | 835 if (fill) { |
836 noEffectPaint.setStyle(SkPaint::kFill_Style); | 836 noEffectPaint.setStyle(SkPaint::kFill_Style); |
837 } else { | 837 } else { |
838 noEffectPaint.setStyle(SkPaint::kStroke_Style); | 838 noEffectPaint.setStyle(SkPaint::kStroke_Style); |
839 noEffectPaint.setStrokeWidth(0); | 839 noEffectPaint.setStrokeWidth(0); |
840 } | 840 } |
841 drawPath(d, *pathPtr, noEffectPaint, NULL, true); | 841 drawPath(d, *pathPtr, noEffectPaint, NULL, true); |
842 return; | 842 return; |
843 } | 843 } |
844 | 844 |
845 // TODO(richardlin): This doesn't handle inverse stroke (line) operations. | |
846 // Related to Issue 241. | |
847 if (origPath.isInverseFillType()) { | |
848 if (d.fClip->isEmpty()) { | |
849 return; | |
850 } | |
851 if (!pathIsMutable) { | |
852 pathPtr = &modifiedPath; | |
853 } | |
854 | |
855 // Get bounds of clip in current transform space | |
856 // (clip bounds are given in device space). | |
857 SkRect bounds; | |
858 SkMatrix transformInverse; | |
859 if (!d.fMatrix->invert(&transformInverse)) { | |
860 return; | |
861 } | |
862 bounds.set(d.fClip->getBounds()); | |
863 transformInverse.mapRect(&bounds); | |
864 | |
865 // Extend the bounds by the line width, so the edge doesn't cause | |
866 // a visible stroke. | |
867 SkScalar lineWidth = paint.getStrokeWidth(); | |
868 bounds = SkRect::MakeLTRB( | |
869 bounds.left() - lineWidth, bounds.top() - lineWidth, | |
870 bounds.right() + lineWidth, bounds.bottom() + lineWidth); | |
871 | |
872 SkPath fillPath; | |
873 fillPath.addRect(bounds); | |
874 | |
875 // Create positive version of original path, since PathOps takes | |
876 // inverse fills into account. | |
877 SkPath origDup(origPath); | |
878 origDup.toggleInverseFillType(); | |
879 | |
880 if (Op(fillPath, origDup, kDifference_PathOp, pathPtr)) { | |
881 drawPath(d, *pathPtr, paint, NULL, true); | |
882 } | |
883 return; | |
884 } | |
885 | |
845 if (handleRectAnnotation(pathPtr->getBounds(), *d.fMatrix, paint)) { | 886 if (handleRectAnnotation(pathPtr->getBounds(), *d.fMatrix, paint)) { |
846 return; | 887 return; |
847 } | 888 } |
848 | 889 |
849 ScopedContentEntry content(this, d, paint); | 890 ScopedContentEntry content(this, d, paint); |
850 if (!content.entry()) { | 891 if (!content.entry()) { |
851 return; | 892 return; |
852 } | 893 } |
853 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), | 894 SkPDFUtils::EmitPath(*pathPtr, paint.getStyle(), |
854 &content.entry()->fContent); | 895 &content.entry()->fContent); |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1753 } | 1794 } |
1754 | 1795 |
1755 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, | 1796 bool SkPDFDevice::onReadPixels(const SkBitmap& bitmap, int x, int y, |
1756 SkCanvas::Config8888) { | 1797 SkCanvas::Config8888) { |
1757 return false; | 1798 return false; |
1758 } | 1799 } |
1759 | 1800 |
1760 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { | 1801 bool SkPDFDevice::allowImageFilter(SkImageFilter*) { |
1761 return false; | 1802 return false; |
1762 } | 1803 } |
OLD | NEW |