#include "BitmapAtlasStorage.h" #include #include #include "bitmap-blit.h" namespace msdf_atlas { template BitmapAtlasStorage::BitmapAtlasStorage() { } template BitmapAtlasStorage::BitmapAtlasStorage(int width, int height) : bitmap(width, height) { memset((T *) bitmap, 0, sizeof(T)*N*width*height); } template BitmapAtlasStorage::BitmapAtlasStorage(const msdfgen::BitmapConstRef &bitmap) : bitmap(bitmap) { } template BitmapAtlasStorage::BitmapAtlasStorage(msdfgen::Bitmap &&bitmap) : bitmap((msdfgen::Bitmap &&) bitmap) { } template BitmapAtlasStorage::BitmapAtlasStorage(const BitmapAtlasStorage &orig, int width, int height) : bitmap(width, height) { memset((T *) bitmap, 0, sizeof(T)*N*width*height); blit(bitmap, orig.bitmap, 0, 0, 0, 0, std::min(width, orig.bitmap.width()), std::min(height, orig.bitmap.height())); } template BitmapAtlasStorage::BitmapAtlasStorage(const BitmapAtlasStorage &orig, int width, int height, const Remap *remapping, int count) : bitmap(width, height) { memset((T *) bitmap, 0, sizeof(T)*N*width*height); for (int i = 0; i < count; ++i) { const Remap &remap = remapping[i]; blit(bitmap, orig.bitmap, remap.target.x, remap.target.y, remap.source.x, remap.source.y, remap.width, remap.height); } } template BitmapAtlasStorage::operator msdfgen::BitmapConstRef() const { return bitmap; } template BitmapAtlasStorage::operator msdfgen::BitmapRef() { return bitmap; } template BitmapAtlasStorage::operator msdfgen::Bitmap() && { return (msdfgen::Bitmap &&) bitmap; } template template void BitmapAtlasStorage::put(int x, int y, const msdfgen::BitmapConstRef &subBitmap) { blit(bitmap, subBitmap, x, y, 0, 0, subBitmap.width, subBitmap.height); } template void BitmapAtlasStorage::get(int x, int y, const msdfgen::BitmapRef &subBitmap) const { blit(subBitmap, bitmap, 0, 0, x, y, subBitmap.width, subBitmap.height); } }