| Flutter Impeller |

contents_filter_input.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/filters/inputs/contents_filter_input.h"
6
7 #include <optional>
8 #include <utility>
9
10 #include "impeller/base/strings.h"
11
12 namespace impeller {
13
14 ContentsFilterInput::ContentsFilterInput(std::shared_ptr<Contents> contents,
15 bool msaa_enabled)
16 : contents_(std::move(contents)), msaa_enabled_(msaa_enabled) {}
17
18 ContentsFilterInput::~ContentsFilterInput() = default;
19
20 FilterInput::Variant ContentsFilterInput::GetInput() const {
21 return contents_;
22 }
23
24 std::optional<Snapshot> ContentsFilterInput::GetSnapshot(
25 const std::string& label,
26 const ContentContext& renderer,
27 const Entity& entity,
28 std::optional<Rect> coverage_limit,
29 int32_t mip_count) const {
30 if (!coverage_limit.has_value() && entity.GetContents()) {
31 coverage_limit = entity.GetContents()->GetCoverageHint();
32 }
33 if (!snapshot_.has_value()) {
34 snapshot_ = contents_->RenderToSnapshot(
35 renderer, // renderer
36 entity, // entity
37 coverage_limit, // coverage_limit
38 std::nullopt, // sampler_descriptor
39 msaa_enabled_, // msaa_enabled
40 /*mip_count=*/mip_count,
41 SPrintF("Contents to %s Filter Snapshot", label.c_str())); // label
42 }
43 return snapshot_;
44 }
45
46 std::optional<Rect> ContentsFilterInput::GetCoverage(
47 const Entity& entity) const {
48 return contents_->GetCoverage(entity);
49 }
50
51 void ContentsFilterInput::PopulateGlyphAtlas(
52 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
53 Scalar scale) {
54 contents_->PopulateGlyphAtlas(lazy_glyph_atlas, scale);
55 }
56
57 } // namespace impeller
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::ContentsFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: contents_filter_input.cc:46
impeller::ContentsFilterInput::GetSnapshot
std::optional< Snapshot > GetSnapshot(const std::string &label, const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit, int32_t mip_count) const override
Definition: contents_filter_input.cc:24
impeller::Entity
Definition: entity.h:20
impeller::ContentsFilterInput::GetInput
Variant GetInput() const override
Definition: contents_filter_input.cc:20
impeller::SPrintF
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
impeller::Entity::GetContents
const std::shared_ptr< Contents > & GetContents() const
Definition: entity.cc:94
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
strings.h
impeller::ContentsFilterInput::~ContentsFilterInput
~ContentsFilterInput() override
std
Definition: comparable.h:95
scale
const Scalar scale
Definition: stroke_path_geometry.cc:308
impeller::ContentsFilterInput::PopulateGlyphAtlas
void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale) override
Definition: contents_filter_input.cc:51
contents_filter_input.h
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ContentContext
Definition: content_context.h:366