Merge "Add layer filter to winscope" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e871962f81
@@ -27,6 +27,7 @@
|
|||||||
<h2 class="md-title" style="flex: 1;">Hierarchy</h2>
|
<h2 class="md-title" style="flex: 1;">Hierarchy</h2>
|
||||||
<md-checkbox v-model="store.onlyVisible">Only visible</md-checkbox>
|
<md-checkbox v-model="store.onlyVisible">Only visible</md-checkbox>
|
||||||
<md-checkbox v-model="store.flattened">Flat</md-checkbox>
|
<md-checkbox v-model="store.flattened">Flat</md-checkbox>
|
||||||
|
<input id="filter" type="search" placeholder="Filter..." v-model="hierarchyPropertyFilterString" />
|
||||||
</md-whiteframe>
|
</md-whiteframe>
|
||||||
<tree-view class="data-card" :item="tree" @item-selected="itemSelected" :selected="hierarchySelected" :filter="hierarchyFilter" :flattened="store.flattened" ref="hierarchy" />
|
<tree-view class="data-card" :item="tree" @item-selected="itemSelected" :selected="hierarchySelected" :filter="hierarchyFilter" :flattened="store.flattened" ref="hierarchy" />
|
||||||
</md-card>
|
</md-card>
|
||||||
@@ -93,6 +94,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
propertyFilterString: "",
|
propertyFilterString: "",
|
||||||
|
hierarchyPropertyFilterString:"",
|
||||||
selectedTree: {},
|
selectedTree: {},
|
||||||
hierarchySelected: null,
|
hierarchySelected: null,
|
||||||
lastSelectedStableId: null,
|
lastSelectedStableId: null,
|
||||||
@@ -170,30 +172,12 @@ export default {
|
|||||||
return this.file.selectedIndex;
|
return this.file.selectedIndex;
|
||||||
},
|
},
|
||||||
hierarchyFilter() {
|
hierarchyFilter() {
|
||||||
return this.store.onlyVisible ? (c, flattened) => {
|
var hierarchyPropertyFilter = getFilter(this.hierarchyPropertyFilterString);
|
||||||
return c.visible || c.childrenVisible && !flattened;
|
return this.store.onlyVisible ? (c) => {
|
||||||
} : null;
|
return c.visible && hierarchyPropertyFilter(c);} : hierarchyPropertyFilter;
|
||||||
},
|
},
|
||||||
propertyFilter() {
|
propertyFilter() {
|
||||||
var filterStrings = this.propertyFilterString.split(",");
|
return getFilter(this.propertyFilterString);
|
||||||
var positive = [];
|
|
||||||
var negative = [];
|
|
||||||
filterStrings.forEach((f) => {
|
|
||||||
if (f.startsWith("!")) {
|
|
||||||
var str = f.substring(1);
|
|
||||||
negative.push((s) => s.indexOf(str) === -1);
|
|
||||||
} else {
|
|
||||||
var str = f;
|
|
||||||
positive.push((s) => s.indexOf(str) !== -1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var filter = (item) => {
|
|
||||||
var apply = (f) => f(item.name);
|
|
||||||
return (positive.length === 0 || positive.some(apply)) &&
|
|
||||||
(negative.length === 0 || negative.every(apply));
|
|
||||||
};
|
|
||||||
filter.includeChildren = true;
|
|
||||||
return filter;
|
|
||||||
},
|
},
|
||||||
hasScreenView() {
|
hasScreenView() {
|
||||||
return this.file.type !== DATA_TYPES.TRANSACTION;
|
return this.file.type !== DATA_TYPES.TRANSACTION;
|
||||||
@@ -205,6 +189,27 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFilter(filterString) {
|
||||||
|
var filterStrings = filterString.split(",");
|
||||||
|
var positive = [];
|
||||||
|
var negative = [];
|
||||||
|
filterStrings.forEach((f) => {
|
||||||
|
if (f.startsWith("!")) {
|
||||||
|
var str = f.substring(1);
|
||||||
|
negative.push((s) => s.indexOf(str) === -1);
|
||||||
|
} else {
|
||||||
|
var str = f;
|
||||||
|
positive.push((s) => s.indexOf(str) !== -1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var filter = (item) => {
|
||||||
|
var apply = (f) => f(String(item.name));
|
||||||
|
return (positive.length === 0 || positive.some(apply)) &&
|
||||||
|
(negative.length === 0 || negative.every(apply));
|
||||||
|
};
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.rects {
|
.rects {
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ import jsonProtoDefs from 'frameworks/base/core/proto/android/server/windowmanag
|
|||||||
import protobuf from 'protobufjs'
|
import protobuf from 'protobufjs'
|
||||||
|
|
||||||
var protoDefs = protobuf.Root.fromJSON(jsonProtoDefs);
|
var protoDefs = protobuf.Root.fromJSON(jsonProtoDefs);
|
||||||
var TraceMessage = protoDefs.lookupType(
|
|
||||||
"com.android.server.wm.WindowManagerTraceFileProto");
|
|
||||||
var ServiceMessage = protoDefs.lookupType(
|
|
||||||
"com.android.server.wm.WindowManagerServiceDumpProto");
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'tree-view',
|
name: 'tree-view',
|
||||||
@@ -84,14 +80,19 @@ export default {
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
filterMatches(c) {
|
filterMatches(c) {
|
||||||
|
// If a filter is set, consider the item matches if the current item or any of its
|
||||||
|
// children matches.
|
||||||
if (this.filter) {
|
if (this.filter) {
|
||||||
return this.filter(c, this.applyingFlattened);
|
var thisMatches = this.filter(c);
|
||||||
|
const childMatches = (child) => this.filterMatches(child);
|
||||||
|
return thisMatches || (!this.applyingFlattened &&
|
||||||
|
c.children && c.children.some(childMatches));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
childFilter(c) {
|
childFilter(c) {
|
||||||
if (this.filter && this.filter.includeChildren) {
|
if (this.filter) {
|
||||||
if (this.filterMatches(c)) {
|
if (this.filter(c)) {
|
||||||
// Filter matched c, don't apply further filtering on c's children.
|
// Filter matched c, don't apply further filtering on c's children.
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user