Flutter Engine
 
Loading...
Searching...
No Matches
impeller::BlitCopyBufferToTextureCommandGLES Struct Reference

#include <blit_command_gles.h>

Inheritance diagram for impeller::BlitCopyBufferToTextureCommandGLES:
impeller::BlitEncodeGLES impeller::BlitCopyBufferToTextureCommand impeller::BackendCast< BlitEncodeGLES, BlitCommand > impeller::BlitCommand

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 BlitEncodeGLESCast (BlitCommand &base)
 
static const BlitEncodeGLESCast (const BlitCommand &base)
 
static BlitEncodeGLESCast (BlitCommand *base)
 
static const BlitEncodeGLESCast (const BlitCommand *base)
 
- Public Attributes inherited from impeller::BlitCopyBufferToTextureCommand
BufferView source
 
std::shared_ptr< Texturedestination
 
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 227 of file blit_command_gles.cc.

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

223 {
224 return label;
225}

References impeller::BlitCommand::label.


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