~ubuntu-branches/ubuntu/hardy/kdebase-workspace/hardy-backports

« back to all changes in this revision

Viewing changes to plasma/containments/desktop/renderthread.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Richard A. Johnson
  • Date: 2008-05-02 23:57:34 UTC
  • mfrom: (1.2.1 upstream) (20.1.22 hardy)
  • Revision ID: james.westby@ubuntu.com-20080502235734-kwrykz4qcvunwqf4
Tags: 4:4.0.4-0ubuntu1~hardy1
* New upstream release (LP: #225994)
* Updated control file (LP: #220655)
* Updated install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#include "renderthread.h"
11
11
 
12
12
#include <QPainter>
 
13
#include <QFile>
13
14
#include <KDebug>
14
15
#include <KSvgRenderer>
15
16
 
45
46
                          Background::ResizeMethod method,
46
47
                          Qt::TransformationMode mode)
47
48
{
 
49
    int token;
48
50
    {
49
51
        QMutexLocker lock(&m_mutex);
50
52
        m_file = file;
52
54
        m_method = method;
53
55
        m_mode = mode;
54
56
        m_restart = true;
 
57
        token = ++m_current_token;
55
58
    }
56
59
    
57
60
    if (!isRunning()) {
61
64
        m_condition.wakeOne();
62
65
    }
63
66
    
64
 
    return ++m_current_token;
 
67
    return token;
65
68
}
66
69
 
67
70
void RenderThread::run()
95
98
            mode = m_mode;
96
99
        }
97
100
        
 
101
        QImage result(size, QImage::Format_ARGB32_Premultiplied);
 
102
        result.fill(color.rgb());
 
103
 
 
104
        if (file.isEmpty() || !QFile::exists(file)) {
 
105
            emit done(token, result);
 
106
            continue;
 
107
        }
 
108
        
98
109
        QPoint pos(0, 0);
99
110
        bool tiled = false;
100
111
        bool scalable = file.endsWith("svg") || file.endsWith("svgz");
118
129
        }
119
130
        imgSize *= ratio;
120
131
        
 
132
        // if any of them is zero we may run into a div-by-zero below.
 
133
        if (imgSize.width() == 0) {
 
134
            imgSize.setWidth(1);
 
135
        }
 
136
        if (imgSize.height() == 0) {
 
137
            imgSize.setHeight(1);
 
138
        }
 
139
 
121
140
        // set render parameters according to resize mode
122
141
        switch (method)
123
142
        {
161
180
            break;
162
181
        }
163
182
        
164
 
        QImage result(size, QImage::Format_ARGB32_Premultiplied);
165
 
        result.fill(color.rgb());
166
 
        
167
183
        QPainter p(&result);
168
184
        if (scalable) {
169
185
            // tiling is ignored for scalable wallpapers