| 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 #include "impeller/geometry/point.h"
10
11 namespace impeller {
12
13 ColorSourceContents::ColorSourceContents() = default;
14
15 ColorSourceContents::~ColorSourceContents() = default;
16
17 void ColorSourceContents::SetGeometry(std::shared_ptr<Geometry> geometry) {
18 geometry_ = std::move(geometry);
19 }
20
21 const std::shared_ptr<Geometry>& ColorSourceContents::GetGeometry() const {
22 return geometry_;
23 }
24
25 void ColorSourceContents::SetOpacityFactor(Scalar alpha) {
26 opacity_ = alpha;
27 }
28
29 Scalar ColorSourceContents::GetOpacityFactor() const {
30 return opacity_ * inherited_opacity_;
31 }
32
33 void ColorSourceContents::SetEffectTransform(Matrix matrix) {
34 inverse_matrix_ = matrix.Invert();
35 }
36
37 const Matrix& ColorSourceContents::GetInverseEffectTransform() const {
38 return inverse_matrix_;
39 }
40
41 bool ColorSourceContents::IsSolidColor() const {
42 return false;
43 }
44
45 std::optional<Rect> ColorSourceContents::GetCoverage(
46 const Entity& entity) const {
47 return geometry_->GetCoverage(entity.GetTransformation());
48 };
49
50 bool ColorSourceContents::CanInheritOpacity(const Entity& entity) const {
51 return true;
52 }
53
54 void ColorSourceContents::SetInheritedOpacity(Scalar opacity) {
55 inherited_opacity_ = opacity;
56 }
57
58 } // namespace impeller
impeller::ColorSourceContents::GetOpacityFactor
Scalar GetOpacityFactor() const
Get the opacity factor for this color source.
Definition: color_source_contents.cc:29
impeller::ColorSourceContents::IsSolidColor
virtual bool IsSolidColor() const
Definition: color_source_contents.cc:41
impeller::ColorSourceContents::SetInheritedOpacity
void SetInheritedOpacity(Scalar opacity) override
Inherit the provided opacity.
Definition: color_source_contents.cc:54
point.h
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::ColorSourceContents::SetGeometry
void SetGeometry(std::shared_ptr< Geometry > geometry)
Set the geometry that this contents will use to render.
Definition: color_source_contents.cc:17
impeller::ColorSourceContents::SetEffectTransform
void SetEffectTransform(Matrix matrix)
Set the effect transform for this color source.
Definition: color_source_contents.cc:33
entity.h
impeller::ColorSourceContents::GetGeometry
const std::shared_ptr< Geometry > & GetGeometry() const
Get the geometry that this contents will use to render.
Definition: color_source_contents.cc:21
impeller::ColorSourceContents::CanInheritOpacity
bool CanInheritOpacity(const Entity &entity) const override
Whether or not this contents can accept the opacity peephole optimization.
Definition: color_source_contents.cc:50
impeller::ColorSourceContents::ColorSourceContents
ColorSourceContents()
impeller::Entity::GetTransformation
const Matrix & GetTransformation() const
Definition: entity.cc:49
matrix.h
impeller::Entity
Definition: entity.h:21
impeller::ColorSourceContents::~ColorSourceContents
~ColorSourceContents() override
color_source_contents.h
impeller::Matrix::Invert
Matrix Invert() const
Definition: matrix.cc:97
impeller::ColorSourceContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the screen space bounding rectangle that this contents affects.
Definition: color_source_contents.cc:45
impeller::ColorSourceContents::SetOpacityFactor
void SetOpacityFactor(Scalar opacity)
Set the opacity factor for this color source.
Definition: color_source_contents.cc:25
impeller
Definition: aiks_context.cc:10
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:36
impeller::ColorSourceContents::GetInverseEffectTransform
const Matrix & GetInverseEffectTransform() const
Set the inverted effect transform for this color source.
Definition: color_source_contents.cc:37