| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 383 } |
| 384 | 384 |
| 385 #if SK_SUPPORT_GPU | 385 #if SK_SUPPORT_GPU |
| 386 #include "GrFragmentProcessor.h" | 386 #include "GrFragmentProcessor.h" |
| 387 #include "GrInvariantOutput.h" | 387 #include "GrInvariantOutput.h" |
| 388 #include "gl/GrGLFragmentProcessor.h" | 388 #include "gl/GrGLFragmentProcessor.h" |
| 389 #include "gl/builders/GrGLProgramBuilder.h" | 389 #include "gl/builders/GrGLProgramBuilder.h" |
| 390 | 390 |
| 391 class ColorMatrixEffect : public GrFragmentProcessor { | 391 class ColorMatrixEffect : public GrFragmentProcessor { |
| 392 public: | 392 public: |
| 393 static GrFragmentProcessor* Create(const SkColorMatrix& matrix) { | 393 static const GrFragmentProcessor* Create(const SkColorMatrix& matrix) { |
| 394 return new ColorMatrixEffect(matrix); | 394 return new ColorMatrixEffect(matrix); |
| 395 } | 395 } |
| 396 | 396 |
| 397 const char* name() const override { return "Color Matrix"; } | 397 const char* name() const override { return "Color Matrix"; } |
| 398 | 398 |
| 399 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 399 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 400 | 400 |
| 401 class GLProcessor : public GrGLFragmentProcessor { | 401 class GLProcessor : public GrGLFragmentProcessor { |
| 402 public: | 402 public: |
| 403 // this class always generates the same code. | 403 // this class always generates the same code. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect); | 529 GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorMatrixEffect); |
| 530 | 530 |
| 531 const GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d)
{ | 531 const GrFragmentProcessor* ColorMatrixEffect::TestCreate(GrProcessorTestData* d)
{ |
| 532 SkColorMatrix colorMatrix; | 532 SkColorMatrix colorMatrix; |
| 533 for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) { | 533 for (size_t i = 0; i < SK_ARRAY_COUNT(colorMatrix.fMat); ++i) { |
| 534 colorMatrix.fMat[i] = d->fRandom->nextSScalar1(); | 534 colorMatrix.fMat[i] = d->fRandom->nextSScalar1(); |
| 535 } | 535 } |
| 536 return ColorMatrixEffect::Create(colorMatrix); | 536 return ColorMatrixEffect::Create(colorMatrix); |
| 537 } | 537 } |
| 538 | 538 |
| 539 bool SkColorMatrixFilter::asFragmentProcessors(GrContext*, GrProcessorDataManage
r*, | 539 const GrFragmentProcessor* SkColorMatrixFilter::asFragmentProcessor(GrContext*, |
| 540 SkTDArray<const GrFragmentProcess
or*>* array) const { | 540 GrProcessorD
ataManager*) const { |
| 541 GrFragmentProcessor* frag = ColorMatrixEffect::Create(fMatrix); | 541 return ColorMatrixEffect::Create(fMatrix); |
| 542 if (frag) { | |
| 543 if (array) { | |
| 544 *array->append() = frag; | |
| 545 } else { | |
| 546 frag->unref(); | |
| 547 SkDEBUGCODE(frag = nullptr;) | |
| 548 } | |
| 549 return true; | |
| 550 } | |
| 551 return false; | |
| 552 } | 542 } |
| 553 | 543 |
| 554 #endif | 544 #endif |
| 555 | 545 |
| 556 #ifndef SK_IGNORE_TO_STRING | 546 #ifndef SK_IGNORE_TO_STRING |
| 557 void SkColorMatrixFilter::toString(SkString* str) const { | 547 void SkColorMatrixFilter::toString(SkString* str) const { |
| 558 str->append("SkColorMatrixFilter: "); | 548 str->append("SkColorMatrixFilter: "); |
| 559 | 549 |
| 560 str->append("matrix: ("); | 550 str->append("matrix: ("); |
| 561 for (int i = 0; i < 20; ++i) { | 551 for (int i = 0; i < 20; ++i) { |
| 562 str->appendScalar(fMatrix.fMat[i]); | 552 str->appendScalar(fMatrix.fMat[i]); |
| 563 if (i < 19) { | 553 if (i < 19) { |
| 564 str->append(", "); | 554 str->append(", "); |
| 565 } | 555 } |
| 566 } | 556 } |
| 567 str->append(")"); | 557 str->append(")"); |
| 568 } | 558 } |
| 569 #endif | 559 #endif |
| OLD | NEW |