Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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/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/shader_key.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)
 
static ShaderLibrary::ShaderMap flutter::gpu::ParseShaderBundle (impeller::Context::BackendType backend_type, const std::shared_ptr< fml::Mapping > &payload, const std::string &library_id)
 
Dart_Handle InternalFlutterGpu_ShaderLibrary_InitializeWithAsset (Dart_Handle wrapper, Dart_Handle asset_name)
 
Dart_Handle InternalFlutterGpu_ShaderLibrary_ReinitializeWithAsset (flutter::gpu::ShaderLibrary *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 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()

Dart_Handle InternalFlutterGpu_ShaderLibrary_InitializeWithAsset ( Dart_Handle  wrapper,
Dart_Handle  asset_name 
)

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

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

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