Commit Graph

222 Commits

Author SHA1 Message Date
Alex Franchuk
da658fa4b2 Bug 1942129 pt4 - Convert old shmem call sites to use the new shmem classes r=ipc-reviewers,media-playback-reviewers,padenot,lsalzman,aosmond,nika
While much of this is simply converting code (and removing extraneous
`size` parameters), toolkit/xre/GeckoArgs.{h,cpp} has some significant
changes to support sending read-only handles (which is all we need!).

Differential Revision: https://phabricator.services.mozilla.com/D236750
2025-03-04 22:11:12 +00:00
Butkovits Atila
2406ce261c Backed out 8 changesets (bug 1942129) for causing bustages at SharedMemoryMapping.h. CLOSED TREE
Backed out changeset 8d9053f1c203 (bug 1942129)
Backed out changeset 393e3c507c27 (bug 1942129)
Backed out changeset 8240d353d224 (bug 1942129)
Backed out changeset 8c4cd026b720 (bug 1942129)
Backed out changeset 742634b0d6e9 (bug 1942129)
Backed out changeset d16857f9812f (bug 1942129)
Backed out changeset 7ff7af041ee7 (bug 1942129)
Backed out changeset ef41d9e4c7de (bug 1942129)
2025-03-04 00:43:23 +02:00
Alex Franchuk
f7ee08eef3 Bug 1942129 pt4 - Convert old shmem call sites to use the new shmem classes r=ipc-reviewers,media-playback-reviewers,padenot,lsalzman,aosmond,nika
While much of this is simply converting code (and removing extraneous
`size` parameters), toolkit/xre/GeckoArgs.{h,cpp} has some significant
changes to support sending read-only handles (which is all we need!).

Differential Revision: https://phabricator.services.mozilla.com/D236750
2025-03-03 19:53:20 +00:00
Lee Salzman
06d7f87f70 Bug 1950085 - Ensure DrawTargetWebgl::DrawSurface clips drawing to surface bounds. r=aosmond
For offset surfaces, the source rect to DrawSurface may not actually be entirely filled by
the surface's contents. In this case, we need to clip the source and dest rects to reflect
the actual surface content bounds.

This required some collateral modifications to make using offset surfaces safe in a few other
places in DrawTargets in general.

Differential Revision: https://phabricator.services.mozilla.com/D239993
2025-02-28 18:20:19 +00:00
Lee Salzman
ac4355bb7d Bug 1947668 - Avoid filling path cache with failed entries. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D239497
2025-02-25 14:58:03 +00:00
Lee Salzman
131d5d7515 Bug 1945997 - Avoid duplicate memory reports in DrawTargetWebgl. r=aosmond
ResetPathVertexBuffer could accidentally report memory more than once.

Differential Revision: https://phabricator.services.mozilla.com/D239479
2025-02-25 14:56:43 +00:00
Lee Salzman
3b140c846e Bug 1950085 - Handle offset surfaces in DrawTargetWebgl::DrawSurface. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D239393
2025-02-25 14:54:53 +00:00
Lee Salzman
cfa5958fa8 Bug 1926970 - Add memory reporter for Accelerated Canvas2D. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D236493
2025-02-03 16:15:07 +00:00
Lee Salzman
f389de744d Bug 1937751 - Remember AAStroke mode when caching stroked path. r=jrmuizel
Differential Revision: https://phabricator.services.mozilla.com/D232781
2024-12-21 10:42:28 +00:00
Lee Salzman
5da26a7bf5 Bug 1937929 - Avoid applying path transform to stroke options. r=ahale
When drawing arcs or similar constructs that may have a path transform to implement
scaling, this scaling may inadvertently alter stroke options such as line width or
dashes. We need to ensure that we don't apply this scaling from the path transform
to stroke options.

Differential Revision: https://phabricator.services.mozilla.com/D232579
2024-12-19 09:01:43 +00:00
Lee Salzman
5cb98c47fa Bug 1935759 - Work around Intel driver bug when binding clip mask. r=tnikkel
The Windows Intel D3D driver does not seem to be recognizing that the clip mask
texture's data has changed unless the texture binding is re-latched. This causes
clipping to seemingly use an old version of the clip mask's contents.

To work around this bug, the clip mask is instead built on texture unit 0, and
then only bound on texture unit 1 after it is modified, so that the binding is
only re-latched on texture unit 1 after modification.

Differential Revision: https://phabricator.services.mozilla.com/D232184
2024-12-16 11:10:45 +00:00
Lee Salzman
2333e25924 Bug 1927053 - Optimize GlyphCache lookups. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D231512
2024-12-09 19:18:51 +00:00
Lee Salzman
4af1b33330 Bug 1933668 - Undo half-pixel shift from WGR when using AA-Stroke. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D231471
2024-12-07 19:32:02 +00:00
Lee Salzman
74b950eaf9 Bug 1625606 - Use Skia's mac font smoothing handling. r=aosmond
Currently we try to alternate between light-on-dark and dark-on-light
text rendering masks on macOS depending on text colors. Historically,
this matched earlier versions of macOS reasonably well. In successive
versions of macOS, however, this approximation appears to have broken
down and no longer gives correct results.

Given that recent macOS versions no longer promotes font-smoothing at
all, it seems more reasonable to match Skia's font smoothing handling
because it appears to better work with these more recent versions while
requiring us to have less special code to do so.

Differential Revision: https://phabricator.services.mozilla.com/D229444
2024-11-19 18:38:48 +00:00
Adi
4e76298914 Backed out changeset 77fb278f9d8f (bug 1625606) for causing reftest failures @ext-subpixel-1.html. CLOSED TREE 2024-11-19 10:52:40 +02:00
Lee Salzman
5a9f9eb681 Bug 1625606 - Use Skia's mac font smoothing handling. r=aosmond
Currently we try to alternate between light-on-dark and dark-on-light
text rendering masks on macOS depending on text colors. Historically,
this matched earlier versions of macOS reasonably well. In successive
versions of macOS, however, this approximation appears to have broken
down and no longer gives correct results.

Given that recent macOS versions no longer promotes font-smoothing at
all, it seems more reasonable to match Skia's font smoothing handling
because it appears to better work with these more recent versions while
requiring us to have less special code to do so.

Differential Revision: https://phabricator.services.mozilla.com/D229444
2024-11-19 07:37:51 +00:00
Lee Salzman
37de68c7c2 Bug 1926668 - Support ExtendMode::REPEAT in DrawTargetWebgl. r=aosmond
If, by default, all DrawTargetWebgl textures are created with ExtendMode::REPEAT,
then we can support a hardware-accelerated repeat mode for free with no shader
alterations.

The shader already implements clamp to edge behavior manually to support texture
atlasing, so to allow textures to repeat, we just have to force them to be a
standalone texture and set the clamping to wider bounds to not interfere with
the hardware repeat.

Differential Revision: https://phabricator.services.mozilla.com/D226703
2024-10-24 04:58:56 +00:00
Lee Salzman
647e6b04ae Bug 1925845 - Check if path falls inside precision limits. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D226254
2024-10-20 22:58:55 +00:00
Lee Salzman
1ce0188f37 Bug 1920580 - Detect WebGL context loss and notify Canvas2D of reset. r=aosmond
When AC2D fails to fall back to a software canvas due to not having a cached
surface available, we need to notify the canvas with an event so that it can
respond appropriately. This uses the newly added plumbing to do route this.

Differential Revision: https://phabricator.services.mozilla.com/D225702
2024-10-16 03:25:02 +00:00
Lee Salzman
da0b813101 Bug 1920753 - Work around buggy ANGLE/D3D drivers that may copy blocks of pixels outside the row length. r=aosmond
This attempts to allocate shared texture handles with reserved space at the end of each row in case
pixels get uploaded outside of the row length. This does not seem to affect standalone textures.

Differential Revision: https://phabricator.services.mozilla.com/D224883
2024-10-11 04:37:02 +00:00
Lee Salzman
03f82efda3 Bug 1910480 - Use preblending in DrawTargetWebgl for grayscale AA on Windows. r=aosmond
Gamma-aware ClearType rendering is used on Windows even when requesting
grayscale AA, as we still sample the approximate luminance of the ClearType
result to generate the grayscale result. To compensate for this, we have to
use preblending for grayscale AA, even when no subpixel AA is requested.

Differential Revision: https://phabricator.services.mozilla.com/D222229
2024-09-16 02:50:42 +00:00
Lee Salzman
f1264796a3 Bug 1916907 - Support linear gradients in DrawTargetWebgl. r=aosmond
This attempts to map linear gradient to 1D textures of sufficient resolution
for a given rendered primitive. The 1D texture can then be rendered using
the image shader, without having to add any specialized gradient shaders.

The 1D ramp textures are much smaller than uploading a texture for an entire
fallback primitive, which becomes a significant performance benefit in the
case of primitives that take up a large area on screen.

In the future it might be possible to cache these ramp textures, but for now
they remain uncached.

Differential Revision: https://phabricator.services.mozilla.com/D221107
2024-09-05 17:24:16 +00:00
Lee Salzman
886cebc855 Bug 1913869 - Fix preblend quantization color. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D219833
2024-08-22 13:55:26 +00:00
Lee Salzman
dc1f974be2 Bug 1910815 - Inflate glyph bounds to account for potential font hinting. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D219403
2024-08-18 23:17:52 +00:00
Lee Salzman
7dd3bbda13 Bug 1910869 - Support preblending in DrawTargetWebgl's glyph caching. r=aosmond
Even though glyph masks are stored without any baked-in color, the blending weights
they represent are preblended so as to be gamma-aware on macOS and Windows. That means
the color requested for the glyph alters the mask itself. It is not sufficient to
store a single mask that can be used for any color, rather, there must be different
masks stored for each potential preblend ramp that is generated by Skia.

Skia uses a quantization scheme where only the high bits of the color are used to
generate the preblend ramp so as to minimize the number of tables generated, so we do
our best to mimic that scheme and avoid generating an excessive number of masks. This
allows reuse of masks for some subset of colors, albeit not every color.

However, coaxing Skia into generating preblended masks without baking in the final
rasterized color requires some subversive use of SkShader to alter the queried luminance
color without changing the actual color of an SkPaint. An alternative invasive approach
would be to modify Skia to support this via a flag in SkPaint directly, but that would
require patching Skia directly, which might be necessary in the future should SkShader
become deprecated.

Differential Revision: https://phabricator.services.mozilla.com/D219242
2024-08-15 22:50:24 +00:00
Butkovits Atila
994dddfcd9 Backed out changeset 0ac3aa2e9c97 (bug 1910869) for causing failures at 2d.text.draw.generic.family.w.html. CLOSED TREE 2024-08-15 21:23:02 +03:00
Lee Salzman
76276d0240 Bug 1910869 - Support preblending in DrawTargetWebgl's glyph caching. r=aosmond
Even though glyph masks are stored without any baked-in color, the blending weights
they represent are preblended so as to be gamma-aware on macOS and Windows. That means
the color requested for the glyph alters the mask itself. It is not sufficient to
store a single mask that can be used for any color, rather, there must be different
masks stored for each potential preblend ramp that is generated by Skia.

Skia uses a quantization scheme where only the high bits of the color are used to
generate the preblend ramp so as to minimize the number of tables generated, so we do
our best to mimic that scheme and avoid generating an excessive number of masks. This
allows reuse of masks for some subset of colors, albeit not every color.

However, coaxing Skia into generating preblended masks without baking in the final
rasterized color requires some subversive use of SkShader to alter the queried luminance
color without changing the actual color of an SkPaint. An alternative invasive approach
would be to modify Skia to support this via a flag in SkPaint directly, but that would
require patching Skia directly, which might be necessary in the future should SkShader
become deprecated.

Differential Revision: https://phabricator.services.mozilla.com/D219242
2024-08-15 13:25:00 +00:00
Lee Salzman
7aa69f750f Bug 1909718 - Guard against lossy PathSkia::AsRect conversions. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D218912
2024-08-09 15:31:07 +00:00
Alex Franchuk
5a5e8a0b1c Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D217487
2024-08-06 18:16:08 +00:00
Noemi Erli
4a933a7f06 Backed out changeset e5864b976c3b (bug 1454819) for causing build bustages in SharedMemory.cpp CLOSED TREE 2024-08-05 18:08:32 +03:00
Alex Franchuk
e7d059af48 Bug 1454819 - Simplify SharedMemory classes r=ipc-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D217487
2024-08-05 13:01:33 +00:00
Lee Salzman
fe964196f2 Bug 1911019 - Use different anti-aliasing approximation for subpixel rectangles. r=aosmond
The previous attempt at refining the subpixel anti-aliasing approximation modified the
distance-to-edge tracking, which can cause the AA to approach zero too soon.

This fixes this by reverting the distance-to-edge tracking back to the way it was, but
instead limiting the alpha to the area of the subpixel rectangle if necessary.

Differential Revision: https://phabricator.services.mozilla.com/D218493
2024-08-04 17:16:32 +00:00
Lee Salzman
a1ed40adc4 Bug 1911231 - Clip fill/clear ops to viewport when possible. r=aosmond
We can avoid falling back to Skia on certain fill/clear ops so long as
the transform produces axis-aligned rectangles. In that case, we can
do a precise clip of the transformed rect to the viewport, which can
then be accelerated without any risk of fallback.

Differential Revision: https://phabricator.services.mozilla.com/D218472
2024-08-03 18:57:01 +00:00
Lee Salzman
330b9e83d5 Bug 1874314 - Better anti-aliasing for subpixel rectangles. r=aosmond
The existing distance-to-edge AA scheme breaks down somewhat when rectangles
have subpixel areas. We need to bias the AA to account for this situation when
the scales get to these subpixel sizes.

Differential Revision: https://phabricator.services.mozilla.com/D215095
2024-06-28 00:42:56 +00:00
Lee Salzman
97b63bb9d4 Bug 1902718 - Use Etagere for DrawTargetWebgl allocation. r=nical
The existing custom TexturePacker can have some worst case behavior
when it is filled with a lot of allocated textures. Allocation
can become deeply recursive, causing allocator performance to hit
a performance cliff.

Using Etagere instead should remove this potential performance
issue while simplifying the code of DrawTargetWebgl.

Differential Revision: https://phabricator.services.mozilla.com/D213812
2024-06-25 14:16:23 +00:00
Lee Salzman
c328b18386 Bug 1888338 - Use a single SharedContextWebgl. r=aosmond
This shares a global SharedContextWebgl among all instances of CanvasTranslator.
The goal is that regardless of how many windows are open, we only have to pay the
startup costs and shader compilation times for SharedContextWebgl once. In the
event that all CanvasTranslators are gone, the SharedContextWebgl is kept around
while its internal caches and textures are discarded to avoid significant memory
usage when no canvases are in use, while at the same time saving on startup
costs the next time a first live CanvasTranslator is created.

Differential Revision: https://phabricator.services.mozilla.com/D205977
2024-03-28 17:33:58 +00:00
Brad Werth
fab597c0fd Bug 1764201 Part 3: Remove screen info stuff from gfxPlatform. r=jgilbert,geckoview-reviewers
The gfxPlatform::GetScreen* methods have always been redundant. Removing
them in favor of ScreenManager or nsDeviceContext methods will
discourage future code authors from adding more redundancy in
gfxPlatform.

Differential Revision: https://phabricator.services.mozilla.com/D203672
2024-03-22 00:55:48 +00:00
Sandor Molnar
938c7c0e0d Backed out 3 changesets (bug 1764201) for causing multiple failures, including build bustages @ widget/windows/ScreenHelperWin.cpp CLOSED TREE
Backed out changeset ea6921c88429 (bug 1764201)
Backed out changeset ff751c2ce8ef (bug 1764201)
Backed out changeset 2d21d14a2df3 (bug 1764201)
2024-03-19 17:12:40 +02:00
Brad Werth
27feaefa61 Bug 1764201 Part 3: Remove screen info stuff from gfxPlatform. r=jgilbert,geckoview-reviewers
The gfxPlatform::GetScreen* methods have always been redundant. Removing
them in favor of ScreenManager or nsDeviceContext methods will
discourage future code authors from adding more redundancy in
gfxPlatform.

Differential Revision: https://phabricator.services.mozilla.com/D203672
2024-03-19 13:52:32 +00:00
unknown
6b54094ea8 Bug 1885028 - PlainOldDataSerializer use removed from dom/canvas. r=gfx-reviewers,lsalzman,ahale
Differential Revision: https://phabricator.services.mozilla.com/D204432
2024-03-14 00:21:23 +00:00
Kelsey Gilbert
8ef95f8d10 Bug 1878930 - s/RawBuffer/Span/: TexImage: Use span, fix dtwebgl callers. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D202027
2024-02-29 00:37:30 +00:00
Lee Salzman
182948cbc7 Bug 1881194 - Send TexTypeForWebgl from CanvasChild to CanvasTranslator. r=sotaro
ImageBridgeChild::GetSingleton returns null in the GPU process. This causes
DrawTargetWebgl::CopyToSwapChain to use an incorrect texture type for WebGL
canvases when in the GPU process. To work around this, determine the texture
type for WebGL in the content process and send it to CanvasTranslator for
later usage.

Differential Revision: https://phabricator.services.mozilla.com/D202292
2024-02-22 04:28:44 +00:00
Sandor Molnar
d9c4b21b0d Backed out 7 changesets (bug 1878930) for causing build bustages @ dom/canvas/WebGLTypes.h CLOSED TREE
Backed out changeset 631db0feebb4 (bug 1878930)
Backed out changeset 72ab4dbbf8ed (bug 1878930)
Backed out changeset e5119acd8c8f (bug 1878930)
Backed out changeset 3cd4b2423281 (bug 1878930)
Backed out changeset 4a5512ff4424 (bug 1878930)
Backed out changeset 6f5c64075e31 (bug 1878930)
Backed out changeset fb3b3487a529 (bug 1878930)
2024-02-20 21:25:02 +02:00
Kelsey Gilbert
15143f68a7 Bug 1878930 - s/RawBuffer/Span/: TexImage: Use span, fix dtwebgl callers. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D202027
2024-02-20 17:59:08 +00:00
Lee Salzman
4eba56247d Bug 1880523 - Use aa_stroke_filled_circle in DrawTargetWebgl. r=jrmuizel
WGR is fairly slow at generating specialized circle geometry, whereas we can
generate similar geometry much faster using the AAStroke filled circle
implementation now.

Differential Revision: https://phabricator.services.mozilla.com/D201939
2024-02-15 17:33:15 +00:00
Lee Salzman
0d28396655 Bug 1879178 - Add UninitializedBufferData_SizeOnly for unitialized orphaning of WebGL buffers. r=jgilbert
Currently BufferData when supplied null data, a pattern explicitly recommended in OpenGL for orphaning
buffer before they are subsequently filled with BufferSubData, currently causes zero data to be calloc'd
and uploaded to the buffer, which can be expensive.

In trusted code that only directly accesses WebGLContext, we can add an UninitializedBufferData_SizeOnly
call that can be used for this initialization, with the understanding that subsequent BufferSubData calls
will fill in relevant sections of the buffer before they are ever used.

Differential Revision: https://phabricator.services.mozilla.com/D201176
2024-02-08 23:36:56 +00:00
Lee Salzman
3c808bc246 Bug 1876506 - Check for CopyToSwapChain failure. r=aosmond
CopyToSwapChain was silently failing, causing no texture to get pushed
to RemoteTextureMap, so that when a wait on it was occurring, it would
timeout.

The failure occurred in DrawTargetWebgl::FlushFromSkia, because the
DT's size actually exceeded the value of the texture limit pref when
it was attempting to allocate a temporary texture to blend back a
Skia layer to the WebGL framebuffer. This is fixed by allowing layering
to bypass this limit, as it is always expected that layer blending
succeed.

To guard against future instances of this bug, CopyToSwapChain now returns
a boolean result so that it is fallible and can signal to CanvasTranslator
that it needs to take appropriate fallback measures on failure.

Differential Revision: https://phabricator.services.mozilla.com/D199794
2024-01-27 15:56:04 +00:00
Lee Salzman
b004c2628c Bug 1875221 - Avoid double clear in DrawStrokeMask. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D199692
2024-01-26 19:47:26 +00:00
Lee Salzman
024e0d9915 Bug 1875222 - Implement RecordedSetPermitSubpixelAA. r=aosmond
Certain users of DrawTargetRecording need accurate tracking of SetPermitSubpixelAA.
This ensures the values are properly tracked locally in DrawTargetRecording as well
as forwards any necessary changes to the remote end.

Differential Revision: https://phabricator.services.mozilla.com/D198919
2024-01-18 17:16:08 +00:00
Lee Salzman
2364029b02 Bug 1874534 - Fix DrawTargetWebgl and RemoteTextureMap context loss handling. r=aosmond
When a context loss occurs on DrawTargetWebgl, this may result in a fallback TextureData
being created. Each of these are currently managed by two different RemoteTextureOwnerClients.
This is not really safe at all.

To fix this, CopyToSwapChain is modified so that it can be supplied a RemoteTextureOwnerClient.
Then CanvasTranslator can inject its own RemoteTextureOwnerClient into CopyToSwapChain, rather
than letting CopyToSwapChain use its own separate internal RemoteTextureOwnerClient.

This also tries to address a few other data consistency bugs with the fallback TextureData.

Differential Revision: https://phabricator.services.mozilla.com/D198487
2024-01-13 18:19:24 +00:00