diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-05 17:34:47 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-03-06 10:04:14 +0000 |
commit | eaf1da4d961fbbda9455f9af3b23d1af777f43fa (patch) | |
tree | 95970599ecee31c4f7f940bc97ac98c61a3d0cad /chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html | |
parent | 38a9a29f4f9436cace7f0e7abf9c586057df8a4e (diff) |
BASELINE: Update Chromium to 73.0.3683.64
Change-Id: I76517dc277ba4e16bfd7e098fda3d079656b3b9f
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html')
-rw-r--r-- | chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html b/chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html new file mode 100644 index 00000000000..36126f898db --- /dev/null +++ b/chromium/third_party/catapult/tracing/tracing/ui/timeline_interest_range.html @@ -0,0 +1,249 @@ +<!DOCTYPE html> +<!-- +Copyright (c) 2014 The Chromium Authors. All rights reserved. +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<link rel="import" href="/tracing/base/math/range.html"> + +<script> +'use strict'; + +tr.exportTo('tr.ui', function() { + /** + * @constructor + */ + function SnapIndicator(y, height) { + this.y = y; + this.height = height; + } + + /** + * The interesting part of the world. + * + * @constructor + */ + function TimelineInterestRange(vp) { + this.viewport_ = vp; + + this.range_ = new tr.b.math.Range(); + + this.leftSelected_ = false; + this.rightSelected_ = false; + + this.leftSnapIndicator_ = undefined; + this.rightSnapIndicator_ = undefined; + } + + TimelineInterestRange.prototype = { + get isEmpty() { + return this.range_.isEmpty; + }, + + reset() { + this.range_.reset(); + this.leftSelected_ = false; + this.rightSelected_ = false; + this.leftSnapIndicator_ = undefined; + this.rightSnapIndicator_ = undefined; + this.viewport_.dispatchChangeEvent(); + }, + + get min() { + return this.range_.min; + }, + + set min(min) { + this.range_.min = min; + this.viewport_.dispatchChangeEvent(); + }, + + get max() { + return this.range_.max; + }, + + set max(max) { + this.range_.max = max; + this.viewport_.dispatchChangeEvent(); + }, + + set(range) { + this.range_.reset(); + this.range_.addRange(range); + this.viewport_.dispatchChangeEvent(); + }, + + setMinAndMax(min, max) { + this.range_.min = min; + this.range_.max = max; + this.viewport_.dispatchChangeEvent(); + }, + + get range() { + return this.range_.range; + }, + + asRangeObject() { + const range = new tr.b.math.Range(); + range.addRange(this.range_); + return range; + }, + + get leftSelected() { + return this.leftSelected_; + }, + + set leftSelected(leftSelected) { + if (this.leftSelected_ === leftSelected) return; + + this.leftSelected_ = leftSelected; + this.viewport_.dispatchChangeEvent(); + }, + + get rightSelected() { + return this.rightSelected_; + }, + + set rightSelected(rightSelected) { + if (this.rightSelected_ === rightSelected) return; + + this.rightSelected_ = rightSelected; + this.viewport_.dispatchChangeEvent(); + }, + + get leftSnapIndicator() { + return this.leftSnapIndicator_; + }, + + set leftSnapIndicator(leftSnapIndicator) { + this.leftSnapIndicator_ = leftSnapIndicator; + this.viewport_.dispatchChangeEvent(); + }, + + get rightSnapIndicator() { + return this.rightSnapIndicator_; + }, + + set rightSnapIndicator(rightSnapIndicator) { + this.rightSnapIndicator_ = rightSnapIndicator; + this.viewport_.dispatchChangeEvent(); + }, + + draw(ctx, viewLWorld, viewRWorld, viewHeight) { + if (this.range_.isEmpty) return; + + const dt = this.viewport_.currentDisplayTransform; + + const markerLWorld = this.min; + const markerRWorld = this.max; + + const markerLView = Math.round(dt.xWorldToView(markerLWorld)); + const markerRView = Math.round(dt.xWorldToView(markerRWorld)); + + ctx.fillStyle = 'rgba(0, 0, 0, 0.2)'; + if (markerLWorld > viewLWorld) { + ctx.fillRect(dt.xWorldToView(viewLWorld), 0, + markerLView, viewHeight); + } + + if (markerRWorld < viewRWorld) { + ctx.fillRect(markerRView, 0, + dt.xWorldToView(viewRWorld), viewHeight); + } + + const pixelRatio = window.devicePixelRatio || 1; + ctx.lineWidth = Math.round(pixelRatio); + if (this.range_.range > 0) { + this.drawLine_(ctx, viewLWorld, viewRWorld, + viewHeight, this.min, this.leftSelected_); + this.drawLine_(ctx, viewLWorld, viewRWorld, + viewHeight, this.max, this.rightSelected_); + } else { + this.drawLine_(ctx, viewLWorld, viewRWorld, + viewHeight, this.min, + this.leftSelected_ || this.rightSelected_); + } + ctx.lineWidth = 1; + }, + + drawLine_(ctx, viewLWorld, viewRWorld, height, ts, selected) { + if (ts < viewLWorld || ts >= viewRWorld) return; + + const dt = this.viewport_.currentDisplayTransform; + const viewX = Math.round(dt.xWorldToView(ts)); + + // Apply subpixel translate to get crisp lines. + // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ + ctx.save(); + ctx.translate((Math.round(ctx.lineWidth) % 2) / 2, 0); + + ctx.beginPath(); + tr.ui.b.drawLine(ctx, viewX, 0, viewX, height); + if (selected) { + ctx.strokeStyle = 'rgb(255, 0, 0)'; + } else { + ctx.strokeStyle = 'rgb(0, 0, 0)'; + } + ctx.stroke(); + + ctx.restore(); + }, + + drawIndicators(ctx, viewLWorld, viewRWorld) { + if (this.leftSnapIndicator_) { + this.drawIndicator_(ctx, viewLWorld, viewRWorld, + this.range_.min, + this.leftSnapIndicator_, + this.leftSelected_); + } + if (this.rightSnapIndicator_) { + this.drawIndicator_(ctx, viewLWorld, viewRWorld, + this.range_.max, + this.rightSnapIndicator_, + this.rightSelected_); + } + }, + + drawIndicator_(ctx, viewLWorld, viewRWorld, + xWorld, si, selected) { + const dt = this.viewport_.currentDisplayTransform; + + const viewX = Math.round(dt.xWorldToView(xWorld)); + + // Apply subpixel translate to get crisp lines. + // http://www.mobtowers.com/html5-canvas-crisp-lines-every-time/ + ctx.save(); + ctx.translate((Math.round(ctx.lineWidth) % 2) / 2, 0); + + const pixelRatio = window.devicePixelRatio || 1; + const viewY = si.y * devicePixelRatio; + const viewHeight = si.height * devicePixelRatio; + const arrowSize = 4 * pixelRatio; + + if (selected) { + ctx.fillStyle = 'rgb(255, 0, 0)'; + } else { + ctx.fillStyle = 'rgb(0, 0, 0)'; + } + tr.ui.b.drawTriangle(ctx, + viewX - arrowSize * 0.75, viewY, + viewX + arrowSize * 0.75, viewY, + viewX, viewY + arrowSize); + ctx.fill(); + tr.ui.b.drawTriangle(ctx, + viewX - arrowSize * 0.75, viewY + viewHeight, + viewX + arrowSize * 0.75, viewY + viewHeight, + viewX, viewY + viewHeight - arrowSize); + ctx.fill(); + + ctx.restore(); + } + }; + + return { + SnapIndicator, + TimelineInterestRange, + }; +}); +</script> |