Changeset View
Changeset View
Standalone View
Standalone View
abstract_egl_backend.cpp
Show First 20 Lines • Show All 350 Lines • ▼ Show 20 Line(s) | 324 | { | |||
---|---|---|---|---|---|
351 | const QImage &image = buffer->data(); | 351 | const QImage &image = buffer->data(); | ||
352 | if (image.isNull() || !s) { | 352 | if (image.isNull() || !s) { | ||
353 | return; | 353 | return; | ||
354 | } | 354 | } | ||
355 | Q_ASSERT(image.size() == m_size); | 355 | Q_ASSERT(image.size() == m_size); | ||
356 | q->bind(); | 356 | q->bind(); | ||
357 | const QRegion damage = s->trackedDamage(); | 357 | const QRegion damage = s->trackedDamage(); | ||
358 | s->resetTrackedDamage(); | 358 | s->resetTrackedDamage(); | ||
359 | auto scale = s->scale(); //damage is normalised, so needs converting up to match texture | ||||
359 | 360 | | |||
360 | // TODO: this should be shared with GLTexture::update | 361 | // TODO: this should be shared with GLTexture::update | ||
361 | if (GLPlatform::instance()->isGLES()) { | 362 | if (GLPlatform::instance()->isGLES()) { | ||
362 | if (s_supportsARGB32 && (image.format() == QImage::Format_ARGB32 || image.format() == QImage::Format_ARGB32_Premultiplied)) { | 363 | if (s_supportsARGB32 && (image.format() == QImage::Format_ARGB32 || image.format() == QImage::Format_ARGB32_Premultiplied)) { | ||
graesslin: nitpick | |||||
363 | const QImage im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | 364 | const QImage im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | ||
364 | for (const QRect &rect : damage.rects()) { | 365 | for (const QRect &rect : damage.rects()) { | ||
365 | glTexSubImage2D(m_target, 0, rect.x(), rect.y(), rect.width(), rect.height(), | 366 | auto scaledRect = QRect(rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale); | ||
366 | GL_BGRA_EXT, GL_UNSIGNED_BYTE, im.copy(rect).bits()); | 367 | glTexSubImage2D(m_target, 0, scaledRect.x(), scaledRect.y(), scaledRect.width(), scaledRect.height(), | ||
368 | GL_BGRA_EXT, GL_UNSIGNED_BYTE, im.copy(scaledRect).bits()); | ||||
367 | } | 369 | } | ||
368 | } else { | 370 | } else { | ||
369 | const QImage im = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied); | 371 | const QImage im = image.convertToFormat(QImage::Format_RGBA8888_Premultiplied); | ||
370 | for (const QRect &rect : damage.rects()) { | 372 | for (const QRect &rect : damage.rects()) { | ||
371 | glTexSubImage2D(m_target, 0, rect.x(), rect.y(), rect.width(), rect.height(), | 373 | auto scaledRect = QRect(rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale); | ||
372 | GL_RGBA, GL_UNSIGNED_BYTE, im.copy(rect).bits()); | 374 | glTexSubImage2D(m_target, 0, scaledRect.x(), scaledRect.y(), scaledRect.width(), scaledRect.height(), | ||
375 | GL_RGBA, GL_UNSIGNED_BYTE, im.copy(scaledRect).bits()); | ||||
373 | } | 376 | } | ||
374 | } | 377 | } | ||
375 | } else { | 378 | } else { | ||
376 | const QImage im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | 379 | const QImage im = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); | ||
377 | for (const QRect &rect : damage.rects()) { | 380 | for (const QRect &rect : damage.rects()) { | ||
378 | glTexSubImage2D(m_target, 0, rect.x(), rect.y(), rect.width(), rect.height(), | 381 | auto scaledRect = QRect(rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale); | ||
379 | GL_BGRA, GL_UNSIGNED_BYTE, im.copy(rect).bits()); | 382 | glTexSubImage2D(m_target, 0, scaledRect.x(), scaledRect.y(), scaledRect.width(), scaledRect.height(), | ||
383 | GL_BGRA, GL_UNSIGNED_BYTE, im.copy(scaledRect).bits()); | ||||
380 | } | 384 | } | ||
I'm wondering whether the partial upload makes sense at all now. Maybe we should just upload the complete texture? Note: I have vague ideas of using a texture upload thread. graesslin: I'm wondering whether the partial upload makes sense at all now. Maybe we should just upload… | |||||
381 | } | 385 | } | ||
382 | q->unbind(); | 386 | q->unbind(); | ||
383 | } | 387 | } | ||
384 | 388 | | |||
385 | bool AbstractEglTexture::loadShmTexture(const QPointer< KWayland::Server::BufferInterface > &buffer) | 389 | bool AbstractEglTexture::loadShmTexture(const QPointer< KWayland::Server::BufferInterface > &buffer) | ||
386 | { | 390 | { | ||
387 | const QImage &image = buffer->data(); | 391 | const QImage &image = buffer->data(); | ||
388 | if (image.isNull()) { | 392 | if (image.isNull()) { | ||
389 | return false; | 393 | return false; | ||
390 | } | 394 | } | ||
391 | 395 | | |||
392 | glGenTextures(1, &m_texture); | 396 | glGenTextures(1, &m_texture); | ||
393 | q->setWrapMode(GL_CLAMP_TO_EDGE); | 397 | q->setWrapMode(GL_CLAMP_TO_EDGE); | ||
394 | q->setFilter(GL_LINEAR); | 398 | q->setFilter(GL_LINEAR); | ||
395 | q->bind(); | 399 | q->bind(); | ||
396 | 400 | | |||
397 | const QSize &size = image.size(); | 401 | const QSize &size = image.size(); | ||
398 | // TODO: this should be shared with GLTexture(const QImage&, GLenum) | 402 | // TODO: this should be shared with GLTexture(const QImage&, GLenum) | ||
graesslin: nitpick | |||||
399 | GLenum format = 0; | 403 | GLenum format = 0; | ||
400 | switch (image.format()) { | 404 | switch (image.format()) { | ||
401 | case QImage::Format_ARGB32: | 405 | case QImage::Format_ARGB32: | ||
402 | case QImage::Format_ARGB32_Premultiplied: | 406 | case QImage::Format_ARGB32_Premultiplied: | ||
403 | format = GL_RGBA8; | 407 | format = GL_RGBA8; | ||
404 | break; | 408 | break; | ||
405 | case QImage::Format_RGB32: | 409 | case QImage::Format_RGB32: | ||
406 | format = GL_RGB8; | 410 | format = GL_RGB8; | ||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |
nitpick