| 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 |
| 8 #include "SkDraw.h" | 9 #include "SkDraw.h" |
| 9 #include "SkBlitter.h" | 10 #include "SkBlitter.h" |
| 10 #include "SkBounder.h" | 11 #include "SkBounder.h" |
| 11 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 12 #include "SkColorPriv.h" | 13 #include "SkColorPriv.h" |
| 13 #include "SkDevice.h" | 14 #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 SkIRect ir; | 876 if (true) { |
| 877 devRect.roundOut(&ir); | 877 SkIRect ir; |
| 878 if (paint.getStyle() != SkPaint::kFill_Style) { | 878 devRect.roundOut(&ir); |
| 879 // extra space for hairlines | 879 if (paint.getStyle() != SkPaint::kFill_Style) { |
| 880 ir.inset(-1, -1); | 880 // extra space for hairlines |
| 881 } | 881 ir.inset(-1, -1); |
| 882 if (fRC->quickReject(ir)) { | 882 } |
| 883 return; | 883 if (fRC->quickReject(ir)) |
| 884 return; |
| 884 } | 885 } |
| 885 | 886 |
| 886 SkDeviceLooper looper(*fBitmap, *fRC, ir, paint.isAntiAlias()); | 887 SkAutoBlitterChoose blitterStorage(*fBitmap, matrix, paint); |
| 887 while (looper.next()) { | 888 const SkRasterClip& clip = *fRC; |
| 888 SkRect localDevRect; | 889 SkBlitter* blitter = blitterStorage.get(); |
| 889 looper.mapRect(&localDevRect, devRect); | |
| 890 SkMatrix localMatrix; | |
| 891 looper.mapMatrix(&localMatrix, matrix); | |
| 892 | 890 |
| 893 SkAutoBlitterChoose blitterStorage(looper.getBitmap(), localMatrix, | 891 // we want to "fill" if we are kFill or kStrokeAndFill, since in the latter |
| 894 paint); | 892 // case we are also hairline (if we've gotten to here), which devolves to |
| 895 const SkRasterClip& clip = looper.getRC(); | 893 // effectively just kFill |
| 896 SkBlitter* blitter = blitterStorage.get(); | 894 switch (rtype) { |
| 897 | 895 case kFill_RectType: |
| 898 // we want to "fill" if we are kFill or kStrokeAndFill, since in the lat
ter | 896 if (paint.isAntiAlias()) { |
| 899 // case we are also hairline (if we've gotten to here), which devolves t
o | 897 SkScan::AntiFillRect(devRect, clip, blitter); |
| 900 // effectively just kFill | 898 } else { |
| 901 switch (rtype) { | 899 SkScan::FillRect(devRect, clip, blitter); |
| 902 case kFill_RectType: | 900 } |
| 903 if (paint.isAntiAlias()) { | 901 break; |
| 904 SkScan::AntiFillRect(localDevRect, clip, blitter); | 902 case kStroke_RectType: |
| 905 } else { | 903 if (paint.isAntiAlias()) { |
| 906 SkScan::FillRect(localDevRect, clip, blitter); | 904 SkScan::AntiFrameRect(devRect, strokeSize, clip, blitter); |
| 907 } | 905 } else { |
| 908 break; | 906 SkScan::FrameRect(devRect, strokeSize, clip, blitter); |
| 909 case kStroke_RectType: | 907 } |
| 910 if (paint.isAntiAlias()) { | 908 break; |
| 911 SkScan::AntiFrameRect(localDevRect, strokeSize, clip, blitte
r); | 909 case kHair_RectType: |
| 912 } else { | 910 if (paint.isAntiAlias()) { |
| 913 SkScan::FrameRect(localDevRect, strokeSize, clip, blitter); | 911 SkScan::AntiHairRect(devRect, clip, blitter); |
| 914 } | 912 } else { |
| 915 break; | 913 SkScan::HairRect(devRect, clip, blitter); |
| 916 case kHair_RectType: | 914 } |
| 917 if (paint.isAntiAlias()) { | 915 break; |
| 918 SkScan::AntiHairRect(localDevRect, clip, blitter); | 916 default: |
| 919 } else { | 917 SkDEBUGFAIL("bad rtype"); |
| 920 SkScan::HairRect(localDevRect, clip, blitter); | |
| 921 } | |
| 922 break; | |
| 923 default: | |
| 924 SkDEBUGFAIL("bad rtype"); | |
| 925 } | |
| 926 } | 918 } |
| 927 } | 919 } |
| 928 | 920 |
| 929 void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint) const { | 921 void SkDraw::drawDevMask(const SkMask& srcM, const SkPaint& paint) const { |
| 930 if (srcM.fBounds.isEmpty()) { | 922 if (srcM.fBounds.isEmpty()) { |
| 931 return; | 923 return; |
| 932 } | 924 } |
| 933 | 925 |
| 934 const SkMask* mask = &srcM; | 926 const SkMask* mask = &srcM; |
| 935 | 927 |
| (...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2826 mask->fImage = SkMask::AllocImage(size); | 2818 mask->fImage = SkMask::AllocImage(size); |
| 2827 memset(mask->fImage, 0, mask->computeImageSize()); | 2819 memset(mask->fImage, 0, mask->computeImageSize()); |
| 2828 } | 2820 } |
| 2829 | 2821 |
| 2830 if (SkMask::kJustComputeBounds_CreateMode != mode) { | 2822 if (SkMask::kJustComputeBounds_CreateMode != mode) { |
| 2831 draw_into_mask(*mask, devPath, style); | 2823 draw_into_mask(*mask, devPath, style); |
| 2832 } | 2824 } |
| 2833 | 2825 |
| 2834 return true; | 2826 return true; |
| 2835 } | 2827 } |
| 2836 | |
| OLD | NEW |