OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 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 #include "SkColorMatrixFilter.h" | 8 #include "SkColorMatrixFilter.h" |
9 #include "SkColorMatrix.h" | 9 #include "SkColorMatrix.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return NULL; | 315 return NULL; |
316 } | 316 } |
317 | 317 |
318 bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { | 318 bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { |
319 if (matrix) { | 319 if (matrix) { |
320 memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); | 320 memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); |
321 } | 321 } |
322 return true; | 322 return true; |
323 } | 323 } |
324 | 324 |
| 325 SkColorFilter* SkColorMatrixFilter::newComposed(const SkColorFilter* innerFilter
) const { |
| 326 SkScalar innerMatrix[20]; |
| 327 if (innerFilter->asColorMatrix(innerMatrix) && !SkColorMatrix::NeedsClamping
(innerMatrix)) { |
| 328 SkScalar concat[20]; |
| 329 SkColorMatrix::SetConcat(concat, fMatrix.fMat, innerMatrix); |
| 330 return SkColorMatrixFilter::Create(concat); |
| 331 } |
| 332 return NULL; |
| 333 } |
| 334 |
325 #if SK_SUPPORT_GPU | 335 #if SK_SUPPORT_GPU |
326 #include "GrFragmentProcessor.h" | 336 #include "GrFragmentProcessor.h" |
327 #include "GrInvariantOutput.h" | 337 #include "GrInvariantOutput.h" |
328 #include "gl/GrGLProcessor.h" | 338 #include "gl/GrGLProcessor.h" |
329 #include "gl/builders/GrGLProgramBuilder.h" | 339 #include "gl/builders/GrGLProgramBuilder.h" |
330 | 340 |
331 class ColorMatrixEffect : public GrFragmentProcessor { | 341 class ColorMatrixEffect : public GrFragmentProcessor { |
332 public: | 342 public: |
333 static GrFragmentProcessor* Create(const SkColorMatrix& matrix) { | 343 static GrFragmentProcessor* Create(const SkColorMatrix& matrix) { |
334 return SkNEW_ARGS(ColorMatrixEffect, (matrix)); | 344 return SkNEW_ARGS(ColorMatrixEffect, (matrix)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 str->append("matrix: ("); | 507 str->append("matrix: ("); |
498 for (int i = 0; i < 20; ++i) { | 508 for (int i = 0; i < 20; ++i) { |
499 str->appendScalar(fMatrix.fMat[i]); | 509 str->appendScalar(fMatrix.fMat[i]); |
500 if (i < 19) { | 510 if (i < 19) { |
501 str->append(", "); | 511 str->append(", "); |
502 } | 512 } |
503 } | 513 } |
504 str->append(")"); | 514 str->append(")"); |
505 } | 515 } |
506 #endif | 516 #endif |
OLD | NEW |