| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 private: | 204 private: |
| 205 | 205 |
| 206 typedef GrGLGradientEffect INHERITED; | 206 typedef GrGLGradientEffect INHERITED; |
| 207 | 207 |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 ///////////////////////////////////////////////////////////////////// | 210 ///////////////////////////////////////////////////////////////////// |
| 211 | 211 |
| 212 class GrSweepGradient : public GrGradientEffect { | 212 class GrSweepGradient : public GrGradientEffect { |
| 213 public: | 213 public: |
| 214 static GrFragmentProcessor* Create(GrContext* ctx, const SkSweepGradient& sh
ader, | 214 static GrFragmentProcessor* Create(GrContext* ctx, GrShaderDataManager* shad
erDataManager, |
| 215 const SkMatrix& m) { | 215 const SkSweepGradient& shader, const SkMa
trix& m) { |
| 216 return SkNEW_ARGS(GrSweepGradient, (ctx, shader, m)); | 216 return SkNEW_ARGS(GrSweepGradient, (ctx, shaderDataManager, shader, m)); |
| 217 } | 217 } |
| 218 virtual ~GrSweepGradient() { } | 218 virtual ~GrSweepGradient() { } |
| 219 | 219 |
| 220 const char* name() const override { return "Sweep Gradient"; } | 220 const char* name() const override { return "Sweep Gradient"; } |
| 221 | 221 |
| 222 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | 222 virtual void getGLProcessorKey(const GrGLSLCaps& caps, |
| 223 GrProcessorKeyBuilder* b) const override { | 223 GrProcessorKeyBuilder* b) const override { |
| 224 GrGLSweepGradient::GenKey(*this, caps, b); | 224 GrGLSweepGradient::GenKey(*this, caps, b); |
| 225 } | 225 } |
| 226 | 226 |
| 227 GrGLFragmentProcessor* createGLInstance() const override { | 227 GrGLFragmentProcessor* createGLInstance() const override { |
| 228 return SkNEW_ARGS(GrGLSweepGradient, (*this)); | 228 return SkNEW_ARGS(GrGLSweepGradient, (*this)); |
| 229 } | 229 } |
| 230 | 230 |
| 231 private: | 231 private: |
| 232 GrSweepGradient(GrContext* ctx, | 232 GrSweepGradient(GrContext* ctx, |
| 233 GrShaderDataManager* shaderDataManager, |
| 233 const SkSweepGradient& shader, | 234 const SkSweepGradient& shader, |
| 234 const SkMatrix& matrix) | 235 const SkMatrix& matrix) |
| 235 : INHERITED(ctx, shader, matrix, SkShader::kClamp_TileMode) { | 236 : INHERITED(ctx, shaderDataManager, shader, matrix, SkShader::kClamp_TileMod
e) { |
| 236 this->initClassID<GrSweepGradient>(); | 237 this->initClassID<GrSweepGradient>(); |
| 237 } | 238 } |
| 238 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 239 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 239 | 240 |
| 240 typedef GrGradientEffect INHERITED; | 241 typedef GrGradientEffect INHERITED; |
| 241 }; | 242 }; |
| 242 | 243 |
| 243 ///////////////////////////////////////////////////////////////////// | 244 ///////////////////////////////////////////////////////////////////// |
| 244 | 245 |
| 245 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient); | 246 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSweepGradient); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 coords2D.c_str(), coords2D.c_str()); | 292 coords2D.c_str(), coords2D.c_str()); |
| 292 } | 293 } |
| 293 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); | 294 this->emitColor(builder, ge, t.c_str(), outputColor, inputColor, samplers); |
| 294 } | 295 } |
| 295 | 296 |
| 296 ///////////////////////////////////////////////////////////////////// | 297 ///////////////////////////////////////////////////////////////////// |
| 297 | 298 |
| 298 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, | 299 bool SkSweepGradient::asFragmentProcessor(GrContext* context, const SkPaint& pai
nt, |
| 299 const SkMatrix& viewM, | 300 const SkMatrix& viewM, |
| 300 const SkMatrix* localMatrix, GrColor*
paintColor, | 301 const SkMatrix* localMatrix, GrColor*
paintColor, |
| 301 GrShaderDataManager*, | 302 GrShaderDataManager* shaderDataManager
, |
| 302 GrFragmentProcessor** effect) const { | 303 GrFragmentProcessor** effect) const { |
| 303 | 304 |
| 304 SkMatrix matrix; | 305 SkMatrix matrix; |
| 305 if (!this->getLocalMatrix().invert(&matrix)) { | 306 if (!this->getLocalMatrix().invert(&matrix)) { |
| 306 return false; | 307 return false; |
| 307 } | 308 } |
| 308 if (localMatrix) { | 309 if (localMatrix) { |
| 309 SkMatrix inv; | 310 SkMatrix inv; |
| 310 if (!localMatrix->invert(&inv)) { | 311 if (!localMatrix->invert(&inv)) { |
| 311 return false; | 312 return false; |
| 312 } | 313 } |
| 313 matrix.postConcat(inv); | 314 matrix.postConcat(inv); |
| 314 } | 315 } |
| 315 matrix.postConcat(fPtsToUnit); | 316 matrix.postConcat(fPtsToUnit); |
| 316 | 317 |
| 317 *effect = GrSweepGradient::Create(context, *this, matrix); | 318 *effect = GrSweepGradient::Create(context, shaderDataManager, *this, matrix)
; |
| 318 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 319 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 319 | 320 |
| 320 return true; | 321 return true; |
| 321 } | 322 } |
| 322 | 323 |
| 323 #else | 324 #else |
| 324 | 325 |
| 325 bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, | 326 bool SkSweepGradient::asFragmentProcessor(GrContext*, const SkPaint&, const SkMa
trix&, |
| 326 const SkMatrix*, GrColor*, GrShaderDat
aManager*, | 327 const SkMatrix*, GrColor*, GrShaderDat
aManager*, |
| 327 GrFragmentProcessor**) const { | 328 GrFragmentProcessor**) const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 339 str->appendScalar(fCenter.fX); | 340 str->appendScalar(fCenter.fX); |
| 340 str->append(", "); | 341 str->append(", "); |
| 341 str->appendScalar(fCenter.fY); | 342 str->appendScalar(fCenter.fY); |
| 342 str->append(") "); | 343 str->append(") "); |
| 343 | 344 |
| 344 this->INHERITED::toString(str); | 345 this->INHERITED::toString(str); |
| 345 | 346 |
| 346 str->append(")"); | 347 str->append(")"); |
| 347 } | 348 } |
| 348 #endif | 349 #endif |
| OLD | NEW |