[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [sflphone-kde] src: [ #50470 ] Drop mipmapping => reduce CPU usage
From: Emmanuel Lepage Vallee <emmanuel.lepage () savoirfairelinux ! com>
Date: 2014-06-30 19:42:37
Message-ID: E1X1hTJ-0003Uy-Va () scm ! kde ! org
[Download RAW message or body]
Git commit f667533cf0293db17780d948f7270b31afb7b509 by Emmanuel Lepage Vallee.
Committed on 30/06/2014 at 19:42.
Pushed by lepagevalleeemmanuel into branch 'master'.
[ #50470 ] Drop mipmapping => reduce CPU usage
M +1 -1 src/lib/call.cpp
M +7 -12 src/lib/video/videorenderer.cpp
M +9 -11 src/widgets/videoglframe.cpp
M +0 -88 src/widgets/videoscene.cpp
M +0 -6 src/widgets/videoscene.h
http://commits.kde.org/sflphone-kde/f667533cf0293db17780d948f7270b31afb7b509
diff --git a/src/lib/call.cpp b/src/lib/call.cpp
index 3370bae..73528b2 100644
--- a/src/lib/call.cpp
+++ b/src/lib/call.cpp
@@ -161,7 +161,7 @@ const TypedStateMachine< TypedStateMachine< bool , \
Call::LifeCycleState > , Call /*BUSY */ {{ true , false , \
false }},/**/ /*TRANSFERT */ {{ false , true , false }},/**/
/*TRANSFERT_HOLD */ {{ false , true , false }},/**/
-/*OVER */ {{ true , true , false }},/**/
+/*OVER */ {{ true , true , true }},/**/
/*ERROR */ {{ true , true , false }},/**/
/*CONF */ {{ true , false , false }},/**/
/*CONF_HOLD */ {{ true , false , false }},/**/
diff --git a/src/lib/video/videorenderer.cpp b/src/lib/video/videorenderer.cpp
index d98dac5..799e43b 100644
--- a/src/lib/video/videorenderer.cpp
+++ b/src/lib/video/videorenderer.cpp
@@ -81,7 +81,7 @@ bool VideoRenderer::renderToBitmap()
}
if (!shmLock()) {
- return true;
+ return false;
}
if(!VideoModel::instance()->startStopMutex()->tryLock())
@@ -115,16 +115,11 @@ bool VideoRenderer::renderToBitmap()
// return QByteArray();
// break;
// }
- if (err < 0) {
+ if ((err < 0) || (!shmLock())) {
VideoModel::instance()->startStopMutex()->unlock();
- return errno == EAGAIN;
+ return false;
}
-
- if (!shmLock()) {
- VideoModel::instance()->startStopMutex()->unlock();
- return true;
- }
- usleep((1/60.0)*10000);
+ usleep((1/60.0)*100);
}
if (!resizeShm()) {
@@ -247,7 +242,7 @@ void VideoRenderer::timedEvents()
bool ok = renderToBitmap();
- if (ok == true) {
+ if (ok) {
//Compute the FPS shown to the client
if (m_CurrentTime.second() != QTime::currentTime().second()) {
@@ -259,10 +254,10 @@ void VideoRenderer::timedEvents()
emit frameUpdated();
}
- else {
+ /*else {
qDebug() << "Frame dropped";
usleep(rand()%1000); //Be sure it can come back in sync
- }
+ }*/
}
///Start the rendering loop
diff --git a/src/widgets/videoglframe.cpp b/src/widgets/videoglframe.cpp
index 418c781..24a5606 100644
--- a/src/widgets/videoglframe.cpp
+++ b/src/widgets/videoglframe.cpp
@@ -21,6 +21,7 @@
#include <QtCore/QDebug>
#include <QtCore/QMutex>
#include <QtOpenGL/QGLWidget>
+#include <QtOpenGL/qglfunctions.h>
//System
#include <math.h>
@@ -35,7 +36,7 @@
#define GL_MULTISAMPLE 0x809D
#endif
-class ThreadedPainter2: public QObject {
+class ThreadedPainter2: public QObject, protected QGLFunctions {
Q_OBJECT
public:
friend class VideoGLFrame;
@@ -121,13 +122,9 @@ void ThreadedPainter2::draw(QPainter* p)
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_DECAL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_DECAL);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, \
GL_LINEAR_MIPMAP_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//To give a bit of history about why this code is weird, it used to have \
another copy buffer
//but this was removed and replaced with a flip buffer in libQt, there is some \
leftover @@ -142,11 +139,11 @@ void ThreadedPainter2::draw(QPainter* p)
return;
}
- if (res.width() && res.height() && data.size())
- gluBuild2DMipmaps(GL_TEXTURE_2D, 4, res.width(), res.height(), GL_BGRA, \
GL_UNSIGNED_BYTE, data); + if (res.width() && res.height() && data.size()) {
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, res.width(), res.height(), 0, \
GL_BGRA, GL_UNSIGNED_BYTE, data.data()); + }
// draw into the GL widget
-// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1, 1, -1, 1, 10, 100);
@@ -162,6 +159,7 @@ void ThreadedPainter2::draw(QPainter* p)
glEnable(GL_TEXTURE_2D);
glEnable(GL_MULTISAMPLE);
glEnable(GL_CULL_FACE);
+ glBindTexture(GL_TEXTURE_2D, texture);
glScalef(-1.0f*scale, -1.0f*scale, 1.0f*scale);
glRotatef(rot_x, 1.0f, 0.0f, 0.0f);
diff --git a/src/widgets/videoscene.cpp b/src/widgets/videoscene.cpp
index de6a01b..e102ef5 100644
--- a/src/widgets/videoscene.cpp
+++ b/src/widgets/videoscene.cpp
@@ -34,27 +34,6 @@
VideoScene::VideoScene()
: m_backgroundColor(25, 25, 25)//,m_pToolbar(nullptr)
{
-
-// QPointF pos(10, 10);
-// foreach (QGraphicsItem *item, items()) {
-// item->setFlag(QGraphicsItem::ItemIsMovable);
-// item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
-//
-// const QRectF rect = item->boundingRect();
-// item->setPos(pos.x() - rect.x(), pos.y() - rect.y());
-// pos += QPointF(0, 10 + rect.height());
-// }
-
-// QRadialGradient gradient(40, 40, 40, 40, 40);
-// gradient.setColorAt(0.2, Qt::yellow);
-// gradient.setColorAt(1, Qt::transparent);
-
-// m_lightItem = new QGraphicsRectItem(0, 0, 80, 80);
-// m_lightItem->setPen(Qt::NoPen);
-// m_lightItem->setBrush(gradient);
-// m_lightItem->setFlag(QGraphicsItem::ItemIsMovable);
-// m_lightItem->setPos(800, 200);
-// addItem(m_lightItem);
}
void VideoScene::drawBackground(QPainter *painter, const QRectF& rect)
@@ -68,61 +47,6 @@ void VideoScene::drawBackground(QPainter *painter, const QRectF& \
rect) }
}
-void VideoScene::setBackgroundColor()
-{
-// const QColor color = QColorDialog::getColor(m_backgroundColor);
-// if (color.isValid()) {
-// m_backgroundColor = color;
-// update();
-// }
-}
-
-// void VideoScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-// {
-// QGraphicsScene::mouseMoveEvent(event);
-// if (event->isAccepted())
-// return;
-// if (event->buttons() & Qt::LeftButton) {
-// event->accept();
-// update();
-// }
-// foreach(VideoGLFrame* frm, m_lFrames) {
-// // const QPointF diff = event->pos() - frm->anchor();
-// if (event->buttons() & Qt::LeftButton) {
-//
-// frm->setRotZ(frm->rotZ()+1);
-// // frm->setRotY(frm->rotY()+1/5.0f);
-// // } else if (event->buttons() & Qt::RightButton) {
-// // frm->setRotZ(frm->rotZ()+diff.x()/5.0f);
-// }
-//
-// frm->setAnchor(event->pos());
-// }
-// }
-
-// void VideoScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
-// {
-// QGraphicsScene::mousePressEvent(event);
-// if (event->isAccepted())
-// return;
-//
-// event->accept();
-//
-// foreach(VideoGLFrame* frm, m_lFrames) {
-// frm->setAnchor(event->pos());
-// }
-// }
-
-// void VideoScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-// {
-// QGraphicsScene::mouseReleaseEvent(event);
-// if (event->isAccepted())
-// return;
-//
-// event->accept();
-// update();
-// }
-
void VideoScene::wheelEvent(QGraphicsSceneWheelEvent *event)
{
QGraphicsScene::wheelEvent(event);
@@ -144,12 +68,6 @@ void VideoScene::frameChanged()
update();
}
-// void VideoScene::setToolbar(VideoToolbar* tb)
-// {
-// m_pToolbar = tb;
-// addWidget(m_pToolbar);
-// }
-
void VideoScene::addFrame(VideoGLFrame* frame)
{
m_lFrames << frame;
@@ -176,9 +94,3 @@ void VideoScene::slotRotateRight()
frm->setRotZ(frm->rotZ()+90);
}
}
-
-void VideoScene::slotShowPreview()
-{
-
-}
-
diff --git a/src/widgets/videoscene.h b/src/widgets/videoscene.h
index 12b2dcb..24988b3 100644
--- a/src/widgets/videoscene.h
+++ b/src/widgets/videoscene.h
@@ -34,15 +34,11 @@ public:
void drawBackground(QPainter *painter, const QRectF &rect);
//Setters
-// void setToolbar( VideoToolbar* tb );
void addFrame ( VideoGLFrame* frame );
void removeFrame( VideoGLFrame* frame );
protected:
//Events
-// virtual void mousePressEvent ( QGraphicsSceneMouseEvent* event );
-// virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent* event );
-// virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent* event );
virtual void wheelEvent ( QGraphicsSceneWheelEvent* wheelEvent );
private:
@@ -54,11 +50,9 @@ private:
public Q_SLOTS:
- void setBackgroundColor();
void frameChanged ();
void slotRotateLeft();
void slotRotateRight();
- void slotShowPreview();
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic