Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
tiled_texture_contents.h
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#ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_TILED_TEXTURE_CONTENTS_H_
6#define FLUTTER_IMPELLER_ENTITY_CONTENTS_TILED_TEXTURE_CONTENTS_H_
7
8#include <functional>
9#include <memory>
10#include <vector>
11
18
19namespace impeller {
20
22 public:
24
26
28 std::function<std::shared_ptr<ColorFilterContents>(FilterInput::Ref)>;
29
30 // |Contents|
31 bool IsOpaque() const override;
32
33 // |Contents|
34 bool Render(const ContentContext& renderer,
35 const Entity& entity,
36 RenderPass& pass) const override;
37
38 void SetTexture(std::shared_ptr<Texture> texture);
39
40 void SetTileModes(Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode);
41
43
44 /// @brief Set a color filter to apply directly to this tiled texture
45 /// @param color_filter
46 ///
47 /// When applying a color filter to a tiled texture, we can reduce the
48 /// size and number of the subpasses required and the shader workload by
49 /// applying the filter to the untiled image and absorbing the opacity before
50 /// tiling it into the final location.
51 ///
52 /// This may not be a performance improvement if the image is tiled into a
53 /// much smaller size that its original texture size.
55
56 // |Contents|
57 std::optional<Snapshot> RenderToSnapshot(
58 const ContentContext& renderer,
59 const Entity& entity,
60 std::optional<Rect> coverage_limit = std::nullopt,
61 const std::optional<SamplerDescriptor>& sampler_descriptor = std::nullopt,
62 bool msaa_enabled = true,
63 int32_t mip_count = 1,
64 const std::string& label = "Tiled Texture Snapshot") const override;
65
66 private:
67 std::shared_ptr<Texture> CreateFilterTexture(
68 const ContentContext& renderer) const;
69
70 SamplerDescriptor CreateSamplerDescriptor(
71 const Capabilities& capabilities) const;
72
73 bool UsesEmulatedTileMode(const Capabilities& capabilities) const;
74
75 std::shared_ptr<Texture> texture_;
76 SamplerDescriptor sampler_descriptor_ = {};
79 ColorFilterProc color_filter_ = nullptr;
80
82
83 TiledTextureContents& operator=(const TiledTextureContents&) = delete;
84};
85
86} // namespace impeller
87
88#endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_TILED_TEXTURE_CONTENTS_H_
static sk_sp< SkImage > color_filter(const SkImage *image, SkColorFilter *colorFilter)
std::shared_ptr< FilterInput > Ref
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:33
void SetSamplerDescriptor(SamplerDescriptor desc)
bool IsOpaque() const override
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
std::optional< Snapshot > RenderToSnapshot(const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit=std::nullopt, const std::optional< SamplerDescriptor > &sampler_descriptor=std::nullopt, bool msaa_enabled=true, int32_t mip_count=1, const std::string &label="Tiled Texture Snapshot") const override
Render this contents to a snapshot, respecting the entity's transform, path, clip depth,...
void SetColorFilter(ColorFilterProc color_filter)
Set a color filter to apply directly to this tiled texture.
void SetTileModes(Entity::TileMode x_tile_mode, Entity::TileMode y_tile_mode)
std::function< std::shared_ptr< ColorFilterContents >(FilterInput::Ref)> ColorFilterProc
void SetTexture(std::shared_ptr< Texture > texture)
FlTexture * texture