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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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