Bug 539356 - Part 6 - Add compositing paint flashing to BasicLayers. r=roc
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 11 Jun 2012 16:44:08 +1200
changeset 101166 eec8ef3ebe480d31ac5e7eab56e076cceff2b6a5
parent 101165 f7f29fcd1845c510db3e53bc8f13a9ede25917e9
child 101167 4859876972f37b60ed16d8c9ee80a367bc15c953
push id1316
push userakeybl@mozilla.com
push dateMon, 27 Aug 2012 22:37:00 +0000
treeherdermozilla-beta@db4b09302ee2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs539356
milestone16.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 539356 - Part 6 - Add compositing paint flashing to BasicLayers. r=roc
gfx/layers/basic/BasicLayers.cpp
gfx/layers/basic/BasicLayers.h
modules/libpref/src/init/all.js
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -6,16 +6,17 @@
 #include "mozilla/Attributes.h"
 
 #include "gfxSharedImageSurface.h"
 
 #include "mozilla/layers/PLayerChild.h"
 #include "mozilla/layers/PLayersChild.h"
 #include "mozilla/layers/PLayersParent.h"
 #include "mozilla/gfx/2D.h"
+#include "mozilla/Preferences.h"
 
 #include "ipc/ShadowLayerChild.h"
 
 #include "BasicLayers.h"
 #include "BasicImplData.h"
 #include "BasicTiledThebesLayer.h"
 #include "ImageLayers.h"
 #include "RenderTrace.h"
@@ -1671,16 +1672,19 @@ BasicLayerManager::EndTransactionInterna
       nsIntRegion region;
       MarkLayersHidden(mRoot, clipRect, clipRect, region, ALLOW_OPAQUE);
       if (mUsingDefaultTarget && mDoubleBuffering != BUFFER_NONE) {
         ApplyDoubleBuffering(mRoot, clipRect);
       }
     }
 
     PaintLayer(mTarget, mRoot, aCallback, aCallbackData, nsnull);
+    if (mWidget) {
+      FlashWidgetUpdateArea(mTarget);
+    }
 
     if (!mTransactionIncomplete) {
       // Clear out target if we have a complete transaction.
       mTarget = nsnull;
     }
   }
 
 #ifdef MOZ_LAYERS_HAVE_LOG
@@ -1701,16 +1705,37 @@ BasicLayerManager::EndTransactionInterna
                "If callback is not null, transaction must be complete");
 
   // XXX - We should probably assert here that for an incomplete transaction
   // out target is the default target.
 
   return !mTransactionIncomplete;
 }
 
+void
+BasicLayerManager::FlashWidgetUpdateArea(gfxContext *aContext)
+{
+  static bool sWidgetFlashingEnabled;
+  static bool sWidgetFlashingPrefCached = false;
+
+  if (!sWidgetFlashingPrefCached) {
+    sWidgetFlashingPrefCached = true;
+    mozilla::Preferences::AddBoolVarCache(&sWidgetFlashingEnabled,
+                                          "nglayout.debug.widget_update_flashing");
+  }
+
+  if (sWidgetFlashingEnabled) {
+    float r = float(rand()) / RAND_MAX;
+    float g = float(rand()) / RAND_MAX;
+    float b = float(rand()) / RAND_MAX;
+    aContext->SetColor(gfxRGBA(r, g, b, 0.2));
+    aContext->Paint();
+  }
+}
+
 bool
 BasicLayerManager::EndEmptyTransaction()
 {
   if (!mRoot) {
     return false;
   }
 
   return EndTransactionInternal(nsnull, nsnull);
--- a/gfx/layers/basic/BasicLayers.h
+++ b/gfx/layers/basic/BasicLayers.h
@@ -167,16 +167,18 @@ protected:
 
   // Clear the contents of a layer
   void ClearLayer(Layer* aLayer);
 
   bool EndTransactionInternal(DrawThebesLayerCallback aCallback,
                               void* aCallbackData,
                               EndTransactionFlags aFlags = END_DEFAULT);
 
+  void FlashWidgetUpdateArea(gfxContext* aContext);
+
   // Widget whose surface should be used as the basis for ThebesLayer
   // buffers.
   nsIWidget* mWidget;
   // The default context for BeginTransaction.
   nsRefPtr<gfxContext> mDefaultTarget;
   // The context to draw into.
   nsRefPtr<gfxContext> mTarget;
   // A context we want our shadow to draw into.
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -334,16 +334,20 @@ pref("view_source.editor.args", "");
 pref("nglayout.events.dispatchLeftClickOnly", true);
 
 // whether or not to draw images while dragging
 pref("nglayout.enable_drag_images", true);
 
 // enable/disable paint flashing --- useful for debugging
 pref("nglayout.debug.paint_flashing", false);
 
+// enable/disable widget update area flashing --- only supported with 
+// BasicLayers (other layer managers always update the entire widget area)
+pref("nglayout.debug.widget_update_flashing", false);
+
 // scrollbar snapping region
 // 0 - off
 // 1 and higher - slider thickness multiple
 pref("slider.snapMultiplier", 0);
 
 // option to choose plug-in finder
 pref("application.use_ns_plugin_finder", false);