aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/scenegraph
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-06-30 15:53:03 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2016-07-01 11:37:03 +0000
commit4c3a3dbee9701a62eec8455713451ac1afaeda10 (patch)
tree7956559769a690ef5709cc12da362f120f7337b5 /src/plugins/scenegraph
parentc3561cdb36e538132ea07491ab6418294117b8f2 (diff)
D3D12: Fix 8-bit QImage mapping
The engine treats these specially due to the glyph textures sharing the same code path, but ordinary images do not need this. Convert them to 32-bit instead like it's done with OpenGL. Change-Id: If484e61c7269e55ba4ebaaba34819e064c10be7c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/scenegraph')
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp
index c4ba80bd48..a5f3eb7a31 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12texture.cpp
@@ -52,7 +52,13 @@ void QSGD3D12Texture::create(const QImage &image, uint flags)
const bool alphaRequest = flags & QSGRenderContext::CreateTexture_Alpha;
m_alphaWanted = alphaRequest && image.hasAlphaChannel();
- m_image = image;
+ // The engine maps 8-bit formats to R8. This is fine for glyphs and such
+ // but may not be what apps expect for ordinary image data. The OpenGL
+ // implementation maps these to ARGB32_Pre so let's follow suit.
+ if (image.depth() != 8)
+ m_image = image;
+ else
+ m_image = image.convertToFormat(m_alphaWanted ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
m_id = m_engine->genTexture();
Q_ASSERT(m_id);