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)

--HG--
extra : rebase_source : 6a5c1732d3908be748ea4d05668f4a7562828f6a
This commit is contained in:
Bas Schouten 2019-02-26 08:46:08 +01:00
parent 4c51ddc941
commit a4220fc608

View File

@ -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(gfx::Rect());
if (!dt->IsValid()) {
}
return dt.forget();
}
already_AddRefed<DrawTarget> gfxPlatform::CreateSimilarSoftwareDrawTarget(