Scroom  0.14
LayerOperations Class Referenceabstract

#include <tiledbitmapinterface.hh>

Inheritance diagram for LayerOperations:
Inheritance graph
Collaboration diagram for LayerOperations:
Collaboration graph

Public Types

using Ptr = boost::shared_ptr< LayerOperations >
 

Public Member Functions

virtual int getBpp ()=0
 
virtual void initializeCairo (cairo_t *cr)=0
 
virtual void draw (cairo_t *cr, const ConstTile::Ptr &tile, Scroom::Utils::Rectangle< double > tileArea, Scroom::Utils::Rectangle< double > viewArea, int zoom, Scroom::Utils::Stuff cache)=0
 
virtual void drawState (cairo_t *cr, TileState s, Scroom::Utils::Rectangle< double > viewArea)=0
 
virtual Scroom::Utils::Stuff cache (const ConstTile::Ptr &tile)
 
virtual Scroom::Utils::Stuff cacheZoom (const ConstTile::Ptr &tile, int zoom, Scroom::Utils::Stuff &cache)
 
virtual void reduce (Tile::Ptr target, ConstTile::Ptr source, int x, int y)=0
 

Additional Inherited Members

- Private Member Functions inherited from Interface
 Interface ()=default
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
 Interface (const Interface &&)=delete
 
Interfaceoperator= (const Interface &&)=delete
 
virtual ~Interface ()=default
 

Detailed Description

Operations on a layer in the TiledBitmap

Tasks of LayerOperations objects include:

  • Reducing the given Layer by a factor of 8, producing data that the LayerOperations object of the next layer will understand
  • Draw any portion of the given Layer, at the requested zoom level
See also
Layer

Member Typedef Documentation

◆ Ptr

using LayerOperations::Ptr = boost::shared_ptr<LayerOperations>

Member Function Documentation

◆ cache()

virtual Scroom::Utils::Stuff LayerOperations::cache ( const ConstTile::Ptr tile)
inlinevirtual

Cache data for use during later cacheZoom() calls.

This function is called for a given tile, and then the results are passed to the cacheZoom() function. Because draw() is called relatively frequently (i.e. when scrolling), it is recommended to do cpu-intensive work in the cache() and cacheZoom() functions, and then re-use the data to make the draw() faster.

The default implementation returns an empty reference, meaning nothing is cached. As a result, the draw() function will receive an empty reference.

Parameters
tilethe Tile for which caching is requested

Reimplemented in OperationsCMYK4, OperationsCMYK8, OperationsCMYK16, OperationsCMYK32, OperationsColormapped, Operations, Operations24bpp, Operations8bpp, and Operations1bpp.

127  {
128  UNUSED(tile);
129  return {};
130  }

Referenced by cacheZoom(), and Operations1bppClipped::cacheZoom().

Here is the caller graph for this function:

◆ cacheZoom()

virtual Scroom::Utils::Stuff LayerOperations::cacheZoom ( const ConstTile::Ptr tile,
int  zoom,
Scroom::Utils::Stuff cache 
)
inlinevirtual

Cache data for use during later draw() calls.

This function is called for a given tile and zoom level, and then the results are passed to the draw() function. Because draw() is called relatively frequently (i.e. when scrolling), it is recommended to do cpu-intensive work in the cache() and cacheZoom() functions, and then re-use the data to make the draw() faster.

The default implementation returns an empty reference, meaning nothing is cached. As a result, the draw() function will receive an empty reference.

Parameters
tilethe Tile for which caching is requested
zoomthe requested zoom level
cachethe output of cache(const ConstTile::Ptr)

Reimplemented in Operations1bppClipped, and CommonOperations.

151  {
152  UNUSED(tile);
153  UNUSED(zoom);
154  UNUSED(cache);
155  return {};
156  }
Here is the call graph for this function:

◆ draw()

virtual void LayerOperations::draw ( cairo_t *  cr,
const ConstTile::Ptr tile,
Scroom::Utils::Rectangle< double >  tileArea,
Scroom::Utils::Rectangle< double >  viewArea,
int  zoom,
Scroom::Utils::Stuff  cache 
)
pure virtual

Draw the given tileArea into the given viewArea at the requested zoom level

Parameters
crThe canvas on which to draw
tileThe tile to take data from
tileAreaArea of the tile that needs to be drawn
viewAreaArea of the canvas that the tile needs to be drawn in
zoomThe requested zoom level. One pixel of your presentation should have size 2**zoom when drawn. zoom will be negative for all but the first layer.
cacheDepending on whether the cacheZoom() function finished already, this may either be an empty reference, or a reference to the value returned by cacheZoom()

Implemented in Operations, Operations8bpp, Operations1bpp, CommonOperations, and DummyLayerOperations.

◆ drawState()

virtual void LayerOperations::drawState ( cairo_t *  cr,
TileState  s,
Scroom::Utils::Rectangle< double >  viewArea 
)
pure virtual

Draw the given state into the given viewArea

The associated tile is likely not loaded or not initialized or in whatever other TileState that doesn't allow its contents to be drawn.

Something needs to be drawn in the given viewArea anyway. Implementors might want to just draw an empty rectangle, maybe color-coded to reflect the state of the tile.

Implemented in CommonOperations, and DummyLayerOperations.

◆ getBpp()

virtual int LayerOperations::getBpp ( )
pure virtual

Return the number of bits per pixel that the layer will use.

This number will be used to compute the amount of memory required to store one tile

Implemented in OperationsCMYK4, OperationsCMYK8, OperationsCMYK16, OperationsCMYK32, Operations1bppClipped, OperationsColormapped, Operations, Operations24bpp, Operations8bpp, Operations1bpp, and DummyLayerOperations.

◆ initializeCairo()

virtual void LayerOperations::initializeCairo ( cairo_t *  cr)
pure virtual

Initialize the canvas for drawing the bitmap

When TiledBitmapInterface::redraw() is called, (a portion of) the Layer needs to be redrawn. TiledBitmap will compute which tiles are involved in the redraw, and call draw() or drawState() for each of them, as appropriate. However, before doing so, it will first call initializeCairo(). You can take this opportunity to set various properties that are needed in all subsequent calls to draw() and drawState(), such as anti-aliasing and line caps.

Implemented in CommonOperations, and DummyLayerOperations.

◆ reduce()

virtual void LayerOperations::reduce ( Tile::Ptr  target,
ConstTile::Ptr  source,
int  x,
int  y 
)
pure virtual

Reduce the source tile by a factor of 8

The target tile will contain data for 8*8 source tiles. Offsets x and y indicate which of those 64 source tiles is currently being processed

Parameters
targetTile that will contain the reduced bitmap
sourceTile that is to be reduced
xx-offset (0..7) of the source tile in the target tile
yy-offset (0..7) of the source tile in the target tile
Note
The target tile belongs to a different layer, and hence possibly has a different bpp than the current one, depending on the LayerSpec given to createTiledBitmap()

Implemented in DummyLayerOperations, OperationsCMYK4, OperationsCMYK8, OperationsCMYK16, OperationsCMYK32, Operations1bppClipped, OperationsColormapped, Operations, Operations24bpp, Operations8bpp, and Operations1bpp.


The documentation for this class was generated from the following file:
UNUSED
#define UNUSED(x)
Definition: unused.hh:10
LayerOperations::cache
virtual Scroom::Utils::Stuff cache(const ConstTile::Ptr &tile)
Definition: tiledbitmapinterface.hh:126