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
5 found in the LICENSE file.
8 <link rel="stylesheet" href="/cc/layer_view.css">
10 <link rel="import" href="/cc/constants.html">
11 <link rel="import" href="/cc/layer_tree_quad_stack_view.html">
12 <link rel="import" href="/cc/picture.html">
13 <link rel="import" href="/base/raf.html">
14 <link rel="import" href="/base/settings.html">
15 <link rel="import" href="/base/ui/drag_handle.html">
16 <link rel="import" href="/tracing/analysis/util.html">
22 * @fileoverview LayerView coordinates graphical and analysis views of layers.
25 tv.exportTo('cc', function() {
26 var constants = cc.constants;
31 var LayerView = tv.ui.define('layer-view');
33 LayerView.prototype = {
34 __proto__: HTMLUnknownElement.prototype,
36 decorate: function() {
37 this.layerTreeQuadStackView_ = new cc.LayerTreeQuadStackView();
38 this.dragBar_ = new tv.ui.DragHandle();
39 this.analysisEl_ = document.createElement('layer-view-analysis');
40 this.analysisEl_.addEventListener('requestSelectionChange',
41 this.onRequestSelectionChangeFromAnalysisEl_.bind(this));
43 this.dragBar_.target = this.analysisEl_;
45 this.appendChild(this.layerTreeQuadStackView_);
46 this.appendChild(this.dragBar_);
47 this.appendChild(this.analysisEl_);
49 this.layerTreeQuadStackView_.addEventListener('selection-change',
51 this.layerTreeQuadStackViewSelectionChanged_();
53 this.layerTreeQuadStackViewSelectionChanged_();
57 return this.layerTreeQuadStackView_.layerTreeImpl;
60 set layerTreeImpl(newValue) {
61 return this.layerTreeQuadStackView_.layerTreeImpl = newValue;
64 set isRenderPassQuads(newValue) {
65 return this.layerTreeQuadStackView_.isRenderPassQuads = newValue;
69 return this.layerTreeQuadStackView_.selection;
72 set selection(newValue) {
73 this.layerTreeQuadStackView_.selection = newValue;
76 regenerateContent: function() {
77 this.layerTreeQuadStackView_.regenerateContent();
80 layerTreeQuadStackViewSelectionChanged_: function() {
81 var selection = this.layerTreeQuadStackView_.selection;
83 this.dragBar_.style.display = '';
84 this.analysisEl_.style.display = '';
85 this.analysisEl_.textContent = '';
87 var layer = selection.layer;
88 if (layer && layer.args && layer.args.pictures) {
89 this.analysisEl_.appendChild(
90 this.createPictureBtn_(layer.args.pictures));
93 var analysis = selection.createAnalysis();
94 this.analysisEl_.appendChild(analysis);
96 this.dragBar_.style.display = 'none';
97 this.analysisEl_.style.display = 'none';
98 var analysis = this.analysisEl_.firstChild;
100 this.analysisEl_.removeChild(analysis);
101 this.layerTreeQuadStackView_.style.height =
102 window.getComputedStyle(this).height;
104 tv.dispatchSimpleEvent(this, 'selection-change');
107 createPictureBtn_: function(pictures) {
108 if (!(pictures instanceof Array))
109 pictures = [pictures];
111 var link = new tracing.analysis.AnalysisLink();
112 link.innerText = 'View in Picture Debugger';
113 link.selectionGenerator = function() {
114 var layeredPicture = new cc.LayeredPicture(pictures);
115 var snapshot = new cc.PictureSnapshot(layeredPicture);
116 snapshot.picture = layeredPicture;
118 var selection = new tracing.Selection();
119 selection.push(snapshot);
125 onRequestSelectionChangeFromAnalysisEl_: function(e) {
126 if (!(e.selection instanceof cc.Selection))
130 this.selection = e.selection;
133 get extraHighlightsByLayerId() {
134 return this.layerTreeQuadStackView_.extraHighlightsByLayerId;
137 set extraHighlightsByLayerId(extraHighlightsByLayerId) {
138 this.layerTreeQuadStackView_.extraHighlightsByLayerId =
139 extraHighlightsByLayerId;