OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrOvalRenderer.h" | 8 #include "GrOvalRenderer.h" |
9 | 9 |
10 #include "GrBatchFlushState.h" | 10 #include "GrBatchFlushState.h" |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
936 | 936 |
937 xRadius += scaledStroke.fX; | 937 xRadius += scaledStroke.fX; |
938 yRadius += scaledStroke.fY; | 938 yRadius += scaledStroke.fY; |
939 } | 939 } |
940 | 940 |
941 // We've extended the outer x radius out half a pixel to antialias. | 941 // We've extended the outer x radius out half a pixel to antialias. |
942 // This will also expand the rect so all the pixels will be captured. | 942 // This will also expand the rect so all the pixels will be captured. |
943 // TODO: Consider if we should use sqrt(2)/2 instead | 943 // TODO: Consider if we should use sqrt(2)/2 instead |
944 xRadius += SK_ScalarHalf; | 944 xRadius += SK_ScalarHalf; |
945 yRadius += SK_ScalarHalf; | 945 yRadius += SK_ScalarHalf; |
946 | 946 |
robertphillips
2016/06/30 14:10:16
Hmmm ... can we not just remove the above 2 lines
vjiaoblack
2016/06/30 14:13:35
Right yeah, sorry. Jim pointed this out while over
| |
947 // fix bug where the ovals are drawn 0.5 pixels too big on each side | |
948 // (the 0.5 width antialiasing exceeds the rect bounds) | |
949 xRadius -= 0.5f; | |
950 yRadius -= 0.5f; | |
951 | |
947 EllipseBatch::Geometry geometry; | 952 EllipseBatch::Geometry geometry; |
948 geometry.fColor = color; | 953 geometry.fColor = color; |
949 geometry.fXRadius = xRadius; | 954 geometry.fXRadius = xRadius; |
950 geometry.fYRadius = yRadius; | 955 geometry.fYRadius = yRadius; |
951 geometry.fInnerXRadius = innerXRadius; | 956 geometry.fInnerXRadius = innerXRadius; |
952 geometry.fInnerYRadius = innerYRadius; | 957 geometry.fInnerYRadius = innerYRadius; |
953 geometry.fDevBounds = SkRect::MakeLTRB(center.fX - xRadius, center.fY - yRad ius, | 958 geometry.fDevBounds = SkRect::MakeLTRB(center.fX - xRadius, center.fY - yRad ius, |
954 center.fX + xRadius, center.fY + yRad ius); | 959 center.fX + xRadius, center.fY + yRad ius); |
955 | 960 |
956 return new EllipseBatch(geometry, viewMatrix, | 961 return new EllipseBatch(geometry, viewMatrix, |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1717 } | 1722 } |
1718 | 1723 |
1719 DRAW_BATCH_TEST_DEFINE(RRectBatch) { | 1724 DRAW_BATCH_TEST_DEFINE(RRectBatch) { |
1720 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); | 1725 SkMatrix viewMatrix = GrTest::TestMatrixRectStaysRect(random); |
1721 GrColor color = GrRandomColor(random); | 1726 GrColor color = GrRandomColor(random); |
1722 const SkRRect& rrect = GrTest::TestRRectSimple(random); | 1727 const SkRRect& rrect = GrTest::TestRRectSimple(random); |
1723 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); | 1728 return create_rrect_batch(color, viewMatrix, rrect, GrTest::TestStrokeRec(ra ndom)); |
1724 } | 1729 } |
1725 | 1730 |
1726 #endif | 1731 #endif |
OLD | NEW |