/*
    QAD - Qt ADvanced

    Ivan Pelipenko peri4ko@yandex.ru

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "mapview_types.h"

#include <QString>

using namespace MapViewTypes;


QString TileIndex ::hashName() const {
	return QString("%1.%2.%3").arg(z).arg(x).arg(y);
}


quint64 TileIndex::hash() const {
	union _Hash {
		quint64 ret;
		struct {
			quint64 z: 8;
			quint64 x: 24;
			quint64 y: 24;
		};
	};
	_Hash h;
	h.ret = 0;
	h.z   = z;
	h.x   = x;
	h.y   = y;
	return h.ret;
}


QString TileIndex::cacheDir() const {
	return QString::number(qHash(hash()) % 256);
};


bool TilePixmap::isEmpty() const {
	return pixmap.isNull();
}


int TilePixmap::pixmapBytes() const {
	return pixmap.width() * pixmap.height() * pixmap.depth() / 8;
}
