0

[TreesInViz] Implement mirror layers

Bug: 402213513
Change-Id: If20757c5de42bd5ac4e135b1cc57d51314b1b46e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6409533
Reviewed-by: Fred Shih <ffred@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Victor Miura <vmiura@chromium.org>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1439824}
This commit is contained in:
Victor Miura 2025-03-28 18:44:18 -07:00 committed by Chromium LUCI CQ
parent 37f2a19623
commit 65b50c98bd
4 changed files with 35 additions and 6 deletions
cc/mojo_embedder
components/viz/service/layers
services/viz/public/mojom/compositing
testing/buildbot/filters

@ -22,6 +22,7 @@
#include "cc/animation/keyframe_effect.h"
#include "cc/animation/keyframe_model.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/mirror_layer_impl.h"
#include "cc/layers/picture_layer_impl.h"
#include "cc/layers/surface_layer_impl.h"
#include "cc/tiles/picture_layer_tiling.h"
@ -439,6 +440,11 @@ void SerializePictureLayerTileUpdates(
}
}
void SerializeMirrorLayerExtra(MirrorLayerImpl& layer,
viz::mojom::MirrorLayerExtraPtr& extra) {
extra->mirrored_layer_id = layer.mirrored_layer_id();
}
void SerializeSurfaceLayerExtra(SurfaceLayerImpl& layer,
viz::mojom::SurfaceLayerExtraPtr& extra) {
extra->surface_range = layer.range();
@ -475,6 +481,14 @@ void SerializeLayer(LayerImpl& layer,
wire.effect_tree_index = layer.effect_tree_index();
wire.scroll_tree_index = layer.scroll_tree_index();
switch (layer.GetLayerType()) {
case mojom::LayerType::kMirror: {
auto mirror_layer_extra = viz::mojom::MirrorLayerExtra::New();
SerializeMirrorLayerExtra(static_cast<MirrorLayerImpl&>(layer),
mirror_layer_extra);
wire.layer_extra = viz::mojom::LayerExtra::NewMirrorLayerExtra(
std::move(mirror_layer_extra));
break;
}
case mojom::LayerType::kSurface: {
auto surface_layer_extra = viz::mojom::SurfaceLayerExtra::New();
SerializeSurfaceLayerExtra(static_cast<SurfaceLayerImpl&>(layer),

@ -22,6 +22,7 @@
#include "cc/animation/keyframe_effect.h"
#include "cc/debug/rendering_stats_instrumentation.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/mirror_layer_impl.h"
#include "cc/layers/solid_color_layer_impl.h"
#include "cc/layers/surface_layer_impl.h"
#include "cc/layers/tile_display_layer_impl.h"
@ -60,6 +61,9 @@ std::unique_ptr<cc::LayerImpl> CreateLayer(LayerContextImpl& context,
case cc::mojom::LayerType::kLayer:
return cc::LayerImpl::Create(&tree, id);
case cc::mojom::LayerType::kMirror:
return cc::MirrorLayerImpl::Create(&tree, id);
case cc::mojom::LayerType::kSurface:
// TODO(394137303): handle |update_submission_state_callback|.
return cc::SurfaceLayerImpl::Create(&tree, id, base::NullCallback());
@ -357,6 +361,11 @@ base::expected<void, std::string> UpdateTransformTreeProperties(
return base::ok();
}
void UpdateMirrorLayerExtra(const mojom::MirrorLayerExtraPtr& extra,
cc::MirrorLayerImpl& layer) {
layer.SetMirroredLayerId(extra->mirrored_layer_id);
}
void UpdateSurfaceLayerExtra(const mojom::SurfaceLayerExtraPtr& extra,
cc::SurfaceLayerImpl& layer) {
layer.SetRange(extra->surface_range, extra->deadline_in_frames);
@ -424,6 +433,10 @@ base::expected<void, std::string> UpdateLayer(const mojom::Layer& wire,
layer.SetScrollTreeIndex(wire.scroll_tree_index);
switch (wire.type) {
case cc::mojom::LayerType::kMirror:
UpdateMirrorLayerExtra(wire.layer_extra->get_mirror_layer_extra(),
static_cast<cc::MirrorLayerImpl&>(layer));
break;
case cc::mojom::LayerType::kSurface:
UpdateSurfaceLayerExtra(wire.layer_extra->get_surface_layer_extra(),
static_cast<cc::SurfaceLayerImpl&>(layer));

@ -15,6 +15,12 @@ import "services/viz/public/mojom/compositing/copy_output_request.mojom";
import "services/viz/public/mojom/compositing/resource_id.mojom";
import "ui/gfx/mojom/transform.mojom";
// Extra fields in a cc::MirrorLayerImpl that has been added to a tree or
// modified in some interesting way since a prior tree update.
struct MirrorLayerExtra {
int32 mirrored_layer_id;
};
// Extra fields in a cc::SurfaceLayerImpl that has been added to a tree or
// modified in some interesting way since a prior tree update.
struct SurfaceLayerExtra {
@ -50,6 +56,8 @@ struct SurfaceLayerExtra {
// Extra properties that are specific to a LayerImpl type.
union LayerExtra {
// Extra properties that are specific to MirrorLayerImpl.
MirrorLayerExtra mirror_layer_extra;
// Extra properties that are specific to SurfaceLayerImpl.
SurfaceLayerExtra surface_layer_extra;
};

@ -78,12 +78,6 @@
-LayerTreeHostTestDamageWithScale.RunMultiThread_DelegatingRenderer
-LayerTreeHostTestDamageWithScale.RunSingleThread_DelegatingRenderer
# TODO(crbug.com/402213513) Implement MirrorLayer support
-All/LayerTreeHostMirrorPixelTest.MirrorLayer/SkiaGL
-All/LayerTreeHostMirrorPixelTest.MirrorLayer/SkiaGraphiteDawn
-All/LayerTreeHostMirrorPixelTest.MirrorLayer/SkiaVulkan
-All/LayerTreeHostMirrorPixelTest.MirrorLayer/Software
# TODO(crbug.com/388877791) Implement support for displaying scroll bar layers
-All/LayerTreeHostOverlayScrollbarsPixelTest.NinePatchScrollbarScaledDown/SkiaGL
-All/LayerTreeHostOverlayScrollbarsPixelTest.NinePatchScrollbarScaledDown/SkiaGraphiteDawn