Bug 1802625 - Hide GPU path stroking behind a pref. r=jrmuizel

It seems like this is slow for now until we implement a better way than WPF-gpu-raster
for stroking paths. Just hide this behind a pref so we can at least test it but not
impact performance as badly.

Differential Revision: https://phabricator.services.mozilla.com/D163248
This commit is contained in:
Lee Salzman 2022-11-28 20:31:02 +00:00
Родитель 269939beda
Коммит 06f0c7307f
3 изменённых файлов: 20 добавлений и 6 удалений

Просмотреть файл

@ -2534,8 +2534,11 @@ void PathCache::ClearVertexRanges() {
}
}
inline bool DrawTargetWebgl::ShouldAccelPath(const DrawOptions& aOptions) {
return mWebglValid && SupportsDrawOptions(aOptions) && PrepareContext();
inline bool DrawTargetWebgl::ShouldAccelPath(
const DrawOptions& aOptions, const StrokeOptions* aStrokeOptions) {
return mWebglValid && SupportsDrawOptions(aOptions) &&
(!aStrokeOptions || mSharedContext->mPathAccelStroke) &&
PrepareContext();
}
bool DrawTargetWebgl::SharedContext::DrawPathAccel(
@ -2795,7 +2798,7 @@ void DrawTargetWebgl::DrawPath(const Path* aPath, const Pattern& aPattern,
const StrokeOptions* aStrokeOptions) {
// If there is a WebGL context, then try to cache the path to avoid slow
// fallbacks.
if (ShouldAccelPath(aOptions) &&
if (ShouldAccelPath(aOptions, aStrokeOptions) &&
mSharedContext->DrawPathAccel(aPath, aPattern, aOptions,
aStrokeOptions)) {
return;
@ -2890,7 +2893,7 @@ void DrawTargetWebgl::DrawShadow(const Path* aPath, const Pattern& aPattern,
const StrokeOptions* aStrokeOptions) {
// If there is a WebGL context, then try to cache the path to avoid slow
// fallbacks.
if (ShouldAccelPath(aOptions) &&
if (ShouldAccelPath(aOptions, aStrokeOptions) &&
mSharedContext->DrawPathAccel(aPath, aPattern, aOptions, aStrokeOptions,
&aShadow)) {
return;
@ -2907,7 +2910,7 @@ void DrawTargetWebgl::DrawSurfaceWithShadow(SourceSurface* aSurface,
const ShadowOptions& aShadow,
CompositionOp aOperator) {
DrawOptions options(1.0f, aOperator);
if (ShouldAccelPath(options)) {
if (ShouldAccelPath(options, nullptr)) {
SurfacePattern pattern(aSurface, ExtendMode::CLAMP,
Matrix::Translation(aDest));
SkPath skiaPath;
@ -3733,6 +3736,8 @@ void DrawTargetWebgl::SharedContext::CachePrefs() {
mPathMaxComplexity =
StaticPrefs::gfx_canvas_accelerated_gpu_path_complexity();
mPathAccelStroke = StaticPrefs::gfx_canvas_accelerated_gpu_path_stroke();
}
// For use within CanvasRenderingContext2D, called on BorrowDrawTarget.

Просмотреть файл

@ -176,6 +176,8 @@ class DrawTargetWebgl : public DrawTarget, public SupportsWeakPtr {
uint32_t mPathVertexCapacity = 0;
// The maximum supported type complexity of a GPU path.
uint32_t mPathMaxComplexity = 0;
// Whether to accelerate stroked paths.
bool mPathAccelStroke = false;
RefPtr<WebGLProgramJS> mSolidProgram;
RefPtr<WebGLUniformLocationJS> mSolidProgramViewport;
RefPtr<WebGLUniformLocationJS> mSolidProgramAA;
@ -490,7 +492,8 @@ class DrawTargetWebgl : public DrawTarget, public SupportsWeakPtr {
bool aAccelOnly = false, bool aForceUpdate = false,
const StrokeOptions* aStrokeOptions = nullptr);
bool ShouldAccelPath(const DrawOptions& aOptions);
bool ShouldAccelPath(const DrawOptions& aOptions,
const StrokeOptions* aStrokeOptions);
void DrawPath(const Path* aPath, const Pattern& aPattern,
const DrawOptions& aOptions,
const StrokeOptions* aStrokeOptions = nullptr);

Просмотреть файл

@ -5622,6 +5622,12 @@
value: 4000
mirror: always
# Whether to accelerate stroked paths.
- name: gfx.canvas.accelerated.gpu-path-stroke
type: RelaxedAtomicBool
value: false
mirror: always
# 0x7fff is the maximum supported xlib surface size and is more than enough for canvases.
- name: gfx.canvas.max-size
type: RelaxedAtomicInt32