| Flutter Impeller |

color_source_contents.cc
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 #include "impeller/entity/contents/color_source_contents.h"
6
7 #include "impeller/entity/entity.h"
8 #include "impeller/geometry/matrix.h"
9
10 namespace impeller {
11
12 ColorSourceContents::ColorSourceContents() = default;
13
14 ColorSourceContents::~ColorSourceContents() = default;
15
16 void ColorSourceContents::SetGeometry(const Geometry* geometry) {
17 geometry_ = geometry;
18 }
19
20 const Geometry* ColorSourceContents::GetGeometry() const {
21 return geometry_;
22 }
23
24 void ColorSourceContents::SetOpacityFactor(Scalar alpha) {
25 opacity_ = alpha;
26 }
27
28 Scalar ColorSourceContents::GetOpacityFactor() const {
29 return opacity_ * inherited_opacity_;
30 }
31
32 void ColorSourceContents::SetEffectTransform(Matrix matrix) {
33 inverse_matrix_ = matrix.Invert();
34 }
35
36 const Matrix& ColorSourceContents::GetInverseEffectTransform() const {
37 return inverse_matrix_;
38 }
39
40 bool ColorSourceContents::IsSolidColor() const {
41 return false;
42 }
43
44 std::optional<Rect> ColorSourceContents::GetCoverage(
45 const Entity& entity) const {
46 return geometry_->GetCoverage(entity.GetTransform());
47 };
48
49 void ColorSourceContents::SetInheritedOpacity(Scalar opacity) {
50 inherited_opacity_ = opacity;
51 }
52
53 bool ColorSourceContents::AppliesAlphaForStrokeCoverage(
54 const Matrix& transform) const {
55 return GetGeometry() && GetGeometry()->ComputeAlphaCoverage(transform) < 1.0;
56 }
57
58 } // namespace impeller
impeller::ColorSourceContents::SetInheritedOpacity
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
Definition: color_source_contents.cc:49
impeller::ColorSourceContents::GetGeometry
const Geometry * GetGeometry() const
Get the geometry that this contents will use to render.
Definition: color_source_contents.cc:20
impeller::ColorSourceContents::GetOpacityFactor
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
Definition: color_source_contents.cc:28
impeller::ColorSourceContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
Definition: color_source_contents.cc:44
impeller::ColorSourceContents::AppliesAlphaForStrokeCoverage
bool AppliesAlphaForStrokeCoverage(const Matrix &transform) const
Whether the entity should be treated as non-opaque due to stroke geometry requiring alpha for coverag...
Definition: color_source_contents.cc:53
impeller::ColorSourceContents::ColorSourceContents
ColorSourceContents()
impeller::ColorSourceContents::~ColorSourceContents
~ColorSourceContents() override
impeller::ColorSourceContents::SetEffectTransform
void SetEffectTransform(Matrix matrix)
Set the effect transform for this color source.
Definition: color_source_contents.cc:32
impeller::ColorSourceContents::GetInverseEffectTransform
const Matrix & GetInverseEffectTransform() const
Set the inverted effect transform for this color source.
Definition: color_source_contents.cc:36
impeller::ColorSourceContents::IsSolidColor
virtual bool IsSolidColor() const
Definition: color_source_contents.cc:40
impeller::ColorSourceContents::SetOpacityFactor
void SetOpacityFactor(Scalar opacity)
Set the opacity factor for this color source.
Definition: color_source_contents.cc:24
impeller::ColorSourceContents::SetGeometry
void SetGeometry(const Geometry *geometry)
Set the geometry that this contents will use to render.
Definition: color_source_contents.cc:16
impeller::Entity
Definition: entity.h:26
impeller::Entity::GetTransform
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition: entity.cc:44
impeller::Geometry
Definition: geometry.h:50
impeller::Geometry::ComputeAlphaCoverage
virtual Scalar ComputeAlphaCoverage(const Matrix &transform) const
Definition: geometry.h:125
impeller::Geometry::GetCoverage
virtual std::optional< Rect > GetCoverage(const Matrix &transform) const =0
color_source_contents.h
entity.h
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
matrix.h
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:97