OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
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 #include "SkTwoPointConicalGradient_gpu.h" | 9 #include "SkTwoPointConicalGradient_gpu.h" |
10 | 10 |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 matrix.mapPoints(¢erEndTrans, ¢erEnd, 1); | 778 matrix.mapPoints(¢erEndTrans, ¢erEnd, 1); |
779 | 779 |
780 SkScalar A = centerEndTrans.fX * centerEndTrans.fX + centerEndTrans.fY * cen terEndTrans.fY | 780 SkScalar A = centerEndTrans.fX * centerEndTrans.fX + centerEndTrans.fY * cen terEndTrans.fY |
781 - radiusEnd * radiusEnd + 2 * radiusEnd - 1; | 781 - radiusEnd * radiusEnd + 2 * radiusEnd - 1; |
782 | 782 |
783 // Check to see if start circle is inside end circle with edges touching. | 783 // Check to see if start circle is inside end circle with edges touching. |
784 // If touching we return that it is of kEdge_ConicalType, and leave the matr ix setting | 784 // If touching we return that it is of kEdge_ConicalType, and leave the matr ix setting |
785 // to the edge shader. kEdgeErrorTol = 5 * kErrorTol was picked after manual testing | 785 // to the edge shader. kEdgeErrorTol = 5 * kErrorTol was picked after manual testing |
786 // so that C = 1 / A is stable, and the linear approximation used in the Edg e shader is | 786 // so that C = 1 / A is stable, and the linear approximation used in the Edg e shader is |
787 // still accurate. | 787 // still accurate. |
788 if (SkScalarAbs(A) < kEdgeErrorTol) { | 788 if (SkScalarAbs(SkScalarAbs(shader.getDiffRadius()) - shader.getCenterX1()) < |
egdaniel
2014/09/22 13:59:35
can we do "SkScalarAbs(||centerEndTrans|| - (radiu
| |
789 kEdgeErrorTol * shader.getStartRadius()) { | |
789 return kEdge_ConicalType; | 790 return kEdge_ConicalType; |
790 } | 791 } |
791 | 792 |
792 SkScalar C = 1.f / A; | 793 SkScalar C = 1.f / A; |
793 SkScalar B = (radiusEnd - 1.f) * C; | 794 SkScalar B = (radiusEnd - 1.f) * C; |
794 | 795 |
795 matrix.postScale(C, C); | 796 matrix.postScale(C, C); |
796 | 797 |
797 invLMatrix->postConcat(matrix); | 798 invLMatrix->postConcat(matrix); |
798 | 799 |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1317 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); | 1318 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf o); |
1318 } else if (type == kEdge_ConicalType) { | 1319 } else if (type == kEdge_ConicalType) { |
1319 set_matrix_edge_conical(shader, &matrix); | 1320 set_matrix_edge_conical(shader, &matrix); |
1320 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); | 1321 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); |
1321 } else { | 1322 } else { |
1322 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); | 1323 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in fo); |
1323 } | 1324 } |
1324 } | 1325 } |
1325 | 1326 |
1326 #endif | 1327 #endif |
OLD | NEW |