| 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
8 #include "impeller/entity/contents/filters/filter_contents.h"
9
10 namespace impeller {
11
12 class ColorFilterContents : public FilterContents {
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
35 ColorFilterContents();
36
37 ~ColorFilterContents() override;
38
39 void SetAbsorbOpacity(AbsorbOpacity absorb_opacity);
40
41 AbsorbOpacity GetAbsorbOpacity() const;
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
61 ColorFilterContents(const ColorFilterContents&) = delete;
62
63 ColorFilterContents& operator=(const ColorFilterContents&) = delete;
64 };
65
66 } // namespace impeller
67
68 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_FILTERS_COLOR_FILTER_CONTENTS_H_
impeller::ColorFilterContents
Definition: color_filter_contents.h:12
impeller::ColorFilterContents::ColorFilterContents
ColorFilterContents()
impeller::ColorFilterContents::SetInheritedOpacity
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
Definition: color_filter_contents.cc:102
impeller::ColorFilterContents::GetAlpha
std::optional< Scalar > GetAlpha() const
Definition: color_filter_contents.cc:98
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
AbsorbOpacity
Definition: color_filter_contents.h:14
impeller::ColorFilterContents::AbsorbOpacity::kYes
@ kYes
impeller::ColorFilterContents::AbsorbOpacity::kNo
@ kNo
impeller::ColorFilterContents::MakeSrgbToLinearFilter
static std::shared_ptr< ColorFilterContents > MakeSrgbToLinearFilter(FilterInput::Ref input)
Definition: color_filter_contents.cc:75
impeller::ColorFilterContents::SetAbsorbOpacity
void SetAbsorbOpacity(AbsorbOpacity absorb_opacity)
Definition: color_filter_contents.cc:85
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:106
impeller::ColorFilterContents::GetAbsorbOpacity
AbsorbOpacity GetAbsorbOpacity() const
Definition: color_filter_contents.cc:89
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::~ColorFilterContents
~ColorFilterContents() override
impeller::ColorFilterContents::MakeLinearToSrgbFilter
static std::shared_ptr< ColorFilterContents > MakeLinearToSrgbFilter(FilterInput::Ref input)
Definition: color_filter_contents.cc:68
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::FilterContents
Definition: filter_contents.h:24
impeller::FilterInput::Ref
std::shared_ptr< FilterInput > Ref
Definition: filter_input.h:32
impeller::FilterInput::Vector
std::vector< FilterInput::Ref > Vector
Definition: filter_input.h:33
filter_contents.h
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::ColorMatrix
Definition: color.h:117
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::TRect< Scalar >