Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
texture.cc File Reference

Go to the source code of this file.

Namespaces

namespace  flutter
 
namespace  flutter::gpu
 

Functions

 flutter::gpu::IMPLEMENT_WRAPPERTYPEINFO (flutter_gpu, Texture)
 
static int32_t flutter::gpu::MipDimensionAtLevel (int32_t base_dimension, uint32_t mip_level)
 
static bool flutter::gpu::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)
 
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)
 
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)
 

Function Documentation

◆ InternalFlutterGpu_Texture_AsImage()

Dart_Handle InternalFlutterGpu_Texture_AsImage ( flutter::gpu::Texture wrapper)

Definition at line 238 of file texture.cc.

238 {
239 return wrapper->AsImage();
240}
Dart_Handle AsImage() const
Definition texture.cc:143

References flutter::gpu::Texture::AsImage().

◆ InternalFlutterGpu_Texture_Initialize()

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 
)

Exports

Definition at line 165 of file texture.cc.

176 {
177 if (mip_level_count < 1) {
178 return false;
179 }
182 desc.size = {width, height};
184 desc.mip_count = static_cast<size_t>(mip_level_count);
185 desc.usage = {};
186 if (enable_render_target_usage) {
188 }
189 if (enable_shader_read_usage) {
191 }
192 if (enable_shader_write_usage) {
194 }
195 switch (sample_count) {
196 case 1:
198 break;
199 case 4:
201 break;
202 default:
203 return false;
204 }
205 desc.type = static_cast<impeller::TextureType>(texture_type);
208 return false;
209 }
210
211 auto texture =
212 gpu_context->GetContext().GetResourceAllocator()->CreateTexture(desc,
213 true);
214 if (!texture) {
215 FML_LOG(ERROR) << "Failed to create texture.";
216 return false;
217 }
218
219 auto res = fml::MakeRefCounted<flutter::gpu::Texture>(std::move(texture));
220 res->AssociateWithDartWrapper(wrapper);
221
222 return true;
223}
impeller::Context & GetContext()
Definition context.cc:87
virtual std::shared_ptr< Allocator > GetResourceAllocator() const =0
Returns the allocator used to create textures and buffers on the device.
#define FML_LOG(severity)
Definition logging.h:101
FlTexture * texture
constexpr impeller::PixelFormat ToImpellerPixelFormat(FlutterGPUPixelFormat value)
Definition formats.h:104
constexpr impeller::StorageMode ToImpellerStorageMode(FlutterGPUStorageMode value)
Definition formats.h:25
constexpr bool IsMultisampleCapable(TextureType type)
Definition formats.h:471
int32_t height
int32_t width
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...

References FML_LOG, impeller::TextureDescriptor::format, format, flutter::gpu::Context::GetContext(), impeller::Context::GetResourceAllocator(), height, impeller::IsMultisampleCapable(), impeller::kCount1, impeller::kCount4, impeller::kRenderTarget, impeller::kShaderRead, impeller::kShaderWrite, impeller::TextureDescriptor::mip_count, impeller::TextureDescriptor::sample_count, impeller::TextureDescriptor::size, impeller::TextureDescriptor::storage_mode, texture, flutter::gpu::ToImpellerPixelFormat(), flutter::gpu::ToImpellerStorageMode(), impeller::TextureDescriptor::type, impeller::TextureDescriptor::usage, and width.

◆ InternalFlutterGpu_Texture_Overwrite()

bool InternalFlutterGpu_Texture_Overwrite ( flutter::gpu::Texture texture,
flutter::gpu::Context gpu_context,
Dart_Handle  source_byte_data,
int  mip_level,
int  slice 
)

Definition at line 225 of file texture.cc.

229 {
230 if (mip_level < 0 || slice < 0) {
231 return false;
232 }
233 return texture->Overwrite(*gpu_context, tonic::DartByteData(source_byte_data),
234 static_cast<uint32_t>(mip_level),
235 static_cast<uint32_t>(slice));
236}

References texture.