Flutter Engine
The Flutter Engine
Classes | Namespaces | Functions
shader_library.h File Reference
#include <memory>
#include <string>
#include <unordered_map>
#include "flutter/lib/gpu/export.h"
#include "flutter/lib/gpu/shader.h"
#include "flutter/lib/ui/dart_wrapper.h"
#include "fml/memory/ref_ptr.h"

Go to the source code of this file.

Classes

class  flutter::gpu::ShaderLibrary
 An immutable collection of shaders loaded from a shader bundle asset. More...
 

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_ShaderLibrary_InitializeWithAsset (Dart_Handle wrapper, Dart_Handle asset_name)
 
FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_ShaderLibrary_GetShader (flutter::gpu::ShaderLibrary *wrapper, Dart_Handle shader_name, Dart_Handle shader_wrapper)
 

Function Documentation

◆ InternalFlutterGpu_ShaderLibrary_GetShader()

FLUTTER_GPU_EXPORT 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()

FLUTTER_GPU_EXPORT 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