Bug 912766. Use the DIB texture client/host. r=mattwoodrow

This commit is contained in:
Nicholas Cameron 2013-09-24 13:14:12 +12:00
parent df24a6ad47
commit caf72f56bd
5 changed files with 27 additions and 14 deletions

View File

@ -121,10 +121,15 @@ DeprecatedCanvasClient2D::DeprecatedCanvasClient2D(CompositableForwarder* aFwd,
void
DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
{
bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
gfxASurface::gfxContentType contentType = isOpaque
? gfxASurface::CONTENT_COLOR
: gfxASurface::CONTENT_COLOR_ALPHA;
if (!mDeprecatedTextureClient) {
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT);
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT, contentType);
if (!mDeprecatedTextureClient) {
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK);
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK, contentType);
if (!mDeprecatedTextureClient) {
NS_WARNING("Could not create texture client");
return;
@ -132,17 +137,12 @@ DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
}
}
bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
gfxASurface::gfxContentType contentType = isOpaque
? gfxASurface::CONTENT_COLOR
: gfxASurface::CONTENT_COLOR_ALPHA;
if (!mDeprecatedTextureClient->EnsureAllocated(aSize, contentType)) {
// We might already be on the fallback texture client if we couldn't create a
// better one above. In which case this call to create is wasted. But I don't
// think this will happen often enough to be worth complicating the code with
// further checks.
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK);
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK, contentType);
MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
if (!mDeprecatedTextureClient->EnsureAllocated(aSize, contentType)) {
NS_WARNING("Could not allocate texture client");
@ -173,7 +173,10 @@ void
DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
{
if (!mDeprecatedTextureClient) {
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL);
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL,
aLayer->GetSurfaceMode() == Layer::SURFACE_OPAQUE
? gfxASurface::CONTENT_COLOR
: gfxASurface::CONTENT_COLOR_ALPHA);
MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
}

View File

@ -10,6 +10,7 @@
#include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc
#include "mozilla/layers/TextureClientOGL.h"
#include "mozilla/mozalloc.h" // for operator delete, etc
#include "gfxASurface.h" // for gfxContentType
#ifdef XP_WIN
#include "mozilla/layers/TextureD3D9.h"
#include "mozilla/layers/TextureD3D11.h"
@ -107,7 +108,8 @@ CompositableChild::Destroy()
}
TemporaryRef<DeprecatedTextureClient>
CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType)
CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
gfxASurface::gfxContentType aContentType)
{
MOZ_ASSERT(GetForwarder(), "Can't create a texture client if the compositable is not connected to the compositor.");
LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
@ -145,7 +147,11 @@ CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aD
}
if (parentBackend == LAYERS_D3D9 &&
!GetForwarder()->ForwardsToDifferentProcess()) {
result = new DeprecatedTextureClientD3D9(GetForwarder(), GetTextureInfo());
if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA) {
result = new DeprecatedTextureClientDIB(GetForwarder(), GetTextureInfo());
} else {
result = new DeprecatedTextureClientD3D9(GetForwarder(), GetTextureInfo());
}
break;
}
#endif

View File

@ -16,6 +16,7 @@
#include "mozilla/layers/LayersTypes.h" // for LayersBackend
#include "mozilla/layers/PCompositableChild.h" // for PCompositableChild
#include "nsTraceRefcnt.h" // for MOZ_COUNT_CTOR, etc
#include "gfxASurface.h" // for gfxContentType
namespace mozilla {
namespace layers {
@ -80,7 +81,8 @@ public:
LayersBackend GetCompositorBackendType() const;
TemporaryRef<DeprecatedTextureClient>
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType);
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
gfxASurface::gfxContentType aContentType = gfxASurface::CONTENT_SENTINEL);
virtual TemporaryRef<BufferTextureClient>
CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);

View File

@ -163,11 +163,11 @@ ContentClientRemoteBuffer::EndPaint()
bool
ContentClientRemoteBuffer::CreateAndAllocateDeprecatedTextureClient(RefPtr<DeprecatedTextureClient>& aClient)
{
aClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT);
aClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT, mContentType);
MOZ_ASSERT(aClient, "Failed to create texture client");
if (!aClient->EnsureAllocated(mSize, mContentType)) {
aClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK);
aClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK, mContentType);
MOZ_ASSERT(aClient, "Failed to create texture client");
if (!aClient->EnsureAllocated(mSize, mContentType)) {
NS_WARNING("Could not allocate texture client");

View File

@ -27,6 +27,8 @@ CreateDeprecatedTextureHostD3D9(SurfaceDescriptorType aDescriptorType,
result = new DeprecatedTextureHostYCbCrD3D9();
} else if (aDescriptorType == SurfaceDescriptor::TSurfaceDescriptorD3D9) {
result = new DeprecatedTextureHostSystemMemD3D9();
} else if (aDescriptorType == SurfaceDescriptor::TSurfaceDescriptorDIB) {
result = new DeprecatedTextureHostDIB();
} else {
result = new DeprecatedTextureHostShmemD3D9();
}