summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJulien Brianceau <jbrianceau@nds.com>2012-09-12 12:46:21 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-09-12 17:45:30 (GMT)
commitbdbfc1d1824c32b00506b2a3b8d1b176c3c9a8a0 (patch)
tree50f457d701695cbd7ef3553e1206ae1721a71bd5 /src/gui
parent5032ca8cde5ed6fa39acfde650d373fcb4ea7807 (diff)
downloadQt-bdbfc1d1824c32b00506b2a3b8d1b176c3c9a8a0.zip
Qt-bdbfc1d1824c32b00506b2a3b8d1b176c3c9a8a0.tar.gz
Qt-bdbfc1d1824c32b00506b2a3b8d1b176c3c9a8a0.tar.bz2
qpa: extend drawPixmap capabilities
Extend drawPixmap capabilities for qpa through new OpacityPixmapCapability QBlittable flag and add related implementation in DirectFB platform. cherry-picked from qt5/qtbase 4ae829c1dbd0e8a72b82ab4c6cddb0a4ffe009f6 Change-Id: I8abdb0fa72bc030d769190d7cba40561007e7b46 Reviewed-by: Jørgen Lind <jorgen.lind@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/painting/qblittable_p.h10
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp57
2 files changed, 57 insertions, 10 deletions
diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h
index d89fd22..1640317 100644
--- a/src/gui/painting/qblittable_p.h
+++ b/src/gui/painting/qblittable_p.h
@@ -63,6 +63,7 @@ public:
SourceOverPixmapCapability = 0x0004,
SourceOverScaledPixmapCapability = 0x0008,
AlphaFillRectCapability = 0x0010,
+ OpacityPixmapCapability = 0x0020,
// Internal ones
OutlineCapability = 0x0001000,
@@ -83,6 +84,15 @@ public:
Q_UNUSED(cmode);
qWarning("Please implement alphaFillRect function in your platform or remove AlphaFillRectCapability from it");
}
+ virtual void drawPixmapOpacity(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect, QPainter::CompositionMode cmode, qreal opacity) {
+ Q_UNUSED(rect);
+ Q_UNUSED(pixmap);
+ Q_UNUSED(subrect);
+ Q_UNUSED(cmode);
+ Q_UNUSED(opacity);
+ qWarning("Please implement drawPixmapOpacity function in your platform or remove OpacityPixmapCapability from it");
+ }
+
bool isLocked() const;
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 679e21b..c31bebd 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -75,6 +75,7 @@ public:
, drawRectMask(0)
, drawPixmapMask(0)
, alphaFillRectMask(0)
+ , opacityPixmapMask(0)
, capabillitiesState(0)
{
if (capabilities & QBlittable::SolidRectCapability)
@@ -87,6 +88,8 @@ public:
setSourceOverScaledPixmapMask();
if (capabilities & QBlittable::AlphaFillRectCapability)
setAlphaFillRectMask();
+ if (capabilities & QBlittable::OpacityPixmapCapability)
+ setOpacityPixmapMask();
}
inline bool canBlitterFillRect() const
@@ -122,6 +125,14 @@ public:
return false;
}
+ bool canBlitterDrawPixmapOpacity(const QPixmap &pm) const
+ {
+ if (pm.pixmapData()->classId() != QPixmapData::BlitterClass)
+ return false;
+
+ return checkStateAgainstMask(capabillitiesState, opacityPixmapMask);
+ }
+
inline void updateState(uint mask, bool on) {
updateStateBits(&capabillitiesState, mask, on);
}
@@ -200,11 +211,29 @@ private:
updateStateBits(&drawRectMask, STATE_XFORM_SCALE, true);
}
+ void setOpacityPixmapMask() {
+ updateStateBits(&opacityPixmapMask, STATE_XFORM_SCALE, true);
+ updateStateBits(&opacityPixmapMask, STATE_XFORM_COMPLEX, false);
+
+ updateStateBits(&opacityPixmapMask, STATE_BRUSH_PATTERN, true);
+ updateStateBits(&opacityPixmapMask, STATE_BRUSH_ALPHA, true);
+
+ updateStateBits(&opacityPixmapMask, STATE_PEN_ENABLED, true);
+
+ updateStateBits(&opacityPixmapMask, STATE_ANTIALIASING, true);
+ updateStateBits(&opacityPixmapMask, STATE_ALPHA, true);
+ updateStateBits(&opacityPixmapMask, STATE_BLENDING_COMPLEX, false);
+
+ updateStateBits(&opacityPixmapMask, STATE_CLIPSYS_COMPLEX, false);
+ updateStateBits(&opacityPixmapMask, STATE_CLIP_COMPLEX, false);
+ }
+
QBlittable::Capabilities m_capabilities;
uint fillRectMask;
uint drawRectMask;
uint drawPixmapMask;
uint alphaFillRectMask;
+ uint opacityPixmapMask;
uint capabillitiesState;
};
@@ -223,7 +252,7 @@ public:
void lock();
void unlock();
void fillRect(const QRectF& rect, const QColor&, bool alpha);
- void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr);
+ void clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity);
void updateCompleteState(QPainterState *s);
@@ -362,8 +391,9 @@ void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &colo
}
}
-void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr)
+void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRectF &target, const QPixmap &pm, const QRectF &sr, bool opacity)
{
+ Q_Q(QBlitterPaintEngine);
QRectF intersectedRect = clip.intersected(target);
if (intersectedRect.isEmpty())
return;
@@ -388,7 +418,10 @@ void QBlitterPaintEnginePrivate::clipAndDrawPixmap(const QRectF &clip, const QRe
}
}
pmData->unmarkRasterOverlay(intersectedRect);
- pmData->blittable()->drawPixmap(intersectedRect, pm, source);
+ if (opacity)
+ pmData->blittable()->drawPixmapOpacity(intersectedRect, pm, source, q->state()->compositionMode(), q->state()->opacity);
+ else
+ pmData->blittable()->drawPixmap(intersectedRect, pm, source);
}
QBlitterPaintEngine::QBlitterPaintEngine(QBlittablePixmapData *p)
@@ -521,8 +554,9 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
&& qbrush_color(brush).alpha() == 0xff
&& d->caps.canBlitterFillRect()) {
d->fillRect(rect, qbrush_color(brush), false);
- } else if (brush.style() == Qt::TexturePattern
- && d->caps.canBlitterDrawPixmap(rect, brush.texture(), rect)) {
+ } else if (brush.style() == Qt::TexturePattern &&
+ ((d->caps.canBlitterDrawPixmapOpacity(brush.texture())) ||
+ (d->caps.canBlitterDrawPixmap(rect, brush.texture(), rect)))) {
bool rectIsFilled = false;
QRectF transformedRect = state()->matrix.mapRect(rect);
qreal x = transformedRect.x();
@@ -618,7 +652,10 @@ void QBlitterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pm)
void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
{
Q_D(QBlitterPaintEngine);
- if (d->caps.canBlitterDrawPixmap(r, pm, sr)) {
+ bool canDrawOpacity;
+
+ canDrawOpacity = d->caps.canBlitterDrawPixmapOpacity(pm);
+ if (canDrawOpacity || (d->caps.canBlitterDrawPixmap(r, pm, sr))) {
d->unlock();
QRectF targetRect = r;
@@ -627,15 +664,15 @@ void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const Q
const QClipData *clipData = d->clip();
if (clipData) {
if (clipData->hasRectClip) {
- d->clipAndDrawPixmap(clipData->clipRect, targetRect, pm, sr);
+ d->clipAndDrawPixmap(clipData->clipRect, targetRect, pm, sr, canDrawOpacity);
} else if (clipData->hasRegionClip) {
QVector<QRect>rects = clipData->clipRegion.rects();
- for (int i = 0; i<rects.size(); i++)
- d->clipAndDrawPixmap(rects.at(i), targetRect, pm, sr);
+ for (int i = 0; i<rects.size(); ++i)
+ d->clipAndDrawPixmap(rects.at(i), targetRect, pm, sr, canDrawOpacity);
}
} else {
QRectF deviceRect(0, 0, paintDevice()->width(), paintDevice()->height());
- d->clipAndDrawPixmap(deviceRect, targetRect, pm, sr);
+ d->clipAndDrawPixmap(deviceRect, targetRect, pm, sr, canDrawOpacity);
}
}else {
d->lock();