Example #1
0
void HTMLCanvasElement::reset()
{
    if (m_ignoreReset)
        return;

    resetDirtyRect();

    bool ok;
    bool hadImageBuffer = hasImageBuffer();

    int w = getAttribute(widthAttr).toInt(&ok);
    if (!ok || w < 0)
        w = DefaultWidth;

    int h = getAttribute(heightAttr).toInt(&ok);
    if (!ok || h < 0)
        h = DefaultHeight;

    if (m_contextStateSaver) {
        // Reset to the initial graphics context state.
        m_contextStateSaver->restore();
        m_contextStateSaver->save();
    }

    if (m_context && m_context->is2d())
        toCanvasRenderingContext2D(m_context.get())->reset();

    IntSize oldSize = size();
    IntSize newSize(w, h);

    // If the size of an existing buffer matches, we can just clear it instead of reallocating.
    // This optimization is only done for 2D canvases for now.
    if (hadImageBuffer && oldSize == newSize && m_context && m_context->is2d()) {
        if (!m_didClearImageBuffer)
            clearImageBuffer();
        return;
    }

    setSurfaceSize(newSize);

    if (m_context && m_context->is3d() && oldSize != size())
        toWebGLRenderingContext(m_context.get())->reshape(width(), height());

    if (RenderObject* renderer = this->renderer()) {
        if (renderer->isCanvas()) {
            if (oldSize != size()) {
                toRenderHTMLCanvas(renderer)->canvasSizeChanged();
                if (renderBox() && renderBox()->hasAcceleratedCompositing())
                    renderBox()->contentChanged(CanvasChanged);
            }
            if (hadImageBuffer)
                renderer->setShouldDoFullPaintInvalidation(true);
        }
    }

    WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator end = m_observers.end();
    for (WillBeHeapHashSet<RawPtrWillBeWeakMember<CanvasObserver> >::iterator it = m_observers.begin(); it != end; ++it)
        (*it)->canvasResized(this);
}
Example #2
0
CameraView::CameraView(QWidget *mainwindow, QWidget *parent,int tabIdx, SharedImageBuffer *sharedImageBuffer) :
QWidget(parent),
ui(new Ui::CameraView),
sharedImageBuffer(sharedImageBuffer)
{
	// Setup UI
	ui->setupUi(this);
	
	tabId = tabIdx;
	// Initialize internal flag
	isCameraConnected=false;
	// Set initial GUI state
	ui->frameLabel->setText("No camera connected.");
	ui->imageBufferBar->setValue(0);
	ui->imageBufferLabel->setText("[000/000]");
	ui->captureRateLabel->setText("");
	ui->processingRateLabel->setText("");
	ui->deviceNumberLabel->setText("");
	ui->cameraResolutionLabel->setText("");
	ui->roiLabel->setText("");
	ui->mouseCursorPosLabel->setText("");
	ui->clearImageBufferButton->setDisabled(true);
	// Initialize ImageProcessingFlags structure
	imageProcessingFlags.grayscaleOn=false;
	imageProcessingFlags.smoothOn=false;
	imageProcessingFlags.dilateOn=false;
	imageProcessingFlags.erodeOn=false;
	imageProcessingFlags.flipOn=false;
	imageProcessingFlags.cannyOn=false;
	// Connect signals/slots
	connect(ui->frameLabel, SIGNAL(onMouseMoveEvent()), this, SLOT(updateMouseCursorPosLabel()));
	connect(ui->clearImageBufferButton, SIGNAL(released()), this, SLOT(clearImageBuffer()));
	connect(ui->frameLabel->menu, SIGNAL(triggered(QAction*)), this, SLOT(handleContextMenuAction(QAction*)));
	connect(ui->startStopDatalogger, SIGNAL(released()), this, SLOT(startStopDatalogger()));
	
	connect(this, SIGNAL(setROI(QRect)), mainwindow, SLOT(newROI(QRect)));
	
	// Register type
	qRegisterMetaType<struct ThreadStatisticsData>("ThreadStatisticsData");
	
	id++;
	
	pYarpDataloggerCtrl.initPortSend(YARPPORT_SEND_DATALOGGERCTRL,YARPPORT_RCV_DATALOGGERCTRL,"tcp");
	recordingDlg = false;
	
	isVideo = false;
}
Example #3
0
void Controller::disconnectCamera()
{
	// Stop processing thread
	if(processingThread->isRunning())
		stopProcessingThread();
	// Stop capture thread
	if(captureThread->isRunning())
		stopCaptureThread();
	// Clear image buffer
	clearImageBuffer();
	// Disconnect camera
	captureThread->disconnectCamera();
	// Delete threads
	deleteCaptureThread();
	deleteProcessingThread();
	// Delete image buffer
	deleteImageBuffer();
} // disconnectCamera()
Example #4
0
void CameraView::setVideoResolution(int width,int height)
{
        if(isVideo)
        {
                INFOMSG(("setting new resolution %dx%d",width,height));
                // captureThread->pVideoCapture.setImageSize(width,height);
                captureThread->setVideoResolution(width,height);
                clearImageBuffer();
                // delete processingThread;
                
                // sharedImageBuffer->clear(tabId);
                // if(processingThread->isRunning())
                // stopProcessingThread();
		
		// while(!processingThread->isRunning())
		// {
		// usleep(500);
		// }
                // processingThread = new ProcessingThread(sharedImageBuffer, tabId,id,pSharedParticles);
                // processingThread->resetTracking();
        }
}
Example #5
0
	void keyboard(unsigned char key, int x, int y)
	{
		std::cout << key << std::endl;

		switch (key) 
		{
		   case(27):
			   exit(1);
			   break;
		   case 'w':
			   renderCam->positions->y += .1f;
			   clearImageBuffer(renderCam);
			   iterations = 0;
			   break;
		   case 'x':
			   renderCam->positions->y -= .1f;
			   clearImageBuffer(renderCam);
			   iterations = 0;
			   break;
		   case 'a':
			   renderCam->positions->x += .1f;
			   clearImageBuffer(renderCam);
			   iterations = 0;
			   break;
		   case 'd':
			   renderCam->positions->x -= .1f;
			   clearImageBuffer(renderCam);
			   iterations = 0;
			   break;
		   case 's':
			   renderCam->positions->z -= .1f;
			   clearImageBuffer(renderCam);
			   iterations = 0;
			   break;
		   case 'z':
			   renderCam->positions->z += .1f;
			   clearImageBuffer(renderCam);
			   iterations = 0;
			   break;
		}
	}