diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index 11ee8285bec..4decd78fcb9 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -342,7 +342,7 @@ TemporaryRef CompositorD3D11::CreateDataTextureSource(TextureFlags aFlags) { RefPtr result = new DataTextureSourceD3D11(gfx::SurfaceFormat::UNKNOWN, - this); + this, aFlags); return result.forget(); } diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 1362ef41027..4cc26ff2040 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -62,10 +62,11 @@ GetTileRectD3D11(uint32_t aID, IntSize aSize, uint32_t aMaxSize) } DataTextureSourceD3D11::DataTextureSourceD3D11(SurfaceFormat aFormat, - CompositorD3D11* aCompositor) + CompositorD3D11* aCompositor, + TextureFlags aFlags) : mCompositor(aCompositor) , mFormat(aFormat) - , mFlags(0) + , mFlags(aFlags) , mCurrentTile(0) , mIsTiled(false) , mIterating(false) @@ -421,7 +422,7 @@ void DataTextureSourceD3D11::SetCompositor(Compositor* aCompositor) { CompositorD3D11* d3dCompositor = static_cast(aCompositor); - if (mCompositor != d3dCompositor) { + if (mCompositor && mCompositor != d3dCompositor) { Reset(); } mCompositor = d3dCompositor; @@ -905,9 +906,9 @@ DeprecatedTextureHostYCbCrD3D11::UpdateImpl(const SurfaceDescriptor& aImage, RefPtr srcCb; RefPtr srcCr; if (!mFirstSource) { - srcY = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor); - srcCb = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor); - srcCr = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor); + srcY = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, TEXTURE_DISALLOW_BIGIMAGE); + srcCb = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, TEXTURE_DISALLOW_BIGIMAGE); + srcCr = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, TEXTURE_DISALLOW_BIGIMAGE); mFirstSource = srcY; srcY->SetNextSibling(srcCb); srcCb->SetNextSibling(srcCr); diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index b7606ad9960..d77cb6d33b9 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -100,7 +100,8 @@ class DataTextureSourceD3D11 : public DataTextureSource , public TileIterator { public: - DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor); + DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor, + TextureFlags aFlags); DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor, ID3D11Texture2D* aTexture); diff --git a/gfx/layers/d3d9/CompositorD3D9.cpp b/gfx/layers/d3d9/CompositorD3D9.cpp index 050e54b2a04..03235cd3f5d 100644 --- a/gfx/layers/d3d9/CompositorD3D9.cpp +++ b/gfx/layers/d3d9/CompositorD3D9.cpp @@ -89,8 +89,7 @@ CompositorD3D9::GetMaxTextureSize() const TemporaryRef CompositorD3D9::CreateDataTextureSource(TextureFlags aFlags) { - return new DataTextureSourceD3D9(SurfaceFormat::UNKNOWN, this, - !(aFlags & TEXTURE_DISALLOW_BIGIMAGE)); + return new DataTextureSourceD3D9(SurfaceFormat::UNKNOWN, this, aFlags); } TemporaryRef diff --git a/gfx/layers/d3d9/TextureD3D9.cpp b/gfx/layers/d3d9/TextureD3D9.cpp index 18d3f477552..3bdd4e5b63b 100644 --- a/gfx/layers/d3d9/TextureD3D9.cpp +++ b/gfx/layers/d3d9/TextureD3D9.cpp @@ -1214,11 +1214,10 @@ void DataTextureSourceD3D9::SetCompositor(Compositor* aCompositor) { CompositorD3D9* d3dCompositor = static_cast(aCompositor); - - if (d3dCompositor != mCompositor) { + if (mCompositor && mCompositor != d3dCompositor) { Reset(); - mCompositor = d3dCompositor; } + mCompositor = d3dCompositor; } void @@ -1278,6 +1277,7 @@ CairoTextureClientD3D9::Lock(OpenMode) if (mNeedsClear) { mDrawTarget = GetAsDrawTarget(); mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height)); + mNeedsClear = false; } mIsLocked = true; return true; @@ -1339,19 +1339,22 @@ CairoTextureClientD3D9::GetAsDrawTarget() } } - if (ContentForFormat(mFormat) == gfxContentType::COLOR_ALPHA) { - D3DLOCKED_RECT rect; - mD3D9Surface->LockRect(&rect, nullptr, 0); - mSurface = new gfxImageSurface((uint8_t*)rect.pBits, ThebesIntSize(mSize), - rect.Pitch, gfxImageFormat::ARGB32); - mLockRect = true; - } else { + if (ContentForFormat(mFormat) == gfxContentType::COLOR) { mSurface = new gfxWindowsSurface(mD3D9Surface); if (!mSurface || mSurface->CairoStatus()) { NS_WARNING("Could not create surface for d3d9 surface"); mSurface = nullptr; return nullptr; } + } else { + // gfxWindowsSurface don't support transparency so we can't use the d3d9 + // windows surface optimization. + // Instead we have to use a gfxImageSurface and fallback for font drawing. + D3DLOCKED_RECT rect; + mD3D9Surface->LockRect(&rect, nullptr, 0); + mSurface = new gfxImageSurface((uint8_t*)rect.pBits, ThebesIntSize(mSize), + rect.Pitch, SurfaceFormatToImageFormat(mFormat)); + mLockRect = true; } mDrawTarget = @@ -1557,10 +1560,15 @@ DataTextureSourceD3D9::UpdateFromTexture(IDirect3DTexture9* aTexture, D3DSURFACE_DESC desc; HRESULT hr = aTexture->GetLevelDesc(0, &desc); - if (!FAILED(hr)) { + if (FAILED(hr)) { + return false; + } else { + // If we changed the compositor, the size might have been reset to zero + // Otherwise the texture size must not change. MOZ_ASSERT(mFormat == D3D9FormatToSurfaceFormat(desc.Format)); - MOZ_ASSERT(mSize.width == desc.Width); - MOZ_ASSERT(mSize.height == desc.Height); + MOZ_ASSERT(!mSize.width || mSize.width == desc.Width); + MOZ_ASSERT(!mSize.height || mSize.height == desc.Height); + mSize = IntSize(desc.Width, desc.Height); } DeviceManagerD3D9* dm = gfxWindowsPlatform::GetPlatform()->GetD3D9DeviceManager(); @@ -1598,10 +1606,18 @@ DataTextureSourceD3D9::UpdateFromTexture(IDirect3DTexture9* aTexture, POINT point; point.x = iterRect->x; point.y = iterRect->y; - dm->device()->UpdateSurface(srcSurface, &rect, dstSurface, &point); + hr = dm->device()->UpdateSurface(srcSurface, &rect, dstSurface, &point); + if (FAILED(hr)) { + NS_WARNING("Failed Update the surface"); + return false; + } } } else { - dm->device()->UpdateSurface(srcSurface, nullptr, dstSurface, nullptr); + hr = dm->device()->UpdateSurface(srcSurface, nullptr, dstSurface, nullptr); + if (FAILED(hr)) { + NS_WARNING("Failed Update the surface"); + return false; + } } mIsTiled = false; return true;