working, except tablet issue

This commit is contained in:
David Kelly 2017-06-19 14:41:42 -07:00
parent c7e4649ec2
commit b4c75c3f87
5 changed files with 24 additions and 37 deletions

View file

@ -190,25 +190,21 @@ Rectangle {
boxSize: 24;
onClicked: {
sendToScript({method: (checked ? 'spectatorCameraOn' : 'spectatorCameraOff')});
spectatorCameraPreviewItem.ready = checked;
spectatorCameraPreview.ready = checked;
}
}
// Spectator Camera Preview
Rectangle {
Hifi.ResourceImageItem {
id: spectatorCameraPreview;
url: "resource://spectatorCameraFrame";
ready: false;
mirrorVertically: true;
height: 250;
anchors.left: parent.left;
anchors.top: cameraToggleCheckBox.bottom;
anchors.topMargin: 20;
anchors.right: parent.right;
Hifi.ResourceImageItem {
id: spectatorCameraPreviewItem;
anchors.fill: parent;
url: "resource://spectatorCameraFrame";
ready: false;
mirrorVertically: true;
}
}
// "Monitor Shows" Switch Label Glyph

View file

@ -54,24 +54,15 @@ void ResourceImageItemRenderer::synchronize(QQuickFramebufferObject* item) {
readyChanged = true;
}
if (!_ready && readyChanged) {
qDebug() << "clearing network texture!!!!!!!!!!!!!!!!!";
_networkTexture.clear();
}
_window = resourceImageItem->window();
if (_ready && !_url.isNull() && !_url.isEmpty() && (urlChanged || readyChanged || !_networkTexture)) {
_networkTexture = DependencyManager::get<TextureCache>()->getTexture(_url);
}
if (_networkTexture && _networkTexture->isLoaded()) {
qDebug() << "copying texture";
auto texture = _networkTexture->getGPUTexture();
if (texture) {
if (_fboMutex.tryLock()) {
qApp->getActiveDisplayPlugin()->copyTextureToQuickFramebuffer(texture, framebufferObject());
_fboMutex.unlock();
}
if (_ready && _networkTexture && _networkTexture->isLoaded()) {
if(_fboMutex.tryLock()) {
qApp->getActiveDisplayPlugin()->copyTextureToQuickFramebuffer(_networkTexture, framebufferObject());
_fboMutex.unlock();
}
}
}

View file

@ -42,7 +42,7 @@
#include <ui-plugins/PluginContainer.h>
#include <ui/Menu.h>
#include <CursorManager.h>
#include <TextureCache.h>
#include "CompositorHelper.h"
#include "Logging.h"
@ -823,33 +823,31 @@ void OpenGLDisplayPlugin::updateCompositeFramebuffer() {
}
}
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) {
void OpenGLDisplayPlugin::copyTextureToQuickFramebuffer(NetworkTexturePointer networkTexture, QOpenGLFramebufferObject* target) {
auto glBackend = const_cast<OpenGLDisplayPlugin&>(*this).getGLBackend();
withMainThreadContext([&] {
qDebug() << "initial gl error:" << glGetError();
GLuint sourceTexture = glBackend->getTextureID(source);
GLuint sourceTexture = glBackend->getTextureID(networkTexture->getGPUTexture());
GLuint targetTexture = target->texture();
GLuint fbo[2] {0, 0};
// need mipmaps for blitting texture
glGenerateTextureMipmap(sourceTexture);
qDebug() << "errors: " << glGetError();
// create 2 fbos (one for initial texture, second for scaled one)
glCreateFramebuffers(2, fbo);
// setup source fbo
glBindFramebuffer(GL_FRAMEBUFFER, fbo[0]);
qDebug() << "errors: " << glGetError();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sourceTexture, 0);
qDebug() << "errors: " << glGetError();
// setup destination fbo
glBindFramebuffer(GL_FRAMEBUFFER, fbo[1]);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, targetTexture, 0);
qDebug() << "errors: " << glGetError();
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, source->getWidth(), source->getHeight(), 0, 0, target->width(), target->height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
qDebug() << "errors: " << glGetError() << "bound?" << target->isBound();
glBlitNamedFramebuffer(fbo[0], fbo[1], 0, 0, networkTexture->getWidth(), networkTexture->getHeight(), 0, 0, target->width(), target->height(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
// don't delete the textures!
glDeleteFramebuffers(2, fbo);
glDeleteTextures(1, fbo);
glFinish();
});
}

View file

@ -79,7 +79,7 @@ public:
// Three threads, one for rendering, one for texture transfers, one reserved for the GL driver
int getRequiredThreadCount() const override { return 3; }
void copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) override;
void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target);
protected:
friend class PresentThread;

View file

@ -22,7 +22,6 @@
#include <RegisteredMetaTypes.h>
#include <shared/Bilateral.h>
#include <gpu/Forward.h>
#include "Plugin.h"
class QOpenGLFramebufferObject;
@ -62,6 +61,9 @@ namespace gpu {
using TexturePointer = std::shared_ptr<Texture>;
}
class NetworkTexture;
using NetworkTexturePointer = QSharedPointer<NetworkTexture>;
// Stereo display functionality
// TODO move out of this file don't derive DisplayPlugin from this. Instead use dynamic casting when
// displayPlugin->isStereo returns true
@ -210,7 +212,7 @@ public:
// Hardware specific stats
virtual QJsonObject getHardwareStats() const { return QJsonObject(); }
virtual void copyTextureToQuickFramebuffer(gpu::TexturePointer source, QOpenGLFramebufferObject* target) = 0;
virtual void copyTextureToQuickFramebuffer(NetworkTexturePointer source, QOpenGLFramebufferObject* target) = 0;
uint32_t presentCount() const { return _presentedFrameIndex; }
// Time since last call to incrementPresentCount (only valid if DEBUG_PAINT_DELAY is defined)