Commit Graph

3051 Commits

Author SHA1 Message Date
Lee Salzman
bc333ceb93 Bug 1761404 - Add DrawTarget DrawShadow API call. r=jrmuizel,gfx-reviewers
This implements a new DrawTarget API call, DrawShadow. This can be used to draw
the shadow of a given Path and Pattern. Unlike DrawSurfaceWithShadow, this only
draws the shadow to simplify the resulting implementation. DrawTarget provides
a default implementation that will draw a blurred shadow to a transient surface
before handing it off to DrawSurfaceWithShadow, allowing existing DrawTarget
implementations to function without having to implement the new API at all.

Within DrawTargetWebgl, DrawShadow allows direct caching of the shadow in the
existing PathCache mechanism, unlike DrawSurfaceWithShadow which would usually
be called with different transient surfaces every time, even if the input
patterns actually matched.

CanvasRenderingContext2D is modified to call DrawShadow when only a shadow
needs to be applied without any filter. AdjustedTarget is modified to wrap
the necessary DrawTarget draw calls so they can be dispatched appropriately.

Since a lot of redundant shadow parameters are shared between DrawShadow and
DrawSurfaceWithShadow, and since a lot of consumers of these functions need
to also pass around these parameters, this also bundles these into a new
ShadowOptions structure to make this easier.

Differential Revision: https://phabricator.services.mozilla.com/D142026
2022-04-01 19:03:29 +00:00
Lee Salzman
162987b5a3 Bug 1759715 - Avoid using layers with D2D blend effect. r=aosmond
It seems as if any attempt to use PushLayer with the Blend effect causes alpha
to be incorrectly blended. Using FillGeometry explicitly with the clip geometry
and D2D1_PRIMITIVE_BLEND_COPY seems to work around this.

Differential Revision: https://phabricator.services.mozilla.com/D142501
2022-03-31 08:58:39 +00:00
Jonathan Kew
6bbbf58763 Bug 1756468 - Add locking to gfxFont, to allow worker threads to do text shaping. r=lsalzman
We protect the shaped-word cache in each font with a RWLock, so that multiple threads can
shape in parallel using cached data; only when a new entry needs to be cached will we need
to take a write lock.

(To improve clarity, this patch also constifys a bunch of methods that do not mutate the
font instance.)

Differential Revision: https://phabricator.services.mozilla.com/D141473
2022-03-24 18:58:00 +00:00
Butkovits Atila
131dd31758 Backed out changeset f26f836c1575 (bug 1756468) for causing leakes. CLOSED TREE 2022-03-24 03:28:12 +02:00
Jonathan Kew
5a3bb65719 Bug 1756468 - Add locking to gfxFont, to allow worker threads to do text shaping. r=lsalzman
We protect the shaped-word cache in each font with a RWLock, so that multiple threads can
shape in parallel using cached data; only when a new entry needs to be cached will we need
to take a write lock.

(To improve clarity, this patch also constifys a bunch of methods that do not mutate the
font instance.)

Differential Revision: https://phabricator.services.mozilla.com/D141473
2022-03-23 23:17:34 +00:00
Randell Jesup
c1b9361c0e Bug 1207753 - gfx & image thread-safety annotations r=gfx-reviewers,aosmond
Differential Revision: https://phabricator.services.mozilla.com/D130600
2022-03-21 18:05:31 +00:00
Randell Jesup
1ca66b0f8c Bug 1207753 - gfx thread-safety annotations r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D141608
2022-03-21 16:28:47 +00:00
Randell Jesup
c5917ed65a Bug 1207753: Basic thread-safety annotations to quiet errors until real annotations land r=nika
Differential Revision: https://phabricator.services.mozilla.com/D141062
2022-03-17 18:39:15 +00:00
Emilio Cobos Álvarez
b055f536ea Bug 1758702 - Allow ThreadSafeWeakPtr<IncompleteType> to work. r=glandium
This will be used to avoid problematic includes from WorkerPrivate.h,
and it matches the behavior of RefPtr<> and WeakPtr<>.

Differential Revision: https://phabricator.services.mozilla.com/D140658
2022-03-17 15:24:40 +00:00
criss
9302fa739c Backed out 2 changesets (bug 1758702) for causing build bustages. CLOSED TREE
Backed out changeset 3e00d9203851 (bug 1758702)
Backed out changeset 66625baf0875 (bug 1758702)
2022-03-17 15:21:31 +02:00
Emilio Cobos Álvarez
370bce32dc Bug 1758702 - Allow ThreadSafeWeakPtr<IncompleteType> to work. r=glandium
This will be used to avoid problematic includes from WorkerPrivate.h,
and it matches the behavior of RefPtr<> and WeakPtr<>.

Differential Revision: https://phabricator.services.mozilla.com/D140658
2022-03-17 12:15:20 +00:00
Randell Jesup
fcaf70841e Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 18:47:08 +00:00
Noemi Erli
2390d257e6 Backed out changeset 12a59e5a50bf (bug 1207753) for causing build bustage CLOSED TREE 2022-03-16 18:32:51 +02:00
Randell Jesup
4b033a5256 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 16:16:14 +00:00
Butkovits Atila
927ad62c6a Backed out changeset a68ee4b09f92 (bug 1207753) for causing Hazard bustages. CLOSED TREE 2022-03-16 14:38:14 +02:00
Randell Jesup
7d4b5fae04 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 12:01:14 +00:00
Lee Salzman
a1ba0b4ade Bug 1758968 - Clip drawing in DrawTargetD2D1::DrawSurfaceWithShadow. r=gfx-reviewers,nical
DrawSurfaceWithShadow is supposed to ignore transforms but still support clipping.
It appears that DrawTargetD2D1 for some reason never actually implemented clipping.

The DrawImage calls on the DC just need to happen within the bounds of PrepareForDrawing
and FinalizeDrawing. Since PrepareForDrawing handles the overriding of the blend mode
via SetPrimitiveBlend, we need to use DrawImage with D2D1_COMPOSITE_MODE_SOURCE_OVER
so that it will blend appropriately.

Differential Revision: https://phabricator.services.mozilla.com/D140798
2022-03-11 10:02:07 +00:00
Lee Salzman
6f0be8c19f Bug 1757067 - Explicitly specify chroma subsampling scheme for YCbCr data. r=jgilbert,jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D139656
2022-03-10 09:24:15 +00:00
smolnar
97f77f8381 Backed out changeset 36c6350bc7d1 (bug 1757067) for causing build bustages in gfx/gl/GLBlitHelperD3D.cpp CLOSED TREE 2022-03-10 10:10:10 +02:00
Lee Salzman
a664a6d305 Bug 1757067 - Explicitly specify chroma subsampling scheme for YCbCr data. r=jgilbert,jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D139656
2022-03-10 07:48:53 +00:00
Brad Werth
418ae64bbb Bug 1745492 Part 2: Update MacIOSurface handling to deal with 10-bit formats. r=media-playback-reviewers,gfx-reviewers,lsalzman,alwu
This fixes an issue caused by landing Bug 1679927. Now that it's possible to
get 10-bit formats in macOS, the texture pipeline has to be updated to pass
those surfaces to WebRender.

This also contains a drive-by comment on D3D11 handing of 10-bit WebRender
display items. It was not clear why specifing 16-bit color depth for P010
format was correct there, but should be specified as 10-bit color elsewhere.

This also contains another drive-by fix to comments in webrender describing
the RG16 enum.

Depends on D136046

Differential Revision: https://phabricator.services.mozilla.com/D136823
2022-03-05 17:31:18 +00:00
Randell Jesup
ffaf118a11 Bug 1758188: Remove unneeded mutex from FilterNodeSoftware r=gfx-reviewers,mstange
Differential Revision: https://phabricator.services.mozilla.com/D140404
2022-03-04 21:44:29 +00:00
Lee Salzman
05d60c01fa Bug 1752457 - Don't normalize zero halfway-vector in SpecularLightingSoftware. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D139967
2022-03-02 18:24:28 +00:00
Randell Jesup
359cf4ab53 Bug 1757189: Remove unneeded lock in FilterNodeLightingSoftware since we don't use OMTP r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D139726
2022-02-25 19:58:24 +00:00
Narcis Beleuzu
79e1db1339 Backed out 5 changesets (bug 1745492) for reftest failures on image-10bits-rendering-720-video.html CLOSED TREE
Backed out changeset 4cbbe77eaede (bug 1745492)
Backed out changeset 8eead27d1cc7 (bug 1745492)
Backed out changeset 6fc6bbab5b53 (bug 1745492)
Backed out changeset 823e45ca5fd3 (bug 1745492)
Backed out changeset f378944b0366 (bug 1745492)
2022-02-23 21:15:58 +02:00
Brad Werth
4b772da5ef Bug 1745492 Part 2: Update MacIOSurface handling to deal with 10-bit formats. r=media-playback-reviewers,gfx-reviewers,lsalzman,alwu
This fixes an issue caused by landing Bug 1679927. Now that it's possible to
get 10-bit formats in macOS, the texture pipeline has to be updated to pass
those surfaces to WebRender.

This also contains a drive-by comment on D3D11 handing of 10-bit WebRender
display items. It was not clear why specifing 16-bit color depth for P010
format was correct there, but should be specified as 10-bit color elsewhere.

This also contains another drive-by fix to comments in webrender describing
the RG16 enum.

Differential Revision: https://phabricator.services.mozilla.com/D136823
2022-02-22 19:17:20 +00:00
Lee Salzman
ce2bd5b47f Bug 1755780 - Optimize DrawTargetWebgl for BGRA WebGL framebuffer. r=aosmond
Currently within DrawTargetWebGL, the Skia framebuffer and external software
surfaces are in BGRA, while the WebGL framebuffer is in RGBA. This requires
swizzling all software surfaces to RGBA on upload and swizzling surfaces
back to BGRA on readback. This can either require intermediate surfaces or
extra costly processing.

Now that CopyToSwapChain is available with support for a BGRA blit, we can
remove these complications by just treating the WebGL framebuffer as if it
was BGRA directly, so that any uploads or readbacks do not require a swizzle.

Differential Revision: https://phabricator.services.mozilla.com/D139066
2022-02-21 17:33:09 +00:00
Jeff Muizelaar
1b11e0ebdb Bug 1755718 - Assert that color formats can be handled by Skia. r=aosmond
Just defaulting to BGRA is going to cause trouble down the line.

Differential Revision: https://phabricator.services.mozilla.com/D138897
2022-02-17 20:14:01 +00:00
Butkovits Atila
dff61f12f4 Backed out changeset 4c5ad6cc4df3 (bug 1755718) for causing reftest failures. CLOSED TREE 2022-02-16 20:06:14 +02:00
Jeff Muizelaar
f610da391a Bug 1755718 - Assert that color formats can be handled by Skia. r=aosmond
Just defaulting to BGRA is going to cause trouble down the line.

Differential Revision: https://phabricator.services.mozilla.com/D138897
2022-02-16 16:12:50 +00:00
Lee Salzman
58cc63bda7 Bug 1754130 - Implement SourceSurfaceWebgl for faster snapshots of DrawTargetWebgl. r=aosmond
Now that each DrawTargetWebgl shares the same WebGL context, we can efficiently draw snapshots
of one DrawTargetWebgl to another without requiring any readback or error-prone driver-provided
shared context/resource mechanism. We just need to simply pass the WebGL texture from one target
to the other, and use it like any other texture.

This provides SourceSurfaceWebgl to store and pass along that WebGL texture. It is largely
modeled off of SourceSurfaceSkia in terms of its copy-on-write behavior. There are three
noteworthy state changes that it must track from DrawTargetWebgl - when the framebuffer
contents is changing, when the framebuffer is being destroyed, and when any cached texture
handle separate from a framebuffer is also being destroyed. It will copy, orphan, or read
back data as appropriate to handle each case.

If it needs to be mapped, it just forces a read back of the data into a CPU surface that
can be mapped as requested.

Differential Revision: https://phabricator.services.mozilla.com/D138118
2022-02-11 19:49:55 +00:00
Marian-Vasile Laza
610558649b Backed out 3 changesets (bug 1754130) for causing mochitest failures. CLOSED TREE
Backed out changeset 7fea32057b92 (bug 1754130)
Backed out changeset 1ac8f10e0025 (bug 1754130)
Backed out changeset 3d56b847ddf9 (bug 1754130)
2022-02-11 18:30:11 +02:00
Lee Salzman
8a34e8c65e Bug 1754130 - Implement SourceSurfaceWebgl for faster snapshots of DrawTargetWebgl. r=aosmond
Now that each DrawTargetWebgl shares the same WebGL context, we can efficiently draw snapshots
of one DrawTargetWebgl to another without requiring any readback or error-prone driver-provided
shared context/resource mechanism. We just need to simply pass the WebGL texture from one target
to the other, and use it like any other texture.

This provides SourceSurfaceWebgl to store and pass along that WebGL texture. It is largely
modeled off of SourceSurfaceSkia in terms of its copy-on-write behavior. There are three
noteworthy state changes that it must track from DrawTargetWebgl - when the framebuffer
contents is changing, when the framebuffer is being destroyed, and when any cached texture
handle separate from a framebuffer is also being destroyed. It will copy, orphan, or read
back data as appropriate to handle each case.

If it needs to be mapped, it just forces a read back of the data into a CPU surface that
can be mapped as requested.

Differential Revision: https://phabricator.services.mozilla.com/D138118
2022-02-11 15:36:30 +00:00
Jonathan Kew
a1c5d47ba6 Bug 1587094 - Create a pref to control whether we use DirectWrite's bold simulation or multi-strike synthetic bold; default to multi-strike for webfonts. r=lsalzman
This is designed to mitigate the problem of third-party fonts that render poorly
under DirectWrite's bold simulation, by using multi-strike synthetic bold (like
we use on macOS) instead.

The behavior is controlled by a pref, so that we can readily switch between
using DWrite's bold simulation for all fonts (pref=2, our current behavior);
using it only for installed fonts and falling back to multi-strike for webfonts
(pref=1, new behavior); or never using the DWrite simulation (pref=0).

Differential Revision: https://phabricator.services.mozilla.com/D137584
2022-02-09 12:07:05 +00:00
Butkovits Atila
c12a59323e Backed out changeset c885ece84961 (bug 1587094) for causing graphics crashes (bug 1754385). a=backout 2022-02-09 11:54:44 +02:00
Jonathan Kew
559f2ace9c Bug 1587094 - Create a pref to control whether we use DirectWrite's bold simulation or multi-strike synthetic bold; default to multi-strike for webfonts. r=lsalzman
This is designed to mitigate the problem of third-party fonts that render poorly
under DirectWrite's bold simulation, by using multi-strike synthetic bold (like
we use on macOS) instead.

The behavior is controlled by a pref, so that we can readily switch between
using DWrite's bold simulation for all fonts (pref=2, our current behavior);
using it only for installed fonts and falling back to multi-strike for webfonts
(pref=1, new behavior); or never using the DWrite simulation (pref=0).

Differential Revision: https://phabricator.services.mozilla.com/D137584
2022-02-08 14:40:02 +00:00
Norisz Fay
671b353782 Backed out changeset 49dc772ff0cd (bug 1587094) for causing multiple crashes CLOSED TREE 2022-02-08 05:30:51 +02:00
Jonathan Kew
aef8a0d1a8 Bug 1587094 - Create a pref to control whether we use DirectWrite's bold simulation or multi-strike synthetic bold; default to multi-strike for webfonts. r=lsalzman
This is designed to mitigate the problem of third-party fonts that render poorly
under DirectWrite's bold simulation, by using multi-strike synthetic bold (like
we use on macOS) instead.

The behavior is controlled by a pref, so that we can readily switch between
using DWrite's bold simulation for all fonts (pref=2, our current behavior);
using it only for installed fonts and falling back to multi-strike for webfonts
(pref=1, new behavior); or never using the DWrite simulation (pref=0).

Differential Revision: https://phabricator.services.mozilla.com/D137584
2022-02-07 20:54:52 +00:00
Jeff Muizelaar
909e38144b Bug 1753507 - Simplify the implementation of BaseRect::Scale(). r=gfx-reviewers,bradwerth
Rect::Scale(float, float):                      # @Rect::Scale(float, float)
        movss   xmm2, dword ptr [rdi]           # xmm2 = mem[0],zero,zero,zero
        movss   xmm3, dword ptr [rdi + 4]       # xmm3 = mem[0],zero,zero,zero
        movss   xmm4, dword ptr [rdi + 8]       # xmm4 = mem[0],zero,zero,zero
        addss   xmm4, xmm2
        mulss   xmm4, xmm0
        movss   xmm5, dword ptr [rdi + 12]      # xmm5 = mem[0],zero,zero,zero
        addss   xmm5, xmm3
        mulss   xmm5, xmm1
        mulss   xmm2, xmm0
        movss   dword ptr [rdi], xmm2
        mulss   xmm3, xmm1
        movss   dword ptr [rdi + 4], xmm3
        subss   xmm4, xmm2
        movss   dword ptr [rdi + 8], xmm4
        subss   xmm5, xmm3
        movss   dword ptr [rdi + 12], xmm5
        ret

vs

Rect::Scale(float, float):                     # @Rect::Scale(float, float)
        movups  xmm2, xmmword ptr [rdi]
        unpcklps        xmm0, xmm1                      # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
        movlhps xmm0, xmm0                      # xmm0 = xmm0[0,0]
        mulps   xmm0, xmm2
        movups  xmmword ptr [rdi], xmm0
        ret

Differential Revision: https://phabricator.services.mozilla.com/D137789
2022-02-03 20:34:41 +00:00
Marian-Vasile Laza
ddac1da17c Backed out changeset 12f866a5b267 (bug 1587094) for wrench bustages on synthetic-bold.yaml . CLOSED TREE 2022-02-03 22:23:07 +02:00
Steven Michaud
4c3344cc89 Bug 1719215 - Constrain clipping in CreateSubImageForData(). r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D137777
2022-02-03 18:54:01 +00:00
Lee Salzman
36c0803568 Bug 1587094 - Support MULTISTRIKE_BOLD font instance flag for WebRender. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D137725
2022-02-03 18:53:13 +00:00
Andrew Osmond
47af38389f Bug 1751205 - Part 1. Add Swizzle/PremultiplyYFlipData helper methods. r=gfx-reviewers,lsalzman,jgilbert
These new methods do both swizzle/premultiply and a Y-flip operation.

Differential Revision: https://phabricator.services.mozilla.com/D136503
2022-02-01 13:20:49 +00:00
Norisz Fay
beb556025c Backed out 2 changesets (bug 1751205) for causing multiple wpt failures on offscreencanvas.resize.html CLOSED TREE
Backed out changeset 70e5f13d08cc (bug 1751205)
Backed out changeset e97271d90795 (bug 1751205)
2022-01-28 09:14:15 +02:00
Andrew Osmond
bcb62d5adb Bug 1751205 - Part 1. Add Swizzle/PremultiplyYFlipData helper methods. r=gfx-reviewers,lsalzman,jgilbert
These new methods do both swizzle/premultiply and a Y-flip operation.

Differential Revision: https://phabricator.services.mozilla.com/D136503
2022-01-28 05:16:02 +00:00
Butkovits Atila
c26eab5ff1 Backed out 2 changesets (bug 1751205) for causing failures at webgl-color-offscreen-test.html. CLOSED TREE
Backed out changeset 211ffc98eb32 (bug 1751205)
Backed out changeset 2a1e5a439a3b (bug 1751205)
2022-01-28 03:11:14 +02:00
Andrew Osmond
0ed592a2fc Bug 1751205 - Part 1. Add Swizzle/PremultiplyYFlipData helper methods. r=gfx-reviewers,lsalzman,jgilbert
These new methods do both swizzle/premultiply and a Y-flip operation.

Differential Revision: https://phabricator.services.mozilla.com/D136503
2022-01-27 15:17:43 +00:00
Lee Salzman
f581a9af28 Bug 1745556 - Add support for stroked paths to path cache. r=gfx-reviewers,aosmond
Differential Revision: https://phabricator.services.mozilla.com/D135902
2022-01-14 17:30:22 +00:00
Lee Salzman
306b7d9a6b Bug 1745556 - Cache paths to textures to avoid falling back to Skia. r=gfx-reviewers,aosmond
This generalizes the CacheEntry infrastructure to implement path caching.
This allows us to cache recently drawn paths to a texture which can be then
drawn without falling back to Skia.

Paths using simple solid color patterns will be drawn as alpha masks that
can then have the color applied in the shader. For now, other pattern types
have the pattern baked into the texture to avoid having to complicate the
shader setup for now. In the future, other pattern types could be supported
with new shaders to allow those to be cached as alpha masks as well.

In the service of this, comparison and cloning operators were added to the
Pattern classes to make remembering and matching against them easier for
cache entries.

Differential Revision: https://phabricator.services.mozilla.com/D135261
2022-01-14 17:30:21 +00:00
Lee Salzman
87c39a41e6 Bug 1745556 - Support layering of Skia and WebGL contexts in accelerated canvas. r=gfx-reviewers,aosmond
Reading back from the WebGL context to the Skia context if we need to fall back
software rasterization can be extremely expensive. In general, it is better to
try to avoid this by rasterizing primitives in software and then uploading them
to a texture.

This generalizes that idea so that when using the default source-over blend
mode, the Skia context can function as a layer that accumulates recently
drawn primitives and blends them via source-over to the WebGL context when
a flush is necessary.

Differential Revision: https://phabricator.services.mozilla.com/D135260
2022-01-14 17:30:21 +00:00