Skia
2D Graphics Library
SkColorFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 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 SkColorFilter_DEFINED
9 #define SkColorFilter_DEFINED
10 
12 #include "include/core/SkColor.h"
14 
15 class SkColorMatrix;
16 
26 public:
27  // DEPRECATED. skbug.com/8941
28 
29  bool asColorMode(SkColor* color, SkBlendMode* mode) const;
30 
35  bool asAColorMode(SkColor* color, SkBlendMode* mode) const;
36 
41  bool asAColorMatrix(float matrix[20]) const;
42 
43  // deprecated, use isAlphaUnchanged()
44  enum Flags {
45  kAlphaUnchanged_Flag = 1 << 0,
46  };
47  uint32_t getFlags() const;
48 
49 
50  // Returns true if the filter is guaranteed to never change the alpha of a color it filters.
51  bool isAlphaUnchanged() const;
52 
54 
59  SkColor4f filterColor4f(const SkColor4f& srcColor, SkColorSpace* srcCS,
60  SkColorSpace* dstCS) const;
61 
68 
70  return kSkColorFilter_Type;
71  }
72 
73 private:
74  SkColorFilter() = default;
75  friend class SkColorFilterBase;
76 
77  using INHERITED = SkFlattenable;
78 };
79 
81 public:
83  return outer ? outer->makeComposed(inner) : inner;
84  }
87  static sk_sp<SkColorFilter> Matrix(const float rowMajor[20]);
88 
89  // A version of Matrix which operates in HSLA space instead of RGBA.
90  // I.e. HSLA-to-RGBA(Matrix(RGBA-to-HSLA(input))).
92  static sk_sp<SkColorFilter> HSLAMatrix(const float rowMajor[20]);
93 
97 
98  // Runs the child filter in a different working color format than usual (premul in
99  // destination surface's color space), with all inputs and outputs expressed in this format.
100  // Each non-null {tf,gamut,at} parameter overrides that particular aspect of the color format.
102  const skcms_TransferFunction* tf,
103  const skcms_Matrix3x3* gamut,
104  const SkAlphaType* at);
105 
106 private:
107  SkColorFilters() = delete;
108 };
109 
110 #endif
SkFlattenable.h
SkColorFilter
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:25
SkColorFilter::asAColorMode
bool asAColorMode(SkColor *color, SkBlendMode *mode) const
If the filter can be represented by a source color plus Mode, this returns true, and sets (if not NUL...
SkColor4f
SkColorFilters::WithWorkingFormat
static sk_sp< SkColorFilter > WithWorkingFormat(sk_sp< SkColorFilter > child, const skcms_TransferFunction *tf, const skcms_Matrix3x3 *gamut, const SkAlphaType *at)
SkBlendMode
SkBlendMode
Blends are operators that take in two colors (source, destination) and return a new color.
Definition: SkBlendMode.h:38
SkColorFilter::isAlphaUnchanged
bool isAlphaUnchanged() const
SkFlattenable::Type
Type
Definition: SkFlattenable.h:28
SkColorFilters::Compose
static sk_sp< SkColorFilter > Compose(sk_sp< SkColorFilter > outer, sk_sp< SkColorFilter > inner)
Definition: SkColorFilter.h:82
SkColorFilters::HSLAMatrix
static sk_sp< SkColorFilter > HSLAMatrix(const float rowMajor[20])
SkColorFilter::getFlags
uint32_t getFlags() const
sk_sp< SkColorFilter >
SkColorFilter::Flags
Flags
Definition: SkColorFilter.h:44
SkFlattenable::SkFlattenable
SkFlattenable()
Definition: SkFlattenable.h:45
SK_API
#define SK_API
Definition: SkTypes.h:181
SkColorFilters::SRGBToLinearGamma
static sk_sp< SkColorFilter > SRGBToLinearGamma()
SkColorFilter::filterColor4f
SkColor4f filterColor4f(const SkColor4f &srcColor, SkColorSpace *srcCS, SkColorSpace *dstCS) const
Converts the src color (in src colorspace), into the dst colorspace, then applies this filter to it,...
SkFlattenable::kSkColorFilter_Type
@ kSkColorFilter_Type
Definition: SkFlattenable.h:29
SkColorFilters::Blend
static sk_sp< SkColorFilter > Blend(SkColor c, SkBlendMode mode)
SkBlendMode.h
SkColorFilters::LinearToSRGBGamma
static sk_sp< SkColorFilter > LinearToSRGBGamma()
SkColorFilters::Matrix
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
SkColorFilters::Matrix
static sk_sp< SkColorFilter > Matrix(const float rowMajor[20])
SkColorFilters::Lerp
static sk_sp< SkColorFilter > Lerp(float t, sk_sp< SkColorFilter > dst, sk_sp< SkColorFilter > src)
SkColorFilter::GetFlattenableType
static SkFlattenable::Type GetFlattenableType()
Definition: SkColorFilter.h:69
SkColorFilters
Definition: SkColorFilter.h:80
SkColorFilters::HSLAMatrix
static sk_sp< SkColorFilter > HSLAMatrix(const SkColorMatrix &)
SkColorFilter::makeComposed
sk_sp< SkColorFilter > makeComposed(sk_sp< SkColorFilter > inner) const
Construct a colorfilter whose effect is to first apply the inner filter and then apply this filter,...
SkColor
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:35
SkColorFilter::filterColor
SkColor filterColor(SkColor) const
SkColorMatrix
Definition: SkColorMatrix.h:16
SkColorFilter::asColorMode
bool asColorMode(SkColor *color, SkBlendMode *mode) const
SkColorFilter::asAColorMatrix
bool asAColorMatrix(float matrix[20]) const
If the filter can be represented by a 5x4 matrix, this returns true, and sets the matrix appropriatel...
SkColor.h
SkAlphaType
SkAlphaType
Definition: SkImageInfo.h:37
SkFlattenable
Definition: SkFlattenable.h:26
SkColorSpace
Definition: SkColorSpace.h:104