Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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/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 365 of file shader_library.cc.

368 {
369 FML_DCHECK(Dart_IsString(shader_name));
370 auto shader =
371 wrapper->GetShader(tonic::StdStringFromDart(shader_name), shader_wrapper);
372 if (!shader) {
373 return Dart_Null();
374 }
375 return tonic::ToDart(shader.get());
376}
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 341 of file shader_library.cc.

343 {
344 if (!Dart_IsString(asset_name)) {
345 return tonic::ToDart("Asset name must be a string");
346 }
347
348 std::optional<std::string> out_error;
349 auto impeller_context = flutter::gpu::Context::GetDefaultContext(out_error);
350 if (out_error.has_value()) {
351 return tonic::ToDart(out_error.value());
352 }
353
354 std::string error;
356 impeller_context->GetBackendType(), tonic::StdStringFromDart(asset_name),
357 error);
358 if (!res) {
359 return tonic::ToDart(error);
360 }
361 res->AssociateWithDartWrapper(wrapper);
362 return Dart_Null();
363}
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