| Flutter Impeller |

paint_pass_delegate.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/aiks/paint_pass_delegate.h"
6
7 #include "impeller/core/formats.h"
8 #include "impeller/entity/contents/contents.h"
9 #include "impeller/entity/contents/texture_contents.h"
10 #include "impeller/entity/entity_pass.h"
11 #include "impeller/geometry/color.h"
12
13 namespace impeller {
14
15 /// PaintPassDelegate
16 /// ----------------------------------------------
17
18 PaintPassDelegate::PaintPassDelegate(Paint paint) : paint_(std::move(paint)) {}
19
20 // |EntityPassDelgate|
21 PaintPassDelegate::~PaintPassDelegate() = default;
22
23 // |EntityPassDelgate|
24 bool PaintPassDelegate::CanElide() {
25 return paint_.blend_mode == BlendMode::kDestination;
26 }
27
28 // |EntityPassDelgate|
29 bool PaintPassDelegate::CanCollapseIntoParentPass(EntityPass* entity_pass) {
30 return false;
31 }
32
33 // |EntityPassDelgate|
34 std::shared_ptr<Contents> PaintPassDelegate::CreateContentsForSubpassTarget(
35 std::shared_ptr<Texture> target,
36 const Matrix& effect_transform) {
37 auto contents = TextureContents::MakeRect(Rect::MakeSize(target->GetSize()));
38 contents->SetTexture(target);
39 contents->SetLabel("Subpass");
40 contents->SetSourceRect(Rect::MakeSize(target->GetSize()));
41 contents->SetOpacity(paint_.color.alpha);
42 contents->SetDeferApplyingOpacity(true);
43
44 return paint_.WithFiltersForSubpassTarget(std::move(contents),
45 effect_transform);
46 }
47
48 // |EntityPassDelgate|
49 std::shared_ptr<FilterContents> PaintPassDelegate::WithImageFilter(
50 const FilterInput::Variant& input,
51 const Matrix& effect_transform) const {
52 return paint_.WithImageFilter(
53 input, effect_transform,
54 Entity::RenderingMode::kSubpassPrependSnapshotTransform);
55 }
56
57 } // namespace impeller
impeller::PaintPassDelegate::CreateContentsForSubpassTarget
std::shared_ptr< Contents > CreateContentsForSubpassTarget(std::shared_ptr< Texture > target, const Matrix &effect_transform) override
Definition: paint_pass_delegate.cc:34
contents.h
texture_contents.h
impeller::Paint
Definition: paint.h:23
impeller::Paint::color
Color color
Definition: paint.h:68
paint_pass_delegate.h
impeller::BlendMode::kDestination
@ kDestination
formats.h
impeller::Color::alpha
Scalar alpha
Definition: color.h:143
impeller::EntityPass
Definition: entity_pass.h:43
impeller::PaintPassDelegate::CanCollapseIntoParentPass
bool CanCollapseIntoParentPass(EntityPass *entity_pass) override
Whether or not this entity pass can be collapsed into the parent. If true, this method may modify the...
Definition: paint_pass_delegate.cc:29
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
entity_pass.h
impeller::Paint::WithImageFilter
std::shared_ptr< FilterContents > WithImageFilter(const FilterInput::Variant &input, const Matrix &effect_transform, Entity::RenderingMode rendering_mode) const
Definition: paint.cc:90
impeller::Entity::RenderingMode::kSubpassPrependSnapshotTransform
@ kSubpassPrependSnapshotTransform
impeller::TRect< Scalar >::MakeSize
constexpr static TRect MakeSize(const TSize< U > &size)
Definition: rect.h:146
std
Definition: comparable.h:95
impeller::PaintPassDelegate::PaintPassDelegate
PaintPassDelegate(Paint paint)
Definition: paint_pass_delegate.cc:18
impeller::PaintPassDelegate::WithImageFilter
std::shared_ptr< FilterContents > WithImageFilter(const FilterInput::Variant &input, const Matrix &effect_transform) const override
Definition: paint_pass_delegate.cc:49
paint
const Paint & paint
Definition: color_source.cc:38
impeller::PaintPassDelegate::~PaintPassDelegate
~PaintPassDelegate() override
color.h
impeller::PaintPassDelegate::CanElide
bool CanElide() override
Definition: paint_pass_delegate.cc:24
impeller::TextureContents::MakeRect
static std::shared_ptr< TextureContents > MakeRect(Rect destination)
A common case factory that marks the texture contents as having a destination rectangle....
Definition: texture_contents.cc:27
impeller
Definition: aiks_blend_unittests.cc:18
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::Paint::WithFiltersForSubpassTarget
std::shared_ptr< Contents > WithFiltersForSubpassTarget(std::shared_ptr< Contents > input, const Matrix &effect_transform=Matrix()) const
Wrap this paint's configured filters to the given contents of subpass target.
Definition: paint.cc:67
impeller::Paint::blend_mode
BlendMode blend_mode
Definition: paint.h:76