History

merge with hifi/plugins

Sam Gondelman committed 11 years ago

Commit f69b7552 parents 8fbbb26 95000ee231 files · +6439 −5987Browse files

Showing the changes to interface/src/Application.cpp (1 of 231 files). Show all

Unified · Split

interface/src/Application.cpp+79−8
@@ -93,6 +93,7 @@ · 92 unmodified lines
9393 #include <SceneScriptingInterface.h>
9494 #include <ScriptCache.h>
9595 #include <SettingHandle.h>
96+#include <SimpleAverage.h>
9697 #include <SoundCache.h>
9798 #include <TextRenderer.h>
9899 #include <Tooltip.h>
@@ -196,6 +197,7 @@ using namespace std; · 97 unmodified lines
196197 // Starfield information
197198 static unsigned STARFIELD_NUM_STARS = 50000;
198199 static unsigned STARFIELD_SEED = 1;
200+static uint8_t THROTTLED_IDLE_TIMER_DELAY = 10;
199201
200202 const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB
201203
@@ -1087,6 +1089,7 @@ void Application::paintGL() { · 885 unmodified lines
10871089 uvec2 finalSize = toGlm(size);
10881090 // Ensure the rendering context commands are completed when rendering
10891091 GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
1092+ glFinish();
10901093 _offscreenContext->doneCurrent();
10911094 Q_ASSERT(!QOpenGLContext::currentContext());
10921095 displayPlugin->preDisplay();
@@ -1130,7 +1133,6 @@ void Application::showEditEntitiesHelp() { · 37 unmodified lines
11301133 InfoView::show(INFO_EDIT_ENTITIES_PATH);
11311134 }
11321135
1133−
11341136 void Application::resizeEvent(QResizeEvent * event) {
11351137 resizeGL();
11361138 }
@@ -1258,6 +1260,54 @@ bool Application::eventFilter(QObject* object, QEvent* event) { · 121 unmodified lines
12581260 return true;
12591261 }
12601262 }
1263+
1264+ if (object == _glWindow) {
1265+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
1266+ if (offscreenUi->eventFilter(object, event)) {
1267+ return true;
1268+ }
1269+ switch (event->type()) {
1270+ case QEvent::MouseMove:
1271+ mouseMoveEvent((QMouseEvent*)event);
1272+ return true;
1273+ case QEvent::MouseButtonPress:
1274+ mousePressEvent((QMouseEvent*)event);
1275+ return true;
1276+ case QEvent::MouseButtonDblClick:
1277+ mouseDoublePressEvent((QMouseEvent*)event);
1278+ return true;
1279+ case QEvent::MouseButtonRelease:
1280+ mouseReleaseEvent((QMouseEvent*)event);
1281+ return true;
1282+ case QEvent::KeyPress:
1283+ keyPressEvent((QKeyEvent*)event);
1284+ return true;
1285+ case QEvent::KeyRelease:
1286+ keyReleaseEvent((QKeyEvent*)event);
1287+ return true;
1288+ case QEvent::FocusOut:
1289+ focusOutEvent((QFocusEvent*)event);
1290+ return true;
1291+ case QEvent::TouchBegin:
1292+ touchBeginEvent(static_cast<QTouchEvent*>(event));
1293+ event->accept();
1294+ return true;
1295+ case QEvent::TouchEnd:
1296+ touchEndEvent(static_cast<QTouchEvent*>(event));
1297+ return true;
1298+ case QEvent::TouchUpdate:
1299+ touchUpdateEvent(static_cast<QTouchEvent*>(event));
1300+ return true;
1301+ case QEvent::Wheel:
1302+ wheelEvent(static_cast<QWheelEvent*>(event));
1303+ return true;
1304+ case QEvent::Drop:
1305+ dropEvent(static_cast<QDropEvent*>(event));
1306+ return true;
1307+ default:
1308+ break;
1309+ }
1310+ }
12611311 return false;
12621312 }
12631313
@@ -1848,8 +1898,24 @@ void Application::checkFPS() { · 584 unmodified lines
18481898 }
18491899
18501900 void Application::idle() {
1851− PerformanceTimer perfTimer("idle");
1901+ static SimpleAverage<float> interIdleDurations;
1902+ static uint64_t lastIdleEnd{ 0 };
1903+
1904+ if (lastIdleEnd != 0) {
1905+ uint64_t now = usecTimestampNow();
1906+ interIdleDurations.update(now - lastIdleEnd);
1907+ static uint64_t lastReportTime = now;
1908+ if ((now - lastReportTime) >= (USECS_PER_SECOND)) {
1909+ static QString LOGLINE("Average inter-idle time: %1 us for %2 samples");
1910+ if (Menu::getInstance()->isOptionChecked(MenuOption::LogExtraTimings)) {
1911+ qCDebug(interfaceapp_timing) << LOGLINE.arg((int)interIdleDurations.getAverage()).arg(interIdleDurations.getCount());
1912+ }
1913+ interIdleDurations.reset();
1914+ lastReportTime = now;
1915+ }
1916+ }
18521917
1918+ PerformanceTimer perfTimer("idle");
18531919 if (_aboutToQuit) {
18541920 return; // bail early, nothing to do here.
18551921 }
@@ -1892,13 +1958,15 @@ void Application::idle() { · 36 unmodified lines
18921958 _idleLoopStdev.reset();
18931959 }
18941960
1895− // After finishing all of the above work, restart the idle timer, allowing 2ms to process events.
1896− idleTimer->start(2);
18971961 }
1898− }
1962+ // After finishing all of the above work, ensure the idle timer is set to the proper interval,
1963+ // depending on whether we're throttling or not
1964+ idleTimer->start(getActiveDisplayPlugin()->isThrottled() ? THROTTLED_IDLE_TIMER_DELAY : 0);
1965+ }
18991966
19001967 // check for any requested background downloads.
19011968 emit checkBackgroundDownloads();
1969+ lastIdleEnd = usecTimestampNow();
19021970 }
19031971
19041972 #if 0
@@ -2269,6 +2337,7 @@ void Application::init() { · 364 unmodified lines
22692337
22702338 // Make sure any new sounds are loaded as soon as know about them.
22712339 connect(tree, &EntityTree::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound);
2340+ connect(_myAvatar, &MyAvatar::newCollisionSoundURL, DependencyManager::get<SoundCache>().data(), &SoundCache::getSound);
22722341 }
22732342
22742343 void Application::closeMirrorView() {
@@ -3588,6 +3657,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 1313 unmodified lines
35883657 renderContext._maxDrawnTransparentItems = sceneInterface->getEngineMaxDrawnTransparentItems();
35893658 renderContext._maxDrawnOverlay3DItems = sceneInterface->getEngineMaxDrawnOverlay3DItems();
35903659
3660+ renderContext._drawItemStatus = sceneInterface->doEngineDisplayItemStatus();
3661+
35913662 renderArgs->_shouldRender = LODManager::shouldRender;
35923663
35933664 renderContext.args = renderArgs;
@@ -3609,7 +3680,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se · 15 unmodified lines
36093680 }
36103681 //Render the sixense lasers
36113682 if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLasers)) {
3612− _myAvatar->renderLaserPointers();
3683+ _myAvatar->renderLaserPointers(*renderArgs->_batch);
36133684 }
36143685
36153686 if (!selfAvatarOnly) {
@@ -4877,8 +4948,8 @@ void Application::updateDisplayMode() { · 1261 unmodified lines
48774948 DisplayPluginPointer oldDisplayPlugin = _displayPlugin;
48784949 if (oldDisplayPlugin != newDisplayPlugin) {
48794950 if (oldDisplayPlugin) {
4880− oldDisplayPlugin->removeEventFilter(offscreenUi.data());
48814951 oldDisplayPlugin->removeEventFilter(qApp);
4952+ oldDisplayPlugin->removeEventFilter(offscreenUi.data());
48824953 }
48834954
48844955 if (!_currentDisplayPluginActions.isEmpty()) {
@@ -4894,8 +4965,8 @@ void Application::updateDisplayMode() { · 9 unmodified lines
48944965 newDisplayPlugin->activate(this);
48954966
48964967 _offscreenContext->makeCurrent();
4897− newDisplayPlugin->installEventFilter(offscreenUi.data());
48984968 newDisplayPlugin->installEventFilter(qApp);
4969+ newDisplayPlugin->installEventFilter(offscreenUi.data());
48994970 QWindow* pluginWindow = newDisplayPlugin->getWindow();
49004971 if (pluginWindow) {
49014972 DependencyManager::get<OffscreenUi>()->setProxyWindow(pluginWindow);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t