From 0023c034c41a57e14bbe7322fd58bd471a367c7e Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Sun, 29 Nov 2015 00:42:46 -0800 Subject: [PATCH] Fixing naming of GL classes --- interface/src/Application.cpp | 4 +-- interface/src/Application.h | 4 +-- .../display-plugins/OpenGLDisplayPlugin.cpp | 1 - .../openvr/OpenVrDisplayPlugin.cpp | 1 - .../stereo/InterleavedStereoDisplayPlugin.cpp | 11 +------- .../stereo/SideBySideStereoDisplayPlugin.cpp | 12 +------- libraries/gl/src/gl/GLEscrow.h | 8 +++++- libraries/gl/src/gl/GLWidget.cpp | 8 ++++++ libraries/gl/src/gl/GLWidget.h | 2 ++ .../gl/src/gl/{GlWindow.cpp => GLWindow.cpp} | 28 ++++++++++++------- .../gl/src/gl/{GlWindow.h => GLWindow.h} | 13 +++++---- ...reenGlCanvas.cpp => OffscreenGLCanvas.cpp} | 14 +++++----- ...ffscreenGlCanvas.h => OffscreenGLCanvas.h} | 14 +++++----- libraries/gl/src/gl/OffscreenQmlSurface.cpp | 6 ++-- .../src/OculusLegacyDisplayPlugin.cpp | 1 - 15 files changed, 65 insertions(+), 62 deletions(-) rename libraries/gl/src/gl/{GlWindow.cpp => GLWindow.cpp} (69%) rename libraries/gl/src/gl/{GlWindow.h => GLWindow.h} (63%) rename libraries/gl/src/gl/{OffscreenGlCanvas.cpp => OffscreenGLCanvas.cpp} (86%) rename libraries/gl/src/gl/{OffscreenGlCanvas.h => OffscreenGLCanvas.h} (77%) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5ac14ac0ec..708f8ee5ee 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -78,7 +78,7 @@ #include #include #include -#include +#include #include #include #include @@ -616,7 +616,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : // enable mouse tracking; otherwise, we only get drag events _glWidget->setMouseTracking(true); - _offscreenContext = new OffscreenGlCanvas(); + _offscreenContext = new OffscreenGLCanvas(); _offscreenContext->create(_glWidget->context()->contextHandle()); _offscreenContext->makeCurrent(); initializeGL(); diff --git a/interface/src/Application.h b/interface/src/Application.h index 730158c689..6e8df65032 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -65,7 +65,7 @@ #include "ui/ToolWindow.h" #include "UndoStackScriptingInterface.h" -class OffscreenGlCanvas; +class OffscreenGLCanvas; class GLCanvas; class FaceTracker; class MainWindow; @@ -421,7 +421,7 @@ private: bool _dependencyManagerIsSetup; - OffscreenGlCanvas* _offscreenContext { nullptr }; + OffscreenGLCanvas* _offscreenContext { nullptr }; DisplayPluginPointer _displayPlugin; InputPluginList _activeInputPlugins; diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp index 3ef882fe76..01cb0961e4 100644 --- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp @@ -10,7 +10,6 @@ #include #include -#include #include diff --git a/libraries/display-plugins/src/display-plugins/openvr/OpenVrDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/openvr/OpenVrDisplayPlugin.cpp index bb39c7bb7a..4278165e25 100644 --- a/libraries/display-plugins/src/display-plugins/openvr/OpenVrDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/openvr/OpenVrDisplayPlugin.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/libraries/display-plugins/src/display-plugins/stereo/InterleavedStereoDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/stereo/InterleavedStereoDisplayPlugin.cpp index 6e14a158d4..72921b4f90 100644 --- a/libraries/display-plugins/src/display-plugins/stereo/InterleavedStereoDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/stereo/InterleavedStereoDisplayPlugin.cpp @@ -8,15 +8,6 @@ #include "InterleavedStereoDisplayPlugin.h" -#include -#include - -#include -#include -#include - -#include - static const char * INTERLEAVED_TEXTURED_VS = R"VS(#version 410 core #pragma line __LINE__ @@ -81,4 +72,4 @@ void InterleavedStereoDisplayPlugin::display( _program->Bind(); Uniform(*_program, "textureSize").SetValue(sceneSize); WindowOpenGLDisplayPlugin::display(finalTexture, sceneSize); -} \ No newline at end of file +} diff --git a/libraries/display-plugins/src/display-plugins/stereo/SideBySideStereoDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/stereo/SideBySideStereoDisplayPlugin.cpp index 5ba113420d..12865cf4cd 100644 --- a/libraries/display-plugins/src/display-plugins/stereo/SideBySideStereoDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/stereo/SideBySideStereoDisplayPlugin.cpp @@ -7,17 +7,7 @@ // #include "SideBySideStereoDisplayPlugin.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include +#include const QString SideBySideStereoDisplayPlugin::NAME("3D TV - Side by Side Stereo"); diff --git a/libraries/gl/src/gl/GLEscrow.h b/libraries/gl/src/gl/GLEscrow.h index 54b124ae3c..db9f033de8 100644 --- a/libraries/gl/src/gl/GLEscrow.h +++ b/libraries/gl/src/gl/GLEscrow.h @@ -87,6 +87,11 @@ public: _recycler = recycler; } + size_t depth() { + Lock lock(_mutex); + return _submits.size(); + } + // Submit a new resource from the producer context // returns the number of prior submissions that were // never consumed before becoming available. @@ -124,7 +129,7 @@ public: } return result; } - + // If fetch returns a non-zero value, it's the responsibility of the // client to release it at some point void release(T t, GLsync readSync = 0) { @@ -175,6 +180,7 @@ private: // May be called on any thread, but must be inside a locked section void pop(Deque& deque) { + Lock lock(_mutex); auto& item = deque.front(); _trash.push_front(item); deque.pop_front(); diff --git a/libraries/gl/src/gl/GLWidget.cpp b/libraries/gl/src/gl/GLWidget.cpp index b274b39da7..ec08d70e7a 100644 --- a/libraries/gl/src/gl/GLWidget.cpp +++ b/libraries/gl/src/gl/GLWidget.cpp @@ -45,6 +45,14 @@ void GLWidget::initializeGL() { setAutoBufferSwap(false); } +void GLWidget::paintEvent(QPaintEvent* event) { + QWidget::paintEvent(event); +} + +void GLWidget::resizeEvent(QResizeEvent* event) { + QWidget::resizeEvent(event); +} + bool GLWidget::event(QEvent* event) { switch (event->type()) { case QEvent::MouseMove: diff --git a/libraries/gl/src/gl/GLWidget.h b/libraries/gl/src/gl/GLWidget.h index 040ce542e9..5c4f4305cc 100644 --- a/libraries/gl/src/gl/GLWidget.h +++ b/libraries/gl/src/gl/GLWidget.h @@ -27,6 +27,8 @@ public: protected: virtual void initializeGL() override; virtual bool event(QEvent* event) override; + virtual void paintEvent(QPaintEvent* event) override; + virtual void resizeEvent(QResizeEvent* event) override; private slots: virtual bool eventFilter(QObject*, QEvent* event) override; diff --git a/libraries/gl/src/gl/GlWindow.cpp b/libraries/gl/src/gl/GLWindow.cpp similarity index 69% rename from libraries/gl/src/gl/GlWindow.cpp rename to libraries/gl/src/gl/GLWindow.cpp index 40a5bedf7e..42914fed59 100644 --- a/libraries/gl/src/gl/GlWindow.cpp +++ b/libraries/gl/src/gl/GLWindow.cpp @@ -6,17 +6,18 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "GlWindow.h" +#include "GLWindow.h" #include #include #include "GLHelpers.h" -GlWindow::GlWindow(QOpenGLContext* shareContext) : GlWindow(getDefaultOpenGlSurfaceFormat(), shareContext) { +void GLWindow::createContext(QOpenGLContext* shareContext) { + createContext(getDefaultOpenGlSurfaceFormat(), shareContext); } -GlWindow::GlWindow(const QSurfaceFormat& format, QOpenGLContext* shareContext) { +void GLWindow::createContext(const QSurfaceFormat& format, QOpenGLContext* shareContext) { setSurfaceType(QSurface::OpenGLSurface); setFormat(format); _context = new QOpenGLContext; @@ -27,13 +28,15 @@ GlWindow::GlWindow(const QSurfaceFormat& format, QOpenGLContext* shareContext) { _context->create(); } -GlWindow::~GlWindow() { - _context->doneCurrent(); - _context->deleteLater(); - _context = nullptr; +GLWindow::~GLWindow() { + if (_context) { + _context->doneCurrent(); + _context->deleteLater(); + _context = nullptr; + } } -bool GlWindow::makeCurrent() { +bool GLWindow::makeCurrent() { bool makeCurrentResult = _context->makeCurrent(this); Q_ASSERT(makeCurrentResult); @@ -49,11 +52,16 @@ bool GlWindow::makeCurrent() { return makeCurrentResult; } -void GlWindow::doneCurrent() { +void GLWindow::doneCurrent() { _context->doneCurrent(); } -void GlWindow::swapBuffers() { +void GLWindow::swapBuffers() { _context->swapBuffers(this); } +QOpenGLContext* GLWindow::context() const { + return _context; +} + + diff --git a/libraries/gl/src/gl/GlWindow.h b/libraries/gl/src/gl/GLWindow.h similarity index 63% rename from libraries/gl/src/gl/GlWindow.h rename to libraries/gl/src/gl/GLWindow.h index 4956177725..bccfcd7320 100644 --- a/libraries/gl/src/gl/GlWindow.h +++ b/libraries/gl/src/gl/GLWindow.h @@ -7,8 +7,8 @@ // #pragma once -#ifndef hifi_GlWindow_h -#define hifi_GlWindow_h +#ifndef hifi_GLWindow_h +#define hifi_GLWindow_h #include #include @@ -16,14 +16,15 @@ class QOpenGLContext; class QOpenGLDebugLogger; -class GlWindow : public QWindow { +class GLWindow : public QWindow { public: - GlWindow(QOpenGLContext* shareContext = nullptr); - GlWindow(const QSurfaceFormat& format, QOpenGLContext* shareContext = nullptr); - virtual ~GlWindow(); + virtual ~GLWindow(); + void createContext(QOpenGLContext* shareContext = nullptr); + void createContext(const QSurfaceFormat& format, QOpenGLContext* shareContext = nullptr); bool makeCurrent(); void doneCurrent(); void swapBuffers(); + QOpenGLContext* context() const; private: std::once_flag _reportOnce; QOpenGLContext* _context{ nullptr }; diff --git a/libraries/gl/src/gl/OffscreenGlCanvas.cpp b/libraries/gl/src/gl/OffscreenGLCanvas.cpp similarity index 86% rename from libraries/gl/src/gl/OffscreenGlCanvas.cpp rename to libraries/gl/src/gl/OffscreenGLCanvas.cpp index e5c1ee4c4a..b8c9b9e117 100644 --- a/libraries/gl/src/gl/OffscreenGlCanvas.cpp +++ b/libraries/gl/src/gl/OffscreenGLCanvas.cpp @@ -1,5 +1,5 @@ // -// OffscreenGlCanvas.cpp +// OffscreenGLCanvas.cpp // interface/src/renderer // // Created by Bradley Austin Davis on 2014/04/09. @@ -10,7 +10,7 @@ // -#include "OffscreenGlCanvas.h" +#include "OffscreenGLCanvas.h" #include #include @@ -18,10 +18,10 @@ #include "GLHelpers.h" -OffscreenGlCanvas::OffscreenGlCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){ +OffscreenGLCanvas::OffscreenGLCanvas() : _context(new QOpenGLContext), _offscreenSurface(new QOffscreenSurface){ } -OffscreenGlCanvas::~OffscreenGlCanvas() { +OffscreenGLCanvas::~OffscreenGLCanvas() { #ifdef DEBUG if (_logger) { makeCurrent(); @@ -32,7 +32,7 @@ OffscreenGlCanvas::~OffscreenGlCanvas() { _context->doneCurrent(); } -void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) { +void OffscreenGLCanvas::create(QOpenGLContext* sharedContext) { if (nullptr != sharedContext) { sharedContext->doneCurrent(); _context->setShareContext(sharedContext); @@ -45,7 +45,7 @@ void OffscreenGlCanvas::create(QOpenGLContext* sharedContext) { } -bool OffscreenGlCanvas::makeCurrent() { +bool OffscreenGLCanvas::makeCurrent() { bool result = _context->makeCurrent(_offscreenSurface); Q_ASSERT(result); @@ -72,7 +72,7 @@ bool OffscreenGlCanvas::makeCurrent() { return result; } -void OffscreenGlCanvas::doneCurrent() { +void OffscreenGLCanvas::doneCurrent() { _context->doneCurrent(); } diff --git a/libraries/gl/src/gl/OffscreenGlCanvas.h b/libraries/gl/src/gl/OffscreenGLCanvas.h similarity index 77% rename from libraries/gl/src/gl/OffscreenGlCanvas.h rename to libraries/gl/src/gl/OffscreenGLCanvas.h index 94014adf98..e278f550f0 100644 --- a/libraries/gl/src/gl/OffscreenGlCanvas.h +++ b/libraries/gl/src/gl/OffscreenGLCanvas.h @@ -1,5 +1,5 @@ // -// OffscreenGlCanvas.h +// OffscreenGLCanvas.h // interface/src/renderer // // Created by Bradley Austin Davis on 2014/04/09. @@ -9,8 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #pragma once -#ifndef hifi_OffscreenGlCanvas_h -#define hifi_OffscreenGlCanvas_h +#ifndef hifi_OffscreenGLCanvas_h +#define hifi_OffscreenGLCanvas_h #include #include @@ -19,10 +19,10 @@ class QOpenGLContext; class QOffscreenSurface; class QOpenGLDebugLogger; -class OffscreenGlCanvas : public QObject { +class OffscreenGLCanvas : public QObject { public: - OffscreenGlCanvas(); - ~OffscreenGlCanvas(); + OffscreenGLCanvas(); + ~OffscreenGLCanvas(); void create(QOpenGLContext* sharedContext = nullptr); bool makeCurrent(); void doneCurrent(); @@ -40,4 +40,4 @@ protected: }; -#endif // hifi_OffscreenGlCanvas_h +#endif // hifi_OffscreenGLCanvas_h diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index e8a950a16b..f2eb112dc7 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -23,7 +23,7 @@ #include #include "GLEscrow.h" -#include "OffscreenGlCanvas.h" +#include "OffscreenGLCanvas.h" // FIXME move to threaded rendering with Qt 5.5 //#define QML_THREADED @@ -64,12 +64,12 @@ static const QEvent::Type STOP = QEvent::Type(QEvent::User + 4); static const QEvent::Type UPDATE = QEvent::Type(QEvent::User + 5); #endif -class OffscreenQmlRenderer : public OffscreenGlCanvas { +class OffscreenQmlRenderer : public OffscreenGLCanvas { friend class OffscreenQmlSurface; public: OffscreenQmlRenderer(OffscreenQmlSurface* surface, QOpenGLContext* shareContext) : _surface(surface) { - OffscreenGlCanvas::create(shareContext); + OffscreenGLCanvas::create(shareContext); #ifdef QML_THREADED // Qt 5.5 _renderControl->prepareThread(_renderThread); diff --git a/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp b/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp index ddf251778f..f0398158b4 100644 --- a/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp +++ b/plugins/oculusLegacy/src/OculusLegacyDisplayPlugin.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include