From a80e13e6fe121b2450b551e76a1d582748ed53d4 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Fri, 28 Aug 2015 11:20:05 -0500 Subject: [PATCH] Bug 1182665 - Add gfxPlatform::CanUseDoubleBufferedContent() r=nical --- gfx/layers/client/ContentClient.cpp | 22 +--------------------- gfx/thebes/gfxPlatform.cpp | 28 ++++++++++++++++++++++++++++ gfx/thebes/gfxPlatform.h | 5 +++++ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 1efa41da06af..4d02a90e0faa 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -69,27 +69,7 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder) return nullptr; } - bool useDoubleBuffering = false; - -#ifdef XP_WIN - if (backend == LayersBackend::LAYERS_D3D11) { - useDoubleBuffering = !!gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); - } else -#endif -#ifdef MOZ_WIDGET_GTK - // We can't use double buffering when using image content with - // Xrender support on Linux, as ContentHostDoubleBuffered is not - // suited for direct uploads to the server. - if (!gfxPlatformGtk::GetPlatform()->UseImageOffscreenSurfaces() || - !gfxPlatformGtk::GetPlatform()->UseXRender()) -#endif - { - useDoubleBuffering = (LayerManagerComposite::SupportsDirectTexturing() && - backend != LayersBackend::LAYERS_D3D9) || - backend == LayersBackend::LAYERS_BASIC; - } - - if (useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING")) { + if (gfxPlatform::GetPlatform()->CanUseDoubleBufferedContent(backend)) { return MakeAndAddRef(aForwarder); } return MakeAndAddRef(aForwarder); diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 698b488fb21e..9fbb056decdd 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -9,6 +9,7 @@ #include "mozilla/layers/ImageBridgeChild.h" #include "mozilla/layers/SharedBufferManagerChild.h" #include "mozilla/layers/ISurfaceAllocator.h" // for GfxMemoryImageReporter +#include "mozilla/layers/LayerManagerComposite.h" #include "mozilla/Logging.h" #include "mozilla/Services.h" @@ -2301,6 +2302,33 @@ gfxPlatform::DisableBufferRotation() sBufferRotationCheckPref = false; } +bool +gfxPlatform::CanUseDoubleBufferedContent(LayersBackend aBackend) const +{ + bool useDoubleBuffering = false; + +#ifdef XP_WIN + if (aBackend == LayersBackend::LAYERS_D3D11) { + useDoubleBuffering = !!gfxWindowsPlatform::GetPlatform()->GetD3D10Device(); + } else +#endif +#ifdef MOZ_WIDGET_GTK + // We can't use double buffering when using image content with + // Xrender support on Linux, as ContentHostDoubleBuffered is not + // suited for direct uploads to the server. + if (!gfxPlatformGtk::GetPlatform()->UseImageOffscreenSurfaces() || + !gfxPlatformGtk::GetPlatform()->UseXRender()) +#endif + { + useDoubleBuffering = (LayerManagerComposite::SupportsDirectTexturing() && + aBackend != LayersBackend::LAYERS_D3D9) || + aBackend == LayersBackend::LAYERS_BASIC; + } + + return useDoubleBuffering || PR_GetEnv("MOZ_FORCE_DOUBLE_BUFFERING"); +} + + already_AddRefed gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFont) { diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 9e3e9415e6f3..156b50ed56ca 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -496,6 +496,11 @@ public: static bool BufferRotationEnabled(); static void DisableBufferRotation(); + /** + * Check to see if we should use double buffered content client + */ + bool CanUseDoubleBufferedContent(mozilla::layers::LayersBackend aBackend) const; + /** * Are we going to try color management? */