Bug 1847244 - Finish plumbing will-read-frequently through WindowRenderer. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D185451
This commit is contained in:
Lee Salzman 2023-08-05 01:05:47 +00:00
Родитель 3b85c18362
Коммит ebbda1906f
5 изменённых файлов: 24 добавлений и 12 удалений

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

@ -1683,8 +1683,9 @@ bool CanvasRenderingContext2D::TrySharedTarget(
return false;
}
aOutProvider =
renderer->CreatePersistentBufferProvider(GetSize(), GetSurfaceFormat());
aOutProvider = renderer->CreatePersistentBufferProvider(
GetSize(), GetSurfaceFormat(),
!mAllowAcceleration || mWillReadFrequently);
if (!aOutProvider) {
return false;

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

@ -749,8 +749,12 @@ void WebRenderLayerManager::ScheduleComposite(wr::RenderReasons aReasons) {
already_AddRefed<PersistentBufferProvider>
WebRenderLayerManager::CreatePersistentBufferProvider(
const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) {
if (!gfxPlatform::UseRemoteCanvas()) {
const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat,
bool aWillReadFrequently) {
// Only initialize devices if hardware acceleration may possibly be used.
// Remoting moves hardware usage out-of-process, while will-read-frequently
// avoids hardware acceleration entirely.
if (!aWillReadFrequently && !gfxPlatform::UseRemoteCanvas()) {
#ifdef XP_WIN
// Any kind of hardware acceleration is incompatible with Win32k Lockdown
// We don't initialize devices here so that PersistentBufferProviderShared
@ -765,8 +769,8 @@ WebRenderLayerManager::CreatePersistentBufferProvider(
}
RefPtr<PersistentBufferProvider> provider =
PersistentBufferProviderShared::Create(aSize, aFormat,
AsKnowsCompositor());
PersistentBufferProviderShared::Create(
aSize, aFormat, AsKnowsCompositor(), aWillReadFrequently);
if (provider) {
return provider.forget();
}

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

@ -125,7 +125,8 @@ class WebRenderLayerManager final : public WindowRenderer {
void SetFocusTarget(const FocusTarget& aFocusTarget);
already_AddRefed<PersistentBufferProvider> CreatePersistentBufferProvider(
const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat) override;
const gfx::IntSize& aSize, gfx::SurfaceFormat aFormat,
bool aWillReadFrequently) override;
bool AsyncPanZoomEnabled() const;

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

@ -117,13 +117,18 @@ void FrameRecorder::StopFrameTimeRecording(uint32_t aStartIndex,
already_AddRefed<PersistentBufferProvider>
WindowRenderer::CreatePersistentBufferProvider(
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat) {
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat,
bool aWillReadFrequently) {
RefPtr<PersistentBufferProviderBasic> bufferProvider;
// If we are using remote canvas we don't want to use acceleration in
// non-remote layer managers, so we always use the fallback software one.
if (!gfxPlatform::UseRemoteCanvas() ||
!gfxPlatform::IsBackendAccelerated(
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend())) {
// If will-read-frequently is set, avoid using the preferred backend in
// favor of the fallback backend in case the preferred backend provides
// acceleration.
if (!aWillReadFrequently &&
(!gfxPlatform::UseRemoteCanvas() ||
!gfxPlatform::IsBackendAccelerated(
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend()))) {
bufferProvider = PersistentBufferProviderBasic::Create(
aSize, aFormat,
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());

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

@ -200,7 +200,8 @@ class WindowRenderer : public FrameRecorder {
*/
virtual already_AddRefed<layers::PersistentBufferProvider>
CreatePersistentBufferProvider(const mozilla::gfx::IntSize& aSize,
mozilla::gfx::SurfaceFormat aFormat);
mozilla::gfx::SurfaceFormat aFormat,
bool aWillReadFrequently = false);
// Helper wrappers around cast to impl and then cast again.