blob: 14d7d9cea0482e9a3edcdb6e86bcc8780752c169 [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "SkIntersections.h"
8#include "SkPathOpsLine.h"
9#include "SkPathOpsQuad.h"
10
11/*
12Find the interection of a line and quadratic by solving for valid t values.
13
14From http://stackoverflow.com/questions/1853637/how-to-find-the-mathematical-function-defining-a-bezier-curve
15
16"A Bezier curve is a parametric function. A quadratic Bezier curve (i.e. three
17control points) can be expressed as: F(t) = A(1 - t)^2 + B(1 - t)t + Ct^2 where
18A, B and C are points and t goes from zero to one.
19
20This will give you two equations:
21
22 x = a(1 - t)^2 + b(1 - t)t + ct^2
23 y = d(1 - t)^2 + e(1 - t)t + ft^2
24
25If you add for instance the line equation (y = kx + m) to that, you'll end up
26with three equations and three unknowns (x, y and t)."
27
28Similar to above, the quadratic is represented as
29 x = a(1-t)^2 + 2b(1-t)t + ct^2
30 y = d(1-t)^2 + 2e(1-t)t + ft^2
31and the line as
32 y = g*x + h
33
34Using Mathematica, solve for the values of t where the quadratic intersects the
35line:
36
37 (in) t1 = Resultant[a*(1 - t)^2 + 2*b*(1 - t)*t + c*t^2 - x,
38 d*(1 - t)^2 + 2*e*(1 - t)*t + f*t^2 - g*x - h, x]
39 (out) -d + h + 2 d t - 2 e t - d t^2 + 2 e t^2 - f t^2 +
40 g (a - 2 a t + 2 b t + a t^2 - 2 b t^2 + c t^2)
41 (in) Solve[t1 == 0, t]
42 (out) {
43 {t -> (-2 d + 2 e + 2 a g - 2 b g -
44 Sqrt[(2 d - 2 e - 2 a g + 2 b g)^2 -
45 4 (-d + 2 e - f + a g - 2 b g + c g) (-d + a g + h)]) /
46 (2 (-d + 2 e - f + a g - 2 b g + c g))
47 },
48 {t -> (-2 d + 2 e + 2 a g - 2 b g +
49 Sqrt[(2 d - 2 e - 2 a g + 2 b g)^2 -
50 4 (-d + 2 e - f + a g - 2 b g + c g) (-d + a g + h)]) /
51 (2 (-d + 2 e - f + a g - 2 b g + c g))
52 }
53 }
54
55Using the results above (when the line tends towards horizontal)
56 A = (-(d - 2*e + f) + g*(a - 2*b + c) )
57 B = 2*( (d - e ) - g*(a - b ) )
58 C = (-(d ) + g*(a ) + h )
59
60If g goes to infinity, we can rewrite the line in terms of x.
61 x = g'*y + h'
62
63And solve accordingly in Mathematica:
64
65 (in) t2 = Resultant[a*(1 - t)^2 + 2*b*(1 - t)*t + c*t^2 - g'*y - h',
66 d*(1 - t)^2 + 2*e*(1 - t)*t + f*t^2 - y, y]
67 (out) a - h' - 2 a t + 2 b t + a t^2 - 2 b t^2 + c t^2 -
68 g' (d - 2 d t + 2 e t + d t^2 - 2 e t^2 + f t^2)
69 (in) Solve[t2 == 0, t]
70 (out) {
71 {t -> (2 a - 2 b - 2 d g' + 2 e g' -
72 Sqrt[(-2 a + 2 b + 2 d g' - 2 e g')^2 -
73 4 (a - 2 b + c - d g' + 2 e g' - f g') (a - d g' - h')]) /
74 (2 (a - 2 b + c - d g' + 2 e g' - f g'))
75 },
76 {t -> (2 a - 2 b - 2 d g' + 2 e g' +
77 Sqrt[(-2 a + 2 b + 2 d g' - 2 e g')^2 -
78 4 (a - 2 b + c - d g' + 2 e g' - f g') (a - d g' - h')])/
79 (2 (a - 2 b + c - d g' + 2 e g' - f g'))
80 }
81 }
82
83Thus, if the slope of the line tends towards vertical, we use:
84 A = ( (a - 2*b + c) - g'*(d - 2*e + f) )
85 B = 2*(-(a - b ) + g'*(d - e ) )
86 C = ( (a ) - g'*(d ) - h' )
87 */
88
89
90class LineQuadraticIntersections {
91public:
caryclark@google.com4fdbb222013-07-23 15:27:41 +000092 enum PinTPoint {
93 kPointUninitialized,
94 kPointInitialized
95 };
96
caryclark@google.com07393ca2013-04-08 11:47:37 +000097 LineQuadraticIntersections(const SkDQuad& q, const SkDLine& l, SkIntersections* i)
caryclark@google.com4fdbb222013-07-23 15:27:41 +000098 : fQuad(q)
99 , fLine(l)
100 , fIntersections(i)
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000101 , fAllowNear(true) {
caryclark@google.com7eaa53d2013-10-02 14:49:34 +0000102 i->setMax(2);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000103 }
104
105 void allowNear(bool allow) {
106 fAllowNear = allow;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000107 }
108
109 int intersectRay(double roots[2]) {
110 /*
111 solve by rotating line+quad so line is horizontal, then finding the roots
112 set up matrix to rotate quad to x-axis
113 |cos(a) -sin(a)|
114 |sin(a) cos(a)|
115 note that cos(a) = A(djacent) / Hypoteneuse
116 sin(a) = O(pposite) / Hypoteneuse
117 since we are computing Ts, we can ignore hypoteneuse, the scale factor:
118 | A -O |
119 | O A |
120 A = line[1].fX - line[0].fX (adjacent side of the right triangle)
121 O = line[1].fY - line[0].fY (opposite side of the right triangle)
122 for each of the three points (e.g. n = 0 to 2)
123 quad[n].fY' = (quad[n].fY - line[0].fY) * A - (quad[n].fX - line[0].fX) * O
124 */
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000125 double adj = fLine[1].fX - fLine[0].fX;
126 double opp = fLine[1].fY - fLine[0].fY;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000127 double r[3];
128 for (int n = 0; n < 3; ++n) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000129 r[n] = (fQuad[n].fY - fLine[0].fY) * adj - (fQuad[n].fX - fLine[0].fX) * opp;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000130 }
131 double A = r[2];
132 double B = r[1];
133 double C = r[0];
134 A += C - 2 * B; // A = a - 2*b + c
135 B -= C; // B = -(b - c)
136 return SkDQuad::RootsValidT(A, 2 * B, C, roots);
137 }
138
139 int intersect() {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000140 addExactEndPoints();
caryclark@google.com570863f2013-09-16 15:55:01 +0000141 if (fAllowNear) {
142 addNearEndPoints();
143 }
caryclark@google.com07393ca2013-04-08 11:47:37 +0000144 double rootVals[2];
145 int roots = intersectRay(rootVals);
146 for (int index = 0; index < roots; ++index) {
147 double quadT = rootVals[index];
148 double lineT = findLineT(quadT);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000149 SkDPoint pt;
150 if (pinTs(&quadT, &lineT, &pt, kPointUninitialized)) {
151 fIntersections->insert(quadT, lineT, pt);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000152 }
153 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000154 return fIntersections->used();
caryclark@google.com07393ca2013-04-08 11:47:37 +0000155 }
156
157 int horizontalIntersect(double axisIntercept, double roots[2]) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000158 double D = fQuad[2].fY; // f
159 double E = fQuad[1].fY; // e
160 double F = fQuad[0].fY; // d
caryclark@google.com07393ca2013-04-08 11:47:37 +0000161 D += F - 2 * E; // D = d - 2*e + f
162 E -= F; // E = -(d - e)
163 F -= axisIntercept;
164 return SkDQuad::RootsValidT(D, 2 * E, F, roots);
165 }
166
167 int horizontalIntersect(double axisIntercept, double left, double right, bool flipped) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000168 addExactHorizontalEndPoints(left, right, axisIntercept);
caryclark@google.com570863f2013-09-16 15:55:01 +0000169 if (fAllowNear) {
170 addNearHorizontalEndPoints(left, right, axisIntercept);
171 }
caryclark@google.com07393ca2013-04-08 11:47:37 +0000172 double rootVals[2];
173 int roots = horizontalIntersect(axisIntercept, rootVals);
174 for (int index = 0; index < roots; ++index) {
175 double quadT = rootVals[index];
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000176 SkDPoint pt = fQuad.ptAtT(quadT);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000177 double lineT = (pt.fX - left) / (right - left);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000178 if (pinTs(&quadT, &lineT, &pt, kPointInitialized)) {
179 fIntersections->insert(quadT, lineT, pt);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000180 }
181 }
182 if (flipped) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000183 fIntersections->flip();
caryclark@google.com07393ca2013-04-08 11:47:37 +0000184 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000185 return fIntersections->used();
caryclark@google.com07393ca2013-04-08 11:47:37 +0000186 }
187
188 int verticalIntersect(double axisIntercept, double roots[2]) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000189 double D = fQuad[2].fX; // f
190 double E = fQuad[1].fX; // e
191 double F = fQuad[0].fX; // d
caryclark@google.com07393ca2013-04-08 11:47:37 +0000192 D += F - 2 * E; // D = d - 2*e + f
193 E -= F; // E = -(d - e)
194 F -= axisIntercept;
195 return SkDQuad::RootsValidT(D, 2 * E, F, roots);
196 }
197
198 int verticalIntersect(double axisIntercept, double top, double bottom, bool flipped) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000199 addExactVerticalEndPoints(top, bottom, axisIntercept);
caryclark@google.com570863f2013-09-16 15:55:01 +0000200 if (fAllowNear) {
201 addNearVerticalEndPoints(top, bottom, axisIntercept);
202 }
caryclark@google.com07393ca2013-04-08 11:47:37 +0000203 double rootVals[2];
204 int roots = verticalIntersect(axisIntercept, rootVals);
205 for (int index = 0; index < roots; ++index) {
206 double quadT = rootVals[index];
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000207 SkDPoint pt = fQuad.ptAtT(quadT);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000208 double lineT = (pt.fY - top) / (bottom - top);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000209 if (pinTs(&quadT, &lineT, &pt, kPointInitialized)) {
210 fIntersections->insert(quadT, lineT, pt);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000211 }
212 }
213 if (flipped) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000214 fIntersections->flip();
caryclark@google.com07393ca2013-04-08 11:47:37 +0000215 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000216 return fIntersections->used();
caryclark@google.com07393ca2013-04-08 11:47:37 +0000217 }
218
219protected:
220 // add endpoints first to get zero and one t values exactly
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000221 void addExactEndPoints() {
caryclark@google.com07393ca2013-04-08 11:47:37 +0000222 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000223 double lineT = fLine.exactPoint(fQuad[qIndex]);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000224 if (lineT < 0) {
caryclark@google.com07e97fc2013-07-08 17:17:02 +0000225 continue;
226 }
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000227 double quadT = (double) (qIndex >> 1);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000228 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000229 }
230 }
231
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000232 void addNearEndPoints() {
caryclark@google.com07393ca2013-04-08 11:47:37 +0000233 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000234 double quadT = (double) (qIndex >> 1);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000235 if (fIntersections->hasT(quadT)) {
caryclark@google.com07393ca2013-04-08 11:47:37 +0000236 continue;
237 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000238 double lineT = fLine.nearPoint(fQuad[qIndex]);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000239 if (lineT < 0) {
240 continue;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000241 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000242 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000243 }
244 // FIXME: see if line end is nearly on quad
245 }
246
247 void addExactHorizontalEndPoints(double left, double right, double y) {
248 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000249 double lineT = SkDLine::ExactPointH(fQuad[qIndex], left, right, y);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000250 if (lineT < 0) {
251 continue;
252 }
253 double quadT = (double) (qIndex >> 1);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000254 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000255 }
256 }
257
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000258 void addNearHorizontalEndPoints(double left, double right, double y) {
caryclark@google.com07393ca2013-04-08 11:47:37 +0000259 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000260 double quadT = (double) (qIndex >> 1);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000261 if (fIntersections->hasT(quadT)) {
caryclark@google.com07393ca2013-04-08 11:47:37 +0000262 continue;
263 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000264 double lineT = SkDLine::NearPointH(fQuad[qIndex], left, right, y);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000265 if (lineT < 0) {
266 continue;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000267 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000268 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000269 }
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000270 // FIXME: see if line end is nearly on quad
271 }
272
273 void addExactVerticalEndPoints(double top, double bottom, double x) {
274 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000275 double lineT = SkDLine::ExactPointV(fQuad[qIndex], top, bottom, x);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000276 if (lineT < 0) {
277 continue;
278 }
279 double quadT = (double) (qIndex >> 1);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000280 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000281 }
282 }
283
284 void addNearVerticalEndPoints(double top, double bottom, double x) {
285 for (int qIndex = 0; qIndex < 3; qIndex += 2) {
286 double quadT = (double) (qIndex >> 1);
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000287 if (fIntersections->hasT(quadT)) {
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000288 continue;
289 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000290 double lineT = SkDLine::NearPointV(fQuad[qIndex], top, bottom, x);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000291 if (lineT < 0) {
292 continue;
293 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000294 fIntersections->insert(quadT, lineT, fQuad[qIndex]);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000295 }
296 // FIXME: see if line end is nearly on quad
caryclark@google.com07393ca2013-04-08 11:47:37 +0000297 }
298
299 double findLineT(double t) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000300 SkDPoint xy = fQuad.ptAtT(t);
301 double dx = fLine[1].fX - fLine[0].fX;
302 double dy = fLine[1].fY - fLine[0].fY;
303 double dxT = (xy.fX - fLine[0].fX) / dx;
304 double dyT = (xy.fY - fLine[0].fY) / dy;
caryclark@google.com07e97fc2013-07-08 17:17:02 +0000305 if (!between(FLT_EPSILON, dxT, 1 - FLT_EPSILON) && between(0, dyT, 1)) {
306 return dyT;
307 }
308 if (!between(FLT_EPSILON, dyT, 1 - FLT_EPSILON) && between(0, dxT, 1)) {
309 return dxT;
310 }
311 return fabs(dx) > fabs(dy) ? dxT : dyT;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000312 }
313
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000314 bool pinTs(double* quadT, double* lineT, SkDPoint* pt, PinTPoint ptSet) {
caryclark@google.com07393ca2013-04-08 11:47:37 +0000315 if (!approximately_one_or_less(*lineT)) {
316 return false;
317 }
318 if (!approximately_zero_or_more(*lineT)) {
319 return false;
320 }
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000321 double qT = *quadT = SkPinT(*quadT);
322 double lT = *lineT = SkPinT(*lineT);
323 if (lT == 0 || lT == 1 || (ptSet == kPointUninitialized && qT != 0 && qT != 1)) {
324 *pt = fLine.ptAtT(lT);
325 } else if (ptSet == kPointUninitialized) {
326 *pt = fQuad.ptAtT(qT);
327 }
caryclark@google.com570863f2013-09-16 15:55:01 +0000328 SkPoint gridPt = pt->asSkPoint();
329 if (gridPt == fLine[0].asSkPoint()) {
330 *lineT = 0;
331 } else if (gridPt == fLine[1].asSkPoint()) {
332 *lineT = 1;
333 }
334 if (gridPt == fQuad[0].asSkPoint()) {
335 *quadT = 0;
336 } else if (gridPt == fQuad[2].asSkPoint()) {
337 *quadT = 1;
338 }
caryclark@google.com07393ca2013-04-08 11:47:37 +0000339 return true;
340 }
341
342private:
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000343 const SkDQuad& fQuad;
344 const SkDLine& fLine;
345 SkIntersections* fIntersections;
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000346 bool fAllowNear;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000347};
348
349// utility for pairs of coincident quads
350static double horizontalIntersect(const SkDQuad& quad, const SkDPoint& pt) {
351 LineQuadraticIntersections q(quad, *(static_cast<SkDLine*>(0)),
352 static_cast<SkIntersections*>(0));
353 double rootVals[2];
354 int roots = q.horizontalIntersect(pt.fY, rootVals);
355 for (int index = 0; index < roots; ++index) {
356 double t = rootVals[index];
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000357 SkDPoint qPt = quad.ptAtT(t);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000358 if (AlmostEqualUlps(qPt.fX, pt.fX)) {
359 return t;
360 }
361 }
362 return -1;
363}
364
365static double verticalIntersect(const SkDQuad& quad, const SkDPoint& pt) {
366 LineQuadraticIntersections q(quad, *(static_cast<SkDLine*>(0)),
367 static_cast<SkIntersections*>(0));
368 double rootVals[2];
369 int roots = q.verticalIntersect(pt.fX, rootVals);
370 for (int index = 0; index < roots; ++index) {
371 double t = rootVals[index];
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000372 SkDPoint qPt = quad.ptAtT(t);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000373 if (AlmostEqualUlps(qPt.fY, pt.fY)) {
374 return t;
375 }
376 }
377 return -1;
378}
379
380double SkIntersections::Axial(const SkDQuad& q1, const SkDPoint& p, bool vertical) {
381 if (vertical) {
382 return verticalIntersect(q1, p);
383 }
384 return horizontalIntersect(q1, p);
385}
386
387int SkIntersections::horizontal(const SkDQuad& quad, double left, double right, double y,
388 bool flipped) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000389 SkDLine line = {{{ left, y }, { right, y }}};
390 LineQuadraticIntersections q(quad, line, this);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000391 return q.horizontalIntersect(y, left, right, flipped);
392}
393
394int SkIntersections::vertical(const SkDQuad& quad, double top, double bottom, double x,
395 bool flipped) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000396 SkDLine line = {{{ x, top }, { x, bottom }}};
397 LineQuadraticIntersections q(quad, line, this);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000398 return q.verticalIntersect(x, top, bottom, flipped);
399}
400
401int SkIntersections::intersect(const SkDQuad& quad, const SkDLine& line) {
402 LineQuadraticIntersections q(quad, line, this);
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000403 q.allowNear(fAllowNear);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000404 return q.intersect();
405}
406
407int SkIntersections::intersectRay(const SkDQuad& quad, const SkDLine& line) {
408 LineQuadraticIntersections q(quad, line, this);
caryclark@google.coma5e55922013-05-07 18:51:31 +0000409 fUsed = q.intersectRay(fT[0]);
410 for (int index = 0; index < fUsed; ++index) {
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000411 fPt[index] = quad.ptAtT(fT[0][index]);
caryclark@google.coma5e55922013-05-07 18:51:31 +0000412 }
413 return fUsed;
caryclark@google.com07393ca2013-04-08 11:47:37 +0000414}