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 coordinate_system, int texture_type, bool enable_render_target_usage, bool enable_shader_read_usage, bool enable_shader_write_usage, int mip_level_count)
 
void InternalFlutterGpu_Texture_SetCoordinateSystem (flutter::gpu::Texture *wrapper, int coordinate_system)
 
bool InternalFlutterGpu_Texture_Overwrite (flutter::gpu::Texture *texture, flutter::gpu::Context *gpu_context, Dart_Handle source_byte_data, int mip_level, int slice)
 
int InternalFlutterGpu_Texture_BytesPerTexel (flutter::gpu::Texture *wrapper)
 
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 264 of file texture.cc.

264 {
265 return wrapper->AsImage();
266}
Dart_Handle AsImage() const
Definition texture.cc:153

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

◆ InternalFlutterGpu_Texture_BytesPerTexel()

int InternalFlutterGpu_Texture_BytesPerTexel ( flutter::gpu::Texture wrapper)
extern

Definition at line 259 of file texture.cc.

260 {
261 return wrapper->GetBytesPerTexel();
262}
size_t GetBytesPerTexel()
Definition texture.cc:148

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

◆ 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  coordinate_system,
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 175 of file texture.cc.

187 {
188 if (mip_level_count < 1) {
189 return false;
190 }
193 desc.size = {width, height};
195 desc.mip_count = static_cast<size_t>(mip_level_count);
196 desc.usage = {};
197 if (enable_render_target_usage) {
199 }
200 if (enable_shader_read_usage) {
202 }
203 if (enable_shader_write_usage) {
205 }
206 switch (sample_count) {
207 case 1:
209 break;
210 case 4:
212 break;
213 default:
214 return false;
215 }
216 desc.type = static_cast<impeller::TextureType>(texture_type);
219 return false;
220 }
221
222 auto texture =
223 gpu_context->GetContext().GetResourceAllocator()->CreateTexture(desc,
224 true);
225 if (!texture) {
226 FML_LOG(ERROR) << "Failed to create texture.";
227 return false;
228 }
229
230 texture->SetCoordinateSystem(
232
233 auto res = fml::MakeRefCounted<flutter::gpu::Texture>(std::move(texture));
234 res->AssociateWithDartWrapper(wrapper);
235
236 return true;
237}
impeller::Context & GetContext()
Definition context.cc:84
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:60
constexpr impeller::TextureCoordinateSystem ToImpellerTextureCoordinateSystem(FlutterGPUTextureCoordinateSystem value)
Definition formats.h:148
constexpr impeller::StorageMode ToImpellerStorageMode(FlutterGPUStorageMode value)
Definition formats.h:25
constexpr bool IsMultisampleCapable(TextureType type)
Definition formats.h:286
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(), flutter::gpu::ToImpellerTextureCoordinateSystem(), 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 246 of file texture.cc.

250 {
251 if (mip_level < 0 || slice < 0) {
252 return false;
253 }
254 return texture->Overwrite(*gpu_context, tonic::DartByteData(source_byte_data),
255 static_cast<uint32_t>(mip_level),
256 static_cast<uint32_t>(slice));
257}

References texture.

◆ InternalFlutterGpu_Texture_SetCoordinateSystem()

void InternalFlutterGpu_Texture_SetCoordinateSystem ( flutter::gpu::Texture wrapper,
int  coordinate_system 
)

Definition at line 239 of file texture.cc.

241 {
242 return wrapper->SetCoordinateSystem(
244}
void SetCoordinateSystem(impeller::TextureCoordinateSystem coordinate_system)
Definition texture.cc:42

References flutter::gpu::Texture::SetCoordinateSystem(), and flutter::gpu::ToImpellerTextureCoordinateSystem().