Пример #1
0
void Renderer::sliceTile(const shared_ptr<MetaTile>& meta, const shared_ptr<Tile>& tile) const
{
	const shared_ptr<MetaIdentifier>& mid = meta->getIdentifier();
	const Cairo::RefPtr<Cairo::Surface>& surface = meta->getData();
	int tx0 = mid->getX();
	int ty0 = mid->getY();

	surface->flush();

	shared_ptr<ImageWriter> writer = getWriter(mid->getImageFormat(), TILE_SIZE, TILE_SIZE);
	Tile::ImageType buffer = boost::make_shared<Tile::ImageType::element_type>();
	// optimized for png images in the default stylesheet
	buffer->reserve(10*1024);
	CairoLayer layer = CairoLayer(writer, buffer);

	const shared_ptr<TileIdentifier>& tid = tile->getIdentifier();
	int dx = (tid->getX() - tx0) * TILE_SIZE;
	int dy = (tid->getY() - ty0) * TILE_SIZE;

	layer.cr->set_source(surface, -dx, -dy);
	layer.cr->paint();

#if DEBUG_BUILD
	printTileId(layer.cr, tile->getIdentifier());
#endif

	writer->write(layer.surface);
	tile->setImage(buffer);
}
Пример #2
0
void Renderer::renderEmptyTile(RenderAttributes& map, const shared_ptr<Tile>& tile)
{
	const shared_ptr<TileIdentifier>& id = tile->getIdentifier();
	shared_ptr<ImageWriter> writer = getWriter(id->getImageFormat(), TILE_SIZE, TILE_SIZE);

	Tile::ImageType buffer = boost::make_shared<Tile::ImageType::element_type>();
	// optimized for png images in the default stylesheet
	buffer->reserve(10*1024);

#if OLD_CAIRO
	renderLock.lock();
#endif

	CairoLayer layer(writer, buffer);
	paintBackground(layer, map.getCanvasStyle());

#if DEBUG_BUILD
	printTileId(layer.cr, tile->getIdentifier());
#endif

#if OLD_CAIRO
	renderLock.unlock();
#endif

	writer->write(layer.surface);
	tile->setImage(buffer);
}