Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: tracing/tracing/ui/base/draw_helpers.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/sorted_array_utils.html"> 8 <link rel="import" href="/tracing/base/math/sorted_array_utils.html">
9 <link rel="import" href="/tracing/ui/base/elided_cache.html"> 9 <link rel="import" href="/tracing/ui/base/elided_cache.html">
10 <link rel="import" href="/tracing/ui/base/event_presenter.html"> 10 <link rel="import" href="/tracing/ui/base/event_presenter.html">
11 11
12 <script> 12 <script>
13 'use strict'; 13 'use strict';
14 14
15 /** 15 /**
16 * @fileoverview Provides various helper methods for drawing to a provided 16 * @fileoverview Provides various helper methods for drawing to a provided
17 * canvas. 17 * canvas.
18 */ 18 */
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 var lightRectHeight = height - darkRectHeight; 156 var lightRectHeight = height - darkRectHeight;
157 157
158 // Begin rendering in world space. 158 // Begin rendering in world space.
159 ctx.save(); 159 ctx.save();
160 dt.applyTransformToCanvas(ctx); 160 dt.applyTransformToCanvas(ctx);
161 161
162 var rect = new tr.ui.b.FastRectRenderer( 162 var rect = new tr.ui.b.FastRectRenderer(
163 ctx, 2 * pixWidth, 2 * pixWidth, colorsAsStrings); 163 ctx, 2 * pixWidth, 2 * pixWidth, colorsAsStrings);
164 rect.setYandH(0, height); 164 rect.setYandH(0, height);
165 165
166 var lowSlice = tr.b.findLowIndexInSortedArray( 166 var lowSlice = tr.b.math.findLowIndexInSortedArray(
167 slices, 167 slices,
168 function(slice) { return slice.start + slice.duration; }, 168 function(slice) { return slice.start + slice.duration; },
169 viewLWorld); 169 viewLWorld);
170 170
171 var hadTopLevel = false; 171 var hadTopLevel = false;
172 172
173 for (var i = lowSlice; i < slices.length; ++i) { 173 for (var i = lowSlice; i < slices.length; ++i) {
174 var slice = slices[i]; 174 var slice = slices[i];
175 var x = slice.start; 175 var x = slice.start;
176 if (x > viewRWorld) 176 if (x > viewRWorld)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 var height = viewHeight * pixelRatio; 300 var height = viewHeight * pixelRatio;
301 301
302 var pixWidth = dt.xViewVectorToWorld(1); 302 var pixWidth = dt.xViewVectorToWorld(1);
303 303
304 // Begin rendering in world space. 304 // Begin rendering in world space.
305 ctx.save(); 305 ctx.save();
306 ctx.lineWidth = pixWidth * lineWidthInPixels * pixelRatio; 306 ctx.lineWidth = pixWidth * lineWidthInPixels * pixelRatio;
307 dt.applyTransformToCanvas(ctx); 307 dt.applyTransformToCanvas(ctx);
308 ctx.beginPath(); 308 ctx.beginPath();
309 309
310 var lowSlice = tr.b.findLowIndexInSortedArray( 310 var lowSlice = tr.b.math.findLowIndexInSortedArray(
311 slices, 311 slices,
312 function(slice) { return slice.start; }, 312 function(slice) { return slice.start; },
313 viewLWorld); 313 viewLWorld);
314 314
315 for (var i = lowSlice; i < slices.length; ++i) { 315 for (var i = lowSlice; i < slices.length; ++i) {
316 var slice = slices[i]; 316 var slice = slices[i];
317 var x = slice.start; 317 var x = slice.start;
318 if (x > viewRWorld) 318 if (x > viewRWorld)
319 break; 319 break;
320 320
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 355
356 ctx.textAlign = 'center'; 356 ctx.textAlign = 'center';
357 ctx.textBaseline = 'top'; 357 ctx.textBaseline = 'top';
358 ctx.font = (fontSize * pixelRatio) + 'px sans-serif'; 358 ctx.font = (fontSize * pixelRatio) + 'px sans-serif';
359 359
360 if (async) 360 if (async)
361 ctx.font = 'italic ' + ctx.font; 361 ctx.font = 'italic ' + ctx.font;
362 362
363 var cY = yOffset * pixelRatio; 363 var cY = yOffset * pixelRatio;
364 364
365 var lowSlice = tr.b.findLowIndexInSortedArray( 365 var lowSlice = tr.b.math.findLowIndexInSortedArray(
366 slices, 366 slices,
367 function(slice) { return slice.start + slice.duration; }, 367 function(slice) { return slice.start + slice.duration; },
368 viewLWorld); 368 viewLWorld);
369 369
370 // Don't render text until until it is 20px wide 370 // Don't render text until until it is 20px wide
371 var quickDiscardThresshold = pixWidth * 20; 371 var quickDiscardThresshold = pixWidth * 20;
372 for (var i = lowSlice; i < slices.length; ++i) { 372 for (var i = lowSlice; i < slices.length; ++i) {
373 var slice = slices[i]; 373 var slice = slices[i];
374 if (slice.start > viewRWorld) 374 if (slice.start > viewRWorld)
375 break; 375 break;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 drawLine, 410 drawLine,
411 drawTriangle, 411 drawTriangle,
412 drawArrow, 412 drawArrow,
413 413
414 elidedTitleCache_: elidedTitleCache, 414 elidedTitleCache_: elidedTitleCache,
415 415
416 THIN_SLICE_HEIGHT, 416 THIN_SLICE_HEIGHT,
417 }; 417 };
418 }); 418 });
419 </script> 419 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/ui/base/column_chart_test.html ('k') | tracing/tracing/ui/base/line_chart_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698