summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-03-21 09:02:57 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-03-21 09:02:57 +0100
commit6cb8121a44ee0f94f2c9fcb075d1d3c802d8c5c7 (patch)
tree25822898b71068f820d25a9e8372dfb348190ec1 /src/gui
parent96740193e1e0f0608f67660811a44b696924ad4c (diff)
parent2e02de165115c9d67ac343ff0960ed80f9c09bc8 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/widgets/styles/qgtkstyle_p.cpp tests/auto/corelib/io/qtextstream/test/test.pro tests/auto/corelib/plugin/plugin.pro Change-Id: I512bc1b36acf3933ed2b96c00f476ee3819c1f4b
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow.cpp72
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow_p.h10
-rw-r--r--src/gui/painting/qcosmeticstroker.cpp26
-rw-r--r--src/gui/text/qfont.cpp4
-rw-r--r--src/gui/text/qrawfont.cpp3
5 files changed, 49 insertions, 66 deletions
diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp
index 2cfbc4caa4..40bf15b807 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow.cpp
+++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp
@@ -48,52 +48,31 @@
QT_BEGIN_NAMESPACE
QShapedPixmapWindow::QShapedPixmapWindow(QScreen *screen)
- : QWindow(screen),
- m_backingStore(0),
- m_useCompositing(true)
+ : m_useCompositing(true)
{
+ setScreen(screen);
QSurfaceFormat format;
format.setAlphaBufferSize(8);
setFormat(format);
- setSurfaceType(RasterSurface);
- setFlags(Qt::ToolTip | Qt::FramelessWindowHint |
- Qt::X11BypassWindowManagerHint | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus);
- create();
- m_backingStore = new QBackingStore(this);
+ setFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint
+ | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus);
}
QShapedPixmapWindow::~QShapedPixmapWindow()
{
- delete m_backingStore;
- m_backingStore = 0;
-}
-
-void QShapedPixmapWindow::render()
-{
- QRect rect(QPoint(), geometry().size());
-
- m_backingStore->beginPaint(rect);
-
- QPaintDevice *device = m_backingStore->paintDevice();
-
- {
- QPainter p(device);
- if (m_useCompositing)
- p.setCompositionMode(QPainter::CompositionMode_Source);
- else
- p.fillRect(rect, QGuiApplication::palette().base());
- p.drawPixmap(0, 0, m_pixmap);
- }
-
- m_backingStore->endPaint();
- m_backingStore->flush(rect);
}
void QShapedPixmapWindow::setPixmap(const QPixmap &pixmap)
{
m_pixmap = pixmap;
- if (!m_useCompositing)
- setMask(m_pixmap.mask());
+ if (!m_useCompositing) {
+ const QBitmap mask = m_pixmap.mask();
+ if (!mask.isNull()) {
+ if (!handle())
+ create();
+ setMask(mask);
+ }
+ }
}
void QShapedPixmapWindow::setHotspot(const QPoint &hotspot)
@@ -101,19 +80,28 @@ void QShapedPixmapWindow::setHotspot(const QPoint &hotspot)
m_hotSpot = hotspot;
}
-void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
+void QShapedPixmapWindow::paintEvent(QPaintEvent *)
{
- if (m_pixmap.isNull())
- m_backingStore->resize(QSize(1,1));
- else if (m_backingStore->size() != m_pixmap.size())
- m_backingStore->resize(m_pixmap.size());
-
- setGeometry(QRect(pos - m_hotSpot, m_backingStore->size()));
+ if (!m_pixmap.isNull()) {
+ const QRect rect(QPoint(0, 0), size());
+ QPainter painter(this);
+ if (m_useCompositing)
+ painter.setCompositionMode(QPainter::CompositionMode_Source);
+ else
+ painter.fillRect(rect, QGuiApplication::palette().base());
+ painter.drawPixmap(rect, m_pixmap);
+ }
}
-void QShapedPixmapWindow::exposeEvent(QExposeEvent *)
+void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
{
- render();
+ QSize size(1, 1);
+ if (!m_pixmap.isNull()) {
+ size = qFuzzyCompare(m_pixmap.devicePixelRatio(), 1.0)
+ ? m_pixmap.size()
+ : (QSizeF(m_pixmap.size()) / m_pixmap.devicePixelRatio()).toSize();
+ }
+ setGeometry(QRect(pos - m_hotSpot, size));
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h
index 65a4e3cfa7..21cecba9e8 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow_p.h
+++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h
@@ -51,21 +51,18 @@
// We mean it.
//
-#include <QtGui/QWindow>
+#include <QtGui/QRasterWindow>
#include <QtGui/QPixmap>
-#include <QtGui/QBackingStore>
QT_BEGIN_NAMESPACE
-class QShapedPixmapWindow : public QWindow
+class QShapedPixmapWindow : public QRasterWindow
{
Q_OBJECT
public:
explicit QShapedPixmapWindow(QScreen *screen = 0);
~QShapedPixmapWindow();
- void render();
-
void setUseCompositing(bool on) { m_useCompositing = on; }
void setPixmap(const QPixmap &pixmap);
void setHotspot(const QPoint &hotspot);
@@ -73,10 +70,9 @@ public:
void updateGeometry(const QPoint &pos);
protected:
- void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
- QBackingStore *m_backingStore;
QPixmap m_pixmap;
QPoint m_hotSpot;
bool m_useCompositing;
diff --git a/src/gui/painting/qcosmeticstroker.cpp b/src/gui/painting/qcosmeticstroker.cpp
index ba0d1871d1..4965762d74 100644
--- a/src/gui/painting/qcosmeticstroker.cpp
+++ b/src/gui/painting/qcosmeticstroker.cpp
@@ -68,8 +68,8 @@ static inline uint sourceOver(uint d, uint color)
inline static int F16Dot16FixedDiv(int x, int y)
{
if (qAbs(x) > 0x7fff)
- return (((qlonglong)x) << 16) / y;
- return (x << 16) / y;
+ return qlonglong(x) * (1<<16) / y;
+ return x * (1<<16) / y;
}
typedef void (*DrawPixel)(QCosmeticStroker *stroker, int x, int y, int coverage);
@@ -441,14 +441,14 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
qSwap(x1, x2);
}
int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1);
- int x = x1 << 10;
+ int x = x1 * (1<<10);
int y = (y1 + 32) >> 6;
int ys = (y2 + 32) >> 6;
int round = (xinc > 0) ? 32 : 0;
if (y != ys) {
- x += ( ((((y << 6) + round - y1))) * xinc ) >> 6;
+ x += ((y * (1<<6)) + round - y1) * xinc >> 6;
if (swapped) {
lastPixel.x = x >> 16;
@@ -480,7 +480,7 @@ void QCosmeticStroker::calculateLastPoint(qreal rx1, qreal ry1, qreal rx2, qreal
int round = (yinc > 0) ? 32 : 0;
if (x != xs) {
- y += ( ((((x << 6) + round - x1))) * yinc ) >> 6;
+ y += ((x * (1<<6)) + round - x1) * yinc >> 6;
if (swapped) {
lastPixel.x = x;
@@ -759,7 +759,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
dir = QCosmeticStroker::BottomToTop;
}
int xinc = F16Dot16FixedDiv(x2 - x1, y2 - y1);
- int x = x1 << 10;
+ int x = x1 * (1<<10);
if ((stroker->lastDir ^ QCosmeticStroker::VerticalMask) == dir)
caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin;
@@ -771,7 +771,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
int round = (xinc > 0) ? 32 : 0;
if (y != ys) {
- x += ( ((((y << 6) + round - y1))) * xinc ) >> 6;
+ x += ((y * (1<<6)) + round - y1) * xinc >> 6;
// calculate first and last pixel and perform dropout control
QCosmeticStroker::Point first;
@@ -810,7 +810,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
stroker->lastDir = dir;
stroker->lastAxisAligned = axisAligned;
- Dasher dasher(stroker, swapped, y << 6, ys << 6);
+ Dasher dasher(stroker, swapped, y * (1<<6), ys * (1<<6));
do {
if (dasher.on())
@@ -836,7 +836,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
dir = QCosmeticStroker::RightToLeft;
}
int yinc = F16Dot16FixedDiv(y2 - y1, x2 - x1);
- int y = y1 << 10;
+ int y = y1 * (1<<10);
if ((stroker->lastDir ^ QCosmeticStroker::HorizontalMask) == dir)
caps |= swapped ? QCosmeticStroker::CapEnd : QCosmeticStroker::CapBegin;
@@ -848,7 +848,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
int round = (yinc > 0) ? 32 : 0;
if (x != xs) {
- y += ( ((((x << 6) + round - x1))) * yinc ) >> 6;
+ y += ((x * (1<<6)) + round - x1) * yinc >> 6;
// calculate first and last pixel to perform dropout control
QCosmeticStroker::Point first;
@@ -886,7 +886,7 @@ static bool drawLine(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx2,
stroker->lastDir = dir;
stroker->lastAxisAligned = axisAligned;
- Dasher dasher(stroker, swapped, x << 6, xs << 6);
+ Dasher dasher(stroker, swapped, x * (1<<6), xs * (1<<6));
do {
if (dasher.on())
@@ -929,7 +929,7 @@ static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx
caps = swapCaps(caps);
}
- int x = (x1 - 32) << 10;
+ int x = (x1 - 32) * (1<<10);
x -= ( ((y1 & 63) - 32) * xinc ) >> 6;
capAdjust(caps, y1, y2, x, xinc);
@@ -992,7 +992,7 @@ static bool drawLineAA(QCosmeticStroker *stroker, qreal rx1, qreal ry1, qreal rx
caps = swapCaps(caps);
}
- int y = (y1 - 32) << 10;
+ int y = (y1 - 32) * (1<<10);
y -= ( ((x1 & 63) - 32) * yinc ) >> 6;
capAdjust(caps, x1, x2, y, yinc);
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 898b268070..7e18250087 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -137,7 +137,7 @@ extern bool qt_is_gui_used;
Q_GUI_EXPORT int qt_defaultDpiX()
{
- if (qApp->testAttribute(Qt::AA_Use96Dpi))
+ if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi))
return 96;
if (!qt_is_gui_used)
@@ -152,7 +152,7 @@ Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()
{
- if (qApp->testAttribute(Qt::AA_Use96Dpi))
+ if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi))
return 96;
if (!qt_is_gui_used)
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index ca6093227d..6065e17d9b 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -614,8 +614,7 @@ QByteArray QRawFont::fontTable(const char *tagName) const
if (!d->isValid())
return QByteArray();
- const quint32 *tagId = reinterpret_cast<const quint32 *>(tagName);
- return d->fontEngine->getSfntTable(qToBigEndian(*tagId));
+ return d->fontEngine->getSfntTable(MAKE_TAG(tagName[0], tagName[1], tagName[2], tagName[3]));
}
/*!