Flutter Engine
The Flutter Engine
Namespaces | Functions
shader_library.cc File Reference
#include "flutter/lib/gpu/shader_library.h"
#include <optional>
#include <utility>
#include "flutter/assets/asset_manager.h"
#include "flutter/lib/gpu/fixtures.h"
#include "flutter/lib/gpu/shader.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "flutter/lib/ui/window/platform_configuration.h"
#include "fml/mapping.h"
#include "fml/memory/ref_ptr.h"
#include "impeller/base/validation.h"
#include "impeller/core/shader_types.h"
#include "impeller/renderer/vertex_descriptor.h"
#include "impeller/shader_bundle/shader_bundle_flatbuffers.h"
#include "lib/gpu/context.h"

Go to the source code of this file.

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

 flutter::gpu::IMPLEMENT_WRAPPERTYPEINFO (flutter_gpu, ShaderLibrary)
 
static impeller::ShaderStage flutter::gpu::ToShaderStage (impeller::fb::shaderbundle::ShaderStage stage)
 
static impeller::ShaderType flutter::gpu::FromInputType (impeller::fb::shaderbundle::InputDataType input_type)
 
static impeller::ShaderType flutter::gpu::FromUniformType (impeller::fb::shaderbundle::UniformDataType uniform_type)
 
static size_t flutter::gpu::SizeOfInputType (impeller::fb::shaderbundle::InputDataType input_type)
 
static const impeller::fb::shaderbundle::BackendShader * flutter::gpu::GetShaderBackend (impeller::Context::BackendType backend_type, const impeller::fb::shaderbundle::Shader *shader)
 
Dart_Handle InternalFlutterGpu_ShaderLibrary_InitializeWithAsset (Dart_Handle wrapper, Dart_Handle asset_name)
 
Dart_Handle InternalFlutterGpu_ShaderLibrary_GetShader (flutter::gpu::ShaderLibrary *wrapper, Dart_Handle shader_name, Dart_Handle shader_wrapper)
 

Function Documentation

◆ InternalFlutterGpu_ShaderLibrary_GetShader()

Dart_Handle InternalFlutterGpu_ShaderLibrary_GetShader ( flutter::gpu::ShaderLibrary wrapper,
Dart_Handle  shader_name,
Dart_Handle  shader_wrapper 
)

Definition at line 376 of file shader_library.cc.

379 {
380 FML_DCHECK(Dart_IsString(shader_name));
381 auto shader =
382 wrapper->GetShader(tonic::StdStringFromDart(shader_name), shader_wrapper);
383 if (!shader) {
384 return Dart_Null();
385 }
386 return tonic::ToDart(shader.get());
387}
fml::RefPtr< Shader > GetShader(const std::string &shader_name, Dart_Handle shader_wrapper) const
DART_EXPORT Dart_Handle Dart_Null(void)
DART_EXPORT bool Dart_IsString(Dart_Handle object)
#define FML_DCHECK(condition)
Definition: logging.h:103
Dart_Handle ToDart(const T &object)
std::string StdStringFromDart(Dart_Handle handle)

◆ InternalFlutterGpu_ShaderLibrary_InitializeWithAsset()

Dart_Handle InternalFlutterGpu_ShaderLibrary_InitializeWithAsset ( Dart_Handle  wrapper,
Dart_Handle  asset_name 
)

Exports

Definition at line 352 of file shader_library.cc.

354 {
355 if (!Dart_IsString(asset_name)) {
356 return tonic::ToDart("Asset name must be a string");
357 }
358
359 std::optional<std::string> out_error;
360 auto impeller_context = flutter::gpu::Context::GetDefaultContext(out_error);
361 if (out_error.has_value()) {
362 return tonic::ToDart(out_error.value());
363 }
364
365 std::string error;
367 impeller_context->GetBackendType(), tonic::StdStringFromDart(asset_name),
368 error);
369 if (!res) {
370 return tonic::ToDart(error);
371 }
372 res->AssociateWithDartWrapper(wrapper);
373 return Dart_Null();
374}
static std::shared_ptr< impeller::Context > GetDefaultContext(std::optional< std::string > &out_error)
Definition: context.cc:29
static fml::RefPtr< ShaderLibrary > MakeFromAsset(impeller::Context::BackendType backend_type, const std::string &name, std::string &out_error)
const uint8_t uint32_t uint32_t GError ** error