mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 997517: Never try to use D2D for BufferTextureClients. r=nical
This commit is contained in:
parent
387995aab3
commit
dbb9271862
@ -648,7 +648,6 @@ BufferTextureClient::BufferTextureClient(ISurfaceAllocator* aAllocator,
|
|||||||
, mFormat(aFormat)
|
, mFormat(aFormat)
|
||||||
, mBackend(aMoz2DBackend)
|
, mBackend(aMoz2DBackend)
|
||||||
, mOpenMode(OpenMode::OPEN_NONE)
|
, mOpenMode(OpenMode::OPEN_NONE)
|
||||||
, mUsingFallbackDrawTarget(false)
|
|
||||||
, mLocked(false)
|
, mLocked(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -699,26 +698,13 @@ BufferTextureClient::GetAsDrawTarget()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(mUsingFallbackDrawTarget == false);
|
|
||||||
mDrawTarget = serializer.GetAsDrawTarget(mBackend);
|
mDrawTarget = serializer.GetAsDrawTarget(mBackend);
|
||||||
if (mDrawTarget) {
|
if (mDrawTarget) {
|
||||||
return mDrawTarget;
|
return mDrawTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback path, probably because the Moz2D backend can't create a
|
mDrawTarget = serializer.GetAsDrawTarget(BackendType::CAIRO);
|
||||||
// DrawTarget around raw memory. This is going to be slow :(
|
|
||||||
mDrawTarget = gfx::Factory::CreateDrawTarget(mBackend, serializer.GetSize(),
|
|
||||||
serializer.GetFormat());
|
|
||||||
if (!mDrawTarget) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
mUsingFallbackDrawTarget = true;
|
|
||||||
if (mOpenMode & OpenMode::OPEN_READ) {
|
|
||||||
RefPtr<DataSourceSurface> surface = serializer.GetAsSurface();
|
|
||||||
IntRect rect(0, 0, surface->GetSize().width, surface->GetSize().height);
|
|
||||||
mDrawTarget->CopySurface(surface, rect, IntPoint(0,0));
|
|
||||||
}
|
|
||||||
return mDrawTarget;
|
return mDrawTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,7 +723,6 @@ BufferTextureClient::Unlock()
|
|||||||
MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!");
|
MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!");
|
||||||
mLocked = false;
|
mLocked = false;
|
||||||
if (!mDrawTarget) {
|
if (!mDrawTarget) {
|
||||||
mUsingFallbackDrawTarget = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,31 +733,7 @@ BufferTextureClient::Unlock()
|
|||||||
MOZ_ASSERT(mDrawTarget->refCount() == 1);
|
MOZ_ASSERT(mDrawTarget->refCount() == 1);
|
||||||
|
|
||||||
mDrawTarget->Flush();
|
mDrawTarget->Flush();
|
||||||
if (mUsingFallbackDrawTarget && (mOpenMode & OpenMode::OPEN_WRITE)) {
|
|
||||||
// When we are using a fallback DrawTarget, it means we could not create
|
|
||||||
// a DrawTarget wrapping the TextureClient's shared memory. In this scenario
|
|
||||||
// we need to put the content of the fallback draw target back into our shared
|
|
||||||
// memory.
|
|
||||||
RefPtr<SourceSurface> snapshot = mDrawTarget->Snapshot();
|
|
||||||
RefPtr<DataSourceSurface> surface = snapshot->GetDataSurface();
|
|
||||||
ImageDataSerializer serializer(GetBuffer(), GetBufferSize());
|
|
||||||
if (!serializer.IsValid() || serializer.GetSize() != surface->GetSize()) {
|
|
||||||
NS_WARNING("Could not write the data back into the texture.");
|
|
||||||
mDrawTarget = nullptr;
|
mDrawTarget = nullptr;
|
||||||
mUsingFallbackDrawTarget = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(surface->GetSize() == serializer.GetSize());
|
|
||||||
MOZ_ASSERT(surface->GetFormat() == serializer.GetFormat());
|
|
||||||
int bpp = BytesPerPixel(surface->GetFormat());
|
|
||||||
for (int i = 0; i < surface->GetSize().height; ++i) {
|
|
||||||
memcpy(serializer.GetData() + i*serializer.GetStride(),
|
|
||||||
surface->GetData() + i*surface->Stride(),
|
|
||||||
surface->GetSize().width * bpp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mDrawTarget = nullptr;
|
|
||||||
mUsingFallbackDrawTarget = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -445,7 +445,6 @@ protected:
|
|||||||
gfx::IntSize mSize;
|
gfx::IntSize mSize;
|
||||||
gfx::BackendType mBackend;
|
gfx::BackendType mBackend;
|
||||||
OpenMode mOpenMode;
|
OpenMode mOpenMode;
|
||||||
bool mUsingFallbackDrawTarget;
|
|
||||||
bool mLocked;
|
bool mLocked;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user