Non owning, writable view of a caller owned pixel buffer. More...
#include <gz/rendering/PixelBuffer.hh>
Public Member Functions | |
| PixelBuffer (const PixelBuffer &_other) | |
| Copy constructor. Copies of a view share the same buffer. | |
| PixelBuffer (Image &_image) | |
| View the storage of an existing image. The view is only valid while the image, or a copy of it, is alive. | |
| PixelBuffer (unsigned int _width, unsigned int _height, PixelFormat _format, void *_data, std::size_t _size) | |
| Describe a caller owned buffer. | |
| ~PixelBuffer () | |
| Destructor. Does not free the buffer. | |
| unsigned char * | Data () const |
| Get a pointer to the first byte of the buffer. The pointer is writable even through a const view: this is a span, not a read only view. | |
| PixelFormat | Format () const |
| Get the pixel format. | |
| unsigned int | Height () const |
| Get the height in pixels. | |
| std::size_t | MemorySize () const |
| Get the number of bytes Width x Height pixels of Format need. | |
| PixelBuffer & | operator= (const PixelBuffer &)=delete |
| Views cannot be rebound. | |
| PixelBuffer & | operator= (PixelBuffer &&)=delete |
| Views cannot be rebound. | |
| std::size_t | Size () const |
| Get the size of the buffer in bytes, as given by the caller. | |
| bool | Valid () const |
| Check that the buffer can hold a frame: the pointer is not null and Size() is at least MemorySize(). | |
| unsigned int | Width () const |
| Get the width in pixels. | |
Detailed Description
Non owning, writable view of a caller owned pixel buffer.
A PixelBuffer describes where a frame should be written: dimensions, pixel format, the start of a contiguous row major buffer and its size in bytes. It owns nothing and never frees the memory. Build one right before handing it to Camera::CopyTo and let it die when the call returns; nothing in the library keeps a pointer to the memory after that.
Every field is immutable and assignment is deleted, so code that receives a PixelBuffer can write through it but cannot point it somewhere else. That is what lets the render engines write straight into caller memory without being able to drop it by mistake.
Constructor & Destructor Documentation
◆ PixelBuffer() [1/3]
| PixelBuffer | ( | unsigned int | _width, |
| unsigned int | _height, | ||
| PixelFormat | _format, | ||
| void * | _data, | ||
| std::size_t | _size | ||
| ) |
Describe a caller owned buffer.
- Parameters
-
[in] _width Width in pixels [in] _height Height in pixels [in] _format Pixel format of the buffer [in] _data Start of the buffer. Not owned. [in] _size Size of the buffer in bytes
◆ PixelBuffer() [2/3]
|
explicit |
View the storage of an existing image. The view is only valid while the image, or a copy of it, is alive.
- Parameters
-
[in] _image Image whose buffer is viewed
◆ PixelBuffer() [3/3]
| PixelBuffer | ( | const PixelBuffer & | _other | ) |
Copy constructor. Copies of a view share the same buffer.
- Parameters
-
[in] _other View to copy
◆ ~PixelBuffer()
| ~PixelBuffer | ( | ) |
Destructor. Does not free the buffer.
Member Function Documentation
◆ Data()
| unsigned char * Data | ( | ) | const |
Get a pointer to the first byte of the buffer. The pointer is writable even through a const view: this is a span, not a read only view.
- Returns
- Pointer to the buffer
◆ Format()
| PixelFormat Format | ( | ) | const |
Get the pixel format.
- Returns
- Pixel format
◆ Height()
| unsigned int Height | ( | ) | const |
Get the height in pixels.
- Returns
- Height in pixels
◆ MemorySize()
| std::size_t MemorySize | ( | ) | const |
Get the number of bytes Width x Height pixels of Format need.
- Returns
- Required size in bytes
◆ operator=() [1/2]
|
delete |
Views cannot be rebound.
◆ operator=() [2/2]
|
delete |
Views cannot be rebound.
◆ Size()
| std::size_t Size | ( | ) | const |
Get the size of the buffer in bytes, as given by the caller.
- Returns
- Buffer size in bytes
◆ Valid()
| bool Valid | ( | ) | const |
Check that the buffer can hold a frame: the pointer is not null and Size() is at least MemorySize().
- Returns
- True if a frame can be written into the buffer
◆ Width()
| unsigned int Width | ( | ) | const |
Get the width in pixels.
- Returns
- Width in pixels
The documentation for this class was generated from the following file: