Bug 1082745 - Avoid reoptimizing optimized SourceSurfaceCairos. r=bas, a=lmandel
authorMichael Wu <mwu@mozilla.com>
Wed, 15 Oct 2014 17:13:14 -0400
changeset 225774 5e3fc9d8a99b
parent 225773 47ef137f046f
child 225775 e57353855abf
push id4013
push userryanvm@gmail.com
push date2014-10-22 23:14 +0000
treeherdermozilla-beta@a963eab53a09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbas, lmandel
bugs1082745
milestone34.0
Bug 1082745 - Avoid reoptimizing optimized SourceSurfaceCairos. r=bas, a=lmandel
gfx/2d/DrawTargetCairo.cpp
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -1175,17 +1175,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;
   }