Flutter Engine
The Flutter Engine
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
6
7#include <optional>
8#include <utility>
9
11
12namespace impeller {
13
14ContentsFilterInput::ContentsFilterInput(std::shared_ptr<Contents> contents,
15 bool msaa_enabled)
16 : contents_(std::move(contents)), msaa_enabled_(msaa_enabled) {}
17
18ContentsFilterInput::~ContentsFilterInput() = default;
19
20FilterInput::Variant ContentsFilterInput::GetInput() const {
21 return contents_;
22}
23
24std::optional<Snapshot> ContentsFilterInput::GetSnapshot(
25 const std::string& label,
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
46std::optional<Rect> ContentsFilterInput::GetCoverage(
47 const Entity& entity) const {
48 return contents_->GetCoverage(entity);
49}
50
51void 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
const std::shared_ptr< Contents > & GetContents() const
Definition: entity.cc:94
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:37
float Scalar
Definition: scalar.h:18
std::string SPrintF(const char *format,...)
Definition: strings.cc:12
Definition: ref_ptr.h:256
const Scalar scale