| Flutter Impeller |

Public Member Functions | List of all members
impeller::BlitCopyBufferToTextureCommandGLES Struct Reference

`#include <blit_command_gles.h>`

Inheritance diagram for impeller::BlitCopyBufferToTextureCommandGLES:

## Public Member Functions
| ~BlitCopyBufferToTextureCommandGLES () override
std::string | GetLabel () const override
bool | Encode (const ReactorGLES &reactor) const override
Public Member Functions inherited from impeller::BlitEncodeGLES
virtual | ~BlitEncodeGLES ()

## Additional Inherited Members
Static Public Member Functions inherited from impeller::BackendCast< BlitEncodeGLES, BlitCommand >
static BlitEncodeGLES & | Cast (BlitCommand &base)
static const BlitEncodeGLES & | Cast (const BlitCommand &base)
static BlitEncodeGLES * | Cast (BlitCommand *base)
static const BlitEncodeGLES * | Cast (const BlitCommand *base)
Public Attributes inherited from impeller::BlitCopyBufferToTextureCommand
BufferView | source
std::shared_ptr< Texture > | destination
IRect | destination_region
uint32_t | mip_level = 0
uint32_t | slice = 0
Public Attributes inherited from impeller::BlitCommand
std::string | label

## Detailed Description

Definition at line 23 of file blit_command_gles.h.

## Constructor & Destructor Documentation

## ◆ ~BlitCopyBufferToTextureCommandGLES()

impeller::BlitCopyBufferToTextureCommandGLES::~BlitCopyBufferToTextureCommandGLES | ( |  | ) |
| overridedefault

## Member Function Documentation

## ◆ Encode()

bool impeller::BlitCopyBufferToTextureCommandGLES::Encode | ( | const ReactorGLES & | reactor | ) | const
| overridevirtual

Implements impeller::BlitEncodeGLES.

Definition at line 232 of file blit_command_gles.cc.

233 {
234 TextureGLES& texture_gles = TextureGLES::Cast(*destination);
235
236 if (texture_gles.GetType() != TextureGLES::Type::kTexture) {
237 VALIDATION_LOG << "Incorrect texture usage flags for setting contents on "
238 "this texture object.";
239 return false;
240 }
241
242 if (texture_gles.IsWrapped()) {
243 VALIDATION_LOG << "Cannot set the contents of a wrapped texture.";
244 return false;
245 }
246
247 const auto& tex_descriptor = texture_gles.GetTextureDescriptor();
248
249 if (tex_descriptor.size.IsEmpty()) {
250 return true;
251 }
252
253 if (!tex_descriptor.IsValid() ||
254 source.GetRange().length !=
255 BytesPerPixelForPixelFormat(tex_descriptor.format) *
256 destination_region.Area()) {
257 return false;
258 }
259
260 destination->SetCoordinateSystem(TextureCoordinateSystem::kUploadFromHost);
261
262 GLenum texture_type;
263 GLenum texture_target;
264 switch (tex_descriptor.type) {
265 case TextureType::kTexture2D:
266 texture_type = GL_TEXTURE_2D;
267 texture_target = GL_TEXTURE_2D;
268 break;
269 case TextureType::kTexture2DMultisample:
270 VALIDATION_LOG << "Multisample texture uploading is not supported for "
271 "the OpenGLES backend.";
272 return false;
273 case TextureType::kTextureCube:
274 texture_type = GL_TEXTURE_CUBE_MAP;
275 texture_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + slice;
276 break;
277 case TextureType::kTextureExternalOES:
278 texture_type = GL_TEXTURE_EXTERNAL_OES;
279 texture_target = GL_TEXTURE_EXTERNAL_OES;
280 break;
281 }
282
283 TexImage2DData data = TexImage2DData(tex_descriptor.format, source);
284 if (!data.IsValid()) {
285 VALIDATION_LOG << "Invalid texture format.";
286 return false;
287 }
288
289 auto gl_handle = texture_gles.GetGLHandle();
290 if (!gl_handle.has_value()) {
291 VALIDATION_LOG
292 << "Texture was collected before it could be uploaded to the GPU.";
293 return false;
294 }
295 const auto& gl = reactor.GetProcTable();
296 gl.BindTexture(texture_type, gl_handle.value());
297 const GLvoid* tex_data = data.buffer_view.GetBuffer()->OnGetContents() +
298 data.buffer_view.GetRange().offset;
299
300 // GL_INVALID_OPERATION if the texture array has not been
301 // defined by a previous glTexImage2D operation.
302 if (!texture_gles.IsSliceInitialized(slice)) {
303 gl.TexImage2D(texture_target, // target
304 mip_level, // LOD level
305 data.internal_format, // internal format
306 tex_descriptor.size.width, // width
307 tex_descriptor.size.height, // height
308 0u, // border
309 data.external_format, // external format
310 data.type, // type
311 nullptr // data
312 );
313 texture_gles.MarkSliceInitialized(slice);
314 }
315
316 {
317 gl.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
318 gl.TexSubImage2D(texture_target, // target
319 mip_level, // LOD level
320 destination_region.GetX(), // xoffset
321 destination_region.GetY(), // yoffset
322 destination_region.GetWidth(), // width
323 destination_region.GetHeight(), // height
324 data.external_format, // external format
325 data.type, // type
326 tex_data // data
327
328 );
329 }
330 return true;
331 }
impeller::BackendCast< TextureGLES, Texture >::Cast
static TextureGLES & Cast(Texture &base)
Definition: backend_cast.h:13
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller::BytesPerPixelForPixelFormat
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:469
impeller::TextureType::kTextureExternalOES
@ kTextureExternalOES
impeller::TextureType::kTexture2DMultisample
@ kTexture2DMultisample
impeller::TextureType::kTexture2D
@ kTexture2D
impeller::TextureType::kTextureCube
@ kTextureCube
impeller::TextureCoordinateSystem::kUploadFromHost
@ kUploadFromHost
impeller::BlitCopyBufferToTextureCommand::mip_level
uint32_t mip_level
Definition: blit_command.h:42
impeller::BlitCopyBufferToTextureCommand::slice
uint32_t slice
Definition: blit_command.h:43
impeller::BlitCopyBufferToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:40
impeller::BlitCopyBufferToTextureCommand::source
BufferView source
Definition: blit_command.h:39
impeller::BlitCopyBufferToTextureCommand::destination_region
IRect destination_region
Definition: blit_command.h:41
impeller::BufferView::GetRange
Range GetRange() const
Definition: buffer_view.h:27
impeller::Range::length
size_t length
Definition: range.h:15
impeller::TRect::GetY
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:337
impeller::TRect::GetHeight
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:347
impeller::TRect::Area
constexpr T Area() const
Get the area of the rectangle, equivalent to |GetSize().Area()|.
Definition: rect.h:376
impeller::TRect::GetX
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition: rect.h:333
impeller::TRect::GetWidth
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition: rect.h:341
data
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:69
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:91

References impeller::TRect< T >::Area(), impeller::BytesPerPixelForPixelFormat(), impeller::BackendCast< TextureGLES, Texture >::Cast(), data, impeller::BlitCopyBufferToTextureCommand::destination, impeller::BlitCopyBufferToTextureCommand::destination_region, impeller::TextureGLES::GetGLHandle(), impeller::TRect< T >::GetHeight(), impeller::ReactorGLES::GetProcTable(), impeller::BufferView::GetRange(), impeller::Texture::GetTextureDescriptor(), impeller::TextureGLES::GetType(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::GetX(), impeller::TRect< T >::GetY(), impeller::TextureGLES::IsSliceInitialized(), impeller::TextureGLES::IsWrapped(), impeller::TextureGLES::kTexture, impeller::kTexture2D, impeller::kTexture2DMultisample, impeller::kTextureCube, impeller::kTextureExternalOES, impeller::kUploadFromHost, impeller::Range::length, impeller::TextureGLES::MarkSliceInitialized(), impeller::BlitCopyBufferToTextureCommand::mip_level, impeller::BlitCopyBufferToTextureCommand::slice, impeller::BlitCopyBufferToTextureCommand::source, and VALIDATION_LOG.

## ◆ GetLabel()

std::string impeller::BlitCopyBufferToTextureCommandGLES::GetLabel | ( |  | ) | const
| overridevirtual

Implements impeller::BlitEncodeGLES.

Definition at line 228 of file blit_command_gles.cc.

228 {
229 return label;
230 }
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:16

References impeller::BlitCommand::label.

The documentation for this struct was generated from the following files:

- impeller/renderer/backend/gles/blit_command_gles.h
- impeller/renderer/backend/gles/blit_command_gles.cc