Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Fix black canvas appearing when "Limit animation frame size" is active

Dmitry Kazakov66e3b37f2355
diff --git a/libs/ui/opengl/kis_texture_tile.cpp b/libs/ui/opengl/kis_texture_tile.cpp
index 5481ff0a7f..6330690cca 100644
--- a/libs/ui/opengl/kis_texture_tile.cpp
+++ b/libs/ui/opengl/kis_texture_tile.cpp
@@ -122,7 +122,7 @@ int KisTextureTile::bindToActiveTexture(bool blockMipmapRegeneration)
f->glBindTexture(GL_TEXTURE_2D, m_textureId);
if (m_needsMipmapRegeneration && !blockMipmapRegeneration) {
- f->glGenerateMipmap(GL_TEXTURE_2D);
+ regenerateMipmap();
setPreparedLodPlane(0);
}
@@ -144,6 +144,13 @@ void KisTextureTile::setPreparedLodPlane(int lod)
m_needsMipmapRegeneration = false;
}
+void KisTextureTile::regenerateMipmap()
+{
+ f->glGenerateMipmap(GL_TEXTURE_2D);
+ m_mipmapHasBeenAllocated = true;
+ m_needsMipmapRegeneration = false;
+}
+
void KisTextureTile::update(const KisTextureTileUpdateInfo &updateInfo, bool blockMipmapRegeneration)
{
f->initializeOpenGLFunctions();
@@ -176,14 +183,22 @@ void KisTextureTile::update(const KisTextureTileUpdateInfo &updateInfo, bool blo
*
* To avoid this issue, we should regenerate the dirty mipmap
* *before* doing anything with the low-resolution plane.
+ *
+ * Another case is when the user has Bilinear or
+ * Nearest Neighbour filtering selected and tries to use LoD
+ * funcionality in animation. glTexSubImage2D() and textureLod()
+ * are defined only when all the planes were explicitly initialized
+ * with glTexImage2D(), which doesn't happen in case of bilinear- or
+ * nn-filtering. In this case !m_mipmapHasBeenAllocated condition
+ * comes in.
*/
if (!blockMipmapRegeneration &&
patchLevelOfDetail > 0 &&
- m_needsMipmapRegeneration &&
- !updateInfo.isEntireTileUpdated()) {
+ (m_needsMipmapRegeneration &&
+ !updateInfo.isEntireTileUpdated())
+ || !m_mipmapHasBeenAllocated) {
- f->glGenerateMipmap(GL_TEXTURE_2D);
- m_needsMipmapRegeneration = false;
+ regenerateMipmap();
}
diff --git a/libs/ui/opengl/kis_texture_tile.h b/libs/ui/opengl/kis_texture_tile.h
index 97d4d72a16..f04a5339ba 100644
--- a/libs/ui/opengl/kis_texture_tile.h
+++ b/libs/ui/opengl/kis_texture_tile.h
@@ -82,6 +82,7 @@ private:
void setNeedsMipmapRegeneration();
void setPreparedLodPlane(int lod);
+ void regenerateMipmap();
GLuint m_textureId;
@@ -95,6 +96,7 @@ private:
int m_numMipmapLevels;
QOpenGLFunctions *f;
KisOpenGLBufferCircularStorage *m_bufferStorage;
+ bool m_mipmapHasBeenAllocated = false;
Q_DISABLE_COPY(KisTextureTile)
};