#include <layeroperations.hh>
|
| | Operations1bppClipped (ColormapProvider::Ptr colormapProvider) |
| |
| int | getBpp () override |
| |
| Scroom::Utils::Stuff | cacheZoom (const ConstTile::Ptr &tile, int zoom, Scroom::Utils::Stuff &cache) override |
| |
| void | reduce (Tile::Ptr target, ConstTile::Ptr source, int x, int y) override |
| |
| void | initializeCairo (cairo_t *cr) override |
| |
| void | drawState (cairo_t *cr, TileState s, Scroom::Utils::Rectangle< double > viewArea) 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 |
| |
| virtual Scroom::Utils::Stuff | cache (const ConstTile::Ptr &tile) |
| |
◆ Operations1bppClipped()
◆ cacheZoom()
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
-
| tile | the Tile for which caching is requested |
| zoom | the requested zoom level |
| cache | the output of cache(const ConstTile::Ptr) |
Reimplemented from CommonOperations.
849 const int pixelSize = 1 << (-zoom);
850 const int outputWidth = tile->width / pixelSize;
851 const int outputHeight = tile->height / pixelSize;
853 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, outputWidth);
854 boost::shared_ptr<unsigned char>
const data =
shared_malloc(stride * outputHeight);
857 unsigned char* row = data.get();
858 for(
int j = 0; j < outputHeight; j++, row += stride)
860 auto* pixel =
reinterpret_cast<uint32_t*
>(row);
861 for(
int i = 0; i < outputWidth; i++)
865 for(
int y = 0; y < pixelSize; y++)
867 const byte* inputByte = tile->data.get() + (j * pixelSize + y) * tile->width / 8 + pixelSize * i / 8;
868 byte const inputBit = pixelSize * i % 8;
872 for(
int x = 0; x < pixelSize; x++, ++bit)
885 *pixel =
colormap->colors[sum].getARGB32();
◆ create()
◆ getBpp()
| int Operations1bppClipped::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.
◆ 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.
896 const int sourceStride = source->width / 8;
897 const byte* sourceBase = source->data.get();
899 const int targetStride = target->width / 8;
900 byte* targetBase = target->data.get() + target->height * y * targetStride / 8 + target->width * x / 8 / 8;
902 for(
int j = 0; j < source->height / 8; j++, targetBase += targetStride, sourceBase += sourceStride * 8)
905 const byte* sourcePtr = sourceBase;
908 for(
int i = 0; i < source->width / 8; i++, sourcePtr++, targetPtr++)
917 const byte*
current = sourcePtr;
919 for(
int k = 0; k < 8; k++,
current += sourceStride)
924 targetPtr.set((sum > 0) ? 1 : 0);
◆ colormapProvider
The documentation for this class was generated from the following files: