Grok  9.5.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
grk::SparseCanvas< LBW, LBH > Class Template Reference

#include <SparseCanvas.h>

Inheritance diagram for grk::SparseCanvas< LBW, LBH >:
grk::ISparseCanvas

Public Member Functions

 SparseCanvas (grkRectU32 bds)
 SparseCanvas constructor. More...
 
 SparseCanvas (uint32_t width, uint32_t height)
 SparseCanvas constructor. More...
 
 ~SparseCanvas ()
 
bool read (uint8_t resno, eBandOrientation bandOrientation, grkRectU32 window, int32_t *dest, const uint32_t dest_col_stride, const uint32_t dest_line_stride, bool forgiving)
 Read the content of a rectangular window of the sparse buffer into a user buffer. More...
 
bool write (uint8_t resno, eBandOrientation bandOrientation, grkRectU32 window, const int32_t *src, const uint32_t src_col_stride, const uint32_t src_line_stride, bool forgiving)
 Write the content of a rectangular window into the sparse buffer from a user buffer. More...
 
bool alloc (grkRectU32 win, bool zeroOutBuffer)
 Allocate all blocks for a rectangular window into the sparse buffer from a user buffer. More...
 
- Public Member Functions inherited from grk::ISparseCanvas
virtual ~ISparseCanvas ()=default
 

Private Member Functions

SparseBlockgetBlock (uint32_t block_x, uint32_t block_y)
 
bool is_window_valid (grkRectU32 win)
 Returns whether window bounds are valid (non empty and within bounds) More...
 
bool read_or_write (uint8_t resno, grkRectU32 win, int32_t *buf, const uint32_t buf_col_stride, const uint32_t buf_line_stride, bool forgiving, bool is_read_op)
 

Private Attributes

const uint32_t block_width
 
const uint32_t block_height
 
SparseBlock ** data_blocks
 
grkRectU32 bounds
 
grkRectU32 grid_bounds
 

Constructor & Destructor Documentation

◆ SparseCanvas() [1/2]

template<uint32_t LBW, uint32_t LBH>
grk::SparseCanvas< LBW, LBH >::SparseCanvas ( grkRectU32  bds)
inline

◆ SparseCanvas() [2/2]

template<uint32_t LBW, uint32_t LBH>
grk::SparseCanvas< LBW, LBH >::SparseCanvas ( uint32_t  width,
uint32_t  height 
)
inline

SparseCanvas constructor.

Parameters
widthtotal width of the array.
heighttotal height of the array
Returns
a new sparse buffer instance, or nullptr in case of failure.

◆ ~SparseCanvas()

template<uint32_t LBW, uint32_t LBH>
grk::SparseCanvas< LBW, LBH >::~SparseCanvas ( )
inline

Member Function Documentation

◆ alloc()

template<uint32_t LBW, uint32_t LBH>
bool grk::SparseCanvas< LBW, LBH >::alloc ( grkRectU32  window,
bool  zeroOutBuffer 
)
inlinevirtual

Allocate all blocks for a rectangular window into the sparse buffer from a user buffer.

Blocks intersecting the window are allocated

Parameters
windowwindow to write into the sparse buffer.
zeroOutBuffermemset buffer to zero if true
Returns
true in case of success.

Implements grk::ISparseCanvas.

References grk::SparseCanvas< LBW, LBH >::block_height, grk::SparseCanvas< LBW, LBH >::block_width, grk::grkRect< T >::contains(), grk::SparseCanvas< LBW, LBH >::data_blocks, grk::SparseCanvas< LBW, LBH >::getBlock(), grk::SparseCanvas< LBW, LBH >::grid_bounds, grk::GRK_ERROR(), grk::SparseCanvas< LBW, LBH >::is_window_valid(), grk::grkRect< T >::width(), grk::grkRect< T >::x0, grk::grkRect< T >::x1, grk::grkRect< T >::y0, and grk::grkRect< T >::y1.

◆ getBlock()

template<uint32_t LBW, uint32_t LBH>
SparseBlock* grk::SparseCanvas< LBW, LBH >::getBlock ( uint32_t  block_x,
uint32_t  block_y 
)
inlineprivate

◆ is_window_valid()

template<uint32_t LBW, uint32_t LBH>
bool grk::SparseCanvas< LBW, LBH >::is_window_valid ( grkRectU32  win)
inlineprivate

Returns whether window bounds are valid (non empty and within bounds)

Parameters
winwindow bounds
Returns
true or false.

References grk::SparseCanvas< LBW, LBH >::bounds, grk::grkRect< T >::x0, grk::grkRect< T >::x1, grk::grkRect< T >::y0, and grk::grkRect< T >::y1.

Referenced by grk::SparseCanvas< LBW, LBH >::alloc(), and grk::SparseCanvas< LBW, LBH >::read_or_write().

◆ read()

template<uint32_t LBW, uint32_t LBH>
bool grk::SparseCanvas< LBW, LBH >::read ( uint8_t  resno,
eBandOrientation  bandOrientation,
grkRectU32  window,
int32_t *  dest,
const uint32_t  dest_col_stride,
const uint32_t  dest_line_stride,
bool  forgiving 
)
inlinevirtual

Read the content of a rectangular window of the sparse buffer into a user buffer.

Windows not written with write() are read as 0.

Parameters
windowwindow to read from sparse buffer.
destuser buffer to fill. Must be at least sizeof(int32) * ( (y1 - y0 - 1) * dest_line_stride + (x1 - x0 - 1) * dest_col_stride + 1) bytes large.
dest_col_stridespacing (in elements, not in bytes) in x dimension between consecutive elements of the user buffer.
dest_line_stridespacing (in elements, not in bytes) in y dimension between consecutive elements of the user buffer.
forgivingif set to TRUE and the window is invalid, true will still be returned.
Returns
true in case of success.

Implements grk::ISparseCanvas.

References grk::SparseCanvas< LBW, LBH >::read_or_write().

◆ read_or_write()

template<uint32_t LBW, uint32_t LBH>
bool grk::SparseCanvas< LBW, LBH >::read_or_write ( uint8_t  resno,
grkRectU32  win,
int32_t *  buf,
const uint32_t  buf_col_stride,
const uint32_t  buf_line_stride,
bool  forgiving,
bool  is_read_op 
)
inlineprivate

◆ write()

template<uint32_t LBW, uint32_t LBH>
bool grk::SparseCanvas< LBW, LBH >::write ( uint8_t  resno,
eBandOrientation  bandOrientation,
grkRectU32  window,
const int32_t *  src,
const uint32_t  src_col_stride,
const uint32_t  src_line_stride,
bool  forgiving 
)
inlinevirtual

Write the content of a rectangular window into the sparse buffer from a user buffer.

Blocks intersecting the window are allocated, if not already done.

Parameters
window: window to write to buffer
srcuser buffer to fill. Must be at least sizeof(int32) * ( (y1 - y0 - 1) * src_line_stride + (x1 - x0 - 1) * src_col_stride + 1) bytes large.
src_col_stridespacing (in elements, not in bytes) in x dimension between consecutive elements of the user buffer.
src_line_stridespacing (in elements, not in bytes) in y dimension between consecutive elements of the user buffer.
forgivingif set to TRUE and the window is invalid, true will still be returned.
Returns
true in case of success.

Implements grk::ISparseCanvas.

References grk::SparseCanvas< LBW, LBH >::read_or_write().

Member Data Documentation

◆ block_height

template<uint32_t LBW, uint32_t LBH>
const uint32_t grk::SparseCanvas< LBW, LBH >::block_height
private

◆ block_width

template<uint32_t LBW, uint32_t LBH>
const uint32_t grk::SparseCanvas< LBW, LBH >::block_width
private

◆ bounds

template<uint32_t LBW, uint32_t LBH>
grkRectU32 grk::SparseCanvas< LBW, LBH >::bounds
private

◆ data_blocks

template<uint32_t LBW, uint32_t LBH>
SparseBlock** grk::SparseCanvas< LBW, LBH >::data_blocks
private

◆ grid_bounds

template<uint32_t LBW, uint32_t LBH>
grkRectU32 grk::SparseCanvas< LBW, LBH >::grid_bounds
private

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