| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 SkPaint paint; | 260 SkPaint paint; |
| 261 GrFragmentProcessor* fp; | 261 GrFragmentProcessor* fp; |
| 262 GrColor paintColor; | 262 GrColor paintColor; |
| 263 SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor
, &fp)); | 263 SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor
, &fp)); |
| 264 return fp; | 264 return fp; |
| 265 } | 265 } |
| 266 | 266 |
| 267 ///////////////////////////////////////////////////////////////////// | 267 ///////////////////////////////////////////////////////////////////// |
| 268 | 268 |
| 269 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, | 269 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, |
| 270 const GrFragmentProcessor&, | 270 const GrFragmentProcessor& fp, |
| 271 const GrProcessorKey& key, | 271 const GrProcessorKey& key, |
| 272 const char* outputColor, | 272 const char* outputColor, |
| 273 const char* inputColor, | 273 const char* inputColor, |
| 274 const TransformedCoordsArray& coords, | 274 const TransformedCoordsArray& coords, |
| 275 const TextureSamplerArray& samplers) { | 275 const TextureSamplerArray& samplers) { |
| 276 uint32_t baseKey = key.get32(0); | 276 const GrGradientEffect& ge = fp.cast<GrGradientEffect>(); |
| 277 this->emitUniforms(builder, baseKey); | 277 this->emitUniforms(builder, ge); |
| 278 SkString coords2D = builder->getFragmentShaderBuilder()->ensureFSCoords2D(co
ords, 0); | 278 SkString coords2D = builder->getFragmentShaderBuilder()->ensureFSCoords2D(co
ords, 0); |
| 279 const GrGLContextInfo ctxInfo = builder->ctxInfo(); | 279 const GrGLContextInfo ctxInfo = builder->ctxInfo(); |
| 280 SkString t; | 280 SkString t; |
| 281 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] | 281 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] |
| 282 // On Intel GPU there is an issue where it reads the second arguement to ata
n "- %s.x" as an int | 282 // On Intel GPU there is an issue where it reads the second arguement to ata
n "- %s.x" as an int |
| 283 // thus must us -1.0 * %s.x to work correctly | 283 // thus must us -1.0 * %s.x to work correctly |
| 284 if (kIntel_GrGLVendor != ctxInfo.vendor()){ | 284 if (kIntel_GrGLVendor != ctxInfo.vendor()){ |
| 285 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", | 285 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", |
| 286 coords2D.c_str(), coords2D.c_str()); | 286 coords2D.c_str(), coords2D.c_str()); |
| 287 } else { | 287 } else { |
| 288 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", | 288 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", |
| 289 coords2D.c_str(), coords2D.c_str()); | 289 coords2D.c_str(), coords2D.c_str()); |
| 290 } | 290 } |
| 291 this->emitColor(builder, t.c_str(), baseKey, outputColor, inputColor, sample
rs); | 291 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); |
| 292 } | 292 } |
| 293 | 293 |
| 294 ///////////////////////////////////////////////////////////////////// | 294 ///////////////////////////////////////////////////////////////////// |
| 295 | 295 |
| 296 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, | 296 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, |
| 297 const SkMatrix* localMatrix, GrColor*
paintColor, | 297 const SkMatrix* localMatrix, GrColor*
paintColor, |
| 298 GrFragmentProcessor** effect) const { | 298 GrFragmentProcessor** effect) const { |
| 299 | 299 |
| 300 SkMatrix matrix; | 300 SkMatrix matrix; |
| 301 if (!this->getLocalMatrix().invert(&matrix)) { | 301 if (!this->getLocalMatrix().invert(&matrix)) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 str->appendScalar(fCenter.fX); | 334 str->appendScalar(fCenter.fX); |
| 335 str->append(", "); | 335 str->append(", "); |
| 336 str->appendScalar(fCenter.fY); | 336 str->appendScalar(fCenter.fY); |
| 337 str->append(") "); | 337 str->append(") "); |
| 338 | 338 |
| 339 this->INHERITED::toString(str); | 339 this->INHERITED::toString(str); |
| 340 | 340 |
| 341 str->append(")"); | 341 str->append(")"); |
| 342 } | 342 } |
| 343 #endif | 343 #endif |
| OLD | NEW |