OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library heap_map_element; | 5 library heap_map_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:math'; | 9 import 'dart:math'; |
10 import 'package:observatory/models.dart' as M; | 10 import 'package:observatory/models.dart' as M; |
11 import 'package:observatory/service.dart' as S; | 11 import 'package:observatory/service.dart' as S; |
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 13 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
| 14 import 'package:observatory/src/elements/helpers/nav_menu.dart'; |
13 import 'package:observatory/src/elements/helpers/tag.dart'; | 15 import 'package:observatory/src/elements/helpers/tag.dart'; |
14 import 'package:observatory/src/elements/helpers/uris.dart'; | 16 import 'package:observatory/src/elements/helpers/uris.dart'; |
15 import 'package:observatory/src/elements/nav/bar.dart'; | |
16 import 'package:observatory/src/elements/nav/isolate_menu.dart'; | 17 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
17 import 'package:observatory/src/elements/nav/menu.dart'; | |
18 import 'package:observatory/src/elements/nav/notify.dart'; | 18 import 'package:observatory/src/elements/nav/notify.dart'; |
19 import 'package:observatory/src/elements/nav/refresh.dart'; | 19 import 'package:observatory/src/elements/nav/refresh.dart'; |
20 import 'package:observatory/src/elements/nav/top_menu.dart'; | 20 import 'package:observatory/src/elements/nav/top_menu.dart'; |
21 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 21 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
22 class HeapMapElement extends HtmlElement implements Renderable { | 22 class HeapMapElement extends HtmlElement implements Renderable { |
23 static const tag = const Tag<HeapMapElement>('heap-map', | 23 static const tag = const Tag<HeapMapElement>('heap-map', |
24 dependencies: const [ | 24 dependencies: const [ |
25 NavBarElement.tag, | |
26 NavTopMenuElement.tag, | 25 NavTopMenuElement.tag, |
27 NavVMMenuElement.tag, | 26 NavVMMenuElement.tag, |
28 NavIsolateMenuElement.tag, | 27 NavIsolateMenuElement.tag, |
29 NavMenuElement.tag, | |
30 NavRefreshElement.tag, | 28 NavRefreshElement.tag, |
31 NavNotifyElement.tag, | 29 NavNotifyElement.tag, |
32 ]); | 30 ]); |
33 | 31 |
34 RenderingScheduler<HeapMapElement> _r; | 32 RenderingScheduler<HeapMapElement> _r; |
35 | 33 |
36 Stream<RenderedEvent<HeapMapElement>> get onRendered => | 34 Stream<RenderedEvent<HeapMapElement>> get onRendered => |
37 _r.onRendered; | 35 _r.onRendered; |
38 | 36 |
39 M.VM _vm; | 37 M.VM _vm; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 94 |
97 void render() { | 95 void render() { |
98 if (_canvas == null) { | 96 if (_canvas == null) { |
99 _canvas = new CanvasElement() | 97 _canvas = new CanvasElement() |
100 ..width = 1 | 98 ..width = 1 |
101 ..height= 1 | 99 ..height= 1 |
102 ..onMouseMove.listen(_handleMouseMove) | 100 ..onMouseMove.listen(_handleMouseMove) |
103 ..onMouseDown.listen(_handleClick); | 101 ..onMouseDown.listen(_handleClick); |
104 } | 102 } |
105 children = [ | 103 children = [ |
106 new NavBarElement(queue: _r.queue) | 104 navBar([ |
107 ..children = [ | 105 new NavTopMenuElement(queue: _r.queue), |
108 new NavTopMenuElement(queue: _r.queue), | 106 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
109 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 107 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
110 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), | 108 navMenu('heap map'), |
111 new NavMenuElement('heap map', last: true, | 109 new NavRefreshElement(queue: _r.queue) |
112 link: Uris.heapMap(_isolate), queue: _r.queue), | 110 ..onRefresh.listen((_) => _refresh()), |
113 new NavRefreshElement(queue: _r.queue) | 111 new NavNotifyElement(_notifications, queue: _r.queue) |
114 ..onRefresh.listen((_) => _refresh()), | 112 ]), |
115 new NavNotifyElement(_notifications, queue: _r.queue) | |
116 ], | |
117 new DivElement()..classes = ['content-centered-big'] | 113 new DivElement()..classes = ['content-centered-big'] |
118 ..children = [ | 114 ..children = [ |
119 new HeadingElement.h2()..text = _status, | 115 new HeadingElement.h2()..text = _status, |
120 new HRElement(), | 116 new HRElement(), |
121 ], | 117 ], |
122 new DivElement()..classes = ['flex-row'] | 118 new DivElement()..classes = ['flex-row'] |
123 ..children = [_canvas] | 119 ..children = [_canvas] |
124 ]; | 120 ]; |
125 } | 121 } |
126 | 122 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 }); | 219 }); |
224 } | 220 } |
225 | 221 |
226 void _updateFragmentationData() { | 222 void _updateFragmentationData() { |
227 if (_fragmentation == null || _canvas == null) { | 223 if (_fragmentation == null || _canvas == null) { |
228 return; | 224 return; |
229 } | 225 } |
230 _updateClassList( | 226 _updateClassList( |
231 _fragmentation['classList'], _fragmentation['freeClassId']); | 227 _fragmentation['classList'], _fragmentation['freeClassId']); |
232 var pages = _fragmentation['pages']; | 228 var pages = _fragmentation['pages']; |
233 var width = _canvas.parent.client.width; | 229 var width = max(_canvas.parent.client.width, 1); |
234 _pageHeight = _PAGE_SEPARATION_HEIGHT + | 230 _pageHeight = _PAGE_SEPARATION_HEIGHT + |
235 _fragmentation['pageSizeBytes'] ~/ | 231 _fragmentation['pageSizeBytes'] ~/ |
236 _fragmentation['unitSizeBytes'] ~/ width; | 232 _fragmentation['unitSizeBytes'] ~/ width; |
237 var height = min(_pageHeight * pages.length, _MAX_CANVAS_HEIGHT); | 233 var height = min(_pageHeight * pages.length, _MAX_CANVAS_HEIGHT); |
238 _fragmentationData = | 234 _fragmentationData = |
239 _canvas.context2D.createImageData(width, height); | 235 _canvas.context2D.createImageData(width, height); |
240 _canvas.width = _fragmentationData.width; | 236 _canvas.width = _fragmentationData.width; |
241 _canvas.height = _fragmentationData.height; | 237 _canvas.height = _fragmentationData.height; |
242 _renderPages(0); | 238 _renderPages(0); |
243 } | 239 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 | 311 |
316 // The row-major index of this pixel. | 312 // The row-major index of this pixel. |
317 int get index => _dataIndex ~/ NUM_COLOR_COMPONENTS; | 313 int get index => _dataIndex ~/ NUM_COLOR_COMPONENTS; |
318 } | 314 } |
319 | 315 |
320 class ObjectInfo { | 316 class ObjectInfo { |
321 final address; | 317 final address; |
322 final size; | 318 final size; |
323 ObjectInfo(this.address, this.size); | 319 ObjectInfo(this.address, this.size); |
324 } | 320 } |
OLD | NEW |