Commit 3addda33 authored by Martin Flöser's avatar Martin Flöser
Browse files

Drop GLVertexBuffer::useShader.

The vertex buffer implementation uses the shader manager to decide
whether core painting should be used or not. Shader manager is only
used by shaders using vertex attributes instead of gl_Vertex etc.
parent 87f4f53b
......@@ -335,7 +335,6 @@ void CoverSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData&
verts << vertices[6] << vertices[7] << vertices[8];
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
vbo->reset();
vbo->setUseShader(true);
vbo->setData(6, 3, verts.data(), texcoords.data());
vbo->render(GL_TRIANGLES);
......
......@@ -550,7 +550,6 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
verts << vertices[6] << vertices[7] << vertices[8];
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
vbo->reset();
vbo->setUseShader(true);
vbo->setData(6, 3, verts.data(), texcoords.data());
vbo->render(GL_TRIANGLES);
......@@ -1123,9 +1122,6 @@ void CubeEffect::paintCubeCap()
delete m_cubeCapBuffer;
m_cubeCapBuffer = new GLVertexBuffer(GLVertexBuffer::Static);
m_cubeCapBuffer->setData(verts.count()/3, 3, verts.constData(), texture ? texCoords.constData() : NULL);
if (ShaderManager::instance()->isValid() && m_capShader->isValid()) {
m_cubeCapBuffer->setUseShader(true);
}
}
void CubeEffect::paintCylinderCap()
......
......@@ -87,7 +87,6 @@ void MouseMarkEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
vbo->setColor(color);
if (ShaderManager::instance()->isValid()) {
ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
vbo->setUseShader(true);
}
QVector<float> verts;
foreach (const Mark& mark, marks) {
......
......@@ -94,7 +94,6 @@ void ResizeEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Windo
vbo->setUseColor(true);
if (ShaderManager::instance()->isValid()) {
ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
vbo->setUseShader(true);
}
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
......
......@@ -85,7 +85,6 @@ void ShowPaintEffect::paintGL()
vbo->setUseColor(true);
if (ShaderManager::instance()->isValid()) {
ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
vbo->setUseShader(true);
}
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
......
......@@ -88,7 +88,6 @@ void SnapHelperEffect::postPaintScreen()
vbo->setUseColor(true);
if (ShaderManager::instance()->isValid()) {
ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
vbo->setUseShader(true);
}
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
......
......@@ -130,7 +130,7 @@ void TrackMouseEffect::paintScreen( int mask, QRegion region, ScreenPaintData& d
++i )
{
QRect r = starRect( i );
texture->render( region, r, useShader );
texture->render( region, r );
}
texture->unbind();
glDisable(GL_BLEND);
......
......@@ -513,11 +513,6 @@ void GLTexture::unbind()
}
void GLTexture::render( QRegion region, const QRect& rect )
{
render( region, rect, false );
}
void GLTexture::render( QRegion region, const QRect& rect, bool useShader )
{
if( rect.size() != m_cachedSize )
{
......@@ -544,16 +539,18 @@ void GLTexture::render( QRegion region, const QRect& rect, bool useShader )
};
m_vbo->setData( 4, 2, verts, texcoords );
}
if (useShader) {
ShaderManager::instance()->getBoundShader()->setUniform("offset", QVector2D(rect.x(), rect.y()));
if (ShaderManager::instance()->isShaderBound()) {
GLShader *shader = ShaderManager::instance()->getBoundShader();
shader->setUniform("offset", QVector2D(rect.x(), rect.y()));
shader->setUniform("textureWidth", 1.0f);
shader->setUniform("textureHeight", 1.0f);
} else {
#ifndef KWIN_HAVE_OPENGLES
glTranslatef( rect.x(), rect.y(), 0.0f );
#endif
}
m_vbo->setUseShader( useShader );
m_vbo->render( region, GL_TRIANGLE_STRIP );
if (!useShader) {
if (!ShaderManager::instance()->isShaderBound()) {
#ifndef KWIN_HAVE_OPENGLES
glTranslatef( -rect.x(), -rect.y(), 0.0f );
#endif
......@@ -1524,7 +1521,6 @@ class GLVertexBufferPrivate
: hint( usageHint )
, numberVertices( 0 )
, dimension( 2 )
, useShader( false )
, useColor( false )
, useTexCoords( true )
, color( 0, 0, 0, 255 )
......@@ -1545,7 +1541,6 @@ class GLVertexBufferPrivate
GLuint buffers[2];
int numberVertices;
int dimension;
bool useShader;
static bool supported;
static GLVertexBuffer *streamingBuffer;
QVector<float> legacyVertices;
......@@ -1707,7 +1702,7 @@ void GLVertexBuffer::render( const QRegion& region, GLenum primitiveMode )
d->legacyPainting( region, primitiveMode );
return;
}
if( d->useShader )
if( ShaderManager::instance()->isShaderBound() )
{
d->corePainting( region, primitiveMode );
return;
......@@ -1741,16 +1736,6 @@ void GLVertexBuffer::render( const QRegion& region, GLenum primitiveMode )
#endif
}
void GLVertexBuffer::setUseShader( bool use )
{
d->useShader = use;
}
bool GLVertexBuffer::isUseShader() const
{
return d->useShader;
}
bool GLVertexBuffer::isSupported()
{
return GLVertexBufferPrivate::supported;
......@@ -1778,7 +1763,6 @@ void GLVertexBuffer::reset()
d->color = QColor(0, 0, 0, 255);
d->numberVertices = 0;
d->dimension = 2;
d->useShader = false;
d->useTexCoords = true;
}
......
......@@ -149,17 +149,6 @@ class KWIN_EXPORT GLTexture
virtual void bind();
virtual void unbind();
void render( QRegion region, const QRect& rect );
/**
* Same as above, but allows to specify if the geometry of the texture
* should be passed for a core profile shader. The shader needs to be
* bound before. The default is to perform legacy rendering.
* @param useShader If @c true core profile compatible rendering is used.
* If a bound shader is not core profile compatible @c false should be used.
* @see render
* @see GLVertexBuffer::setUseShader
* @since 4.7
*/
void render( QRegion region, const QRect& rect, bool useShader );
/**
* Set up texture transformation matrix to automatically map unnormalized
* texture coordinates (i.e. 0 to width, 0 to height, (0,0) is top-left)
......@@ -520,22 +509,6 @@ class KWIN_EXPORT GLVertexBuffer
* Same as above restricting painting to @a region.
*/
void render( const QRegion& region, GLenum primitiveMode );
/**
* Use methods from core profile to perform rendering. A core compatible shader has
* to be bound while rendering.
* If the shader emulates fixed functionality rendering (e.g. uses gl_Vertex) using core
* rendering should be disabled.
* The default rendering path does not use core profile rendering.
* @param use enable/disable use of core profile rendering.
* @since 4.7
**/
void setUseShader( bool use );
/**
* @returns @c true if core profile methods are used for rendering, @c false otherwise.
* @see setUseShader
* @since 4.7
**/
bool isUseShader() const;
/**
* Sets the color the geometry will be rendered with.
* For legacy rendering glColor is used before rendering the geometry.
......
......@@ -530,7 +530,6 @@ void SceneOpenGL::Window::performPaint( int mask, QRegion region, WindowPaintDat
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
vbo->reset();
vbo->setUseShader(sceneShader);
// decorations
Client *client = dynamic_cast<Client*>(toplevel);
......@@ -1288,7 +1287,6 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
glTranslatef( pt.x(), pt.y(), 0.0f );
#endif
}
m_unstyledVBO->setUseShader( sceneShader );
m_unstyledVBO->render( region, GL_TRIANGLES );
#ifndef KWIN_HAVE_OPENGLES
if (!sceneShader) {
......@@ -1311,7 +1309,7 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
m_texture->bind();
qreal left, top, right, bottom;
m_effectFrame->frame().getMargins( left, top, right, bottom ); // m_geometry is the inner geometry
m_texture->render( region, m_effectFrame->geometry().adjusted( -left, -top, right, bottom ), sceneShader );
m_texture->render( region, m_effectFrame->geometry().adjusted( -left, -top, right, bottom ) );
m_texture->unbind();
if( !m_effectFrame->selection().isNull() )
......@@ -1324,7 +1322,7 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
}
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
m_selectionTexture->bind();
m_selectionTexture->render( region, m_effectFrame->selection(), sceneShader );
m_selectionTexture->render( region, m_effectFrame->selection() );
m_selectionTexture->unbind();
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
......@@ -1373,7 +1371,7 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
m_iconTexture->setYInverted(true);
}
m_iconTexture->bind();
m_iconTexture->render( region, QRect( topLeft, m_effectFrame->iconSize() ), sceneShader );
m_iconTexture->render( region, QRect( topLeft, m_effectFrame->iconSize() ) );
m_iconTexture->unbind();
}
......@@ -1390,7 +1388,7 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
#endif
m_oldTextTexture->bind();
m_oldTextTexture->render( region, m_effectFrame->geometry(), sceneShader );
m_oldTextTexture->render( region, m_effectFrame->geometry() );
m_oldTextTexture->unbind();
if( shader )
shader->setUniform( "opacity", (float)opacity * (float)m_effectFrame->crossFadeProgress() );
......@@ -1411,7 +1409,7 @@ void SceneOpenGL::EffectFrame::render( QRegion region, double opacity, double fr
if( !m_textTexture ) // Lazy creation
updateTextTexture();
m_textTexture->bind();
m_textTexture->render( region, m_effectFrame->geometry(), sceneShader );
m_textTexture->render( region, m_effectFrame->geometry() );
m_textTexture->unbind();
}
......
......@@ -278,7 +278,6 @@ void SceneOpenGL::paintBackground(QRegion region)
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
vbo->reset();
vbo->setUseColor(true);
vbo->setUseShader(true);
vbo->setData(verts.count() / 2, 2, verts.data(), NULL);
GLShader *shader = ShaderManager::instance()->pushShader(ShaderManager::ColorShader);
shader->setUniform("offset", QVector2D(0, 0));
......
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