Changeset View
Changeset View
Standalone View
Standalone View
source/tools/profiler2/ReportDraw.js
// Copyright (C) 2016 Wildfire Games. | // Copyright (C) 2023 Wildfire Games. | ||||
// | // | ||||
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
// of this software and associated documentation files (the "Software"), to deal | // of this software and associated documentation files (the "Software"), to deal | ||||
// in the Software without restriction, including without limitation the rights | // in the Software without restriction, including without limitation the rights | ||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
// copies of the Software, and to permit persons to whom the Software is | // copies of the Software, and to permit persons to whom the Software is | ||||
// furnished to do so, subject to the following conditions: | // furnished to do so, subject to the following conditions: | ||||
// | // | ||||
▲ Show 20 Lines • Show All 429 Lines • ▼ Show 20 Lines | function set_zoom_handlers(main_data, data, canvas0, canvas1) | ||||
function do_zoom(event) | function do_zoom(event) | ||||
{ | { | ||||
var hdata = canvas0._hierarchyData; | var hdata = canvas0._hierarchyData; | ||||
function x_to_time(x) | function x_to_time(x) | ||||
{ | { | ||||
return hdata.tmin + x * (hdata.tmax - hdata.tmin) / canvas0.width; | return hdata.tmin + x * (hdata.tmax - hdata.tmin) / canvas0.width; | ||||
} | } | ||||
const canvasRect = this.getBoundingClientRect(); | |||||
var relativeX = event.pageX - this.offsetLeft; | var relativeX = event.clientX - canvasRect.left; | ||||
var relativeY = (event.pageY + this.offsetTop) / canvas0.height; | var relativeY = (event.clientY - canvasRect.top) / canvasRect.height; | ||||
relativeY = relativeY - 0.5; | const width = relativeY * canvas0.width / 2; | ||||
relativeY *= 5; | |||||
relativeY *= relativeY; | |||||
var width = relativeY / canvas0.height; | |||||
width = width*width; | |||||
width = 3 + width * x_to_time(canvas0.width)/10; | |||||
var zoom = { tmin: x_to_time(relativeX-width/2), tmax: x_to_time(relativeX+width/2) }; | var zoom = { tmin: x_to_time(relativeX-width/2), tmax: x_to_time(relativeX+width/2) }; | ||||
display_hierarchy(main_data, data, canvas0, hdata.range, zoom); | display_hierarchy(main_data, data, canvas0, hdata.range, zoom); | ||||
display_hierarchy(main_data, data, canvas1, zoom, undefined); | display_hierarchy(main_data, data, canvas1, zoom, undefined); | ||||
set_tooltip_handlers(canvas1); | set_tooltip_handlers(canvas1); | ||||
} | } | ||||
$(canvas0).mousedown(function(event) | $(canvas0).mousedown(function(event) | ||||
{ | { | ||||
mouse_is_down = canvas0; | mouse_is_down = canvas0; | ||||
do_zoom.call(this, event); | do_zoom.call(this, event); | ||||
}); | }); | ||||
$(canvas0).mouseup(function(event) | $(canvas0).mouseup(function(event) | ||||
{ | { | ||||
mouse_is_down = null; | mouse_is_down = null; | ||||
}); | }); | ||||
$(canvas0).mousemove(function(event) | $(canvas0).mousemove(function(event) | ||||
{ | { | ||||
if (mouse_is_down) | if (mouse_is_down) | ||||
do_zoom.call(this, event); | do_zoom.call(this, event); | ||||
}); | }); | ||||
} | } | ||||
return outInterface; | return outInterface; | ||||
})(); | })(); | ||||
No newline at end of file |
Wildfire Games · Phabricator