Virtual class to access an image as a Surface. More...

#include <ImageSurface.h>

Inheritance diagram for Graphics::ImageSurface:
Collaboration diagram for Graphics::ImageSurface:

Public Member Functions

 ImageSurface (ImageObject &image, PixelFormat format, size_t bufferSize)
 
Stat stat () const override
 
Size getSize () const override
 
PixelFormat getPixelFormat () const override
 
bool setAddrWindow (const Rect &rect) override
 
uint8_t * getBuffer (uint16_t minBytes, uint16_t &available) override
 
void commit (uint16_t length) override
 
bool blockFill (const void *data, uint16_t length, uint32_t repeat) override
 
bool writeDataBuffer (SharedBuffer &data, size_t offset, uint16_t length) override
 
bool setPixel (PackedColor color, Point pt) override
 
bool writePixels (const void *data, uint16_t length) override
 
int readDataBuffer (ReadBuffer &buffer, ReadStatus *status, ReadCallback callback, void *param) override
 Read some pixels. More...
 
void reset () override
 Reset surface ready for more commands. More...
 
bool present (PresentCallback callback, void *param) override
 Present surface to display device. More...
 
bool fillRect (PackedColor color, const Rect &rect) override
 
void write (MetaWriter &meta) const override
 
- Public Member Functions inherited from Graphics::Surface
void write (MetaWriter &meta) const override
 
virtual Type getType () const =0
 
bool writePixel (PackedColor color)
 
bool writePixel (Color color)
 
virtual int readDataBuffer (ReadStatusBuffer &buffer, ReadCallback callback=nullptr, void *param=nullptr)
 
virtual bool render (const Object &object, const Rect &location, std::unique_ptr< Renderer > &renderer)
 Start rendering an object. More...
 
bool render (const Object &object, const Rect &location)
 Render an object in one cycle. More...
 
bool execute (std::unique_ptr< Renderer > &renderer)
 Execute a renderer. More...
 
uint16_t width () const
 
uint16_t height () const
 
bool blockFill (PackedColor color, uint32_t repeat)
 
bool clear ()
 
bool fillSmallRect (const Brush &brush, const Rect &location, const Rect &rect)
 Fill a small rectangle using a non-transparent brush. More...
 
bool drawHLine (PackedColor color, uint16_t x0, uint16_t x1, uint16_t y, uint16_t w)
 Draw a simple horizontal line using a filled rectangle. More...
 
bool drawVLine (PackedColor color, uint16_t x, uint16_t y0, uint16_t y1, uint16_t w)
 Draw a simple vertical line using a filled rectangle. More...
 
- Public Member Functions inherited from Graphics::AssetTemplate< AssetType::Surface >
virtual Type type () const override
 
 Asset ()
 
 Asset (ID id)
 
- Public Member Functions inherited from Graphics::Asset
 Asset ()
 
 Asset (ID id)
 
bool operator== (ID id) const
 
ID id () const
 
virtual String getTypeStr () const
 
- Public Member Functions inherited from LinkedObjectTemplate< Asset >
Asset * getNext () const
 
bool insertAfter (Asset *object)
 
Iterator begin () const
 
Iterator end () const
 
Iterator cbegin () const
 
Iterator cend () const
 
- Public Member Functions inherited from LinkedObject
virtual ~LinkedObject ()
 
virtual LinkedObjectnext () const
 
bool insertAfter (LinkedObject *object)
 
bool operator== (const LinkedObject &other) const
 
bool operator!= (const LinkedObject &other) const
 

Protected Member Functions

virtual void read (uint32_t offset, void *buffer, size_t length)=0
 
virtual void write (uint32_t offset, const void *data, size_t length)=0
 

Protected Attributes

ImageObjectimage
 
AddressWindow addressWindow {}
 
Size imageSize
 
size_t imageBytes
 
SharedBuffer buffer
 
PixelFormat pixelFormat
 
uint8_t bytesPerPixel
 

Additional Inherited Members

- Public Types inherited from Graphics::Surface
enum class  Type {
  Memory , File , Device , Drawing ,
  Blend
}
 
using List = LinkedObjectListTemplate< Surface >
 
using OwnedList = OwnedLinkedObjectListTemplate< Surface >
 
using PresentCallback = void(*)(void *param)
 
using ReadCallback = void(*)(ReadBuffer &data, size_t length, void *param)
 Callback for readPixel() operations. More...
 
- Public Types inherited from Graphics::Asset
enum class  Type { XX }
 
using List = LinkedObjectListTemplate< Asset >
 
using OwnedList = OwnedLinkedObjectListTemplate< Asset >
 
using ID = AssetID
 
- Public Types inherited from LinkedObjectTemplate< Asset >
using Iterator = IteratorTemplate< Asset, Asset *, Asset & >
 
using ConstIterator = IteratorTemplate< const Asset, const Asset *, const Asset & >
 
- Static Public Attributes inherited from Graphics::Surface
static constexpr size_t READ_PIXEL_SIZE {3}
 
- Static Public Attributes inherited from Graphics::AssetTemplate< AssetType::Surface >
static constexpr Asset::Type assetType
 

Detailed Description

Virtual class to access an image as a Surface.

Use to create off-screen bitmaps by drawing or copying areas from display memory.

Constructor & Destructor Documentation

◆ ImageSurface()

Graphics::ImageSurface::ImageSurface ( ImageObject image,
PixelFormat  format,
size_t  bufferSize 
)
inline

Member Function Documentation

◆ blockFill()

bool Graphics::ImageSurface::blockFill ( const void *  data,
uint16_t  length,
uint32_t  repeat 
)
overridevirtual

Implements Graphics::Surface.

◆ commit()

void Graphics::ImageSurface::commit ( uint16_t  length)
overridevirtual

Implements Graphics::Surface.

◆ fillRect()

bool Graphics::ImageSurface::fillRect ( PackedColor  color,
const Rect rect 
)
overridevirtual

Reimplemented from Graphics::Surface.

◆ getBuffer()

uint8_t* Graphics::ImageSurface::getBuffer ( uint16_t  minBytes,
uint16_t &  available 
)
overridevirtual

Implements Graphics::Surface.

◆ getPixelFormat()

PixelFormat Graphics::ImageSurface::getPixelFormat ( ) const
inlineoverridevirtual

Implements Graphics::Surface.

◆ getSize()

Size Graphics::ImageSurface::getSize ( ) const
inlineoverridevirtual

Implements Graphics::Surface.

◆ present()

bool Graphics::ImageSurface::present ( PresentCallback  callback,
void *  param 
)
overridevirtual

Present surface to display device.

Parameters
callbackInvoked when surface is available for more commands
paramPassed to callback
Return values
booltrue If callback has been queued, false if surface is empty

Hardware devices will queue buffered commands to the display device then return. The surface will be marked as BUSY. Attempting to call present() on a BUSY surface must return true. If surface is EMPTY (no buffered commands), must return false.

Implements Graphics::Surface.

◆ read()

virtual void Graphics::ImageSurface::read ( uint32_t  offset,
void *  buffer,
size_t  length 
)
protectedpure virtual

◆ readDataBuffer()

int Graphics::ImageSurface::readDataBuffer ( ReadBuffer buffer,
ReadStatus status,
ReadCallback  callback,
void *  param 
)
overridevirtual

Read some pixels.

Parameters
bufferDetails requested format and buffer to read
statusOptional. Stores result of read operation.
callbackOptional. Invoked when read has completed
paramParameters passed to callback
Return values
intNumber of pixels queued for reading (or read); 0 if no further pixels to read, < 0 to try again later

Call setAddrWindow to set up region to be read. Returns true when all pixels have been queued for reading.

Implements Graphics::Surface.

◆ reset()

void Graphics::ImageSurface::reset ( )
inlineoverridevirtual

Reset surface ready for more commands.

Implements Graphics::Surface.

◆ setAddrWindow()

bool Graphics::ImageSurface::setAddrWindow ( const Rect rect)
inlineoverridevirtual

Implements Graphics::Surface.

◆ setPixel()

bool Graphics::ImageSurface::setPixel ( PackedColor  color,
Point  pt 
)
overridevirtual

Implements Graphics::Surface.

◆ stat()

Stat Graphics::ImageSurface::stat ( ) const
inlineoverridevirtual

Implements Graphics::Surface.

◆ write() [1/2]

void Graphics::Surface::write
inlineoverride

◆ write() [2/2]

virtual void Graphics::ImageSurface::write ( uint32_t  offset,
const void *  data,
size_t  length 
)
protectedpure virtual

◆ writeDataBuffer()

bool Graphics::ImageSurface::writeDataBuffer ( SharedBuffer data,
size_t  offset,
uint16_t  length 
)
inlineoverridevirtual

Implements Graphics::Surface.

◆ writePixels()

bool Graphics::ImageSurface::writePixels ( const void *  data,
uint16_t  length 
)
overridevirtual

Reimplemented from Graphics::Surface.

Member Data Documentation

◆ addressWindow

AddressWindow Graphics::ImageSurface::addressWindow {}
protected

◆ buffer

SharedBuffer Graphics::ImageSurface::buffer
protected

◆ bytesPerPixel

uint8_t Graphics::ImageSurface::bytesPerPixel
protected

◆ image

ImageObject& Graphics::ImageSurface::image
protected

◆ imageBytes

size_t Graphics::ImageSurface::imageBytes
protected

◆ imageSize

Size Graphics::ImageSurface::imageSize
protected

◆ pixelFormat

PixelFormat Graphics::ImageSurface::pixelFormat
protected

The documentation for this class was generated from the following file: