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.
744{
745 const int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, tile->width);
746 std::shared_ptr<unsigned char>
const data =
shared_malloc(stride * tile->height);
748 const int multiplier = 2;
749
750 unsigned char* row =
data.get();
751 for(int j = 0; j < tile->height; j++, row += stride)
752 {
754 reinterpret_cast<uint16_t const*
>(tile->data.get() + j * multiplier * tile->width /
pixelsPerByte), 0, multiplier *
bpp
755 );
756 auto* pixelOut = reinterpret_cast<uint32_t*>(row);
757 for(int i = 0; i < tile->width; i++)
758 {
760
761 pixelOut++;
762 ++pixelIn;
763 }
764 }
765
767}
uint8_t data
Definition blob-tests.cc:36
uint32_t getARGB32() const
Definition color.hh:112
std::shared_ptr< Colormap > Ptr
Definition colormappable.hh:29
const unsigned bpp
Definition layeroperations.hh:130
const unsigned pixelMask
Definition layeroperations.hh:133
ColormapProvider::Ptr colormapProvider
Definition layeroperations.hh:129
const unsigned pixelOffset
Definition layeroperations.hh:132
const unsigned pixelsPerByte
Definition layeroperations.hh:131
static Ptr create(int width, int height, cairo_format_t format)
Definition bitmap-helpers.cc:13
Definition bitmap-helpers.hh:62
Color mix(const Color &a, const Color &b, double alpha)
Definition color.hh:133
Colormap::Ptr const colormap
Definition colormaphelpers_test.cc:55
std::shared_ptr< unsigned char > shared_malloc(size_t size)
Definition layeroperations.cc:28