void GraphicsPixmapHoverItem::paint(QPainter *painter,
    const QStyleOptionGraphicsItem *option, QWidget *)
{
    if (pixmap().isNull()) {
        return;
    }

    //此处不能使用static来定义tempPix,因为普通界面和全幅界面使用的图片尺寸不一样
    QPixmap tempPix(pixmap().size());
    tempPix.fill(Qt::transparent);

    QPainter tempPainter(&tempPix);
    tempPainter.setRenderHint(QPainter::SmoothPixmapTransform,
        (transformationMode() == Qt::SmoothTransformation));

    if (m_val > 0) {
        tempPainter.drawPixmap(offset(), m_heroSkinPixmap);

        double percent = 1 - (double)m_val / (double)m_max;
        QRectF rect = QRectF(offset().x(), offset().y(),
            boundingRect().width(), percent * boundingRect().height());

        tempPainter.setClipRect(rect);
        tempPainter.drawPixmap(offset(), pixmap());

        tempPainter.setClipRect(boundingRect());
        tempPainter.drawPixmap(rect.left() - 9, rect.bottom() - 25,
            m_skinChangingFrames[m_currentSkinChangingFrameIndex]);

        //由于可能需要在外部额外处理tempPix,因此必须调用tempPainter.end()
        //来释放tempPainter对tempPix的控制权,否则会出现异常
        tempPainter.end();
        if (isSecondaryAvartarItem()) {
            tempPix = m_playerCardContainer->paintByMask(tempPix);
        }
    }
    else {
        tempPainter.drawPixmap(offset(), pixmap());
    }

    if (option->state & QStyle::State_Selected) {
        qt_graphicsItem_highlightSelected(this, &tempPainter, option);
    }

    painter->drawPixmap(0, 0, tempPix);
}
void GraphicsPixmapHoverItem::paint(QPainter *painter,
    const QStyleOptionGraphicsItem *option, QWidget *)
{
    if (pixmap().isNull()) {
        return;
    }

    QPixmap tempPix(pixmap().size());
    tempPix.fill(Qt::transparent);

    QPainter tempPainter(&tempPix);
    tempPainter.setRenderHint(QPainter::SmoothPixmapTransform,
        (transformationMode() == Qt::SmoothTransformation));

    if (m_val > 0) {
        tempPainter.drawPixmap(offset(), m_heroSkinPixmap);

        double percent = 1 - (double)m_val / (double)m_max;
        QRectF rect = QRectF(offset().x(), offset().y(),
            boundingRect().width(), percent * boundingRect().height());

        tempPainter.setClipRect(rect);
        tempPainter.drawPixmap(offset(), pixmap());

        tempPainter.setClipRect(boundingRect());
        tempPainter.drawPixmap(rect.left() - 9, rect.bottom() - 25,
            m_skinChangingFrames[m_currentSkinChangingFrameIndex]);

        // For tempPix may be processed outside, we should call tempPainter.end() to
        // release its control of tempPix, or an exception will occur
        tempPainter.end();
        if (!isAvatarOfDashboard() && isSecondaryAvartarItem()) {
            tempPix = m_playerCardContainer->paintByMask(tempPix);
        }
    } else {
        tempPainter.drawPixmap(offset(), pixmap());
    }

    if (option->state & QStyle::State_Selected) {
        qt_graphicsItem_highlightSelected(this, &tempPainter, option);
    }

    painter->drawPixmap(0, 0, tempPix);
}