Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
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 ()
 
virtual std::string GetLabel () const =0
 
virtual bool Encode (const ReactorGLES &reactor) const =0
 

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 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 200 of file blit_command_gles.cc.

201 {
202 TextureGLES& texture_gles = TextureGLES::Cast(*destination);
203
204 if (texture_gles.GetType() != TextureGLES::Type::kTexture) {
205 VALIDATION_LOG << "Incorrect texture usage flags for setting contents on "
206 "this texture object.";
207 return false;
208 }
209
210 if (texture_gles.IsWrapped()) {
211 VALIDATION_LOG << "Cannot set the contents of a wrapped texture.";
212 return false;
213 }
214
215 const auto& tex_descriptor = texture_gles.GetTextureDescriptor();
216
217 if (tex_descriptor.size.IsEmpty()) {
218 return true;
219 }
220
221 if (!tex_descriptor.IsValid() ||
223 BytesPerPixelForPixelFormat(tex_descriptor.format) *
225 return false;
226 }
227
229
230 GLenum texture_type;
231 GLenum texture_target;
232 switch (tex_descriptor.type) {
234 texture_type = GL_TEXTURE_2D;
235 texture_target = GL_TEXTURE_2D;
236 break;
238 VALIDATION_LOG << "Multisample texture uploading is not supported for "
239 "the OpenGLES backend.";
240 return false;
242 texture_type = GL_TEXTURE_CUBE_MAP;
243 texture_target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + slice;
244 break;
246 texture_type = GL_TEXTURE_EXTERNAL_OES;
247 texture_target = GL_TEXTURE_EXTERNAL_OES;
248 break;
249 }
250
251 TexImage2DData data = TexImage2DData(tex_descriptor.format, source);
252 if (!data.IsValid()) {
253 VALIDATION_LOG << "Invalid texture format.";
254 return false;
255 }
256
257 auto gl_handle = texture_gles.GetGLHandle();
258 if (!gl_handle.has_value()) {
260 << "Texture was collected before it could be uploaded to the GPU.";
261 return false;
262 }
263 const auto& gl = reactor.GetProcTable();
264 gl.BindTexture(texture_type, gl_handle.value());
265 const GLvoid* tex_data =
266 data.buffer_view.buffer->OnGetContents() + data.buffer_view.range.offset;
267
268 // GL_INVALID_OPERATION if the texture array has not been
269 // defined by a previous glTexImage2D operation.
270 if (!texture_gles.IsSliceInitialized(slice)) {
271 gl.TexImage2D(texture_target, // target
272 0u, // LOD level
273 data.internal_format, // internal format
274 tex_descriptor.size.width, // width
275 tex_descriptor.size.height, // height
276 0u, // border
277 data.external_format, // external format
278 data.type, // type
279 nullptr // data
280 );
281 texture_gles.MarkSliceInitialized(slice);
282 }
283
284 {
285 TRACE_EVENT1("impeller", "TexImage2DUpload", "Bytes",
286 std::to_string(data.buffer_view.range.length).c_str());
287 gl.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
288 gl.TexSubImage2D(texture_target, // target
289 0u, // LOD level
290 destination_region.GetX(), // xoffset
291 destination_region.GetY(), // yoffset
292 destination_region.GetWidth(), // width
293 destination_region.GetHeight(), // height
294 data.external_format, // external format
295 data.type, // type
296 tex_data // data
297
298 );
299 }
300 return true;
301}
const char * c_str() const
Definition: SkString.h:133
static TextureGLES & Cast(Texture &base)
Definition: backend_cast.h:13
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
Definition: formats.h:460
gl
Definition: malisc.py:41
static SkString to_string(int n)
Definition: nanobench.cpp:119
std::shared_ptr< Texture > destination
Definition: blit_command.h:34
size_t length
Definition: range.h:14
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:327
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:337
constexpr T Area() const
Get the area of the rectangle, equivalent to |GetSize().Area()|.
Definition: rect.h:366
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition: rect.h:323
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition: rect.h:331
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:141
#define VALIDATION_LOG
Definition: validation.h:73

◆ GetLabel()

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

Implements impeller::BlitEncodeGLES.

Definition at line 196 of file blit_command_gles.cc.

196 {
197 return label;
198}

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