Bug 1526045 - Part 2: Verify all DrawTargets created through CreateOffscreenContentDrawTarget. r=rhunt

Preferrably CreateOffscreenContentDrawTarget would create Capture DrawTargets when we intend to use OMTP. This is not the case at the moment though and changing this would likely introduce more unforseen issues. For now all of these calls basically mean a DrawTarget will be used on the main thread and we should use a no-op ClearRect to ensure that the DrawTarget is actually initialized. Since IsValid for the moment won't do this for DrawTargetD2D. (See bug 1521368)

Differential Revision: https://phabricator.services.mozilla.com/D21037

--HG--
extra : rebase_source : 7b9f4c5ed66d5ecaf613634c660f085de3584fd3
This commit is contained in:
Bas Schouten 2019-02-25 19:12:13 +01:00
Родитель c85a512b81
Коммит 3bc90cc49b
1 изменённых файлов: 14 добавлений и 1 удалений

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

@ -1744,7 +1744,20 @@ already_AddRefed<DrawTarget> gfxPlatform::CreateOffscreenContentDrawTarget(
const IntSize& aSize, SurfaceFormat aFormat, bool aFallback) {
BackendType backend = (aFallback) ? mSoftwareBackend : mContentBackend;
NS_ASSERTION(backend != BackendType::NONE, "No backend.");
return CreateDrawTargetForBackend(backend, aSize, aFormat);
RefPtr<DrawTarget> dt = CreateDrawTargetForBackend(backend, aSize, aFormat);
if (!dt) {
return nullptr;
}
// We'd prefer this to take proper care and return a CaptureDT, but for the
// moment since we can't and this means we're going to be drawing on the main
// thread force it's initialization. See bug 1526045 and bug 1521368.
dt->ClearRect(Rect());
if (!dt->IsValid()) {
return nullptr;
}
return dt.forget();
}
already_AddRefed<DrawTarget> gfxPlatform::CreateSimilarSoftwareDrawTarget(