diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 11368434416..6e495ebf917 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -164,6 +164,7 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) // If this is a new paint, increment the paint sequence number. if (!mIsRepeatTransaction) { ++mPaintSequenceNumber; + mApzTestData.StartNewPaint(mPaintSequenceNumber); } } diff --git a/gfx/layers/client/ClientLayerManager.h b/gfx/layers/client/ClientLayerManager.h index 9eb36aff101..cfc3e5c88eb 100644 --- a/gfx/layers/client/ClientLayerManager.h +++ b/gfx/layers/client/ClientLayerManager.h @@ -16,6 +16,7 @@ #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/LayersTypes.h" // for BufferMode, LayersBackend, etc #include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder, etc +#include "mozilla/layers/APZTestData.h" // for APZTestData #include "nsAutoPtr.h" // for nsRefPtr #include "nsCOMPtr.h" // for already_AddRefed #include "nsDebug.h" // for NS_ABORT_IF_FALSE @@ -172,6 +173,31 @@ public: return (GetTextureFactoryIdentifier().mSupportedBlendModes & aMixBlendModes) == aMixBlendModes; } + // Log APZ test data for the current paint. We supply the paint sequence + // number ourselves, and take care of calling APZTestData::StartNewPaint() + // when a new paint is started. + void LogTestDataForCurrentPaint(FrameMetrics::ViewID aScrollId, + const std::string& aKey, + const std::string& aValue) + { + mApzTestData.LogTestDataForPaint(mPaintSequenceNumber, aScrollId, aKey, aValue); + } + + // Log APZ test data for a repaint request. The sequence number must be + // passed in from outside, and APZTestData::StartNewRepaintRequest() needs + // to be called from the outside as well when a new repaint request is started. + void StartNewRepaintRequest(SequenceNumber aSequenceNumber) + { + mApzTestData.StartNewRepaintRequest(aSequenceNumber); + } + void LogTestDataForRepaintRequest(SequenceNumber aSequenceNumber, + FrameMetrics::ViewID aScrollId, + const std::string& aKey, + const std::string& aValue) + { + mApzTestData.LogTestDataForRepaintRequest(aSequenceNumber, aScrollId, aKey, aValue); + } + protected: enum TransactionPhase { PHASE_NONE, PHASE_CONSTRUCTION, PHASE_DRAWING, PHASE_FORWARD @@ -236,6 +262,8 @@ private: // Incremented in BeginTransaction(), but not for repeat transactions. uint32_t mPaintSequenceNumber; + APZTestData mApzTestData; + RefPtr mForwarder; nsAutoTArray,2> mTexturePools; nsAutoTArray mOverfillCallbacks; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index a1ed129e149..b31ee752a52 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -77,6 +77,7 @@ #include "mozilla/LookAndFeel.h" #include "UnitTransforms.h" #include "TiledLayerBuffer.h" // For TILEDLAYERBUFFER_TILE_SIZE +#include "ClientLayerManager.h" #include "mozilla/Preferences.h" @@ -6514,7 +6515,21 @@ nsLayoutUtils::WantSubAPZC() } #endif return wantSubAPZC; - } +} + +/* static */ void +nsLayoutUtils::LogTestDataForPaint(nsIPresShell* aPresShell, + ViewID aScrollId, + const std::string& aKey, + const std::string& aValue) +{ + nsRefPtr lm = aPresShell->GetPresContext()->GetRootPresContext() + ->GetPresShell()->GetLayerManager(); + if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) { + static_cast(lm.get())->LogTestDataForCurrentPaint(aScrollId, aKey, aValue); + } +} + nsLayoutUtils::SurfaceFromElementResult::SurfaceFromElementResult() // Use safe default values here diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 2839fe2c0aa..29e1ad988de 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -26,6 +26,7 @@ #include "imgIContainer.h" #include "mozilla/gfx/2D.h" #include "Units.h" +#include "mozilla/ToString.h" #include #include @@ -2170,6 +2171,34 @@ public: */ static bool WantSubAPZC(); + /** + * Log a key/value pair for APZ testing during a paint. + * @param aPresShell The pres shell that identifies where to log to. The data + * will be written to the APZTestData associated with the + * pres shell's layer manager. + * @param aScrollId Identifies the scroll frame to which the data pertains. + * @param aKey The key under which to log the data. + * @param aValue The value of the data to be logged. + */ + static void LogTestDataForPaint(nsIPresShell* aPresShell, + ViewID aScrollId, + const std::string& aKey, + const std::string& aValue); + + /** + * A convenience overload of LogTestDataForPaint() that accepts any type + * as the value, and passes it through mozilla::ToString() to obtain a string + * value. The type passed must support streaming to an std::ostream. + */ + template + static void LogTestDataForPaint(nsIPresShell* aPresShell, + ViewID aScrollId, + const std::string& aKey, + const Value& aValue) { + LogTestDataForPaint(aPresShell, aScrollId, aKey, + mozilla::ToString(aValue)); + } + /** * Get the display port for |aScrollFrame|'s content. If |aScrollFrame| * WantsAsyncScroll() and we don't have a scrollable displayport yet (as