#include <layeroperations.hh>
|
| | Operations (ColormapProvider::Ptr colormapProvider, int bpp) |
| |
| int | getBpp () override |
| |
| Scroom::Utils::Stuff | cache (const ConstTile::Ptr &tile) override |
| |
| void | reduce (Tile::Ptr target, ConstTile::Ptr source, int x, int y) override |
| |
| 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) override |
| |
| void | initializeCairo (cairo_t *cr) override |
| |
| void | drawState (cairo_t *cr, TileState s, Scroom::Utils::Rectangle< double > viewArea) override |
| |
| Scroom::Utils::Stuff | cacheZoom (const ConstTile::Ptr &tile, int zoom, Scroom::Utils::Stuff &cache) override |
| |
|
| static Ptr | create (ColormapProvider::Ptr colormapProvider, int bpp) |
| |
| static void | drawPixelValue (cairo_t *cr, int x, int y, int size, int value) |
| |
| static void | drawPixelValue (cairo_t *cr, int x, int y, int size, int value, Color const &bgColor) |
| |
◆ Operations()
◆ cache()
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
-
| tile | the Tile for which caching is requested |
Reimplemented from LayerOperations.
Reimplemented in OperationsColormapped.
592 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, tile->width);
593 boost::shared_ptr<unsigned char>
const data =
shared_malloc(stride * tile->height);
596 unsigned char* row = data.get();
597 for(
int j = 0; j < tile->height; j++, row += stride)
601 auto* pixelOut =
reinterpret_cast<uint32_t*
>(row);
602 for(
int i = 0; i < tile->width; i++)
604 *pixelOut =
colormap->colors[*pixelIn].getARGB32();
Referenced by draw().
◆ create()
◆ draw()
Draw the given tileArea into the given viewArea at the requested zoom level
- Parameters
-
| cr | The canvas on which to draw |
| tile | The tile to take data from |
| tileArea | Area of the tile that needs to be drawn |
| viewArea | Area of the canvas that the tile needs to be drawn in |
| zoom | The 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. |
| cache | Depending on whether the cacheZoom() function finished already, this may either be an empty reference, or a reference to the value returned by cacheZoom() |
Reimplemented from CommonOperations.
691 const int multiplier = 1 << zoom;
693 cairo_select_font_face(cr,
"Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
694 cairo_set_font_size(cr, 12.0);
699 auto offset = tileAreaInt.getTopLeft() - tileArea.
getTopLeft();
700 viewArea += offset * multiplier;
702 for(
int y = 0; y < tileAreaInt.height(); y++)
704 const byte*
const data = tile->data.get();
707 for(
int x = 0; x < tileAreaInt.width(); x++, ++
current)
713 cr, viewArea.
x() + multiplier * x, viewArea.
y() + multiplier * y, multiplier, value,
colormap->colors[value]);
◆ getBpp()
| int Operations::getBpp |
( |
| ) |
|
|
overridevirtual |
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
Implements LayerOperations.
Reimplemented in OperationsColormapped.
◆ reduce()
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
-
| target | Tile that will contain the reduced bitmap |
| source | Tile that is to be reduced |
| x | x-offset (0..7) of the source tile in the target tile |
| y | y-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()
Implements LayerOperations.
Reimplemented in OperationsColormapped.
617 const byte* sourceBase = source->data.get();
619 const int targetMultiplier = 2;
620 const int targetStride = targetMultiplier * target->width /
pixelsPerByte;
622 target->data.get() + target->height * targetStride * y / 8 + targetMultiplier * target->width * x / 8 /
pixelsPerByte;
624 for(
int j = 0; j < source->height / 8; j++, targetBase += targetStride, sourceBase += sourceStride * 8)
627 const byte* sourcePtr = sourceBase;
630 for(
int i = 0; i < source->width / 8; i++, sourcePtr += 8 /
pixelsPerByte, ++targetPtr)
636 const byte* base = sourcePtr;
638 memset(lookup, 0,
sizeof(lookup));
640 for(
int k = 0; k < 8; k++, base += sourceStride)
643 for(
int l = 0; l < 8; l++, ++
current)
650 if(lookup[1] > lookup[0])
655 for(
unsigned c = 2; c <
pixelMask + 1; c++)
657 if(lookup[c] > lookup[first])
662 else if(lookup[c] > lookup[second])
667 if(lookup[second] == 0)
◆ bpp
| const unsigned Operations::bpp |
|
protected |
◆ colormapProvider
◆ pixelMask
| const unsigned Operations::pixelMask |
|
protected |
◆ pixelOffset
| const unsigned Operations::pixelOffset |
|
protected |
◆ pixelsPerByte
| const unsigned Operations::pixelsPerByte |
|
protected |
The documentation for this class was generated from the following files:
xy_type getTopLeft() const
Definition: rectangle.hh:133
value_type x() const
Definition: rectangle.hh:125
const unsigned pixelOffset
Definition: layeroperations.hh:126
const unsigned bpp
Definition: layeroperations.hh:124
const unsigned pixelsPerByte
Definition: layeroperations.hh:125
Definition: bitmap-helpers.hh:61
const unsigned pixelMask
Definition: layeroperations.hh:127
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) override
Definition: layeroperations.cc:161
static unsigned int current
Definition: measure-framerate-callbacks.cc:17
Operations(ColormapProvider::Ptr colormapProvider, int bpp)
Definition: layeroperations.cc:579
boost::shared_ptr< Colormap > Ptr
Definition: colormappable.hh:31
const Colormap::Ptr colormap
Definition: colormaphelpers_test.cc:54
static void drawPixelValue(cairo_t *cr, int x, int y, int size, int value)
Definition: layeroperations.cc:96
boost::shared_ptr< LayerOperations > Ptr
Definition: tiledbitmapinterface.hh:53
value_type y() const
Definition: rectangle.hh:127
boost::shared_ptr< unsigned char > shared_malloc(size_t size)
Definition: layeroperations.cc:28
ColormapProvider::Ptr colormapProvider
Definition: layeroperations.hh:123
Scroom::Utils::Stuff cache(const ConstTile::Ptr &tile) override
Definition: layeroperations.cc:590
Segment< double > roundOutward(Segment< double > s)
Definition: linearsegment.hh:240
void create(NewPresentationInterface *interface)
Definition: loader.cc:175