Bug 1804924 - Don't use DrawTargetWebgl when willReadFrequently is set. r=jgilbert,jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D164362
This commit is contained in:
Lee Salzman 2022-12-10 04:46:28 +00:00
Родитель 4411fc0df9
Коммит 94b04b1067
2 изменённых файлов: 15 добавлений и 2 удалений

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

@ -1348,7 +1348,13 @@ void CanvasRenderingContext2D::RestoreClipsAndTransformToTarget() {
bool CanvasRenderingContext2D::BorrowTarget(const IntRect& aPersistedRect,
bool aNeedsClear) {
if (!mBufferProvider || mBufferProvider->RequiresRefresh()) {
// We are attempting to request a DrawTarget from the current
// PersistentBufferProvider. However, if the provider needs to be refreshed,
// or if it is accelerated and the application has requested that we disallow
// acceleration, then we skip trying to use this provider so that it will be
// recreated by EnsureTarget later.
if (!mBufferProvider || mBufferProvider->RequiresRefresh() ||
(mBufferProvider->IsAccelerated() && mWillReadFrequently)) {
return false;
}
mTarget = mBufferProvider->BorrowDrawTarget(aPersistedRect);
@ -1564,7 +1570,9 @@ bool CanvasRenderingContext2D::TryAcceleratedTarget(
// to be refreshed and we should avoid using acceleration in the future.
mAllowAcceleration = false;
}
if (!mAllowAcceleration) {
// Don't try creating an accelerate DrawTarget if either acceleration failed
// previously or if the application expects acceleration to be slow.
if (!mAllowAcceleration || mWillReadFrequently) {
return false;
}
aOutDT = DrawTargetWebgl::Create(GetSize(), GetSurfaceFormat());
@ -1816,6 +1824,8 @@ CanvasRenderingContext2D::SetContextOptions(JSContext* aCx,
return NS_ERROR_UNEXPECTED;
}
mWillReadFrequently = attributes.mWillReadFrequently;
mContextAttributesHasAlpha = attributes.mAlpha;
UpdateIsOpaque();

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

@ -750,6 +750,9 @@ class CanvasRenderingContext2D : public nsICanvasRenderingContextInternal,
// Whether we should try to create an accelerated buffer provider.
bool mAllowAcceleration = true;
// Whether the application expects to use operations that perform poorly with
// acceleration.
bool mWillReadFrequently = false;
RefPtr<CanvasShutdownObserver> mShutdownObserver;
virtual void AddShutdownObserver();