Changeset 143000 in webkit


Ignore:
Timestamp:
Feb 15, 2013 7:56:51 AM (11 years ago)
Author:
aandrey@chromium.org
Message:

Web Inspector: [Canvas] show replay log grouped by draw calls
https://bugs.webkit.org/show_bug.cgi?id=109592

Reviewed by Pavel Feldman.

Source/WebCore:

Show canvas capturing log grouped by drawing calls.
Drive-by: extended Array.prototype with a handy peekLast function.
Drive-by: removed code dups in few places.

  • inspector/front-end/CanvasProfileView.js:

(WebInspector.CanvasProfileView):
(WebInspector.CanvasProfileView.prototype.dispose):
(WebInspector.CanvasProfileView.prototype._onReplayStepClick):
(WebInspector.CanvasProfileView.prototype._onReplayDrawingCallClick):
(WebInspector.CanvasProfileView.prototype._onReplayLastStepClick):
(WebInspector.CanvasProfileView.prototype._replayTraceLog.didReplayTraceLog):
(WebInspector.CanvasProfileView.prototype._replayTraceLog):
(WebInspector.CanvasProfileView.prototype._didReceiveTraceLog):
(WebInspector.CanvasProfileView.prototype._selectedCallIndex):
(WebInspector.CanvasProfileView.prototype._selectedDrawCallGroupIndex):
(WebInspector.CanvasProfileView.prototype._appendCallNode):

  • inspector/front-end/DataGrid.js:

(WebInspector.DataGrid.prototype.setColumnVisible):
(WebInspector.DataGridNode.prototype.set hasChildren):
(WebInspector.DataGridNode.prototype.set revealed):
(WebInspector.DataGridNode.prototype.get leftPadding):

  • inspector/front-end/externs.js:

(Array.prototype.peekLast):

  • inspector/front-end/utilities.js:

LayoutTests:

A test to dump canvas replay log.

  • inspector/profiler/canvas2d/canvas-replay-log-grid-expected.txt: Added.
  • inspector/profiler/canvas2d/canvas-replay-log-grid.html: Added.
Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142998 r143000  
     12013-02-15  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [Canvas] show replay log grouped by draw calls
     4        https://bugs.webkit.org/show_bug.cgi?id=109592
     5
     6        Reviewed by Pavel Feldman.
     7
     8        A test to dump canvas replay log.
     9
     10        * inspector/profiler/canvas2d/canvas-replay-log-grid-expected.txt: Added.
     11        * inspector/profiler/canvas2d/canvas-replay-log-grid.html: Added.
     12
    1132013-02-15  Vsevolod Vlasov  <vsevik@chromium.org>
    214
  • trunk/LayoutTests/platform/efl/TestExpectations

    r142993 r143000  
    16091609webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
    16101610webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
     1611webkit.org/b/73936 inspector/profiler/canvas2d/canvas-replay-log-grid.html
    16111612
    16121613# EFL port does not support Emacs commands.
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r142980 r143000  
    10401040webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html [ Failure ]
    10411041webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html [ Failure ]
     1042webkit.org/b/73936 inspector/profiler/canvas2d/canvas-replay-log-grid.html [ Failure ]
    10421043
    10431044webkit.org/b/37613 webkit.org/b/20011 printing [ Skip ]
  • trunk/LayoutTests/platform/mac/TestExpectations

    r142983 r143000  
    289289webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
    290290webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
     291webkit.org/b/73936 inspector/profiler/canvas2d/canvas-replay-log-grid.html
    291292
    292293# Skipping newly added tests while I'm finding out what is wrong.
  • trunk/LayoutTests/platform/qt/TestExpectations

    r142991 r143000  
    25072507webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
    25082508webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
     2509webkit.org/b/73936 inspector/profiler/canvas2d/canvas-replay-log-grid.html
    25092510
    25102511# [Qt] Unidentified pixel failures
  • trunk/LayoutTests/platform/win/TestExpectations

    r142947 r143000  
    13141314webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
    13151315webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
     1316webkit.org/b/73936 inspector/profiler/canvas2d/canvas-replay-log-grid.html
    13161317
    13171318# https://bugs.webkit.org/show_bug.cgi?id=40300
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r142883 r143000  
    18321832webkit.org/b/73936 inspector/profiler/canvas2d/canvas-has-uninstrumented-canvases.html
    18331833webkit.org/b/73936 inspector/profiler/canvas2d/canvas-stack-trace.html
     1834webkit.org/b/73936 inspector/profiler/canvas2d/canvas-replay-log-grid.html
    18341835
    18351836# https://bugs.webkit.org/show_bug.cgi?id=40300
  • trunk/Source/WebCore/ChangeLog

    r142999 r143000  
     12013-02-15  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [Canvas] show replay log grouped by draw calls
     4        https://bugs.webkit.org/show_bug.cgi?id=109592
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Show canvas capturing log grouped by drawing calls.
     9        Drive-by: extended Array.prototype with a handy peekLast function.
     10        Drive-by: removed code dups in few places.
     11
     12        * inspector/front-end/CanvasProfileView.js:
     13        (WebInspector.CanvasProfileView):
     14        (WebInspector.CanvasProfileView.prototype.dispose):
     15        (WebInspector.CanvasProfileView.prototype._onReplayStepClick):
     16        (WebInspector.CanvasProfileView.prototype._onReplayDrawingCallClick):
     17        (WebInspector.CanvasProfileView.prototype._onReplayLastStepClick):
     18        (WebInspector.CanvasProfileView.prototype._replayTraceLog.didReplayTraceLog):
     19        (WebInspector.CanvasProfileView.prototype._replayTraceLog):
     20        (WebInspector.CanvasProfileView.prototype._didReceiveTraceLog):
     21        (WebInspector.CanvasProfileView.prototype._selectedCallIndex):
     22        (WebInspector.CanvasProfileView.prototype._selectedDrawCallGroupIndex):
     23        (WebInspector.CanvasProfileView.prototype._appendCallNode):
     24        * inspector/front-end/DataGrid.js:
     25        (WebInspector.DataGrid.prototype.setColumnVisible):
     26        (WebInspector.DataGridNode.prototype.set hasChildren):
     27        (WebInspector.DataGridNode.prototype.set revealed):
     28        (WebInspector.DataGridNode.prototype.get leftPadding):
     29        * inspector/front-end/externs.js:
     30        (Array.prototype.peekLast):
     31        * inspector/front-end/utilities.js:
     32
    1332013-02-15  Yury Semikhatsky  <yurys@chromium.org>
    234
  • trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js

    r141883 r143000  
    7777    columns[1].sortable = true;
    7878    columns[1].width = "75%";
     79    columns[1].disclosure = true;
    7980    columns[2].title = WebInspector.UIString("Location");
    8081    columns[2].sortable = true;
     
    8889    /** @type {!Array.<WebInspector.DataGridNode>} */
    8990    this._logGridNodes = [];
     91    /** @type {!Array.<WebInspector.DataGridNode>} */
     92    this._drawCallGroups = [];
    9093
    9194    this._splitView.show(this.element);
     
    103106    {
    104107        this._logGridNodes = [];
     108        this._drawCallGroupNodes = [];
    105109        this._linkifier.reset();
    106110    },
     
    175179    _onReplayStepClick: function(forward)
    176180    {
    177         var selectedNode = this._logGrid.selectedNode;
    178         if (!selectedNode)
     181        var index = this._selectedCallIndex();
     182        if (index === -1)
    179183            return;
    180         var nextNode = forward ? selectedNode.traverseNextNode(false) : selectedNode.traversePreviousNode(false);
    181         if (nextNode)
    182             nextNode.revealAndSelect();
    183         else
    184             selectedNode.reveal();
     184        var nextNode = this._logGridNodes[forward ? index + 1 : index - 1] || this._logGridNodes[index];
     185        nextNode.revealAndSelect();
    185186    },
    186187
     
    190191    _onReplayDrawingCallClick: function(forward)
    191192    {
    192         var callNode = this._logGrid.selectedNode;
    193         if (!callNode)
     193        var index = this._selectedDrawCallGroupIndex();
     194        if (index === -1)
    194195            return;
    195         var index = callNode.index;
    196         do {
    197             var nextIndex = forward ? index + 1 : index - 1;
    198             var nextCallNode = this._logGridNodes[nextIndex];
    199             if (!nextCallNode)
    200                 break;
    201             index = nextIndex;
    202             callNode = nextCallNode;
    203         } while (!callNode.call.isDrawingCall);
    204         callNode.revealAndSelect();
     196        var nextNode = this._drawCallGroups[forward ? index + 1 : index - 1] || this._drawCallGroups[index];
     197        nextNode.revealAndSelect();
    205198    },
    206199
     
    214207    _onReplayLastStepClick: function()
    215208    {
    216         var children = this._logGrid.rootNode().children;
    217         var lastNode = children[children.length - 1];
     209        var lastNode = this._logGrid.rootNode().children.peekLast();
    218210        if (lastNode)
    219211            lastNode.revealAndSelect();
     
    246238    _replayTraceLog: function()
    247239    {
    248         var callNode = this._logGrid.selectedNode;
    249         if (!callNode)
     240        var index = this._selectedCallIndex();
     241        if (index === -1 || index === this._lastReplayCallIndex)
    250242            return;
     243        this._lastReplayCallIndex = index;
    251244        var time = Date.now();
    252245        /**
     
    256249        function didReplayTraceLog(error, resourceState)
    257250        {
    258             if (callNode !== this._logGrid.selectedNode)
     251            if (index !== this._selectedCallIndex())
    259252                return;
    260253
     
    271264        }
    272265        this._enableWaitIcon(true);
    273         CanvasAgent.replayTraceLog(this._traceLogId, callNode.index, didReplayTraceLog.bind(this));
     266        CanvasAgent.replayTraceLog(this._traceLogId, index, didReplayTraceLog.bind(this));
    274267    },
    275268
     
    283276        if (error || !traceLog)
    284277            return;
    285         var lastNode = null;
    286278        var calls = traceLog.calls;
    287279        for (var i = 0, n = calls.length; i < n; ++i) {
     
    290282            var index = traceLog.startOffset + i;
    291283            var gridNode = this._createCallNode(index, call);
    292             this._logGrid.rootNode().appendChild(gridNode);
    293             lastNode = gridNode;
    294         }
    295         if (lastNode)
    296             lastNode.revealAndSelect();
     284            this._appendCallNode(gridNode);
     285        }
    297286        if (traceLog.alive)
    298287            setTimeout(this._requestTraceLog.bind(this), WebInspector.CanvasProfileView.TraceLogPollingInterval);
    299288        this._profile._updateCapturingStatus(traceLog);
     289        this._onReplayLastStepClick(); // Automatically replay the last step.
    300290    },
    301291
     
    327317        }
    328318        CanvasAgent.getResourceInfo(contextId, didReceiveResourceInfo.bind(this));
     319    },
     320
     321    /**
     322     * @return {number}
     323     */
     324    _selectedCallIndex: function()
     325    {
     326        var node = this._logGrid.selectedNode;
     327        while (node) {
     328            if (typeof node.index === "number")
     329                return node.index;
     330            node = node.children.peekLast();
     331        }
     332        return -1;
     333    },
     334
     335    /**
     336     * @return {number}
     337     */
     338    _selectedDrawCallGroupIndex: function()
     339    {
     340        for (var node = this._logGrid.selectedNode; node; node = node.children.peekLast()) {
     341            if (typeof node.drawCallGroupIndex === "number")
     342                return node.drawCallGroupIndex;
     343        }
     344        for (var node = this._logGrid.selectedNode; node; node = node.parent) {
     345            if (typeof node.drawCallGroupIndex === "number")
     346                return node.drawCallGroupIndex;
     347        }
     348        return -1;
     349    },
     350
     351    /**
     352     * @param {!WebInspector.DataGridNode} gridNode
     353     */
     354    _appendCallNode: function(gridNode)
     355    {
     356        var drawCallGroup = this._drawCallGroups.peekLast();
     357        if (drawCallGroup) {
     358            var lastNode = drawCallGroup.children.peekLast();
     359            if (lastNode && lastNode.call.isDrawingCall)
     360                drawCallGroup = null;
     361        }
     362        if (!drawCallGroup) {
     363            var index = this._drawCallGroups.length;
     364            var data = {};
     365            data[0] = "";
     366            data[1] = "Draw call group #" + (index + 1);
     367            data[2] = "";
     368            drawCallGroup = new WebInspector.DataGridNode(data);
     369            drawCallGroup.selectable = true;
     370            drawCallGroup.drawCallGroupIndex = index;
     371            this._drawCallGroups.push(drawCallGroup);
     372            this._logGrid.rootNode().appendChild(drawCallGroup);
     373        }
     374        drawCallGroup.appendChild(gridNode);
    329375    },
    330376
  • trunk/Source/WebCore/inspector/front-end/DataGrid.js

    r142976 r143000  
    629629
    630630        this.columns[columnIdentifier].hidden = !visible;
    631         if (visible)
    632             this.element.removeStyleClass("hide-" + columnIdentifier + "-column");
    633         else
    634             this.element.addStyleClass("hide-" + columnIdentifier + "-column");
     631        this.element.enableStyleClass("hide-" + columnIdentifier + "-column", !visible);
    635632    },
    636633
     
    11501147            return;
    11511148
    1152         if (this._hasChildren)
    1153         {
    1154             this._element.addStyleClass("parent");
    1155             if (this.expanded)
    1156                 this._element.addStyleClass("expanded");
    1157         }
    1158         else
    1159         {
    1160             this._element.removeStyleClass("parent");
    1161             this._element.removeStyleClass("expanded");
    1162         }
     1149        this._element.enableStyleClass("parent", this._hasChildren);
     1150        this._element.enableStyleClass("expanded", this._hasChildren && this.expanded);
    11631151    },
    11641152
     
    11751163        this._revealed = x;
    11761164
    1177         if (this._element) {
    1178             if (this._revealed)
    1179                 this._element.addStyleClass("revealed");
    1180             else
    1181                 this._element.removeStyleClass("revealed");
    1182         }
     1165        if (this._element)
     1166            this._element.enableStyleClass("revealed", this._revealed);
    11831167
    11841168        for (var i = 0; i < this.children.length; ++i)
     
    11991183    get leftPadding()
    12001184    {
    1201         if (typeof(this._leftPadding) === "number")
     1185        if (typeof this._leftPadding === "number")
    12021186            return this._leftPadding;
    12031187       
     
    16351619    },
    16361620
     1621    /**
     1622     * @return {boolean}
     1623     */
    16371624    isEventWithinDisclosureTriangle: function(event)
    16381625    {
  • trunk/Source/WebCore/inspector/front-end/externs.js

    r142603 r143000  
    129129 */
    130130Array.prototype.select = function(field) {}
     131
     132/**
     133 * @this {Array.<*>}
     134 * @return {*}
     135 */
     136Array.prototype.peekLast = function() {}
    131137
    132138DOMApplicationCache.prototype.UNCACHED = 0;
  • trunk/Source/WebCore/inspector/front-end/utilities.js

    r142128 r143000  
    428428});
    429429
     430Object.defineProperty(Array.prototype, "peekLast",
     431{
     432    /**
     433     * @this {Array.<*>}
     434     * @return {*}
     435     */
     436    value: function()
     437    {
     438        return this[this.length - 1];
     439    }
     440});
     441
    430442/**
    431443 * @param {*} anObject
Note: See TracChangeset for help on using the changeset viewer.