Bug 1526045 - Part 2: Verify all DrawTargets created through CreateOffscreenContentDrawTarget. r=rhunt a=lizzard
authorBas Schouten <bschouten@mozilla.com>
Tue, 26 Feb 2019 08:46:08 +0100
changeset 516200 46f0f4418eddc69b08f223b7766ef55725df3920
parent 516199 b1090ef7dc8bcaeb3ffdbc866ae074c744018a71
child 516201 3bb0dde9e64f4d299f17781180a805912e861a3f
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhunt, lizzard
bugs1526045, 1521368
milestone66.0
Bug 1526045 - Part 2: Verify all DrawTargets created through CreateOffscreenContentDrawTarget. r=rhunt a=lizzard 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)
gfx/thebes/gfxPlatform.cpp
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -1739,17 +1739,30 @@ already_AddRefed<DrawTarget> gfxPlatform
   return CreateDrawTargetForBackend(mFallbackCanvasBackend, aSize, aFormat);
 #endif
 }
 
 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(
     DrawTarget* aDT, const IntSize& aSize, SurfaceFormat aFormat) {
   RefPtr<DrawTarget> dt;
 
   if (Factory::DoesBackendSupportDataDrawtarget(aDT->GetBackendType())) {
     dt = aDT->CreateSimilarDrawTarget(aSize, aFormat);