23#if IMPELLER_SUPPORTS_RENDERING
44 texture_->SetCoordinateSystem(coordinate_system);
53 const int32_t shifted = base_dimension >> mip_level;
54 return shifted > 0 ? shifted : 1;
63 const std::shared_ptr<impeller::Texture>&
texture,
64 const std::shared_ptr<impeller::DeviceBuffer>& staging_buffer,
70 if (!command_buffer) {
71 FML_LOG(ERROR) <<
"Failed to create command buffer for texture overwrite.";
74 auto blit_pass = command_buffer->CreateBlitPass();
76 FML_LOG(ERROR) <<
"Failed to create blit pass for texture overwrite.";
81 if (!blit_pass->AddCopy(std::move(buffer_view),
texture, destination_region,
82 "Texture.overwrite", mip_level, slice)) {
85 if (!blit_pass->EncodeCommands()) {
88 return context.
GetCommandQueue()->Submit({std::move(command_buffer)}).ok();
95 const uint8_t*
data =
static_cast<const uint8_t*
>(source_bytes.
data());
98 auto& impeller_context = gpu_context.
GetContext();
102 if (!staging_buffer) {
103 FML_LOG(ERROR) <<
"Failed to allocate staging buffer for texture "
121 if (impeller_context.GetBackendType() ==
124 auto& task_runners = dart_state->GetTaskRunners();
128 destination_region, mip_level, slice]()
mutable {
131 destination_region, mip_level, slice)) {
132 FML_LOG(ERROR) <<
"Failed to encode texture overwrite blit on the "
135 context_shared->DisposeThreadLocalCachedResources();
141 length, destination_region, mip_level, slice)) {
144 impeller_context.DisposeThreadLocalCachedResources();
150 texture_->GetTextureDescriptor().format);
157#if IMPELLER_SUPPORTS_RENDERING
160 image->set_image(dl_image);
161 auto wrapped =
image->CreateOuterWrapping();
182 int coordinate_system,
184 bool enable_render_target_usage,
185 bool enable_shader_read_usage,
186 bool enable_shader_write_usage,
187 int mip_level_count) {
188 if (mip_level_count < 1) {
195 desc.
mip_count =
static_cast<size_t>(mip_level_count);
197 if (enable_render_target_usage) {
200 if (enable_shader_read_usage) {
203 if (enable_shader_write_usage) {
206 switch (sample_count) {
226 FML_LOG(ERROR) <<
"Failed to create texture.";
233 auto res = fml::MakeRefCounted<flutter::gpu::Texture>(std::move(
texture));
234 res->AssociateWithDartWrapper(wrapper);
241 int coordinate_system) {
248 Dart_Handle source_byte_data,
251 if (mip_level < 0 || slice < 0) {
255 static_cast<uint32_t
>(mip_level),
256 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)
size_t GetBytesPerTexel()
std::shared_ptr< impeller::Texture > GetTexture()
Dart_Handle AsImage() const
void SetCoordinateSystem(impeller::TextureCoordinateSystem coordinate_system)
To do anything rendering related with Impeller, you need a context.
virtual std::shared_ptr< CommandQueue > GetCommandQueue() const =0
Return the graphics queue for submitting command buffers.
virtual std::shared_ptr< CommandBuffer > CreateCommandBuffer() const =0
Create a new command buffer. Command buffers can be used to encode graphics, blit,...
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)
void InternalFlutterGpu_Texture_SetCoordinateSystem(flutter::gpu::Texture *wrapper, int coordinate_system)
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 coordinate_system, int texture_type, bool enable_render_target_usage, bool enable_shader_read_usage, bool enable_shader_write_usage, int mip_level_count)
int InternalFlutterGpu_Texture_BytesPerTexel(flutter::gpu::Texture *wrapper)
constexpr impeller::PixelFormat ToImpellerPixelFormat(FlutterGPUPixelFormat value)
constexpr impeller::TextureCoordinateSystem ToImpellerTextureCoordinateSystem(FlutterGPUTextureCoordinateSystem 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 size_t BytesPerPixelForPixelFormat(PixelFormat format)
constexpr bool IsMultisampleCapable(TextureType type)
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...