Commit 161c58b1 authored by Halla Rempt's avatar Halla Rempt
Browse files

Fix bug 320679: correctly convert input pixels to textures

We hardcoded GL_BGRA, but we actually have GL_RGBA as a possibility now,
for the floating point colorspaces.

BUG: 320679

Conflicts:
	krita/ui/opengl/kis_opengl_image_textures.cpp
	krita/ui/opengl/kis_texture_tile.cpp
parent 036c0535
......@@ -352,10 +352,11 @@ void KisOpenGLImageTextures::getTextureSize(KisGLTexturesInfo *texturesInfo)
void KisOpenGLImageTextures::updateTextureFormat()
{
m_texturesInfo.format = GL_RGBA8;
m_texturesInfo.internalFormat = GL_RGBA8;
m_texturesInfo.type = GL_UNSIGNED_BYTE;
m_texturesInfo.format = GL_BGRA;
#ifdef HAVE_GLEW
#ifdef HAVE_GLEW
KoID colorModelId = m_image->colorSpace()->colorModelId();
KoID colorDepthId = m_image->colorSpace()->colorDepthId();
......@@ -366,11 +367,11 @@ void KisOpenGLImageTextures::updateTextureFormat()
if (colorDepthId == Float16BitsColorDepthID) {
if (GLEW_ARB_texture_float) {
m_texturesInfo.format = GL_RGBA16F_ARB;
m_texturesInfo.internalFormat = GL_RGBA16F_ARB;
dbgUI << "Using ARB half";
}
else if (GLEW_ATI_texture_float){
m_texturesInfo.format = GL_RGBA_FLOAT16_ATI;
m_texturesInfo.internalFormat = GL_RGBA_FLOAT16_ATI;
dbgUI << "Using ATI half";
}
else if (GLEW_ARB_half_float_pixel) {
......@@ -380,23 +381,25 @@ void KisOpenGLImageTextures::updateTextureFormat()
dbgUI << "Pixel type float";
m_texturesInfo.type = GL_FLOAT;
}
m_texturesInfo.format = GL_RGBA;
}
else if (colorDepthId == Float32BitsColorDepthID) {
if (GLEW_ARB_texture_float) {
m_texturesInfo.format = GL_RGBA32F_ARB;
m_texturesInfo.internalFormat = GL_RGBA32F_ARB;
dbgUI << "Using ARB float";
m_texturesInfo.type = GL_FLOAT;
}
else if (GLEW_ATI_texture_float) {
m_texturesInfo.format = GL_RGBA_FLOAT32_ATI;
m_texturesInfo.internalFormat = GL_RGBA_FLOAT32_ATI;
dbgUI << "Using ATI float";
m_texturesInfo.type = GL_FLOAT;
}
m_texturesInfo.format = GL_RGBA;
}
else if (colorDepthId == Integer16BitsColorDepthID) {
dbgUI << "Using 16 bits rgba";
m_texturesInfo.format = GL_RGBA16;
m_texturesInfo.internalFormat = GL_RGBA16;
m_texturesInfo.type = GL_UNSIGNED_SHORT;
}
}
......@@ -404,7 +407,7 @@ void KisOpenGLImageTextures::updateTextureFormat()
// We will convert the colorspace to 16 bits rgba, instead of 8 bits
if (colorDepthId == Integer16BitsColorDepthID) {
dbgUI << "Using conversion to 16 bits rgba";
m_texturesInfo.format = GL_RGBA16;
m_texturesInfo.internalFormat = GL_RGBA16;
m_texturesInfo.type = GL_UNSIGNED_SHORT;
}
}
......
......@@ -71,10 +71,12 @@ KisTextureTile::KisTextureTile(QRect imageRect, const KisGLTexturesInfo *texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0,
m_texturesInfo->format,
m_texturesInfo->internalFormat,
m_texturesInfo->width,
m_texturesInfo->height, 0,
GL_BGRA, GL_UNSIGNED_BYTE, fillData);
m_texturesInfo->format,
GL_UNSIGNED_BYTE, fillData);
}
KisTextureTile::~KisTextureTile() {
......@@ -88,20 +90,24 @@ void KisTextureTile::update(const KisTextureTileUpdateInfo &updateInfo) {
if (updateInfo.isEntireTileUpdated()) {
glTexImage2D(GL_TEXTURE_2D, 0,
m_texturesInfo->format,
m_texturesInfo->internalFormat,
m_texturesInfo->width,
m_texturesInfo->height, 0,
GL_BGRA, m_texturesInfo->type,
m_texturesInfo->format,
m_texturesInfo->type,
updateInfo.data());
} else {
}
else {
QPoint patchOffset = updateInfo.patchOffset();
QSize patchSize = updateInfo.patchSize();
glTexSubImage2D(GL_TEXTURE_2D, 0,
patchOffset.x(), patchOffset.y(),
patchSize.width(), patchSize.height(),
GL_BGRA, m_texturesInfo->type,
m_texturesInfo->format,
m_texturesInfo->type,
updateInfo.data());
}
/**
......@@ -129,7 +135,8 @@ inline void KisTextureTile::repeatStripes(const KisTextureTileUpdateInfo &update
glTexSubImage2D(GL_TEXTURE_2D, 0,
patchOffset.x(), patchOffset.y() - 1,
patchSize.width(), 1,
GL_BGRA, m_texturesInfo->type,
m_texturesInfo->format,
m_texturesInfo->type,
updateInfo.data());
}
......@@ -141,7 +148,8 @@ inline void KisTextureTile::repeatStripes(const KisTextureTileUpdateInfo &update
glTexSubImage2D(GL_TEXTURE_2D, 0,
patchOffset.x(), patchOffset.y() + patchSize.height(),
patchSize.width(), 1,
GL_BGRA, m_texturesInfo->type,
m_texturesInfo->format,
m_texturesInfo->type,
updateInfo.data() + shift);
}
......@@ -161,7 +169,8 @@ inline void KisTextureTile::repeatStripes(const KisTextureTileUpdateInfo &update
glTexSubImage2D(GL_TEXTURE_2D, 0,
patchOffset.x() - 1, patchOffset.y(),
1, patchSize.height(),
GL_BGRA, m_texturesInfo->type,
m_texturesInfo->format,
m_texturesInfo->type,
columnBuffer.constData());
}
......@@ -180,7 +189,8 @@ inline void KisTextureTile::repeatStripes(const KisTextureTileUpdateInfo &update
glTexSubImage2D(GL_TEXTURE_2D, 0,
patchOffset.x() + patchSize.width(), patchOffset.y(),
1, patchSize.height(),
GL_BGRA, m_texturesInfo->type,
m_texturesInfo->format,
m_texturesInfo->type,
columnBuffer.constData());
}
......
......@@ -38,6 +38,7 @@ struct KisGLTexturesInfo {
int border;
GLint internalFormat;
GLint format;
GLint type;
};
......
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