Bug 1938053 - Accelerate canvas drawImage of a WebGL context. r=aosmond
Accelerated Canvas2D and WebGL both live within the GPU process and run within the same thread. We want to avoid any kind of readbacks from the GPU process to the content process when doing a drawImage of a WebGL context to an AC2D canvas. To achieve this, we pause the AC2D recording translation with an AwaitTranslationSync event identified by a sync-id. Then we send a request over IPDL to snapshot the WebGL context while this pause is ongoing via a SnapshotExternalCanvas IPDL message, which uses the sync-id to identify the snapshot safely in a table of such external snapshots and force translation to resume. Finally, we send a ResolveExternalSnapshot event within the recording stream to lookup the snapshot based on the sync-id and assign it an alias that can be used within the recording stream playback for drawImage. The sync-id mechanism acts as a sequenced fence so that multiple SnapshotExternalCanvas requests can be encountered simultaneously from IPDL without confusing the recording playback. Differential Revision: https://phabricator.services.mozilla.com/D243399
This commit is contained in:
@@ -1142,6 +1142,11 @@ already_AddRefed<gfx::SourceSurface> ClientWebGLContext::GetSurfaceSnapshot(
|
||||
return ret.forget();
|
||||
}
|
||||
|
||||
mozilla::ipc::IProtocol* ClientWebGLContext::SupportsSnapshotExternalCanvas()
|
||||
const {
|
||||
return GetChild();
|
||||
}
|
||||
|
||||
RefPtr<gfx::SourceSurface> ClientWebGLContext::GetFrontBufferSnapshot(
|
||||
const bool requireAlphaPremult) {
|
||||
const FuncScope funcScope(*this, "<GetSurfaceSnapshot>");
|
||||
|
||||
Reference in New Issue
Block a user