reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef SkColorMatrix_DEFINED |
| 18 | #define SkColorMatrix_DEFINED |
| 19 | |
| 20 | #include "SkScalar.h" |
| 21 | |
| 22 | class SkColorMatrix { |
| 23 | public: |
| 24 | SkScalar fMat[20]; |
| 25 | |
| 26 | void setIdentity(); |
| 27 | void setScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, |
| 28 | SkScalar aScale = SK_Scalar1); |
| 29 | void preScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, |
| 30 | SkScalar aScale = SK_Scalar1); |
| 31 | void postScale(SkScalar rScale, SkScalar gScale, SkScalar bScale, |
| 32 | SkScalar aScale = SK_Scalar1); |
| 33 | |
| 34 | enum Axis { |
| 35 | kR_Axis = 0, |
| 36 | kG_Axis = 1, |
| 37 | kB_Axis = 2 |
| 38 | }; |
| 39 | void setRotate(Axis, SkScalar degrees); |
| 40 | void setSinCos(Axis, SkScalar sine, SkScalar cosine); |
| 41 | void preRotate(Axis, SkScalar degrees); |
| 42 | void postRotate(Axis, SkScalar degrees); |
| 43 | |
| 44 | void setConcat(const SkColorMatrix& a, const SkColorMatrix& b); |
| 45 | void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); } |
| 46 | void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); } |
| 47 | |
| 48 | void setSaturation(SkScalar sat); |
| 49 | void setRGB2YUV(); |
| 50 | void setYUV2RGB(); |
| 51 | }; |
| 52 | |
| 53 | #endif |