Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shader.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_LIB_GPU_SHADER_H_
6#define FLUTTER_LIB_GPU_SHADER_H_
7
8#include <algorithm>
9#include <memory>
10#include <string>
11
12#include "flutter/lib/gpu/context.h"
13#include "flutter/lib/ui/dart_wrapper.h"
14#include "fml/memory/ref_ptr.h"
18
19namespace flutter {
20namespace gpu {
21
22/// An immutable collection of shaders loaded from a shader bundle asset.
23class Shader : public RefCountedDartWrappable<Shader> {
24 DEFINE_WRAPPERTYPEINFO();
26
27 public:
36
37 ~Shader() override;
38
40 std::string entrypoint,
42 std::shared_ptr<fml::Mapping> code_mapping,
43 std::shared_ptr<impeller::VertexDescriptor> vertex_desc,
44 std::unordered_map<std::string, UniformBinding> uniform_structs,
45 std::unordered_map<std::string, impeller::SampledImageSlot>
46 uniform_textures);
47
48 std::shared_ptr<const impeller::ShaderFunction> GetFunctionFromLibrary(
50
51 bool IsRegistered(Context& context);
52
53 bool RegisterSync(Context& context);
54
55 std::shared_ptr<impeller::VertexDescriptor> GetVertexDescriptor() const;
56
58
59 const Shader::UniformBinding* GetUniformStruct(const std::string& name) const;
60
62 const std::string& name) const;
63
64 private:
65 Shader();
66
67 std::string entrypoint_;
69 std::shared_ptr<fml::Mapping> code_mapping_;
70 std::shared_ptr<impeller::VertexDescriptor> vertex_desc_;
71 std::unordered_map<std::string, UniformBinding> uniform_structs_;
72 std::unordered_map<std::string, impeller::SampledImageSlot> uniform_textures_;
73
75};
76
77} // namespace gpu
78} // namespace flutter
79
80//----------------------------------------------------------------------------
81/// Exports
82///
83
84extern "C" {
85
88 flutter::gpu::Shader* wrapper,
89 Dart_Handle struct_name_handle);
90
93 flutter::gpu::Shader* wrapper,
94 Dart_Handle struct_name_handle,
95 Dart_Handle member_name_handle);
96
97} // extern "C"
98
99#endif // FLUTTER_LIB_GPU_SHADER_H_
An immutable collection of shaders loaded from a shader bundle asset.
Definition shader.h:23
const Shader::UniformBinding * GetUniformStruct(const std::string &name) const
Definition shader.cc:95
impeller::ShaderStage GetShaderStage() const
Definition shader.cc:91
bool IsRegistered(Context &context)
Definition shader.cc:61
bool RegisterSync(Context &context)
Definition shader.cc:66
std::shared_ptr< impeller::VertexDescriptor > GetVertexDescriptor() const
Definition shader.cc:86
const impeller::SampledImageSlot * GetUniformTexture(const std::string &name) const
Definition shader.cc:104
static fml::RefPtr< Shader > Make(std::string entrypoint, impeller::ShaderStage stage, std::shared_ptr< fml::Mapping > code_mapping, std::shared_ptr< impeller::VertexDescriptor > vertex_desc, std::unordered_map< std::string, UniformBinding > uniform_structs, std::unordered_map< std::string, impeller::SampledImageSlot > uniform_textures)
Definition shader.cc:38
std::shared_ptr< const impeller::ShaderFunction > GetFunctionFromLibrary(impeller::ShaderLibrary &library)
Definition shader.cc:56
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
#define FLUTTER_GPU_EXPORT
Definition export.h:13
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Shader_GetUniformMemberOffset(flutter::gpu::Shader *wrapper, Dart_Handle struct_name_handle, Dart_Handle member_name_handle)
Definition shader.cc:132
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Shader_GetUniformStructSize(flutter::gpu::Shader *wrapper, Dart_Handle struct_name_handle)
Definition shader.cc:120
DEF_SWITCHES_START aot vmservice shared library name
Definition switches.h:32
#define FML_FRIEND_MAKE_REF_COUNTED(T)
impeller::ShaderMetadata metadata
Definition shader.h:30
impeller::ShaderUniformSlot slot
Definition shader.h:29
const impeller::ShaderStructMemberMetadata * GetMemberMetadata(const std::string &name) const
Definition shader.cc:20
Metadata required to bind a combined texture and sampler.
Metadata required to bind a buffer.