Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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_ReinitializeWithAsset (flutter::gpu::ShaderLibrary *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 
)
extern

Definition at line 481 of file shader_library.cc.

484 {
485 FML_DCHECK(Dart_IsString(shader_name));
486 auto shader =
487 wrapper->GetShader(tonic::StdStringFromDart(shader_name), shader_wrapper);
488 if (!shader) {
489 return Dart_Null();
490 }
491 return tonic::ToDart(shader.get());
492}
fml::RefPtr< Shader > GetShader(const std::string &shader_name, Dart_Handle shader_wrapper)
#define FML_DCHECK(condition)
Definition logging.h:122
Dart_Handle ToDart(const T &object)
std::string StdStringFromDart(Dart_Handle handle)

References FML_DCHECK, flutter::gpu::ShaderLibrary::GetShader(), tonic::StdStringFromDart(), and tonic::ToDart().

◆ InternalFlutterGpu_ShaderLibrary_InitializeWithAsset()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_ShaderLibrary_InitializeWithAsset ( Dart_Handle  wrapper,
Dart_Handle  asset_name 
)
extern

Exports

Definition at line 436 of file shader_library.cc.

438 {
439 if (!Dart_IsString(asset_name)) {
440 return tonic::ToDart("Asset name must be a string");
441 }
442
443 std::optional<std::string> out_error;
444 auto impeller_context = flutter::gpu::Context::GetDefaultContext(out_error);
445 if (out_error.has_value()) {
446 return tonic::ToDart(out_error.value());
447 }
448
449 std::string error;
451 impeller_context->GetBackendType(), tonic::StdStringFromDart(asset_name),
452 error);
453 if (!res) {
454 return tonic::ToDart(error);
455 }
456 res->AssociateWithDartWrapper(wrapper);
457 return Dart_Null();
458}
static std::shared_ptr< impeller::Context > GetDefaultContext(std::optional< std::string > &out_error)
Definition context.cc:39
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

References error, flutter::gpu::Context::GetDefaultContext(), flutter::gpu::ShaderLibrary::MakeFromAsset(), tonic::StdStringFromDart(), and tonic::ToDart().

◆ InternalFlutterGpu_ShaderLibrary_ReinitializeWithAsset()

FLUTTER_GPU_EXPORT Dart_Handle InternalFlutterGpu_ShaderLibrary_ReinitializeWithAsset ( flutter::gpu::ShaderLibrary wrapper,
Dart_Handle  asset_name 
)
extern

Definition at line 460 of file shader_library.cc.

462 {
463 if (!Dart_IsString(asset_name)) {
464 return tonic::ToDart("Asset name must be a string");
465 }
466
467 std::optional<std::string> out_error;
468 auto impeller_context = flutter::gpu::Context::GetDefaultContext(out_error);
469 if (out_error.has_value()) {
470 return tonic::ToDart(out_error.value());
471 }
472
473 std::string error = wrapper->ReloadFromAsset(
474 impeller_context->GetBackendType(), tonic::StdStringFromDart(asset_name));
475 if (!error.empty()) {
476 return tonic::ToDart(error);
477 }
478 return Dart_Null();
479}
std::string ReloadFromAsset(impeller::Context::BackendType backend_type, const std::string &name)

References error, flutter::gpu::Context::GetDefaultContext(), flutter::gpu::ShaderLibrary::ReloadFromAsset(), tonic::StdStringFromDart(), and tonic::ToDart().