summaryrefslogtreecommitdiffstats
path: root/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/adaptationlayers/qsgpartialuploadtexturemanager.cpp')
-rw-r--r--src/adaptationlayers/qsgpartialuploadtexturemanager.cpp110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp b/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
new file mode 100644
index 0000000..dd8af85
--- /dev/null
+++ b/src/adaptationlayers/qsgpartialuploadtexturemanager.cpp
@@ -0,0 +1,110 @@
+#include "qsgpartialuploadtexturemanager.h"
+
+
+
+QSGPartialUploadTextureManager::QSGPartialUploadTextureManager()
+{
+}
+
+
+
+
+void QSGPartialUploadTextureManager::timerEvent(QTimerEvent *)
+{
+// // ### gunnar:
+// // In the future, I forsee us starting / stopping this timer based
+// // on wether the vsync animation driver is running or not.
+// // Then we can also skip the "time since last upload" logic which
+// // is currently kinda messy and unpredictable.
+// if (d->lastUpload.elapsed() > 50) {
+// processAsyncTextures();
+// }
+}
+
+
+
+void QSGPartialUploadTextureManager::processAsyncTextures()
+{
+// QTime time;
+// time.start();
+
+// while (!d->requests.isEmpty()) {
+
+// UploadRequest *request = d->requests.first();
+
+// int w = request->image.width();
+// int h = request->image.height();
+
+// int hChunkCount = (w + d->uploadChunkSize - 1) / d->uploadChunkSize;
+// int vChunkCount = (h + d->uploadChunkSize - 1) / d->uploadChunkSize;
+// int chunkCount = hChunkCount * vChunkCount;
+// QSGTexture *t = request->texture;
+
+//// printf("\nASYNC: texture: %p, id=%d, size=(%dx%d), progress: %d / %d (%dx%d)\n",
+//// t,
+//// t->textureId(),
+//// w, h,
+//// request->progress, chunkCount, hChunkCount, vChunkCount);
+
+// // Create or bind the texture...
+// if (request->texture->textureId() == 0) {
+// while (glGetError() != GL_NO_ERROR) {}
+// GLuint id;
+// glGenTextures(1, &id);
+// glBindTexture(GL_TEXTURE_2D, id);
+// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+
+// // Clean up
+// // Gracefully fail in case of an error...
+// GLuint error = glGetError();
+// if (error != GL_NO_ERROR) {
+// glBindTexture(GL_TEXTURE_2D, 0);
+// glDeleteTextures(1, &id);
+// d->requests.dequeue();
+// t->setStatus(QSGTexture::Null);
+// delete request;
+// return;
+// }
+
+// t->setTextureId(id);
+// t->setTextureSize(QSize(w, h));
+// t->setAlphaChannel(request->image.hasAlphaChannel());
+//// printf("ASYNC: created texture %p with id=%d\n", t, id);
+// } else {
+// glBindTexture(GL_TEXTURE_2D, t->textureId());
+// }
+
+// if (time.elapsed() > d->maxUploadTime)
+// break;
+
+// while (request->progress < chunkCount && time.elapsed() < d->maxUploadTime) {
+// int x = (request->progress % hChunkCount) * d->uploadChunkSize;
+// int y = (request->progress / hChunkCount) * d->uploadChunkSize;
+
+// QRect area = QRect(x, y, d->uploadChunkSize, d->uploadChunkSize) & request->image.rect();
+// QImage subImage = request->image.copy(area);
+//// printf("ASYNC: - doing another batch: %d (x=%d, y=%d, w=%d, h=%d\n",
+//// request->progress,
+//// x, y, subImage.width(), subImage.height());
+
+// swizzleBGRAToRGBA(&subImage);
+// glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, subImage.width(), subImage.height(), GL_RGBA, GL_UNSIGNED_BYTE, subImage.constBits());
+
+// ++request->progress;
+// }
+
+// if (request->progress == chunkCount) {
+// t->setStatus(QSGTexture::Ready);
+// QSGTextureCacheKey key = { request->image.cacheKey() };
+// d->cache.insert(key, t);
+// d->requests.dequeue();
+// delete request;
+// if (d->requests.size() == 0) {
+// killTimer(d->uploadTimer);
+// d->uploadTimer = 0;
+// }
+// }
+// }
+
+// glBindTexture(GL_TEXTURE_2D, 0);
+}