Chromium Code Reviews| 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 "SkSweepGradient.h" | 9 #include "SkSweepGradient.h" |
| 10 | 10 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 SkPoint center = {random->nextUScalar1(), random->nextUScalar1()}; | 240 SkPoint center = {random->nextUScalar1(), random->nextUScalar1()}; |
| 241 | 241 |
| 242 SkColor colors[kMaxRandomGradientColors]; | 242 SkColor colors[kMaxRandomGradientColors]; |
| 243 SkScalar stopsArray[kMaxRandomGradientColors]; | 243 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 244 SkScalar* stops = stopsArray; | 244 SkScalar* stops = stopsArray; |
| 245 SkShader::TileMode tmIgnored; | 245 SkShader::TileMode tmIgnored; |
| 246 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); | 246 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); |
| 247 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY, | 247 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente r.fY, |
| 248 colors, stops, c olorCount)); | 248 colors, stops, c olorCount)); |
| 249 SkPaint paint; | 249 SkPaint paint; |
| 250 return shader->asNewEffect(context, paint, NULL); | 250 GrEffectRef* effect; |
| 251 GrColor grColor; | |
| 252 shader->asNewEffect(context, paint, &grColor, &effect, NULL); | |
| 253 return effect; | |
| 251 } | 254 } |
| 252 | 255 |
| 253 ///////////////////////////////////////////////////////////////////// | 256 ///////////////////////////////////////////////////////////////////// |
| 254 | 257 |
| 255 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, | 258 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, |
| 256 const GrDrawEffect&, | 259 const GrDrawEffect&, |
| 257 EffectKey key, | 260 EffectKey key, |
| 258 const char* outputColor, | 261 const char* outputColor, |
| 259 const char* inputColor, | 262 const char* inputColor, |
| 260 const TransformedCoordsArray& coords, | 263 const TransformedCoordsArray& coords, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 272 } else { | 275 } else { |
| 273 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", | 276 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", |
| 274 coords2D.c_str(), coords2D.c_str()); | 277 coords2D.c_str(), coords2D.c_str()); |
| 275 } | 278 } |
| 276 this->emitColor(builder, t.c_str(), key, | 279 this->emitColor(builder, t.c_str(), key, |
| 277 outputColor, inputColor, samplers); | 280 outputColor, inputColor, samplers); |
| 278 } | 281 } |
| 279 | 282 |
| 280 ///////////////////////////////////////////////////////////////////// | 283 ///////////////////////////////////////////////////////////////////// |
| 281 | 284 |
| 282 GrEffectRef* SkSweepGradient::asNewEffect(GrContext* context, const SkPaint&, | 285 bool SkSweepGradient::asNewEffect(GrContext* context, const SkPaint& paint, GrCo lor* grColor, |
| 283 const SkMatrix* localMatrix) const { | 286 GrEffectRef** grEffect, const SkMatrix* localM atrix) const { |
|
jvanverth1
2014/06/05 17:36:31
grColor never gets set by this method
dandov
2014/06/06 21:50:43
Done.
| |
| 284 SkMatrix matrix; | 287 SkMatrix matrix; |
| 285 if (!this->getLocalMatrix().invert(&matrix)) { | 288 if (!this->getLocalMatrix().invert(&matrix)) { |
| 286 return NULL; | 289 return false; |
| 287 } | 290 } |
| 288 if (localMatrix) { | 291 if (localMatrix) { |
| 289 SkMatrix inv; | 292 SkMatrix inv; |
| 290 if (!localMatrix->invert(&inv)) { | 293 if (!localMatrix->invert(&inv)) { |
| 291 return NULL; | 294 return false; |
| 292 } | 295 } |
| 293 matrix.postConcat(inv); | 296 matrix.postConcat(inv); |
| 294 } | 297 } |
| 295 matrix.postConcat(fPtsToUnit); | 298 matrix.postConcat(fPtsToUnit); |
| 296 return GrSweepGradient::Create(context, *this, matrix); | 299 *grEffect = GrSweepGradient::Create(context, *this, matrix); |
| 300 return true; | |
| 297 } | 301 } |
| 298 | 302 |
| 299 #else | 303 #else |
| 300 | 304 |
| 301 GrEffectRef* SkSweepGradient::asNewEffect(GrContext*, const SkPaint&, const SkMa trix*) const { | 305 GrEffectRef* SkSweepGradient::asNewEffect(GrContext*, const SkPaint&, const SkMa trix*) const { |
| 302 SkDEBUGFAIL("Should not call in GPU-less build"); | 306 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 303 return NULL; | 307 return NULL; |
| 304 } | 308 } |
| 305 | 309 |
| 306 #endif | 310 #endif |
| 307 | 311 |
| 308 #ifndef SK_IGNORE_TO_STRING | 312 #ifndef SK_IGNORE_TO_STRING |
| 309 void SkSweepGradient::toString(SkString* str) const { | 313 void SkSweepGradient::toString(SkString* str) const { |
| 310 str->append("SkSweepGradient: ("); | 314 str->append("SkSweepGradient: ("); |
| 311 | 315 |
| 312 str->append("center: ("); | 316 str->append("center: ("); |
| 313 str->appendScalar(fCenter.fX); | 317 str->appendScalar(fCenter.fX); |
| 314 str->append(", "); | 318 str->append(", "); |
| 315 str->appendScalar(fCenter.fY); | 319 str->appendScalar(fCenter.fY); |
| 316 str->append(") "); | 320 str->append(") "); |
| 317 | 321 |
| 318 this->INHERITED::toString(str); | 322 this->INHERITED::toString(str); |
| 319 | 323 |
| 320 str->append(")"); | 324 str->append(")"); |
| 321 } | 325 } |
| 322 #endif | 326 #endif |
| OLD | NEW |