mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -07:00
Use QPixmapCache for card images
Drop CardInfo’s own pixmap caches; use QPixmapCache instead. Use QPixmap references instead of pointers. Being stored in QPixmapCache, all card images are now subjected to QPixmapCache’s size limit
This commit is contained in:
parent
b96104bed4
commit
f88621fd97
5 changed files with 71 additions and 69 deletions
|
|
@ -90,15 +90,11 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
qreal scaleFactor = translatedSize.width() / boundingRect().width();
|
||||
|
||||
CardInfo *imageSource = facedown ? db->getCard() : info;
|
||||
QPixmap *translatedPixmap = imageSource->getPixmap(translatedSize.toSize());
|
||||
QPixmap translatedPixmap;
|
||||
imageSource->getPixmap(translatedSize.toSize(), translatedPixmap);
|
||||
painter->save();
|
||||
QColor bgColor = Qt::transparent;
|
||||
if (translatedPixmap) {
|
||||
painter->save();
|
||||
transformPainter(painter, translatedSize, angle);
|
||||
painter->drawPixmap(QPointF(0, 0), *translatedPixmap);
|
||||
painter->restore();
|
||||
} else {
|
||||
if (translatedPixmap.isNull()) {
|
||||
QString colorStr;
|
||||
if (!color.isEmpty())
|
||||
colorStr = color;
|
||||
|
|
@ -121,6 +117,11 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
bgColor = QColor(250, 190, 30);
|
||||
else
|
||||
bgColor = QColor(230, 230, 230);
|
||||
} else {
|
||||
painter->save();
|
||||
transformPainter(painter, translatedSize, angle);
|
||||
painter->drawPixmap(QPointF(0, 0), translatedPixmap);
|
||||
painter->restore();
|
||||
}
|
||||
painter->setBrush(bgColor);
|
||||
QPen pen(Qt::black);
|
||||
|
|
@ -128,7 +129,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
painter->setPen(pen);
|
||||
painter->drawRect(QRectF(1, 1, CARD_WIDTH - 2, CARD_HEIGHT - 2));
|
||||
|
||||
if (!translatedPixmap || settingsCache->getDisplayCardNames() || facedown) {
|
||||
if (translatedPixmap.isNull() || settingsCache->getDisplayCardNames() || facedown) {
|
||||
painter->save();
|
||||
transformPainter(painter, translatedSize, angle);
|
||||
painter->setPen(Qt::white);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue