Граф коммитов

3664 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Kew 12816161da Bug 1110580 - patch 1 - Accelerate canvas2d.fillText for simple unidirectional strings by reusing the same textrun to draw as we created to measure the text. r=lsalzman
In general, the canvas text-drawing code makes two passes over the string, one to measure it and the second to draw.
Each time, it has to find individual direction runs and create a separate gfxTextRun for each.
However, in the (common) case of a simple unidirectional string, we're only going to have a single run,
so it's wasteful to construct it twice; the CanvasBidiProcessor can just re-use the run from the measurement
pass when it needs to draw.

In particular, this will apply to pdf.js drawing, where each glyph is handled in a separate fillText call.
Many other uses of canvas text should also benefit somewhat.

Differential Revision: https://phabricator.services.mozilla.com/D145426
2022-05-05 08:14:11 +00:00
Jonathan Kew c94c08270b Bug 1759686 - patch 5 - Adapt canvas2d text methods to allow use from worker threads without a Document or PresShell. r=aosmond
This enables an offscreen-canvas Worker to do text rendering, but only with system-installed fonts
because we don't yet have a FontFaceSet available in the Worker. (That's bug 1758946.)

Differential Revision: https://phabricator.services.mozilla.com/D144188
2022-05-04 17:13:16 +00:00
Jonathan Kew 0cf6fb1bdd Bug 1759686 - patch 3 - Ensure prefs that may be accessed by canvas2d text code are atomic. r=lsalzman
These need to be atomic so that they can be accessed by canvas code when running on a worker thread
without calling main-thread-only Preferences APIs.

Depends on D144185

Differential Revision: https://phabricator.services.mozilla.com/D144186
2022-05-03 12:39:09 +00:00
Jonathan Kew 723077462f Bug 1759686 - patch 2 - Remove redundant null-checks in CanvasRenderingContext2D, as GetPresShell() will check these members. r=lsalzman
We don't need to null-check the mCanvasElement and mDocShell members in these methods,
and bail out if neither is provided, because in that case the following GetPresShell() call
will return null and we'll bail out there anyhow.

Removing these extra checks will simplify the changes involved in enabling the canvas code
to be used in a Worker context, where it is not connected to a document.

Depends on D144184

Differential Revision: https://phabricator.services.mozilla.com/D144185
2022-05-03 12:39:08 +00:00
Jonathan Kew 6209edec06 Bug 1759686 - patch 1 - Remove unused mPresContext member from CanvasRenderingContext2D. r=lsalzman
Nothing uses this member, so remove it to make it clear we don't need to provide it
when setting up a CanvasRenderingContext2D.

Differential Revision: https://phabricator.services.mozilla.com/D144184
2022-05-03 12:39:08 +00:00
Kelsey Gilbert edaf0ffd31 Bug 1703654 - Deal with Maybe<> not trivially_copyable on build-linux64-base-toolchains. r=gfx-reviewers,lsalzman
Start moving away from manual (risky!) IsTriviallySerializable<>.

Differential Revision: https://phabricator.services.mozilla.com/D145252
2022-05-02 23:54:10 +00:00
Kelsey Gilbert e722cdd3ed Bug 1703654 - Prototype display-p3 for WebGL canvas. r=lsalzman,emilio,webidl,smaug
Enable (direct) external surface compositing for MacIOSurfaces.
Works on Mac.

Differential Revision: https://phabricator.services.mozilla.com/D144073
2022-05-02 23:54:09 +00:00
Dan Robertson 47b6f96706 Bug 1676299 Part 4: Modify BaseMatrix::ScaleFactors() to return a ScaleFactors2D. r=botond
This changes BaseMatrix::ScaleFactors() to return a ScaleFactors2D instead of
a SizeTyped.

Depends on D145041

Differential Revision: https://phabricator.services.mozilla.com/D144666
2022-04-30 01:35:24 +00:00
Csoregi Natalia 9a8af5a95a Backed out changeset 718ead395698 (bug 1703654) for causing bustage on IPCMessageUtils.h. CLOSED TREE 2022-04-29 00:38:28 +03:00
Kelsey Gilbert c3a7e39783 Bug 1703654 - Prototype display-p3 for WebGL canvas. r=lsalzman,emilio
Enable (direct) external surface compositing for MacIOSurfaces.
Works on Mac.

Differential Revision: https://phabricator.services.mozilla.com/D144073
2022-04-28 19:12:08 +00:00
Jonathan Kew dbecbdfdfe Bug 1766356 - Replace the specified font-size with the computed value when serializing the canvas2d font attribute. r=hiro
This requires updating a couple of our old dom/canvas mochitests that assume the size element
of the font attribute will be serialized as specified, which conflicts with the current spec
requirement.

On the other hand, this also resolves a few current WPT test failures that are specifically
testing the behavior described in the spec (e.g. a size specified as percentage gets serialized
as the computed px value).

Differential Revision: https://phabricator.services.mozilla.com/D144812
2022-04-28 08:50:12 +00:00
Mike Hommey e317b0e119 Bug 1766375 - Disable implicit-fallthrough warnings in Windows builds like other platforms. r=firefox-build-system-reviewers,andi
Also disable it for Windows-specific third-party code.

Differential Revision: https://phabricator.services.mozilla.com/D144667
2022-04-27 22:12:53 +00:00
Lee Salzman ca716f7083 Bug 1765911 - Support cloning Patterns with internal weak references. r=aosmond
Currently calling Pattern::Clone() produces a heap-allocated Pattern with RefPtrs
to any internal resources such as SourceSurfaces or GradientStops. While this is
okay if the Pattern is transient, this causes problems if the clone is long-lived
and causes via the RefPtr the stored resource to stay alive, even when there are
no other external references to the resource.

In the case of DrawTargetWebgl's PathCache, we need to be able to create Pattern
clones that have internal weak references, while also still supporting the original
use-case of strong references. To this end we template-ize some of the Pattern
derivatives so that we can make either strong or weak versions according to use-case.
This case way we store a weak clone of a Pattern in the PathCache key, the reference
will automatically invalidate itself when all other external strong references to it
go away, without having to do external crawling of the PathCache to constantly prune
the last reference manually.

Differential Revision: https://phabricator.services.mozilla.com/D144381
2022-04-27 18:48:59 +00:00
Kagami Sascha Rosylight 73f6c1e217 Bug 1619574 - Remove HTMLCanvasElement::MozGetAsFile r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D144815
2022-04-27 16:13:14 +00:00
Andrew Osmond ddc415daba Bug 1755704 - Part 1. Add support for reading back the front buffer for WebGPU. r=gfx-reviewers,lsalzman
This reworks the CanvasManagerChild::GetSnapshot method to work with
WebGPU. This will allow it to be called for a WebGPU context from any
thread, which is useful for screenshots.

Differential Revision: https://phabricator.services.mozilla.com/D144308
2022-04-27 16:05:28 +00:00
Molnar Sandor 68045e3d85 Backed out changeset 071aa43a0419 (bug 1703654) for causing build bustages in SharedSurfaceDMABUF. CLOSED TREE 2022-04-26 20:14:48 +03:00
Kelsey Gilbert 9f7815a9e2 Bug 1703654 - Prototype display-p3 for WebGL canvas. r=lsalzman,emilio
Enable (direct) external surface compositing for MacIOSurfaces.
Works on Mac.

Differential Revision: https://phabricator.services.mozilla.com/D144073
2022-04-26 16:54:17 +00:00
Csoregi Natalia 8f3654680c Backed out 3 changesets (bug 1755704, bug 1765816) for causing reftest failures on webgl-color-test.html
Backed out changeset 2f074e2385d4 (bug 1765816)
Backed out changeset cd0b9e084bcd (bug 1755704)
Backed out changeset 39a846e43162 (bug 1755704)
2022-04-24 02:33:33 +03:00
Andrew Osmond 265e005ae0 Bug 1765816 - Expose front buffer canvas contents when painting for Firefox Screenshots. r=gfx-reviewers,lsalzman
This patch adds support for including the canvas contents in Firefox
Screenshots for Canvas 2D, WebGL and WebGPU. It is already working for
context's created through an OffscreenCanvas, but we failed to hook up
the main thread path after refactoring in previous bugs.

Differential Revision: https://phabricator.services.mozilla.com/D144310
2022-04-23 16:45:10 +00:00
Andrew Osmond 382feb7053 Bug 1755704 - Part 1. Add support for reading back the front buffer for WebGPU. r=gfx-reviewers,lsalzman
This reworks the CanvasManagerChild::GetSnapshot method to work with
WebGPU. This will allow it to be called for a WebGPU context from any
thread, which is useful for screenshots.

Differential Revision: https://phabricator.services.mozilla.com/D144308
2022-04-23 16:45:10 +00:00
Butkovits Atila 6b6840fbbf Backed out changeset 0d23532d6a49 (bug 1757802) as requested by dev. CLOSED TREE 2022-04-22 23:20:08 +03:00
Molnar Sandor 86256102b3 Backed out 3 changesets (bug 1765816, bug 1755704) for causing bp hybrid bustages. CLOSED TREE
Backed out changeset 505897037daf (bug 1765816)
Backed out changeset bc4e2999a2a7 (bug 1755704)
Backed out changeset 26b11a2833b0 (bug 1755704)
2022-04-22 18:03:57 +03:00
Andrew Osmond f1d0511ef0 Bug 1765816 - Expose front buffer canvas contents when painting for Firefox Screenshots. r=gfx-reviewers,lsalzman
This patch adds support for including the canvas contents in Firefox
Screenshots for Canvas 2D, WebGL and WebGPU. It is already working for
context's created through an OffscreenCanvas, but we failed to hook up
the main thread path after refactoring in previous bugs.

Differential Revision: https://phabricator.services.mozilla.com/D144310
2022-04-22 15:05:43 +00:00
Andrew Osmond 720de7a009 Bug 1755704 - Part 1. Add support for reading back the front buffer for WebGPU. r=gfx-reviewers,lsalzman
This reworks the CanvasManagerChild::GetSnapshot method to work with
WebGPU. This will allow it to be called for a WebGPU context from any
thread, which is useful for screenshots.

Differential Revision: https://phabricator.services.mozilla.com/D144308
2022-04-22 15:05:42 +00:00
Lee Salzman cc5a1729f6 Bug 1765162 - Fix leak in GlyphCacheEntry. r=aosmond
GlyphBuffer was getting allocated but never destroyed.
This adds a destructor that fixes that.

Differential Revision: https://phabricator.services.mozilla.com/D143917
2022-04-21 17:59:45 +00:00
Andrew Osmond a455c7329e Bug 1765323 - Enable paint callbacks for OffscreenCanvas and Canvas 2D. r=gfx-reviewers,lsalzman
Canvas 2D needs paint callbacks from the OffscreenCanvas display
pipeline so that it knows when to reinvalidate. They were disabled which
meant only the first frame was rendered.

Differential Revision: https://phabricator.services.mozilla.com/D144006
2022-04-19 17:55:32 +00:00
Kelsey Gilbert 1af7414e22 Bug 1765195 - Remove unused ICRData. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D143935
2022-04-18 20:16:09 +00:00
Nika Layzell 5e08e6891a Bug 1757802 - Don't keep alive Shmem shared memory regions on IProtocol, r=ipc-reviewers,jld
With this new approach, Shmem instances will now have their handles
transferred inline within messages as attachments, rather than being
associated with their actors and sent in separate messages.

This has a few advantages:

* The implementation is much simpler
* Releasing all references to a Shmem will automatically destroy it by
  RAII, rather than leaking the shared memory region until the toplevel
  actor is destroyed, removing the need for types like RaiiShmem.
* This allows re-transmitting Shmem instances to another process, as we
  don't close the shared memory region handle upon receiving it.

But also has a disadvantage that because we keep alive the shared memory
region's handle until the shmem is destroyed, so that it can be
re-transmitted, we may end up using more FDs or HANDLEs while running.

This patch intentionally doesn't change or simplify callsites, removing
APIs like RaiiShmem, in order to make it easier to revert if this causes
issues on platforms like Linux due to FD exhaustion. If we don't run
into increased resource exhaustion problems, we can make these changes
in a follow-up.

Differential Revision: https://phabricator.services.mozilla.com/D140211
2022-04-18 19:26:15 +00:00
Lee Salzman 346a0b42b9 Bug 1764948 - Implement anti-aliasing for DrawTargetWebgl. r=gfx-reviewers,nical
This provides basic distange-to-edge anti-aliasing for accelerated rectangle
drawing in DrawTargetWebgl. It tracks the distance to each edge in screen space
for each edge of the rectangle. These distances are passed down to the fragment
shader in an interpolant and then the smallest one is selected from them to
represent the final opacity of the pixel. We also need to extrude the rectangle
outward by a pixel to account for the AA region.

This is based off WebRender's AA strategy as outlined in bug 1764364.

Differential Revision: https://phabricator.services.mozilla.com/D143832
2022-04-16 03:50:26 +00:00
Razvan Cojocaru cad800beb9 Bug 1759844 - WebGLContextDraw.cpp: use .empty() instead of .size(). r=andi
Use !intersection.empty() instead of bool(intersection.size()) to
check if the container is empty.

Differential Revision: https://phabricator.services.mozilla.com/D143314
2022-04-11 11:30:17 +00:00
Calixte d49143cc92 Bug 1763424 - Limit ImageData typed array to 2Gb when created using its constructor r=edgar
- it's likely an oblivion from the fix for bug 1716622;
 - so just add a check on the final length of the buffer to be under the limit of 2Gb.

Differential Revision: https://phabricator.services.mozilla.com/D143066
2022-04-07 19:46:47 +00:00
Calixte 81f305e033 Bug 1763330 - Ship OffscreenCanvas for pdf.js r=aosmond,gfx-reviewers
- It'll helpful to generate some ImageBitmap in the worker instead passing some
  Uint8Clamped array from the worker to the main thread.
- Hence it will reduce memory footprint and improve performance in pdf.js.

Differential Revision: https://phabricator.services.mozilla.com/D143019
2022-04-06 18:35:04 +00:00
Jonathan Kew b50d715cc5 Bug 1728999 - Implement the CanvasRenderingContext2D.direction property. r=lsalzman,emilio
Differential Revision: https://phabricator.services.mozilla.com/D142701
2022-04-05 12:44:42 +00:00
Andrew Osmond 3fe3f7ca98 Bug 1753302 - Part 1. Integrate WebGPU with OffscreenCanvas plumbing. r=gfx-reviewers,jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D141491
2022-04-04 16:42:02 +00:00
Lee Salzman 244b3a114a Bug 1762523 - Add performance profiling to DrawTargetWebgl. r=aosmond,gfx-reviewers
This adds OnEvent hooks to DrawTargetWebgl for various events so that
profile counters may be maintained each frame. These profile counters
try to determine if a software fallback happened or an uncacheable event
occurs that requires either uploading data to the GPU or reading back
from the GPU, events which can cause substantial slowdown if they happen
repeatedly even without an explicit fallback to software rasterization.

When it is determined a threshold has been reached (as controlled by
some prefs), RequiresRefresh() in PersistentBufferProvider is used to
signal that we should recreate the PersistentBufferProvider of a different
type and thus disable acceleration.

Differential Revision: https://phabricator.services.mozilla.com/D142646
2022-04-04 15:50:48 +00:00
John Lin 0b6b47af6f Bug 1741244 - p6: wait for frame encoded in capture throttle test. r=jib
Initializing platform encoders often takes some time and the frame
rate measured is lower than actual number when the counting starts as
soon as connection established. Delaying the measurement until there
is at least some frame encoded makes it more accurate.

Differential Revision: https://phabricator.services.mozilla.com/D141513
2022-04-02 01:20:26 +00:00
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
Nika Layzell 7743d4fd62 Bug 1761536 - Part 2: Replace nsTArray::elem_type with value_type, r=mccr8
There weren't that many uses of the existing typedef, so it seemed like
it might be worthwhile to just replace all uses of the previous typedef
with the stl-like one.

Differential Revision: https://phabricator.services.mozilla.com/D142705
2022-04-01 17:00:25 +00:00
abhii-now 81f464c556 Bug 1759845 - used !foo.empty() instead of foo.size(). r=jgilbert
Differential Revision: https://phabricator.services.mozilla.com/D142263
2022-03-28 20:14:45 +00:00
Kelsey Gilbert 8b0e3105a0 Bug 1760726 - Failed webgl.linkProgram on CURRENT_PROGRAM should cause draws to fail. r=gfx-reviewers,lsalzman
Hack tests to test new behavior.
Eventually we'll take the full updates with a full CTS update.

Differential Revision: https://phabricator.services.mozilla.com/D141708
2022-03-25 20:11:19 +00:00
Iulian Moraru 92b62b9e23 Bug 1449575 - fix file-whitespace lint failures on WebGLContext.cpp. r=fix CLOSED TREE 2022-03-24 22:35:57 +02:00
Kelsey Gilbert 5362a1dd62 Bug 1449575 - Don't attempt ColorMask elision in WebGL. r=gfx-reviewers,aosmond
* Always use DoColorMask(u32?, u8) in webgl code.
* Handle OES_draw_buffers_indexed ColorMaski in GLBlitHelper.

Differential Revision: https://phabricator.services.mozilla.com/D141543
2022-03-24 19:39:06 +00:00
Andrew Osmond 78afd0ab38 Bug 1760663 - Add blocklist support for WebGPU. r=gfx-reviewers,nical
This patch just adds the plumbing to allow for baked in blocklist rules
or the downloadable blocklist to prevent certain configurations from
getting WebGPU. It does not add any rules.

It also changes us from allowing WebGPU only in nightly, including
tests, to not release and not beta. This allows try to run the WebGPU
tests as expected, since even try builds forked from mozilla-central are
not considered nightly builds by CI (or so it seems).

Differential Revision: https://phabricator.services.mozilla.com/D141682
2022-03-22 15:22:39 +00:00
Kelsey Gilbert e780e343c7 Bug 1682612 - Check for ArrayBuffer Detach/Transfer in texImage2D(ImageData). r=gfx-reviewers,aosmond
Differential Revision: https://phabricator.services.mozilla.com/D141689
2022-03-21 23:21:42 +00:00
Kelsey Gilbert 30bc9c7098 Bug 1744525 - Prevent too-high vert-count draws on Mesa. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D141297
2022-03-21 23:20:49 +00:00
Angus Sawyer dad7ed1e23 Bug 1756803 scaling/premultiply alpha of ImageData r=aosmond
Two issues:

The result of scaling & premultiply is order critical, the previous order for ImageData was scale > premultiply, the other image sources were premultiplied by default so didn't expose this issue. Reorder in the ImageData and common code paths (the original order followed the w3c spec order of operations - maybe the spec needs amending).

The ImageData path did not set the premultiplied flag of the resulting ImageBitmap correctly so the image would be premultiplied again in PrepareForDrawTarget.

Differential Revision: https://phabricator.services.mozilla.com/D139700
2022-03-18 16:47:26 +00:00
sotaro fe0ee34bf8 Bug 1423850 - Take into account video's rotation metadata at context.drawImage() with <video> r=gfx-reviewers,bradwerth
Rotated video for reftest is re-used from bug1228601-video-rotation-90.html

Differential Revision: https://phabricator.services.mozilla.com/D140353
2022-03-18 00:01:02 +00:00
Kelsey Gilbert 101520e3b8 Bug 1759942 - Check that FakeVertexAttrib0Buffer allocation succeeded. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D141298
2022-03-17 19:49:42 +00:00
Lee Salzman 91d3f55a5a Bug 1759792 - Avoid frequently oscillating between Skia layering and WebGL drawing. r=aosmond
In certain use-cases where we support layered drawing to Skia above a WebGL context, we can
repeatedly oscillate between clearing the Skia layer, drawing to it, then flushing it to
the WebGL context to fulfill an accelerated drawing request. For example, StrokeLine followed
by DrawSurface, repeated in a cycle, will cause each StrokeLine request to go to the layer,
and then the following DrawSurface request will go to the WebGL context, with clearing and
flushing of the Skia layer in between.

The original intent of the code was that the performance benefits of accelerated drawing
would compensate for the occasional cost of flushing. However, in practice, this turns out
not to be true and repeated clearing and flushing costs for the Skia layering can dominate
the overall performance. We really just want to continue drawing into the Skia layer as
long as possible if some fallback causes us to initially set it up and use it. While not
ideal, it prevents from bad performance cliffs from occuring where flushing happens more
than once in a frame.

Differential Revision: https://phabricator.services.mozilla.com/D141270
2022-03-17 15:45:56 +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