Пример #1
0
TEST_F(Device, IsCached)
{
    auto buf_ptr = std::make_unique<char[]>(4096);
    void *buf = buf_ptr.get();

    for (unsigned int heapMask : m_allHeaps) {
        SCOPED_TRACE(::testing::Message() << "heap " << heapMask);
        int map_fd = -1;
        unsigned int flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;

        ASSERT_EQ(0, ion_alloc_fd(m_ionFd, 4096, 0, heapMask, flags, &map_fd));
        ASSERT_GE(map_fd, 0);

        void *ptr;
        ptr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0);
        ASSERT_TRUE(ptr != NULL);

        dirtyCache(ptr, 4096);

        readDMA(map_fd, buf, 4096);

        bool same = true;
        for (int i = 4096-16; i >= 0; i -= 16)
            if (((char *)buf)[i] != i)
                same = false;
        ASSERT_FALSE(same);

        ASSERT_EQ(0, munmap(ptr, 4096));
        ASSERT_EQ(0, close(map_fd));
    }
}
Пример #2
0
TEST_F(Device, DMAWrite)
{
    auto alloc_ptr = std::make_unique<char[]>(8192 + 1024);
    void *buf = (void *)(ALIGN((unsigned long)alloc_ptr.get(), 4096) + 1024);

    for (int i = 0; i < 4096; i++)
        ((char *)buf)[i] = i;

    for (unsigned int heapMask : m_allHeaps) {
        SCOPED_TRACE(::testing::Message() << "heap " << heapMask);
        int map_fd = -1;
        unsigned int flags = 0;

        ASSERT_EQ(0, ion_alloc_fd(m_ionFd, 4096, 0, heapMask, flags, &map_fd));
        ASSERT_GE(map_fd, 0);

        void *ptr;
        ptr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0);
        ASSERT_TRUE(ptr != NULL);

        dirtyCache(ptr, 4096);

        writeDMA(map_fd, buf, 4096);

        for (int i = 0; i < 4096; i++)
            ASSERT_EQ((char)i, ((char *)ptr)[i]) << i;

        ASSERT_EQ(0, munmap(ptr, 4096));
        ASSERT_EQ(0, close(map_fd));
    }
}
Пример #3
0
void QDeclarativeTextEdit::loadCursorDelegate()
{
    Q_D(QDeclarativeTextEdit);
    if(d->cursorComponent->isLoading())
        return;
    d->cursor = qobject_cast<QDeclarativeItem*>(d->cursorComponent->create(qmlContext(this)));
    if(d->cursor){
        connect(d->control, SIGNAL(cursorPositionChanged()),
                this, SLOT(moveCursorDelegate()));
        d->control->setCursorWidth(0);
        dirtyCache(cursorRect());
        QDeclarative_setParent_noEvent(d->cursor, this);
        d->cursor->setParentItem(this);
        d->cursor->setHeight(QFontMetrics(d->font).height());
        moveCursorDelegate();
    }else{
        qWarning() << QLatin1String("Error loading cursor delegate for TextEdit:") + objectName();
    }
}
Пример #4
0
void QDeclarativeTextEdit::setCursorDelegate(QDeclarativeComponent* c)
{
    Q_D(QDeclarativeTextEdit);
    if(d->cursorComponent){
        if(d->cursor){
            disconnect(d->control, SIGNAL(cursorPositionChanged()),
                    this, SLOT(moveCursorDelegate()));
            d->control->setCursorWidth(-1);
            dirtyCache(cursorRect());
            delete d->cursor;
            d->cursor = 0;
        }
    }
    d->cursorComponent = c;
    if(c && c->isReady()){
        loadCursorDelegate();
    }else{
        if(c)
            connect(c, SIGNAL(statusChanged()),
                    this, SLOT(loadCursorDelegate()));
    }

    emit cursorDelegateChanged();
}
Пример #5
0
void QDeclarativeTextEdit::updateImgCache(const QRectF &r)
{
    dirtyCache(r.toRect());
    emit update();
}