blob: e26e36bc3d70b98a3ce000275025da8059b1abf2 [file] [log] [blame]
rileya@google.com589708b2012-07-26 20:04:23 +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
8#include "SkTwoPointConicalGradient.h"
9
commit-bot@chromium.orgaa64fbf2014-04-03 14:59:19 +000010#include "SkTwoPointConicalGradient_gpu.h"
11
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000012struct TwoPtRadialContext {
13 const TwoPtRadial& fRec;
14 float fRelX, fRelY;
15 const float fIncX, fIncY;
16 float fB;
17 const float fDB;
18
19 TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkScalar fy,
20 SkScalar dfx, SkScalar dfy);
21 SkFixed nextT();
22};
23
rileya@google.com589708b2012-07-26 20:04:23 +000024static int valid_divide(float numer, float denom, float* ratio) {
25 SkASSERT(ratio);
26 if (0 == denom) {
27 return 0;
28 }
29 *ratio = numer / denom;
30 return 1;
31}
32
33// Return the number of distinct real roots, and write them into roots[] in
34// ascending order
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +000035static int find_quad_roots(float A, float B, float C, float roots[2], bool descendingOrder = false) {
rileya@google.com589708b2012-07-26 20:04:23 +000036 SkASSERT(roots);
rmistry@google.comfbfcd562012-08-23 18:09:54 +000037
rileya@google.com589708b2012-07-26 20:04:23 +000038 if (A == 0) {
39 return valid_divide(-C, B, roots);
40 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +000041
rileya@google.com589708b2012-07-26 20:04:23 +000042 float R = B*B - 4*A*C;
43 if (R < 0) {
44 return 0;
45 }
46 R = sk_float_sqrt(R);
47
48#if 1
49 float Q = B;
50 if (Q < 0) {
51 Q -= R;
52 } else {
53 Q += R;
54 }
55#else
56 // on 10.6 this was much slower than the above branch :(
57 float Q = B + copysignf(R, B);
58#endif
59 Q *= -0.5f;
60 if (0 == Q) {
61 roots[0] = 0;
62 return 1;
63 }
64
65 float r0 = Q / A;
66 float r1 = C / Q;
67 roots[0] = r0 < r1 ? r0 : r1;
68 roots[1] = r0 > r1 ? r0 : r1;
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +000069 if (descendingOrder) {
70 SkTSwap(roots[0], roots[1]);
71 }
rileya@google.com589708b2012-07-26 20:04:23 +000072 return 2;
73}
74
75static float lerp(float x, float dx, float t) {
76 return x + t * dx;
77}
78
79static float sqr(float x) { return x * x; }
80
81void TwoPtRadial::init(const SkPoint& center0, SkScalar rad0,
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +000082 const SkPoint& center1, SkScalar rad1,
83 bool flipped) {
rileya@google.com589708b2012-07-26 20:04:23 +000084 fCenterX = SkScalarToFloat(center0.fX);
85 fCenterY = SkScalarToFloat(center0.fY);
86 fDCenterX = SkScalarToFloat(center1.fX) - fCenterX;
87 fDCenterY = SkScalarToFloat(center1.fY) - fCenterY;
88 fRadius = SkScalarToFloat(rad0);
89 fDRadius = SkScalarToFloat(rad1) - fRadius;
90
91 fA = sqr(fDCenterX) + sqr(fDCenterY) - sqr(fDRadius);
92 fRadius2 = sqr(fRadius);
93 fRDR = fRadius * fDRadius;
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +000094
95 fFlipped = flipped;
rileya@google.com589708b2012-07-26 20:04:23 +000096}
97
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000098TwoPtRadialContext::TwoPtRadialContext(const TwoPtRadial& rec, SkScalar fx, SkScalar fy,
99 SkScalar dfx, SkScalar dfy)
100 : fRec(rec)
101 , fRelX(SkScalarToFloat(fx) - rec.fCenterX)
102 , fRelY(SkScalarToFloat(fy) - rec.fCenterY)
103 , fIncX(SkScalarToFloat(dfx))
104 , fIncY(SkScalarToFloat(dfy))
105 , fB(-2 * (rec.fDCenterX * fRelX + rec.fDCenterY * fRelY + rec.fRDR))
106 , fDB(-2 * (rec.fDCenterX * fIncX + rec.fDCenterY * fIncY)) {}
rileya@google.com589708b2012-07-26 20:04:23 +0000107
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000108SkFixed TwoPtRadialContext::nextT() {
rileya@google.com589708b2012-07-26 20:04:23 +0000109 float roots[2];
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000110
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000111 float C = sqr(fRelX) + sqr(fRelY) - fRec.fRadius2;
112 int countRoots = find_quad_roots(fRec.fA, fB, C, roots, fRec.fFlipped);
rileya@google.com589708b2012-07-26 20:04:23 +0000113
114 fRelX += fIncX;
115 fRelY += fIncY;
116 fB += fDB;
117
118 if (0 == countRoots) {
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000119 return TwoPtRadial::kDontDrawT;
rileya@google.com589708b2012-07-26 20:04:23 +0000120 }
121
122 // Prefer the bigger t value if both give a radius(t) > 0
123 // find_quad_roots returns the values sorted, so we start with the last
124 float t = roots[countRoots - 1];
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000125 float r = lerp(fRec.fRadius, fRec.fDRadius, t);
rileya@google.com589708b2012-07-26 20:04:23 +0000126 if (r <= 0) {
127 t = roots[0]; // might be the same as roots[countRoots-1]
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000128 r = lerp(fRec.fRadius, fRec.fDRadius, t);
rileya@google.com589708b2012-07-26 20:04:23 +0000129 if (r <= 0) {
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000130 return TwoPtRadial::kDontDrawT;
rileya@google.com589708b2012-07-26 20:04:23 +0000131 }
132 }
133 return SkFloatToFixed(t);
134}
135
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000136typedef void (*TwoPointConicalProc)(TwoPtRadialContext* rec, SkPMColor* dstC,
reed@google.com60040292013-02-04 18:21:23 +0000137 const SkPMColor* cache, int toggle, int count);
rileya@google.com589708b2012-07-26 20:04:23 +0000138
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000139static void twopoint_clamp(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC,
reed@google.com60040292013-02-04 18:21:23 +0000140 const SkPMColor* SK_RESTRICT cache, int toggle,
141 int count) {
rileya@google.com589708b2012-07-26 20:04:23 +0000142 for (; count > 0; --count) {
143 SkFixed t = rec->nextT();
144 if (TwoPtRadial::DontDrawT(t)) {
145 *dstC++ = 0;
146 } else {
147 SkFixed index = SkClampMax(t, 0xFFFF);
148 SkASSERT(index <= 0xFFFF);
reed@google.com60040292013-02-04 18:21:23 +0000149 *dstC++ = cache[toggle +
150 (index >> SkGradientShaderBase::kCache32Shift)];
rileya@google.com589708b2012-07-26 20:04:23 +0000151 }
reed@google.com60040292013-02-04 18:21:23 +0000152 toggle = next_dither_toggle(toggle);
rileya@google.com589708b2012-07-26 20:04:23 +0000153 }
154}
155
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000156static void twopoint_repeat(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC,
reed@google.com60040292013-02-04 18:21:23 +0000157 const SkPMColor* SK_RESTRICT cache, int toggle,
158 int count) {
rileya@google.com589708b2012-07-26 20:04:23 +0000159 for (; count > 0; --count) {
160 SkFixed t = rec->nextT();
161 if (TwoPtRadial::DontDrawT(t)) {
162 *dstC++ = 0;
163 } else {
164 SkFixed index = repeat_tileproc(t);
165 SkASSERT(index <= 0xFFFF);
reed@google.com60040292013-02-04 18:21:23 +0000166 *dstC++ = cache[toggle +
167 (index >> SkGradientShaderBase::kCache32Shift)];
rileya@google.com589708b2012-07-26 20:04:23 +0000168 }
reed@google.com60040292013-02-04 18:21:23 +0000169 toggle = next_dither_toggle(toggle);
rileya@google.com589708b2012-07-26 20:04:23 +0000170 }
171}
172
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000173static void twopoint_mirror(TwoPtRadialContext* rec, SkPMColor* SK_RESTRICT dstC,
reed@google.com60040292013-02-04 18:21:23 +0000174 const SkPMColor* SK_RESTRICT cache, int toggle,
175 int count) {
rileya@google.com589708b2012-07-26 20:04:23 +0000176 for (; count > 0; --count) {
177 SkFixed t = rec->nextT();
178 if (TwoPtRadial::DontDrawT(t)) {
179 *dstC++ = 0;
180 } else {
181 SkFixed index = mirror_tileproc(t);
182 SkASSERT(index <= 0xFFFF);
reed@google.com60040292013-02-04 18:21:23 +0000183 *dstC++ = cache[toggle +
184 (index >> SkGradientShaderBase::kCache32Shift)];
rileya@google.com589708b2012-07-26 20:04:23 +0000185 }
reed@google.com60040292013-02-04 18:21:23 +0000186 toggle = next_dither_toggle(toggle);
rileya@google.com589708b2012-07-26 20:04:23 +0000187 }
188}
189
190void SkTwoPointConicalGradient::init() {
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000191 fRec.init(fCenter1, fRadius1, fCenter2, fRadius2, fFlippedGrad);
rileya@google.com589708b2012-07-26 20:04:23 +0000192 fPtsToUnit.reset();
193}
194
rileya@google.com98e8b6d2012-07-31 20:38:06 +0000195/////////////////////////////////////////////////////////////////////
196
rileya@google.com589708b2012-07-26 20:04:23 +0000197SkTwoPointConicalGradient::SkTwoPointConicalGradient(
reed@google.com3d3a8602013-05-24 14:58:44 +0000198 const SkPoint& start, SkScalar startRadius,
199 const SkPoint& end, SkScalar endRadius,
commit-bot@chromium.org9c9005a2014-04-28 14:55:39 +0000200 bool flippedGrad, const Descriptor& desc,
201 const SkMatrix* localMatrix)
202 : SkGradientShaderBase(desc, localMatrix),
rileya@google.com589708b2012-07-26 20:04:23 +0000203 fCenter1(start),
204 fCenter2(end),
205 fRadius1(startRadius),
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000206 fRadius2(endRadius),
207 fFlippedGrad(flippedGrad) {
rileya@google.com589708b2012-07-26 20:04:23 +0000208 // this is degenerate, and should be caught by our caller
209 SkASSERT(fCenter1 != fCenter2 || fRadius1 != fRadius2);
210 this->init();
211}
212
commit-bot@chromium.org3fbab822013-03-20 00:49:57 +0000213bool SkTwoPointConicalGradient::isOpaque() const {
robertphillips@google.comcb6d97c2013-07-09 13:50:09 +0000214 // Because areas outside the cone are left untouched, we cannot treat the
215 // shader as opaque even if the gradient itself is opaque.
216 // TODO(junov): Compute whether the cone fills the plane crbug.com/222380
217 return false;
commit-bot@chromium.org3fbab822013-03-20 00:49:57 +0000218}
219
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000220size_t SkTwoPointConicalGradient::contextSize() const {
221 return sizeof(TwoPointConicalGradientContext);
222}
223
commit-bot@chromium.orgce56d962014-05-05 18:39:18 +0000224SkShader::Context* SkTwoPointConicalGradient::onCreateContext(const ContextRec& rec,
225 void* storage) const {
commit-bot@chromium.orge901b6d2014-05-01 19:31:31 +0000226 return SkNEW_PLACEMENT_ARGS(storage, TwoPointConicalGradientContext, (*this, rec));
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000227}
228
229SkTwoPointConicalGradient::TwoPointConicalGradientContext::TwoPointConicalGradientContext(
commit-bot@chromium.orge901b6d2014-05-01 19:31:31 +0000230 const SkTwoPointConicalGradient& shader, const ContextRec& rec)
231 : INHERITED(shader, rec)
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000232{
233 // we don't have a span16 proc
234 fFlags &= ~kHasSpan16_Flag;
235
236 // in general, we might discard based on computed-radius, so clear
237 // this flag (todo: sometimes we can detect that we never discard...)
238 fFlags &= ~kOpaqueAlpha_Flag;
239}
240
241void SkTwoPointConicalGradient::TwoPointConicalGradientContext::shadeSpan(
242 int x, int y, SkPMColor* dstCParam, int count) {
243 const SkTwoPointConicalGradient& twoPointConicalGradient =
244 static_cast<const SkTwoPointConicalGradient&>(fShader);
245
reed@google.com60040292013-02-04 18:21:23 +0000246 int toggle = init_dither_toggle(x, y);
reed@google.com60040292013-02-04 18:21:23 +0000247
rileya@google.com589708b2012-07-26 20:04:23 +0000248 SkASSERT(count > 0);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000249
rileya@google.com589708b2012-07-26 20:04:23 +0000250 SkPMColor* SK_RESTRICT dstC = dstCParam;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000251
rileya@google.com589708b2012-07-26 20:04:23 +0000252 SkMatrix::MapXYProc dstProc = fDstToIndexProc;
bsalomon@google.com100abf42012-09-05 17:40:04 +0000253
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000254 const SkPMColor* SK_RESTRICT cache = fCache->getCache32();
rileya@google.com589708b2012-07-26 20:04:23 +0000255
reed@google.com60040292013-02-04 18:21:23 +0000256 TwoPointConicalProc shadeProc = twopoint_repeat;
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000257 if (SkShader::kClamp_TileMode == twoPointConicalGradient.fTileMode) {
rileya@google.com589708b2012-07-26 20:04:23 +0000258 shadeProc = twopoint_clamp;
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000259 } else if (SkShader::kMirror_TileMode == twoPointConicalGradient.fTileMode) {
rileya@google.com589708b2012-07-26 20:04:23 +0000260 shadeProc = twopoint_mirror;
261 } else {
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000262 SkASSERT(SkShader::kRepeat_TileMode == twoPointConicalGradient.fTileMode);
rileya@google.com589708b2012-07-26 20:04:23 +0000263 }
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000264
rileya@google.com589708b2012-07-26 20:04:23 +0000265 if (fDstToIndexClass != kPerspective_MatrixClass) {
266 SkPoint srcPt;
267 dstProc(fDstToIndex, SkIntToScalar(x) + SK_ScalarHalf,
268 SkIntToScalar(y) + SK_ScalarHalf, &srcPt);
269 SkScalar dx, fx = srcPt.fX;
270 SkScalar dy, fy = srcPt.fY;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000271
rileya@google.com589708b2012-07-26 20:04:23 +0000272 if (fDstToIndexClass == kFixedStepInX_MatrixClass) {
273 SkFixed fixedX, fixedY;
274 (void)fDstToIndex.fixedStepInX(SkIntToScalar(y), &fixedX, &fixedY);
275 dx = SkFixedToScalar(fixedX);
276 dy = SkFixedToScalar(fixedY);
277 } else {
278 SkASSERT(fDstToIndexClass == kLinear_MatrixClass);
279 dx = fDstToIndex.getScaleX();
280 dy = fDstToIndex.getSkewY();
281 }
282
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000283 TwoPtRadialContext rec(twoPointConicalGradient.fRec, fx, fy, dx, dy);
284 (*shadeProc)(&rec, dstC, cache, toggle, count);
rileya@google.com589708b2012-07-26 20:04:23 +0000285 } else { // perspective case
mike@reedtribe.org139a2352013-11-14 20:15:51 +0000286 SkScalar dstX = SkIntToScalar(x) + SK_ScalarHalf;
287 SkScalar dstY = SkIntToScalar(y) + SK_ScalarHalf;
rileya@google.com589708b2012-07-26 20:04:23 +0000288 for (; count > 0; --count) {
289 SkPoint srcPt;
290 dstProc(fDstToIndex, dstX, dstY, &srcPt);
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +0000291 TwoPtRadialContext rec(twoPointConicalGradient.fRec, srcPt.fX, srcPt.fY, 0, 0);
292 (*shadeProc)(&rec, dstC, cache, toggle, 1);
mike@reedtribe.org139a2352013-11-14 20:15:51 +0000293
294 dstX += SK_Scalar1;
reed@google.com60040292013-02-04 18:21:23 +0000295 toggle = next_dither_toggle(toggle);
mike@reedtribe.org139a2352013-11-14 20:15:51 +0000296 dstC += 1;
rileya@google.com589708b2012-07-26 20:04:23 +0000297 }
298 }
299}
300
rileya@google.com589708b2012-07-26 20:04:23 +0000301SkShader::BitmapType SkTwoPointConicalGradient::asABitmap(
302 SkBitmap* bitmap, SkMatrix* matrix, SkShader::TileMode* xy) const {
303 SkPoint diff = fCenter2 - fCenter1;
rileya@google.com589708b2012-07-26 20:04:23 +0000304 SkScalar diffLen = 0;
305
306 if (bitmap) {
rileya@google.com1c6d64b2012-07-27 15:49:05 +0000307 this->getGradientTableBitmap(bitmap);
rileya@google.com589708b2012-07-26 20:04:23 +0000308 }
309 if (matrix) {
310 diffLen = diff.length();
311 }
312 if (matrix) {
313 if (diffLen) {
314 SkScalar invDiffLen = SkScalarInvert(diffLen);
315 // rotate to align circle centers with the x-axis
316 matrix->setSinCos(-SkScalarMul(invDiffLen, diff.fY),
317 SkScalarMul(invDiffLen, diff.fX));
318 } else {
319 matrix->reset();
320 }
321 matrix->preTranslate(-fCenter1.fX, -fCenter1.fY);
322 }
323 if (xy) {
324 xy[0] = fTileMode;
325 xy[1] = kClamp_TileMode;
326 }
327 return kTwoPointConical_BitmapType;
328}
329
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000330// Returns the original non-sorted version of the gradient
rileya@google.com589708b2012-07-26 20:04:23 +0000331SkShader::GradientType SkTwoPointConicalGradient::asAGradient(
332 GradientInfo* info) const {
333 if (info) {
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000334 commonAsAGradient(info, fFlippedGrad);
rileya@google.com589708b2012-07-26 20:04:23 +0000335 info->fPoint[0] = fCenter1;
336 info->fPoint[1] = fCenter2;
337 info->fRadius[0] = fRadius1;
338 info->fRadius[1] = fRadius2;
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000339 if (fFlippedGrad) {
340 SkTSwap(info->fPoint[0], info->fPoint[1]);
341 SkTSwap(info->fRadius[0], info->fRadius[1]);
342 }
rileya@google.com589708b2012-07-26 20:04:23 +0000343 }
344 return kConical_GradientType;
345}
346
rileya@google.com589708b2012-07-26 20:04:23 +0000347SkTwoPointConicalGradient::SkTwoPointConicalGradient(
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +0000348 SkReadBuffer& buffer)
rileya@google.com589708b2012-07-26 20:04:23 +0000349 : INHERITED(buffer),
350 fCenter1(buffer.readPoint()),
351 fCenter2(buffer.readPoint()),
352 fRadius1(buffer.readScalar()),
353 fRadius2(buffer.readScalar()) {
commit-bot@chromium.org7ed173b2014-05-20 17:31:08 +0000354 if (buffer.isVersionLT(SkReadBuffer::kGradientFlippedFlag_Version)) {
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000355 // V23_COMPATIBILITY_CODE
356 // Sort gradient by radius size for old pictures
357 if (fRadius2 < fRadius1) {
358 SkTSwap(fCenter1, fCenter2);
359 SkTSwap(fRadius1, fRadius2);
360 this->flipGradientColors();
361 fFlippedGrad = true;
362 } else {
363 fFlippedGrad = false;
364 }
commit-bot@chromium.org7ed173b2014-05-20 17:31:08 +0000365 } else {
366 fFlippedGrad = buffer.readBool();
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000367 }
rileya@google.com589708b2012-07-26 20:04:23 +0000368 this->init();
369};
370
371void SkTwoPointConicalGradient::flatten(
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +0000372 SkWriteBuffer& buffer) const {
rileya@google.com589708b2012-07-26 20:04:23 +0000373 this->INHERITED::flatten(buffer);
374 buffer.writePoint(fCenter1);
375 buffer.writePoint(fCenter2);
376 buffer.writeScalar(fRadius1);
377 buffer.writeScalar(fRadius2);
commit-bot@chromium.org44d83c12014-04-21 13:10:25 +0000378 buffer.writeBool(fFlippedGrad);
rileya@google.com589708b2012-07-26 20:04:23 +0000379}
380
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000381#if SK_SUPPORT_GPU
382
commit-bot@chromium.org96fb7482014-05-09 20:28:11 +0000383GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext* context, const SkPaint&,
384 const SkMatrix* localMatrix) const {
bsalomon@google.com00835cc2013-01-14 17:07:22 +0000385 SkASSERT(NULL != context);
bsalomon@google.comf94b3a42012-10-31 18:09:01 +0000386 SkASSERT(fPtsToUnit.isIdentity());
bsalomon@google.comf94b3a42012-10-31 18:09:01 +0000387
commit-bot@chromium.org96fb7482014-05-09 20:28:11 +0000388 return Gr2PtConicalGradientEffect::Create(context, *this, fTileMode, localMatrix);
rileya@google.comd7cc6512012-07-27 14:00:39 +0000389}
390
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000391#else
392
reed@google.comeaa67492014-05-09 20:52:23 +0000393GrEffectRef* SkTwoPointConicalGradient::asNewEffect(GrContext*, const SkPaint&,
394 const SkMatrix*) const {
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000395 SkDEBUGFAIL("Should not call in GPU-less build");
bsalomon@google.come197cbf2013-01-14 16:46:26 +0000396 return NULL;
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +0000397}
398
twiz@google.coma5e65ec2012-08-02 15:15:16 +0000399#endif
robertphillips@google.com76f9e932013-01-15 20:17:47 +0000400
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +0000401#ifndef SK_IGNORE_TO_STRING
robertphillips@google.com76f9e932013-01-15 20:17:47 +0000402void SkTwoPointConicalGradient::toString(SkString* str) const {
403 str->append("SkTwoPointConicalGradient: (");
404
405 str->append("center1: (");
406 str->appendScalar(fCenter1.fX);
407 str->append(", ");
408 str->appendScalar(fCenter1.fY);
409 str->append(") radius1: ");
410 str->appendScalar(fRadius1);
411 str->append(" ");
412
413 str->append("center2: (");
414 str->appendScalar(fCenter2.fX);
415 str->append(", ");
416 str->appendScalar(fCenter2.fY);
417 str->append(") radius2: ");
418 str->appendScalar(fRadius2);
419 str->append(" ");
420
421 this->INHERITED::toString(str);
422
423 str->append(")");
424}
425#endif