MyApplication::MyApplication(const char *conf, int &argc, char **argv) : QApplication(argc, argv) , renderer(KSharedConfig::openConfig(QFile::decodeName(conf))) { connect(&timer, SIGNAL(timeout()), SLOT(slotTimeout())); connect(&renderer, SIGNAL(imageDone()), this, SLOT(renderDone())); renderer.enableTiling(true); // optimize renderer.changeWallpaper(); // cannot do it when we're killed, so do it now timer.start(60000); renderer.start(); }
void TestRenderServer::askRender(){ ui->uploadFolderPushButton->setEnabled(false); ui->renderPushButton->setEnabled(false); if(link == NULL){ link = new SheerCloudLink("http://172.245.20.58:8080", "abc", "123");//http://172.245.20.58:8080 //link->connect(link, SIGNAL(done()), this, SLOT(progressDone())); } QString scene = ui->sceneLineEdit->text(); link->Job(scene, rendering); connect(link, SIGNAL(done()), this, SLOT(renderDone())); }
Decode_Status VaapiDecoderBase::getOutput(unsigned long draw, int64_t *timeStamp , int drawX, int drawY, int drawWidth, int drawHeight, bool draining , int frameX, int frameY, int frameWidth, int frameHeight) { VAStatus vaStatus = VA_STATUS_SUCCESS; const VideoRenderBuffer *renderBuffer = getOutput(draining); if (!renderBuffer) return RENDER_NO_AVAILABLE_FRAME; if (frameX == -1 && frameY == -1 && frameWidth == -1 && frameHeight == -1) { frameX = 0; frameY = 0; frameWidth = m_videoFormatInfo.width; frameHeight = m_videoFormatInfo.height; } if (!draw || drawX < 0 || drawY < 0 || drawWidth <=0 || drawHeight <=0 || frameX < 0 || frameY < 0 || frameWidth <= 0 || frameHeight <= 0) return RENDER_INVALID_PARAMETER; #if __ENABLE_X11__ vaStatus = vaPutSurface(m_display->getID(), renderBuffer->surface, draw, drawX, drawY, drawWidth, drawHeight, frameX, frameY, frameWidth, frameHeight, NULL,0,0); #else vaStatus = VA_STATUS_ERROR_OPERATION_FAILED; ERROR("vaPutSurface is not supported when libva-x11 backend is disable during build (--disable-x11)"); #endif if (vaStatus != VA_STATUS_SUCCESS) return RENDER_FAIL; *timeStamp = renderBuffer->timeStamp; renderDone(renderBuffer); return RENDER_SUCCESS; }
void vidStreamer::pbLoadClicked() { QString fName = QFileDialog::getOpenFileName(this, "Open Video File", "../../../../videos", "*"); if(fName.isEmpty()) return; worker = new QThread(); decoder = new cDecoder(); // set correct spinnaker board spinn->setHost(ui->cbSpiNN->currentIndex()); decoder->moveToThread(worker); connect(decoder, SIGNAL(error(QString)), this, SLOT(errorString(QString))); connect(worker, SIGNAL(started()), decoder, SLOT(started())); connect(decoder, SIGNAL(finished()), worker, SLOT(quit())); connect(decoder, SIGNAL(finished()), decoder, SLOT(deleteLater())); connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(decoder, SIGNAL(newFrame(const QImage &)), screen, SLOT(putFrame(const QImage &))); // use the following to send the image from decoder to spinnaker connect(decoder, SIGNAL(newFrame(const QImage &)), spinn, SLOT(frameIn(const QImage &))); // use the following to send the image from decoder to edge-screener //connect(decoder, SIGNAL(newFrame(QImage)), edge, SLOT(putFrame(QImage))); connect(spinn, SIGNAL(frameOut(const QImage &)), edge, SLOT(putFrame(const QImage &))); connect(decoder, SIGNAL(gotPicSz(int,int)), this, SLOT(setSize(int,int))); connect(decoder, SIGNAL(finished()), this, SLOT(videoFinish())); //connect(refresh, SIGNAL(timeout()), decoder, SLOT(refresh())); connect(edge, SIGNAL(renderDone()), decoder, SLOT(refresh())); decoder->filename = fName; worker->start(); //refresh->start(); }
void TextBoxWarmingThread::run() { if(!m_model) { qDebug()<<"TextBoxWarmingThread::run(): m_model is null"; return; } //qDebug()<<"TextBoxWarmingThread::run(): model ptr:"<<m_model<<", attempting to dynamic cast"; TextBoxItem * model = dynamic_cast<TextBoxItem*>((AbstractVisualItem*)m_model); //int sleepTime = (int)(((float)qrand()) / ((float)RAND_MAX) * 10000.0 + 2000.0); //qDebug()<<"TextBoxWarmingThread::run(): modelItem:"<<model->itemName();//<<": Cache redraw, sleep: "<<sleepTime; // Sleep doesnt work - if I sleep, then it seems the cache is never updated! //sleep((unsigned long)sleepTime); //sleep(1000); QString htmlCode = model->text(); // qDebug()<<model->itemName()<<"TextBoxWarmingThread::run(): htmlCode:"<<htmlCode; QTextDocument doc; QTextDocument shadowDoc; doc.setHtml(htmlCode); shadowDoc.setHtml(htmlCode); int textWidth = model->contentsRect().toRect().width(); doc.setTextWidth(textWidth); shadowDoc.setTextWidth(textWidth); // Apply outline pen to the html QTextCursor cursor(&doc); cursor.select(QTextCursor::Document); QTextCharFormat format; QPen p(Qt::NoPen); if(model && model->outlineEnabled()) { p = model->outlinePen(); p.setJoinStyle(Qt::MiterJoin); } format.setTextOutline(p); format.setForeground(model && model->fillType() == AbstractVisualItem::Solid ? model->fillBrush() : Qt::NoBrush); //Qt::white); cursor.mergeCharFormat(format); #if QT46_SHADOW_ENAB == 0 // Setup the shadow text formatting if enabled if(model && model->shadowEnabled()) { if(qFuzzyIsNull(model->shadowBlurRadius())) { QTextCursor cursor(&shadowDoc); cursor.select(QTextCursor::Document); QTextCharFormat format; format.setTextOutline(Qt::NoPen); format.setForeground(model ? model->shadowBrush() : Qt::black); cursor.mergeCharFormat(format); } } #endif QSizeF shadowSize = model->shadowEnabled() ? QSizeF(model->shadowOffsetX(),model->shadowOffsetY()) : QSizeF(0,0); QImage *cache = new QImage((model->contentsRect().size()+shadowSize).toSize(),QImage::Format_ARGB32_Premultiplied); memset(cache->scanLine(0),0,cache->byteCount()); QPainter textPainter(cache); textPainter.fillRect(cache->rect(),Qt::transparent); QAbstractTextDocumentLayout::PaintContext pCtx; #if QT46_SHADOW_ENAB == 0 if(model->shadowEnabled()) { if(qFuzzyIsNull(model->shadowBlurRadius())) { // render a "cheap" version of the shadow using the shadow text document textPainter.save(); textPainter.translate(model->shadowOffsetX(),model->shadowOffsetY()); shadowDoc.documentLayout()->draw(&textPainter, pCtx); textPainter.restore(); } else { // double radius = model->shadowBlurRadius(); // double radiusSquared = radius*radius; // // // create temporary pixmap to hold a copy of the text // double blurSize = (int)(radiusSquared*2); // QSize shadowSize(blurSize,blurSize); // QImage tmpImage((model->contentsRect().size()+shadowSize).toSize(),QImage::Format_ARGB32); // memset(tmpImage.scanLine(0),0,tmpImage.byteCount()); // // // render the text // QPainter tmpPainter(&tmpImage); // tmpPainter.fillRect(tmpImage.rect(),Qt::transparent); // // tmpPainter.save(); // tmpPainter.translate(radiusSquared, radiusSquared); // doc.documentLayout()->draw(&tmpPainter, pCtx); // tmpPainter.restore(); // // // blacken the text by applying a color to the copy using a QPainter::CompositionMode_DestinationIn operation. // // This produces a homogeneously-colored pixmap. // QRect rect = tmpImage.rect(); // tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); // tmpPainter.fillRect(rect, model->shadowBrush().color()); // tmpPainter.end(); // // // blur the colored text // QImage blurredImage = ImageFilters::blurred(tmpImage, rect, (int)radius); // // // render the blurred text at an offset into the cache // textPainter.save(); // textPainter.translate(model->shadowOffsetX() - radiusSquared, // model->shadowOffsetY() - radiusSquared); // textPainter.drawImage(0, 0, blurredImage.copy(blurredImage.rect())); // textPainter.restore(); // New method of rendering shadows double radius = model->shadowBlurRadius(); // create temporary pixmap to hold a copy of the text QSizeF blurSize = ImageFilters::blurredSizeFor(model->contentsRect().size(), (int)radius); //qDebug() << "Blur size:"<<blurSize<<", doc:"<<doc.size()<<", radius:"<<radius; QImage tmpImage(blurSize.toSize(),QImage::Format_ARGB32_Premultiplied); memset(tmpImage.scanLine(0),0,tmpImage.byteCount()); // render the text QPainter tmpPainter(&tmpImage); tmpPainter.save(); tmpPainter.translate(radius, radius); doc.documentLayout()->draw(&tmpPainter, pCtx); tmpPainter.restore(); // blacken the text by applying a color to the copy using a QPainter::CompositionMode_DestinationIn operation. // This produces a homogeneously-colored pixmap. QRect rect = tmpImage.rect(); tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); tmpPainter.fillRect(rect, model->shadowBrush().color()); tmpPainter.end(); // blur the colored text ImageFilters::blurImage(tmpImage, (int)radius); // render the blurred text at an offset into the cache textPainter.save(); textPainter.translate(model->shadowOffsetX() - radius, model->shadowOffsetY() - radius); textPainter.drawImage(0, 0, tmpImage); textPainter.restore(); } } #endif doc.documentLayout()->draw(&textPainter, pCtx); textPainter.end(); emit renderDone(cache); }