Bug 1182665 - Add gfxPlatform::CanUseDoubleBufferedContent() r=nical

This commit is contained in:
James Willcox 2015-08-28 11:20:05 -05:00
parent 226e891da2
commit a80e13e6fe
3 changed files with 34 additions and 21 deletions

View File

@ -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<ContentClientDoubleBuffered>(aForwarder);
}
return MakeAndAddRef<ContentClientSingleBuffered>(aForwarder);

View File

@ -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<ScaledFont>
gfxPlatform::GetScaledFontForFontWithCairoSkia(DrawTarget* aTarget, gfxFont* aFont)
{

View File

@ -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?
*/