qmlfrontend/runqueue.cpp
author unc0rr
Sun, 07 Jan 2018 09:48:26 +0100
branchqmlfrontend
changeset 12884 66171ce586cc
parent 12861 488782d9aba9
permissions -rw-r--r--
Fix referencing missing item
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12861
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     1
#include "runqueue.h"
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     2
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     3
#include "flib.h"
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     4
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     5
extern "C" {
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     6
extern RunEngine_t* flibRunEngine;
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     7
extern ipcToEngineRaw_t* flibIpcToEngineRaw;
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     8
extern ipcSetEngineBarrier_t* flibIpcSetEngineBarrier;
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
     9
extern ipcRemoveBarrierFromEngineQueue_t* flibIpcRemoveBarrierFromEngineQueue;
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    10
}
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    11
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    12
RunQueue::RunQueue(QObject* parent)
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    13
    : QObject(parent)
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    14
{
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    15
}
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    16
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    17
void RunQueue::queue(const GameConfig& config)
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    18
{
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    19
    m_runQueue.prepend(config);
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    20
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    21
    flibIpcSetEngineBarrier();
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    22
    for (const QByteArray& b : m_runQueue.last().config()) {
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    23
        flibIpcToEngineRaw(b.data(), b.size());
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    24
    }
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    25
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    26
    if (m_runQueue.size() == 1)
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    27
        nextRun();
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    28
}
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    29
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    30
void RunQueue::onGameFinished()
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    31
{
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    32
    m_runQueue.pop_front();
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    33
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    34
    nextRun();
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    35
}
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    36
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    37
void RunQueue::nextRun()
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    38
{
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    39
    if (!m_runQueue.isEmpty()) {
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    40
        if (m_runQueue[0].isPreview())
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    41
            emit previewIsRendering();
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    42
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    43
        flibIpcRemoveBarrierFromEngineQueue();
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    44
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    45
        flibRunEngine(m_runQueue[0].argc(), m_runQueue[0].argv());
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    46
    }
488782d9aba9 Recreate uFLRunQueue in Qt, render previews
unc0rr
parents:
diff changeset
    47
}