OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 for (int i = 0; i < count; ++i) { | 97 for (int i = 0; i < count; ++i) { |
98 const SkPoint& pt = segments[i].endPt(); | 98 const SkPoint& pt = segments[i].endPt(); |
99 avg.fX += pt.fX; | 99 avg.fX += pt.fX; |
100 avg.fY += pt.fY; | 100 avg.fY += pt.fY; |
101 } | 101 } |
102 SkScalar denom = SK_Scalar1 / count; | 102 SkScalar denom = SK_Scalar1 / count; |
103 avg.scale(denom); | 103 avg.scale(denom); |
104 *c = avg; | 104 *c = avg; |
105 } else { | 105 } else { |
106 area *= 3; | 106 area *= 3; |
107 area = SkScalarDiv(SK_Scalar1, area); | 107 area = SkScalarInvert(area); |
108 center.fX = SkScalarMul(center.fX, area); | 108 center.fX = SkScalarMul(center.fX, area); |
109 center.fY = SkScalarMul(center.fY, area); | 109 center.fY = SkScalarMul(center.fY, area); |
110 // undo the translate of p0 to the origin. | 110 // undo the translate of p0 to the origin. |
111 *c = center + p0; | 111 *c = center + p0; |
112 } | 112 } |
113 SkASSERT(!SkScalarIsNaN(c->fX) && !SkScalarIsNaN(c->fY)); | 113 SkASSERT(!SkScalarIsNaN(c->fX) && !SkScalarIsNaN(c->fY)); |
114 } | 114 } |
115 | 115 |
116 static void compute_vectors(SegmentArray* segments, | 116 static void compute_vectors(SegmentArray* segments, |
117 SkPoint* fanPt, | 117 SkPoint* fanPt, |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 geometry.fColor = color; | 1029 geometry.fColor = color; |
1030 geometry.fViewMatrix = vm; | 1030 geometry.fViewMatrix = vm; |
1031 geometry.fPath = path; | 1031 geometry.fPath = path; |
1032 | 1032 |
1033 SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry)); | 1033 SkAutoTUnref<GrBatch> batch(AAConvexPathBatch::Create(geometry)); |
1034 target->drawBatch(pipelineBuilder, batch); | 1034 target->drawBatch(pipelineBuilder, batch); |
1035 | 1035 |
1036 return true; | 1036 return true; |
1037 | 1037 |
1038 } | 1038 } |
OLD | NEW |