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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 #ifdef SK_DEBUG | 262 #ifdef SK_DEBUG |
263 SkPMFloat pmf(pm); | 263 SkPMFloat pmf(pm); |
264 SkASSERT(pmf.isValid()); | 264 SkASSERT(pmf.isValid()); |
265 #endif | 265 #endif |
266 | 266 |
267 return pm; | 267 return pm; |
268 } | 268 } |
269 | 269 |
270 static Sk4f unpremul(const SkPMFloat& pm) { | 270 static Sk4f unpremul(const SkPMFloat& pm) { |
271 float scale = 255 / pm.a(); // candidate for fast/approx invert? | 271 float scale = 255 / pm.a(); // candidate for fast/approx invert? |
272 return Sk4f(pm) * Sk4f(scale, scale, scale, 1); | 272 return pm * Sk4f(scale, scale, scale, 1); |
273 } | 273 } |
274 | 274 |
275 static Sk4f clamp_0_255(const Sk4f& value) { | 275 static Sk4f clamp_0_255(const Sk4f& value) { |
276 return Sk4f::Max(Sk4f::Min(value, Sk4f(255)), Sk4f(0)); | 276 return Sk4f::Max(Sk4f::Min(value, Sk4f(255)), Sk4f(0)); |
277 } | 277 } |
278 | 278 |
279 void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
dst[]) const { | 279 void SkColorMatrixFilter::filterSpan(const SkPMColor src[], int count, SkPMColor
dst[]) const { |
280 Proc proc = fProc; | 280 Proc proc = fProc; |
281 if (NULL == proc) { | 281 if (NULL == proc) { |
282 if (src != dst) { | 282 if (src != dst) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 str->append("matrix: ("); | 577 str->append("matrix: ("); |
578 for (int i = 0; i < 20; ++i) { | 578 for (int i = 0; i < 20; ++i) { |
579 str->appendScalar(fMatrix.fMat[i]); | 579 str->appendScalar(fMatrix.fMat[i]); |
580 if (i < 19) { | 580 if (i < 19) { |
581 str->append(", "); | 581 str->append(", "); |
582 } | 582 } |
583 } | 583 } |
584 str->append(")"); | 584 str->append(")"); |
585 } | 585 } |
586 #endif | 586 #endif |
OLD | NEW |