Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: src/core/SkScan_Antihair.cpp

Issue 117053002: remove SK_SCALAR_IS_[FLOAT,FIXED] and assume floats (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 The Android Open Source Project 3 * Copyright 2011 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkScan.h" 10 #include "SkScan.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 595 }
596 596
597 SkASSERT(clip == NULL || !clip->getBounds().isEmpty()); 597 SkASSERT(clip == NULL || !clip->getBounds().isEmpty());
598 598
599 #ifdef TEST_GAMMA 599 #ifdef TEST_GAMMA
600 build_gamma_table(); 600 build_gamma_table();
601 #endif 601 #endif
602 602
603 SkPoint pts[2] = { pt0, pt1 }; 603 SkPoint pts[2] = { pt0, pt1 };
604 604
605 #ifdef SK_SCALAR_IS_FLOAT
606 // We have to pre-clip the line to fit in a SkFixed, so we just chop 605 // We have to pre-clip the line to fit in a SkFixed, so we just chop
607 // the line. TODO find a way to actually draw beyond that range. 606 // the line. TODO find a way to actually draw beyond that range.
608 { 607 {
609 SkRect fixedBounds; 608 SkRect fixedBounds;
610 const SkScalar max = SkIntToScalar(32767); 609 const SkScalar max = SkIntToScalar(32767);
611 fixedBounds.set(-max, -max, max, max); 610 fixedBounds.set(-max, -max, max, max);
612 if (!SkLineClipper::IntersectLine(pts, fixedBounds, pts)) { 611 if (!SkLineClipper::IntersectLine(pts, fixedBounds, pts)) {
613 return; 612 return;
614 } 613 }
615 } 614 }
616 #endif
617 615
618 if (clip) { 616 if (clip) {
619 SkRect clipBounds; 617 SkRect clipBounds;
620 clipBounds.set(clip->getBounds()); 618 clipBounds.set(clip->getBounds());
621 /* We perform integral clipping later on, but we do a scalar clip first 619 /* We perform integral clipping later on, but we do a scalar clip first
622 to ensure that our coordinates are expressible in fixed/integers. 620 to ensure that our coordinates are expressible in fixed/integers.
623 621
624 antialiased hairlines can draw up to 1/2 of a pixel outside of 622 antialiased hairlines can draw up to 1/2 of a pixel outside of
625 their bounds, so we need to outset the clip before calling the 623 their bounds, so we need to outset the clip before calling the
626 clipper. To make the numerics safer, we outset by a whole pixel, 624 clipper. To make the numerics safer, we outset by a whole pixel,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 AntiFillXRect(xr, NULL, blitter); 819 AntiFillXRect(xr, NULL, blitter);
822 } else { 820 } else {
823 SkAAClipBlitterWrapper wrapper(clip, blitter); 821 SkAAClipBlitterWrapper wrapper(clip, blitter);
824 blitter = wrapper.getBlitter(); 822 blitter = wrapper.getBlitter();
825 823
826 AntiFillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter()); 824 AntiFillXRect(xr, &wrapper.getRgn(), wrapper.getBlitter());
827 } 825 }
828 } 826 }
829 } 827 }
830 828
831 #ifdef SK_SCALAR_IS_FLOAT
832
833 /* This guy takes a float-rect, but with the key improvement that it has 829 /* This guy takes a float-rect, but with the key improvement that it has
834 already been clipped, so we know that it is safe to convert it into a 830 already been clipped, so we know that it is safe to convert it into a
835 XRect (fixedpoint), as it won't overflow. 831 XRect (fixedpoint), as it won't overflow.
836 */ 832 */
837 static void antifillrect(const SkRect& r, SkBlitter* blitter) { 833 static void antifillrect(const SkRect& r, SkBlitter* blitter) {
838 SkXRect xr; 834 SkXRect xr;
839 835
840 XRect_set(&xr, r); 836 XRect_set(&xr, r);
841 antifillrect(xr, blitter); 837 antifillrect(xr, blitter);
842 } 838 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 void SkScan::AntiFillRect(const SkRect& r, const SkRasterClip& clip, 877 void SkScan::AntiFillRect(const SkRect& r, const SkRasterClip& clip,
882 SkBlitter* blitter) { 878 SkBlitter* blitter) {
883 if (clip.isBW()) { 879 if (clip.isBW()) {
884 AntiFillRect(r, &clip.bwRgn(), blitter); 880 AntiFillRect(r, &clip.bwRgn(), blitter);
885 } else { 881 } else {
886 SkAAClipBlitterWrapper wrap(clip, blitter); 882 SkAAClipBlitterWrapper wrap(clip, blitter);
887 AntiFillRect(r, &wrap.getRgn(), wrap.getBlitter()); 883 AntiFillRect(r, &wrap.getRgn(), wrap.getBlitter());
888 } 884 }
889 } 885 }
890 886
891 #endif // SK_SCALAR_IS_FLOAT
892
893 /////////////////////////////////////////////////////////////////////////////// 887 ///////////////////////////////////////////////////////////////////////////////
894 888
895 #define SkAlphaMulRound(a, b) SkMulDiv255Round(a, b) 889 #define SkAlphaMulRound(a, b) SkMulDiv255Round(a, b)
896 890
897 // calls blitRect() if the rectangle is non-empty 891 // calls blitRect() if the rectangle is non-empty
898 static void fillcheckrect(int L, int T, int R, int B, SkBlitter* blitter) { 892 static void fillcheckrect(int L, int T, int R, int B, SkBlitter* blitter) {
899 if (L < R && T < B) { 893 if (L < R && T < B) {
900 blitter->blitRect(L, T, R - L, B - T); 894 blitter->blitRect(L, T, R - L, B - T);
901 } 895 }
902 } 896 }
903 897
904 static inline FDot8 SkScalarToFDot8(SkScalar x) { 898 static inline FDot8 SkScalarToFDot8(SkScalar x) {
905 #ifdef SK_SCALAR_IS_FLOAT
906 return (int)(x * 256); 899 return (int)(x * 256);
907 #else
908 return x >> 8;
909 #endif
910 } 900 }
911 901
912 static inline int FDot8Floor(FDot8 x) { 902 static inline int FDot8Floor(FDot8 x) {
913 return x >> 8; 903 return x >> 8;
914 } 904 }
915 905
916 static inline int FDot8Ceil(FDot8 x) { 906 static inline int FDot8Ceil(FDot8 x) {
917 return (x + 0xFF) >> 8; 907 return (x + 0xFF) >> 8;
918 } 908 }
919 909
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1045
1056 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize, 1046 void SkScan::AntiFrameRect(const SkRect& r, const SkPoint& strokeSize,
1057 const SkRasterClip& clip, SkBlitter* blitter) { 1047 const SkRasterClip& clip, SkBlitter* blitter) {
1058 if (clip.isBW()) { 1048 if (clip.isBW()) {
1059 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter); 1049 AntiFrameRect(r, strokeSize, &clip.bwRgn(), blitter);
1060 } else { 1050 } else {
1061 SkAAClipBlitterWrapper wrap(clip, blitter); 1051 SkAAClipBlitterWrapper wrap(clip, blitter);
1062 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter()); 1052 AntiFrameRect(r, strokeSize, &wrap.getRgn(), wrap.getBlitter());
1063 } 1053 }
1064 } 1054 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698