Use Q_GLOBAL_STATIC instead of local statics for singletons

This patch prevents leaking these objects on shutdown.

Change-Id: Ic4a628e0d4dc0b31716f885c1e904b6062cf3ef0
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
<widgets/browser> Connect PermissionUnknown to the discard button

Change-Id: Ie5c216e9a07eae403082ab265ad5300d554037ec
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Wire the geolocation API to QtPositioning

If QtPositioning is available, provide chromium with a
LocationProvider that uses it as a backend.

Change-Id: I53ad3b45e49d0d2d181c1a6459b7be764293c2a6
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
QtQuick: add geolocation permission API

Change-Id: I1a5fedc4167dd780655b004811211e49631663c5
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
QtQuick: rename the media feature permission enum values

In the same way it was done for widgets.

Change-Id: I03ff6ed587346b00c76cf7314483263fd4f90a2d
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Rename DelegatedFrameNodeData to ChromiumCompositorData

This clarifies that those objects span to the lifetime of a Chromium
frame rather than to the DelegatedFrameNode, which can be destroyed
by the scene graph when the window is unmapped.

The also avoids the confusion with the DelegatedFrameData Chromium
structure name.

Change-Id: Ibbeb2b10ef18704fc0934e285cca4ead23879646
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Use the new QSGSimpleTextureNode::sourceRect

This is cleaner than hacking the QSGGeometry data ourselves.

Change-Id: Id2009ac8c6237472e56a11d6daa589e94bf10945
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Don't rely on quads to set the texture size

What really matters with texture coordinates is the normalized 0-1
coordinate that will end up on vertex attributes. By default
QSGSimpleTextureNode will use the full texture size to calculate
those coordinates. In that case any texture size will end up with
the same (0,0)-(1,1) coordinates, so we don't really need to set
the actual texel size of the texture.

So instead of relying on dependent quads to come back and set the
size on the texture, do like the Chromium compositor does and just
make sure that the full normalized texture rect is set on vertices
if no texture size was provided on the resource. Since the scene
graph doesn't achieve this behavior by default with an empty
texture size, set a 1x1 size to get it to do what we want.

Change-Id: I48751d2c2f6ea82dcb4bec9e984b64f7e77316f6
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Avoid relying on QOpenGL classes to handle RenderPasses

Use QSGLayer and get rid of RenderPassTexture so that we can render
intermediate layers with the QtQuick 2D Renderer.
This reintroduces the private dependency on QtQuick since the
QSGLayer factory methods aren't available publically, and also that
we need to use QSGImageNode instead of QSGSimpleTextureNode to use
them.

Since we can't subclass QSGLayer to hold a reference to SG objects
directly in the nodes that use them, store them all in the wrapping
DelegatedFrameNode in a SGObjects structs. This works assuming that
the DelegatedFrameNode will always be at the root of our nodes,
layers and textures; if the scene graph destroys the
DelegatedFrameNode all child nodes will be destroyed with it.

Change-Id: Iedeceb8f98eb54fd8228a677c366d6df9a270e11
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Extract the resource logic out of MailboxTexture

As a first step to allow using plain textures for software resources,
split the Chromium resource handling responsibility into a
ResourceHolder class.

This also moves the static findMailboxTexture into a member
DelegatedFrameNode::findAndHoldResource in preparation for how
texture refcounting will work in the following patch.

Change-Id: Iaa64273c187af022045bbcaa956fcaa1f3defabc
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Support TransferableResource::is_software

When the GPU process fails to initialize, or when the --disable-gpu
switch is provided, the delegating renderer will transfer resource
mailboxes through shared memory pixel data instead of through shared
texture IDs in the GPU process.

Handle this by uploading the pixel data ourselves with
createTextureFromImage, also allowing us to render tiles in the
QtQuick 2D Renderer.

Change-Id: I70ad7122cd0e52dd5ab435ae01e7f032b8e1194e
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Disable the GPU process in cases where we can't setup context sharing

This explicitly disables WebGL and automatic Resource transfer through
GL context sharing in cases that we know this won't work.
This is currently the case for the QtQuick 2D Renderer as well as
when using llvmpipe on Windows.

It could be possible to get Chromium to use GL through opengl32sw.dll
but the change would be more intrusive. Fall back to the Chromium
software compositor code path in that case at the cost of losing
WebGL support with llvmpipe.

Change-Id: I9c1d27ed982dccbe005c8742162c343cc6284e74
Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Don't use Q_FOREACH on QHash::values

QHash::values will copy all values into a new QList, increasing the
ref-count of all stored QSharedPointer temporarily. Use the QHash
iterators directly to avoid this.

Change-Id: I49b1af24b706da195dc4df7206133f039198aad7
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>