[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/kwin
From:       Thomas Lübking <thomas.luebking () web ! de>
Date:       2010-12-04 10:01:57
Message-ID: 20101204100157.F30A3AC8A4 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1203489 by luebking:

avoid recreating effectframes/textures on setPosition; correct position after \
setAlignment

 M  +25 -21    effects.cpp  
 M  +1 -1      effects.h  
 M  +11 -7     lib/kwinglutils.cpp  
 M  +1 -1      lib/kwinglutils.h  
 M  +7 -1      scene_opengl.cpp  


--- trunk/KDE/kdebase/workspace/kwin/effects.cpp #1203488:1203489
@@ -1837,20 +1837,38 @@
     return m_alignment;
     }
 
+
+void
+EffectFrameImpl::align( QRect &geometry )
+{
+    if( m_alignment & Qt::AlignLeft )
+        geometry.moveLeft( m_point.x() );
+    else if( m_alignment & Qt::AlignRight )
+        geometry.moveLeft( m_point.x() - geometry.width() );
+    else
+        geometry.moveLeft( m_point.x() - geometry.width() / 2 );
+    if( m_alignment & Qt::AlignTop )
+        geometry.moveTop( m_point.y() );
+    else if( m_alignment & Qt::AlignBottom )
+        geometry.moveTop( m_point.y() - geometry.height() );
+    else
+        geometry.moveTop( m_point.y() - geometry.height() / 2 );
+}
+
+
 void EffectFrameImpl::setAlignment( Qt::Alignment alignment )
     {
     m_alignment = alignment;
+    align( m_geometry );
+    setGeometry( m_geometry );
     }
 
 void EffectFrameImpl::setPosition( const QPoint& point )
     {
-    if( m_point == point )
-        {
-        return;
-        }
     m_point = point;
-    autoResize();
-    free();
+    QRect geometry = m_geometry; // this is important, setGeometry need call repaint \
for old & new geometry +    align( geometry );
+    setGeometry( geometry );
     }
 
 const QString& EffectFrameImpl::text() const
@@ -1898,7 +1916,6 @@
         return; // Not automatically resizing
 
     QRect geometry;
-
     // Set size
     if( !m_text.isEmpty() )
         {
@@ -1912,20 +1929,7 @@
             geometry.setHeight( m_iconSize.height() );
         }
 
-    // Set position
-    if( m_alignment & Qt::AlignLeft )
-        geometry.moveLeft( m_point.x() );
-    else if( m_alignment & Qt::AlignRight )
-        geometry.moveLeft( m_point.x() - geometry.width() );
-    else
-        geometry.moveLeft( m_point.x() - geometry.width() / 2 );
-    if( m_alignment & Qt::AlignTop )
-        geometry.moveTop( m_point.y() );
-    else if( m_alignment & Qt::AlignBottom )
-        geometry.moveTop( m_point.y() - geometry.height() );
-    else
-        geometry.moveTop( m_point.y() - geometry.height() / 2 );
-
+    align( geometry );
     setGeometry( geometry );
     }
 
--- trunk/KDE/kdebase/workspace/kwin/effects.h #1203488:1203489
@@ -374,7 +374,7 @@
 
     private:
         Q_DISABLE_COPY( EffectFrameImpl ) // As we need to use Qt slots we cannot \
                copy this class
-
+        void align( QRect &geometry ); // positions geometry around m_point \
respecting m_alignment  void autoResize(); // Auto-resize if not a static size
 
         EffectFrameStyle m_style;
--- trunk/KDE/kdebase/workspace/kwin/lib/kwinglutils.cpp #1203488:1203489
@@ -434,19 +434,21 @@
 
 void GLTexture::render( QRegion region, const QRect& rect )
     {
-    if( rect != m_cachedGeometry )
+    if( rect.size() != m_cachedSize )
         {
-        m_cachedGeometry = rect;
+        m_cachedSize = rect.size();
+        QRect r(rect);
+        r.moveTo(0,0);
         if( !m_vbo )
             {
             m_vbo = new GLVertexBuffer( KWin::GLVertexBuffer::Static );
             }
         const float verts[ 4 * 2 ] =
-            {
-            rect.x(), rect.y(),
-            rect.x(), rect.y() + rect.height(),
-            rect.x() + rect.width(), rect.y(),
-            rect.x() + rect.width(), rect.y() + rect.height()
+            {   // NOTICE: r.x/y could be replaced by "0", but that would make it \
unreadable... +            r.x(), r.y(),
+            r.x(), r.y() + rect.height(),
+            r.x() + rect.width(), r.y(),
+            r.x() + rect.width(), r.y() + rect.height()
             };
         const float texcoords[ 4 * 2 ] =
             {
@@ -457,7 +459,9 @@
             };
         m_vbo->setData( 4, 2, verts, texcoords );
         }
+    glTranslatef( rect.x(), rect.y(), 0.0f );
     m_vbo->render( region, GL_TRIANGLE_STRIP );
+    glTranslatef( -rect.x(), -rect.y(), 0.0f );
     }
 
 void GLTexture::enableUnnormalizedTexCoords()
--- trunk/KDE/kdebase/workspace/kwin/lib/kwinglutils.h #1203488:1203489
@@ -198,7 +198,7 @@
         int mUnnormalizeActive; // 0 - no, otherwise refcount
         int mNormalizeActive; // 0 - no, otherwise refcount
         GLVertexBuffer* m_vbo;
-        QRect m_cachedGeometry;
+        QSize m_cachedSize;
 
         static bool mNPOTTextureSupported;
         static bool mFramebufferObjectSupported;
--- trunk/KDE/kdebase/workspace/kwin/scene_opengl.cpp #1203488:1203489
@@ -2049,7 +2049,10 @@
         if( !m_unstyledVBO )
             {
             m_unstyledVBO = new GLVertexBuffer( GLVertexBuffer::Static );
-            const QRect& area = m_effectFrame->geometry().adjusted( -5, -5, 5, 5 );
+            QRect area = m_effectFrame->geometry();
+            area.moveTo(0,0);
+            area.adjust( -5, -5, 5, 5 );
+            
             const int roundness = 5;
             QVector<float> verts, texCoords;
             verts.reserve( 84 );
@@ -2156,7 +2159,10 @@
             glColor4f( 0.0, 0.0, 0.0, opacity * frameOpacity );
 
         m_unstyledTexture->bind();
+        const QPoint pt = m_effectFrame->geometry().topLeft();
+        glTranslatef( pt.x(), pt.y(), 0.0f );
         m_unstyledVBO->render( region, GL_TRIANGLES );
+        glTranslatef( -pt.x(), -pt.y(), 0.0f );
         m_unstyledTexture->unbind();
         }
     else if( m_effectFrame->style() == EffectFrameStyled )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic