| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkColorMatrixFilter.h" | 8 #include "SkColorMatrixFilter.h" |
| 9 #include "SkColorMatrix.h" | 9 #include "SkColorMatrix.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 #include "gl/builders/GrGLProgramBuilder.h" | 387 #include "gl/builders/GrGLProgramBuilder.h" |
| 388 | 388 |
| 389 class ColorMatrixEffect : public GrFragmentProcessor { | 389 class ColorMatrixEffect : public GrFragmentProcessor { |
| 390 public: | 390 public: |
| 391 static GrFragmentProcessor* Create(const SkColorMatrix& matrix) { | 391 static GrFragmentProcessor* Create(const SkColorMatrix& matrix) { |
| 392 return SkNEW_ARGS(ColorMatrixEffect, (matrix)); | 392 return SkNEW_ARGS(ColorMatrixEffect, (matrix)); |
| 393 } | 393 } |
| 394 | 394 |
| 395 const char* name() const override { return "Color Matrix"; } | 395 const char* name() const override { return "Color Matrix"; } |
| 396 | 396 |
| 397 virtual void getGLProcessorKey(const GrGLSLCaps& caps, | |
| 398 GrProcessorKeyBuilder* b) const override { | |
| 399 GLProcessor::GenKey(*this, caps, b); | |
| 400 } | |
| 401 | |
| 402 GrGLFragmentProcessor* createGLInstance() const override { | 397 GrGLFragmentProcessor* createGLInstance() const override { |
| 403 return SkNEW_ARGS(GLProcessor, (*this)); | 398 return SkNEW_ARGS(GLProcessor, (*this)); |
| 404 } | 399 } |
| 405 | 400 |
| 406 | 401 |
| 407 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 402 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 408 | 403 |
| 409 class GLProcessor : public GrGLFragmentProcessor { | 404 class GLProcessor : public GrGLFragmentProcessor { |
| 410 public: | 405 public: |
| 411 // this class always generates the same code. | 406 // this class always generates the same code. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 GrGLProgramDataManager::UniformHandle fVectorHandle; | 459 GrGLProgramDataManager::UniformHandle fVectorHandle; |
| 465 | 460 |
| 466 typedef GrGLFragmentProcessor INHERITED; | 461 typedef GrGLFragmentProcessor INHERITED; |
| 467 }; | 462 }; |
| 468 | 463 |
| 469 private: | 464 private: |
| 470 ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) { | 465 ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) { |
| 471 this->initClassID<ColorMatrixEffect>(); | 466 this->initClassID<ColorMatrixEffect>(); |
| 472 } | 467 } |
| 473 | 468 |
| 469 virtual void onGetGLProcessorKey(const GrGLSLCaps& caps, |
| 470 GrProcessorKeyBuilder* b) const override { |
| 471 GLProcessor::GenKey(*this, caps, b); |
| 472 } |
| 473 |
| 474 bool onIsEqual(const GrFragmentProcessor& s) const override { | 474 bool onIsEqual(const GrFragmentProcessor& s) const override { |
| 475 const ColorMatrixEffect& cme = s.cast<ColorMatrixEffect>(); | 475 const ColorMatrixEffect& cme = s.cast<ColorMatrixEffect>(); |
| 476 return cme.fMatrix == fMatrix; | 476 return cme.fMatrix == fMatrix; |
| 477 } | 477 } |
| 478 | 478 |
| 479 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 479 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
| 480 // We only bother to check whether the alpha channel will be constant. I
f SkColorMatrix had | 480 // We only bother to check whether the alpha channel will be constant. I
f SkColorMatrix had |
| 481 // type flags it might be worth checking the other components. | 481 // type flags it might be worth checking the other components. |
| 482 | 482 |
| 483 // The matrix is defined such the 4th row determines the output alpha. T
he first four | 483 // The matrix is defined such the 4th row determines the output alpha. T
he first four |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 str->append("matrix: ("); | 560 str->append("matrix: ("); |
| 561 for (int i = 0; i < 20; ++i) { | 561 for (int i = 0; i < 20; ++i) { |
| 562 str->appendScalar(fMatrix.fMat[i]); | 562 str->appendScalar(fMatrix.fMat[i]); |
| 563 if (i < 19) { | 563 if (i < 19) { |
| 564 str->append(", "); | 564 str->append(", "); |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 str->append(")"); | 567 str->append(")"); |
| 568 } | 568 } |
| 569 #endif | 569 #endif |
| OLD | NEW |