Bug 1176024 - Have TextureClient::Lock check that it can expose a DrawTarget when it makes sense. r=Bas

This commit is contained in:
Nicolas Silva 2015-12-29 13:05:50 +01:00
Родитель a9159f1b2b
Коммит d0ca78d5be
1 изменённых файлов: 19 добавлений и 0 удалений

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

@ -363,6 +363,25 @@ TextureClient::Lock(OpenMode aMode)
mIsLocked = mData->Lock(aMode, mReleaseFenceHandle.IsValid() ? &mReleaseFenceHandle : nullptr);
mOpenMode = aMode;
auto format = GetFormat();
if (mIsLocked && CanExposeDrawTarget() &&
(aMode & OpenMode::OPEN_WRITE) &&
NS_IsMainThread() &&
// the formats that we apparently expect, in the cairo backend. Any other
// format will trigger an assertion in GfxFormatToCairoFormat.
(format == SurfaceFormat::A8R8G8B8_UINT32 ||
format == SurfaceFormat::X8R8G8B8_UINT32 ||
format == SurfaceFormat::A8 ||
format == SurfaceFormat::R5G6B5_UINT16)) {
if (!BorrowDrawTarget()) {
// Failed to get a DrawTarget, means we won't be able to write into the
// texture, might as well fail now.
Unlock();
return false;
}
}
return mIsLocked;
}