willReadFrequently already implies this; however that can't
be enabled on Windows. We can use our own attribute to control
the value as it plumbs into the depths of Canvas2D and WebGL
Differential Revision: https://phabricator.services.mozilla.com/D212178
willReadFrequently does basically what we want for Canvas2D;
however it won't work on Windows _and_ it doesn't exist for WebGL
So we will just add our own (privileged) attribute we can set
Differential Revision: https://phabricator.services.mozilla.com/D212177
STR of Bug 1911237 caused different flickering on different GPUs. It is better to disable the SurfaceDescriptorD3D10 video rendering optimization of CanvasRenderingContext2D::DrawImage() for now. Though it causes huge performance regression.
Differential Revision: https://phabricator.services.mozilla.com/D218631
When we fallback from accelerated canvases to non-accelerated canvases, there may
be a stale PathRecording left around that DrawTargetSkia can't use. In this case,
we need to create a PathSkia with the PathRecording's contents.
Differential Revision: https://phabricator.services.mozilla.com/D218512
With AMD GPUs, crash happened when ID3D11Query was used for video rendering to remote canvas. Then the ID3D11Query usage needs to be limited only for video overlay with AMD GPUs. To do it, video rendering optimization to remove canvas is disabled when the ID3D11Query usage is detected with AMD GPUs.
GpuProcessQueryId.mOnlyForOverlay is added to deliver the information.
Differential Revision: https://phabricator.services.mozilla.com/D218390
Canvas uses CSS pixels, so this patch encodes the information into the type
system. Some painting code still uses unknown sizes, so we need to use
`CSSIntSize::FromUnknownSize` and `ToUnknownSize()` to convert them.
This patch doesn't change behavior.
Differential Revision: https://phabricator.services.mozilla.com/D216463
Even though drawing a canvas to itself tries to use ExtractSubrect to get a limited
copy where applicable, the canvas still inadvertently forces the copy-on-write snapshot
to also force a copy due to SurfaceFromElementResult holding a subversive extra reference
to the snapshot, keeping it alive when it need not be.
RecordedTextureData also holds a reference to the snapshot that needs to be cleaned up
as well when the DT is modified.
Differential Revision: https://phabricator.services.mozilla.com/D216520
willReadFrequently already implies this; however that can't
be enabled on Windows. We can use our own attribute to control
the value as it plumbs into the depths of Canvas2D and WebGL
Differential Revision: https://phabricator.services.mozilla.com/D212178
willReadFrequently does basically what we want for Canvas2D;
however it won't work on Windows _and_ it doesn't exist for WebGL
So we will just add our own (privileged) attribute we can set
Differential Revision: https://phabricator.services.mozilla.com/D212177
willReadFrequently already implies this; however that can't
be enabled on Windows. We can use our own attribute to control
the value as it plumbs into the depths of Canvas2D and WebGL
Differential Revision: https://phabricator.services.mozilla.com/D212178
willReadFrequently does basically what we want for Canvas2D;
however it won't work on Windows _and_ it doesn't exist for WebGL
So we will just add our own (privileged) attribute we can set
Differential Revision: https://phabricator.services.mozilla.com/D212177
Fast path for RemoteDecoderVideoSubDescriptor::Tnull_t was added by Bug 1887818. The change is going to extend it to RemoteDecoderVideoSubDescriptor::TSurfaceDescriptorD3D10.
D3D11Texture from GpuProcessD3D11TextureMap::GetSharedHandleOfCopiedTexture() sometimes did not work with D3D11DXVA2Manager::CopyToBGRATexture(). The GetSharedHandleOfCopiedTexture() need to be used when D3D11Device is not compositor device.
When D3D11Device is compositor device, the GetSharedHandleOfCopiedTexture() does not needed to be used. In this case, D3D11DXVA2Manager::CopyToBGRATexture() worked well.
After the CopyToBGRATexture() call, D3D11Texture is opened with D3D11Device(CanvasDevice).
To avoid readback to CPU, DXGITextureHostD3D11::GetAsSurfaceWithDevice() is used to get DataSourceSurface with aDevice without readback to CPU.
Differential Revision: https://phabricator.services.mozilla.com/D206446
When we lose the context for a 2D canvas, we need to silently fail any
canvas calls until the context is recovered. Unfortunately that meant we
returned a nullptr in CanvasRenderingContext2D::GetTransform which is
unsupported by the WebIDL. For now, let's just return an identity
transform as a placeholder for these situations.
Differential Revision: https://phabricator.services.mozilla.com/D211471
This fixes two issues. The first is that the dirty rect passed to EnsureTarget was being
transformed, whereas PutImageData is supposed to bypass transforms. The second is that
PutImageData actually initializes the alpha channel properly, such that Skia DTs do not
need the alpha channel of pixels that are modified by PutImageData to be cleared first,
so that PutImageData can effectively function as the clear itself.
Differential Revision: https://phabricator.services.mozilla.com/D210408
Fast path for RemoteDecoderVideoSubDescriptor::Tnull_t was added by Bug 1887818. The change is going to extend it to RemoteDecoderVideoSubDescriptor::TSurfaceDescriptorMacIOSurface.
Differential Revision: https://phabricator.services.mozilla.com/D207518
Remote canvas can run in the GPU process, and if the GPU process
crashes, we need to notify the application using canvas. Historically we
just failed, and the application may have been able to continue drawing
but with the contents prior to the crash lost. Later we regressed to
prevent the canvas from being used at all.
This patch makes it so that we can restore functionality to any
application that supports the contextlost/contextrestored events. This
will allow for a theoretical complete graceful recovery for the user
with minimal disruption.
Differential Revision: https://phabricator.services.mozilla.com/D205608
GPUVideoImage::GetAsSourceSurface() is heavy weight. It seems better to prevent to call it if possible.
The change handles only a case that CanvasTranslator is used, SurfaceDescriptor is RemoteDecoderVideoSubDescriptor::Tnull_t and OptimizeShadow is not used.
DrawTargetRecording::DrawSurfaceDescriptor() also holds layers::Image of SurfaceDescriptor. It is necessary to keep the Image alive in CanvasDrawEventRecorder until end of its usage in CanvasTranslator.
Differential Revision: https://phabricator.services.mozilla.com/D205677
Remote canvas can run in the GPU process, and if the GPU process
crashes, we need to notify the application using canvas. Historically we
just failed, and the application may have been able to continue drawing
but with the contents prior to the crash lost. Later we regressed to
prevent the canvas from being used at all.
This patch makes it so that we can restore functionality to any
application that supports the contextlost/contextrestored events. This
will allow for a theoretical complete graceful recovery for the user
with minimal disruption.
Differential Revision: https://phabricator.services.mozilla.com/D205608
We previously refactor canvas shutdown to account for the fact that they
needed to be shutdown in conjunction with the DOM worker reference
kept alive by the CanvasManagerChild. Unfortunately if the compositor
process crashes, or otherwise the CanvasManagerChild actor is torn down,
we also prematurely shutdown the canvas when it would previously
fallback to Skia in the content process.
This patch abstracts out canvas shutdown into the CanvasShutdownManager
which has the owning reference to the ThreadSafeWorkerRef. It corrects a
similar bug on the main thread as well for HTMLCanvasElement.
Differential Revision: https://phabricator.services.mozilla.com/D204988
We previously refactor canvas shutdown to account for the fact that they
needed to be shutdown in conjunction with the DOM worker reference
kept alive by the CanvasManagerChild. Unfortunately if the compositor
process crashes, or otherwise the CanvasManagerChild actor is torn down,
we also prematurely shutdown the canvas when it would previously
fallback to Skia in the content process.
This patch abstracts out canvas shutdown into the CanvasShutdownManager
which has the owning reference to the ThreadSafeWorkerRef. It corrects a
similar bug on the main thread as well for HTMLCanvasElement.
Differential Revision: https://phabricator.services.mozilla.com/D204988
It is disabled in this patch via the gfx.canvas.remote.allow-offscreen
pref. A follow up patch will enable this by default.
Differential Revision: https://phabricator.services.mozilla.com/D189532
When OffscreenCanvas::CommitFrameToCompositor uses the non-remote
texture canvas path with Skia, it uses ImageBridgeChild for compositing.
When ImageContainer::SetCurrentImages is called, there was an
intermediate state where the relevant textures were not yet marked as
read only for the compositor's consumption, because the event to do so
was dispatched asynchronously to the ImageBridgeChild thread. If the
owning thread of the canvas (main or DOM worker) ran immediately after
CommitFrameToCompositor, then we could run into texture reuse since
nothing marked the texture yet as being used for compositing. This had
the end result of sometimes displaying back buffer textures currently
being used for drawing on the display pipeline.
This patch makes it so that we mark OffscreenCanvas textures as read
only for the compositor before dispatching, and releasing the lock
either when we swap the images in the ImageContainer (winning the race
with ImageBridgeChild), or after the compositor has finished with it
(losing the race, if any, with ImageBridgeChild).
Additionally, to handle better the case where we run out of buffers, we
need to implement ImageBridgeChild::SyncWithCompositor, to be analogous
to how WebRenderBridgeChild::SyncWithCompositor works. We achieve this
by calling from ImageBridgeChild back into the appropriate
WebRenderBridgeChild based on the window ID associated with the canvas,
It also adds a new pref, gfx.offscreencanvas.shared-provider, which
allows one to switch between PersistentBufferProviderShared and Basic.
The latter of which is used if we fallback from using shared buffers if
it takes too long to get the shared buffers back from the compositor.
Differential Revision: https://phabricator.services.mozilla.com/D200991
If a path builder is left in place after a drawing command, and then user then
sets up new transforms before beginning a new path, the old path will get spuriously
transformed every time the transform is changed, even though it will never be used.
We want to delay actually transforming the path until we need to read from it or
write to it.
Differential Revision: https://phabricator.services.mozilla.com/D198672