OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * @param {!WebInspector.LayerTreeModel} model | 33 * @param {!WebInspector.LayerTreeModel} model |
34 * @param {!WebInspector.Layers3DView} layers3DView | 34 * @param {!WebInspector.Layers3DView} layers3DView |
35 * @extends {WebInspector.VBox} | 35 * @extends {WebInspector.PanelWithSidebarTree} |
caseq
2014/06/05 11:14:24
You can't make it a panel, since it's not really a
malch
2014/06/05 12:41:09
Done.
| |
36 */ | 36 */ |
37 WebInspector.PaintProfilerView = function(model, layers3DView) | 37 WebInspector.PaintProfilerView = function(model, layers3DView) |
38 { | 38 { |
39 WebInspector.VBox.call(this); | 39 WebInspector.PanelWithSidebarTree.call(this, "paint-profiler-view", 225); |
40 this.element.classList.add("paint-profiler-view"); | 40 this.sidebarElement().classList.add("outline-disclosure"); |
41 this._panelSplitView.addEventListener(WebInspector.SplitView.Events.SidebarS izeChanged, this.onResize, this); | |
41 | 42 |
42 this._model = model; | 43 this._model = model; |
43 this._layers3DView = layers3DView; | 44 this._layers3DView = layers3DView; |
44 | 45 |
45 this._canvas = this.element.createChild("canvas", "fill"); | 46 this._canvas = this.mainElement().createChild("canvas", "fill"); |
46 this._context = this._canvas.getContext("2d"); | 47 this._context = this._canvas.getContext("2d"); |
47 this._selectionWindow = new WebInspector.OverviewGrid.Window(this.element, t his.element); | 48 this._selectionWindow = new WebInspector.OverviewGrid.Window(this.mainElemen t(), this.mainElement()); |
48 this._selectionWindow.addEventListener(WebInspector.OverviewGrid.Events.Wind owChanged, this._onWindowChanged, this); | 49 this._selectionWindow.addEventListener(WebInspector.OverviewGrid.Events.Wind owChanged, this._onWindowChanged, this); |
49 | 50 |
50 this._innerBarWidth = 4 * window.devicePixelRatio; | 51 this._innerBarWidth = 4 * window.devicePixelRatio; |
51 this._minBarHeight = 4 * window.devicePixelRatio; | 52 this._minBarHeight = 4 * window.devicePixelRatio; |
52 this._barPaddingWidth = 2 * window.devicePixelRatio; | 53 this._barPaddingWidth = 2 * window.devicePixelRatio; |
53 this._outerBarWidth = this._innerBarWidth + this._barPaddingWidth; | 54 this._outerBarWidth = this._innerBarWidth + this._barPaddingWidth; |
54 | 55 |
55 this._reset(); | 56 this._reset(); |
56 } | 57 } |
57 | 58 |
58 WebInspector.PaintProfilerView.prototype = { | 59 WebInspector.PaintProfilerView.prototype = { |
59 onResize: function() | 60 onResize: function() |
60 { | 61 { |
61 this._update(); | 62 this._update(); |
62 }, | 63 }, |
63 | 64 |
64 _update: function() | 65 _update: function() |
65 { | 66 { |
66 this._canvas.width = this.element.clientWidth * window.devicePixelRatio; | 67 this._canvas.width = this.mainElement().clientWidth * window.devicePixel Ratio; |
67 this._canvas.height = this.element.clientHeight * window.devicePixelRati o; | 68 this._canvas.height = this.mainElement().clientHeight * window.devicePix elRatio; |
68 this._samplesPerBar = 0; | 69 this._samplesPerBar = 0; |
69 if (!this._profiles || !this._profiles.length) | 70 if (!this._profiles || !this._profiles.length) |
70 return; | 71 return; |
71 | 72 |
72 var maxBars = Math.floor((this._canvas.width - 2 * this._barPaddingWidth ) / this._outerBarWidth); | 73 var maxBars = Math.floor((this._canvas.width - 2 * this._barPaddingWidth ) / this._outerBarWidth); |
73 var sampleCount = this._profiles[0].length; | 74 var sampleCount = this._profiles[0].length; |
74 this._samplesPerBar = Math.ceil(sampleCount / maxBars); | 75 this._samplesPerBar = Math.ceil(sampleCount / maxBars); |
75 var barCount = Math.floor(sampleCount / this._samplesPerBar); | 76 var barCount = Math.floor(sampleCount / this._samplesPerBar); |
76 | 77 |
77 var maxBarTime = 0; | 78 var maxBarTime = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 124 |
124 var screenLeft = this._selectionWindow.windowLeft * this._canvas.width; | 125 var screenLeft = this._selectionWindow.windowLeft * this._canvas.width; |
125 var screenRight = this._selectionWindow.windowRight * this._canvas.width ; | 126 var screenRight = this._selectionWindow.windowRight * this._canvas.width ; |
126 | 127 |
127 var barLeft = Math.floor((screenLeft - this._barPaddingWidth) / this._ou terBarWidth); | 128 var barLeft = Math.floor((screenLeft - this._barPaddingWidth) / this._ou terBarWidth); |
128 var barRight = Math.floor((screenRight - this._barPaddingWidth + this._i nnerBarWidth)/ this._outerBarWidth); | 129 var barRight = Math.floor((screenRight - this._barPaddingWidth + this._i nnerBarWidth)/ this._outerBarWidth); |
129 | 130 |
130 var stepLeft = Math.max(0, barLeft * this._samplesPerBar); | 131 var stepLeft = Math.max(0, barLeft * this._samplesPerBar); |
131 var stepRight = Math.min(barRight * this._samplesPerBar, this._profiles[ 0].length); | 132 var stepRight = Math.min(barRight * this._samplesPerBar, this._profiles[ 0].length); |
132 this._snapshot.requestImage(stepLeft, stepRight, this._layers3DView.show ImageForLayer.bind(this._layers3DView, this._layer)); | 133 this._snapshot.requestImage(stepLeft, stepRight, this._layers3DView.show ImageForLayer.bind(this._layers3DView, this._layer)); |
134 this._updateLog(stepLeft, stepRight); | |
135 }, | |
136 | |
137 /** | |
138 * @param {number=} stepLeft | |
139 * @param {number=} stepRight | |
140 */ | |
141 _updateLog: function(stepLeft, stepRight) | |
142 { | |
143 var log = this._log; | |
144 stepLeft = stepLeft || 0; | |
145 stepRight = stepRight || log.length - 1; | |
146 this.sidebarTree.removeChildren(); | |
147 for (var i = stepLeft; i <= stepRight; ++i) { | |
148 var node = new WebInspector.LogTreeElement(log[i]); | |
149 this.sidebarTree.appendChild(node); | |
150 } | |
133 }, | 151 }, |
134 | 152 |
135 _reset: function() | 153 _reset: function() |
136 { | 154 { |
137 this._snapshot = null; | 155 this._snapshot = null; |
138 this._profiles = null; | 156 this._profiles = null; |
139 this._selectionWindow.reset(); | 157 this._selectionWindow.reset(); |
140 }, | 158 }, |
141 | 159 |
142 /** | 160 /** |
(...skipping 11 matching lines...) Expand all Loading... | |
154 */ | 172 */ |
155 function onSnapshotDone(snapshot) | 173 function onSnapshotDone(snapshot) |
156 { | 174 { |
157 this._snapshot = snapshot; | 175 this._snapshot = snapshot; |
158 if (!snapshot) { | 176 if (!snapshot) { |
159 this._profiles = null; | 177 this._profiles = null; |
160 this._update(); | 178 this._update(); |
161 return; | 179 return; |
162 } | 180 } |
163 snapshot.requestImage(null, null, this._layers3DView.showImageForLay er.bind(this._layers3DView, this._layer)); | 181 snapshot.requestImage(null, null, this._layers3DView.showImageForLay er.bind(this._layers3DView, this._layer)); |
164 snapshot.profile(onProfileDone.bind(this)); | 182 snapshot.profile(onProfileDone.bind(this, snapshot)); |
165 } | 183 } |
166 | 184 |
167 /** | 185 /** |
186 * @param {!WebInspector.PaintProfilerSnapshot=} snapshot | |
168 * @param {!Array.<!LayerTreeAgent.PaintProfile>=} profiles | 187 * @param {!Array.<!LayerTreeAgent.PaintProfile>=} profiles |
169 * @this {WebInspector.PaintProfilerView} | 188 * @this {WebInspector.PaintProfilerView} |
170 */ | 189 */ |
171 function onProfileDone(profiles) | 190 function onProfileDone(snapshot, profiles) |
172 { | 191 { |
173 this._profiles = profiles; | 192 this._profiles = profiles; |
193 snapshot.commandLog(onCommandLogDone.bind(this)); | |
194 } | |
195 | |
196 /** | |
197 * @param {!Array.<!Object>=} log | |
198 * @this {WebInspector.PaintProfilerView} | |
199 */ | |
200 function onCommandLogDone(log) | |
201 { | |
202 this._log = log; | |
203 this._updateLog(); | |
174 this._update(); | 204 this._update(); |
175 } | 205 } |
176 }, | 206 }, |
177 | 207 |
178 __proto__: WebInspector.VBox.prototype | 208 __proto__: WebInspector.PanelWithSidebarTree.prototype |
179 }; | 209 }; |
210 | |
211 /** | |
212 * @constructor | |
213 * @param {!Object} logItem | |
214 * @extends {TreeElement} | |
215 */ | |
216 WebInspector.LogTreeElement = function(logItem) | |
217 { | |
218 TreeElement.call(this, "", logItem); | |
219 this._update(); | |
220 } | |
221 | |
222 WebInspector.LogTreeElement.prototype = { | |
223 /** | |
224 * @param {!Object} param | |
225 * @param {string} name | |
226 * @return {string} | |
227 */ | |
228 _paramToString: function(param, name) | |
229 { | |
230 if (typeof param !== "object") | |
231 return typeof param === "string" && param.length > 100 ? name : JSON .stringify(param); | |
232 var str = ""; | |
233 var keyCount = 0; | |
234 for (var key in param) { | |
235 if (++keyCount > 4 || typeof param[key] === "object" || (typeof para m[key] === "string" && param[key].length > 100)) | |
236 return name; | |
237 if (str) | |
238 str += ", "; | |
239 str += param[key]; | |
240 } | |
241 return str; | |
242 }, | |
243 | |
244 /** | |
245 * @param {!Object} params | |
246 * @return {string} | |
247 */ | |
248 _paramsToString: function(params) | |
249 { | |
250 var str = ""; | |
251 for (var key in params) { | |
252 if (str) | |
253 str += ", "; | |
254 str += this._paramToString(params[key], key); | |
255 } | |
256 return str; | |
257 }, | |
258 | |
259 _update: function() | |
260 { | |
261 var logItem = (this.representedObject); | |
caseq
2014/06/05 11:14:24
remove redundant brackets
malch
2014/06/05 12:41:09
Done.
| |
262 var title = document.createDocumentFragment(); | |
263 title.textContent = logItem.method; | |
264 if (logItem.params) | |
265 title.textContent += "(" + this._paramsToString(logItem.params) + ") "; | |
266 this.title = title; | |
267 }, | |
268 | |
269 __proto__: TreeElement.prototype | |
270 }; | |
OLD | NEW |