Index: Source/web/WebViewImpl.cpp |
diff --git a/Source/web/WebViewImpl.cpp b/Source/web/WebViewImpl.cpp |
index 7953fe0d40d6ba63f7c95b40434a740680f628e8..12d772c2df18c169a5363fd341ea73ac8f7032f9 100644 |
--- a/Source/web/WebViewImpl.cpp |
+++ b/Source/web/WebViewImpl.cpp |
@@ -80,10 +80,13 @@ |
#include "core/page/ScopedPageLoadDeferrer.h" |
#include "core/page/TouchDisambiguation.h" |
#include "core/rendering/FastTextAutosizer.h" |
+#include "core/rendering/RenderGeometryMap.h" |
#include "core/rendering/RenderView.h" |
#include "core/rendering/RenderWidget.h" |
#include "core/rendering/TextAutosizer.h" |
+#include "core/rendering/compositing/CompositedLayerMapping.h" |
#include "core/rendering/compositing/RenderLayerCompositor.h" |
+#include "core/timing/Performance.h" |
#include "modules/device_orientation/DeviceOrientationInspectorAgent.h" |
#include "modules/encryptedmedia/MediaKeysController.h" |
#include "modules/filesystem/InspectorFileSystemAgent.h" |
@@ -122,11 +125,13 @@ |
#include "public/web/WebActiveWheelFlingParameters.h" |
#include "public/web/WebAutofillClient.h" |
#include "public/web/WebBeginFrameArgs.h" |
+#include "public/web/WebFrame.h" |
#include "public/web/WebFrameClient.h" |
#include "public/web/WebHitTestResult.h" |
#include "public/web/WebInputElement.h" |
#include "public/web/WebMediaPlayerAction.h" |
#include "public/web/WebNode.h" |
+#include "public/web/WebPerformance.h" |
#include "public/web/WebPlugin.h" |
#include "public/web/WebPluginAction.h" |
#include "public/web/WebRange.h" |
@@ -1758,6 +1763,63 @@ void WebViewImpl::beginFrame(const WebBeginFrameArgs& frameTime) |
} |
} |
+static void findDrawFrameRequestRects(Page* page) |
+{ |
+ typedef WTF::HashMap<const GraphicsLayer*, |
+ std::vector<std::pair<int64_t, WebRect> > > |
+ GraphicsLayerDrawRects; |
+ |
+ GraphicsLayerDrawRects glRects; |
+ |
+ for (Frame* frame = page ? page->mainFrame() : 0; frame; |
+ frame = frame->tree().traverseNext()) { |
+ |
+ if (!frame->isLocalFrame()) |
+ continue; |
+ |
+ LocalFrame* localframe = toLocalFrame(frame); |
+ Document* document = localframe->document(); |
+ HTMLFrameOwnerElement* ownerElement = document->ownerElement(); |
+ |
+ const GraphicsLayer* graphicsLayer; |
+ |
+ // Find frame's rect in graphics layer space |
+ LayoutRect rect = |
+ localframe->contentRenderer()->rectForPaintInvalidation(); |
+ |
+ if (document->renderView()->enclosingLayer()->compositingState() |
+ == PaintsIntoOwnBacking || !ownerElement) { |
+ graphicsLayer = document->renderView()->enclosingLayer() |
+ ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
+ ->graphicsLayerBacking(); |
+ } else { |
+ graphicsLayer = ownerElement->renderer()->enclosingLayer() |
+ ->enclosingLayerForPaintInvalidationCrossingFrameBoundaries() |
+ ->graphicsLayerBacking(); |
+ |
+ RenderLayer::mapRectToPaintInvalidationBacking( |
+ ownerElement->renderer(), |
+ ownerElement->renderer()->containerForPaintInvalidation(), |
+ rect); |
+ } |
+ |
+ GraphicsLayerDrawRects::iterator glIter = glRects.find(graphicsLayer); |
+ std::vector<std::pair<int64_t, WebRect> > *glVector; |
+ if (glIter == glRects.end()) { |
+ glVector = &glRects.add(graphicsLayer, |
+ std::vector<std::pair<int64_t, WebRect> >()).storedValue->value; |
+ } else { |
+ glVector = &glIter->value; |
+ } |
+ glVector->push_back(std::make_pair(frame->frameID(), enclosingIntRect(rect))); |
+ } |
+ |
+ for (GraphicsLayerDrawRects::const_iterator iter = glRects.begin(); iter != glRects.end(); ++iter) { |
+ const GraphicsLayer* graphicsLayer = iter->key; |
+ graphicsLayer->platformLayer()->setDrawFrameRequestRects(iter->value); |
+ } |
+} |
+ |
void WebViewImpl::layout() |
{ |
TRACE_EVENT0("blink", "WebViewImpl::layout"); |
@@ -1770,6 +1832,8 @@ void WebViewImpl::layout() |
for (size_t i = 0; i < m_linkHighlights.size(); ++i) |
m_linkHighlights[i]->updateGeometry(); |
+ findDrawFrameRequestRects(m_page.get()); |
+ |
if (m_devToolsAgent) |
m_devToolsAgent->didLayout(); |
} |
@@ -4114,6 +4178,29 @@ void WebViewImpl::applyScrollAndScale(const WebSize& scrollDelta, float pageScal |
} |
} |
+void WebViewImpl::recordDrawTiming(int64_t FrameId, const WebVector<std::pair<int, double> >& draws) |
+{ |
+ if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
+ return; |
+ |
+ Frame* frame = m_page ? m_page->mainFrame() : 0; |
+ |
+ while (frame && frame->frameID() != FrameId) { |
+ frame = frame->tree().traverseNext(); |
+ } |
+ |
+ if (!frame) |
+ return; // ASSERT? Other way to report error? |
+ |
+ ASSERT(frame->isLocalFrame()); |
+ |
+ WebCore::LocalDOMWindow* domWindow = toLocalFrame(frame)->domWindow(); |
+ WebCore::Performance& performance = domWindow->performance(); |
+ for (size_t i = 0; i < draws.size(); ++i) { |
+ performance.addDrawTiming(domWindow->document(), draws[i].first, draws[i].second); |
+ } |
+} |
+ |
void WebViewImpl::updateLayerTreeViewport() |
{ |
if (!page() || !m_layerTreeView) |