Commit Graph

992 Commits

Author SHA1 Message Date
Tom Ritter
4c7e1cff5c Bug 1899874: Plumb forceSoftwareRendering down the stack. r=jgilbert
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
2024-08-07 00:31:45 +00:00
Tom Ritter
ffb7757eb1 Bug 1899874: Add a privileged forceSoftwareRendering attribute to Canvas Attributes. r=jgilbert,webidl,smaug
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
2024-08-07 00:31:45 +00:00
sotaro
801498597f Bug 1911237 - Disable SurfaceDescriptorD3D10 fast path of CanvasRenderingContext2D::DrawImage() with remote Canvas2d r=gfx-reviewers,lsalzman
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
2024-08-06 23:18:34 +00:00
Lee Salzman
3e5ba515ef Bug 1910868 - Copy Path state if DrawTarget backend type does not match. r=aosmond
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
2024-08-05 13:54:28 +00:00
sotaro
82d6b46605 Bug 1910990 - Don't use ID3D11Query to wait for video copy complete for remote canvas. with AMD GPUs r=gfx-reviewers,lsalzman
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
2024-08-02 23:51:44 +00:00
Ting-Yu Lin
b7e4c25991 Bug 1150182 - Use strong-typed CSSIntSize instead of nsIntSize for canvas sizes. r=gfx-reviewers,layout-reviewers,emilio,nical
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
2024-07-15 15:20:11 +00:00
Lee Salzman
61b748cff6 Bug 1907755 - Avoid inadvertent copies when drawing a canvas to itself. r=aosmond
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
2024-07-15 13:31:40 +00:00
Cristian Tuns
eaf1eefde7 Backed out 2 changesets (bug 1899874) It is crashing the browser on windows and linux, Bug 1906687. CLOSED TREE
Backed out changeset cd0e7d18bbff (bug 1899874)
Backed out changeset 347c3fe4a18f (bug 1899874)
2024-07-09 17:48:05 -04:00
Tom Ritter
5d0545e0db Bug 1899874: Plumb forceSoftwareRendering down the stack. r=jgilbert
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
2024-07-03 08:29:51 +00:00
Tom Ritter
e336c97393 Bug 1899874: Add a privileged forceSoftwareRendering attribute to Canvas Attributes. r=jgilbert,webidl,smaug
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
2024-07-03 08:29:51 +00:00
Stanca Serban
81b1ce4a56 Backed out 20 changesets (bug 1900828, bug 1900863, bug 1902359, bug 1901771, bug 1902671, bug 1901291, bug 1902003, bug 1901799, bug 1897271, bug 1901260, bug 1899874, bug 1903609, bug 1902086, bug 1902364) for causing multiple failures. CLOSED TREE
Backed out changeset 93cd1edda657 (bug 1900828)
Backed out changeset 693209b2919f (bug 1899874)
Backed out changeset b73df6e562de (bug 1899874)
Backed out changeset a93ca984ca88 (bug 1903609)
Backed out changeset 8303598ec6b0 (bug 1903609)
Backed out changeset e3a3c98b34fd (bug 1903609)
Backed out changeset 962fe23bb97a (bug 1903609)
Backed out changeset 00f2e924c9f2 (bug 1903609)
Backed out changeset 0ade4bbe618d (bug 1901291)
Backed out changeset a13f96530518 (bug 1901260)
Backed out changeset 510bc857cdf4 (bug 1902671)
Backed out changeset 754801e10b4b (bug 1902364)
Backed out changeset 7dc2bd362cb9 (bug 1902359)
Backed out changeset 502943b3d954 (bug 1902086)
Backed out changeset 1368337eb6d5 (bug 1902086)
Backed out changeset 0add6564e69b (bug 1902003)
Backed out changeset 929d9508ad19 (bug 1901799)
Backed out changeset 5baeea7c14f6 (bug 1901771)
Backed out changeset 8cf0f72c6a98 (bug 1897271)
Backed out changeset f32d78084462 (bug 1900863)
2024-06-25 16:08:06 +03:00
Tom Ritter
dce3002d08 Bug 1899874: Plumb forceSoftwareRendering down the stack. r=jgilbert
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
2024-06-25 11:53:33 +00:00
Tom Ritter
939c788e8b Bug 1899874: Add a privileged forceSoftwareRendering attribute to Canvas Attributes. r=jgilbert,webidl,smaug
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
2024-06-25 11:53:33 +00:00
Emilio Cobos Álvarez
f96b4202eb Bug 1714238 - Use a single SVG path representation. r=boris,longsonr,webidl,smaug
This removes a bunch of special and complex code from the SVG path code,
and simplifies fixing stuff like bug 1903361.

Differential Revision: https://phabricator.services.mozilla.com/D214411
2024-06-21 16:16:01 +00:00
sotaro
4722659650 Bug 1889275 - Prevent to call GPUVideoImage::GetAsSourceSurface() in CanvasRenderingContext2D::DrawImage() for SurfaceDescriptorD3D10 if CanvasTranslator is used r=gfx-reviewers,lsalzman
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
2024-06-15 00:24:13 +00:00
Emilio Cobos Álvarez
9e2b32ca17 Bug 1899695 - Account for CSS zoom in SVG lengths. r=longsonr
Ugh

Differential Revision: https://phabricator.services.mozilla.com/D212156
2024-05-31 18:33:11 +00:00
Andrew Osmond
7210a5610f Bug 1897201 - Return identity transform while recovering from context loss with canvas. r=gfx-reviewers,lsalzman
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
2024-05-23 22:58:18 +00:00
Andrew Osmond
95f7dc30ac Bug 1891319. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D207819
2024-05-21 18:19:29 +00:00
Narcis Beleuzu
732c326401 Backed out changeset b753f092e8c7 (bug 1891319) as req by aosmond. CLOSED TREE 2024-05-21 20:02:23 +03:00
Andrew Osmond
71d60976b9 Bug 1891319. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D207819
2024-05-21 14:15:06 +00:00
Lee Salzman
3dd0d76f2c Bug 1896738 - Avoid unnecessary clears when using PutImageData on a new canvas. r=aosmond
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
2024-05-15 16:31:27 +00:00
David Shin
e6ce1aa347 Bug 1892089: Support font-relative line-height units use in canvas via SVG filter. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D207871
2024-05-07 20:35:08 +00:00
David Shin
46a093dc96 Bug 1892089: Support font-relative line-height units in SVG. r=longsonr,emilio
Differential Revision: https://phabricator.services.mozilla.com/D207870
2024-05-07 20:35:08 +00:00
sotaro
c4f0239322 Bug 1891675 - Prevent to call GPUVideoImage::GetAsSourceSurface() in CanvasRenderingContext2D::DrawImage() for SurfaceDescriptorMacIOSurface if CanvasTranslator is used r=gfx-reviewers,aosmond
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
2024-04-17 00:05:26 +00:00
sotaro
19cc591e28 Bug 1890852 - Fix UseOptimizeShadow check in CanvasRenderingContext2D::DrawImage() r=gfx-reviewers,lsalzman
Check for detecting OptimizeShadow added by bug 1887818 was wrong .

Differential Revision: https://phabricator.services.mozilla.com/D207396
2024-04-16 00:30:01 +00:00
Andrew Osmond
77675b2d98 Bug 1890077 - Ensure we check for a null target when creating paths for Canvas2D. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D207464
2024-04-15 20:11:09 +00:00
sotaro
51e3a99f06 Bug 1888867 - Add a capability to diable fast path for remote Canvas with pref in CanvasRenderingContext2D::DrawImage r=gfx-reviewers,lsalzman
It is nice if we could disable fast path for remote canvas(Bug 1887818) with pref for testing.

Differential Revision: https://phabricator.services.mozilla.com/D206217
2024-04-01 07:18:46 +00:00
sotaro
1e7fe26ef2 Bug 1888588 - Rename MaybeGetSurfaceDescriptorForCanvasTranslator() to MaybeGetSurfaceDescriptorForRemoteCanvas() r=gfx-reviewers,lsalzman
MaybeGetSurfaceDescriptorForRemoteCanvas() is better name.

Differential Revision: https://phabricator.services.mozilla.com/D206090
2024-03-29 06:44:16 +00:00
Andrew Osmond
4b2eb5885c Bug 1887729 - Implement context lost/restored support for CanvasRenderingContext2D. r=webidl,gfx-reviewers,smaug,lsalzman
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
2024-03-28 14:50:20 +00:00
sotaro
b1a624365a Bug 1887818 - Prevent to call GPUVideoImage::GetAsSourceSurface() in CanvasRenderingContext2D::DrawImage() for RemoteDecoderVideoSubDescriptor::Tnull_t if CanvasTranslator is used r=gfx-reviewers,lsalzman
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
2024-03-28 06:24:41 +00:00
Butkovits Atila
1e3d704450 Backed out changeset 40fa8e4b06c8 (bug 1887729) for causing failures at test_accelerated_canvas_context_loss.html. CLOSED TREE 2024-03-28 05:09:32 +02:00
Andrew Osmond
7e75ca180a Bug 1887729 - Implement context lost/restored support for CanvasRenderingContext2D. r=webidl,gfx-reviewers,smaug,lsalzman
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
2024-03-28 01:51:23 +00:00
Andrew Osmond
d41fbab24e Bug 1886022 - Refactor canvas shutdown to account for process crashes. r=gfx-reviewers,lsalzman
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
2024-03-19 14:09:13 +00:00
Cosmin Sabou
d7091053b8 Backed out changeset 0e250e45603a (bug 1886022) for causing build bustages on CanvasShutdownManager. CLOSED TREE 2024-03-19 09:42:20 +02:00
Andrew Osmond
e4b6cc882c Bug 1886022 - Refactor canvas shutdown to account for process crashes. r=gfx-reviewers,lsalzman
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
2024-03-19 00:39:55 +00:00
Andrew Osmond
4da3f91a46 Bug 1885365 - Improve canvas error throwing for draw target creation failures. r=gfx-reviewers,jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D204653
2024-03-15 01:45:43 +00:00
Stanca Serban
ddfa1c2b63 Backed out changeset d355d851f95e (bug 1885365) for causing assertion failures. CLOSED TREE 2024-03-14 23:38:42 +02:00
Andrew Osmond
627a9167c5 Bug 1885365 - Improve canvas error throwing for draw target creation failures. r=gfx-reviewers,jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D204653
2024-03-14 18:28:39 +00:00
Andrew Osmond
00af580d42 Bug 1855742 - Part 3. Allow recording based canvases with OffscreenCanvas. r=gfx-reviewers,lsalzman
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
2024-02-21 03:08:03 +00:00
Andrew Osmond
bc84f1c089 Bug 1877429 - Prevent offscreen canvas2d updates from racing with compositing. r=gfx-reviewers,lsalzman
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
2024-02-07 20:25:52 +00:00
Lee Salzman
25a04a247d Bug 1877010 - Track forwarder transaction ids for RemoteTextureMap with WebGL and WebGPU. r=sotaro
Differential Revision: https://phabricator.services.mozilla.com/D199876
2024-01-30 15:44:04 +00:00
Andrew Osmond
c736d3120c Bug 1870488 - Part 3. Make OffscreenCanvas use PersistentBufferProvider on the display pipeline. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D195124
2024-01-18 01:12:34 +00:00
Lee Salzman
9f2090ebbe Bug 1874842 - Avoid redundant transformed copies of Canvas2d path builder. r=aosmond
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
2024-01-17 00:18:05 +00:00
Lee Salzman
3b9c142e33 Bug 1874666 - Reduce some unnecessary SetTransform calls. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D198524
2024-01-15 19:30:40 +00:00
Jonathan Kew
f9312fc171 Bug 1872545 - Hoist color-font palette cache out of TextRunDrawParams to the nsPresContext or CanvasRenderingContext2D, for greater effectiveness. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D197463
2024-01-04 11:07:44 +00:00
Iulian Moraru
27b6f41469 Backed out changeset 21beaf6ba627 (bug 1872545) for causing windows build bustages on FontPaletteCache.cpp. CLOSED TREE 2024-01-04 01:54:01 +02:00
Jonathan Kew
e976fa1b8c Bug 1872545 - Hoist color-font palette cache out of TextRunDrawParams to the nsPresContext or CanvasRenderingContext2D, for greater effectiveness. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D197463
2024-01-03 22:54:10 +00:00
Cristian Tuns
7695546799 Backed out changeset 395cc57551ec (bug 1872545) for causing build bustages in rust.mk CLOSED TREE 2024-01-03 05:14:31 -05:00
Jonathan Kew
66b754598a Bug 1872545 - Hoist color-font palette cache out of TextRunDrawParams to the nsPresContext or CanvasRenderingContext2D, for greater effectiveness. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D197463
2024-01-02 13:12:29 +00:00
Narcis Beleuzu
99b9ad7672 Backed out changeset e959df5e9484 (bug 1872545) for bustages on COLRFonts.cpp 2024-01-02 13:50:05 +02:00