TransformedCopyToBuilder is called any time in Canvas2D the transform
is modified and then a path op is used. On cases that repeatedly change
the transform while building paths, this leads to fairly significant
expense in repeatedly copying the path contents as well as allocating
and deallocating paths.
To work around this, a new primitive TransformedMoveToBuilder is provided
that allows in-place transforming of the path contents. Because paths that
are "finished" and referenced externally can't be safely modified, extra
static methods (i.e. ToBuilder) are added to guarantee that there are no
other refs to the path before modifying its contents.
One snag is that ArcParams could previously not handle transforms, so it
is modified to allow a transform to be supplied to an Arc op, which is
only flattened out when it is streamed to a sink.
Differential Revision: https://phabricator.services.mozilla.com/D225548
This requires hard-coding the value of sqrt(2 * M_PI) as sqrt is not
constexpr.
The value has been generated through the execution of:
#include <math.h>
#include <stdio.h>
int main() {
double s = sqrt(2 * M_PI);
printf("%a\n", s);
return 0;
}
Differential Revision: https://phabricator.services.mozilla.com/D222795
This patch corrects a few different issues related to recycling
MacIOSurface objects.
1) When recycling a surface, we must check that the cached surfaces
match all of the requested parameters, not just the size. If we do
not, we should just flush the whole cache immediately since they
should all be created with the same parameters.
2) Allocations can fail, and we should check for failing to get a
surface from the allocator and fall back if so.
3) Locking can fail, and we should check that return value at all of the
call sites.
This may help resolve a number of otherwise difficult to understand
crash signatures. It may also solve display corruption issues in rare
cases where the parameters that changed were roughly equivalent such
that everything appears to work, but they differ enough to change the
presentation.
Differential Revision: https://phabricator.services.mozilla.com/D222205
CanvasRenderingContext2D depends on RemoveAllClips for efficient resetting,
but DrawTargetRecording did not implement this, causing fast resets to fail.
Differential Revision: https://phabricator.services.mozilla.com/D221285
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
Generally we want to move to more flagged matrices because the transforms are usually simple, just offsets, or simple 2d transforms and the operations do show up in profiles if we do them in the "dumb" way of assuming a full 3d transform.
This specific code isn't necessarily performance critical, but it simplifies nsIFrame::GetTransformMatrix (which is performance critical) so that everything there is Matrix4x4Flagged except the one conversion for GetResultingTransformMatrix.
Matrix4x4TypedFlagged::ToUnknownMatrix gets its first user with this change and we need to make some fixes so that it actually works. We need to friend all template instantiations of this class so that it can access the private constructor of the class with different units. We also need to move the MatrixType enum outside of the class so it doesn't get the templated units imprinted on its type. Maybe there is a better way to do this.
Differential Revision: https://phabricator.services.mozilla.com/D218018
YUV422P10 is needed to properly tag decoded YUV422P10 video. NV16 is
needed to describe the macOS 10-bit YUV422 formats.
Differential Revision: https://phabricator.services.mozilla.com/D217334
This is just a renaming patch, motivated by a need for clarity before
addding more YUV formats. Comments and log messages are updated as well,
and one function in MacIOSurface is renamed.
There is one small change in TextureHost.cpp to satisfy clang-tidy.
Differential Revision: https://phabricator.services.mozilla.com/D217883
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
This aggregates all SourceSurfaceAlignedRawdata into a single line item
of "explicit/gfx/source-surface-aligned-raw-data". If we want to get
more granular, we just need to decide if we split by SurfaceFormat, by
size buckets, or whatever.
I've confirmed this measures the memory held by the reproduction case in
Bug 1904048, which was the motivation for this issue.
Differential Revision: https://phabricator.services.mozilla.com/D217181
Even though drawing a canvas to itself tries to use ExtractSubrect to get a limited
copy where applicable, the canvas still inadvertently forces the copy-on-write snapshot
to also force a copy due to SurfaceFromElementResult holding a subversive extra reference
to the snapshot, keeping it alive when it need not be.
RecordedTextureData also holds a reference to the snapshot that needs to be cleaned up
as well when the DT is modified.
Differential Revision: https://phabricator.services.mozilla.com/D216520
nsIFrame::GetTransformMatrix returns a Matrix4x4Flagged (a matrix with a type field signifying if it is identity, simple 2d matrix, or full 3d matrix so operations can be simplified) but we construct simple Matrix4x4 and return them, which forces us to construct a Matrix4x4Flagged and Analyze() it to determine what type it is. We should just construct a flagged matrix directly. This shows up in profiles.
GetTransformMatrix got converted from Matrix4x4 to Matrix4x4Flagged for perf reasons in the past, so that explains how we ended up in this situation.
We still use Matrix4x4 in the more complicated actually transformed case.
Differential Revision: https://phabricator.services.mozilla.com/D215867
This doesn't fix a similar problem in ArithmeticCombineTwoPixels because the fixes there have performance implications, appear wrong, or are wrong for common inputs.
Since hue-rotate is defined in terms of a color matrix, some tests involving hue-rotate behave slightly differently.
Differential Revision: https://phabricator.services.mozilla.com/D211113
This doesn't fix a similar problem in ArithmeticCombineTwoPixels because the fixes there have performance implications, appear wrong, or are wrong for common inputs.
Since hue-rotate is defined in terms of a color matrix, some tests involving hue-rotate behave slightly differently.
Differential Revision: https://phabricator.services.mozilla.com/D211113
With a USER_RESTRICTED access token level this requires a sync call to the
parent process via the sandbox's shared memory IPC.
This patch also caches the font file name as GetFontFileName, still requires
a number of calls into DirectWrite.
Differential Revision: https://phabricator.services.mozilla.com/D213258
To take advantage of the new cairo capability, extend the link APIs to support
passing both a local destination name and a URI from the display list to the
rendering backend.
With this change, links to parts of the document that aren't included in the
print-to-pdf output will point back to the online resource, instead of just being
dead links.
(Note that this won't work the same on macOS at present, as we don't use
the cairo pdf backend there.)
Differential Revision: https://phabricator.services.mozilla.com/D211995
It looks like there was some header bootlegging happening that was recently
impacted by a Skia update. This adds the missing float header.
Differential Revision: https://phabricator.services.mozilla.com/D210500
A number of public APIs in Skia have changed since the update to m125,
so various places in Gecko need to be updated to track it.
Differential Revision: https://phabricator.services.mozilla.com/D209821
A number of public APIs in Skia have changed since the update to m125,
so various places in Gecko need to be updated to track it.
Differential Revision: https://phabricator.services.mozilla.com/D209821
Created a new metafunction, FloatType, which will prevent truncation of the
decimal portion of the Length method result. Added GTest unit tests, and converted
old unit tests in gfx/2d/unittest/TestPoint.cpp to gtests.
Differential Revision: https://phabricator.services.mozilla.com/D208306