| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 183 |
| 184 #include "SkGr.h" | 184 #include "SkGr.h" |
| 185 #include "gl/builders/GrGLProgramBuilder.h" | 185 #include "gl/builders/GrGLProgramBuilder.h" |
| 186 | 186 |
| 187 class GrGLSweepGradient : public GrGLGradientEffect { | 187 class GrGLSweepGradient : public GrGLGradientEffect { |
| 188 public: | 188 public: |
| 189 | 189 |
| 190 GrGLSweepGradient(const GrProcessor&) {} | 190 GrGLSweepGradient(const GrProcessor&) {} |
| 191 virtual ~GrGLSweepGradient() { } | 191 virtual ~GrGLSweepGradient() { } |
| 192 | 192 |
| 193 virtual void emitCode(GrGLFPBuilder*, | 193 virtual void emitCode(EmitArgs&) override; |
| 194 const GrFragmentProcessor&, | |
| 195 const char* outputColor, | |
| 196 const char* inputColor, | |
| 197 const TransformedCoordsArray&, | |
| 198 const TextureSamplerArray&) override; | |
| 199 | 194 |
| 200 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces
sorKeyBuilder* b) { | 195 static void GenKey(const GrProcessor& processor, const GrGLSLCaps&, GrProces
sorKeyBuilder* b) { |
| 201 b->add32(GenBaseGradientKey(processor)); | 196 b->add32(GenBaseGradientKey(processor)); |
| 202 } | 197 } |
| 203 | 198 |
| 204 private: | 199 private: |
| 205 | 200 |
| 206 typedef GrGLGradientEffect INHERITED; | 201 typedef GrGLGradientEffect INHERITED; |
| 207 | 202 |
| 208 }; | 203 }; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 GrFragmentProcessor* fp; | 254 GrFragmentProcessor* fp; |
| 260 GrColor paintColor; | 255 GrColor paintColor; |
| 261 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, | 256 SkAssertResult(shader->asFragmentProcessor(d->fContext, paint, |
| 262 GrTest::TestMatrix(d->fRandom), N
ULL, | 257 GrTest::TestMatrix(d->fRandom), N
ULL, |
| 263 &paintColor, d->fProcDataManager,
&fp)); | 258 &paintColor, d->fProcDataManager,
&fp)); |
| 264 return fp; | 259 return fp; |
| 265 } | 260 } |
| 266 | 261 |
| 267 ///////////////////////////////////////////////////////////////////// | 262 ///////////////////////////////////////////////////////////////////// |
| 268 | 263 |
| 269 void GrGLSweepGradient::emitCode(GrGLFPBuilder* builder, | 264 void GrGLSweepGradient::emitCode(EmitArgs& args) { |
| 270 const GrFragmentProcessor& fp, | 265 const GrSweepGradient& ge = args.fFp.cast<GrSweepGradient>(); |
| 271 const char* outputColor, | 266 this->emitUniforms(args.fBuilder, ge); |
| 272 const char* inputColor, | 267 SkString coords2D = args.fBuilder->getFragmentShaderBuilder() |
| 273 const TransformedCoordsArray& coords, | 268 ->ensureFSCoords2D(args.fCoords, 0); |
| 274 const TextureSamplerArray& samplers) { | 269 const GrGLContextInfo& ctxInfo = args.fBuilder->ctxInfo(); |
| 275 const GrSweepGradient& ge = fp.cast<GrSweepGradient>(); | |
| 276 this->emitUniforms(builder, ge); | |
| 277 SkString coords2D = builder->getFragmentShaderBuilder()->ensureFSCoords2D(co
ords, 0); | |
| 278 const GrGLContextInfo& ctxInfo = builder->ctxInfo(); | |
| 279 SkString t; | 270 SkString t; |
| 280 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] | 271 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] |
| 281 // On Intel GPU there is an issue where it reads the second arguement to ata
n "- %s.x" as an int | 272 // On Intel GPU there is an issue where it reads the second arguement to ata
n "- %s.x" as an int |
| 282 // thus must us -1.0 * %s.x to work correctly | 273 // thus must us -1.0 * %s.x to work correctly |
| 283 if (kIntel_GrGLVendor != ctxInfo.vendor()){ | 274 if (kIntel_GrGLVendor != ctxInfo.vendor()){ |
| 284 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", | 275 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", |
| 285 coords2D.c_str(), coords2D.c_str()); | 276 coords2D.c_str(), coords2D.c_str()); |
| 286 } else { | 277 } else { |
| 287 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", | 278 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", |
| 288 coords2D.c_str(), coords2D.c_str()); | 279 coords2D.c_str(), coords2D.c_str()); |
| 289 } | 280 } |
| 290 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 281 this->emitColor(args.fBuilder, ge, t.c_str(), args.fOutputColor, args.fInput
Color, |
| 282 args.fSamplers); |
| 291 } | 283 } |
| 292 | 284 |
| 293 ///////////////////////////////////////////////////////////////////// | 285 ///////////////////////////////////////////////////////////////////// |
| 294 | 286 |
| 295 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, | 287 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, |
| 296 const SkMatrix& viewM, | 288 const SkMatrix& viewM, |
| 297 const SkMatrix* localMatrix, GrColor*
paintColor, | 289 const SkMatrix* localMatrix, GrColor*
paintColor, |
| 298 GrProcessorDataManager* procDataManage
r, | 290 GrProcessorDataManager* procDataManage
r, |
| 299 GrFragmentProcessor** effect) const { | 291 GrFragmentProcessor** effect) const { |
| 300 | 292 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 str->appendScalar(fCenter.fX); | 328 str->appendScalar(fCenter.fX); |
| 337 str->append(", "); | 329 str->append(", "); |
| 338 str->appendScalar(fCenter.fY); | 330 str->appendScalar(fCenter.fY); |
| 339 str->append(") "); | 331 str->append(") "); |
| 340 | 332 |
| 341 this->INHERITED::toString(str); | 333 this->INHERITED::toString(str); |
| 342 | 334 |
| 343 str->append(")"); | 335 str->append(")"); |
| 344 } | 336 } |
| 345 #endif | 337 #endif |
| OLD | NEW |