Bug 1082745 - Avoid reoptimizing optimized SourceSurfaceCairos, r=bas
authorMichael Wu <mwu@mozilla.com>
Wed, 15 Oct 2014 17:13:14 -0400
changeset 210613 f013910bbead6cad6f72a56dcc714cdf9e7b2991
parent 210612 aaac8c67129941d2a969ed0df7c76eb30dacd789
child 210614 64bba06a6154f15c2c2b23f781b07fefebe7b87b
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbas
bugs1082745
milestone36.0a1
Bug 1082745 - Avoid reoptimizing optimized SourceSurfaceCairos, r=bas
gfx/2d/DrawTargetCairo.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -1270,17 +1270,24 @@ DestroyPixmap(void *data)
   delete static_cast<DestroyPixmapClosure*>(data);
 }
 #endif
 
 TemporaryRef<SourceSurface>
 DrawTargetCairo::OptimizeSourceSurface(SourceSurface *aSurface) const
 {
 #ifdef CAIRO_HAS_XLIB_SURFACE
-  if (cairo_surface_get_type(mSurface) != CAIRO_SURFACE_TYPE_XLIB) {
+  cairo_surface_type_t ctype = cairo_surface_get_type(mSurface);
+  if (aSurface->GetType() == SurfaceType::CAIRO &&
+      cairo_surface_get_type(
+        static_cast<SourceSurfaceCairo*>(aSurface)->GetSurface()) == ctype) {
+    return aSurface;
+  }
+
+  if (ctype != CAIRO_SURFACE_TYPE_XLIB) {
     return aSurface;
   }
 
   IntSize size = aSurface->GetSize();
   if (!size.width || !size.height) {
     return aSurface;
   }