| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 toggle = next_dither_toggle16(toggle); | 178 toggle = next_dither_toggle16(toggle); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 ///////////////////////////////////////////////////////////////////// | 183 ///////////////////////////////////////////////////////////////////// |
| 184 | 184 |
| 185 #if SK_SUPPORT_GPU | 185 #if SK_SUPPORT_GPU |
| 186 | 186 |
| 187 #include "GrTBackendEffectFactory.h" | 187 #include "GrTBackendEffectFactory.h" |
| 188 #include "gl/GrGLShaderBuilder.h" | 188 #include "gl/builders/GrGLProgramBuilder.h" |
| 189 #include "SkGr.h" | 189 #include "SkGr.h" |
| 190 | 190 |
| 191 class GrGLSweepGradient : public GrGLGradientEffect { | 191 class GrGLSweepGradient : public GrGLGradientEffect { |
| 192 public: | 192 public: |
| 193 | 193 |
| 194 GrGLSweepGradient(const GrBackendEffectFactory& factory, | 194 GrGLSweepGradient(const GrBackendEffectFactory& factory, |
| 195 const GrDrawEffect&) : INHERITED (factory) { } | 195 const GrDrawEffect&) : INHERITED (factory) { } |
| 196 virtual ~GrGLSweepGradient() { } | 196 virtual ~GrGLSweepGradient() { } |
| 197 | 197 |
| 198 virtual void emitCode(GrGLShaderBuilder*, | 198 virtual void emitCode(GrGLProgramBuilder*, |
| 199 const GrDrawEffect&, | 199 const GrDrawEffect&, |
| 200 const GrEffectKey&, | 200 const GrEffectKey&, |
| 201 const char* outputColor, | 201 const char* outputColor, |
| 202 const char* inputColor, | 202 const char* inputColor, |
| 203 const TransformedCoordsArray&, | 203 const TransformedCoordsArray&, |
| 204 const TextureSamplerArray&) SK_OVERRIDE; | 204 const TextureSamplerArray&) SK_OVERRIDE; |
| 205 | 205 |
| 206 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect
KeyBuilder* b) { | 206 static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffect
KeyBuilder* b) { |
| 207 b->add32(GenBaseGradientKey(drawEffect)); | 207 b->add32(GenBaseGradientKey(drawEffect)); |
| 208 } | 208 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 colors, stops, c
olorCount)); | 258 colors, stops, c
olorCount)); |
| 259 SkPaint paint; | 259 SkPaint paint; |
| 260 GrEffect* effect; | 260 GrEffect* effect; |
| 261 GrColor paintColor; | 261 GrColor paintColor; |
| 262 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec
t)); | 262 SkAssertResult(shader->asNewEffect(context, paint, NULL, &paintColor, &effec
t)); |
| 263 return effect; | 263 return effect; |
| 264 } | 264 } |
| 265 | 265 |
| 266 ///////////////////////////////////////////////////////////////////// | 266 ///////////////////////////////////////////////////////////////////// |
| 267 | 267 |
| 268 void GrGLSweepGradient::emitCode(GrGLShaderBuilder* builder, | 268 void GrGLSweepGradient::emitCode(GrGLProgramBuilder* builder, |
| 269 const GrDrawEffect&, | 269 const GrDrawEffect&, |
| 270 const GrEffectKey& key, | 270 const GrEffectKey& key, |
| 271 const char* outputColor, | 271 const char* outputColor, |
| 272 const char* inputColor, | 272 const char* inputColor, |
| 273 const TransformedCoordsArray& coords, | 273 const TransformedCoordsArray& coords, |
| 274 const TextureSamplerArray& samplers) { | 274 const TextureSamplerArray& samplers) { |
| 275 uint32_t baseKey = key.get32(0); | 275 uint32_t baseKey = key.get32(0); |
| 276 this->emitUniforms(builder, baseKey); | 276 this->emitUniforms(builder, baseKey); |
| 277 SkString coords2D = builder->ensureFSCoords2D(coords, 0); | 277 SkString coords2D = builder->getFragmentShaderBuilder()->ensureFSCoords2D(co
ords, 0); |
| 278 const GrGLContextInfo ctxInfo = builder->ctxInfo(); | 278 const GrGLContextInfo ctxInfo = builder->ctxInfo(); |
| 279 SkString t; | 279 SkString t; |
| 280 // 0.1591549430918 is 1/(2*pi), used since atan returns values [-pi, pi] | 280 // 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 | 281 // 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 | 282 // thus must us -1.0 * %s.x to work correctly |
| 283 if (kIntel_GrGLVendor != ctxInfo.vendor()){ | 283 if (kIntel_GrGLVendor != ctxInfo.vendor()){ |
| 284 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", | 284 t.printf("atan(- %s.y, - %s.x) * 0.1591549430918 + 0.5", |
| 285 coords2D.c_str(), coords2D.c_str()); | 285 coords2D.c_str(), coords2D.c_str()); |
| 286 } else { | 286 } else { |
| 287 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", | 287 t.printf("atan(- %s.y, -1.0 * %s.x) * 0.1591549430918 + 0.5", |
| (...skipping 46 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 |