OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 /** @typedef {!{ | 4 /** @typedef {!{ |
5 bounds: {height: number, width: number}, | 5 bounds: {height: number, width: number}, |
6 children: Array.<!TimelineModel.TracingLayerPayload>, | 6 children: Array.<!TimelineModel.TracingLayerPayload>, |
7 layer_id: number, | 7 layer_id: number, |
8 position: Array.<number>, | 8 position: Array.<number>, |
9 scroll_offset: Array.<number>, | 9 scroll_offset: Array.<number>, |
10 layer_quad: Array.<number>, | 10 layer_quad: Array.<number>, |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 | 380 |
381 /** | 381 /** |
382 * @param {!Array<number>} targetRect | 382 * @param {!Array<number>} targetRect |
383 * @return {!Promise<?SDK.SnapshotWithRect>} | 383 * @return {!Promise<?SDK.SnapshotWithRect>} |
384 */ | 384 */ |
385 _pictureForRect(targetRect) { | 385 _pictureForRect(targetRect) { |
386 return Promise.all(this._paints.map(paint => paint.picturePromise())).then(p ictures => { | 386 return Promise.all(this._paints.map(paint => paint.picturePromise())).then(p ictures => { |
387 var fragments = | 387 var fragments = |
388 pictures.filter(picture => picture && rectsOverlap(picture.rect, targe tRect)) | 388 pictures.filter(picture => picture && rectsOverlap(picture.rect, targe tRect)) |
389 .map(picture => ({x: picture.rect[0], y: picture.rect[1], picture: picture.serializedPicture})); | 389 .map(picture => ({x: picture.rect[0], y: picture.rect[1], picture: picture.serializedPicture})); |
390 if (!fragments.length || !this._target) | 390 var paintProfilerModel = this._target && this._target.model(SDK.PaintProfi lerModel); |
caseq1
2017/04/27 21:19:22
That's about the only place we needed target here,
dgozman
2017/04/28 00:07:33
Done.
| |
391 if (!fragments.length || !paintProfilerModel) | |
391 return null; | 392 return null; |
392 var x0 = fragments.reduce((min, item) => Math.min(min, item.x), Infinity); | 393 var x0 = fragments.reduce((min, item) => Math.min(min, item.x), Infinity); |
393 var y0 = fragments.reduce((min, item) => Math.min(min, item.y), Infinity); | 394 var y0 = fragments.reduce((min, item) => Math.min(min, item.y), Infinity); |
394 // Rect is in layer content coordinates, make it relative to picture by of fsetting to the top left corner. | 395 // Rect is in layer content coordinates, make it relative to picture by of fsetting to the top left corner. |
395 var rect = {x: targetRect[0] - x0, y: targetRect[1] - y0, width: targetRec t[2], height: targetRect[3]}; | 396 var rect = {x: targetRect[0] - x0, y: targetRect[1] - y0, width: targetRec t[2], height: targetRect[3]}; |
396 return SDK.PaintProfilerSnapshot.loadFromFragments(this._target, fragments ) | 397 return paintProfilerModel.loadSnapshotFromFragments(fragments).then( |
397 .then(snapshot => snapshot ? {rect: rect, snapshot: snapshot} : null); | 398 snapshot => snapshot ? {rect: rect, snapshot: snapshot} : null); |
398 }); | 399 }); |
399 | 400 |
400 /** | 401 /** |
401 * @param {number} a1 | 402 * @param {number} a1 |
402 * @param {number} a2 | 403 * @param {number} a2 |
403 * @param {number} b1 | 404 * @param {number} b1 |
404 * @param {number} b2 | 405 * @param {number} b2 |
405 * @return {boolean} | 406 * @return {boolean} |
406 */ | 407 */ |
407 function segmentsOverlap(a1, a2, b1, b2) { | 408 function segmentsOverlap(a1, a2, b1, b2) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 } | 469 } |
469 | 470 |
470 /** | 471 /** |
471 * @override | 472 * @override |
472 * @return {boolean} | 473 * @return {boolean} |
473 */ | 474 */ |
474 drawsContent() { | 475 drawsContent() { |
475 return this._drawsContent; | 476 return this._drawsContent; |
476 } | 477 } |
477 }; | 478 }; |
OLD | NEW |