diff --git a/interface/resources/qml/hifi/tablet/BlocksWebView.qml b/interface/resources/qml/hifi/tablet/BlocksWebView.qml new file mode 100644 index 0000000000..1e9eb3beb4 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/BlocksWebView.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 +import QtWebEngine 1.2 + +import "../../controls" as Controls + +Controls.TabletWebView { + profile: WebEngineProfile { httpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"} +} + + diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index bbf56c7827..2f4c3cf62a 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -96,7 +96,7 @@ Item { function loadTabletWebBase() { loader.source = ""; - loader.source = "../../controls/TabletWebView.qml"; + loader.source = "./BlocksWebView.qml"; } function returnToPreviousApp() { diff --git a/interface/resources/qml/hifi/tablet/WindowRoot.qml b/interface/resources/qml/hifi/tablet/WindowRoot.qml index 8596007956..94847b2973 100644 --- a/interface/resources/qml/hifi/tablet/WindowRoot.qml +++ b/interface/resources/qml/hifi/tablet/WindowRoot.qml @@ -44,7 +44,7 @@ Windows.ScrollingWindow { function loadTabletWebBase() { loader.source = ""; - loader.source = "../../controls/TabletWebView.qml"; + loader.source = "./BlocksWebView.qml"; } function loadWebUrl(url, injectedJavaScriptUrl) { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6083463c56..d13b7880fa 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6457,7 +6457,7 @@ void Application::addAssetToWorldFromURL(QString url) { } if (url.contains("vr.google.com/downloads")) { filename = url.section('/', -1); - filename.remove(".zip?noDownload=false"); + filename.remove(".zip"); } if (!DependencyManager::get()->getThisNodeCanWriteAssets()) { @@ -6487,7 +6487,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { } if (url.contains("vr.google.com/downloads")) { filename = url.section('/', -1); - filename.remove(".zip?noDownload=false"); + filename.remove(".zip"); isBlocks = true; } @@ -6504,6 +6504,7 @@ void Application::addAssetToWorldFromURLRequestFinished() { if (tempFile.open(QIODevice::WriteOnly)) { tempFile.write(request->getData()); addAssetToWorldInfoClear(filename); // Remove message from list; next one added will have a different key. + tempFile.close(); qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true, false, isBlocks); } else { QString errorInfo = "Couldn't open temporary file for download"; diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp index 6f1167cfc9..c0278a6496 100644 --- a/interface/src/ui/overlays/Base3DOverlay.cpp +++ b/interface/src/ui/overlays/Base3DOverlay.cpp @@ -26,8 +26,7 @@ Base3DOverlay::Base3DOverlay() : _isSolid(DEFAULT_IS_SOLID), _isDashedLine(DEFAULT_IS_DASHED_LINE), _ignoreRayIntersection(false), - _drawInFront(false), - _isAA(true) + _drawInFront(false) { } @@ -39,7 +38,6 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) : _isDashedLine(base3DOverlay->_isDashedLine), _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), _drawInFront(base3DOverlay->_drawInFront), - _isAA(base3DOverlay->_isAA), _isGrabbable(base3DOverlay->_isGrabbable) { setTransform(base3DOverlay->getTransform()); @@ -191,13 +189,6 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) { needRenderItemUpdate = true; } - auto isAA = properties["isAA"]; - if (isAA.isValid()) { - bool value = isAA.toBool(); - setIsAA(value); - needRenderItemUpdate = true; - } - // Communicate changes to the renderItem if needed if (needRenderItemUpdate) { auto itemID = getRenderItemID(); @@ -253,9 +244,6 @@ QVariant Base3DOverlay::getProperty(const QString& property) { if (property == "parentJointIndex") { return getParentJointIndex(); } - if (property == "isAA") { - return _isAA; - } return Overlay::getProperty(property); } diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index 29d4c093a9..6377b46d7d 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -43,14 +43,11 @@ public: bool getDrawInFront() const { return _drawInFront; } bool getIsGrabbable() const { return _isGrabbable; } - virtual bool isAA() const { return _isAA; } - void setLineWidth(float lineWidth) { _lineWidth = lineWidth; } void setIsSolid(bool isSolid) { _isSolid = isSolid; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; } void setDrawInFront(bool value) { _drawInFront = value; } - void setIsAA(bool value) { _isAA = value; } void setIsGrabbable(bool value) { _isGrabbable = value; } virtual AABox getBounds() const override = 0; @@ -75,7 +72,6 @@ protected: bool _isDashedLine; bool _ignoreRayIntersection; bool _drawInFront; - bool _isAA; bool _isGrabbable { false }; QString _name; diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index f0b01827c7..104082dee4 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -335,9 +335,9 @@ void Web3DOverlay::render(RenderArgs* args) { batch.setModelTransform(transform); auto geometryCache = DependencyManager::get(); if (color.a < OPAQUE_ALPHA_THRESHOLD) { - geometryCache->bindTransparentWebBrowserProgram(batch, _isAA); + geometryCache->bindWebBrowserProgram(batch, true); } else { - geometryCache->bindOpaqueWebBrowserProgram(batch, _isAA); + geometryCache->bindWebBrowserProgram(batch); } geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color, _geometryId); batch.setResourceTexture(0, nullptr); // restore default white color after me diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 8590d6932c..8b5feb15f0 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -182,11 +182,10 @@ void WebEntityRenderer::doRender(RenderArgs* args) { float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; batch._glColor4f(1.0f, 1.0f, 1.0f, fadeRatio); - const bool IS_AA = true; if (fadeRatio < OPAQUE_ALPHA_THRESHOLD) { - DependencyManager::get()->bindTransparentWebBrowserProgram(batch, IS_AA); + DependencyManager::get()->bindWebBrowserProgram(batch, true); } else { - DependencyManager::get()->bindOpaqueWebBrowserProgram(batch, IS_AA); + DependencyManager::get()->bindWebBrowserProgram(batch); } DependencyManager::get()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, fadeRatio), _geometryId); } diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index 16efb96ce9..de0e4ddee5 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -132,10 +132,13 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, if (args.bitstreamVersion < VERSION_ENTITIES_ANIMATION_PROPERTIES_GROUP) { READ_ENTITY_PROPERTY(PROP_ANIMATION_SETTINGS, QString, setAnimationSettings); } else { - // Note: since we've associated our _animationProperties with our _animationLoop, the readEntitySubclassDataFromBuffer() - // will automatically read into the animation loop - int bytesFromAnimation = _animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, - propertyFlags, overwriteLocalData, animationPropertiesChanged); + int bytesFromAnimation; + withWriteLock([&] { + // Note: since we've associated our _animationProperties with our _animationLoop, the readEntitySubclassDataFromBuffer() + // will automatically read into the animation loop + bytesFromAnimation = _animationProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args, + propertyFlags, overwriteLocalData, animationPropertiesChanged); + }); bytesRead += bytesFromAnimation; dataAt += bytesFromAnimation; @@ -188,8 +191,10 @@ void ModelEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit APPEND_ENTITY_PROPERTY(PROP_COMPOUND_SHAPE_URL, getCompoundShapeURL()); APPEND_ENTITY_PROPERTY(PROP_TEXTURES, getTextures()); - _animationProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties, - propertyFlags, propertiesDidntFit, propertyCount, appendState); + withReadLock([&] { + _animationProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties, + propertyFlags, propertiesDidntFit, propertyCount, appendState); + }); APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType()); @@ -241,12 +246,14 @@ ShapeType ModelEntityItem::computeTrueShapeType() const { } void ModelEntityItem::setModelURL(const QString& url) { - if (_modelURL != url) { - _modelURL = url; - if (_shapeType == SHAPE_TYPE_STATIC_MESH) { - _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + withWriteLock([&] { + if (_modelURL != url) { + _modelURL = url; + if (_shapeType == SHAPE_TYPE_STATIC_MESH) { + _dirtyFlags |= Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS; + } } - } + }); } void ModelEntityItem::setCompoundShapeURL(const QString& url) { @@ -261,7 +268,9 @@ void ModelEntityItem::setCompoundShapeURL(const QString& url) { void ModelEntityItem::setAnimationURL(const QString& url) { _dirtyFlags |= Simulation::DIRTY_UPDATEABLE; - _animationProperties.setURL(url); + withWriteLock([&] { + _animationProperties.setURL(url); + }); } void ModelEntityItem::setAnimationSettings(const QString& value) { diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 286674488b..3bf83d08c9 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -1923,7 +1923,7 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) { return a.getRaw() == b.getRaw(); } -static void buildWebShader(const std::string& vertShaderText, const std::string& fragShaderText, bool blendEnable, bool isAA, +static void buildWebShader(const std::string& vertShaderText, const std::string& fragShaderText, bool blendEnable, gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) { auto VS = gpu::Shader::createVertex(vertShaderText); auto PS = gpu::Shader::createPixel(fragShaderText); @@ -1939,43 +1939,23 @@ static void buildWebShader(const std::string& vertShaderText, const std::string& gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); - if (isAA) { - blendEnable ? PrepareStencil::testMask(*state) : PrepareStencil::testMaskDrawShape(*state); - } else { - PrepareStencil::testMaskDrawShapeNoAA(*state); - } + PrepareStencil::testMaskDrawShapeNoAA(*state); pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state); } -void GeometryCache::bindOpaqueWebBrowserProgram(gpu::Batch& batch, bool isAA) { - batch.setPipeline(getOpaqueWebBrowserProgram(isAA)); +void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) { + batch.setPipeline(getWebBrowserProgram(transparent)); } -gpu::PipelinePointer GeometryCache::getOpaqueWebBrowserProgram(bool isAA) { +gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) { static std::once_flag once; std::call_once(once, [&]() { - const bool BLEND_ENABLE = false; - buildWebShader(simple_vert, simple_opaque_web_browser_frag, BLEND_ENABLE, true, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipeline); - buildWebShader(simple_vert, simple_opaque_web_browser_frag, BLEND_ENABLE, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA); + buildWebShader(simple_vert, simple_opaque_web_browser_frag, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA); + buildWebShader(simple_vert, simple_transparent_web_browser_frag, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA); }); - return isAA ? _simpleOpaqueWebBrowserPipeline : _simpleOpaqueWebBrowserPipelineNoAA; -} - -void GeometryCache::bindTransparentWebBrowserProgram(gpu::Batch& batch, bool isAA) { - batch.setPipeline(getTransparentWebBrowserProgram(isAA)); -} - -gpu::PipelinePointer GeometryCache::getTransparentWebBrowserProgram(bool isAA) { - static std::once_flag once; - std::call_once(once, [&]() { - const bool BLEND_ENABLE = true; - buildWebShader(simple_vert, simple_transparent_web_browser_frag, BLEND_ENABLE, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipeline); - buildWebShader(simple_vert, simple_transparent_web_browser_frag, BLEND_ENABLE, false, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA); - }); - - return isAA ? _simpleTransparentWebBrowserPipeline : _simpleTransparentWebBrowserPipelineNoAA; + return transparent ? _simpleTransparentWebBrowserPipelineNoAA : _simpleOpaqueWebBrowserPipelineNoAA; } void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) { diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index 37ba54ea80..a90842403b 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -166,11 +166,8 @@ public: static gpu::PipelinePointer getSimplePipeline(bool textured = false, bool transparent = false, bool culled = true, bool unlit = false, bool depthBias = false, bool fading = false); - void bindOpaqueWebBrowserProgram(gpu::Batch& batch, bool isAA); - gpu::PipelinePointer getOpaqueWebBrowserProgram(bool isAA); - - void bindTransparentWebBrowserProgram(gpu::Batch& batch, bool isAA); - gpu::PipelinePointer getTransparentWebBrowserProgram(bool isAA); + void bindWebBrowserProgram(gpu::Batch& batch, bool transparent = false); + gpu::PipelinePointer getWebBrowserProgram(bool transparent); static void initializeShapePipelines(); @@ -459,10 +456,8 @@ private: static QHash _simplePrograms; gpu::ShaderPointer _simpleOpaqueWebBrowserShader; - gpu::PipelinePointer _simpleOpaqueWebBrowserPipeline; gpu::PipelinePointer _simpleOpaqueWebBrowserPipelineNoAA; gpu::ShaderPointer _simpleTransparentWebBrowserShader; - gpu::PipelinePointer _simpleTransparentWebBrowserPipeline; gpu::PipelinePointer _simpleTransparentWebBrowserPipelineNoAA; static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true, diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index c3d55d5875..3dc62c9e34 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -167,7 +167,6 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) { parentID: this.tabletEntityID, parentJointIndex: -1, showKeyboardFocusHighlight: false, - isAA: HMD.active, visible: visible }); @@ -453,10 +452,6 @@ WebTablet.prototype.onHmdChanged = function () { this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); // TODO -- is this still needed? // Entities.editEntity(this.tabletEntityID, tabletProperties); - - // Full scene FXAA should be disabled on the overlay when the tablet in desktop mode. - // This should make the text more readable. - Overlays.editOverlay(this.webOverlayID, { isAA: HMD.active }); }; WebTablet.prototype.pickle = function () { diff --git a/unpublishedScripts/marketplace/blocks/blocksApp.js b/unpublishedScripts/marketplace/blocks/blocksApp.js index 2c20e13005..c9e8682b23 100644 --- a/unpublishedScripts/marketplace/blocks/blocksApp.js +++ b/unpublishedScripts/marketplace/blocks/blocksApp.js @@ -15,28 +15,56 @@ (function () { var APP_NAME = "BLOCKS"; var APP_URL = "https://vr.google.com/objects/"; + var APP_OUTDATED_URL = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/updateToBlocks.html"; var APP_ICON = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-i.svg"; + var APP_ICON_ACTIVE = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-a.svg"; try { print("Current Interface version: " + Window.checkVersion()); } catch(err) { print("Outdated Interface version does not support Blocks"); - APP_URL = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/updateToBlocks.html"; + APP_URL = APP_OUTDATED_URL; } var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ - icon: APP_ICON, + icon: APP_ICON, + activeIcon: APP_ICON_ACTIVE, text: APP_NAME }); function onClicked() { - tablet.gotoWebScreen(APP_URL, "", true); + if (!shown) { + tablet.gotoWebScreen(APP_URL, "", true); + } else { + tablet.gotoHomeScreen(); + } } button.clicked.connect(onClicked); + var shown = false; + + function checkIfBlocks(url) { + if (url.indexOf("google") !== -1) { + return true; + } + return false; + } + + function onScreenChanged(type, url) { + if ((type === 'Web' && checkIfBlocks(url)) || url === APP_OUTDATED_URL) { + button.editProperties({ isActive: true }); + shown = true; + } else { + button.editProperties({ isActive: false }); + shown = false; + } + } + + tablet.screenChanged.connect(onScreenChanged); + function cleanup() { - tablet.removeButton(button); + tablet.removeButton(button); } Script.scriptEnding.connect(cleanup);