Make hellogl work properly regardless of vsync

Task-number: QTBUG-39370
Change-Id: I5b7acb8367f18bfa9318c292657ff7fa0f21f664
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
tst_qwindow: Fix geometries.

Use sizes relative to the test window size; move windows relative
to the top left point of the available screen geometry.
The test now passes on Windows using a 4K monitor.

Task-number: QTBUG-38858
Change-Id: Ia8d992f2a9bfa1cb1deacaf918ed0cfff7616959
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
tst_qwidget: Fix geometries.

Use sizes relative to the test widget size; move windows relative
to the top left point of the available screen geometry. Set a window
title on widgets to be able to identify them. The test now
passes on Windows using a 4K monitor.

Task-number: QTBUG-38858
Change-Id: I5df9198e390befeb3ca18796e24180135a084aad
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Xcode: Reference files by absolute path, and name them by basename only

Xcode uses project and group relative file paths, but to keep things
simple for ourselves we use absolute paths everywhere. We now make an
effort to actually make these paths absolute before telling Xcode they
are.

We also make the visual representation of the files inside Xcode be
just the filename, not the full path, like Xcode itself does. This
is among other things a prerequisite for Xcode to stop complaining
about missing launch images for retina 4-inch screens.

Change-Id: I5ff6bf07f61888e3c9fe2f64cbc2beb896b8442d
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Add ascii_isspace to replace the locale-dependent isspace(3)

Change-Id: Icee42515179e6f3ddefe0692af69e90054449618
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Android: Really suspend apps that are put in the background

The main event loop will be paused when an application is suspended,
this is also the normal behavior of any Android application. When an
application is suspended on Android all its Gl surfaces are destroyed
and can't be used to render anymore. So, we need to pause the main
event loop in order to pause all the timers which might trigger
drawings. The event loop is resumed immediately after the application
is foreground. AndroidManifest.xml contains more info about how to
disable this behavior and what might happen if you do it.

[ChangeLog][Android][Important Behavior Changes] The main event loop is
now stopped when the app is suspended

Task-number: QTBUG-36274
Change-Id: I4c0ba5df9d95f348bca67ea5c76865d6d20775e4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Android: Release all windows when the application is suspended.

When an application is suspended on Android all its Gl surfaces
are destroyed and can't be used to render anymore, so we should
release them in order to give back to the system the memory used
by them.

[ChangeLog] [Android] Release all windows when the application is
suspended.

Task-number: QTBUG-29069
Change-Id: I038aaa2006da1f3188fccba943ec4ffb3e551cf0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Android: Fix expose region.

It seems that the second parameter of handleExposeEvent function is
about the region inside the window, not its position on the screen.

Change-Id: I89f5b2b13c9b0993253542823a84547d6a994c31
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Android: Cleanup androidjnimain.cpp/.h files

Remove unused includes
Remove unused static vars
use Q_NULLPTR insead of 0 or NULL

Change-Id: Id8c99c83c64425c9725e441108010f3821bd3b44
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Ensure valid data after QImage::invertPixels

QImage::invertPixels may produce invalid data after inversions of
images with premultiplied alpha, because the inverted colors will be
larger than the alpha.

This patch converts any image with a premultiplied alpha channel to
ARGB32 before inverting the pixels, and then back to the original
format after the inversion.

Support is added for correct inversion of RGBA8888 and RGB30 formats.

Task-number: QTBUG-39901
Change-Id: Ief24c55f495e67ef2ad6429b5b418d02963a64dd
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Add a test for move assignment to tst_QPalette

It was simply missing.

Change-Id: I6645bb9fe9c81aec9c46ac5efc7d2295a3784ff6
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
tst_QTimeZone: test QTimeZonePrivate::isValidId()

This is in preparation of rewriting the function for efficiency.

Change-Id: Id5c16b984b95d76e1f26d862e3813f75980f44fb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QTimeZone: optimize QTimeZonePrivate::isValidId()

This function is used in the named timezone ctor and was using QByteArray::split(),
followed by size checks and a linear scan for invalid chars per section. The use of
split() resulted in a lot of memory allocations and, unsurprisingly, bad performance.

The new code just performs one linear scan through the byte array, calculating
section sizes on the fly.

Benchmark results (with the test data in tst_QTimeZone::isValidId_data()) show
typical speedups of ~10x for valid IDs:

   RESULT : tst_QTimeZone::isValidId_bench():"minimal middle":
  -     0.00036 msecs per iteration (total: 95, iterations: 262144)
  +     0.000035 msecs per iteration (total: 74, iterations: 2097152)

Even in the sweet-spot case of the old code---a space character anywhere in the
string, checked for before the split---the new code is anywhere between slightly
faster and not much slower:

   RESULT : tst_QTimeZone::isValidId_bench():"invalid char ' ' front":
  -     0.000011 msecs per iteration (total: 94, iterations: 8388608)
  +     0.000010 msecs per iteration (total: 86, iterations: 8388608)
   RESULT : tst_QTimeZone::isValidId_bench():"invalid char ' ' middle":
  -     0.000014 msecs per iteration (total: 62, iterations: 4194304)
  +     0.000016 msecs per iteration (total: 69, iterations: 4194304)
   RESULT : tst_QTimeZone::isValidId_bench():"invalid char ' ' back":
  -     0.000018 msecs per iteration (total: 79, iterations: 4194304)
  +     0.000023 msecs per iteration (total: 98, iterations: 4194304)

This is not surprising, as the space character was singled out for a fast-exit
check before. For any other invalid character, the new version is anywhere from
15x to 35x faster:

   RESULT : tst_QTimeZone::isValidId_bench():"invalid char ? front":
  -     0.00034 msecs per iteration (total: 91, iterations: 262144)
  +     0.000010 msecs per iteration (total: 87, iterations: 8388608)
   RESULT : tst_QTimeZone::isValidId_bench():"invalid char ? middle":
  -     0.00036 msecs per iteration (total: 96, iterations: 262144)
  +     0.000016 msecs per iteration (total: 68, iterations: 4194304)
   RESULT : tst_QTimeZone::isValidId_bench():"invalid char ? back":
  -     0.00035 msecs per iteration (total: 94, iterations: 262144)
  +     0.000021 msecs per iteration (total: 92, iterations: 4194304)

If there was a deeper reason to single out the space character, that fast-exit
path can easily be restored.

This function is often used in conjunction with availableTimeZoneIds(), which
currently vastly dominates the runtime of the function calling both, but I'll
add another optimization for the common use-case of just checking for a time-zone's
existence in a subsequent commit.

Change-Id: Ife1d096fcd39464083ea464c23e49ad98fabf345
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Fix linking of the Direct2D platform plugin with dynamic Open GL.

Change-Id: I0a3272233de7e685c750f001eb45a5e326d0f35b
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Remove pointless debug output

Removes some debug output that indicates that we're dealing with a dock.
It looks like somebody was testing some implementation more than useful
output information.

Change-Id: I04ebbc1f0f1d29ed2099bab9d9e9fc18c9bf0c86
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Android: Output QML import and root paths for qmlimportscanner

When deploying QML applications, the androiddeployqt tool can
use qmlimportscanner to detect the QML dependencies of the
application, but then it needs to know the root of the project
as well as additional QML import paths. We use the already-existing
QML_IMPORT_PATH for the import paths, and default to using the
location of the .pro file for the root path (same as for static
builds in qt.prf).

Change-Id: Ib536272ed1f3f1320ea8ef529655e2ba003bc734
Task-number: QTBUG-34175
Reviewed-by: BogDan Vatra <bogdan@kde.org>
Fix high DPI icons in menu items

The position of high DPI icons is wrong in the Fusion style because
the pixel resolution is not taking into account when centering them.

Task-number: QTBUG-40277
Change-Id: I3593ed461ea57543c3ddfd473105fdc698789132
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Make QOpenGLWidget public

QOpenGLWidget is now public.

In addition Qt::WA_AlwaysStackOnTop is introduced to support the
special case of semi-transparent QOpenGLWidget or QQuickWidget on
top of regular widgets.

hellogl_es2 becomes the qopenglwidget example. This example performs
painting both via QPainter and native GL commands and has the OpenGL
widget combined with other, normal widgets.

The widget stack receives some changes when it comes to renderToTexture
widgets like QQuickWidget and QOpenGLWidget. Calling update() will now
result in a paint event, which is essential for QOpenGLWidget since we
want it to behave like a regular widget. The dirty region handling is
extended specially for such widgets due to performance reasons.
(an OpenGL content update must not result in any backingstore painting,
and is thus handled as a different kind of dirtiness)

[ChangeLog] Added QOpenGLWidget. This widget serves as a replacement for QGLWidget.

Task-number: QTBUG-36899
Task-number: QTBUG-40086
Change-Id: Ibf7f82fea99b39edfffd2fc088e7e0eadbca25cf
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Update QOpenGLFunctions docs

Mention QOpenGLContext::functions() which is used quite commonly in Qt
itself and also some examples.

Also, make it clear that new instances do not degrade performance since
function resolving is done only once.

Change-Id: I74ac194a0b3956a70e5078dd5a1bcdd277b5cc28
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Avoid calling syncWindow with already destroyed platform windows

Issuing a metacall from swapBuffers is dangerous since the window
may get destroyed by the time the slot is invoked.

This patch changes it to use an event, which is more efficient anyway,
that can be invalidated in case the QXcbWindow is destroy()'ed before
the event is delivered.

Change-Id: I44618ac1cb8b221aecce001ea39702164dcab6a5
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Reviewed-by: Uli Schlachter <psychon@znc.in>