Fix drawCachedGlyphs on RGBA8888

drawCachedGlyphs draws with the wrong color on RGBA8888. The issue
is that the draw routines bitmapblit_quint32 and alphamapblit_quint32
while safe to use on rgba formats, needs to have the input color
converted.

This patch adds small wrapper functions for bitmapblit and alphamapblit
that converts the formats. Two tests are extended to ensure we have
test coverage.

Change-Id: I5f99f3795eba46a69d4df5b167e6099024e9a060
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
CSS parser: fix the pseudo-classes array length

The pseudoclass array is declared with length "NumPseudos - 1",
but the declaration has actually 44 elements, not 45.

This caused a zero-initialized last element to be silently appended
to the array. The zero-initialized element broke the sorting
of the array, which in turn broke std::lower_bound usage
(although of course the problem was there from before switching
to the standard library algorithms).

Task-number: QTBUG-36933
Change-Id: I8a02891fc36761b6ae72d15a0a8d6c6a96813947
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Cocoa Menu: Set keyboard modifiers when item is activated

Seems to be a regression from 4.8, which is not surprising
since everything was rewritten for QPA.

Task-number: QTBUG-36851
Change-Id: If89f8c9e6897fd1e02800f49e51baeb1ea181238
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Reviewed-by: James Turner <james.turner@kdab.com>
Cocoa Menus: Give platform menu ownership back to QWidgets

We don't want to be in the situation where a QCocoaMenuItem
owns a QCocoaMenu (because that item is a submenu), and then
the actual QMenu "sees" that same QCocoaMenu being deleted.

Instead, since all the QCocoaMenu* classes inherit QObject,
we rely on meta-object properties to set the hierarchy and
climb the hierarchy when guessing the menu item's role.

This ammends most of commit 370e89f06465a4d61c7b.

Task-number: QTBUG-36785
Change-Id: I0e03acb593e93061c8c6c1fdd161669cf0d2a293
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
do not use fileno calls in forked child

This fixes an issue that causes QProcess::start to silently fail on
OS X 10.9. Apparently, fileno(stdout) locks the handle on OS X 10.9.
It may happen that the parent process fflush()s stdout while the child
has just been forked. The stdout lock of the parent is never released
in the child and fileno(stdout) therefore locks forever.

According to the fork documentation on opengroup.org one may only call
async-signal-safe functions between fork and exec in the child. The
fileno() function does not appear in the list of async-signal-safe
functions. Also, fileno(stdout) and friends can be easily replaced by
the standard constants STDOUT_FILENO etc.

Done-with: Fawzi Mohamed <fawzi.mohamed@digia.com>
Task-number: QTBUG-37306

Change-Id: I2b1f5f47cc48a1ad020fb0493a955d2bc27aeb47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from b2216bbe06b8be2bef6d8bc2ffff1337f6d23358)
Merge remote-tracking branch 'origin/release' into stable

Conflicts:
	src/gui/painting/qdrawhelper.cpp
	src/gui/painting/qdrawhelper_avx.cpp
	src/gui/painting/qdrawhelper_x86_p.h

Change-Id: I09352d05119f6fd000319074a2705b38361b2c90
Fix Q_DECLARE_METATYPE macro

The macro should stringify value of the given token not the token
itself.

Task-number: QTBUG-37547
Change-Id: I90f4fa613bd13d5a581828ab13f620b40dfd3593
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Fix no-opengl build with egl

Disable eglfs and similar plugins when opengl is not enabled.
(but egl is present)

GL-dependent parts of eglconvenience need to be skipped too.

Task-number: QTBUG-37457
Change-Id: I44d49495241551bc7b1f565aa0b5ace9f310628e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Revert "Make OpenGL texture glyph cache use the right freetype glyphs"

This reverts commit f78661b03cc1affcdd222be50b35d956edac4711.

The reverted patch was working around that QFontEngineFT was using
the poor QFontEngine fall back. That issue was fixed in commit
0b7beaaaf2384fae01ae403737450a59b2fcabac, and the work around
is no longer needed.

This also fixes a rare problem with the workaround when the fontengine
and the glyph-cache do not share the same default glyph format which
can happen with QRawFonts.

Change-Id: I150f70a003b137c1d145f6f70cda568c85633e5c
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
QPrinter - Add page metric tests

Add more page metrics tests to expose the many bugs and inconsistencies
in the page layout handling.  No platform or pdf backend passes all
these tests so they are skipped for now, but following commits will use
the tests to ensure the re-write of the page layout handling fixes the
many problems in a consistent way for all backends.

Change-Id: Ic5b16aa08dfe2bd9a9191662fd2bbe6b913e15c9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
QPageSize - Add new QPageSize class

New QPageSize class to encapsulate paper sizes and names to ensure all
sizes and conversions are consistent and match the Postscript standard
sizes.

Subsequent changes will use this class in the paged paint devices,
paint engines, print engines, and print plugins to replace multiple
inconsistent local implementations.

[ChangeLog][QtGui][QPageSize] Added new QPageSize class to implement
Adobe Postscript PPD standard page sizes. This class supports the
standard page sizes, names and keys from the PPD standard, and provides
convenient size and rect conversion methods.

Change-Id: Ie2c8be0c3df0d29ac5da4cd9877ad41d0982633c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPageLayout - Add new QPageLayout class

New QPageLayout to encapsulate page layout details including page size,
orientation and margins.  Scale may be added later.

Subsequent changes will use this class in the paged paint devices,
paint engines, print engines, and print plugins to replace multiple
inconsistent local implementations.

[ChangeLog][QtGui] Added class QPageLayout to support handling page
layouts including the page size, orientation and margins.

Change-Id: Ife1ddd6c2a8d1516542be2eb37425111f41cd5c7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
QPlatformPrintDevice - New QPA base class

Add a new QPA class to abstract Print Devices.  Each platform instance
will encapsulate all required details about a print device instead of
the code being distributed throughout the print engine and print
plugin.

Change-Id: I7f6a537ad55a6e7f599d83f461b1e2ee62b15094
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QtPrintSupport - Increase Cups required to 1.4

Change the minimum required version of CUPS to be 1.4, which has been
available in most distros since 2009.  Note this is only available in
RHEL 6 and later, RHEL 5 will no longer be supported for printing.

[ChangeLog][QtPrintSupport] CUPS 1.4 is now required for print support
on Linux and other *nix platforms.

Change-Id: Id9c4c748be6436ccc995da08ff6bb3eeef08c35a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPlatformPrintDevice - Add CUPS implementation

Add support to the CUPS print plugin for the new QPlatformPrintDevice
class.  Note this is called QPpdPrintDevicePrivate as it uses the CUPS
PPD support which is deprecated from CUPS 1.6 onwards.  A different
plugin will be implemented for the CUPS 1.6 support.

Change-Id: I26d005f90842d9c6262341171ef157536d28cc5d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPlatformPrintDevice - Add Mac implementation

Implement the OSX support for QPlatformPrintDevice

Change-Id: I2e3900818d4d9f0682a15ed94b8c824085adb465
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPlatformPrintDevice - Add Windows implementation

Add Windows implementation of QPlatformPrintDevice.

Change-Id: I007678cd6d2bdae0728b61cc2796a5c5e5d1578f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPrinterInfo - Switch to QPlatformPrintDevice

Change the QPrinterInfo implementation to use QPlatformPrintDevice as
the backend.  Remove all the old QPrinterInfo related code from the
QPA plugin.  Add public api to QPrinterInfo to support some features
from QPlatformPrintDevice.

[ChangeLog][QtPrintSupport][QPrinterInfo] Added new public api for
isRemote(), state(), defaultPageSize(), supportedPageSizes(),
supportsCustomPageSizes(), minimumPhysicalPageSize(),
maximumPhysicalPageSize(), supportedResolutions(),
availablePrinterNames(), and defaultPrinterName(). The use of
availablePrinters() is discouraged due to performance concerns.

Task-number: QTBUG-35248

Change-Id: Ic38323a930549ad67bf04a1a6bb43d623dfe6a33
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPagedPaintDevice - Use QPageSize and QPageLayout

Use new QPageLayout and QPageSize class to store and convert page sizes
and layouts consistently.  Extend the PageSize enum to match
QPage::PageSize.

Note that public setters/getters cannot be added as virtuals would break
BIC, but without virtuals the derived classes would break.  Instead an
internal api is provided and the derived classes will need to
implement identical api to manipulate it.

[ChangeLog][QtGui][QPagedPaintDevice] Paged paint devices such as
QPrinter and QPdfWriter now support all Postscript standard page sizes.

Task-number: QTBUG-27685
Task-number: QTBUG-25744

Change-Id: I62e96ab94194ab4ac8bed8fa804e0ce1c3233313
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
QPdfPaintEngine - Use QPageLayout and QPageSize

Switch internals of QPdfPageEngine and derived classes to use
QPageLayout and QPageSize to make handling of page layout and size
more consistent by removing multiple implementations.  In particular
remove all use of the QPdf namespace version of page size.

Change-Id: Ie820340015e8812c8162bd1a257dd0f51f4f0b85
Reviewed-by: Lars Knoll <lars.knoll@digia.com>