| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 SkColor colors[kMaxRandomGradientColors]; | 253 SkColor colors[kMaxRandomGradientColors]; |
| 254 SkScalar stopsArray[kMaxRandomGradientColors]; | 254 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 255 SkScalar* stops = stopsArray; | 255 SkScalar* stops = stopsArray; |
| 256 SkShader::TileMode tmIgnored; | 256 SkShader::TileMode tmIgnored; |
| 257 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); | 257 int colorCount = RandomGradientParams(random, colors, &stops, &tmIgnored); |
| 258 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente
r.fY, | 258 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateSweep(center.fX, cente
r.fY, |
| 259 colors, stops, c
olorCount)); | 259 colors, stops, c
olorCount)); |
| 260 SkPaint paint; | 260 SkPaint paint; |
| 261 GrFragmentProcessor* fp; | 261 GrFragmentProcessor* fp; |
| 262 GrColor paintColor; | 262 GrColor paintColor; |
| 263 GrPaint grPaint; |
| 263 SkAssertResult(shader->asFragmentProcessor(context, paint, | 264 SkAssertResult(shader->asFragmentProcessor(context, paint, |
| 264 GrTest::TestMatrix(random), NULL, | 265 GrTest::TestMatrix(random), NULL, |
| 265 &paintColor, &fp)); | 266 &paintColor, grPaint.getShaderDat
aManager(), &fp)); |
| 266 return fp; | 267 return fp; |
| 267 } | 268 } |
| 268 | 269 |
| 269 ///////////////////////////////////////////////////////////////////// | 270 ///////////////////////////////////////////////////////////////////// |
| 270 | 271 |
| 271 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, | 272 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, |
| 272 const GrFragmentProcessor& fp, | 273 const GrFragmentProcessor& fp, |
| 273 const char* outputColor, | 274 const char* outputColor, |
| 274 const char* inputColor, | 275 const char* inputColor, |
| 275 const TransformedCoordsArray& coords, | 276 const TransformedCoordsArray& coords, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 290 coords2D.c_str(), coords2D.c_str()); | 291 coords2D.c_str(), coords2D.c_str()); |
| 291 } | 292 } |
| 292 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 293 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); |
| 293 } | 294 } |
| 294 | 295 |
| 295 ///////////////////////////////////////////////////////////////////// | 296 ///////////////////////////////////////////////////////////////////// |
| 296 | 297 |
| 297 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, | 298 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, |
| 298 const SkMatrix& viewM, | 299 const SkMatrix& viewM, |
| 299 const SkMatrix* localMatrix, GrColor*
paintColor, | 300 const SkMatrix* localMatrix, GrColor*
paintColor, |
| 301 GrShaderDataManager*, |
| 300 GrFragmentProcessor** effect) const { | 302 GrFragmentProcessor** effect) const { |
| 301 | 303 |
| 302 SkMatrix matrix; | 304 SkMatrix matrix; |
| 303 if (!this->getLocalMatrix().invert(&matrix)) { | 305 if (!this->getLocalMatrix().invert(&matrix)) { |
| 304 return false; | 306 return false; |
| 305 } | 307 } |
| 306 if (localMatrix) { | 308 if (localMatrix) { |
| 307 SkMatrix inv; | 309 SkMatrix inv; |
| 308 if (!localMatrix->invert(&inv)) { | 310 if (!localMatrix->invert(&inv)) { |
| 309 return false; | 311 return false; |
| 310 } | 312 } |
| 311 matrix.postConcat(inv); | 313 matrix.postConcat(inv); |
| 312 } | 314 } |
| 313 matrix.postConcat(fPtsToUnit); | 315 matrix.postConcat(fPtsToUnit); |
| 314 | 316 |
| 315 *effect = GrSweepGradient::Create(context, *this, matrix); | 317 *effect = GrSweepGradient::Create(context, *this, matrix); |
| 316 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 318 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 317 | 319 |
| 318 return true; | 320 return true; |
| 319 } | 321 } |
| 320 | 322 |
| 321 #else | 323 #else |
| 322 | 324 |
| 323 bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, | 325 bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, |
| 324 const SkMatrix*, GrColor*, | 326 const SkMatrix*, GrColor*, GrShaderDat
aManager*, |
| 325 GrFragmentProcessor**) const { | 327 GrFragmentProcessor**) const { |
| 326 SkDEBUGFAIL("Should not call in GPU-less build"); | 328 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 327 return false; | 329 return false; |
| 328 } | 330 } |
| 329 | 331 |
| 330 #endif | 332 #endif |
| 331 | 333 |
| 332 #ifndef SK_IGNORE_TO_STRING | 334 #ifndef SK_IGNORE_TO_STRING |
| 333 void SkSweepGradient::toString(SkString* str) const { | 335 void SkSweepGradient::toString(SkString* str) const { |
| 334 str->append("SkSweepGradient: ("); | 336 str->append("SkSweepGradient: ("); |
| 335 | 337 |
| 336 str->append("center: ("); | 338 str->append("center: ("); |
| 337 str->appendScalar(fCenter.fX); | 339 str->appendScalar(fCenter.fX); |
| 338 str->append(", "); | 340 str->append(", "); |
| 339 str->appendScalar(fCenter.fY); | 341 str->appendScalar(fCenter.fY); |
| 340 str->append(") "); | 342 str->append(") "); |
| 341 | 343 |
| 342 this->INHERITED::toString(str); | 344 this->INHERITED::toString(str); |
| 343 | 345 |
| 344 str->append(")"); | 346 str->append(")"); |
| 345 } | 347 } |
| 346 #endif | 348 #endif |
| OLD | NEW |