23#if IMPELLER_SUPPORTS_RENDERING
48 const int32_t shifted = base_dimension >> mip_level;
49 return shifted > 0 ? shifted : 1;
58 const std::shared_ptr<impeller::Texture>&
texture,
59 const std::shared_ptr<impeller::DeviceBuffer>& staging_buffer,
66 FML_LOG(ERROR) <<
"Failed to create command buffer for texture overwrite.";
71 FML_LOG(ERROR) <<
"Failed to create blit pass for texture overwrite.";
76 if (!blit_pass->AddCopy(std::move(buffer_view),
texture, destination_region,
77 "Texture.overwrite", mip_level, slice)) {
80 if (!blit_pass->EncodeCommands()) {
90 const uint8_t*
data =
static_cast<const uint8_t*
>(source_bytes.
data());
93 auto& impeller_context = gpu_context.
GetContext();
97 if (!staging_buffer) {
98 FML_LOG(ERROR) <<
"Failed to allocate staging buffer for texture "
116 if (impeller_context.GetBackendType() ==
119 auto& task_runners = dart_state->GetTaskRunners();
123 destination_region, mip_level, slice]()
mutable {
126 destination_region, mip_level, slice)) {
127 FML_LOG(ERROR) <<
"Failed to encode texture overwrite blit on the "
130 context_shared->DisposeThreadLocalCachedResources();
136 length, destination_region, mip_level, slice)) {
139 impeller_context.DisposeThreadLocalCachedResources();
147#if IMPELLER_SUPPORTS_RENDERING
150 image->set_image(dl_image);
151 auto wrapped =
image->CreateOuterWrapping();
173 bool enable_render_target_usage,
174 bool enable_shader_read_usage,
175 bool enable_shader_write_usage,
176 int mip_level_count) {
177 if (mip_level_count < 1) {
184 desc.
mip_count =
static_cast<size_t>(mip_level_count);
186 if (enable_render_target_usage) {
189 if (enable_shader_read_usage) {
192 if (enable_shader_write_usage) {
195 switch (sample_count) {
215 FML_LOG(ERROR) <<
"Failed to create texture.";
219 auto res = fml::MakeRefCounted<flutter::gpu::Texture>(std::move(
texture));
220 res->AssociateWithDartWrapper(wrapper);
227 Dart_Handle source_byte_data,
230 if (mip_level < 0 || slice < 0) {
234 static_cast<uint32_t
>(mip_level),
235 static_cast<uint32_t
>(slice));
static fml::RefPtr< CanvasImage > Create()
static UIDartState * Current()
std::shared_ptr< impeller::Context > & GetContextShared()
impeller::Context & GetContext()
Texture(std::shared_ptr< impeller::Texture > texture)
bool Overwrite(Context &gpu_context, const tonic::DartByteData &source_bytes, uint32_t mip_level, uint32_t slice)
std::shared_ptr< impeller::Texture > GetTexture()
Dart_Handle AsImage() const
To do anything rendering related with Impeller, you need a context.
virtual std::shared_ptr< Allocator > GetResourceAllocator() const =0
Returns the allocator used to create textures and buffers on the device.
static sk_sp< DlImageImpeller > Make(std::shared_ptr< Texture > texture, OwningContext owning_context=OwningContext::kIO)
const void * data() const
size_t length_in_bytes() const
#define IMPLEMENT_WRAPPERTYPEINFO(LibraryName, ClassName)
FlutterVulkanImage * image
uint32_t uint32_t * format
#define FML_LOG(severity)
bool InternalFlutterGpu_Texture_Overwrite(flutter::gpu::Texture *texture, flutter::gpu::Context *gpu_context, Dart_Handle source_byte_data, int mip_level, int slice)
Dart_Handle InternalFlutterGpu_Texture_AsImage(flutter::gpu::Texture *wrapper)
bool InternalFlutterGpu_Texture_Initialize(Dart_Handle wrapper, flutter::gpu::Context *gpu_context, int storage_mode, int format, int width, int height, int sample_count, int texture_type, bool enable_render_target_usage, bool enable_shader_read_usage, bool enable_shader_write_usage, int mip_level_count)
constexpr impeller::PixelFormat ToImpellerPixelFormat(FlutterGPUPixelFormat value)
static int32_t MipDimensionAtLevel(int32_t base_dimension, uint32_t mip_level)
static bool EncodeAndSubmitOverwrite(impeller::Context &context, const std::shared_ptr< impeller::Texture > &texture, const std::shared_ptr< impeller::DeviceBuffer > &staging_buffer, size_t source_length, impeller::IRect destination_region, uint32_t mip_level, uint32_t slice)
constexpr impeller::StorageMode ToImpellerStorageMode(FlutterGPUStorageMode value)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
internal::CopyableLambda< T > MakeCopyable(T lambda)
constexpr bool IsMultisampleCapable(TextureType type)
std::shared_ptr< ContextGLES > context
std::shared_ptr< CommandBuffer > command_buffer
static constexpr TRect MakeXYWH(Type x, Type y, Type width, Type height)
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...