Exemple #1
0
void BlendBench::unalignedBlendArgb32()
{
    const int dimension = 1024;

    // We use dst aligned by design. We don't want to test all the combination of alignemnt for src and dst.
    // Moreover, it make sense for us to align dst in the implementation because it is accessed more often.
    uchar *dstMemory = static_cast<uchar*>(qMallocAligned((dimension * dimension * sizeof(quint32)), 16));
    QImage destination(dstMemory, dimension, dimension, QImage::Format_ARGB32_Premultiplied);
    destination.fill(0x12345678); // avoid special cases of alpha

    uchar *srcMemory = static_cast<uchar*>(qMallocAligned((dimension * dimension * sizeof(quint32)) + 16, 16));
    QFETCH(int, offset);
    uchar *imageSrcMemory = srcMemory + (offset * sizeof(quint32));

    QImage src(imageSrcMemory, dimension, dimension, QImage::Format_ARGB32_Premultiplied);
    src.fill(0x87654321);

    QPainter painter(&destination);
    QBENCHMARK {
        painter.drawImage(QPoint(), src);
    }

    qFreeAligned(srcMemory);
    qFreeAligned(dstMemory);
}
Exemple #2
0
void QVectorData::free(QVectorData *x, int alignment)
{
    if (alignment > alignmentThreshold())
        qFreeAligned(x);
    else
        qFree(x);
}
Exemple #3
0
static inline void qMapDeallocate(QMapNodeBase *node, int alignment)
{
    if (alignment > qMapAlignmentThreshold())
        qFreeAligned(node);
    else
        ::free(node);
}
Exemple #4
0
void QMapData::continueFreeData(int offset)
{
    Node *e = reinterpret_cast<Node *>(this);
    Node *cur = e->forward[0];
    Node *prev;
    while (cur != e) {
        prev = cur;
        cur = cur->forward[0];
        if (strictAlignment)
            qFreeAligned(reinterpret_cast<char *>(prev) - offset);
        else
            qFree(reinterpret_cast<char *>(prev) - offset);
    }
    delete this;
}
Exemple #5
0
void QMapData::node_delete(Node *update[], int offset, Node *node)
{
    node->forward[0]->backward = node->backward;

    for (int i = 0; i <= topLevel; ++i) {
        if (update[i]->forward[i] != node)
            break;
        update[i]->forward[i] = node->forward[i];
    }
    --size;
    if (strictAlignment)
        qFreeAligned(reinterpret_cast<char *>(node) - offset);
    else
        qFree(reinterpret_cast<char *>(node) - offset);
}
void tst_QGuiMetaType::constructInPlace()
{
    QFETCH(int, typeId);
    int size = QMetaType::sizeOf(typeId);
    void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
    QCOMPARE(QMetaType::construct(typeId, storage, /*copy=*/0), storage);
    QMetaType::destruct(typeId, storage);
    QBENCHMARK {
        for (int i = 0; i < 100000; ++i) {
            QMetaType::construct(typeId, storage, /*copy=*/0);
            QMetaType::destruct(typeId, storage);
        }
    }
    qFreeAligned(storage);
}
void tst_QGuiMetaType::constructInPlaceCopy()
{
    QFETCH(int, typeId);
    int size = QMetaType::sizeOf(typeId);
    void *storage = qMallocAligned(size, 2 * sizeof(qlonglong));
    void *other = QMetaType::create(typeId);
    QCOMPARE(QMetaType::construct(typeId, storage, other), storage);
    QMetaType::destruct(typeId, storage);
    QBENCHMARK {
        for (int i = 0; i < 100000; ++i) {
            QMetaType::construct(typeId, storage, other);
            QMetaType::destruct(typeId, storage);
        }
    }
    QMetaType::destroy(typeId, other);
    qFreeAligned(storage);
}
void QContiguousCacheData::free(QContiguousCacheData *data)
{
    qFreeAligned(data);
}