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 
37  ~ColorFilterContents() override;
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  // |FilterContents|
49  std::optional<Rect> GetFilterSourceCoverage(
50  const Matrix& effect_transform,
51  const Rect& output_limit) const override;
52 
53  private:
54  AbsorbOpacity absorb_opacity_ = AbsorbOpacity::kNo;
55  std::optional<Scalar> alpha_;
56 
58 
59  ColorFilterContents& operator=(const ColorFilterContents&) = delete;
60 };
61 
62 } // namespace impeller
63 
64 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_COLOR_FILTER_CONTENTS_H_
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::ColorFilterContents::GetFilterSourceCoverage
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...
Definition: color_filter_contents.cc:102
impeller::ColorFilterContents::ColorFilterContents
ColorFilterContents()
impeller::ColorFilterContents
Definition: color_filter_contents.h:12
impeller::BlendMode
BlendMode
Definition: color.h:59
impeller::ColorFilterContents::SetAbsorbOpacity
void SetAbsorbOpacity(AbsorbOpacity absorb_opacity)
Definition: color_filter_contents.cc:85
impeller::FilterInput::Ref
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
impeller::ColorFilterContents::AbsorbOpacity::kNo
@ kNo
impeller::ColorFilterContents::~ColorFilterContents
~ColorFilterContents() override
filter_contents.h
impeller::ColorFilterContents::GetAbsorbOpacity
AbsorbOpacity GetAbsorbOpacity() const
Definition: color_filter_contents.cc:89
impeller::ColorFilterContents::MakeSrgbToLinearFilter
static std::shared_ptr< ColorFilterContents > MakeSrgbToLinearFilter(FilterInput::Ref input)
Definition: color_filter_contents.cc:75
impeller::ColorFilterContents::SetAlpha
void SetAlpha(Scalar alpha)
Sets an alpha that is applied to the final blended result.
Definition: color_filter_contents.cc:94
impeller::ColorFilterContents::MakeLinearToSrgbFilter
static std::shared_ptr< ColorFilterContents > MakeLinearToSrgbFilter(FilterInput::Ref input)
Definition: color_filter_contents.cc:68
impeller::ColorFilterContents::MakeColorMatrix
static std::shared_ptr< ColorFilterContents > MakeColorMatrix(FilterInput::Ref input, const ColorMatrix &color_matrix)
Definition: color_filter_contents.cc:58
impeller::ColorFilterContents::AbsorbOpacity::kYes
@ kYes
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
impeller::ColorFilterContents::GetAlpha
std::optional< Scalar > GetAlpha() const
Definition: color_filter_contents.cc:98
impeller::ColorMatrix
Definition: color.h:117
impeller::ColorFilterContents::MakeBlend
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.
Definition: color_filter_contents.cc:17
impeller::ColorFilterContents::AbsorbOpacity
AbsorbOpacity
Definition: color_filter_contents.h:14
impeller
Definition: aiks_blur_unittests.cc:20
impeller::TRect
Definition: rect.h:122
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::FilterContents
Definition: filter_contents.h:22