ozone: scenic: Make software output work with VizDisplayCompositor

This makes software output work from Viz on Fuchsia by allowing creation
of surfaces from non "main" threads. Previously we assumed that the
thread that ran our initializer was the only one creating any surfaces,
which were the browser UI and Viz GPU threads. This assumption does not
hold in Viz display compositor's software path.

Since we use mojo and mojo proxy objects are thread hostile, a couple of
operations are now posted to the thread that runs the initializer ("main"
thread).

  - Creation of sessions via the master scenic FIDL endpoint
  - Messaging to the browser to attach scenic surfaces to their parents

These are infrequent operations so it shouldn't be a performance concern.

Locking is used to protect the surface map. Surfaces are still thread
hostile, but software surfaces can now be created from any thread as long
as they are used and destroyed on the same thread.

Bug: 922242
Test: run_content_shell --enable-features=VizDisplayCompositor on fuchsia

Change-Id: I7acba0d3cc03ac27825616bec40d86f682d4bf62
Reviewed-on: https://chromium-review.googlesource.com/c/1413658
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Reviewed-by: Sergey Ulanov <sergeyu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#623522}
5 files changed