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 
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 
19 
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) const {
29  if (!coverage_limit.has_value() && entity.GetContents()) {
30  coverage_limit = entity.GetContents()->GetCoverageHint();
31  }
32  if (!snapshot_.has_value()) {
33  snapshot_ = contents_->RenderToSnapshot(
34  renderer, // renderer
35  entity, // entity
36  coverage_limit, // coverage_limit
37  std::nullopt, // sampler_descriptor
38  msaa_enabled_, // msaa_enabled
39  SPrintF("Contents to %s Filter Snapshot", label.c_str())); // label
40  }
41  return snapshot_;
42 }
43 
45  const Entity& entity) const {
46  return contents_->GetCoverage(entity);
47 }
48 
50  const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
51  Scalar scale) {
52  contents_->PopulateGlyphAtlas(lazy_glyph_atlas, scale);
53 }
54 
55 } // namespace impeller
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::ContentsFilterInput::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Definition: contents_filter_input.cc:44
impeller::ContentsFilterInput::GetSnapshot
std::optional< Snapshot > GetSnapshot(const std::string &label, const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit) const override
Definition: contents_filter_input.cc:24
impeller::Entity
Definition: entity.h:21
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:81
impeller::FilterInput::Variant
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
Definition: filter_input.h:36
strings.h
impeller::ContentsFilterInput::~ContentsFilterInput
~ContentsFilterInput() override
std
Definition: comparable.h:98
impeller::ContentsFilterInput::PopulateGlyphAtlas
void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale) override
Definition: contents_filter_input.cc:49
contents_filter_input.h
impeller
Definition: aiks_context.cc:10
impeller::ContentContext
Definition: content_context.h:344