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