Commit c671ea19 authored by Tomaz  Canabrava's avatar Tomaz Canabrava

Set complete vectors instead of creting them at runtime

Summary: I tested a bit of code with -02 to measure the speed gains of using a std::initializer_list over appending to a temporary and appending to temporary is around 50% slower, so I removed all the code that appened to temporaries for a initializer list in breeze.

Reviewers: #breeze, #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, ngraham, zzag, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D13591
parent ebae01db
......@@ -206,27 +206,27 @@ namespace Breeze
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
painter->drawPolygon( QPolygonF()
<< QPointF( 4, 9 )
<< QPointF( 9, 4 )
<< QPointF( 14, 9 )
<< QPointF( 9, 14 ) );
painter->drawPolygon( QVector<QPointF>{
QPointF( 4, 9 ),
QPointF( 9, 4 ),
QPointF( 14, 9 ),
QPointF( 9, 14 )} );
} else {
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 11 )
<< QPointF( 9, 6 )
<< QPointF( 14, 11 ) );
painter->drawPolyline( QVector<QPointF>{
QPointF( 4, 11 ),
QPointF( 9, 6 ),
QPointF( 14, 11 )});
}
break;
}
case DecorationButtonType::Minimize:
{
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 7 )
<< QPointF( 9, 12 )
<< QPointF( 14, 7 ) );
painter->drawPolyline( QVector<QPointF>{
QPointF( 4, 7 ),
QPointF( 9, 12 ),
QPointF( 14, 7 ) });
break;
}
......@@ -254,11 +254,11 @@ namespace Breeze
} else {
painter->drawPolygon( QPolygonF()
<< QPointF( 6.5, 8.5 )
<< QPointF( 12, 3 )
<< QPointF( 15, 6 )
<< QPointF( 9.5, 11.5 ) );
painter->drawPolygon( QVector<QPointF> {
QPointF( 6.5, 8.5 ),
QPointF( 12, 3 ),
QPointF( 15, 6 ),
QPointF( 9.5, 11.5 )} );
painter->setPen( pen );
painter->drawLine( QPointF( 5.5, 7.5 ), QPointF( 10.5, 12.5 ) );
......@@ -274,18 +274,18 @@ namespace Breeze
{
painter->drawLine( 4, 5, 14, 5 );
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 8 )
<< QPointF( 9, 13 )
<< QPointF( 14, 8 ) );
painter->drawPolyline( QVector<QPointF> {
QPointF( 4, 8 ),
QPointF( 9, 13 ),
QPointF( 14, 8 )} );
} else {
painter->drawLine( 4, 5, 14, 5 );
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 13 )
<< QPointF( 9, 8 )
<< QPointF( 14, 13 ) );
painter->drawPolyline( QVector<QPointF> {
QPointF( 4, 13 ),
QPointF( 9, 8 ),
QPointF( 14, 13 ) });
}
break;
......@@ -295,30 +295,30 @@ namespace Breeze
case DecorationButtonType::KeepBelow:
{
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 5 )
<< QPointF( 9, 10 )
<< QPointF( 14, 5 ) );
painter->drawPolyline( QVector<QPointF> {
QPointF( 4, 5 ),
QPointF( 9, 10 ),
QPointF( 14, 5 ) });
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 9 )
<< QPointF( 9, 14 )
<< QPointF( 14, 9 ) );
painter->drawPolyline( QVector<QPointF> {
QPointF( 4, 9 ),
QPointF( 9, 14 ),
QPointF( 14, 9 ) });
break;
}
case DecorationButtonType::KeepAbove:
{
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 9 )
<< QPointF( 9, 4 )
<< QPointF( 14, 9 ) );
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 13 )
<< QPointF( 9, 8 )
<< QPointF( 14, 13 ) );
painter->drawPolyline( QVector<QPointF> {
QPointF( 4, 9 ),
QPointF( 9, 4 ),
QPointF( 14, 9 ) });
painter->drawPolyline( QVector<QPointF> {
QPointF( 4, 13 ),
QPointF( 9, 8 ),
QPointF( 14, 13 ) });
break;
}
......
......@@ -51,13 +51,11 @@ namespace Breeze
setFixedSize( QSize( GripSize, GripSize ) );
// mask
QPolygon p;
p << QPoint( 0, GripSize )
<< QPoint( GripSize, 0 )
<< QPoint( GripSize, GripSize )
<< QPoint( 0, GripSize );
setMask( QRegion( p ) );
setMask( QRegion( QVector<QPoint>{
QPoint( 0, GripSize ),
QPoint( GripSize, 0 ),
QPoint( GripSize, GripSize ),
QPoint( 0, GripSize )} ) );
// embed
embed();
......@@ -147,13 +145,11 @@ namespace Breeze
painter.setBrush( backgroundColor );
// polygon
QPolygon p;
p << QPoint( 0, GripSize )
<< QPoint( GripSize, 0 )
<< QPoint( GripSize, GripSize )
<< QPoint( 0, GripSize );
painter.drawPolygon( p );
painter.drawPolygon( QVector<QPoint> {
QPoint( 0, GripSize ),
QPoint( GripSize, 0 ),
QPoint( GripSize, GripSize ),
QPoint( 0, GripSize )} );
}
//_____________________________________________
......
......@@ -1297,15 +1297,14 @@ namespace Breeze
//______________________________________________________________________________
void Helper::renderArrow( QPainter* painter, const QRect& rect, const QColor& color, ArrowOrientation orientation ) const
{
// define polygon
QPolygonF arrow;
switch( orientation )
{
case ArrowUp: arrow << QPointF( -4, 2 ) << QPointF( 0, -2 ) << QPointF( 4, 2 ); break;
case ArrowDown: arrow << QPointF( -4, -2 ) << QPointF( 0, 2 ) << QPointF( 4, -2 ); break;
case ArrowLeft: arrow << QPointF( 2, -4 ) << QPointF( -2, 0 ) << QPointF( 2, 4 ); break;
case ArrowRight: arrow << QPointF( -2, -4 ) << QPointF( 2, 0 ) << QPointF( -2, 4 ); break;
case ArrowUp: arrow = QVector<QPointF>{QPointF( -4, 2 ), QPointF( 0, -2 ), QPointF( 4, 2 )}; break;
case ArrowDown: arrow = QVector<QPointF>{QPointF( -4, -2 ), QPointF( 0, 2 ), QPointF( 4, -2 )}; break;
case ArrowLeft: arrow = QVector<QPointF>{QPointF( 2, -4 ), QPointF( -2, 0 ), QPointF( 2, 4 )}; break;
case ArrowRight: arrow = QVector<QPointF>{QPointF( -2, -4 ), QPointF( 2, 0 ), QPointF( -2, 4 )}; break;
default: break;
}
......@@ -1367,20 +1366,20 @@ namespace Breeze
case ButtonMaximize:
{
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 11 )
<< QPointF( 9, 6 )
<< QPointF( 14, 11 ) );
painter->drawPolyline( QVector<QPointF>{
QPointF( 4, 11 ),
QPointF( 9, 6 ),
QPointF( 14, 11 )});
break;
}
case ButtonMinimize:
{
painter->drawPolyline( QPolygonF()
<< QPointF( 4, 7 )
<< QPointF( 9, 12 )
<< QPointF( 14, 7 ) );
painter->drawPolyline(QVector<QPointF>{
QPointF( 4, 7 ),
QPointF( 9, 12 ),
QPointF( 14, 7 )} );
break;
}
......@@ -1388,11 +1387,11 @@ namespace Breeze
{
pen.setJoinStyle( Qt::RoundJoin );
painter->setPen( pen );
painter->drawPolygon( QPolygonF()
<< QPointF( 4.5, 9 )
<< QPointF( 9, 4.5 )
<< QPointF( 13.5, 9 )
<< QPointF( 9, 13.5 ) );
painter->drawPolygon( QVector<QPointF>{
QPointF( 4.5, 9 ),
QPointF( 9, 4.5 ),
QPointF( 13.5, 9 ),
QPointF( 9, 13.5 )});
break;
}
......
......@@ -415,16 +415,16 @@ namespace Breeze
// make sure size is valid
if( _pixmaps.empty() )
{
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 1 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 2 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 5 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 8 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 7 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 6 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 3 ) ) );
_pixmaps.append( createPixmap( _shadowTiles.pixmap( 0 ) ) );
_pixmaps = QVector<quint32> {
createPixmap( _shadowTiles.pixmap( 1 ) ),
createPixmap( _shadowTiles.pixmap( 2 ) ),
createPixmap( _shadowTiles.pixmap( 5 ) ),
createPixmap( _shadowTiles.pixmap( 8 ) ),
createPixmap( _shadowTiles.pixmap( 7 ) ),
createPixmap( _shadowTiles.pixmap( 6 ) ),
createPixmap( _shadowTiles.pixmap( 3 ) ),
createPixmap( _shadowTiles.pixmap( 0 ) )
};
}
// return relevant list of pixmap handles
......@@ -504,23 +504,17 @@ namespace Breeze
#ifndef QT_NO_XRENDER
// create pixmap handles if needed
const QVector<quint32>& pixmaps( createPixmapHandles() );
if( pixmaps.size() != numPixmaps ) return false;
// create data
// add pixmap handles
QVector<quint32> data;
foreach( const quint32& value, pixmaps )
{ data.append( value ); }
QVector<quint32> data( createPixmapHandles() );
if( data.size() != numPixmaps ) return false;
const QMargins margins = shadowMargins( widget );
const int topSize = margins.top();
const int bottomSize = margins.bottom();
const int leftSize( margins.left() );
const int rightSize( margins.right() );
const quint32 topSize = margins.top();
const quint32 bottomSize = margins.bottom();
const quint32 leftSize( margins.left() );
const quint32 rightSize( margins.right() );
// assign to data and xcb property
data << topSize << rightSize << bottomSize << leftSize;
data << QVector<quint32>{topSize, rightSize, bottomSize, leftSize};
xcb_change_property( Helper::connection(), XCB_PROP_MODE_REPLACE, widget->winId(), _atom, XCB_ATOM_CARDINAL, 32, data.size(), data.constData() );
xcb_flush( Helper::connection() );
......
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