diff --git a/effects/backgroundcontrast/contrast.cpp b/effects/backgroundcontrast/contrast.cpp index 30d20c42e3..6aa05a31ae 100644 --- a/effects/backgroundcontrast/contrast.cpp +++ b/effects/backgroundcontrast/contrast.cpp @@ -174,7 +174,7 @@ bool ContrastEffect::enabledByDefault() bool ContrastEffect::supported() { - bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported() && GLTexture::NPOTTextureSupported(); + bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported(); if (supported) { int maxTexSize; diff --git a/effects/blur/blur.cpp b/effects/blur/blur.cpp index 0663ace0de..36bfebbed3 100644 --- a/effects/blur/blur.cpp +++ b/effects/blur/blur.cpp @@ -154,7 +154,7 @@ bool BlurEffect::enabledByDefault() bool BlurEffect::supported() { - bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported() && GLTexture::NPOTTextureSupported(); + bool supported = effects->isOpenGLCompositing() && GLRenderTarget::supported(); if (supported) { int maxTexSize; diff --git a/effects/logout/logout.cpp b/effects/logout/logout.cpp index effc99bcaa..4f7e1a041c 100644 --- a/effects/logout/logout.cpp +++ b/effects/logout/logout.cpp @@ -105,7 +105,7 @@ void LogoutEffect::prePaintScreen(ScreenPrePaintData& data, int time) } else if (!blurTexture) { blurSupported = false; delete blurTarget; // catch as we just tested the texture ;-P - if (effects->isOpenGLCompositing() && GLTexture::NPOTTextureSupported() && GLRenderTarget::blitSupported() && useBlur) { + if (effects->isOpenGLCompositing() && GLRenderTarget::blitSupported() && useBlur) { // TODO: It seems that it is not possible to create a GLRenderTarget that has // a different size than the display right now. Most likely a KWin core bug. // Create texture and render target diff --git a/effects/lookingglass/lookingglass.cpp b/effects/lookingglass/lookingglass.cpp index fe144185cf..d30aa7f008 100644 --- a/effects/lookingglass/lookingglass.cpp +++ b/effects/lookingglass/lookingglass.cpp @@ -94,17 +94,10 @@ void LookingGlassEffect::reconfigure(ReconfigureFlags) bool LookingGlassEffect::loadData() { - // If NPOT textures are not supported, use nearest power-of-two sized - // texture. It wastes memory, but it's possible to support systems without - // NPOT textures that way const QSize screenSize = effects->virtualScreenSize(); int texw = screenSize.width(); int texh = screenSize.height(); - if (!GLTexture::NPOTTextureSupported()) { - qWarning() << "NPOT textures not supported, wasting some memory" ; - texw = nearestPowerOfTwo(texw); - texh = nearestPowerOfTwo(texh); - } + // Create texture and render target m_texture = new GLTexture(texw, texh); m_texture->setFilter(GL_LINEAR_MIPMAP_LINEAR); diff --git a/effects/screenshot/screenshot.cpp b/effects/screenshot/screenshot.cpp index 1d7e2114c6..14eaf7e0bf 100644 --- a/effects/screenshot/screenshot.cpp +++ b/effects/screenshot/screenshot.cpp @@ -110,13 +110,7 @@ void ScreenShotEffect::postPaintScreen() QScopedPointer offscreenTexture; QScopedPointer target; if (effects->isOpenGLCompositing()) { - int w = width; - int h = height; - if (!GLTexture::NPOTTextureSupported()) { - w = nearestPowerOfTwo(w); - h = nearestPowerOfTwo(h); - } - offscreenTexture.reset(new GLTexture(w, h)); + offscreenTexture.reset(new GLTexture(width, height)); offscreenTexture->setFilter(GL_LINEAR); offscreenTexture->setWrapMode(GL_CLAMP_TO_EDGE); target.reset(new GLRenderTarget(*offscreenTexture)); diff --git a/glxbackend.cpp b/glxbackend.cpp index 40539f6a61..9fd178e569 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -746,9 +746,7 @@ bool GlxTexture::loadTexture(xcb_pixmap_t pixmap, const QSize &size, xcb_visuali if (!info || info->fbconfig == nullptr) return false; - if ((info->texture_targets & GLX_TEXTURE_2D_BIT_EXT) && - (GLTexture::NPOTTextureSupported() || - (isPowerOfTwo(size.width()) && isPowerOfTwo(size.height())))) { + if (info->texture_targets & GLX_TEXTURE_2D_BIT_EXT) { m_target = GL_TEXTURE_2D; m_scale.setWidth(1.0f / m_size.width()); m_scale.setHeight(1.0f / m_size.height()); diff --git a/lanczosfilter.cpp b/lanczosfilter.cpp index d25cbf885a..d16f958de9 100644 --- a/lanczosfilter.cpp +++ b/lanczosfilter.cpp @@ -103,10 +103,7 @@ void LanczosFilter::updateOffscreenSurfaces() { int w = displayWidth(); int h = displayHeight(); - if (!GLTexture::NPOTTextureSupported()) { - w = nearestPowerOfTwo(w); - h = nearestPowerOfTwo(h); - } + if (!m_offscreenTex || m_offscreenTex->width() != w || m_offscreenTex->height() != h) { if (m_offscreenTex) { delete m_offscreenTex; diff --git a/libkwineffects/kwingltexture.cpp b/libkwineffects/kwingltexture.cpp index e98efa24cf..93104ed787 100644 --- a/libkwineffects/kwingltexture.cpp +++ b/libkwineffects/kwingltexture.cpp @@ -42,7 +42,6 @@ namespace KWin // GLTexture //**************************************** -bool GLTexturePrivate::sNPOTTextureSupported = false; bool GLTexturePrivate::sFramebufferObjectSupported = false; GLenum GLTexturePrivate::sTextureFormat = GL_RGBA; // custom dummy, GL_BGRA is not present on GLES uint GLTexturePrivate::s_textureObjectCounter = 0; @@ -86,27 +85,26 @@ GLTexture::GLTexture(int width, int height) : d_ptr(new GLTexturePrivate()) { Q_D(GLTexture); - if (NPOTTextureSupported() || (isPowerOfTwo(width) && isPowerOfTwo(height))) { - d->m_target = GL_TEXTURE_2D; - d->m_scale.setWidth(1.0 / width); - d->m_scale.setHeight(1.0 / height); - d->m_size = QSize(width, height); - d->m_canUseMipmaps = true; - d->updateMatrix(); + d->m_target = GL_TEXTURE_2D; + d->m_scale.setWidth(1.0 / width); + d->m_scale.setHeight(1.0 / height); + d->m_size = QSize(width, height); + d->m_canUseMipmaps = true; - glGenTextures(1, &d->m_texture); - bind(); + d->updateMatrix(); - if (!GLPlatform::instance()->isGLES()) { - glTexImage2D(d->m_target, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); - } else { - glTexImage2D(d->m_target, 0, GLTexturePrivate::sTextureFormat, width, height, - 0, GLTexturePrivate::sTextureFormat, GL_UNSIGNED_BYTE, 0); - } + glGenTextures(1, &d->m_texture); + bind(); - unbind(); + if (!GLPlatform::instance()->isGLES()) { + glTexImage2D(d->m_target, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); + } else { + glTexImage2D(d->m_target, 0, GLTexturePrivate::sTextureFormat, width, height, + 0, GLTexturePrivate::sTextureFormat, GL_UNSIGNED_BYTE, 0); } + + unbind(); } GLTexture::GLTexture(const QSize &size) @@ -159,11 +157,9 @@ GLTexturePrivate::~GLTexturePrivate() void GLTexturePrivate::initStatic() { if (!GLPlatform::instance()->isGLES()) { - sNPOTTextureSupported = hasGLExtension(QByteArrayLiteral("GL_ARB_texture_non_power_of_two")); sFramebufferObjectSupported = hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object")); sTextureFormat = GL_BGRA; } else { - sNPOTTextureSupported = true; sFramebufferObjectSupported = true; if (hasGLExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888"))) sTextureFormat = GL_BGRA_EXT; @@ -174,7 +170,6 @@ void GLTexturePrivate::initStatic() void GLTexturePrivate::cleanup() { - sNPOTTextureSupported = false; sFramebufferObjectSupported = false; sTextureFormat = GL_RGBA; // custom dummy, GL_BGRA is not present on GLES } @@ -199,18 +194,12 @@ bool GLTexture::load(const QImage& image, GLenum target) Q_D(GLTexture); if (image.isNull()) return false; - QImage img = image; + d->m_target = target; if (d->m_target != GL_TEXTURE_RECTANGLE_ARB) { - if (!NPOTTextureSupported() - && (!isPowerOfTwo(image.width()) || !isPowerOfTwo(image.height()))) { - // non-rectangular target requires POT texture - img = img.scaled(nearestPowerOfTwo(image.width()), - nearestPowerOfTwo(image.height())); - } - d->m_scale.setWidth(1.0 / img.width()); - d->m_scale.setHeight(1.0 / img.height()); + d->m_scale.setWidth(1.0 / image.width()); + d->m_scale.setHeight(1.0 / image.height()); d->m_canUseMipmaps = true; } else { d->m_scale.setWidth(1.0); @@ -218,12 +207,12 @@ bool GLTexture::load(const QImage& image, GLenum target) d->m_canUseMipmaps = false; } - d->m_size = img.size(); + d->m_size = image.size(); d->m_yInverted = true; d->updateMatrix(); - img = d->convertToGLFormat(img); + const QImage img = d->convertToGLFormat(image); if (isNull()) { glGenTextures(1, &d->m_texture); @@ -317,9 +306,7 @@ void GLTexture::bind() if (d->m_filterChanged) { if (d->m_filter == GL_LINEAR_MIPMAP_LINEAR) { // trilinear filtering requested, but is it possible? - if (d->sNPOTTextureSupported - && d->sFramebufferObjectSupported - && d->m_canUseMipmaps) { + if (d->sFramebufferObjectSupported && d->m_canUseMipmaps) { glTexParameteri(d->m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(d->m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glGenerateMipmap(d->m_target); @@ -595,11 +582,6 @@ QMatrix4x4 GLTexture::matrix(TextureCoordinateType type) const return d->m_matrix[type]; } -bool GLTexture::NPOTTextureSupported() -{ - return GLTexturePrivate::sNPOTTextureSupported; -} - bool GLTexture::framebufferObjectSupported() { return GLTexturePrivate::sFramebufferObjectSupported; diff --git a/libkwineffects/kwingltexture.h b/libkwineffects/kwingltexture.h index 53c6d19e1e..85db24c187 100644 --- a/libkwineffects/kwingltexture.h +++ b/libkwineffects/kwingltexture.h @@ -104,7 +104,6 @@ public: void setWrapMode(GLenum mode); void setDirty(); - static bool NPOTTextureSupported(); static bool framebufferObjectSupported(); protected: diff --git a/libkwineffects/kwingltexture_p.h b/libkwineffects/kwingltexture_p.h index 5c173cb812..9537ca68d9 100644 --- a/libkwineffects/kwingltexture_p.h +++ b/libkwineffects/kwingltexture_p.h @@ -70,7 +70,6 @@ public: static void initStatic(); - static bool sNPOTTextureSupported; static bool sFramebufferObjectSupported; static GLenum sTextureFormat; static uint s_fbo; diff --git a/paintredirector.cpp b/paintredirector.cpp index fe73340f6b..bea6ea28fe 100644 --- a/paintredirector.cpp +++ b/paintredirector.cpp @@ -357,10 +357,6 @@ void OpenGLPaintRedirector::resizePixmaps(const QRect *rects) size.rwidth() = align(size.width(), 128); effects->makeOpenGLContextCurrent(); - if (!GLTexture::NPOTTextureSupported()) { - size.rwidth() = nearestPowerOfTwo(size.width()); - size.rheight() = nearestPowerOfTwo(size.height()); - } if (m_texture && m_texture->size() == size) return;