OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 | |
9 #include "SkDraw.h" | 8 #include "SkDraw.h" |
10 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
11 #include "SkBounder.h" | 10 #include "SkBounder.h" |
12 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
13 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
14 #include "SkDevice.h" | 13 #include "SkDevice.h" |
14 #include "SkDeviceLooper.h" | |
15 #include "SkFixed.h" | 15 #include "SkFixed.h" |
16 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
17 #include "SkPaint.h" | 17 #include "SkPaint.h" |
18 #include "SkPathEffect.h" | 18 #include "SkPathEffect.h" |
19 #include "SkRasterClip.h" | 19 #include "SkRasterClip.h" |
20 #include "SkRasterizer.h" | 20 #include "SkRasterizer.h" |
21 #include "SkScan.h" | 21 #include "SkScan.h" |
22 #include "SkShader.h" | 22 #include "SkShader.h" |
23 #include "SkString.h" | 23 #include "SkString.h" |
24 #include "SkStroke.h" | 24 #include "SkStroke.h" |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
866 | 866 |
867 // transform rect into devRect | 867 // transform rect into devRect |
868 matrix.mapPoints(rect_points(devRect), rect_points(rect), 2); | 868 matrix.mapPoints(rect_points(devRect), rect_points(rect), 2); |
869 devRect.sort(); | 869 devRect.sort(); |
870 | 870 |
871 if (fBounder && !fBounder->doRect(devRect, paint)) { | 871 if (fBounder && !fBounder->doRect(devRect, paint)) { |
872 return; | 872 return; |
873 } | 873 } |
874 | 874 |
875 // look for the quick exit, before we build a blitter | 875 // look for the quick exit, before we build a blitter |
876 if (true) { | 876 SkIRect ir; |
877 SkIRect ir; | 877 devRect.roundOut(&ir); |
878 devRect.roundOut(&ir); | 878 if (paint.getStyle() != SkPaint::kFill_Style) { |
879 if (paint.getStyle() != SkPaint::kFill_Style) { | 879 // extra space for hairlines |
880 // extra space for hairlines | 880 ir.inset(-1, -1); |
881 ir.inset(-1, -1); | 881 } |
882 } | 882 if (fRC->quickReject(ir)) { |
883 if (fRC->quickReject(ir)) | 883 return; |
884 return; | |
885 } | 884 } |
886 | 885 |
887 SkAutoBlitterChoose blitterStorage(*fBitmap, matrix, paint); | 886 SkDeviceLooper looper(*fBitmap, *fRC, ir, paint.isAntiAlias()); |
888 const SkRasterClip& clip = *fRC; | 887 while (looper.next()) { |
tomhudson
2013/08/28 10:53:05
This injects another degree of indirection & bunch
reed1
2013/08/28 12:35:07
There should be zero allocations in the (common) c
| |
889 SkBlitter* blitter = blitterStorage.get(); | 888 SkRect localDevRect; |
889 looper.mapRect(&localDevRect, devRect); | |
890 SkMatrix localMatrix; | |
891 looper.mapMatrix(&localMatrix, matrix); | |
890 | 892 |
891 // we want to "fill" if we are kFill or kStrokeAndFill, since in the latter | 893 SkAutoBlitterChoose blitterStorage(looper.getBitmap(), localMatrix, |
892 // case we are also hairline (if we've gotten to here), which devolves to | 894 paint); |
893 // effectively just kFill | 895 const SkRasterClip& clip = looper.getRC(); |
894 switch (rtype) { | 896 SkBlitter* blitter = blitterStorage.get(); |
895 case kFill_RectType: | 897 |
896 if (paint.isAntiAlias()) { | 898 // we want to "fill" if we are kFill or kStrokeAndFill, since in the lat ter |
897 SkScan::AntiFillRect(devRect, clip, blitter); | 899 // case we are also hairline (if we've gotten to here), which devolves t o |
898 } else { | 900 // effectively just kFill |
899 SkScan::FillRect(devRect, clip, blitter); | 901 switch (rtype) { |
900 } | 902 case kFill_RectType: |
901 break; | 903 if (paint.isAntiAlias()) { |
902 case kStroke_RectType: | 904 SkScan::AntiFillRect(localDevRect, clip, blitter); |
903 if (paint.isAntiAlias()) { | 905 } else { |
904 SkScan::AntiFrameRect(devRect, strokeSize, clip, blitter); | 906 SkScan::FillRect(localDevRect, clip, blitter); |
905 } else { | 907 } |
906 SkScan::FrameRect(devRect, strokeSize, clip, blitter); | 908 break; |
907 } | 909 case kStroke_RectType: |
908 break; | 910 if (paint.isAntiAlias()) { |
909 case kHair_RectType: | 911 SkScan::AntiFrameRect(localDevRect, strokeSize, clip, blitte r); |
910 if (paint.isAntiAlias()) { | 912 } else { |
911 SkScan::AntiHairRect(devRect, clip, blitter); | 913 SkScan::FrameRect(localDevRect, strokeSize, clip, blitter); |
912 } else { | 914 } |
913 SkScan::HairRect(devRect, clip, blitter); | 915 break; |
914 } | 916 case kHair_RectType: |
915 break; | 917 if (paint.isAntiAlias()) { |
916 default: | 918 SkScan::AntiHairRect(localDevRect, clip, blitter); |
917 SkDEBUGFAIL("bad rtype"); | 919 } else { |
920 SkScan::HairRect(localDevRect, clip, blitter); | |
921 } | |
922 break; | |
923 default: | |
924 SkDEBUGFAIL("bad rtype"); | |
925 } | |
918 } | 926 } |
919 } | 927 } |
920 | 928 |
921 void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint) const { | 929 void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint) const { |
922 if (srcM.fBounds.isEmpty()) { | 930 if (srcM.fBounds.isEmpty()) { |
923 return; | 931 return; |
924 } | 932 } |
925 | 933 |
926 const SkMask* mask = &srcM; | 934 const SkMask* mask = &srcM; |
927 | 935 |
(...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2818 mask->fImage = SkMask::AllocImage(size); | 2826 mask->fImage = SkMask::AllocImage(size); |
2819 memset(mask->fImage, 0, mask->computeImageSize()); | 2827 memset(mask->fImage, 0, mask->computeImageSize()); |
2820 } | 2828 } |
2821 | 2829 |
2822 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
2823 draw_into_mask(*mask, devPath, style); | 2831 draw_into_mask(*mask, devPath, style); |
2824 } | 2832 } |
2825 | 2833 |
2826 return true; | 2834 return true; |
2827 } | 2835 } |
2836 | |
OLD | NEW |