#include <layeroperations.hh>
|
| | OperationsColormapped (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 |
| |
| | Operations (ColormapProvider::Ptr colormapProvider, int bpp) |
| |
| 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 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) |
| |
◆ OperationsColormapped()
◆ 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 Operations.
737 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, tile->width);
738 boost::shared_ptr<unsigned char>
const data =
shared_malloc(stride * tile->height);
740 const int multiplier = 2;
742 unsigned char* row = data.get();
743 for(
int j = 0; j < tile->height; j++, row += stride)
746 reinterpret_cast<uint16_t const*
>(tile->data.get() + j * multiplier * tile->width /
pixelsPerByte), 0, multiplier *
bpp);
747 auto* pixelOut =
reinterpret_cast<uint32_t*
>(row);
748 for(
int i = 0; i < tile->width; i++)
◆ create()
◆ getBpp()
| int OperationsColormapped::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
Reimplemented from Operations.
◆ 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()
Reimplemented from Operations.
763 const int multiplier = 2;
764 const int sourceStride = multiplier * source->width /
pixelsPerByte;
765 const byte* sourceBase = source->data.get();
767 const int targetStride = multiplier * target->width /
pixelsPerByte;
769 target->data.get() + target->height * y * targetStride / 8 + multiplier * target->width * x / 8 /
pixelsPerByte;
771 for(
int j = 0; j < source->height / 8; j++, targetBase += targetStride, sourceBase += sourceStride * 8)
774 const byte* sourcePtr = sourceBase;
777 for(
int i = 0; i < source->width / 8; i++, sourcePtr += 8 * multiplier /
pixelsPerByte, ++targetPtr)
783 const byte* base = sourcePtr;
785 memset(lookup, 0,
sizeof(lookup));
787 for(
int k = 0; k < 8; k++, base += sourceStride)
790 for(
int l = 0; l < 8; l++, ++
current)
798 if(lookup[1] > lookup[0])
803 for(
unsigned c = 2; c <
pixelMask + 1; c++)
805 if(lookup[c] > lookup[first])
810 else if(lookup[c] > lookup[second])
815 if(lookup[second] == 0)
The documentation for this class was generated from the following files: