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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 this->INHERITED::flatten(buffer); | 303 this->INHERITED::flatten(buffer); |
304 SkASSERT(sizeof(fMatrix.fMat)/sizeof(SkScalar) == 20); | 304 SkASSERT(sizeof(fMatrix.fMat)/sizeof(SkScalar) == 20); |
305 buffer.writeScalarArray(fMatrix.fMat, 20); | 305 buffer.writeScalarArray(fMatrix.fMat, 20); |
306 } | 306 } |
307 | 307 |
308 SkColorMatrixFilter::SkColorMatrixFilter(SkFlattenableReadBuffer& buffer) | 308 SkColorMatrixFilter::SkColorMatrixFilter(SkFlattenableReadBuffer& buffer) |
309 : INHERITED(buffer) { | 309 : INHERITED(buffer) { |
310 SkASSERT(buffer.getArrayCount() == 20); | 310 SkASSERT(buffer.getArrayCount() == 20); |
311 buffer.readScalarArray(fMatrix.fMat); | 311 buffer.readScalarArray(fMatrix.fMat); |
312 this->initState(fMatrix.fMat); | 312 this->initState(fMatrix.fMat); |
| 313 for (int i = 0; i < 20; ++i) { |
| 314 buffer.validate(SkScalarIsFinite(fMatrix.fMat[i])); |
| 315 } |
313 } | 316 } |
314 | 317 |
315 bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { | 318 bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { |
316 if (matrix) { | 319 if (matrix) { |
317 memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); | 320 memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); |
318 } | 321 } |
319 return true; | 322 return true; |
320 } | 323 } |
321 | 324 |
322 #if SK_SUPPORT_GPU | 325 #if SK_SUPPORT_GPU |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 str->append("matrix: ("); | 489 str->append("matrix: ("); |
487 for (int i = 0; i < 20; ++i) { | 490 for (int i = 0; i < 20; ++i) { |
488 str->appendScalar(fMatrix.fMat[i]); | 491 str->appendScalar(fMatrix.fMat[i]); |
489 if (i < 19) { | 492 if (i < 19) { |
490 str->append(", "); | 493 str->append(", "); |
491 } | 494 } |
492 } | 495 } |
493 str->append(")"); | 496 str->append(")"); |
494 } | 497 } |
495 #endif | 498 #endif |
OLD | NEW |