From 77b09771989874184cbe3884d5b93be5b9a61cbe Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Mon, 13 Aug 2012 22:10:10 +1200 Subject: [PATCH] Bug 539356 - Part 13 - Only repaint widgets that have had changes since the last paint. r=roc --- view/src/nsViewManager.cpp | 7 +++++-- widget/nsIWidget.h | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index e339e90a2b66..50e7970cf03e 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -23,6 +23,7 @@ #include "nsEventStateManager.h" #include "mozilla/StartupTimeline.h" #include "sampler.h" +#include "nsRefreshDriver.h" /** XXX TODO XXX @@ -377,7 +378,9 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // damage is applied based on the final widget geometry if (aFlushDirtyRegion) { nsIWidget *widget = aView->GetWidget(); - if (widget) { + if (widget && widget->NeedsPaint() && aView->HasNonEmptyDirtyRegion()) { + FlushDirtyRegionToWidget(aView); + SetPainting(true); #ifdef DEBUG_INVALIDATIONS printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); #endif @@ -386,8 +389,8 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, #ifdef DEBUG_INVALIDATIONS printf("---- PAINT END ----\n"); #endif + SetPainting(false); } - FlushDirtyRegionToWidget(aView); } } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index e03aaca87462..b4bfb119f865 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -409,6 +409,7 @@ class nsIWidget : public nsISupports { nsIWidget() : mLastChild(nullptr) , mPrevSibling(nullptr) + , mNeedsPaint(false) {} @@ -1593,6 +1594,9 @@ class nsIWidget : public nsISupports { */ virtual bool WidgetPaintsBackground() { return false; } + bool NeedsPaint() { + return true; + } /** * Get the natural bounds of this widget. This method is only * meaningful for widgets for which Gecko implements screen @@ -1643,6 +1647,7 @@ protected: nsIWidget* mLastChild; nsCOMPtr mNextSibling; nsIWidget* mPrevSibling; + bool mNeedsPaint; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)