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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 b = pin(result[2], SK_B32_MASK); | 296 b = pin(result[2], SK_B32_MASK); |
297 | 297 |
298 // now packed it back down to 16bits (hmmm, could dither...) | 298 // now packed it back down to 16bits (hmmm, could dither...) |
299 dst[i] = SkPack888ToRGB16(r, g, b); | 299 dst[i] = SkPack888ToRGB16(r, g, b); |
300 } | 300 } |
301 } | 301 } |
302 | 302 |
303 /////////////////////////////////////////////////////////////////////////////// | 303 /////////////////////////////////////////////////////////////////////////////// |
304 | 304 |
305 void SkColorMatrixFilter::flatten(SkWriteBuffer& buffer) const { | 305 void SkColorMatrixFilter::flatten(SkWriteBuffer& buffer) const { |
306 this->INHERITED::flatten(buffer); | |
307 SkASSERT(sizeof(fMatrix.fMat)/sizeof(SkScalar) == 20); | 306 SkASSERT(sizeof(fMatrix.fMat)/sizeof(SkScalar) == 20); |
308 buffer.writeScalarArray(fMatrix.fMat, 20); | 307 buffer.writeScalarArray(fMatrix.fMat, 20); |
309 } | 308 } |
310 | 309 |
311 SkColorMatrixFilter::SkColorMatrixFilter(SkReadBuffer& buffer) | 310 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
312 : INHERITED(buffer) { | 311 SkColorMatrixFilter::SkColorMatrixFilter(SkReadBuffer& buffer) : INHERITED(buffe
r) { |
313 SkASSERT(buffer.getArrayCount() == 20); | 312 SkASSERT(buffer.getArrayCount() == 20); |
314 if (buffer.readScalarArray(fMatrix.fMat, 20)) { | 313 if (buffer.readScalarArray(fMatrix.fMat, 20)) { |
315 this->initState(fMatrix.fMat); | 314 this->initState(fMatrix.fMat); |
316 } | 315 } |
317 } | 316 } |
| 317 #endif |
| 318 |
| 319 SkFlattenable* SkColorMatrixFilter::CreateProc(SkReadBuffer& buffer) { |
| 320 SkColorMatrix matrix; |
| 321 if (buffer.readScalarArray(matrix.fMat, 20)) { |
| 322 return Create(matrix); |
| 323 } |
| 324 return NULL; |
| 325 } |
318 | 326 |
319 bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { | 327 bool SkColorMatrixFilter::asColorMatrix(SkScalar matrix[20]) const { |
320 if (matrix) { | 328 if (matrix) { |
321 memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); | 329 memcpy(matrix, fMatrix.fMat, 20 * sizeof(SkScalar)); |
322 } | 330 } |
323 return true; | 331 return true; |
324 } | 332 } |
325 | 333 |
326 #if SK_SUPPORT_GPU | 334 #if SK_SUPPORT_GPU |
327 #include "GrEffect.h" | 335 #include "GrEffect.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 str->append("matrix: ("); | 501 str->append("matrix: ("); |
494 for (int i = 0; i < 20; ++i) { | 502 for (int i = 0; i < 20; ++i) { |
495 str->appendScalar(fMatrix.fMat[i]); | 503 str->appendScalar(fMatrix.fMat[i]); |
496 if (i < 19) { | 504 if (i < 19) { |
497 str->append(", "); | 505 str->append(", "); |
498 } | 506 } |
499 } | 507 } |
500 str->append(")"); | 508 str->append(")"); |
501 } | 509 } |
502 #endif | 510 #endif |
OLD | NEW |