1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 tvcm.requireStylesheet('cc.layer_tree_host_impl_view');
9 tvcm.require('cc.layer_tree_host_impl');
10 tvcm.require('cc.layer_picker');
11 tvcm.require('cc.layer_view');
12 tvcm.require('cc.tile');
13 tvcm.require('tracing.analysis.object_snapshot_view');
14 tvcm.require('tvcm.ui.drag_handle');
16 tvcm.exportTo('cc', function() {
18 * Displays a LayerTreeHostImpl snapshot in a human readable form.
21 var LayerTreeHostImplSnapshotView = tvcm.ui.define(
22 'layer-tree-host-impl-snapshot-view',
23 tracing.analysis.ObjectSnapshotView);
25 LayerTreeHostImplSnapshotView.prototype = {
26 __proto__: tracing.analysis.ObjectSnapshotView.prototype,
28 decorate: function() {
29 this.classList.add('lthi-s-view');
31 this.selection_ = undefined;
33 this.layerPicker_ = new cc.LayerPicker();
34 this.layerPicker_.addEventListener(
36 this.onLayerPickerSelectionChanged_.bind(this));
38 this.layerView_ = new cc.LayerView();
39 this.layerView_.addEventListener(
41 this.onLayerViewSelectionChanged_.bind(this));
42 this.dragHandle_ = new tvcm.ui.DragHandle();
43 this.dragHandle_.horizontal = false;
44 this.dragHandle_.target = this.layerView_;
46 this.appendChild(this.layerPicker_);
47 this.appendChild(this.dragHandle_);
48 this.appendChild(this.layerView_);
50 // Make sure we have the current values from layerView_ and layerPicker_,
51 // since those might have been created before we added the listener.
52 this.onLayerViewSelectionChanged_();
53 this.onLayerPickerSelectionChanged_();
57 get objectSnapshot() {
58 return this.objectSnapshot_;
61 set objectSnapshot(objectSnapshot) {
62 this.objectSnapshot_ = objectSnapshot;
64 var lthi = this.objectSnapshot;
67 layerTreeImpl = lthi.getTree(this.layerPicker_.whichTree);
69 this.layerPicker_.lthiSnapshot = lthi;
70 this.layerView_.whichTree = this.layerPicker_.whichTree;
71 this.layerView_.layerTreeImpl = layerTreeImpl;
72 this.layerView_.regenerateContent();
76 this.selection = this.selection_.findEquivalent(lthi);
80 return this.selection_;
83 set selection(selection) {
84 this.selection_ = selection;
85 this.layerPicker_.selection = selection;
86 this.layerView_.selection = selection;
89 onLayerPickerSelectionChanged_: function() {
90 this.selection_ = this.layerPicker_.selection;
91 this.layerView_.selection = this.selection;
92 this.layerView_.isRenderPassQuads = this.layerPicker_.isRenderPassQuads;
93 this.layerView_.regenerateContent();
96 onLayerViewSelectionChanged_: function() {
97 this.selection_ = this.layerView_.selection;
98 this.layerPicker_.selection = this.selection;
103 tracing.analysis.ObjectSnapshotView.register(
104 'cc::LayerTreeHostImpl', LayerTreeHostImplSnapshotView);
107 LayerTreeHostImplSnapshotView: LayerTreeHostImplSnapshotView