Flutter Impeller
color_filter_contents.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_COLOR_FILTER_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_COLOR_FILTER_CONTENTS_H_
7 
9 
10 namespace impeller {
11 
13  public:
14  enum class AbsorbOpacity {
15  kYes,
16  kNo,
17  };
18 
19  /// @brief the [inputs] are expected to be in the order of dst, src.
20  static std::shared_ptr<ColorFilterContents> MakeBlend(
21  BlendMode blend_mode,
22  FilterInput::Vector inputs,
23  std::optional<Color> foreground_color = std::nullopt);
24 
25  static std::shared_ptr<ColorFilterContents> MakeColorMatrix(
26  FilterInput::Ref input,
27  const ColorMatrix& color_matrix);
28 
29  static std::shared_ptr<ColorFilterContents> MakeLinearToSrgbFilter(
30  FilterInput::Ref input);
31 
32  static std::shared_ptr<ColorFilterContents> MakeSrgbToLinearFilter(
33  FilterInput::Ref input);
34 
36 
38 
39  void SetAbsorbOpacity(AbsorbOpacity absorb_opacity);
40 
42 
43  /// @brief Sets an alpha that is applied to the final blended result.
44  void SetAlpha(Scalar alpha);
45 
46  std::optional<Scalar> GetAlpha() const;
47 
48  // |Contents|
49  void SetInheritedOpacity(Scalar opacity) override;
50 
51  // |FilterContents|
52  std::optional<Rect> GetFilterSourceCoverage(
53  const Matrix& effect_transform,
54  const Rect& output_limit) const override;
55 
56  private:
57  AbsorbOpacity absorb_opacity_ = AbsorbOpacity::kNo;
58  std::optional<Scalar> alpha_;
59  Scalar inherited_opacity_ = 1.0;
60 
62 
63  ColorFilterContents& operator=(const ColorFilterContents&) = delete;
64 };
65 
66 } // namespace impeller
67 
68 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_COLOR_FILTER_CONTENTS_H_
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
std::optional< Scalar > GetAlpha() const
static std::shared_ptr< ColorFilterContents > MakeColorMatrix(FilterInput::Ref input, const ColorMatrix &color_matrix)
static std::shared_ptr< ColorFilterContents > MakeSrgbToLinearFilter(FilterInput::Ref input)
void SetAbsorbOpacity(AbsorbOpacity absorb_opacity)
std::optional< Rect > GetFilterSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const override
Internal utility method for |GetSourceCoverage| that computes the inverse effect of this transform on...
AbsorbOpacity GetAbsorbOpacity() const
void SetAlpha(Scalar alpha)
Sets an alpha that is applied to the final blended result.
static std::shared_ptr< ColorFilterContents > MakeLinearToSrgbFilter(FilterInput::Ref input)
static std::shared_ptr< ColorFilterContents > MakeBlend(BlendMode blend_mode, FilterInput::Vector inputs, std::optional< Color > foreground_color=std::nullopt)
the [inputs] are expected to be in the order of dst, src.
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
float Scalar
Definition: scalar.h:19
BlendMode
Definition: color.h:58
A 4x4 matrix using column-major storage.
Definition: matrix.h:37