• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2007 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkColorMatrix_DEFINED
9 #define SkColorMatrix_DEFINED
10 
11 #include "SkScalar.h"
12 
13 class SK_API SkColorMatrix {
14 public:
15     SkScalar    fMat[20];
16 
17     void setIdentity();
18     void setScale(SkScalar rScale, SkScalar gScale, SkScalar bScale,
19                   SkScalar aScale = SK_Scalar1);
20     void preScale(SkScalar rScale, SkScalar gScale, SkScalar bScale,
21                   SkScalar aScale = SK_Scalar1);
22     void postScale(SkScalar rScale, SkScalar gScale, SkScalar bScale,
23                    SkScalar aScale = SK_Scalar1);
24 
25     enum Axis {
26         kR_Axis = 0,
27         kG_Axis = 1,
28         kB_Axis = 2
29     };
30     void setRotate(Axis, SkScalar degrees);
31     void setSinCos(Axis, SkScalar sine, SkScalar cosine);
32     void preRotate(Axis, SkScalar degrees);
33     void postRotate(Axis, SkScalar degrees);
34 
35     void setConcat(const SkColorMatrix& a, const SkColorMatrix& b);
preConcat(const SkColorMatrix & mat)36     void preConcat(const SkColorMatrix& mat) { this->setConcat(*this, mat); }
postConcat(const SkColorMatrix & mat)37     void postConcat(const SkColorMatrix& mat) { this->setConcat(mat, *this); }
38 
39     void setSaturation(SkScalar sat);
40     void setRGB2YUV();
41     void setYUV2RGB();
42 
43     bool operator==(const SkColorMatrix& other) const {
44         return 0 == memcmp(fMat, other.fMat, sizeof(fMat));
45     }
46 
47     bool operator!=(const SkColorMatrix& other) const { return !((*this) == other); }
48 };
49 
50 #endif
51