Treat canvas invalidations as animation activity for JS heuristics, bug 753630. r=dmandelin
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 29 Jun 2012 14:35:06 -0700
changeset 100705 e8c20d4ba61a0cb6e545e14bf265283408b84ba8
parent 100704 9933d50de880821f51040e788cbc0963232f6c48
child 100706 47488847428f4fad4f7d348ba469caa2c719066f
push id1729
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 20:02:43 +0000
treeherdermozilla-aurora@f4e75e148951 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdmandelin
bugs753630
milestone16.0a1
Treat canvas invalidations as animation activity for JS heuristics, bug 753630. r=dmandelin
content/html/content/src/nsHTMLCanvasElement.cpp
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -674,16 +674,29 @@ nsHTMLCanvasElement::InvalidateCanvasCon
     invalRect = nsRect(nsPoint(0, 0), contentArea.Size());
   }
   invalRect.MoveBy(contentArea.TopLeft() - frame->GetPosition());
 
   Layer* layer = frame->InvalidateLayer(invalRect, nsDisplayItem::TYPE_CANVAS);
   if (layer) {
     static_cast<CanvasLayer*>(layer)->Updated();
   }
+
+  /*
+   * Treat canvas invalidations as animation activity for JS. Frequently
+   * invalidating a canvas will feed into heuristics and cause JIT code to be
+   * kept around longer, for smoother animations.
+   */
+  nsIScriptGlobalObject *scope = OwnerDoc()->GetScriptGlobalObject();
+  if (scope) {
+    JSObject *obj = scope->GetGlobalJSObject();
+    if (obj) {
+      js::NotifyAnimationActivity(obj);
+    }
+  }
 }
 
 void
 nsHTMLCanvasElement::InvalidateCanvas()
 {
   // We don't need to flush anything here; if there's no frame or if
   // we plan to reframe we don't need to invalidate it anyway.
   nsIFrame *frame = GetPrimaryFrame();