Bug 1255320 - Create DrawTarget with DIB as similar DrawTarget r=jrmuizel
authorSotaro Ikeda <sotaro.ikeda.g@gmail.com>
Sun, 13 Mar 2016 19:46:23 -0700
changeset 339901 0ce67740545443ec87c0afd2d3d8b146dc517466
parent 339874 f0c0480732d36153e8839c7f17394d45f679f87d
child 339902 48adfd045db5e7ee610408b2014ca74c845fced3
push id12823
push userjmaher@mozilla.com
push dateMon, 14 Mar 2016 10:52:22 +0000
reviewersjrmuizel
bugs1255320
milestone48.0a1
Bug 1255320 - Create DrawTarget with DIB as similar DrawTarget r=jrmuizel
gfx/2d/DrawTargetCairo.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -1744,19 +1744,28 @@ DrawTargetCairo::CreateSimilarDrawTarget
 {
   if (cairo_surface_status(cairo_get_group_target(mContext))) {
     RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
     if (target->Init(aSize, aFormat)) {
       return target.forget();
     }
   }
 
-  cairo_surface_t* similar = cairo_surface_create_similar(mSurface,
-                                                          GfxFormatToCairoContent(aFormat),
-                                                          aSize.width, aSize.height);
+  cairo_surface_t* similar;
+#ifdef CAIRO_HAS_WIN32_SURFACE
+  if (cairo_surface_get_type(mSurface) == CAIRO_SURFACE_TYPE_WIN32) {
+    similar = cairo_win32_surface_create_with_dib(GfxFormatToCairoFormat(aFormat),
+                                                  aSize.width, aSize.height);
+  } else
+#endif
+  {
+    similar = cairo_surface_create_similar(mSurface,
+                                           GfxFormatToCairoContent(aFormat),
+                                           aSize.width, aSize.height);
+  }
 
   if (!cairo_surface_status(similar)) {
     RefPtr<DrawTargetCairo> target = new DrawTargetCairo();
     if (target->InitAlreadyReferenced(similar, aSize)) {
       return target.forget();
     }
   }