| Flutter Impeller |

runtime_effect_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_RUNTIME_EFFECT_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_RUNTIME_EFFECT_CONTENTS_H_
7
8 #include <memory>
9 #include <vector>
10
11 #include "impeller/core/host_buffer.h"
12 #include "impeller/core/sampler_descriptor.h"
13 #include "impeller/entity/contents/color_source_contents.h"
14 #include "impeller/runtime_stage/runtime_stage.h"
15
16 namespace impeller {
17
18 class RuntimeEffectContents final : public ColorSourceContents {
19 public:
20 struct TextureInput {
21 SamplerDescriptor sampler_descriptor;
22 std::shared_ptr<Texture> texture;
23 };
24
25 void SetRuntimeStage(std::shared_ptr<RuntimeStage> runtime_stage);
26
27 void SetUniformData(std::shared_ptr<std::vector<uint8_t>> uniform_data);
28
29 void SetTextureInputs(std::vector<TextureInput> texture_inputs);
30
31 // |Contents|
32 bool Render(const ContentContext& renderer,
33 const Entity& entity,
34 RenderPass& pass) const override;
35
36 /// Load the runtime effect and ensure a default PSO is initialized.
37 bool BootstrapShader(const ContentContext& renderer) const;
38
39 // Visible for testing
40 static BufferView EmplaceVulkanUniform(
41 const std::shared_ptr<const std::vector<uint8_t>>& input_data,
42 HostBuffer& host_buffer,
43 const RuntimeUniformDescription& uniform,
44 size_t minimum_uniform_alignment);
45
46 private:
47 bool RegisterShader(const ContentContext& renderer) const;
48
49 // If async is true, this will always return nullptr as pipeline creation
50 // is not blocked on.
51 std::shared_ptr<Pipeline<PipelineDescriptor>> CreatePipeline(
52 const ContentContext& renderer,
53 ContentContextOptions options,
54 bool async) const;
55
56 std::shared_ptr<RuntimeStage> runtime_stage_;
57 std::shared_ptr<std::vector<uint8_t>> uniform_data_;
58 std::vector<TextureInput> texture_inputs_;
59 };
60
61 } // namespace impeller
62
63 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_RUNTIME_EFFECT_CONTENTS_H_
impeller::ColorSourceContents
Definition: color_source_contents.h:38
impeller::ContentContext
Definition: content_context.h:122
impeller::Entity
Definition: entity.h:26
impeller::HostBuffer
Definition: host_buffer.h:26
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::RuntimeEffectContents
Definition: runtime_effect_contents.h:18
impeller::RuntimeEffectContents::EmplaceVulkanUniform
static BufferView EmplaceVulkanUniform(const std::shared_ptr< const std::vector< uint8_t >> &input_data, HostBuffer &host_buffer, const RuntimeUniformDescription &uniform, size_t minimum_uniform_alignment)
Definition: runtime_effect_contents.cc:33
impeller::RuntimeEffectContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: runtime_effect_contents.cc:219
impeller::RuntimeEffectContents::BootstrapShader
bool BootstrapShader(const ContentContext &renderer) const
Load the runtime effect and ensure a default PSO is initialized.
Definition: runtime_effect_contents.cc:100
impeller::RuntimeEffectContents::SetRuntimeStage
void SetRuntimeStage(std::shared_ptr< RuntimeStage > runtime_stage)
Definition: runtime_effect_contents.cc:58
impeller::RuntimeEffectContents::SetTextureInputs
void SetTextureInputs(std::vector< TextureInput > texture_inputs)
Definition: runtime_effect_contents.cc:68
impeller::RuntimeEffectContents::SetUniformData
void SetUniformData(std::shared_ptr< std::vector< uint8_t >> uniform_data)
Definition: runtime_effect_contents.cc:63
color_source_contents.h
host_buffer.h
impeller
Definition: allocation.cc:12
runtime_stage.h
sampler_descriptor.h
impeller::BufferView
Definition: buffer_view.h:19
impeller::ContentContextOptions
Definition: content_context.h:40
impeller::RuntimeEffectContents::TextureInput
Definition: runtime_effect_contents.h:20
impeller::RuntimeEffectContents::TextureInput::texture
std::shared_ptr< Texture > texture
Definition: runtime_effect_contents.h:22
impeller::RuntimeEffectContents::TextureInput::sampler_descriptor
SamplerDescriptor sampler_descriptor
Definition: runtime_effect_contents.h:21
impeller::RuntimeUniformDescription
Definition: runtime_types.h:41
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14