| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 str->append("matrix: ("); | 331 str->append("matrix: ("); |
| 332 for (int i = 0; i < 20; ++i) { | 332 for (int i = 0; i < 20; ++i) { |
| 333 str->appendScalar(fMatrix.fMat[i]); | 333 str->appendScalar(fMatrix.fMat[i]); |
| 334 if (i < 19) { | 334 if (i < 19) { |
| 335 str->append(", "); | 335 str->append(", "); |
| 336 } | 336 } |
| 337 } | 337 } |
| 338 str->append(")"); | 338 str->append(")"); |
| 339 } | 339 } |
| 340 #endif | 340 #endif |
| 341 |
| 342 /////////////////////////////////////////////////////////////////////////////// |
| 343 |
| 344 static SkScalar byte_to_scale(U8CPU byte) { |
| 345 if (0xFF == byte) { |
| 346 // want to get this exact |
| 347 return 1; |
| 348 } else { |
| 349 return byte * 0.00392156862745f; |
| 350 } |
| 351 } |
| 352 |
| 353 SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor ad
d) { |
| 354 SkColorMatrix matrix; |
| 355 matrix.setScale(byte_to_scale(SkColorGetR(mul)), |
| 356 byte_to_scale(SkColorGetG(mul)), |
| 357 byte_to_scale(SkColorGetB(mul)), |
| 358 1); |
| 359 matrix.postTranslate(SkIntToScalar(SkColorGetR(add)), |
| 360 SkIntToScalar(SkColorGetG(add)), |
| 361 SkIntToScalar(SkColorGetB(add)), |
| 362 0); |
| 363 return SkColorMatrixFilter::Create(matrix); |
| 364 } |
| 365 |
| 366 // DEPRECTED -- remove this when chrome/android stop calling it |
| 367 SkColorFilter* SkColorFilter::CreateLightingFilter(SkColor mul, SkColor add) { |
| 368 return SkColorMatrixFilter::CreateLightingFilter(mul, add); |
| 369 } |
| OLD | NEW |