1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="stylesheet" 9 href="/tracing/ui/extras/chrome/cc/layer_tree_host_impl_view.css"> 10 11<link rel="import" href="/tracing/extras/chrome/cc/layer_tree_host_impl.html"> 12<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_picker.html"> 13<link rel="import" href="/tracing/ui/extras/chrome/cc/layer_view.html"> 14<link rel="import" href="/tracing/extras/chrome/cc/tile.html"> 15<link rel="import" href="/tracing/ui/analysis/object_snapshot_view.html"> 16<link rel="import" href="/tracing/ui/base/drag_handle.html"> 17 18<script> 19'use strict'; 20 21tr.exportTo('tr.ui.e.chrome.cc', function() { 22 /* 23 * Displays a LayerTreeHostImpl snapshot in a human readable form. 24 * @constructor 25 */ 26 var LayerTreeHostImplSnapshotView = tr.ui.b.define( 27 'tr-ui-e-chrome-cc-layer-tree-host-impl-snapshot-view', 28 tr.ui.analysis.ObjectSnapshotView); 29 30 LayerTreeHostImplSnapshotView.prototype = { 31 __proto__: tr.ui.analysis.ObjectSnapshotView.prototype, 32 33 decorate: function() { 34 this.classList.add('tr-ui-e-chrome-cc-lthi-s-view'); 35 36 this.selection_ = undefined; 37 38 this.layerPicker_ = new tr.ui.e.chrome.cc.LayerPicker(); 39 this.layerPicker_.addEventListener( 40 'selection-change', 41 this.onLayerPickerSelectionChanged_.bind(this)); 42 43 this.layerView_ = new tr.ui.e.chrome.cc.LayerView(); 44 this.layerView_.addEventListener( 45 'selection-change', 46 this.onLayerViewSelectionChanged_.bind(this)); 47 this.dragHandle_ = document.createElement('tr-ui-b-drag-handle'); 48 this.dragHandle_.horizontal = false; 49 this.dragHandle_.target = this.layerView_; 50 51 this.appendChild(this.layerPicker_); 52 this.appendChild(this.dragHandle_); 53 this.appendChild(this.layerView_); 54 55 // Make sure we have the current values from layerView_ and layerPicker_, 56 // since those might have been created before we added the listener. 57 this.onLayerViewSelectionChanged_(); 58 this.onLayerPickerSelectionChanged_(); 59 60 }, 61 62 get objectSnapshot() { 63 return this.objectSnapshot_; 64 }, 65 66 set objectSnapshot(objectSnapshot) { 67 this.objectSnapshot_ = objectSnapshot; 68 69 var lthi = this.objectSnapshot; 70 var layerTreeImpl; 71 if (lthi) 72 layerTreeImpl = lthi.getTree(this.layerPicker_.whichTree); 73 74 this.layerPicker_.lthiSnapshot = lthi; 75 this.layerView_.layerTreeImpl = layerTreeImpl; 76 this.layerView_.regenerateContent(); 77 78 if (!this.selection_) 79 return; 80 this.selection = this.selection_.findEquivalent(lthi); 81 }, 82 83 get selection() { 84 return this.selection_; 85 }, 86 87 set selection(selection) { 88 if (this.selection_ == selection) 89 return; 90 this.selection_ = selection; 91 this.layerPicker_.selection = selection; 92 this.layerView_.selection = selection; 93 tr.b.dispatchSimpleEvent(this, 'cc-selection-change'); 94 }, 95 96 onLayerPickerSelectionChanged_: function() { 97 this.selection_ = this.layerPicker_.selection; 98 this.layerView_.selection = this.selection; 99 this.layerView_.layerTreeImpl = this.layerPicker_.layerTreeImpl; 100 this.layerView_.isRenderPassQuads = this.layerPicker_.isRenderPassQuads; 101 this.layerView_.regenerateContent(); 102 tr.b.dispatchSimpleEvent(this, 'cc-selection-change'); 103 }, 104 105 onLayerViewSelectionChanged_: function() { 106 this.selection_ = this.layerView_.selection; 107 this.layerPicker_.selection = this.selection; 108 tr.b.dispatchSimpleEvent(this, 'cc-selection-change'); 109 }, 110 111 get extraHighlightsByLayerId() { 112 return this.layerView_.extraHighlightsByLayerId; 113 }, 114 115 set extraHighlightsByLayerId(extraHighlightsByLayerId) { 116 this.layerView_.extraHighlightsByLayerId = extraHighlightsByLayerId; 117 } 118 }; 119 120 tr.ui.analysis.ObjectSnapshotView.register( 121 LayerTreeHostImplSnapshotView, {typeName: 'cc::LayerTreeHostImpl'}); 122 123 return { 124 LayerTreeHostImplSnapshotView: LayerTreeHostImplSnapshotView 125 }; 126}); 127</script> 128