示例#1
0
void Stage::process()
{
    cppassist::debug(1, "gloperate") << this->qualifiedName() << ": processing";

    if (m_timeMeasurement)
    {
        // Get currently used queries
        auto usedStartQuery   = m_useQueryPairOne ? Query::PairOneStart : Query::PairTwoStart;
        auto usedEndQuery     = m_useQueryPairOne ? Query::PairOneEnd   : Query::PairTwoEnd;
        auto unusedStartQuery = m_useQueryPairOne ? Query::PairTwoStart : Query::PairOneStart;
        auto unusedEndQuery   = m_useQueryPairOne ? Query::PairTwoEnd   : Query::PairOneEnd;

        // Start CPU time measurement
        auto cpu_start = std::chrono::high_resolution_clock::now();

        // Start GPU time measurement
        gl::glQueryCounter(m_queries[unusedStartQuery], gl::GL_TIMESTAMP);

        // Execute stage
        onProcess();

        // Stop CPU time measurement
        auto cpu_end = std::chrono::high_resolution_clock::now();
        m_lastCPUDuration = m_currentCPUDuration;
        m_currentCPUDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(cpu_end - cpu_start).count();

        // Stop GPU time measurement
        gl::glQueryCounter(m_queries[unusedEndQuery], gl::GL_TIMESTAMP);

        // Get GPU values from last frame
        gl::GLuint64 gpu_start, gpu_end;
        gl::glGetQueryObjectui64v(m_queries[usedStartQuery], gl::GL_QUERY_RESULT, &gpu_start);
        gl::glGetQueryObjectui64v(m_queries[usedEndQuery], gl::GL_QUERY_RESULT, &gpu_end);
        m_lastGPUDuration = gpu_end - gpu_start;

        // Switch queries for next frame
        m_useQueryPairOne = !m_useQueryPairOne;

        // Emit measured times
        if (m_resultAvailable) {
            timeMeasured(m_lastCPUDuration, m_lastGPUDuration);
        } else m_resultAvailable = true;
    }
    else
    {
        onProcess();
    }

    for (auto input : m_inputs)
    {
        input->setChanged(false);
    }
}
示例#2
0
Widget::Widget(QWidget *parent)
	: QWidget(parent)
	, ui(new Ui::Widget)
//	, m_thread() // por default
	, m_thread( this )
	, m_doProcess(false)
{

    ui->setupUi(this);

    ui->progressBar->hide();
	enum { MAX_LOOP = 10*1000*1000};
        ui->maxloopEdit->setText( QString::number(MAX_LOOP) );

	// signal da classe QThread(base)
	connect( &m_thread, SIGNAL(finished()),
					this, SLOT(posProcess()));

	// signal da minha derivada:
	connect( &m_thread , SIGNAL(progress() ),
					this, SLOT (onProcess()) );
}
void StemmedFileProcessingDialog::processFiles(const QString &inFile, const QString &outFile)
{
    ui->cbxReading->setText(ui->cbxReading->text() + " " + inFile);
    ui->cbxWriting->setText(ui->cbxWriting->text() + " " + outFile);
    this->in = inFile;
    this->out = outFile;

    QThread* t = new QThread(this);
    StemmedFileParserController* controller = new StemmedFileParserController(this);
    controller->moveToThread(t);
    t->start();
    QObject::connect(this, SIGNAL(read(QString)), controller, SLOT(onRead(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(process()), controller, SLOT(onProcess()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(write(QString)), controller, SLOT(onWrite(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(generateHistograms(QString)), controller, SLOT(onGenerateHistograms(QString)), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(readDone(bool)), this, SLOT(onReadDone(bool)), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(processDone()), this, SLOT(onProcessDone()), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(writeDone(bool)), this, SLOT(onWriteDone(bool)), Qt::QueuedConnection);
    QObject::connect(controller, SIGNAL(generateHistogramsDone(bool, QString)), this, SLOT(onGenerateHistogramsDone(bool, QString)), Qt::QueuedConnection);
    emit read(this->in);

    this->show();
}
示例#4
0
void Widget::process(const WidgetEvents & events)
{
	// check automatic size.
	if (isAutoManagingWidth() || isAutoManagingHeight())
	{
		sf::Vector2f autoSize = getAutomaticSize();
		setSize(isAutoManagingWidth() ? autoSize.x : getSize().x, isAutoManagingHeight() ? autoSize.y : getSize().y);
	}

	// clear click flags for all buttons.
	myIsClicked = 0;

	// set mouse-over flag. mouse position is already pre-transformed.
	bool mouseOver = events.mouseFocus && checkMouseover(events.mousePosition);

	if (myIsMouseOver != mouseOver)
	{
		myIsMouseOver = mouseOver;

		if (mouseOver)
		{
			onMouseOver();
		}
		else
		{
			onMouseAway();
		}
	}

	// analyze container events to find state changes.
	for (auto it = events.conEvents.mouseEvents.begin(); it != events.conEvents.mouseEvents.end(); ++it)
	{
		ContainerEvents::MouseEvent event = *it;
		MouseBitmask buttonMask = convertMouseButtonBitmask(event.button);

		sf::Vector2f convPos = events.transform.getInverse().transformPoint(event.position);

		// check if mouse is over widget (and widget is not obstructed).
		if (events.mouseFocus && checkMouseover(convPos))
		{
			// handle mouse presses/releases on the widget, check for successful click.
			if (event.isPress)
			{
				// bring widget to front on left mouse click.
				//if (event.button == sf::Mouse::Left)
				//	sendToFront();

				// add mouse button to bitmask.
				myIsMouseDown |= buttonMask;
				onMouseDown(convPos, event.button);
			}
			else if (myIsMouseDown & buttonMask)
			{
				myIsClicked |= buttonMask;
				onClick(convPos, event.button);
			}
		}

		// handle mouse button release.
		if (!event.isPress)
		{
			// remove mouse button from bitmask.
			if (myIsMouseDown & buttonMask)
			{
				myIsMouseDown &= ~buttonMask;
				onMouseUp(convPos, event.button);
			}
		}

	}

	// now process widget events.
	onProcess(events);
}