Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
10namespace 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,
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 // |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_
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...
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
std::vector< FilterInput::Ref > Vector
float Scalar
Definition scalar.h:18
BlendMode
Definition color.h:59
A 4x4 matrix using column-major storage.
Definition matrix.h:37