Display only elements actually visible on the screen as "Visible"
Use the visibleRegion property to determine if a layer is visible on the screen or not. Elements may have a size and a crop but be displayed below another. While the visible option cannot be used to render the elements due to transforms, it only has a value if the element is displayed on the screen. Note that elements may still not appear on the screen as all their visible regions are below the screen (right < 0 or bottom < 0) Test: Open trace in winscope, check if only layers visible on the screen have a visible chip and are displayed. Change-Id: I75137a5057a5bda96db887b110b053e64b49f885
This commit is contained in:
@@ -89,11 +89,12 @@ function transform_layer(layer, {parentBounds, parentHidden}) {
|
||||
* @param {layer} layer
|
||||
* @returns if the layer is visible on screen or not
|
||||
*/
|
||||
function is_visible(layer, visibleRect) {
|
||||
function is_visible(layer) {
|
||||
var visible = (layer.activeBuffer || layer.type === 'ColorLayer')
|
||||
&& !hidden && layer.color.a > 0;
|
||||
if (visibleRect != undefined) {
|
||||
visible &= has_size(visibleRect);
|
||||
&& !hidden && layer.color.a > 0;
|
||||
if (visible && layer.visibleRegion != undefined) {
|
||||
var isRectVisible = layer.visibleRegion.rect.some(has_size);
|
||||
visible &= isRectVisible;
|
||||
}
|
||||
return visible
|
||||
}
|
||||
@@ -101,7 +102,7 @@ function transform_layer(layer, {parentBounds, parentHidden}) {
|
||||
var chips = [];
|
||||
var rect = transform_bounds(layer, parentBounds);
|
||||
var hidden = (layer.flags & FLAG_HIDDEN) != 0 || parentHidden;
|
||||
var visible = is_visible(layer, rect);
|
||||
var visible = is_visible(layer);
|
||||
if (visible) {
|
||||
chips.push(get_visible_chip());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user