Bug 957560 - Fix new textures on windows (OMTC). r=mattwoodrow

This commit is contained in:
Nicolas Silva 2014-03-31 11:07:40 +08:00
Родитель cb83f0aa3c
Коммит 4e568f39b1
9 изменённых файлов: 57 добавлений и 31 удалений

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

@ -65,12 +65,21 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
: gfxContentType::COLOR_ALPHA;
gfxImageFormat format
= gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
TEXTURE_FLAGS_DEFAULT,
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
MOZ_ASSERT(mBuffer->AsTextureClientSurface());
mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize);
mBuffer = CreateTextureClientForDrawing(gfx::ImageFormatToSurfaceFormat(format),
TEXTURE_FLAGS_DEFAULT,
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend(),
aSize);
bool allocSuccess = false;
if (mBuffer->AsTextureClientSurface()) {
allocSuccess = mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize);
} else {
MOZ_ASSERT(mBuffer->AsTextureClientDrawTarget());
allocSuccess = mBuffer->AsTextureClientDrawTarget()->AllocateForSurface(aSize);
}
if (!allocSuccess) {
mBuffer = nullptr;
return;
}
bufferCreated = true;
}
@ -81,8 +90,18 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
bool updated = false;
{
// Restrict drawTarget to a scope so that terminates before Unlock.
nsRefPtr<gfxASurface> surface =
mBuffer->AsTextureClientSurface()->GetAsSurface();
nsRefPtr<gfxASurface> surface;
if (mBuffer->AsTextureClientSurface()) {
surface = mBuffer->AsTextureClientSurface()->GetAsSurface();
} else {
RefPtr<gfx::DrawTarget> dt
= mBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget();
if (dt) {
surface = gfxPlatform::GetPlatform()->CreateThebesSurfaceAliasForDrawTarget_hack(dt);
}
// the DrawTarget will be kept alive until mBuffer->Unlock() so it's
// OK to let go of dt before we destroy surface.
}
if (surface) {
aLayer->DeprecatedUpdateSurface(surface);
updated = true;

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

@ -51,12 +51,7 @@ ContentClient::CreateContentClient(CompositableForwarder* aForwarder)
bool useDoubleBuffering = false;
bool useDeprecatedTextures = true;
// XXX We need support for gralloc with non-deprecated textures content before
// we can use them with FirefoxOS (bug 946720). We need the same locking for
// Windows.
#if !defined(XP_WIN)
useDeprecatedTextures = gfxPlatform::GetPlatform()->UseDeprecatedTextures();
#endif
#ifdef XP_WIN
if (backend == LayersBackend::LAYERS_D3D11) {

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

@ -282,6 +282,8 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
aMoz2DBackend = gfxPlatform::GetPlatform()->GetContentBackend();
}
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
RefPtr<TextureClient> result;
#ifdef XP_WIN
@ -290,9 +292,10 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
(aMoz2DBackend == gfx::BackendType::DIRECT2D ||
aMoz2DBackend == gfx::BackendType::DIRECT2D1_1) &&
gfxWindowsPlatform::GetPlatform()->GetD2DDevice() &&
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
result = new TextureClientD3D11(aFormat, aTextureFlags);
if (aSizeHint.width <= maxTextureSize && aSizeHint.height <= maxTextureSize) {
result = new TextureClientD3D11(aFormat, aTextureFlags);
}
}
if (parentBackend == LayersBackend::LAYERS_D3D9 &&
aMoz2DBackend == gfx::BackendType::CAIRO &&
@ -337,7 +340,6 @@ TextureClient::CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
if (!DisableGralloc(aFormat, aSizeHint)) {
// Don't allow Gralloc texture clients to exceed the maximum texture size.
// BufferTextureClients have code to handle tiling the surface client-side.
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
if (aSizeHint.width <= maxTextureSize && aSizeHint.height <= maxTextureSize) {
result = new GrallocTextureClientOGL(aAllocator, aFormat, aMoz2DBackend,
aTextureFlags);

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

@ -132,7 +132,6 @@ ThebesLayerComposite::RenderLayer(const nsIntRect& aClipRect)
EffectChain effectChain(this);
LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(mMaskLayer, effectChain);
nsIntRegion visibleRegion = GetEffectiveVisibleRegion();
TiledLayerProperties tiledLayerProps;

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

@ -171,6 +171,10 @@ bool
TextureClientD3D11::Lock(OpenMode aMode)
{
MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");
if (!mTexture) {
return false;
}
LockD3DTexture(mTexture.get());
mIsLocked = true;
@ -211,6 +215,10 @@ TextureClientD3D11::GetAsDrawTarget()
return mDrawTarget;
}
if (!mTexture) {
return nullptr;
}
mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, mFormat);
return mDrawTarget;
}
@ -221,7 +229,7 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag
mSize = aSize;
ID3D10Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D10Device();
CD3D10_TEXTURE2D_DESC newDesc(SurfaceFormatToDXGIFormat(mFormat),
CD3D10_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM,
aSize.width, aSize.height, 1, 1,
D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE);
@ -329,10 +337,10 @@ DataTextureSourceD3D11::Update(DataSourceSurface* aSurface,
nsIntRegion* aDestRegion,
IntPoint* aSrcOffset)
{
// Right now we only support null aDestRegion and aSrcOffset (which means)
// full surface update. Incremental update is only used on Mac so it is
// not clear that we ever will need to support it for D3D.
MOZ_ASSERT(!aDestRegion && !aSrcOffset);
// Right now we only support full surface update. If aDestRegion is provided,
// It will be ignered. Incremental update with a source offset is only used
// on Mac so it is not clear that we ever will need to support it for D3D.
MOZ_ASSERT(!aSrcOffset);
MOZ_ASSERT(aSurface);
if (!mCompositor || !mCompositor->GetDevice()) {

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

@ -1061,10 +1061,10 @@ DataTextureSourceD3D9::Update(gfx::DataSourceSurface* aSurface,
nsIntRegion* aDestRegion,
gfx::IntPoint* aSrcOffset)
{
// Right now we only support null aDestRegion and aSrcOffset (which means
// full surface update). Incremental update is only used on Mac so it is
// not clear that we ever will need to support it for D3D.
MOZ_ASSERT(!aDestRegion && !aSrcOffset);
// Right now we only support full surface update. If aDestRegion is provided,
// It will be ignered. Incremental update with a source offset is only used
// on Mac so it is not clear that we ever will need to support it for D3D.
MOZ_ASSERT(!aSrcOffset);
if (!mCompositor || !mCompositor->device()) {
NS_WARNING("No D3D device to update the texture.");

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

@ -449,6 +449,10 @@ void
ShadowLayerForwarder::RemoveTextureFromCompositable(CompositableClient* aCompositable,
TextureClient* aTexture)
{
MOZ_ASSERT(aCompositable);
MOZ_ASSERT(aCompositable->GetIPDLActor());
MOZ_ASSERT(aTexture);
MOZ_ASSERT(aTexture->GetIPDLActor());
mTxn->AddEdit(OpRemoveTexture(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTexture->GetIPDLActor()));
if (aTexture->GetFlags() & TEXTURE_DEALLOCATE_CLIENT) {

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

@ -273,7 +273,7 @@ gfxPlatform::gfxPlatform()
#ifdef XP_WIN
// XXX - When 957560 is fixed, the pref can go away entirely
mLayersUseDeprecated =
Preferences::GetBool("layers.use-deprecated-textures", true)
Preferences::GetBool("layers.use-deprecated-textures", false)
&& !gfxPrefs::LayersPreferOpenGL();
#else
mLayersUseDeprecated = false;

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

@ -4002,13 +4002,12 @@ pref("layers.offmainthreadcomposition.enabled", false);
// -1 -> default (match layout.frame_rate or 60 FPS)
// 0 -> full-tilt mode: Recomposite even if not transaction occured.
pref("layers.offmainthreadcomposition.frame-rate", -1);
// Whether to use the deprecated texture architecture rather than the new one.
#ifndef XP_WIN
#ifdef XP_WIN
// Asynchonous video compositing using the ImageBridge IPDL protocol.
// requires off-main-thread compositing.
// Never works on Windows, so no point pref'ing it on.
pref("layers.async-video.enabled",false);
pref("layers.use-deprecated-textures", true);
pref("layers.async-video.enabled", false);
#endif
#ifdef MOZ_X11