viz: Set an explicit layer ID for RenderSurfaceImpl
This change makes it explicit that a layer ID of 0 valid, and sets a unique id for RenderSurfaceImpl. Bug: 324460866 Change-Id: Ib3ea70e9f375f49313ec103469b250e4eab0a14e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5912146 Commit-Queue: Michael Tang <tangm@microsoft.com> Reviewed-by: Vasiliy Telezhnikov <vasilyt@chromium.org> Cr-Commit-Position: refs/heads/main@{#1396195}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
fe2702e96c
commit
c00a822079
cc
components/viz
@ -89,6 +89,11 @@ Layer::Inputs::~Inputs() = default;
|
||||
Layer::LayerTreeInputs::LayerTreeInputs() = default;
|
||||
Layer::LayerTreeInputs::~LayerTreeInputs() = default;
|
||||
|
||||
int Layer::GetNextLayerId() {
|
||||
// Layer IDs start from 1.
|
||||
return g_next_layer_id.GetNext() + 1;
|
||||
}
|
||||
|
||||
scoped_refptr<Layer> Layer::Create() {
|
||||
return base::WrapRefCounted(new Layer());
|
||||
}
|
||||
@ -96,8 +101,7 @@ scoped_refptr<Layer> Layer::Create() {
|
||||
Layer::Layer()
|
||||
: parent_(nullptr),
|
||||
layer_tree_host_(nullptr),
|
||||
// Layer IDs start from 1.
|
||||
layer_id_(g_next_layer_id.GetNext() + 1),
|
||||
layer_id_(GetNextLayerId()),
|
||||
num_descendants_that_draw_content_(0),
|
||||
transform_tree_index_(kInvalidPropertyNodeId),
|
||||
effect_tree_index_(kInvalidPropertyNodeId),
|
||||
|
@ -95,6 +95,9 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
|
||||
INVALID_ID = -1,
|
||||
};
|
||||
|
||||
// Get a unique layer id.
|
||||
static int GetNextLayerId();
|
||||
|
||||
// Factory to create a new Layer, with a unique id.
|
||||
static scoped_refptr<Layer> Create();
|
||||
|
||||
|
@ -37,7 +37,8 @@ RenderSurfaceImpl::RenderSurfaceImpl(LayerTreeImpl* layer_tree_impl,
|
||||
ElementId id)
|
||||
: layer_tree_impl_(layer_tree_impl),
|
||||
id_(id),
|
||||
effect_tree_index_(kInvalidPropertyNodeId) {
|
||||
effect_tree_index_(kInvalidPropertyNodeId),
|
||||
layer_id_(Layer::GetNextLayerId()) {
|
||||
DCHECK(id);
|
||||
damage_tracker_ = DamageTracker::Create();
|
||||
}
|
||||
@ -459,7 +460,7 @@ void RenderSurfaceImpl::AppendQuads(DrawMode draw_mode,
|
||||
shared_quad_state->SetAll(
|
||||
draw_transform(), content_rect(), content_rect(), mask_filter_info(),
|
||||
clip_rect, contents_opaque, draw_properties_.draw_opacity, BlendMode(),
|
||||
sorting_context_id, /*layer_id=*/0u, is_fast_rounded_corner());
|
||||
sorting_context_id, layer_id_, is_fast_rounded_corner());
|
||||
|
||||
if (layer_tree_impl_->debug_state().show_debug_borders.test(
|
||||
DebugBorderType::RENDERPASS)) {
|
||||
|
@ -273,6 +273,10 @@ class CC_EXPORT RenderSurfaceImpl {
|
||||
ElementId id_;
|
||||
int effect_tree_index_;
|
||||
|
||||
// A unique id in the same namespace as `Layer::layer_id_`, so viz can
|
||||
// identify `RenderPassDrawQuads` across the frame, similarly to other quads.
|
||||
uint32_t layer_id_ = 0;
|
||||
|
||||
// Container for properties that render surfaces need to compute before they
|
||||
// can be drawn.
|
||||
struct DrawProperties {
|
||||
|
@ -429,7 +429,8 @@ viz::SharedQuadState* Layer::CreateAndAppendSharedQuadState(
|
||||
data.mask_filter_info_in_target, clip_opt,
|
||||
contents_opaque(), opacity, SkBlendMode::kSrcOver,
|
||||
/*sorting_context=*/0,
|
||||
/*layer_id=*/0u, /*fast_rounded_corner=*/false);
|
||||
/*layer_id=*/static_cast<uint32_t>(id()),
|
||||
/*fast_rounded_corner=*/false);
|
||||
quad_state->is_fast_rounded_corner = true;
|
||||
quad_state->offset_tag = data.offset_tag;
|
||||
return quad_state;
|
||||
|
@ -74,10 +74,10 @@ class VIZ_COMMON_EXPORT SharedQuadState {
|
||||
float opacity = 1.0f;
|
||||
SkBlendMode blend_mode = SkBlendMode::kSrcOver;
|
||||
int sorting_context_id = 0;
|
||||
// Optionally set by the client with a stable ID for the layer that produced
|
||||
// the DrawQuad(s). This is used to help identify that DrawQuad(s) in one
|
||||
// frame came from the same layer as DrawQuads() from a previous frame, even
|
||||
// if they changed position or other attributes.
|
||||
// Optionally set by the client as a performance hint for viz with a stable ID
|
||||
// for the layer that produced the DrawQuad(s). This is used to help identify
|
||||
// that DrawQuad(s) in one frame came from the same layer as DrawQuads() from
|
||||
// a previous frame, even if they changed position or other attributes.
|
||||
uint32_t layer_id = 0;
|
||||
// Used by SurfaceAggregator to namespace layer_ids from different clients.
|
||||
uint32_t layer_namespace_id = 0;
|
||||
|
@ -173,15 +173,13 @@ OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromDrawQuad(
|
||||
candidate.overlay_damage_index =
|
||||
sqs->overlay_damage_index.value_or(OverlayCandidate::kInvalidDamageIndex);
|
||||
|
||||
if (sqs->layer_id != 0) {
|
||||
static_assert(
|
||||
std::is_same<decltype(SharedQuadState::layer_id), uint32_t>::value);
|
||||
static_assert(std::is_same<decltype(SharedQuadState::layer_namespace_id),
|
||||
uint32_t>::value);
|
||||
candidate.aggregated_layer_id =
|
||||
static_cast<uint64_t>(sqs->layer_id) |
|
||||
(static_cast<uint64_t>(sqs->layer_namespace_id) << 32);
|
||||
}
|
||||
static_assert(
|
||||
std::is_same<decltype(SharedQuadState::layer_id), uint32_t>::value);
|
||||
static_assert(std::is_same<decltype(SharedQuadState::layer_namespace_id),
|
||||
uint32_t>::value);
|
||||
candidate.aggregated_layer_id =
|
||||
static_cast<uint64_t>(sqs->layer_id) |
|
||||
(static_cast<uint64_t>(sqs->layer_namespace_id) << 32);
|
||||
|
||||
auto status = CandidateStatus::kFailQuadNotSupported;
|
||||
switch (quad->material) {
|
||||
|
Reference in New Issue
Block a user