Commit 3dad1cd5 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Fix openGL texture buffers on non RGB8 color spaces

We should prepare a proper pixel size when creating a buffer

BUG:328998
parent 9fb36b75
......@@ -154,7 +154,7 @@ void KisOpenGLImageTextures::createImageTextureTiles()
m_numCols = lastCol + 1;
// Default color is transparent black
const int pixelSize = 4;
const int pixelSize = tilesColorSpace()->pixelSize();
QByteArray emptyTileData((m_texturesInfo.width) * (m_texturesInfo.height) * pixelSize, 0);
KisConfig config;
......@@ -243,6 +243,32 @@ KisOpenGLUpdateInfoSP KisOpenGLImageTextures::updateCache(const QRect& rect)
return info;
}
const KoColorSpace* KisOpenGLImageTextures::tilesColorSpace() const
{
const KoColorSpace *dstCS = 0;
switch(m_texturesInfo.type) {
case GL_UNSIGNED_BYTE:
dstCS = KoColorSpaceRegistry::instance()->rgb8(m_monitorProfile);
break;
case GL_UNSIGNED_SHORT:
dstCS = KoColorSpaceRegistry::instance()->rgb16(m_monitorProfile);
break;
#if defined(HAVE_OPENEXR)
case GL_HALF_FLOAT_ARB:
dstCS = KoColorSpaceRegistry::instance()->colorSpace("RGBA", "F16", 0);
break;
#endif
case GL_FLOAT:
dstCS = KoColorSpaceRegistry::instance()->colorSpace("RGBA", "F32", 0);
break;
default:
qFatal("Unknown m_imageTextureType");
}
return dstCS;
}
void KisOpenGLImageTextures::recalculateCache(KisUpdateInfoSP info)
{
KisOpenGLUpdateInfoSP glInfo = dynamic_cast<KisOpenGLUpdateInfo*>(info.data());
......@@ -251,29 +277,10 @@ void KisOpenGLImageTextures::recalculateCache(KisUpdateInfoSP info)
KisOpenGL::makeContextCurrent();
KIS_OPENGL_CLEAR_ERROR();
const KoColorSpace *dstCS = tilesColorSpace();
KisTextureTileUpdateInfo tileInfo;
foreach(tileInfo, glInfo->tileList) {
const KoColorSpace *dstCS = 0;
switch(m_texturesInfo.type) {
case GL_UNSIGNED_BYTE:
dstCS = KoColorSpaceRegistry::instance()->rgb8(m_monitorProfile);
break;
case GL_UNSIGNED_SHORT:
dstCS = KoColorSpaceRegistry::instance()->rgb16(m_monitorProfile);
break;
#if defined(HAVE_OPENEXR)
case GL_HALF_FLOAT_ARB:
dstCS = KoColorSpaceRegistry::instance()->colorSpace("RGBA", "F16", 0);
break;
#endif
case GL_FLOAT:
dstCS = KoColorSpaceRegistry::instance()->colorSpace("RGBA", "F32", 0);
break;
default:
qFatal("Unknown m_imageTextureType");
}
foreach(tileInfo, glInfo->tileList) {
tileInfo.convertTo(dstCS, m_renderingIntent, m_conversionFlags);
KisTextureTile *tile = getTextureTileCR(tileInfo.tileCol(), tileInfo.tileRow());
KIS_ASSERT_RECOVER_RETURN(tile);
......
......@@ -145,6 +145,7 @@ private:
static void getTextureSize(KisGLTexturesInfo *texturesInfo);
void updateTextureFormat();
const KoColorSpace* tilesColorSpace() const;
private:
KisImageWSP m_image;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment