fix resource texture crash

This commit is contained in:
SamGondelman 2019-02-11 16:12:13 -08:00
parent 4202685a4b
commit d96b0534ab
2 changed files with 10 additions and 6 deletions

View file

@ -333,10 +333,14 @@ QSharedPointer<Resource> TextureCache::createResourceCopy(const QSharedPointer<R
int networkTexturePointerMetaTypeId = qRegisterMetaType<QWeakPointer<NetworkTexture>>();
NetworkTexture::NetworkTexture(const QUrl& url) :
NetworkTexture::NetworkTexture(const QUrl& url, bool resourceTexture) :
Resource(url),
_maxNumPixels(100)
{
if (resourceTexture) {
_textureSource = std::make_shared<gpu::TextureSource>(url);
_loaded = true;
}
}
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
@ -1244,11 +1248,11 @@ void ImageReader::read() {
Q_ARG(int, texture->getHeight()));
}
NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl) {
NetworkTexturePointer TextureCache::getResourceTexture(const QUrl& resourceTextureUrl) {
gpu::TexturePointer texture;
if (resourceTextureUrl == SPECTATOR_CAMERA_FRAME_URL) {
if (!_spectatorCameraNetworkTexture) {
_spectatorCameraNetworkTexture.reset(new NetworkTexture(resourceTextureUrl));
_spectatorCameraNetworkTexture.reset(new NetworkTexture(resourceTextureUrl, true));
}
if (!_spectatorCameraFramebuffer) {
getSpectatorCameraFramebuffer(); // initialize frame buffer
@ -1259,7 +1263,7 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
// FIXME: Generalize this, DRY up this code
if (resourceTextureUrl == HMD_PREVIEW_FRAME_URL) {
if (!_hmdPreviewNetworkTexture) {
_hmdPreviewNetworkTexture.reset(new NetworkTexture(resourceTextureUrl));
_hmdPreviewNetworkTexture.reset(new NetworkTexture(resourceTextureUrl, true));
}
if (_hmdPreviewFramebuffer) {
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);

View file

@ -45,7 +45,7 @@ class NetworkTexture : public Resource, public Texture {
Q_OBJECT
public:
NetworkTexture(const QUrl& url);
NetworkTexture(const QUrl& url, bool resourceTexture = false);
NetworkTexture(const NetworkTexture& other);
~NetworkTexture() override;
@ -183,7 +183,7 @@ public:
gpu::TexturePointer getTextureByHash(const std::string& hash);
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
NetworkTexturePointer getResourceTexture(const QUrl& resourceTextureUrl);
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer(int width, int height);