| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 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 #ifndef SkColorMatrix_DEFINED | 8 #ifndef SkColorMatrix_DEFINED |
| 9 #define SkColorMatrix_DEFINED | 9 #define SkColorMatrix_DEFINED |
| 10 | 10 |
| 11 #include "SkScalar.h" | 11 #include "SkScalar.h" |
| 12 | 12 |
| 13 class SK_API SkColorMatrix { | 13 class SK_API SkColorMatrix { |
| 14 public: | 14 public: |
| 15 SkScalar fMat[20]; | 15 SkScalar fMat[20]; |
| 16 | 16 |
| 17 enum Elem { |
| 18 kR_Scale = 0, |
| 19 kG_Scale = 6, |
| 20 kB_Scale = 12, |
| 21 kA_Scale = 18, |
| 22 |
| 23 kR_Trans = 4, |
| 24 kG_Trans = 9, |
| 25 kB_Trans = 14, |
| 26 kA_Trans = 19, |
| 27 }; |
| 28 |
| 17 void setIdentity(); | 29 void setIdentity(); |
| 18 void setScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, | 30 void setScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, |
| 19 SkScalar aScale = SK_Scalar1); | 31 SkScalar aScale = SK_Scalar1); |
| 20 void preScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, | 32 void preScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, |
| 21 SkScalar aScale = SK_Scalar1); | 33 SkScalar aScale = SK_Scalar1); |
| 22 void postScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, | 34 void postScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, |
| 23 SkScalar aScale = SK_Scalar1); | 35 SkScalar aScale = SK_Scalar1); |
| 36 void postTranslate(SkScalar rTrans, SkScalar gTrans, SkScalar bTrans, |
| 37 SkScalar aTrans = 0); |
| 24 | 38 |
| 25 enum Axis { | 39 enum Axis { |
| 26 kR_Axis = 0, | 40 kR_Axis = 0, |
| 27 kG_Axis = 1, | 41 kG_Axis = 1, |
| 28 kB_Axis = 2 | 42 kB_Axis = 2 |
| 29 }; | 43 }; |
| 30 void setRotate(Axis, SkScalar degrees); | 44 void setRotate(Axis, SkScalar degrees); |
| 31 void setSinCos(Axis, SkScalar sine, SkScalar cosine); | 45 void setSinCos(Axis, SkScalar sine, SkScalar cosine); |
| 32 void preRotate(Axis, SkScalar degrees); | 46 void preRotate(Axis, SkScalar degrees); |
| 33 void postRotate(Axis, SkScalar degrees); | 47 void postRotate(Axis, SkScalar degrees); |
| 34 | 48 |
| 35 void setConcat(const SkColorMatrix& a, const SkColorMatrix& b); | 49 void setConcat(const SkColorMatrix& a, const SkColorMatrix& b); |
| 36 void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); } | 50 void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); } |
| 37 void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); } | 51 void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); } |
| 38 | 52 |
| 39 void setSaturation(SkScalar sat); | 53 void setSaturation(SkScalar sat); |
| 40 void setRGB2YUV(); | 54 void setRGB2YUV(); |
| 41 void setYUV2RGB(); | 55 void setYUV2RGB(); |
| 42 | 56 |
| 43 bool operator==(const SkColorMatrix& other) const { | 57 bool operator==(const SkColorMatrix& other) const { |
| 44 return 0 == memcmp(fMat, other.fMat, sizeof(fMat)); | 58 return 0 == memcmp(fMat, other.fMat, sizeof(fMat)); |
| 45 } | 59 } |
| 46 | 60 |
| 47 bool operator!=(const SkColorMatrix& other) const { return !((*this) == othe
r); } | 61 bool operator!=(const SkColorMatrix& other) const { return !((*this) == othe
r); } |
| 48 }; | 62 }; |
| 49 | 63 |
| 50 #endif | 64 #endif |
| OLD | NEW |