author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 3 | 41300fa6a67c |
child 8 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the plugins of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "qdirectfbpaintengine.h" |
|
43 |
||
44 |
#ifndef QT_NO_QWS_DIRECTFB |
|
45 |
||
46 |
#include "qdirectfbwindowsurface.h" |
|
47 |
#include "qdirectfbscreen.h" |
|
48 |
#include "qdirectfbpixmap.h" |
|
49 |
#include <directfb.h> |
|
50 |
#include <qtransform.h> |
|
51 |
#include <qvarlengtharray.h> |
|
52 |
#include <qcache.h> |
|
53 |
#include <qmath.h> |
|
54 |
#include <private/qpixmapdata_p.h> |
|
55 |
#include <private/qpixmap_raster_p.h> |
|
56 |
#include <private/qimagepixmapcleanuphooks_p.h> |
|
57 |
||
58 |
QT_BEGIN_NAMESPACE |
|
59 |
||
60 |
class SurfaceCache; |
|
61 |
class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate |
|
62 |
{ |
|
63 |
public: |
|
64 |
enum TransformationTypeFlags { |
|
65 |
Matrix_NegativeScale = 0x100, |
|
66 |
Matrix_RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject), |
|
67 |
Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported) |
|
68 |
}; |
|
69 |
||
70 |
enum CompositionModeStatus { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
PorterDuff_None = 0x00, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
PorterDuff_SupportedBlits = 0x01, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
73 |
PorterDuff_SupportedPrimitives = 0x02, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
74 |
PorterDuff_SupportedOpaquePrimitives = 0x04, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
75 |
PorterDuff_Dirty = 0x10 |
0 | 76 |
}; |
77 |
||
78 |
enum ClipType { |
|
79 |
ClipUnset, |
|
80 |
NoClip, |
|
81 |
RectClip, |
|
82 |
RegionClip, |
|
83 |
ComplexClip |
|
84 |
}; |
|
85 |
||
86 |
QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p); |
|
87 |
~QDirectFBPaintEnginePrivate(); |
|
88 |
||
89 |
inline void setTransform(const QTransform &transforma); |
|
90 |
inline void setPen(const QPen &pen); |
|
91 |
inline void setCompositionMode(QPainter::CompositionMode mode); |
|
92 |
inline void setRenderHints(QPainter::RenderHints hints); |
|
93 |
||
94 |
inline void setDFBColor(const QColor &color); |
|
95 |
||
96 |
inline void lock(); |
|
97 |
inline void unlock(); |
|
98 |
static inline void unlock(QDirectFBPaintDevice *device); |
|
99 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
100 |
inline bool testCompositionMode(const QPen *pen, const QBrush *brush, const QColor *color = 0) const; |
0 | 101 |
inline bool isSimpleBrush(const QBrush &brush) const; |
102 |
||
103 |
void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos); |
|
104 |
void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); |
|
105 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
106 |
inline bool supportsStretchBlit() const; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
107 |
|
0 | 108 |
inline void updateClip(); |
109 |
virtual void systemStateChanged(); |
|
110 |
||
111 |
static IDirectFBSurface *getSurface(const QImage &img, bool *release); |
|
112 |
||
113 |
#ifdef QT_DIRECTFB_IMAGECACHE |
|
114 |
static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; } |
|
115 |
#endif |
|
116 |
||
117 |
void prepareForBlit(bool alpha); |
|
118 |
||
119 |
IDirectFBSurface *surface; |
|
120 |
||
121 |
bool antialiased; |
|
122 |
bool simplePen; |
|
123 |
||
124 |
uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0 |
|
125 |
||
126 |
SurfaceCache *surfaceCache; |
|
127 |
IDirectFB *fb; |
|
128 |
quint8 opacity; |
|
129 |
||
130 |
ClipType clipType; |
|
131 |
QDirectFBPaintDevice *dfbDevice; |
|
132 |
uint compositionModeStatus; |
|
133 |
||
134 |
bool inClip; |
|
135 |
QRect currentClip; |
|
136 |
||
137 |
QDirectFBPaintEngine *q; |
|
138 |
}; |
|
139 |
||
140 |
class SurfaceCache |
|
141 |
{ |
|
142 |
public: |
|
143 |
SurfaceCache() : surface(0), buffer(0), bufsize(0) {} |
|
144 |
~SurfaceCache() { clear(); } |
|
145 |
IDirectFBSurface *getSurface(const uint *buf, int size); |
|
146 |
void clear(); |
|
147 |
private: |
|
148 |
IDirectFBSurface *surface; |
|
149 |
uint *buffer; |
|
150 |
int bufsize; |
|
151 |
}; |
|
152 |
||
153 |
||
154 |
#ifdef QT_DIRECTFB_IMAGECACHE |
|
155 |
QT_BEGIN_INCLUDE_NAMESPACE |
|
156 |
#include <private/qimage_p.h> |
|
157 |
QT_END_INCLUDE_NAMESPACE |
|
158 |
struct CachedImage |
|
159 |
{ |
|
160 |
IDirectFBSurface *surface; |
|
161 |
~CachedImage() |
|
162 |
{ |
|
163 |
if (surface && QDirectFBScreen::instance()) { |
|
164 |
QDirectFBScreen::instance()->releaseDFBSurface(surface); |
|
165 |
} |
|
166 |
} |
|
167 |
}; |
|
168 |
static QCache<qint64, CachedImage> imageCache(4*1024*1024); // 4 MB |
|
169 |
#endif |
|
170 |
||
171 |
#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS |
|
172 |
#define VOID_ARG() static_cast<bool>(false) |
|
173 |
enum PaintOperation { |
|
174 |
DRAW_RECTS = 0x0001, DRAW_LINES = 0x0002, DRAW_IMAGE = 0x0004, |
|
175 |
DRAW_PIXMAP = 0x0008, DRAW_TILED_PIXMAP = 0x0010, STROKE_PATH = 0x0020, |
|
176 |
DRAW_PATH = 0x0040, DRAW_POINTS = 0x0080, DRAW_ELLIPSE = 0x0100, |
|
177 |
DRAW_POLYGON = 0x0200, DRAW_TEXT = 0x0400, FILL_PATH = 0x0800, |
|
178 |
FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, DRAW_ROUNDED_RECT = 0x4000, |
|
179 |
ALL = 0xffff |
|
180 |
}; |
|
181 |
#endif |
|
182 |
||
183 |
#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS |
|
184 |
template <typename device, typename T1, typename T2, typename T3> |
|
185 |
static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, |
|
186 |
uint transformationType, bool simplePen, |
|
187 |
uint clipType, uint compositionModeStatus, |
|
188 |
const char *nameOne, const T1 &one, |
|
189 |
const char *nameTwo, const T2 &two, |
|
190 |
const char *nameThree, const T3 &three); |
|
191 |
#endif |
|
192 |
||
193 |
#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS |
|
194 |
#define RASTERFALLBACK(op, one, two, three) \ |
|
195 |
if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ |
|
196 |
rasterFallbackWarn("Disabled raster engine operation", \ |
|
197 |
__FUNCTION__, state()->painter->device(), \ |
|
198 |
d_func()->transformationType, \ |
|
199 |
d_func()->simplePen, \ |
|
200 |
d_func()->clipType, \ |
|
201 |
d_func()->compositionModeStatus, \ |
|
202 |
#one, one, #two, two, #three, three); \ |
|
203 |
if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ |
|
204 |
return; |
|
205 |
#elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS |
|
206 |
#define RASTERFALLBACK(op, one, two, three) \ |
|
207 |
if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ |
|
208 |
return; |
|
209 |
#elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS |
|
210 |
#define RASTERFALLBACK(op, one, two, three) \ |
|
211 |
if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ |
|
212 |
rasterFallbackWarn("Falling back to raster engine for", \ |
|
213 |
__FUNCTION__, state()->painter->device(), \ |
|
214 |
d_func()->transformationType, \ |
|
215 |
d_func()->simplePen, \ |
|
216 |
d_func()->clipType, \ |
|
217 |
d_func()->compositionModeStatus, \ |
|
218 |
#one, one, #two, two, #three, three); |
|
219 |
#else |
|
220 |
#define RASTERFALLBACK(op, one, two, three) |
|
221 |
#endif |
|
222 |
||
223 |
template <class T> |
|
224 |
static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface); |
|
225 |
template <class T> |
|
226 |
static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); |
|
227 |
template <class T> |
|
228 |
static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); |
|
229 |
||
230 |
#define CLIPPED_PAINT(operation) { \ |
|
231 |
d->unlock(); \ |
|
232 |
DFBRegion clipRegion; \ |
|
233 |
switch (d->clipType) { \ |
|
234 |
case QDirectFBPaintEnginePrivate::NoClip: \ |
|
235 |
case QDirectFBPaintEnginePrivate::RectClip: \ |
|
236 |
operation; \ |
|
237 |
break; \ |
|
238 |
case QDirectFBPaintEnginePrivate::RegionClip: { \ |
|
239 |
Q_ASSERT(d->clip()); \ |
|
240 |
const QVector<QRect> cr = d->clip()->clipRegion.rects(); \ |
|
241 |
const int size = cr.size(); \ |
|
242 |
for (int i=0; i<size; ++i) { \ |
|
243 |
d->currentClip = cr.at(i); \ |
|
244 |
clipRegion.x1 = d->currentClip.x(); \ |
|
245 |
clipRegion.y1 = d->currentClip.y(); \ |
|
246 |
clipRegion.x2 = d->currentClip.right(); \ |
|
247 |
clipRegion.y2 = d->currentClip.bottom(); \ |
|
248 |
d->surface->SetClip(d->surface, &clipRegion); \ |
|
249 |
operation; \ |
|
250 |
} \ |
|
251 |
d->updateClip(); \ |
|
252 |
break; } \ |
|
253 |
case QDirectFBPaintEnginePrivate::ComplexClip: \ |
|
254 |
case QDirectFBPaintEnginePrivate::ClipUnset: \ |
|
255 |
qFatal("CLIPPED_PAINT internal error %d", d->clipType); \ |
|
256 |
break; \ |
|
257 |
} \ |
|
258 |
} |
|
259 |
||
260 |
||
261 |
QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) |
|
262 |
: QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device) |
|
263 |
{ |
|
264 |
} |
|
265 |
||
266 |
QDirectFBPaintEngine::~QDirectFBPaintEngine() |
|
267 |
{ |
|
268 |
} |
|
269 |
||
270 |
bool QDirectFBPaintEngine::begin(QPaintDevice *device) |
|
271 |
{ |
|
272 |
Q_D(QDirectFBPaintEngine); |
|
273 |
if (device->devType() == QInternal::CustomRaster) { |
|
274 |
d->dfbDevice = static_cast<QDirectFBPaintDevice*>(device); |
|
275 |
} else if (device->devType() == QInternal::Pixmap) { |
|
276 |
QPixmapData *data = static_cast<QPixmap*>(device)->pixmapData(); |
|
277 |
Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); |
|
278 |
QDirectFBPixmapData *dfbPixmapData = static_cast<QDirectFBPixmapData*>(data); |
|
279 |
QDirectFBPaintEnginePrivate::unlock(dfbPixmapData); |
|
280 |
d->dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData); |
|
281 |
} |
|
282 |
||
283 |
if (d->dfbDevice) |
|
284 |
d->surface = d->dfbDevice->directFBSurface(); |
|
285 |
||
286 |
if (!d->surface) { |
|
287 |
qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", |
|
288 |
device->devType()); |
|
289 |
} |
|
290 |
||
291 |
d->prepare(d->dfbDevice); |
|
292 |
gccaps = AllFeatures; |
|
293 |
d->setCompositionMode(state()->composition_mode); |
|
294 |
||
295 |
return QRasterPaintEngine::begin(device); |
|
296 |
} |
|
297 |
||
298 |
bool QDirectFBPaintEngine::end() |
|
299 |
{ |
|
300 |
Q_D(QDirectFBPaintEngine); |
|
301 |
d->unlock(); |
|
302 |
d->dfbDevice = 0; |
|
303 |
#if (Q_DIRECTFB_VERSION >= 0x010000) |
|
304 |
d->surface->ReleaseSource(d->surface); |
|
305 |
#endif |
|
306 |
d->currentClip = QRect(); |
|
307 |
d->surface->SetClip(d->surface, NULL); |
|
308 |
d->surface = 0; |
|
309 |
return QRasterPaintEngine::end(); |
|
310 |
} |
|
311 |
||
312 |
void QDirectFBPaintEngine::clipEnabledChanged() |
|
313 |
{ |
|
314 |
Q_D(QDirectFBPaintEngine); |
|
315 |
QRasterPaintEngine::clipEnabledChanged(); |
|
316 |
d->updateClip(); |
|
317 |
} |
|
318 |
||
319 |
void QDirectFBPaintEngine::penChanged() |
|
320 |
{ |
|
321 |
Q_D(QDirectFBPaintEngine); |
|
322 |
d->setPen(state()->pen); |
|
323 |
||
324 |
QRasterPaintEngine::penChanged(); |
|
325 |
} |
|
326 |
||
327 |
void QDirectFBPaintEngine::opacityChanged() |
|
328 |
{ |
|
329 |
Q_D(QDirectFBPaintEngine); |
|
330 |
d->opacity = quint8(state()->opacity * 255); |
|
331 |
QRasterPaintEngine::opacityChanged(); |
|
332 |
} |
|
333 |
||
334 |
void QDirectFBPaintEngine::compositionModeChanged() |
|
335 |
{ |
|
336 |
Q_D(QDirectFBPaintEngine); |
|
337 |
d->setCompositionMode(state()->compositionMode()); |
|
338 |
QRasterPaintEngine::compositionModeChanged(); |
|
339 |
} |
|
340 |
||
341 |
void QDirectFBPaintEngine::renderHintsChanged() |
|
342 |
{ |
|
343 |
Q_D(QDirectFBPaintEngine); |
|
344 |
d->setRenderHints(state()->renderHints); |
|
345 |
QRasterPaintEngine::renderHintsChanged(); |
|
346 |
} |
|
347 |
||
348 |
void QDirectFBPaintEngine::transformChanged() |
|
349 |
{ |
|
350 |
Q_D(QDirectFBPaintEngine); |
|
351 |
d->setTransform(state()->matrix); |
|
352 |
QRasterPaintEngine::transformChanged(); |
|
353 |
} |
|
354 |
||
355 |
void QDirectFBPaintEngine::setState(QPainterState *state) |
|
356 |
{ |
|
357 |
Q_D(QDirectFBPaintEngine); |
|
358 |
QRasterPaintEngine::setState(state); |
|
359 |
d->setPen(state->pen); |
|
360 |
d->opacity = quint8(state->opacity * 255); |
|
361 |
d->setCompositionMode(state->compositionMode()); |
|
362 |
d->setTransform(state->transform()); |
|
363 |
d->setRenderHints(state->renderHints); |
|
364 |
if (d->surface) |
|
365 |
d->updateClip(); |
|
366 |
} |
|
367 |
||
368 |
void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) |
|
369 |
{ |
|
370 |
Q_D(QDirectFBPaintEngine); |
|
371 |
const bool wasInClip = d->inClip; |
|
372 |
d->inClip = true; |
|
373 |
QRasterPaintEngine::clip(path, op); |
|
374 |
if (!wasInClip) { |
|
375 |
d->inClip = false; |
|
376 |
d->updateClip(); |
|
377 |
} |
|
378 |
} |
|
379 |
||
380 |
void QDirectFBPaintEngine::clip(const QRegion ®ion, Qt::ClipOperation op) |
|
381 |
{ |
|
382 |
Q_D(QDirectFBPaintEngine); |
|
383 |
const bool wasInClip = d->inClip; |
|
384 |
d->inClip = true; |
|
385 |
QRasterPaintEngine::clip(region, op); |
|
386 |
if (!wasInClip) { |
|
387 |
d->inClip = false; |
|
388 |
d->updateClip(); |
|
389 |
} |
|
390 |
} |
|
391 |
||
392 |
void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) |
|
393 |
{ |
|
394 |
Q_D(QDirectFBPaintEngine); |
|
395 |
const bool wasInClip = d->inClip; |
|
396 |
d->inClip = true; |
|
397 |
QRasterPaintEngine::clip(rect, op); |
|
398 |
if (!wasInClip) { |
|
399 |
d->inClip = false; |
|
400 |
d->updateClip(); |
|
401 |
} |
|
402 |
} |
|
403 |
||
404 |
void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) |
|
405 |
{ |
|
406 |
Q_D(QDirectFBPaintEngine); |
|
407 |
const QPen &pen = state()->pen; |
|
408 |
const QBrush &brush = state()->brush; |
|
409 |
if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen) |
|
410 |
return; |
|
411 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
412 |
if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) |
0 | 413 |
|| !d->simplePen |
414 |
|| d->clipType == QDirectFBPaintEnginePrivate::ComplexClip |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
|| !d->isSimpleBrush(brush) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
416 |
|| !d->testCompositionMode(&pen, &brush)) { |
0 | 417 |
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); |
418 |
d->lock(); |
|
419 |
QRasterPaintEngine::drawRects(rects, rectCount); |
|
420 |
return; |
|
421 |
} |
|
422 |
||
423 |
if (brush.style() != Qt::NoBrush) { |
|
424 |
d->setDFBColor(brush.color()); |
|
425 |
CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects<QRect>)(rects, rectCount, state()->matrix, d->surface)); |
|
426 |
} |
|
427 |
||
428 |
if (pen.style() != Qt::NoPen) { |
|
429 |
d->setDFBColor(pen.color()); |
|
430 |
CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRect>)(rects, rectCount, state()->matrix, d->surface)); |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) |
|
435 |
{ |
|
436 |
Q_D(QDirectFBPaintEngine); |
|
437 |
const QPen &pen = state()->pen; |
|
438 |
const QBrush &brush = state()->brush; |
|
439 |
if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen) |
|
440 |
return; |
|
441 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
442 |
if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) |
0 | 443 |
|| !d->simplePen |
444 |
|| d->clipType == QDirectFBPaintEnginePrivate::ComplexClip |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
445 |
|| !d->isSimpleBrush(brush) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
446 |
|| !d->testCompositionMode(&pen, &brush)) { |
0 | 447 |
RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); |
448 |
d->lock(); |
|
449 |
QRasterPaintEngine::drawRects(rects, rectCount); |
|
450 |
return; |
|
451 |
} |
|
452 |
||
453 |
if (brush.style() != Qt::NoBrush) { |
|
454 |
d->setDFBColor(brush.color()); |
|
455 |
CLIPPED_PAINT(fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface)); |
|
456 |
} |
|
457 |
||
458 |
if (pen.style() != Qt::NoPen) { |
|
459 |
d->setDFBColor(pen.color()); |
|
460 |
CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRectF>)(rects, rectCount, state()->matrix, d->surface)); |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) |
|
465 |
{ |
|
466 |
Q_D(QDirectFBPaintEngine); |
|
467 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
468 |
const QPen &pen = state()->pen; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
469 |
if (!d->simplePen |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
470 |
|| d->clipType == QDirectFBPaintEnginePrivate::ComplexClip |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
471 |
|| !d->testCompositionMode(&pen, 0)) { |
0 | 472 |
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); |
473 |
d->lock(); |
|
474 |
QRasterPaintEngine::drawLines(lines, lineCount); |
|
475 |
return; |
|
476 |
} |
|
477 |
||
478 |
if (pen.style() != Qt::NoPen) { |
|
479 |
d->setDFBColor(pen.color()); |
|
480 |
CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLine>)(lines, lineCount, state()->matrix, d->surface)); |
|
481 |
} |
|
482 |
} |
|
483 |
||
484 |
void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) |
|
485 |
{ |
|
486 |
Q_D(QDirectFBPaintEngine); |
|
487 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
488 |
const QPen &pen = state()->pen; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
489 |
if (!d->simplePen |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
490 |
|| d->clipType == QDirectFBPaintEnginePrivate::ComplexClip |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
491 |
|| !d->testCompositionMode(&pen, 0)) { |
0 | 492 |
RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); |
493 |
d->lock(); |
|
494 |
QRasterPaintEngine::drawLines(lines, lineCount); |
|
495 |
return; |
|
496 |
} |
|
497 |
||
498 |
if (pen.style() != Qt::NoPen) { |
|
499 |
d->setDFBColor(pen.color()); |
|
500 |
CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLineF>)(lines, lineCount, state()->matrix, d->surface)); |
|
501 |
} |
|
502 |
} |
|
503 |
||
504 |
void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, |
|
505 |
const QRectF &sr, |
|
506 |
Qt::ImageConversionFlags flags) |
|
507 |
{ |
|
508 |
Q_D(QDirectFBPaintEngine); |
|
509 |
Q_UNUSED(flags); |
|
510 |
||
511 |
/* This is hard to read. The way it works is like this: |
|
512 |
||
513 |
- If you do not have support for preallocated surfaces and do not use an |
|
514 |
image cache we always fall back to raster engine. |
|
515 |
||
516 |
- If it's rotated/sheared/mirrored (negative scale) or we can't |
|
517 |
clip it we fall back to raster engine. |
|
518 |
||
519 |
- If we don't cache the image, but we do have support for |
|
520 |
preallocated surfaces we fall back to the raster engine if the |
|
521 |
image is in a format DirectFB can't handle. |
|
522 |
||
523 |
- If we do cache the image but don't have support for preallocated |
|
524 |
images and the cost of caching the image (bytes used) is higher |
|
525 |
than the max image cache size we fall back to raster engine. |
|
526 |
*/ |
|
527 |
||
528 |
#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE |
|
529 |
if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) |
|
530 |
|| (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
531 |
|| (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
532 |
|| (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size()) |
0 | 533 |
#ifndef QT_DIRECTFB_IMAGECACHE |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
534 |
|| (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN) |
0 | 535 |
#elif defined QT_NO_DIRECTFB_PREALLOCATED |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
536 |
|| (QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost()) |
0 | 537 |
#endif |
538 |
) |
|
539 |
#endif |
|
540 |
{ |
|
541 |
RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr); |
|
542 |
d->lock(); |
|
543 |
QRasterPaintEngine::drawImage(r, image, sr, flags); |
|
544 |
return; |
|
545 |
} |
|
546 |
#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE |
|
547 |
bool release; |
|
548 |
IDirectFBSurface *imgSurface = d->getSurface(image, &release); |
|
549 |
d->prepareForBlit(QDirectFBScreen::hasAlphaChannel(imgSurface)); |
|
550 |
CLIPPED_PAINT(d->blit(r, imgSurface, sr)); |
|
551 |
if (release) { |
|
552 |
#if (Q_DIRECTFB_VERSION >= 0x010000) |
|
553 |
d->surface->ReleaseSource(d->surface); |
|
554 |
#endif |
|
555 |
imgSurface->Release(imgSurface); |
|
556 |
} |
|
557 |
#endif |
|
558 |
} |
|
559 |
||
560 |
void QDirectFBPaintEngine::drawImage(const QPointF &p, const QImage &img) |
|
561 |
{ |
|
562 |
drawImage(QRectF(p, img.size()), img, img.rect()); |
|
563 |
} |
|
564 |
||
565 |
void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, |
|
566 |
const QRectF &sr) |
|
567 |
{ |
|
568 |
Q_D(QDirectFBPaintEngine); |
|
569 |
||
570 |
if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { |
|
571 |
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); |
|
572 |
d->lock(); |
|
573 |
QRasterPaintEngine::drawPixmap(r, pixmap, sr); |
|
574 |
} else { |
|
575 |
QPixmapData *data = pixmap.pixmapData(); |
|
576 |
Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); |
|
577 |
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); |
|
578 |
if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
579 |
|| (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
580 |
|| (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
581 |
|| (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())) { |
0 | 582 |
RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); |
583 |
const QImage *img = dfbData->buffer(); |
|
584 |
d->lock(); |
|
585 |
QRasterPaintEngine::drawImage(r, *img, sr); |
|
586 |
} else { |
|
587 |
QDirectFBPaintEnginePrivate::unlock(dfbData); |
|
588 |
d->prepareForBlit(pixmap.hasAlphaChannel()); |
|
589 |
IDirectFBSurface *s = dfbData->directFBSurface(); |
|
590 |
CLIPPED_PAINT(d->blit(r, s, sr)); |
|
591 |
} |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
void QDirectFBPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) |
|
596 |
{ |
|
597 |
drawPixmap(QRectF(p, pm.size()), pm, pm.rect()); |
|
598 |
} |
|
599 |
||
600 |
void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, |
|
601 |
const QPixmap &pixmap, |
|
602 |
const QPointF &offset) |
|
603 |
{ |
|
604 |
Q_D(QDirectFBPaintEngine); |
|
605 |
if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) { |
|
606 |
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); |
|
607 |
d->lock(); |
|
608 |
QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); |
|
609 |
} else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) |
|
610 |
|| (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
611 |
|| (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
612 |
|| (!d->supportsStretchBlit() && state()->matrix.isScaling())) { |
0 | 613 |
RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); |
614 |
QPixmapData *pixmapData = pixmap.pixmapData(); |
|
615 |
Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass); |
|
616 |
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(pixmapData); |
|
617 |
const QImage *img = dfbData->buffer(); |
|
618 |
d->lock(); |
|
619 |
QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType); |
|
620 |
data->fromImage(*img, Qt::AutoColor); |
|
621 |
const QPixmap pix(data); |
|
622 |
QRasterPaintEngine::drawTiledPixmap(r, pix, offset); |
|
623 |
} else { |
|
624 |
CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset)); |
|
625 |
} |
|
626 |
} |
|
627 |
||
628 |
||
629 |
void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen) |
|
630 |
{ |
|
631 |
RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG()); |
|
632 |
Q_D(QDirectFBPaintEngine); |
|
633 |
d->lock(); |
|
634 |
QRasterPaintEngine::stroke(path, pen); |
|
635 |
} |
|
636 |
||
637 |
void QDirectFBPaintEngine::drawPath(const QPainterPath &path) |
|
638 |
{ |
|
639 |
RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG()); |
|
640 |
Q_D(QDirectFBPaintEngine); |
|
641 |
d->lock(); |
|
642 |
QRasterPaintEngine::drawPath(path); |
|
643 |
} |
|
644 |
||
645 |
void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount) |
|
646 |
{ |
|
647 |
RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); |
|
648 |
Q_D(QDirectFBPaintEngine); |
|
649 |
d->lock(); |
|
650 |
QRasterPaintEngine::drawPoints(points, pointCount); |
|
651 |
} |
|
652 |
||
653 |
void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount) |
|
654 |
{ |
|
655 |
RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG()); |
|
656 |
Q_D(QDirectFBPaintEngine); |
|
657 |
d->lock(); |
|
658 |
QRasterPaintEngine::drawPoints(points, pointCount); |
|
659 |
} |
|
660 |
||
661 |
void QDirectFBPaintEngine::drawEllipse(const QRectF &rect) |
|
662 |
{ |
|
663 |
RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG()); |
|
664 |
Q_D(QDirectFBPaintEngine); |
|
665 |
d->lock(); |
|
666 |
QRasterPaintEngine::drawEllipse(rect); |
|
667 |
} |
|
668 |
||
669 |
void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount, |
|
670 |
PolygonDrawMode mode) |
|
671 |
{ |
|
672 |
RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); |
|
673 |
Q_D(QDirectFBPaintEngine); |
|
674 |
d->lock(); |
|
675 |
QRasterPaintEngine::drawPolygon(points, pointCount, mode); |
|
676 |
} |
|
677 |
||
678 |
void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount, |
|
679 |
PolygonDrawMode mode) |
|
680 |
{ |
|
681 |
RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG()); |
|
682 |
Q_D(QDirectFBPaintEngine); |
|
683 |
d->lock(); |
|
684 |
QRasterPaintEngine::drawPolygon(points, pointCount, mode); |
|
685 |
} |
|
686 |
||
687 |
void QDirectFBPaintEngine::drawTextItem(const QPointF &p, |
|
688 |
const QTextItem &textItem) |
|
689 |
{ |
|
690 |
RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG()); |
|
691 |
Q_D(QDirectFBPaintEngine); |
|
692 |
d->lock(); |
|
693 |
QRasterPaintEngine::drawTextItem(p, textItem); |
|
694 |
} |
|
695 |
||
696 |
void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush) |
|
697 |
{ |
|
698 |
if (brush.style() == Qt::NoBrush) |
|
699 |
return; |
|
700 |
RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG()); |
|
701 |
Q_D(QDirectFBPaintEngine); |
|
702 |
d->lock(); |
|
703 |
QRasterPaintEngine::fill(path, brush); |
|
704 |
} |
|
705 |
||
706 |
void QDirectFBPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode) |
|
707 |
{ |
|
708 |
RASTERFALLBACK(DRAW_ROUNDED_RECT, rect, xrad, yrad); |
|
709 |
Q_D(QDirectFBPaintEngine); |
|
710 |
d->lock(); |
|
711 |
QRasterPaintEngine::drawRoundedRect(rect, xrad, yrad, mode); |
|
712 |
} |
|
713 |
||
714 |
void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) |
|
715 |
{ |
|
716 |
Q_D(QDirectFBPaintEngine); |
|
717 |
if (brush.style() == Qt::NoBrush) |
|
718 |
return; |
|
719 |
if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) { |
|
720 |
switch (brush.style()) { |
|
721 |
case Qt::SolidPattern: { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
722 |
if (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
723 |
|| !d->testCompositionMode(0, &brush)) { |
0 | 724 |
break; |
725 |
} |
|
726 |
const QColor color = brush.color(); |
|
727 |
if (!color.isValid()) |
|
728 |
return; |
|
729 |
d->setDFBColor(color); |
|
730 |
const QRect r = state()->matrix.mapRect(rect).toRect(); |
|
731 |
CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); |
|
732 |
return; } |
|
733 |
||
734 |
case Qt::TexturePattern: { |
|
735 |
if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) |
|
736 |
|| (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
737 |
|| (!d->supportsStretchBlit() && state()->matrix.isScaling())) { |
0 | 738 |
break; |
739 |
} |
|
740 |
||
741 |
const QPixmap texture = brush.texture(); |
|
742 |
if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass) |
|
743 |
break; |
|
744 |
||
745 |
CLIPPED_PAINT(d->drawTiledPixmap(rect, texture, rect.topLeft() - state()->brushOrigin)); |
|
746 |
return; } |
|
747 |
default: |
|
748 |
break; |
|
749 |
} |
|
750 |
} |
|
751 |
RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG()); |
|
752 |
d->lock(); |
|
753 |
QRasterPaintEngine::fillRect(rect, brush); |
|
754 |
} |
|
755 |
||
756 |
void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) |
|
757 |
{ |
|
758 |
if (!color.isValid()) |
|
759 |
return; |
|
760 |
Q_D(QDirectFBPaintEngine); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
761 |
if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) |
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
762 |
|| (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
763 |
|| !d->testCompositionMode(0, 0, &color)) { |
0 | 764 |
RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); |
765 |
d->lock(); |
|
766 |
QRasterPaintEngine::fillRect(rect, color); |
|
767 |
} else { |
|
768 |
d->setDFBColor(color); |
|
769 |
const QRect r = state()->matrix.mapRect(rect).toRect(); |
|
770 |
CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height())); |
|
771 |
} |
|
772 |
} |
|
773 |
||
774 |
void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize, |
|
775 |
int x, int y, int length, |
|
776 |
uint const_alpha) |
|
777 |
{ |
|
778 |
Q_D(QDirectFBPaintEngine); |
|
779 |
IDirectFBSurface *src = d->surfaceCache->getSurface(buffer, bufsize); |
|
780 |
// ### how does this play with setDFBColor |
|
781 |
src->SetColor(src, 0, 0, 0, const_alpha); |
|
782 |
const DFBRectangle rect = { 0, 0, length, 1 }; |
|
783 |
d->surface->Blit(d->surface, src, &rect, x, y); |
|
784 |
} |
|
785 |
||
786 |
#ifdef QT_DIRECTFB_IMAGECACHE |
|
787 |
static void cachedImageCleanupHook(qint64 key) |
|
788 |
{ |
|
789 |
delete imageCache.take(key); |
|
790 |
} |
|
791 |
void QDirectFBPaintEngine::initImageCache(int size) |
|
792 |
{ |
|
793 |
Q_ASSERT(size >= 0); |
|
794 |
imageCache.setMaxCost(size); |
|
795 |
QImagePixmapCleanupHooks::instance()->addImageHook(cachedImageCleanupHook); |
|
796 |
} |
|
797 |
||
798 |
#endif // QT_DIRECTFB_IMAGECACHE |
|
799 |
||
800 |
// ---- QDirectFBPaintEnginePrivate ---- |
|
801 |
||
802 |
||
803 |
QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) |
|
804 |
: surface(0), antialiased(false), simplePen(false), |
|
805 |
transformationType(0), opacity(255), |
|
806 |
clipType(ClipUnset), dfbDevice(0), |
|
807 |
compositionModeStatus(0), inClip(false), q(p) |
|
808 |
{ |
|
809 |
fb = QDirectFBScreen::instance()->dfb(); |
|
810 |
surfaceCache = new SurfaceCache; |
|
811 |
} |
|
812 |
||
813 |
QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate() |
|
814 |
{ |
|
815 |
delete surfaceCache; |
|
816 |
} |
|
817 |
||
818 |
bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const |
|
819 |
{ |
|
820 |
return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); |
|
821 |
} |
|
822 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
823 |
bool QDirectFBPaintEnginePrivate::testCompositionMode(const QPen *pen, const QBrush *brush, const QColor *color) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
824 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
825 |
Q_ASSERT(!pen || pen->style() == Qt::NoPen || pen->style() == Qt::SolidLine); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
826 |
Q_ASSERT(!brush || brush->style() == Qt::NoBrush || brush->style() == Qt::SolidPattern); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
827 |
switch (compositionModeStatus & (QDirectFBPaintEnginePrivate::PorterDuff_SupportedOpaquePrimitives |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
828 |
|QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
829 |
case QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
830 |
return true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
831 |
case QDirectFBPaintEnginePrivate::PorterDuff_SupportedOpaquePrimitives: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
832 |
if (pen && pen->style() == Qt::SolidLine && pen->color().alpha() != 255) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
833 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
834 |
if (brush) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
835 |
if (brush->style() == Qt::SolidPattern && brush->color().alpha() != 255) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
836 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
837 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
838 |
} else if (color && color->alpha() != 255) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
839 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
840 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
841 |
return true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
842 |
case QDirectFBPaintEnginePrivate::PorterDuff_None: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
843 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
844 |
default: |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
845 |
// ### PorterDuff_SupportedOpaquePrimitives|PorterDuff_SupportedPrimitives can't be combined |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
846 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
847 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
848 |
Q_ASSERT(0); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
850 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
851 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
852 |
|
0 | 853 |
void QDirectFBPaintEnginePrivate::lock() |
854 |
{ |
|
855 |
// We will potentially get a new pointer to the buffer after a |
|
856 |
// lock so we need to call the base implementation of prepare so |
|
857 |
// it updates its rasterBuffer to point to the new buffer address. |
|
858 |
Q_ASSERT(dfbDevice); |
|
859 |
if (dfbDevice->lockSurface(DSLF_READ|DSLF_WRITE)) { |
|
860 |
prepare(dfbDevice); |
|
861 |
} |
|
862 |
} |
|
863 |
||
864 |
void QDirectFBPaintEnginePrivate::unlock() |
|
865 |
{ |
|
866 |
Q_ASSERT(dfbDevice); |
|
867 |
#ifdef QT_DIRECTFB_SUBSURFACE |
|
868 |
dfbDevice->syncPending = true; |
|
869 |
#else |
|
870 |
QDirectFBPaintEnginePrivate::unlock(dfbDevice); |
|
871 |
#endif |
|
872 |
} |
|
873 |
||
874 |
void QDirectFBPaintEnginePrivate::unlock(QDirectFBPaintDevice *device) |
|
875 |
{ |
|
876 |
#ifdef QT_NO_DIRECTFB_SUBSURFACE |
|
877 |
Q_ASSERT(device); |
|
878 |
device->unlockSurface(); |
|
879 |
#else |
|
880 |
Q_UNUSED(device); |
|
881 |
#endif |
|
882 |
} |
|
883 |
||
884 |
void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) |
|
885 |
{ |
|
886 |
transformationType = transform.type(); |
|
887 |
if (qMin(transform.m11(), transform.m22()) < 0) { |
|
888 |
transformationType |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale; |
|
889 |
} |
|
890 |
setPen(q->state()->pen); |
|
891 |
} |
|
892 |
||
893 |
void QDirectFBPaintEnginePrivate::setPen(const QPen &pen) |
|
894 |
{ |
|
895 |
if (pen.style() == Qt::NoPen) { |
|
896 |
simplePen = true; |
|
897 |
} else if (pen.style() == Qt::SolidLine |
|
898 |
&& !antialiased |
|
899 |
&& pen.brush().style() == Qt::SolidPattern |
|
900 |
&& pen.widthF() <= 1.0 |
|
901 |
&& (transformationType < QTransform::TxScale || pen.isCosmetic())) { |
|
902 |
simplePen = true; |
|
903 |
} else { |
|
904 |
simplePen = false; |
|
905 |
} |
|
906 |
} |
|
907 |
||
908 |
void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode) |
|
909 |
{ |
|
910 |
if (!surface) |
|
911 |
return; |
|
912 |
||
913 |
static const bool forceRasterFallBack = qgetenv("QT_DIRECTFB_FORCE_RASTER").toInt() > 0; |
|
914 |
if (forceRasterFallBack) { |
|
915 |
compositionModeStatus = 0; |
|
916 |
return; |
|
917 |
} |
|
918 |
||
919 |
compositionModeStatus = PorterDuff_SupportedBlits; |
|
920 |
switch (mode) { |
|
921 |
case QPainter::CompositionMode_Clear: |
|
922 |
surface->SetPorterDuff(surface, DSPD_CLEAR); |
|
923 |
break; |
|
924 |
case QPainter::CompositionMode_Source: |
|
925 |
surface->SetPorterDuff(surface, DSPD_SRC); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
926 |
compositionModeStatus |= PorterDuff_SupportedOpaquePrimitives; |
0 | 927 |
break; |
928 |
case QPainter::CompositionMode_SourceOver: |
|
929 |
compositionModeStatus |= PorterDuff_SupportedPrimitives; |
|
930 |
surface->SetPorterDuff(surface, DSPD_SRC_OVER); |
|
931 |
break; |
|
932 |
case QPainter::CompositionMode_DestinationOver: |
|
933 |
surface->SetPorterDuff(surface, DSPD_DST_OVER); |
|
934 |
break; |
|
935 |
case QPainter::CompositionMode_SourceIn: |
|
936 |
surface->SetPorterDuff(surface, DSPD_SRC_IN); |
|
937 |
break; |
|
938 |
case QPainter::CompositionMode_DestinationIn: |
|
939 |
surface->SetPorterDuff(surface, DSPD_DST_IN); |
|
940 |
break; |
|
941 |
case QPainter::CompositionMode_SourceOut: |
|
942 |
surface->SetPorterDuff(surface, DSPD_SRC_OUT); |
|
943 |
break; |
|
944 |
case QPainter::CompositionMode_DestinationOut: |
|
945 |
surface->SetPorterDuff(surface, DSPD_DST_OUT); |
|
946 |
break; |
|
947 |
#if (Q_DIRECTFB_VERSION >= 0x010000) |
|
948 |
case QPainter::CompositionMode_SourceAtop: |
|
949 |
surface->SetPorterDuff(surface, DSPD_SRC_ATOP); |
|
950 |
break; |
|
951 |
case QPainter::CompositionMode_DestinationAtop: |
|
952 |
surface->SetPorterDuff(surface, DSPD_DST_ATOP); |
|
953 |
break; |
|
954 |
case QPainter::CompositionMode_Plus: |
|
955 |
surface->SetPorterDuff(surface, DSPD_ADD); |
|
956 |
break; |
|
957 |
case QPainter::CompositionMode_Xor: |
|
958 |
surface->SetPorterDuff(surface, DSPD_XOR); |
|
959 |
break; |
|
960 |
#endif |
|
961 |
default: |
|
962 |
compositionModeStatus = 0; |
|
963 |
break; |
|
964 |
} |
|
965 |
} |
|
966 |
||
967 |
void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) |
|
968 |
{ |
|
969 |
const bool old = antialiased; |
|
970 |
antialiased = bool(hints & QPainter::Antialiasing); |
|
971 |
if (old != antialiased) { |
|
972 |
setPen(q->state()->pen); |
|
973 |
} |
|
974 |
} |
|
975 |
||
976 |
void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) |
|
977 |
{ |
|
978 |
DFBSurfaceBlittingFlags blittingFlags = alpha ? DSBLIT_BLEND_ALPHACHANNEL : DSBLIT_NOFX; |
|
979 |
if (opacity != 255) { |
|
980 |
blittingFlags |= DSBLIT_BLEND_COLORALPHA; |
|
981 |
} |
|
982 |
surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); |
|
983 |
surface->SetBlittingFlags(surface, blittingFlags); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
984 |
if (compositionModeStatus & PorterDuff_Dirty) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
985 |
setCompositionMode(q->state()->composition_mode); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
986 |
} |
0 | 987 |
} |
988 |
||
989 |
static inline uint ALPHA_MUL(uint x, uint a) |
|
990 |
{ |
|
991 |
uint t = x * a; |
|
992 |
t = ((t + (t >> 8) + 0x80) >> 8) & 0xff; |
|
993 |
return t; |
|
994 |
} |
|
995 |
||
996 |
void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) |
|
997 |
{ |
|
998 |
Q_ASSERT(surface); |
|
999 |
const quint8 alpha = (opacity == 255 ? |
|
1000 |
color.alpha() : ALPHA_MUL(color.alpha(), opacity)); |
|
1001 |
surface->SetColor(surface, color.red(), color.green(), color.blue(), alpha); |
|
1002 |
surface->SetPorterDuff(surface, DSPD_NONE); |
|
1003 |
surface->SetDrawingFlags(surface, alpha == 255 ? DSDRAW_NOFX : DSDRAW_BLEND); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1004 |
compositionModeStatus |= PorterDuff_Dirty; |
0 | 1005 |
} |
1006 |
||
1007 |
IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) |
|
1008 |
{ |
|
1009 |
#ifdef QT_NO_DIRECTFB_IMAGECACHE |
|
1010 |
*release = true; |
|
1011 |
return QDirectFBScreen::instance()->createDFBSurface(img, img.format(), QDirectFBScreen::DontTrackSurface); |
|
1012 |
#else |
|
1013 |
const qint64 key = img.cacheKey(); |
|
1014 |
*release = false; |
|
1015 |
if (imageCache.contains(key)) { |
|
1016 |
return imageCache[key]->surface; |
|
1017 |
} |
|
1018 |
||
1019 |
const int cost = cacheCost(img); |
|
1020 |
const bool cache = cost <= imageCache.maxCost(); |
|
1021 |
QDirectFBScreen *screen = QDirectFBScreen::instance(); |
|
1022 |
const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img) |
|
1023 |
? screen->alphaPixmapFormat() : screen->pixelFormat()); |
|
1024 |
||
1025 |
IDirectFBSurface *surface = screen->createDFBSurface(img, format, |
|
1026 |
cache |
|
1027 |
? QDirectFBScreen::TrackSurface |
|
1028 |
: QDirectFBScreen::DontTrackSurface); |
|
1029 |
if (cache) { |
|
1030 |
CachedImage *cachedImage = new CachedImage; |
|
1031 |
const_cast<QImage&>(img).data_ptr()->is_cached = true; |
|
1032 |
cachedImage->surface = surface; |
|
1033 |
imageCache.insert(key, cachedImage, cost); |
|
1034 |
} else { |
|
1035 |
*release = true; |
|
1036 |
} |
|
1037 |
return surface; |
|
1038 |
#endif |
|
1039 |
} |
|
1040 |
||
1041 |
||
1042 |
void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src) |
|
1043 |
{ |
|
1044 |
const QRect sr = src.toRect(); |
|
1045 |
const QRect dr = q->state()->matrix.mapRect(dest).toRect(); |
|
1046 |
if (dr.isEmpty()) |
|
1047 |
return; |
|
1048 |
const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; |
|
1049 |
DFBResult result; |
|
1050 |
||
1051 |
if (dr.size() == sr.size()) { |
|
1052 |
result = surface->Blit(surface, s, &sRect, dr.x(), dr.y()); |
|
1053 |
} else { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1054 |
Q_ASSERT(supportsStretchBlit()); |
0 | 1055 |
const DFBRectangle dRect = { dr.x(), dr.y(), dr.width(), dr.height() }; |
1056 |
result = surface->StretchBlit(surface, s, &sRect, &dRect); |
|
1057 |
} |
|
1058 |
if (result != DFB_OK) |
|
1059 |
DirectFBError("QDirectFBPaintEngine::drawPixmap()", result); |
|
1060 |
} |
|
1061 |
||
1062 |
static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset) |
|
1063 |
{ |
|
1064 |
qreal pos = rect_pos - offset; |
|
1065 |
while (pos > rect_pos) |
|
1066 |
pos -= pixmapSize; |
|
1067 |
while (pos + pixmapSize < rect_pos) |
|
1068 |
pos += pixmapSize; |
|
1069 |
return pos; |
|
1070 |
} |
|
1071 |
||
1072 |
void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off) |
|
1073 |
{ |
|
1074 |
Q_ASSERT(!(transformationType & Matrix_BlitsUnsupported)); |
|
1075 |
const QTransform &transform = q->state()->matrix; |
|
1076 |
const QRect destinationRect = transform.mapRect(dest).toRect().normalized(); |
|
1077 |
QRect newClip = destinationRect; |
|
1078 |
if (!currentClip.isEmpty()) |
|
1079 |
newClip &= currentClip; |
|
1080 |
||
1081 |
if (newClip.isNull()) |
|
1082 |
return; |
|
1083 |
||
1084 |
const DFBRegion clip = { |
|
1085 |
newClip.x(), |
|
1086 |
newClip.y(), |
|
1087 |
newClip.right(), |
|
1088 |
newClip.bottom() |
|
1089 |
}; |
|
1090 |
surface->SetClip(surface, &clip); |
|
1091 |
||
1092 |
QPointF offset = off; |
|
1093 |
Q_ASSERT(transform.type() <= QTransform::TxScale); |
|
1094 |
prepareForBlit(pixmap.hasAlphaChannel()); |
|
1095 |
QPixmapData *data = pixmap.pixmapData(); |
|
1096 |
Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); |
|
1097 |
QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data); |
|
1098 |
QDirectFBPaintEnginePrivate::unlock(dfbData); |
|
1099 |
const QSize pixmapSize = dfbData->size(); |
|
1100 |
IDirectFBSurface *sourceSurface = dfbData->directFBSurface(); |
|
1101 |
if (transform.isScaling()) { |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1102 |
Q_ASSERT(supportsStretchBlit()); |
0 | 1103 |
Q_ASSERT(qMin(transform.m11(), transform.m22()) >= 0); |
1104 |
offset.rx() *= transform.m11(); |
|
1105 |
offset.ry() *= transform.m22(); |
|
1106 |
||
1107 |
const QSizeF mappedSize(pixmapSize.width() * transform.m11(), pixmapSize.height() * transform.m22()); |
|
1108 |
qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); |
|
1109 |
const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); |
|
1110 |
while (y <= destinationRect.bottom()) { |
|
1111 |
qreal x = startX; |
|
1112 |
while (x <= destinationRect.right()) { |
|
1113 |
const DFBRectangle destination = { qRound(x), qRound(y), mappedSize.width(), mappedSize.height() }; |
|
1114 |
surface->StretchBlit(surface, sourceSurface, 0, &destination); |
|
1115 |
x += mappedSize.width(); |
|
1116 |
} |
|
1117 |
y += mappedSize.height(); |
|
1118 |
} |
|
1119 |
} else { |
|
1120 |
qreal y = fixCoord(destinationRect.y(), pixmapSize.height(), offset.y()); |
|
1121 |
const qreal startX = fixCoord(destinationRect.x(), pixmapSize.width(), offset.x()); |
|
1122 |
int horizontal = qMax(1, destinationRect.width() / pixmapSize.width()) + 1; |
|
1123 |
if (startX != destinationRect.x()) |
|
1124 |
++horizontal; |
|
1125 |
int vertical = qMax(1, destinationRect.height() / pixmapSize.height()) + 1; |
|
1126 |
if (y != destinationRect.y()) |
|
1127 |
++vertical; |
|
1128 |
||
1129 |
const int maxCount = (vertical * horizontal); |
|
1130 |
QVarLengthArray<DFBRectangle, 16> sourceRects(maxCount); |
|
1131 |
QVarLengthArray<DFBPoint, 16> points(maxCount); |
|
1132 |
||
1133 |
int i = 0; |
|
1134 |
while (y <= destinationRect.bottom()) { |
|
1135 |
Q_ASSERT(i < maxCount); |
|
1136 |
qreal x = startX; |
|
1137 |
while (x <= destinationRect.right()) { |
|
1138 |
points[i].x = qRound(x); |
|
1139 |
points[i].y = qRound(y); |
|
1140 |
sourceRects[i].x = 0; |
|
1141 |
sourceRects[i].y = 0; |
|
1142 |
sourceRects[i].w = int(pixmapSize.width()); |
|
1143 |
sourceRects[i].h = int(pixmapSize.height()); |
|
1144 |
x += pixmapSize.width(); |
|
1145 |
++i; |
|
1146 |
} |
|
1147 |
y += pixmapSize.height(); |
|
1148 |
} |
|
1149 |
surface->BatchBlit(surface, sourceSurface, sourceRects.constData(), points.constData(), i); |
|
1150 |
} |
|
1151 |
||
1152 |
if (currentClip.isEmpty()) { |
|
1153 |
surface->SetClip(surface, 0); |
|
1154 |
} else { |
|
1155 |
const DFBRegion clip = { |
|
1156 |
currentClip.x(), |
|
1157 |
currentClip.y(), |
|
1158 |
currentClip.right(), |
|
1159 |
currentClip.bottom() |
|
1160 |
}; |
|
1161 |
surface->SetClip(surface, &clip); |
|
1162 |
} |
|
1163 |
} |
|
1164 |
||
1165 |
void QDirectFBPaintEnginePrivate::updateClip() |
|
1166 |
{ |
|
1167 |
Q_ASSERT(surface); |
|
1168 |
currentClip = QRect(); |
|
1169 |
const QClipData *clipData = clip(); |
|
1170 |
if (!clipData || !clipData->enabled) { |
|
1171 |
surface->SetClip(surface, NULL); |
|
1172 |
clipType = NoClip; |
|
1173 |
} else if (clipData->hasRectClip) { |
|
1174 |
const DFBRegion r = { |
|
1175 |
clipData->clipRect.x(), |
|
1176 |
clipData->clipRect.y(), |
|
1177 |
clipData->clipRect.right(), |
|
1178 |
clipData->clipRect.bottom() |
|
1179 |
}; |
|
1180 |
surface->SetClip(surface, &r); |
|
1181 |
currentClip = clipData->clipRect.normalized(); |
|
1182 |
// ### is this guaranteed to always be normalized? |
|
1183 |
clipType = RectClip; |
|
1184 |
} else if (clipData->hasRegionClip) { |
|
1185 |
clipType = RegionClip; |
|
1186 |
} else { |
|
1187 |
clipType = ComplexClip; |
|
1188 |
} |
|
1189 |
} |
|
1190 |
||
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1191 |
bool QDirectFBPaintEnginePrivate::supportsStretchBlit() const |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1192 |
{ |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1193 |
#ifdef QT_DIRECTFB_STRETCHBLIT |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1194 |
return !(q->state()->renderHints & QPainter::SmoothPixmapTransform); |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1195 |
#else |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1196 |
return false; |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1197 |
#endif |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1198 |
} |
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1199 |
|
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
1200 |
|
0 | 1201 |
void QDirectFBPaintEnginePrivate::systemStateChanged() |
1202 |
{ |
|
1203 |
QRasterPaintEnginePrivate::systemStateChanged(); |
|
1204 |
updateClip(); |
|
1205 |
} |
|
1206 |
||
1207 |
IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size) |
|
1208 |
{ |
|
1209 |
if (buffer == buf && bufsize == size) |
|
1210 |
return surface; |
|
1211 |
||
1212 |
clear(); |
|
1213 |
||
1214 |
const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); |
|
1215 |
surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface, 0); |
|
1216 |
if (!surface) |
|
1217 |
qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); |
|
1218 |
||
1219 |
buffer = const_cast<uint*>(buf); |
|
1220 |
bufsize = size; |
|
1221 |
||
1222 |
return surface; |
|
1223 |
} |
|
1224 |
||
1225 |
void SurfaceCache::clear() |
|
1226 |
{ |
|
1227 |
if (surface && QDirectFBScreen::instance()) |
|
1228 |
QDirectFBScreen::instance()->releaseDFBSurface(surface); |
|
1229 |
surface = 0; |
|
1230 |
buffer = 0; |
|
1231 |
bufsize = 0; |
|
1232 |
} |
|
1233 |
||
1234 |
||
1235 |
static inline QRect mapRect(const QTransform &transform, const QRect &rect) { return transform.mapRect(rect); } |
|
1236 |
static inline QRect mapRect(const QTransform &transform, const QRectF &rect) { return transform.mapRect(rect).toRect(); } |
|
1237 |
static inline QLine map(const QTransform &transform, const QLine &line) { return transform.map(line); } |
|
1238 |
static inline QLine map(const QTransform &transform, const QLineF &line) { return transform.map(line).toLine(); } |
|
1239 |
template <class T> |
|
1240 |
static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface) |
|
1241 |
{ |
|
1242 |
if (n == 1) { |
|
1243 |
const QLine l = map(transform, lines[0]); |
|
1244 |
surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); |
|
1245 |
} else { |
|
1246 |
QVarLengthArray<DFBRegion, 32> lineArray(n); |
|
1247 |
for (int i=0; i<n; ++i) { |
|
1248 |
const QLine l = map(transform, lines[i]); |
|
1249 |
lineArray[i].x1 = l.x1(); |
|
1250 |
lineArray[i].y1 = l.y1(); |
|
1251 |
lineArray[i].x2 = l.x2(); |
|
1252 |
lineArray[i].y2 = l.y2(); |
|
1253 |
} |
|
1254 |
surface->DrawLines(surface, lineArray.constData(), n); |
|
1255 |
} |
|
1256 |
} |
|
1257 |
||
1258 |
template <class T> |
|
1259 |
static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) |
|
1260 |
{ |
|
1261 |
if (n == 1) { |
|
1262 |
const QRect r = mapRect(transform, rects[0]); |
|
1263 |
surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height()); |
|
1264 |
} else { |
|
1265 |
QVarLengthArray<DFBRectangle, 32> rectArray(n); |
|
1266 |
for (int i=0; i<n; ++i) { |
|
1267 |
const QRect r = mapRect(transform, rects[i]); |
|
1268 |
rectArray[i].x = r.x(); |
|
1269 |
rectArray[i].y = r.y(); |
|
1270 |
rectArray[i].w = r.width(); |
|
1271 |
rectArray[i].h = r.height(); |
|
1272 |
} |
|
1273 |
surface->FillRectangles(surface, rectArray.constData(), n); |
|
1274 |
} |
|
1275 |
} |
|
1276 |
||
1277 |
template <class T> |
|
1278 |
static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) |
|
1279 |
{ |
|
1280 |
for (int i=0; i<n; ++i) { |
|
1281 |
const QRect r = mapRect(transform, rects[i]); |
|
1282 |
surface->DrawRectangle(surface, r.x(), r.y(), r.width(), r.height()); |
|
1283 |
} |
|
1284 |
} |
|
1285 |
||
1286 |
#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS |
|
1287 |
template <typename T> inline const T *ptr(const T &t) { return &t; } |
|
1288 |
template <> inline const bool* ptr<bool>(const bool &) { return 0; } |
|
1289 |
template <typename device, typename T1, typename T2, typename T3> |
|
1290 |
static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, |
|
1291 |
uint transformationType, bool simplePen, |
|
1292 |
uint clipType, uint compositionModeStatus, |
|
1293 |
const char *nameOne, const T1 &one, |
|
1294 |
const char *nameTwo, const T2 &two, |
|
1295 |
const char *nameThree, const T3 &three) |
|
1296 |
{ |
|
1297 |
QString out; |
|
1298 |
QDebug dbg(&out); |
|
1299 |
dbg << msg << (QByteArray(func) + "()") << "painting on"; |
|
1300 |
if (dev->devType() == QInternal::Widget) { |
|
1301 |
dbg << static_cast<const QWidget*>(dev); |
|
1302 |
} else { |
|
1303 |
dbg << dev << "of type" << dev->devType(); |
|
1304 |
} |
|
1305 |
||
1306 |
dbg << QString::fromLatin1("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) |
|
1307 |
<< "simplePen" << simplePen |
|
1308 |
<< "clipType" << clipType |
|
1309 |
<< "compositionModeStatus" << compositionModeStatus; |
|
1310 |
||
1311 |
const T1 *t1 = ptr(one); |
|
1312 |
const T2 *t2 = ptr(two); |
|
1313 |
const T3 *t3 = ptr(three); |
|
1314 |
||
1315 |
if (t1) { |
|
1316 |
dbg << nameOne << *t1; |
|
1317 |
if (t2) { |
|
1318 |
dbg << nameTwo << *t2; |
|
1319 |
if (t3) { |
|
1320 |
dbg << nameThree << *t3; |
|
1321 |
} |
|
1322 |
} |
|
1323 |
} |
|
1324 |
qWarning("%s", qPrintable(out)); |
|
1325 |
} |
|
1326 |
||
1327 |
#endif // QT_DIRECTFB_WARN_ON_RASTERFALLBACKS |
|
1328 |
||
1329 |
QT_END_NAMESPACE |
|
1330 |
||
1331 |
#endif // QT_NO_QWS_DIRECTFB |