Interface for a drawing surface. More...

#include <Surface.h>

Inheritance diagram for Graphics::Surface:
Collaboration diagram for Graphics::Surface:

Classes

struct  Stat
 

Public Types

enum  Type {
  Type::Memory, Type::File, Type::Device, Type::Drawing,
  Type::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  Type { 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 & >
 

Public Member Functions

void write (MetaWriter &meta) const override
 
virtual Type getType () const =0
 
virtual Stat stat () const =0
 
virtual Size getSize () const =0
 
virtual PixelFormat getPixelFormat () const =0
 
virtual bool setAddrWindow (const Rect &rect)=0
 
virtual uint8_tgetBuffer (uint16_t minBytes, uint16_t &available)=0
 
virtual void commit (uint16_t length)=0
 
virtual bool blockFill (const void *data, uint16_t length, uint32_t repeat)=0
 
virtual bool writeDataBuffer (SharedBuffer &buffer, size_t offset, uint16_t length)=0
 
virtual bool setPixel (PackedColor color, Point pt)=0
 
virtual bool writePixels (const void *data, uint16_t length)
 
bool writePixel (PackedColor color)
 
bool writePixel (Color color)
 
virtual int readDataBuffer (ReadBuffer &buffer, ReadStatus *status=nullptr, ReadCallback callback=nullptr, void *param=nullptr)=0
 Read some pixels. More...
 
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...
 
virtual void reset ()=0
 Reset surface ready for more commands. More...
 
virtual bool present (PresentCallback callback=nullptr, void *param=nullptr)=0
 Present surface to display device. More...
 
uint16_t width () const
 
uint16_t height () const
 
bool blockFill (PackedColor color, uint32_t repeat)
 
bool clear ()
 
virtual bool fillRect (PackedColor color, const Rect &rect)
 
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 Type type () const =0
 
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
 

Static Public Attributes

static constexpr size_t READ_PIXEL_SIZE {3}
 
- Static Public Attributes inherited from Graphics::AssetTemplate< AssetType::Surface >
static constexpr Asset::Type assetType
 

Detailed Description

Interface for a drawing surface.

Represents a rectangular area of pixels which can be read or written.

A display device has at least one of these, representing the primary display area. More complex devices with large amounts of display memory may allow additional surfaces to be used to perform screen updates by 'flipping' (switching active surface) or fast copies using display hardware.

Member Typedef Documentation

◆ List

◆ OwnedList

◆ PresentCallback

using Graphics::Surface::PresentCallback = void (*)(void* param)

◆ ReadCallback

using Graphics::Surface::ReadCallback = void (*)(ReadBuffer& data, size_t length, void* param)

Callback for readPixel() operations.

Parameters
bufferBuffer passed to readPixel() call

Member Enumeration Documentation

◆ Type

Enumerator
Memory 
File 
Device 
Drawing 
Blend 

Member Function Documentation

◆ blockFill() [1/2]

virtual bool Graphics::Surface::blockFill ( const void *  data,
uint16_t  length,
uint32_t  repeat 
)
pure virtual

◆ blockFill() [2/2]

bool Graphics::Surface::blockFill ( PackedColor  color,
uint32_t  repeat 
)
inline

◆ clear()

bool Graphics::Surface::clear ( )
inline

◆ commit()

virtual void Graphics::Surface::commit ( uint16_t  length)
pure virtual

◆ drawHLine()

bool Graphics::Surface::drawHLine ( PackedColor  color,
uint16_t  x0,
uint16_t  x1,
uint16_t  y,
uint16_t  w 
)

Draw a simple horizontal line using a filled rectangle.

◆ drawVLine()

bool Graphics::Surface::drawVLine ( PackedColor  color,
uint16_t  x,
uint16_t  y0,
uint16_t  y1,
uint16_t  w 
)

Draw a simple vertical line using a filled rectangle.

◆ execute()

bool Graphics::Surface::execute ( std::unique_ptr< Renderer > &  renderer)
inline

Execute a renderer.

Parameters
rendererWill be released when render has completed
Return values
booltrue if render is complete

◆ fillRect()

virtual bool Graphics::Surface::fillRect ( PackedColor  color,
const Rect rect 
)
virtual

Reimplemented in Graphics::ImageSurface.

◆ fillSmallRect()

bool Graphics::Surface::fillSmallRect ( const Brush brush,
const Rect location,
const Rect rect 
)

Fill a small rectangle using a non-transparent brush.

◆ getBuffer()

virtual uint8_t* Graphics::Surface::getBuffer ( uint16_t  minBytes,
uint16_t available 
)
pure virtual

◆ getPixelFormat()

virtual PixelFormat Graphics::Surface::getPixelFormat ( ) const
pure virtual

◆ getSize()

virtual Size Graphics::Surface::getSize ( ) const
pure virtual

◆ getType()

virtual Type Graphics::Surface::getType ( ) const
pure virtual

◆ height()

uint16_t Graphics::Surface::height ( ) const
inline

◆ present()

virtual bool Graphics::Surface::present ( PresentCallback  callback = nullptr,
void *  param = nullptr 
)
pure virtual

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.

Implemented in Graphics::MipiSurface, and Graphics::ImageSurface.

◆ readDataBuffer() [1/2]

virtual int Graphics::Surface::readDataBuffer ( ReadBuffer buffer,
ReadStatus status = nullptr,
ReadCallback  callback = nullptr,
void *  param = nullptr 
)
pure virtual

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.

Implemented in Graphics::MipiSurface, and Graphics::ImageSurface.

◆ readDataBuffer() [2/2]

virtual int Graphics::Surface::readDataBuffer ( ReadStatusBuffer buffer,
ReadCallback  callback = nullptr,
void *  param = nullptr 
)
inlinevirtual

◆ render() [1/2]

bool Graphics::Surface::render ( const Object object,
const Rect location 
)

Render an object in one cycle.

Parameters
surfaceWhere to render the object to
location
Return values
booltrue on success

Use this method for simple renders which should complete in one cycle. Typically used for memory surface renders or where an object is expected to render within a single surface.

◆ render() [2/2]

virtual bool Graphics::Surface::render ( const Object object,
const Rect location,
std::unique_ptr< Renderer > &  renderer 
)
virtual

Start rendering an object.

Parameters
objectWhat to render
locationPlacement information
rendererIf operation cannot be completed in hardware, create a renderer instance to manage the process
Return values
Returntrue on success, false to retry later

Surfaces may override this method to implement alternative rendering using specific hardware features of the display device.

Software renderers should be run by calling surface::execute.

Reimplemented in Graphics::MipiSurface.

◆ reset()

virtual void Graphics::Surface::reset ( )
pure virtual

Reset surface ready for more commands.

Implemented in Graphics::MipiSurface, and Graphics::ImageSurface.

◆ setAddrWindow()

virtual bool Graphics::Surface::setAddrWindow ( const Rect rect)
pure virtual

◆ setPixel()

virtual bool Graphics::Surface::setPixel ( PackedColor  color,
Point  pt 
)
pure virtual

◆ stat()

virtual Stat Graphics::Surface::stat ( ) const
pure virtual

◆ width()

uint16_t Graphics::Surface::width ( ) const
inline

◆ write()

void Graphics::Surface::write ( MetaWriter meta) const
inlineoverridevirtual

Reimplemented from Graphics::Asset.

◆ writeDataBuffer()

virtual bool Graphics::Surface::writeDataBuffer ( SharedBuffer buffer,
size_t  offset,
uint16_t  length 
)
pure virtual

◆ writePixel() [1/2]

bool Graphics::Surface::writePixel ( Color  color)
inline

◆ writePixel() [2/2]

bool Graphics::Surface::writePixel ( PackedColor  color)
inline

◆ writePixels()

virtual bool Graphics::Surface::writePixels ( const void *  data,
uint16_t  length 
)
virtual

Reimplemented in Graphics::ImageSurface.

Member Data Documentation

◆ READ_PIXEL_SIZE

constexpr size_t Graphics::Surface::READ_PIXEL_SIZE {3}
staticconstexpr

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