kwinglutils: bind texture in GLTexture::render

... instead of doing it everywhere that the method is used
This commit is contained in:
Xaver Hugl 2023-04-02 12:32:04 +02:00
parent 52361936e7
commit 86a9796a5a
13 changed files with 2 additions and 28 deletions

View file

@ -66,11 +66,9 @@ void CursorDelegateOpenGL::paint(const RenderTarget &renderTarget, const QRegion
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
m_texture->bind();
ShaderBinder binder(ShaderTrait::MapTexture);
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
m_texture->render(region, cursorRect.size(), scale);
m_texture->unbind();
glDisable(GL_BLEND);
GLFramebuffer::popFramebuffer();

View file

@ -1646,9 +1646,7 @@ void EffectsHandlerImpl::renderOffscreenQuickView(const RenderTarget &renderTarg
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
t->bind();
t->render(w->size(), viewport.scale());
t->unbind();
glDisable(GL_BLEND);
ShaderManager::instance()->popShader();

View file

@ -125,14 +125,12 @@ void MagnifierEffect::paintScreen(const RenderTarget &renderTarget, const Render
if (effects->isOpenGLCompositing()) {
m_fbo->blitFromRenderTarget(renderTarget, viewport, srcArea.toRect(), QRect(QPoint(), m_fbo->size()));
// paint magnifier
m_texture->bind();
auto s = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture);
QMatrix4x4 mvp = viewport.projectionMatrix();
mvp.translate(area.x() * scale, area.y() * scale);
s->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
m_texture->render(area.size(), scale);
ShaderManager::instance()->popShader();
m_texture->unbind();
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
vbo->reset();

View file

@ -80,7 +80,6 @@ void ScreenEdgeEffect::paintScreen(const RenderTarget &renderTarget, const Rende
GLTexture *texture = glow->texture.get();
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
texture->bind();
ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::Modulate);
const QVector4D constant(opacity, opacity, opacity, opacity);
binder.shader()->setUniform(GLShader::ModulationConstant, constant);
@ -89,7 +88,6 @@ void ScreenEdgeEffect::paintScreen(const RenderTarget &renderTarget, const Rende
mvp.translate(glow->geometry.x() * scale, glow->geometry.y() * scale);
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
texture->render(glow->geometry.size(), scale);
texture->unbind();
glDisable(GL_BLEND);
} else if (effects->compositingType() == QPainterCompositing) {
QImage tmp(glow->image->size(), QImage::Format_ARGB32_Premultiplied);

View file

@ -213,7 +213,6 @@ void StartupFeedbackEffect::paintScreen(const RenderTarget &renderTarget, const
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
texture->bind();
if (m_type == BlinkingFeedback && m_blinkingShader && m_blinkingShader->isValid()) {
const QColor &blinkingColor = BLINKING_COLORS[FRAME_TO_BLINKING_COLOR[m_frame]];
ShaderManager::instance()->pushShader(m_blinkingShader.get());
@ -227,7 +226,6 @@ void StartupFeedbackEffect::paintScreen(const RenderTarget &renderTarget, const
ShaderManager::instance()->getBoundShader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
texture->render(m_currentGeometry.size(), scale);
ShaderManager::instance()->popShader();
texture->unbind();
glDisable(GL_BLEND);
}
}

View file

@ -122,9 +122,7 @@ void TrackMouseEffect::paintScreen(const RenderTarget &renderTarget, const Rende
QMatrix4x4 mvp(matrix);
mvp.translate(m_lastRect[i].x() * scale, m_lastRect[i].y() * scale);
shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
m_texture[i]->bind();
m_texture[i]->render(m_lastRect[i].size(), scale);
m_texture[i]->unbind();
}
glDisable(GL_BLEND);
} else if (effects->compositingType() == QPainterCompositing && !m_image[0].isNull() && !m_image[1].isNull()) {

View file

@ -361,9 +361,7 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp
shader->setUniform(GLShader::ModelViewProjectionMatrix, viewport.projectionMatrix() * matrix);
offscreen.texture->bind();
offscreen.texture->render(offscreen.viewport.size(), scale);
offscreen.texture->unbind();
}
ShaderManager::instance()->popShader();
@ -382,7 +380,6 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp
const QPointF p = (effects->cursorPos() - cursor.hotSpot()) * zoom + QPoint(xTranslation, yTranslation);
cursorTexture->bind();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
auto s = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture);
@ -391,7 +388,6 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp
s->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
cursorTexture->render(cursorSize, scale);
ShaderManager::instance()->popShader();
cursorTexture->unbind();
glDisable(GL_BLEND);
}
}

View file

@ -564,7 +564,9 @@ void GLTexture::render(const QRectF &source, const QRegion &region, const QSizeF
d->m_vbo->setData(4, 2, verts, texcoords);
}
bind();
d->m_vbo->render(region, GL_TRIANGLE_STRIP, hardwareClipping);
unbind();
}
GLuint GLTexture::texture() const

View file

@ -1193,9 +1193,7 @@ bool GLFramebuffer::blitFromRenderTarget(const RenderTarget &sourceRenderTarget,
ShaderBinder binder(ShaderTrait::MapTexture);
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mat);
texture->bind();
texture->render(sourceViewport.mapToRenderTargetTexture(source), infiniteRegion(), destination.size(), 1);
texture->unbind();
GLFramebuffer::popFramebuffer();
return true;

View file

@ -66,9 +66,7 @@ void OutputScreenCastSource::render(GLFramebuffer *target)
shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
GLFramebuffer::pushFramebuffer(target);
outputTexture->bind();
outputTexture->render(textureSize(), m_output->scale());
outputTexture->unbind();
GLFramebuffer::popFramebuffer();
}

View file

@ -64,9 +64,7 @@ void RegionScreenCastSource::updateOutput(Output *output)
shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
outputTexture->bind();
outputTexture->render(output->geometry().size(), 1 / m_scale);
outputTexture->unbind();
GLFramebuffer::popFramebuffer();
}
}
@ -102,9 +100,7 @@ void RegionScreenCastSource::render(GLFramebuffer *target)
projectionMatrix.ortho(QRect(QPoint(), target->size()));
shader->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
m_renderedTexture->bind();
m_renderedTexture->render(target->size(), m_scale);
m_renderedTexture->unbind();
ShaderManager::instance()->popShader();
GLFramebuffer::popFramebuffer();

View file

@ -527,7 +527,6 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
}
m_cursor.texture->setContentTransform(TextureTransforms());
m_cursor.texture->bind();
const auto cursorRect = cursorGeometry(cursor);
mvp.translate(cursorRect.left(), r.height() - cursorRect.top() - cursor->image().height());
shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
@ -536,7 +535,6 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
m_cursor.texture->render(cursorRect.size(), m_cursor.scale);
glDisable(GL_BLEND);
m_cursor.texture->unbind();
ShaderManager::instance()->popShader();
GLFramebuffer::popFramebuffer();

View file

@ -92,9 +92,7 @@ static void grabTexture(GLTexture *texture, spa_data *spa, spa_video_format form
shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
GLFramebuffer::pushFramebuffer(&fbo);
texture->bind();
texture->render(size, 1);
texture->unbind();
GLFramebuffer::popFramebuffer();
doGrabTexture(&backingTexture, spa, format);
} else {