Skip to content

Commit

Permalink
Merge "Merge remote-tracking branch 'origin/release' into stable" int…
Browse files Browse the repository at this point in the history
…o refs/staging/stable
  • Loading branch information
janihe authored and The Qt Project committed Mar 17, 2014
2 parents 2c175d3 + a2850e5 commit 23b47a8
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 51 deletions.
83 changes: 49 additions & 34 deletions src/gui/painting/qdrawhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5937,7 +5937,7 @@ static void qt_gradient_quint16(int count, const QSpan *spans, void *userData)
}
}

inline static void qt_bitmapblit_quint32(QRasterBuffer *rasterBuffer,
inline static void qt_bitmapblit_argb32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride)
Expand All @@ -5946,6 +5946,15 @@ inline static void qt_bitmapblit_quint32(QRasterBuffer *rasterBuffer,
map, mapWidth, mapHeight, mapStride);
}

inline static void qt_bitmapblit_rgba8888(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride)
{
qt_bitmapblit_template<quint32>(rasterBuffer, x, y, ARGB2RGBA(color),
map, mapWidth, mapHeight, mapStride);
}

inline static void qt_bitmapblit_quint16(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
Expand Down Expand Up @@ -6057,11 +6066,11 @@ static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, in
}
#endif

static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip)
static void qt_alphamapblit_argb32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip)
{
const quint32 c = color;
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32);
Expand Down Expand Up @@ -6152,10 +6161,19 @@ static void qt_alphamapblit_quint32(QRasterBuffer *rasterBuffer,
}
}

static void qt_alphargbblit_quint32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uint *src, int mapWidth, int mapHeight, int srcStride,
const QClipData *clip)
static void qt_alphamapblit_rgba8888(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uchar *map,
int mapWidth, int mapHeight, int mapStride,
const QClipData *clip)
{
qt_alphamapblit_argb32(rasterBuffer, x, y, ARGB2RGBA(color), map, mapWidth, mapHeight, mapStride, clip);
}

static void qt_alphargbblit_argb32(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
const uint *src, int mapWidth, int mapHeight, int srcStride,
const QClipData *clip)
{
const quint32 c = color;

Expand Down Expand Up @@ -6297,27 +6315,27 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
{
blend_color_argb,
qt_gradient_argb32,
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
qt_bitmapblit_argb32,
qt_alphamapblit_argb32,
qt_alphargbblit_argb32,
qt_rectfill_argb32
},
// Format_ARGB32,
{
blend_color_generic,
qt_gradient_argb32,
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
qt_bitmapblit_argb32,
qt_alphamapblit_argb32,
qt_alphargbblit_argb32,
qt_rectfill_nonpremul_argb32
},
// Format_ARGB32_Premultiplied
{
blend_color_argb,
qt_gradient_argb32,
qt_bitmapblit_quint32,
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
qt_bitmapblit_argb32,
qt_alphamapblit_argb32,
qt_alphargbblit_argb32,
qt_rectfill_argb32
},
// Format_RGB16
Expand Down Expand Up @@ -6381,42 +6399,39 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
{
blend_color_generic,
blend_src_generic,
qt_bitmapblit_quint32,
qt_bitmapblit_rgba8888,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
qt_alphamapblit_rgba8888,
#else
0,
0,
#endif
0,
qt_rectfill_rgba
},
// Format_RGBA8888
{
blend_color_generic,
blend_src_generic,
qt_bitmapblit_quint32,
qt_bitmapblit_rgba8888,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
qt_alphamapblit_rgba8888,
#else
0,
0,
#endif
0,
qt_rectfill_nonpremul_rgba
},
// Format_RGB8888_Premultiplied
{
blend_color_generic,
blend_src_generic,
qt_bitmapblit_quint32,
qt_bitmapblit_rgba8888,
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
qt_alphamapblit_quint32,
qt_alphargbblit_quint32,
qt_alphamapblit_rgba8888,
#else
0,
0,
#endif
0,
qt_rectfill_rgba
}
};
Expand Down Expand Up @@ -6502,9 +6517,9 @@ void qInitDrawhelperAsm()
qDrawHelper[QImage::Format_ARGB32].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_ARGB32_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_RGB16].bitmapBlit = qt_bitmapblit16_sse2;
qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit32_sse2;
qDrawHelper[QImage::Format_RGBX8888].bitmapBlit = qt_bitmapblit8888_sse2;
qDrawHelper[QImage::Format_RGBA8888].bitmapBlit = qt_bitmapblit8888_sse2;
qDrawHelper[QImage::Format_RGBA8888_Premultiplied].bitmapBlit = qt_bitmapblit8888_sse2;

extern void qt_scale_image_argb32_on_argb32_sse2(uchar *destPixels, int dbpl,
const uchar *srcPixels, int sbpl,
Expand Down
7 changes: 7 additions & 0 deletions src/gui/painting/qdrawhelper_sse2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
}
}

void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride)
{
qt_bitmapblit32_sse2(rasterBuffer, x, y, ARGB2RGBA(color), src, width, height, stride);
}

void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride)
Expand Down
3 changes: 3 additions & 0 deletions src/gui/painting/qdrawhelper_x86_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ void qt_memfill16(quint16 *dest, quint16 value, int count);
void qt_bitmapblit32_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
void qt_bitmapblit8888_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
void qt_bitmapblit16_sse2(QRasterBuffer *rasterBuffer, int x, int y,
quint32 color,
const uchar *src, int width, int height, int stride);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/text/qcssparser_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ const quint64 PseudoClass_EditFocus = Q_UINT64_C(0x0000080000000000);
const quint64 PseudoClass_Alternate = Q_UINT64_C(0x0000100000000000);
// The Any specifier is never generated, but can be used as a wildcard in searches.
const quint64 PseudoClass_Any = Q_UINT64_C(0x0000ffffffffffff);
const int NumPseudos = 46;
const int NumPseudos = 45;

struct Pseudo
{
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/platforms/cocoa/qcocoamenu.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ - (void) itemFired:(NSMenuItem*) item
{
QCocoaMenuItem *cocoaItem = reinterpret_cast<QCocoaMenuItem *>([item tag]);
QScopedLoopLevelCounter loopLevelCounter(QGuiApplicationPrivate::instance()->threadData);
QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers:[NSEvent modifierFlags]];
cocoaItem->activated();
}

Expand Down Expand Up @@ -268,7 +269,7 @@ - (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteg
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
QCocoaMenuItem *beforeItem = static_cast<QCocoaMenuItem *>(before);

menuItem->setParent(this);
SET_COCOA_MENU_ANCESTOR(menuItem, this);
cocoaItem->sync();
if (beforeItem) {
int index = m_menuItems.indexOf(beforeItem);
Expand Down Expand Up @@ -325,8 +326,8 @@ - (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteg
return;
}

if (menuItem->parent() == this)
menuItem->setParent(0);
if (COCOA_MENU_ANCESTOR(menuItem) == this)
SET_COCOA_MENU_ANCESTOR(menuItem, 0);

m_menuItems.removeOne(cocoaItem);
if (!cocoaItem->isMerged()) {
Expand Down Expand Up @@ -550,7 +551,7 @@ - (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteg
void QCocoaMenu::setMenuBar(QCocoaMenuBar *menuBar)
{
m_menuBar = menuBar;
setParent(menuBar);
SET_COCOA_MENU_ANCESTOR(this, menuBar);
}

QCocoaMenuBar *QCocoaMenu::menuBar() const
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/platforms/cocoa/qcocoamenuitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class QCocoaMenuItem : public QPlatformMenuItem
quintptr m_tag;
};

#define COCOA_MENU_ANCESTOR(m) ((m)->property("_qCocoaMenuAncestor").value<QObject *>())
#define SET_COCOA_MENU_ANCESTOR(m, ancestor) (m)->setProperty("_qCocoaMenuAncestor", QVariant::fromValue<QObject *>(ancestor))

QT_END_NAMESPACE

#endif
10 changes: 5 additions & 5 deletions src/plugins/platforms/cocoa/qcocoamenuitem.mm
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ NSUInteger keySequenceModifierMask(const QKeySequence &accel)
{
if (menu == m_menu)
return;
if (m_menu && m_menu->parent() == this)
m_menu->setParent(0);
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
SET_COCOA_MENU_ANCESTOR(m_menu, 0);

QCocoaAutoReleasePool pool;
m_menu = static_cast<QCocoaMenu *>(menu);
if (m_menu) {
m_menu->setParent(this);
SET_COCOA_MENU_ANCESTOR(m_menu, this);
} else {
// we previously had a menu, but no longer
// clear out our item so the nexy sync() call builds a new one
Expand Down Expand Up @@ -217,12 +217,12 @@ NSUInteger keySequenceModifierMask(const QKeySequence &accel)
mergeItem = [loader preferencesMenuItem];
break;
case TextHeuristicRole: {
QObject *p = parent();
QObject *p = COCOA_MENU_ANCESTOR(this);
int depth = 1;
QCocoaMenuBar *menubar = 0;
while (depth < 3 && p && !(menubar = qobject_cast<QCocoaMenuBar *>(p))) {
++depth;
p = p->parent();
p = COCOA_MENU_ANCESTOR(p);
}
if (depth == 3 || !menubar)
break; // Menu item too deep in the hierarchy, or not connected to any menubar
Expand Down
28 changes: 21 additions & 7 deletions tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private slots:

void plainTextVsRichText();

void setPenPlainText_data();
void setPenPlainText();
void setPenRichText();
void richTextOverridesPen();
Expand All @@ -106,6 +107,8 @@ private slots:
QImage const m_whiteSquare;
};

Q_DECLARE_METATYPE(QImage::Format);

void tst_QStaticText::initTestCase()
{
// a "blank" square; we compare against in our testfunctions to verify
Expand Down Expand Up @@ -615,30 +618,41 @@ void tst_QStaticText::plainTextVsRichText()
QCOMPARE(imagePlainText, imageRichText);
}

void tst_QStaticText::setPenPlainText_data()
{
QTest::addColumn<QImage::Format>("format");

QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied;
QTest::newRow("rgb32") << QImage::Format_RGB32;
QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied;
QTest::newRow("rgbx8888") << QImage::Format_RGBX8888;
}

void tst_QStaticText::setPenPlainText()
{
QFETCH(QImage::Format, format);

QFont font = QGuiApplication::font();
font.setStyleStrategy(QFont::NoAntialias);

QFontMetricsF fm(font);
QPixmap image(qCeil(fm.width("XXXXX")), qCeil(fm.height()));
QImage image(qCeil(fm.width("XXXXX")), qCeil(fm.height()), format);
image.fill(Qt::white);
{
QPainter p(&image);
p.setFont(font);
p.setPen(Qt::green);
p.setPen(Qt::yellow);

QStaticText staticText("XXXXX");
staticText.setTextFormat(Qt::PlainText);
p.drawStaticText(0, 0, staticText);
}

QImage img = image.toImage();
for (int x=0; x<img.width(); ++x) {
for (int y=0; y<img.height(); ++y) {
QRgb pixel = img.pixel(x, y);
for (int x=0; x<image.width(); ++x) {
for (int y=0; y<image.height(); ++y) {
QRgb pixel = image.pixel(x, y);
QVERIFY(pixel == QColor(Qt::white).rgba()
|| pixel == QColor(Qt::green).rgba());
|| pixel == QColor(Qt::yellow).rgba());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ private slots:
void task232085_spinBoxLineEditBg();
void changeStyleInChangeEvent();
void QTBUG15910_crashNullWidget();
void QTBUG36933_brokenPseudoClassLookup();

//at the end because it mess with the style.
void widgetStyle();
Expand Down Expand Up @@ -1656,6 +1657,37 @@ void tst_QStyleSheetStyle::QTBUG15910_crashNullWidget()
QVERIFY(QTest::qWaitForWindowExposed(&w));
}

void tst_QStyleSheetStyle::QTBUG36933_brokenPseudoClassLookup()
{
const int rowCount = 10;
const int columnCount = 10;

QTableWidget widget(rowCount, columnCount);

for (int row = 0; row < rowCount; ++row) {
for (int column = 0; column < columnCount; ++column)
widget.setItem(row, column, new QTableWidgetItem(QStringLiteral("row %1 column %2").arg(row + 1).arg(column + 1)));

// put no visible text for the vertical headers, but still put some text or they will collapse
widget.setVerticalHeaderItem(row, new QTableWidgetItem(QStringLiteral(" ")));
}

// parsing of this stylesheet must not crash, and it must be correctly applied
widget.setStyleSheet(QStringLiteral("QHeaderView::section:vertical { background-color: #FF0000 }"));

widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));

widget.activateWindow();
QApplication::setActiveWindow(&widget);
QVERIFY(QTest::qWaitForWindowActive(&widget));

QHeaderView *verticalHeader = widget.verticalHeader();
QImage image(verticalHeader->size(), QImage::Format_ARGB32);
verticalHeader->render(&image);
QVERIFY(testForColors(image, QColor(0xFF, 0x00, 0x00)));
}


QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"
Expand Down

0 comments on commit 23b47a8

Please sign in to comment.