Fix dimensions of rendered web entities

This commit is contained in:
Brad Davis 2017-09-21 20:47:36 -07:00
parent ecca1fea93
commit 549cb77902
5 changed files with 35 additions and 5 deletions

View file

@ -140,6 +140,11 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
_webSurface->resize(QSize(windowSize.x, windowSize.y));
}
void WebEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
Parent::doRenderUpdateAsynchronousTyped(entity);
_modelTransform.postScale(entity->getDimensions());
}
void WebEntityRenderer::doRender(RenderArgs* args) {
withWriteLock([&] {
_lastRenderTime = usecTimestampNow();

View file

@ -29,6 +29,7 @@ protected:
virtual bool needsRenderUpdate() const override;
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override;
virtual void doRender(RenderArgs* args) override;
virtual bool isTransparent() const override;

View file

@ -211,12 +211,12 @@ class UrlHandler : public QObject {
public:
Q_INVOKABLE bool canHandleUrl(const QString& url) {
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
return handler->canAcceptURL(url);
return handler && handler->canAcceptURL(url);
}
Q_INVOKABLE bool handleUrl(const QString& url) {
static auto handler = dynamic_cast<AbstractUriHandler*>(qApp);
return handler->acceptURL(url);
return handler && handler->acceptURL(url);
}
};

View file

@ -12,7 +12,7 @@ setup_hifi_project(Quick Gui OpenGL)
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/")
# link in the shared libraries
link_hifi_libraries(shared networking model fbx ktx image octree gl gpu gpu-gl render model-networking networking render-utils entities entities-renderer animation audio avatars script-engine physics procedural midi)
link_hifi_libraries(shared networking model fbx ktx image octree gl gpu gpu-gl render model-networking networking render-utils entities entities-renderer animation audio avatars script-engine physics procedural midi ui)
package_libraries_for_deployment()

View file

@ -42,11 +42,15 @@
#include <LogHandler.h>
#include <AssetClient.h>
#include <gl/OffscreenGLCanvas.h>
#include <gpu/gl/GLBackend.h>
#include <gpu/gl/GLFramebuffer.h>
#include <gpu/gl/GLTexture.h>
#include <gpu/StandardShaderLib.h>
#include <ui/OffscreenQmlSurface.h>
#include <AnimationCache.h>
#include <SimpleEntitySimulation.h>
#include <EntityDynamicInterface.h>
@ -427,6 +431,10 @@ namespace render {
}
}
OffscreenGLCanvas* _chromiumShareContext{ nullptr };
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
// Create a simple OpenGL window that renders text in various ways
class QTestWindow : public QWindow, public AbstractViewStateInterface {
@ -506,8 +514,6 @@ public:
AbstractViewStateInterface::setInstance(this);
_octree = DependencyManager::set<EntityTreeRenderer>(false, this, nullptr);
_octree->init();
// Prevent web entities from rendering
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory);
DependencyManager::set<ParentFinder>(_octree->getTree());
auto nodeList = DependencyManager::get<LimitedNodeList>();
@ -535,6 +541,23 @@ public:
_renderThread.initialize(this, _initContext);
_initContext.makeCurrent();
if (nsightActive()) {
// Prevent web entities from rendering
REGISTER_ENTITY_TYPE_WITH_FACTORY(Web, WebEntityItem::factory);
} else {
_chromiumShareContext = new OffscreenGLCanvas();
_chromiumShareContext->setObjectName("ChromiumShareContext");
_chromiumShareContext->create(_initContext.qglContext());
_chromiumShareContext->makeCurrent();
qt_gl_set_global_share_context(_chromiumShareContext->getContext());
// Make sure all QML surfaces share the main thread GL context
OffscreenQmlSurface::setSharedContext(_initContext.qglContext());
_initContext.makeCurrent();
}
// FIXME use a wait condition
QThread::msleep(1000);
_renderThread.submitFrame(gpu::FramePointer());
@ -679,6 +702,7 @@ private:
_renderCount = _renderThread._presentCount.load();
update();
_initContext.makeCurrent();
RenderArgs renderArgs(_renderThread._gpuContext, DEFAULT_OCTREE_SIZE_SCALE,
0, RenderArgs::DEFAULT_RENDER_MODE,
RenderArgs::MONO, RenderArgs::RENDER_DEBUG_NONE);