Bug 1383078 - Use at minimum a 1,1 draw target in headless. r=jrmuizel
authorBrendan Dahl <brendan.dahl@gmail.com>
Fri, 21 Jul 2017 11:23:34 -0700
changeset 370848 d771aa47acab86a054f4408a50c66291f2073d5d
parent 370847 506c0fc7d2f25e68ba7d000d957db4f9781518f3
child 370849 288c2f3f9dd532358a20557845560db407b42dee
child 370940 9eddb0a92820c6445f9d1e680e4c239e888e93f0
push id92946
push userbdahl@mozilla.com
push dateTue, 25 Jul 2017 16:05:18 +0000
treeherdermozilla-inbound@d771aa47acab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1383078
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1383078 - Use at minimum a 1,1 draw target in headless. r=jrmuizel
widget/headless/HeadlessWidget.cpp
--- a/widget/headless/HeadlessWidget.cpp
+++ b/widget/headless/HeadlessWidget.cpp
@@ -19,17 +19,20 @@ nsIWidget::CreateHeadlessWidget()
 }
 
 namespace mozilla {
 namespace widget {
 
 already_AddRefed<gfxContext>
 CreateDefaultTarget(IntSize aSize)
 {
-  RefPtr<DrawTarget> target = Factory::CreateDrawTarget(gfxVars::ContentBackend(), aSize, SurfaceFormat::B8G8R8A8);
+  // Always use at least a 1x1 draw target to avoid gfx issues
+  // with 0x0 targets.
+  IntSize size = (aSize.width <= 0 || aSize.height <= 0) ? gfx::IntSize(1, 1) : aSize;
+  RefPtr<DrawTarget> target = Factory::CreateDrawTarget(gfxVars::ContentBackend(), size, SurfaceFormat::B8G8R8A8);
   RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(target);
   return ctx.forget();
 }
 
 NS_IMPL_ISUPPORTS_INHERITED0(HeadlessWidget, nsBaseWidget)
 
 nsresult
 HeadlessWidget::Create(nsIWidget* aParent,