VT: Rename DocumentTransition to ViewTransitions
R=khushalsagar@chromium.org, bokan@chromium.org
Change-Id: I44926449ef6f5731719484df924de56bd23bf63b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3993505
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Vladimir Levin <vmpstr@chromium.org>
Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
Reviewed-by: Philip Rogers <pdr@chromium.org>
Reviewed-by: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/main@{#1067633}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 96e1c03..f0690ee 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -33,10 +33,6 @@
"benchmarks/unittest_only_benchmark.h",
"benchmarks/unittest_only_benchmark_impl.cc",
"benchmarks/unittest_only_benchmark_impl.h",
- "document_transition/document_transition_request.cc",
- "document_transition/document_transition_request.h",
- "document_transition/document_transition_shared_element_id.cc",
- "document_transition/document_transition_shared_element_id.h",
"input/actively_scrolling_type.h",
"input/browser_controls_offset_manager.cc",
"input/browser_controls_offset_manager.h",
@@ -81,10 +77,6 @@
"layers/content_layer_client.h",
"layers/deadline_policy.cc",
"layers/deadline_policy.h",
- "layers/document_transition_content_layer.cc",
- "layers/document_transition_content_layer.h",
- "layers/document_transition_content_layer_impl.cc",
- "layers/document_transition_content_layer_impl.h",
"layers/draw_mode.h",
"layers/draw_properties.cc",
"layers/draw_properties.h",
@@ -163,6 +155,10 @@
"layers/video_layer.h",
"layers/video_layer_impl.cc",
"layers/video_layer_impl.h",
+ "layers/view_transition_content_layer.cc",
+ "layers/view_transition_content_layer.h",
+ "layers/view_transition_content_layer_impl.cc",
+ "layers/view_transition_content_layer_impl.h",
"layers/viewport.cc",
"layers/viewport.h",
"metrics/average_lag_tracker.cc",
@@ -443,6 +439,10 @@
"trees/viewport_layers.cc",
"trees/viewport_layers.h",
"trees/viewport_property_ids.h",
+ "view_transition/view_transition_request.cc",
+ "view_transition/view_transition_request.h",
+ "view_transition/view_transition_shared_element_id.cc",
+ "view_transition/view_transition_shared_element_id.h",
]
public_deps = [
@@ -689,7 +689,6 @@
"base/unique_notifier_unittest.cc",
"benchmarks/micro_benchmark_controller_unittest.cc",
"debug/rendering_stats_unittest.cc",
- "document_transition/document_transition_request_unittest.cc",
"input/browser_controls_offset_manager_unittest.cc",
"input/main_thread_scrolling_reason_unittest.cc",
"input/scroll_snap_data_unittest.cc",
@@ -824,6 +823,7 @@
"trees/throttle_decider_unittest.cc",
"trees/tree_synchronizer_unittest.cc",
"trees/ukm_manager_unittest.cc",
+ "view_transition/view_transition_request_unittest.cc",
# Animation test files.
"animation/animation_host_unittest.cc",
diff --git a/cc/document_transition/document_transition_shared_element_id.cc b/cc/document_transition/document_transition_shared_element_id.cc
deleted file mode 100644
index 5baacf7..0000000
--- a/cc/document_transition/document_transition_shared_element_id.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/document_transition/document_transition_shared_element_id.h"
-
-#include <sstream>
-#include <string>
-
-#include "base/check_op.h"
-#include "base/containers/flat_set.h"
-
-namespace cc {
-
-DocumentTransitionSharedElementId::DocumentTransitionSharedElementId() =
- default;
-
-DocumentTransitionSharedElementId::DocumentTransitionSharedElementId(
- uint32_t document_tag)
- : document_tag_(document_tag) {}
-
-DocumentTransitionSharedElementId::DocumentTransitionSharedElementId(
- DocumentTransitionSharedElementId&&) = default;
-
-DocumentTransitionSharedElementId::DocumentTransitionSharedElementId(
- const DocumentTransitionSharedElementId&) = default;
-
-DocumentTransitionSharedElementId::~DocumentTransitionSharedElementId() =
- default;
-
-void DocumentTransitionSharedElementId::AddIndex(uint32_t index) {
- DCHECK_NE(document_tag_, 0u);
- element_indices_.insert(index);
-}
-
-bool DocumentTransitionSharedElementId::Matches(uint32_t document_tag,
- uint32_t index) const {
- return document_tag_ == document_tag && element_indices_.count(index) != 0;
-}
-
-std::string DocumentTransitionSharedElementId::ToString() const {
- std::ostringstream str;
- str << "DocumentTransitionSharedElementId{ document_tag: " << document_tag_
- << " element_indices: [";
- std::string separator = "";
- for (auto index : element_indices_) {
- str << separator << index;
- separator = ", ";
- }
- str << "]}";
- return str.str();
-}
-
-} // namespace cc
diff --git a/cc/document_transition/document_transition_shared_element_id.h b/cc/document_transition/document_transition_shared_element_id.h
deleted file mode 100644
index 134a449..0000000
--- a/cc/document_transition/document_transition_shared_element_id.h
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_DOCUMENT_TRANSITION_DOCUMENT_TRANSITION_SHARED_ELEMENT_ID_H_
-#define CC_DOCUMENT_TRANSITION_DOCUMENT_TRANSITION_SHARED_ELEMENT_ID_H_
-
-#include <stdint.h>
-
-#include <string>
-#include <tuple>
-
-#include "base/containers/flat_set.h"
-#include "cc/cc_export.h"
-
-namespace cc {
-
-class CC_EXPORT DocumentTransitionSharedElementId {
- public:
- DocumentTransitionSharedElementId();
- explicit DocumentTransitionSharedElementId(uint32_t document_tag);
- DocumentTransitionSharedElementId(const DocumentTransitionSharedElementId&);
- DocumentTransitionSharedElementId(DocumentTransitionSharedElementId&&);
- ~DocumentTransitionSharedElementId();
-
- // Add a shared index to this id. It must have a valid document tag.
- void AddIndex(uint32_t index);
-
- // Returns true if the document tag matches this id and the index is in the
- // list of indices for this id.
- bool Matches(uint32_t document_tag, uint32_t index) const;
-
- DocumentTransitionSharedElementId& operator=(
- DocumentTransitionSharedElementId&&) = default;
-
- DocumentTransitionSharedElementId& operator=(
- const DocumentTransitionSharedElementId&) = default;
-
- bool operator==(const DocumentTransitionSharedElementId& other) const {
- return element_indices_ == other.element_indices_ &&
- document_tag_ == other.document_tag_;
- }
-
- bool operator!=(const DocumentTransitionSharedElementId& other) const {
- return !(*this == other);
- }
-
- bool operator<(const DocumentTransitionSharedElementId& other) const {
- return std::tie(document_tag_, element_indices_) <
- std::tie(other.document_tag_, other.element_indices_);
- }
-
- bool valid() const {
- return document_tag_ != 0u && !element_indices_.empty();
- }
-
- std::string ToString() const;
-
- private:
- uint32_t document_tag_ = 0u;
- base::flat_set<uint32_t> element_indices_;
-};
-
-} // namespace cc
-
-#endif // CC_DOCUMENT_TRANSITION_DOCUMENT_TRANSITION_SHARED_ELEMENT_ID_H_
diff --git a/cc/layers/append_quads_data.h b/cc/layers/append_quads_data.h
index c6ade61..939a92d 100644
--- a/cc/layers/append_quads_data.h
+++ b/cc/layers/append_quads_data.h
@@ -45,8 +45,8 @@
// activate.
std::vector<viz::SurfaceId> activation_dependencies;
- // Indicates if any layer has SharedElementResourceIds which need to be
- // swapped with actual viz::ResourceIds in the Viz process.
+ // Indicates if any layer has ViewTransitionElementResourceIds which need to
+ // be swapped with actual viz::ResourceIds in the Viz process.
bool has_shared_element_resources = false;
};
diff --git a/cc/layers/document_transition_content_layer.cc b/cc/layers/document_transition_content_layer.cc
deleted file mode 100644
index 7e982e0..0000000
--- a/cc/layers/document_transition_content_layer.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "cc/layers/document_transition_content_layer.h"
-
-#include <memory>
-
-#include "base/logging.h"
-#include "cc/layers/document_transition_content_layer_impl.h"
-#include "cc/trees/layer_tree_host.h"
-
-namespace cc {
-
-scoped_refptr<DocumentTransitionContentLayer>
-DocumentTransitionContentLayer::Create(
- const viz::SharedElementResourceId& resource_id,
- bool is_live_content_layer) {
- return base::WrapRefCounted(
- new DocumentTransitionContentLayer(resource_id, is_live_content_layer));
-}
-
-DocumentTransitionContentLayer::DocumentTransitionContentLayer(
- const viz::SharedElementResourceId& resource_id,
- bool is_live_content_layer)
- : resource_id_(resource_id),
- is_live_content_layer_(is_live_content_layer) {}
-
-DocumentTransitionContentLayer::~DocumentTransitionContentLayer() = default;
-
-viz::SharedElementResourceId
-DocumentTransitionContentLayer::DocumentTransitionResourceId() const {
- return resource_id_;
-}
-
-std::unique_ptr<LayerImpl> DocumentTransitionContentLayer::CreateLayerImpl(
- LayerTreeImpl* tree_impl) const {
- return DocumentTransitionContentLayerImpl::Create(
- tree_impl, id(), resource_id_, is_live_content_layer_);
-}
-
-} // namespace cc
diff --git a/cc/layers/document_transition_content_layer.h b/cc/layers/document_transition_content_layer.h
deleted file mode 100644
index 8c7a09a..0000000
--- a/cc/layers/document_transition_content_layer.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_LAYERS_DOCUMENT_TRANSITION_CONTENT_LAYER_H_
-#define CC_LAYERS_DOCUMENT_TRANSITION_CONTENT_LAYER_H_
-
-#include <memory>
-
-#include "base/logging.h"
-#include "cc/cc_export.h"
-#include "cc/layers/layer.h"
-#include "components/viz/common/shared_element_resource_id.h"
-
-namespace cc {
-
-// A layer that renders a texture cached in the Viz process.
-class CC_EXPORT DocumentTransitionContentLayer : public Layer {
- public:
- static scoped_refptr<DocumentTransitionContentLayer> Create(
- const viz::SharedElementResourceId& resource_id,
- bool is_live_content_layer);
-
- DocumentTransitionContentLayer(const DocumentTransitionContentLayer&) =
- delete;
- DocumentTransitionContentLayer& operator=(
- const DocumentTransitionContentLayer&) = delete;
-
- viz::SharedElementResourceId DocumentTransitionResourceId() const override;
-
- // Layer overrides.
- std::unique_ptr<LayerImpl> CreateLayerImpl(
- LayerTreeImpl* tree_impl) const override;
-
- protected:
- explicit DocumentTransitionContentLayer(
- const viz::SharedElementResourceId& resource_id,
- bool is_live_content_layer);
-
- private:
- ~DocumentTransitionContentLayer() override;
-
- const viz::SharedElementResourceId resource_id_;
- const bool is_live_content_layer_;
-};
-
-} // namespace cc
-
-#endif // CC_LAYERS_DOCUMENT_TRANSITION_CONTENT_LAYER_H_
diff --git a/cc/layers/document_transition_content_layer_impl.h b/cc/layers/document_transition_content_layer_impl.h
deleted file mode 100644
index 2c7938d..0000000
--- a/cc/layers/document_transition_content_layer_impl.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2021 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CC_LAYERS_DOCUMENT_TRANSITION_CONTENT_LAYER_IMPL_H_
-#define CC_LAYERS_DOCUMENT_TRANSITION_CONTENT_LAYER_IMPL_H_
-
-#include <memory>
-
-#include "cc/cc_export.h"
-#include "cc/layers/layer_impl.h"
-#include "components/viz/common/shared_element_resource_id.h"
-
-namespace cc {
-
-class CC_EXPORT DocumentTransitionContentLayerImpl : public LayerImpl {
- public:
- static std::unique_ptr<DocumentTransitionContentLayerImpl> Create(
- LayerTreeImpl* tree_impl,
- int id,
- const viz::SharedElementResourceId& resource_id,
- bool is_live_content_layer);
-
- DocumentTransitionContentLayerImpl(
- const DocumentTransitionContentLayerImpl&) = delete;
- ~DocumentTransitionContentLayerImpl() override;
-
- DocumentTransitionContentLayerImpl& operator=(
- const DocumentTransitionContentLayerImpl&) = delete;
-
- // LayerImpl overrides.
- std::unique_ptr<LayerImpl> CreateLayerImpl(
- LayerTreeImpl* tree_impl) const override;
- void AppendQuads(viz::CompositorRenderPass* render_pass,
- AppendQuadsData* append_quads_data) override;
-
- void NotifyKnownResourceIdsBeforeAppendQuads(
- const base::flat_set<viz::SharedElementResourceId>& known_resource_ids)
- override;
-
- protected:
- DocumentTransitionContentLayerImpl(
- LayerTreeImpl* tree_impl,
- int id,
- const viz::SharedElementResourceId& resource_id,
- bool is_live_content_layer);
-
- private:
- const char* LayerTypeAsString() const override;
-
- const viz::SharedElementResourceId resource_id_;
- const bool is_live_content_layer_;
- bool skip_unseen_resource_quads_ = false;
-};
-
-} // namespace cc
-
-#endif // CC_LAYERS_DOCUMENT_TRANSITION_CONTENT_LAYER_IMPL_H_
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 6bd2ae13..d73354c 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -36,7 +36,7 @@
#include "cc/trees/transform_node.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
-#include "components/viz/common/shared_element_resource_id.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
@@ -214,8 +214,8 @@
EnsureDebugInfo().name = name;
}
-viz::SharedElementResourceId Layer::DocumentTransitionResourceId() const {
- return viz::SharedElementResourceId();
+viz::ViewTransitionElementResourceId Layer::ViewTransitionResourceId() const {
+ return viz::ViewTransitionElementResourceId();
}
void Layer::SetNeedsFullTreeSync() {
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 16ee976..ffa88e4 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -30,9 +30,9 @@
#include "cc/trees/effect_node.h"
#include "cc/trees/property_tree.h"
#include "cc/trees/target_property.h"
-#include "components/viz/common/shared_element_resource_id.h"
#include "components/viz/common/surfaces/region_capture_bounds.h"
#include "components/viz/common/surfaces/subtree_capture_id.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/linear_gradient.h"
#include "ui/gfx/geometry/point3_f.h"
@@ -842,7 +842,7 @@
// If the content of this layer is provided by a cached or live render
// surface, returns the ID of that resource.
- virtual viz::SharedElementResourceId DocumentTransitionResourceId() const;
+ virtual viz::ViewTransitionElementResourceId ViewTransitionResourceId() const;
protected:
friend class LayerImpl;
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h
index 98a98494..a89a434c 100644
--- a/cc/layers/layer_impl.h
+++ b/cc/layers/layer_impl.h
@@ -459,7 +459,8 @@
virtual gfx::ContentColorUsage GetContentColorUsage() const;
virtual void NotifyKnownResourceIdsBeforeAppendQuads(
- const base::flat_set<viz::SharedElementResourceId>& known_resource_ids) {}
+ const base::flat_set<viz::ViewTransitionElementResourceId>&
+ known_resource_ids) {}
protected:
// When |will_always_push_properties| is true, the layer will not itself set
diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc
index 2e3bee3..adc750f 100644
--- a/cc/layers/render_surface_impl.cc
+++ b/cc/layers/render_surface_impl.cc
@@ -174,7 +174,7 @@
bool RenderSurfaceImpl::CopyOfOutputRequired() const {
return HasCopyRequest() || ShouldCacheRenderSurface() ||
SubtreeCaptureId().is_valid() ||
- OwningEffectNode()->shared_element_resource_id.IsValid();
+ OwningEffectNode()->view_transition_element_resource_id.IsValid();
}
int RenderSurfaceImpl::TransformTreeIndex() const {
@@ -194,9 +194,9 @@
EffectTreeIndex());
}
-const DocumentTransitionSharedElementId&
-RenderSurfaceImpl::GetDocumentTransitionSharedElementId() const {
- return OwningEffectNode()->document_transition_shared_element_id;
+const ViewTransitionElementId& RenderSurfaceImpl::GetViewTransitionElementId()
+ const {
+ return OwningEffectNode()->view_transition_shared_element_id;
}
void RenderSurfaceImpl::SetClipRect(const gfx::Rect& clip_rect) {
@@ -337,7 +337,7 @@
// If this surface is a shared element id then it is being used to generate an
// independent snapshot and won't contribute to its target surface.
if (contributing_surface->OwningEffectNode()
- ->shared_element_resource_id.IsValid())
+ ->view_transition_element_resource_id.IsValid())
return;
// The content rect of contributing surface is in its own space. Instead, we
@@ -425,8 +425,8 @@
pass->cache_render_pass = ShouldCacheRenderSurface();
pass->has_damage_from_contributing_content =
HasDamageFromeContributingContent();
- pass->shared_element_resource_id =
- OwningEffectNode()->shared_element_resource_id;
+ pass->view_transition_element_resource_id =
+ OwningEffectNode()->view_transition_element_resource_id;
return pass;
}
@@ -438,10 +438,10 @@
if (unoccluded_content_rect.IsEmpty())
return;
- // If this render surface has a valid |shared_element_resource_id| then its
- // being used to produce live content. Its content will be drawn to its
- // actual position in the Viz process.
- if (OwningEffectNode()->shared_element_resource_id.IsValid())
+ // If this render surface has a valid |view_transition_element_resource_id|
+ // then its being used to produce live content. Its content will be drawn to
+ // its actual position in the Viz process.
+ if (OwningEffectNode()->view_transition_element_resource_id.IsValid())
return;
const PropertyTrees* property_trees = layer_tree_impl_->property_trees();
diff --git a/cc/layers/render_surface_impl.h b/cc/layers/render_surface_impl.h
index 88ce4801..2e21ab5 100644
--- a/cc/layers/render_surface_impl.h
+++ b/cc/layers/render_surface_impl.h
@@ -14,11 +14,11 @@
#include "base/memory/raw_ptr.h"
#include "cc/cc_export.h"
-#include "cc/document_transition/document_transition_shared_element_id.h"
#include "cc/layers/draw_mode.h"
#include "cc/layers/layer_collections.h"
#include "cc/trees/occlusion.h"
#include "cc/trees/property_tree.h"
+#include "cc/view_transition/view_transition_shared_element_id.h"
#include "components/viz/common/quads/compositor_render_pass.h"
#include "components/viz/common/quads/shared_quad_state.h"
#include "components/viz/common/surfaces/subtree_capture_id.h"
@@ -240,8 +240,7 @@
const EffectNode* OwningEffectNode() const;
- const DocumentTransitionSharedElementId&
- GetDocumentTransitionSharedElementId() const;
+ const ViewTransitionElementId& GetViewTransitionElementId() const;
private:
void SetContentRect(const gfx::Rect& content_rect);
diff --git a/cc/layers/view_transition_content_layer.cc b/cc/layers/view_transition_content_layer.cc
new file mode 100644
index 0000000..4d872b8
--- /dev/null
+++ b/cc/layers/view_transition_content_layer.cc
@@ -0,0 +1,41 @@
+// Copyright 2021 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/layers/view_transition_content_layer.h"
+
+#include <memory>
+
+#include "base/logging.h"
+#include "cc/layers/view_transition_content_layer_impl.h"
+#include "cc/trees/layer_tree_host.h"
+
+namespace cc {
+
+scoped_refptr<ViewTransitionContentLayer> ViewTransitionContentLayer::Create(
+ const viz::ViewTransitionElementResourceId& resource_id,
+ bool is_live_content_layer) {
+ return base::WrapRefCounted(
+ new ViewTransitionContentLayer(resource_id, is_live_content_layer));
+}
+
+ViewTransitionContentLayer::ViewTransitionContentLayer(
+ const viz::ViewTransitionElementResourceId& resource_id,
+ bool is_live_content_layer)
+ : resource_id_(resource_id),
+ is_live_content_layer_(is_live_content_layer) {}
+
+ViewTransitionContentLayer::~ViewTransitionContentLayer() = default;
+
+viz::ViewTransitionElementResourceId
+ViewTransitionContentLayer::ViewTransitionResourceId() const {
+ return resource_id_;
+}
+
+std::unique_ptr<LayerImpl> ViewTransitionContentLayer::CreateLayerImpl(
+ LayerTreeImpl* tree_impl) const {
+ return ViewTransitionContentLayerImpl::Create(tree_impl, id(), resource_id_,
+ is_live_content_layer_);
+}
+
+} // namespace cc
diff --git a/cc/layers/view_transition_content_layer.h b/cc/layers/view_transition_content_layer.h
new file mode 100644
index 0000000..e047243
--- /dev/null
+++ b/cc/layers/view_transition_content_layer.h
@@ -0,0 +1,49 @@
+// Copyright 2021 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_LAYERS_VIEW_TRANSITION_CONTENT_LAYER_H_
+#define CC_LAYERS_VIEW_TRANSITION_CONTENT_LAYER_H_
+
+#include <memory>
+
+#include "base/logging.h"
+#include "cc/cc_export.h"
+#include "cc/layers/layer.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
+
+namespace cc {
+
+// A layer that renders a texture cached in the Viz process.
+class CC_EXPORT ViewTransitionContentLayer : public Layer {
+ public:
+ static scoped_refptr<ViewTransitionContentLayer> Create(
+ const viz::ViewTransitionElementResourceId& resource_id,
+ bool is_live_content_layer);
+
+ ViewTransitionContentLayer(const ViewTransitionContentLayer&) = delete;
+ ViewTransitionContentLayer& operator=(const ViewTransitionContentLayer&) =
+ delete;
+
+ viz::ViewTransitionElementResourceId ViewTransitionResourceId()
+ const override;
+
+ // Layer overrides.
+ std::unique_ptr<LayerImpl> CreateLayerImpl(
+ LayerTreeImpl* tree_impl) const override;
+
+ protected:
+ explicit ViewTransitionContentLayer(
+ const viz::ViewTransitionElementResourceId& resource_id,
+ bool is_live_content_layer);
+
+ private:
+ ~ViewTransitionContentLayer() override;
+
+ const viz::ViewTransitionElementResourceId resource_id_;
+ const bool is_live_content_layer_;
+};
+
+} // namespace cc
+
+#endif // CC_LAYERS_VIEW_TRANSITION_CONTENT_LAYER_H_
diff --git a/cc/layers/document_transition_content_layer_impl.cc b/cc/layers/view_transition_content_layer_impl.cc
similarity index 66%
rename from cc/layers/document_transition_content_layer_impl.cc
rename to cc/layers/view_transition_content_layer_impl.cc
index 562413b6..b4f03d3 100644
--- a/cc/layers/document_transition_content_layer_impl.cc
+++ b/cc/layers/view_transition_content_layer_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cc/layers/document_transition_content_layer_impl.h"
+#include "cc/layers/view_transition_content_layer_impl.h"
#include "base/memory/ptr_util.h"
#include "cc/layers/append_quads_data.h"
@@ -10,47 +10,45 @@
#include "cc/trees/layer_tree_impl.h"
#include "components/viz/common/quads/shared_element_draw_quad.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
-#include "components/viz/common/shared_element_resource_id.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
namespace cc {
// static
-std::unique_ptr<DocumentTransitionContentLayerImpl>
-DocumentTransitionContentLayerImpl::Create(
+std::unique_ptr<ViewTransitionContentLayerImpl>
+ViewTransitionContentLayerImpl::Create(
LayerTreeImpl* tree_impl,
int id,
- const viz::SharedElementResourceId& resource_id,
+ const viz::ViewTransitionElementResourceId& resource_id,
bool is_live_content_layer) {
- return base::WrapUnique(new DocumentTransitionContentLayerImpl(
+ return base::WrapUnique(new ViewTransitionContentLayerImpl(
tree_impl, id, resource_id, is_live_content_layer));
}
-DocumentTransitionContentLayerImpl::DocumentTransitionContentLayerImpl(
+ViewTransitionContentLayerImpl::ViewTransitionContentLayerImpl(
LayerTreeImpl* tree_impl,
int id,
- const viz::SharedElementResourceId& resource_id,
+ const viz::ViewTransitionElementResourceId& resource_id,
bool is_live_content_layer)
: LayerImpl(tree_impl, id),
resource_id_(resource_id),
is_live_content_layer_(is_live_content_layer) {}
-DocumentTransitionContentLayerImpl::~DocumentTransitionContentLayerImpl() =
- default;
+ViewTransitionContentLayerImpl::~ViewTransitionContentLayerImpl() = default;
-std::unique_ptr<LayerImpl> DocumentTransitionContentLayerImpl::CreateLayerImpl(
+std::unique_ptr<LayerImpl> ViewTransitionContentLayerImpl::CreateLayerImpl(
LayerTreeImpl* tree_impl) const {
- return DocumentTransitionContentLayerImpl::Create(
- tree_impl, id(), resource_id_, is_live_content_layer_);
+ return ViewTransitionContentLayerImpl::Create(tree_impl, id(), resource_id_,
+ is_live_content_layer_);
}
-void DocumentTransitionContentLayerImpl::
- NotifyKnownResourceIdsBeforeAppendQuads(
- const base::flat_set<viz::SharedElementResourceId>&
- known_resource_ids) {
+void ViewTransitionContentLayerImpl::NotifyKnownResourceIdsBeforeAppendQuads(
+ const base::flat_set<viz::ViewTransitionElementResourceId>&
+ known_resource_ids) {
skip_unseen_resource_quads_ = known_resource_ids.count(resource_id_) == 0;
}
-void DocumentTransitionContentLayerImpl::AppendQuads(
+void ViewTransitionContentLayerImpl::AppendQuads(
viz::CompositorRenderPass* render_pass,
AppendQuadsData* append_quads_data) {
// Skip live content elements that don't have a corresponding resource render
@@ -84,8 +82,8 @@
append_quads_data->has_shared_element_resources = true;
}
-const char* DocumentTransitionContentLayerImpl::LayerTypeAsString() const {
- return "cc::DocumentTransitionContentLayerImpl";
+const char* ViewTransitionContentLayerImpl::LayerTypeAsString() const {
+ return "cc::ViewTransitionContentLayerImpl";
}
} // namespace cc
diff --git a/cc/layers/view_transition_content_layer_impl.h b/cc/layers/view_transition_content_layer_impl.h
new file mode 100644
index 0000000..de7cd3c
--- /dev/null
+++ b/cc/layers/view_transition_content_layer_impl.h
@@ -0,0 +1,58 @@
+// Copyright 2021 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_LAYERS_VIEW_TRANSITION_CONTENT_LAYER_IMPL_H_
+#define CC_LAYERS_VIEW_TRANSITION_CONTENT_LAYER_IMPL_H_
+
+#include <memory>
+
+#include "cc/cc_export.h"
+#include "cc/layers/layer_impl.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
+
+namespace cc {
+
+class CC_EXPORT ViewTransitionContentLayerImpl : public LayerImpl {
+ public:
+ static std::unique_ptr<ViewTransitionContentLayerImpl> Create(
+ LayerTreeImpl* tree_impl,
+ int id,
+ const viz::ViewTransitionElementResourceId& resource_id,
+ bool is_live_content_layer);
+
+ ViewTransitionContentLayerImpl(const ViewTransitionContentLayerImpl&) =
+ delete;
+ ~ViewTransitionContentLayerImpl() override;
+
+ ViewTransitionContentLayerImpl& operator=(
+ const ViewTransitionContentLayerImpl&) = delete;
+
+ // LayerImpl overrides.
+ std::unique_ptr<LayerImpl> CreateLayerImpl(
+ LayerTreeImpl* tree_impl) const override;
+ void AppendQuads(viz::CompositorRenderPass* render_pass,
+ AppendQuadsData* append_quads_data) override;
+
+ void NotifyKnownResourceIdsBeforeAppendQuads(
+ const base::flat_set<viz::ViewTransitionElementResourceId>&
+ known_resource_ids) override;
+
+ protected:
+ ViewTransitionContentLayerImpl(
+ LayerTreeImpl* tree_impl,
+ int id,
+ const viz::ViewTransitionElementResourceId& resource_id,
+ bool is_live_content_layer);
+
+ private:
+ const char* LayerTypeAsString() const override;
+
+ const viz::ViewTransitionElementResourceId resource_id_;
+ const bool is_live_content_layer_;
+ bool skip_unseen_resource_quads_ = false;
+};
+
+} // namespace cc
+
+#endif // CC_LAYERS_VIEW_TRANSITION_CONTENT_LAYER_IMPL_H_
diff --git a/cc/trees/commit_state.h b/cc/trees/commit_state.h
index f0299db..736014c 100644
--- a/cc/trees/commit_state.h
+++ b/cc/trees/commit_state.h
@@ -17,7 +17,6 @@
#include "cc/benchmarks/micro_benchmark_impl.h"
#include "cc/cc_export.h"
#include "cc/debug/layer_tree_debug_state.h"
-#include "cc/document_transition/document_transition_request.h"
#include "cc/input/event_listener_properties.h"
#include "cc/input/layer_selection_bound.h"
#include "cc/input/overscroll_behavior.h"
@@ -32,6 +31,7 @@
#include "cc/trees/presentation_time_callback_buffer.h"
#include "cc/trees/swap_promise.h"
#include "cc/trees/viewport_property_ids.h"
+#include "cc/view_transition/view_transition_request.h"
#include "components/viz/common/surfaces/local_surface_id.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/delegated_ink_metadata.h"
@@ -142,10 +142,9 @@
std::vector<PresentationTimeCallbackBuffer::MainCallback>
pending_presentation_time_callbacks;
std::vector<std::unique_ptr<MicroBenchmarkImpl>> benchmarks;
- // A list of document transitions that need to be transported from Blink to
+ // A list of view transitions that need to be transported from Blink to
// Viz, as a CompositorFrameTransitionDirective.
- std::vector<std::unique_ptr<DocumentTransitionRequest>>
- document_transition_requests;
+ std::vector<std::unique_ptr<ViewTransitionRequest>> view_transition_requests;
std::vector<std::unique_ptr<SwapPromise>> swap_promises;
std::vector<UIResourceRequest> ui_resource_request_queue;
base::flat_map<UIResourceId, gfx::Size> ui_resource_sizes;
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index f446d27..41dba5fc 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -33,7 +33,7 @@
#include "cc/trees/transform_node.h"
#include "cc/trees/viewport_property_ids.h"
#include "components/viz/common/display/de_jelly.h"
-#include "components/viz/common/shared_element_resource_id.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace cc {
diff --git a/cc/trees/effect_node.cc b/cc/trees/effect_node.cc
index e2e0dfb..5a151b44 100644
--- a/cc/trees/effect_node.cc
+++ b/cc/trees/effect_node.cc
@@ -153,8 +153,8 @@
return "mirrored";
case RenderSurfaceReason::kSubtreeIsBeingCaptured:
return "subtree being captured";
- case RenderSurfaceReason::kDocumentTransitionParticipant:
- return "document transition participant";
+ case RenderSurfaceReason::kViewTransitionParticipant:
+ return "view transition participant";
case RenderSurfaceReason::kTest:
return "test";
default:
diff --git a/cc/trees/effect_node.h b/cc/trees/effect_node.h
index 77d3e52..4c305773 100644
--- a/cc/trees/effect_node.h
+++ b/cc/trees/effect_node.h
@@ -6,11 +6,11 @@
#define CC_TREES_EFFECT_NODE_H_
#include "cc/cc_export.h"
-#include "cc/document_transition/document_transition_shared_element_id.h"
#include "cc/paint/element_id.h"
#include "cc/paint/filter_operations.h"
-#include "components/viz/common/shared_element_resource_id.h"
+#include "cc/view_transition/view_transition_shared_element_id.h"
#include "components/viz/common/surfaces/subtree_capture_id.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "ui/gfx/geometry/mask_filter_info.h"
@@ -50,7 +50,7 @@
kCopyRequest,
kMirrored,
kSubtreeIsBeingCaptured,
- kDocumentTransitionParticipant,
+ kViewTransitionParticipant,
kGradientMask,
// This must be the last value because it's used in tracing code to know the
// number of reasons.
@@ -168,12 +168,12 @@
int closest_ancestor_being_captured_id;
int closest_ancestor_with_shared_element_id;
- // Represents a shared element id for the document transition API.
- DocumentTransitionSharedElementId document_transition_shared_element_id;
+ // Represents a DOM element id for the view transition API.
+ ViewTransitionElementId view_transition_shared_element_id;
// Represents a resource id for a resource cached or generated in the Viz
// process.
- viz::SharedElementResourceId shared_element_resource_id;
+ viz::ViewTransitionElementResourceId view_transition_element_resource_id;
bool HasRenderSurface() const {
return render_surface_reason != RenderSurfaceReason::kNone;
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 4dbd019..00ca3e2d 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -36,7 +36,6 @@
#include "cc/base/histograms.h"
#include "cc/base/math_util.h"
#include "cc/debug/rendering_stats_instrumentation.h"
-#include "cc/document_transition/document_transition_request.h"
#include "cc/input/layer_selection_bound.h"
#include "cc/input/overscroll_behavior.h"
#include "cc/input/page_scale_animation.h"
@@ -68,6 +67,7 @@
#include "cc/trees/transform_node.h"
#include "cc/trees/tree_synchronizer.h"
#include "cc/trees/ukm_manager.h"
+#include "cc/view_transition/view_transition_request.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
@@ -506,11 +506,11 @@
// TODO(vmpstr): This might also be a good spot to expire long standing
// requests if they were not finished.
for (auto& sequence_id : sequence_ids) {
- auto it = document_transition_callbacks_.find(sequence_id);
- if (it == document_transition_callbacks_.end())
+ auto it = view_transition_callbacks_.find(sequence_id);
+ if (it == view_transition_callbacks_.end())
continue;
std::move(it->second).Run();
- document_transition_callbacks_.erase(it);
+ view_transition_callbacks_.erase(it);
}
}
@@ -891,17 +891,15 @@
first_scroll_timestamp);
}
-void LayerTreeHost::AddDocumentTransitionRequest(
- std::unique_ptr<DocumentTransitionRequest> request) {
+void LayerTreeHost::AddViewTransitionRequest(
+ std::unique_ptr<ViewTransitionRequest> request) {
// Store the commit callback on LayerTreeHost, so that we can invoke them
// when the request is finished.
- DCHECK(
- !base::Contains(document_transition_callbacks_, request->sequence_id()));
+ DCHECK(!base::Contains(view_transition_callbacks_, request->sequence_id()));
if (auto callback = request->TakeFinishedCallback()) {
- document_transition_callbacks_[request->sequence_id()] =
- std::move(callback);
+ view_transition_callbacks_[request->sequence_id()] = std::move(callback);
}
- pending_commit_state()->document_transition_requests.push_back(
+ pending_commit_state()->view_transition_requests.push_back(
std::move(request));
SetNeedsCommit();
}
@@ -2024,12 +2022,12 @@
}
std::vector<base::OnceClosure>
-LayerTreeHost::TakeDocumentTransitionCallbacksForTesting() {
+LayerTreeHost::TakeViewTransitionCallbacksForTesting() {
DCHECK(IsMainThread());
std::vector<base::OnceClosure> result;
- for (auto& item : document_transition_callbacks_)
+ for (auto& item : view_transition_callbacks_)
result.push_back(std::move(item.second));
- document_transition_callbacks_.clear();
+ view_transition_callbacks_.clear();
return result;
}
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index fa05133..0c5cd2c 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -74,7 +74,7 @@
namespace cc {
-class DocumentTransitionRequest;
+class ViewTransitionRequest;
class HeadsUpDisplayLayer;
class LayerTreeHostImpl;
class LayerTreeHostImplClient;
@@ -861,10 +861,9 @@
void DidObserveFirstScrollDelay(base::TimeDelta first_scroll_delay,
base::TimeTicks first_scroll_timestamp);
- void AddDocumentTransitionRequest(
- std::unique_ptr<DocumentTransitionRequest> request);
+ void AddViewTransitionRequest(std::unique_ptr<ViewTransitionRequest> request);
- std::vector<base::OnceClosure> TakeDocumentTransitionCallbacksForTesting();
+ std::vector<base::OnceClosure> TakeViewTransitionCallbacksForTesting();
// Returns a percentage of dropped frames of the last second.
double GetPercentDroppedFrames() const;
@@ -1064,7 +1063,7 @@
EventsMetricsManager events_metrics_manager_;
// A list of callbacks that need to be invoked when they are processed.
- base::flat_map<uint32_t, base::OnceClosure> document_transition_callbacks_;
+ base::flat_map<uint32_t, base::OnceClosure> view_transition_callbacks_;
// Set if WaitForCommitCompletion() was called before commit completes. Used
// for histograms.
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 80473b9..343906ed 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -44,7 +44,6 @@
#include "cc/base/switches.h"
#include "cc/benchmarks/benchmark_instrumentation.h"
#include "cc/debug/rendering_stats_instrumentation.h"
-#include "cc/document_transition/document_transition_request.h"
#include "cc/input/browser_controls_offset_manager.h"
#include "cc/input/page_scale_animation.h"
#include "cc/input/scrollbar_animation_controller.h"
@@ -96,6 +95,7 @@
#include "cc/trees/scroll_node.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/tree_synchronizer.h"
+#include "cc/view_transition/view_transition_request.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_timing_details.h"
#include "components/viz/common/hit_test/hit_test_region_list.h"
@@ -1308,7 +1308,7 @@
return root_surface_has_visible_damage ||
active_tree_->property_trees()->effect_tree().HasCopyRequests() ||
- hud_wants_to_draw_ || active_tree_->HasDocumentTransitionRequests();
+ hud_wants_to_draw_ || active_tree_->HasViewTransitionRequests();
}
DrawResult LayerTreeHostImpl::CalculateRenderPasses(FrameData* frame) {
@@ -1344,7 +1344,7 @@
// crbug.com/805673.
active_tree_->ResetHandleVisibilityChanged();
- base::flat_set<viz::SharedElementResourceId> known_resource_ids;
+ base::flat_set<viz::ViewTransitionElementResourceId> known_resource_ids;
// Create the render passes in dependency order.
size_t render_surface_list_size = frame->render_surface_list->size();
for (size_t i = 0; i < render_surface_list_size; ++i) {
@@ -1360,9 +1360,9 @@
if (should_draw_into_render_pass)
frame->render_passes.push_back(render_surface->CreateRenderPass());
if (render_surface->OwningEffectNode()
- ->shared_element_resource_id.IsValid()) {
- known_resource_ids.insert(
- render_surface->OwningEffectNode()->shared_element_resource_id);
+ ->view_transition_element_resource_id.IsValid()) {
+ known_resource_ids.insert(render_surface->OwningEffectNode()
+ ->view_transition_element_resource_id);
}
}
@@ -1771,7 +1771,7 @@
pass->backdrop_filters.IsEmpty() &&
// TODO(khushalsagar) : Send information about no-op passes to viz to
// retain this optimization for shared elements. See crbug.com/1265178.
- !pass->shared_element_resource_id.IsValid()) {
+ !pass->view_transition_element_resource_id.IsValid()) {
// Remove the pass and decrement |i| to counter the for loop's increment,
// so we don't skip the next pass in the loop.
frame->render_passes.erase(frame->render_passes.begin() + i);
@@ -1791,7 +1791,7 @@
viz::CompositorRenderPass* pass =
frame->render_passes[frame->render_passes.size() - 2 - i].get();
if (!pass->copy_requests.empty() ||
- pass->shared_element_resource_id.IsValid()) {
+ pass->view_transition_element_resource_id.IsValid()) {
continue;
}
if (pass_references[pass->id])
@@ -2720,10 +2720,10 @@
viz::CompositorFrameMetadata metadata = MakeCompositorFrameMetadata();
- DocumentTransitionRequest::SharedElementMap shared_element_render_pass_id_map;
+ ViewTransitionRequest::SharedElementMap shared_element_render_pass_id_map;
for (RenderSurfaceImpl* render_surface : *frame->render_surface_list) {
const auto& shared_element_id =
- render_surface->GetDocumentTransitionSharedElementId();
+ render_surface->GetViewTransitionElementId();
if (!shared_element_id.valid())
continue;
@@ -2738,10 +2738,10 @@
shared_element_render_pass_id_map[shared_element_id].render_pass_id =
render_surface->render_pass_id();
shared_element_render_pass_id_map[shared_element_id].resource_id =
- render_surface->OwningEffectNode()->shared_element_resource_id;
+ render_surface->OwningEffectNode()->view_transition_element_resource_id;
}
- for (auto& request : active_tree_->TakeDocumentTransitionRequests()) {
+ for (auto& request : active_tree_->TakeViewTransitionRequests()) {
metadata.transition_directives.push_back(
request->ConstructDirective(shared_element_render_pass_id_map));
}
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index cdcc116..0a1137ba 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -26,7 +26,6 @@
#include "cc/animation/animation_id_provider.h"
#include "cc/base/features.h"
#include "cc/base/histograms.h"
-#include "cc/document_transition/document_transition_request.h"
#include "cc/input/browser_controls_offset_manager.h"
#include "cc/input/input_handler.h"
#include "cc/input/main_thread_scrolling_reason.h"
@@ -72,6 +71,7 @@
#include "cc/trees/render_frame_metadata_observer.h"
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
+#include "cc/view_transition/view_transition_request.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
@@ -18493,7 +18493,7 @@
GetInputHandler().FindFrameElementIdAtPoint(gfx::PointF(30, 30)));
}
-TEST_F(LayerTreeHostImplTest, DocumentTransitionRequestCausesDamage) {
+TEST_F(LayerTreeHostImplTest, ViewTransitionRequestCausesDamage) {
const gfx::Size viewport_size(100, 100);
SetupDefaultRootLayer(viewport_size);
UpdateDrawProperties(host_impl_->active_tree());
@@ -18517,8 +18517,8 @@
did_request_redraw_ = false;
// Adding a transition effect should cause us to redraw.
- host_impl_->active_tree()->AddDocumentTransitionRequest(
- DocumentTransitionRequest::CreateAnimateRenderer(
+ host_impl_->active_tree()->AddViewTransitionRequest(
+ ViewTransitionRequest::CreateAnimateRenderer(
/*document_tag=*/0, viz::NavigationID::Null()));
// Ensure there is damage and we requested a redraw.
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 94a27c4..7ac12f6 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -27,7 +27,6 @@
#include "build/build_config.h"
#include "cc/animation/animation_host.h"
#include "cc/base/features.h"
-#include "cc/document_transition/document_transition_request.h"
#include "cc/input/scroll_elasticity_helper.h"
#include "cc/layers/content_layer_client.h"
#include "cc/layers/heads_up_display_layer.h"
@@ -70,6 +69,7 @@
#include "cc/trees/swap_promise.h"
#include "cc/trees/swap_promise_manager.h"
#include "cc/trees/transform_node.h"
+#include "cc/view_transition/view_transition_request.h"
#include "components/ukm/test_ukm_recorder.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"
@@ -9929,7 +9929,7 @@
MULTI_THREAD_TEST_F(LayerTreeHostUkmSmoothnessMemoryOwnership);
-class LayerTreeHostTestDocumentTransitionsPropagatedToMetadata
+class LayerTreeHostTestViewTransitionsPropagatedToMetadata
: public LayerTreeHostTest {
protected:
void SetupTree() override {
@@ -9938,8 +9938,8 @@
}
void BeginTest() override {
- layer_tree_host()->AddDocumentTransitionRequest(
- DocumentTransitionRequest::CreateCapture(
+ layer_tree_host()->AddViewTransitionRequest(
+ ViewTransitionRequest::CreateCapture(
/*document_tag=*/0, /*shared_element_count=*/0,
viz::NavigationID::Null(), {},
base::BindLambdaForTesting([this]() { CommitLambdaCalled(); })));
@@ -9970,7 +9970,7 @@
};
SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostTestDocumentTransitionsPropagatedToMetadata);
+ LayerTreeHostTestViewTransitionsPropagatedToMetadata);
class LayerTreeHostTestDebugStateDowngrade : public LayerTreeHostTest {
void InitializeSettings(LayerTreeSettings* settings) override {
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 3d199b4..0689fed2 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -34,7 +34,6 @@
#include "cc/base/histograms.h"
#include "cc/base/math_util.h"
#include "cc/base/synced_property.h"
-#include "cc/document_transition/document_transition_request.h"
#include "cc/input/page_scale_animation.h"
#include "cc/input/scrollbar_animation_controller.h"
#include "cc/layers/effect_tree_layer_list_iterator.h"
@@ -54,6 +53,7 @@
#include "cc/trees/scroll_node.h"
#include "cc/trees/transform_node.h"
#include "cc/trees/tree_synchronizer.h"
+#include "cc/view_transition/view_transition_request.h"
#include "components/viz/common/traced_value.h"
#include "ui/gfx/geometry/box_f.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -743,8 +743,8 @@
delegated_ink_metadata_.reset();
// Transfer page transition directives.
- for (auto& request : commit_state.document_transition_requests)
- AddDocumentTransitionRequest(std::move(request));
+ for (auto& request : commit_state.view_transition_requests)
+ AddViewTransitionRequest(std::move(request));
SetVisualUpdateDurations(
commit_state.previous_surfaces_visual_update_duration,
@@ -874,8 +874,8 @@
target_tree->clear_delegated_ink_metadata();
}
- for (auto& request : TakeDocumentTransitionRequests())
- target_tree->AddDocumentTransitionRequest(std::move(request));
+ for (auto& request : TakeViewTransitionRequests())
+ target_tree->AddViewTransitionRequest(std::move(request));
target_tree->SetVisualUpdateDurations(
previous_surfaces_visual_update_duration_, visual_update_duration_);
@@ -2900,20 +2900,20 @@
return value.ToFormattedJSON();
}
-void LayerTreeImpl::AddDocumentTransitionRequest(
- std::unique_ptr<DocumentTransitionRequest> request) {
- document_transition_requests_.push_back(std::move(request));
+void LayerTreeImpl::AddViewTransitionRequest(
+ std::unique_ptr<ViewTransitionRequest> request) {
+ view_transition_requests_.push_back(std::move(request));
// We need to send the request to viz.
SetNeedsRedraw();
}
-std::vector<std::unique_ptr<DocumentTransitionRequest>>
-LayerTreeImpl::TakeDocumentTransitionRequests() {
- return std::move(document_transition_requests_);
+std::vector<std::unique_ptr<ViewTransitionRequest>>
+LayerTreeImpl::TakeViewTransitionRequests() {
+ return std::move(view_transition_requests_);
}
-bool LayerTreeImpl::HasDocumentTransitionRequests() const {
- return !document_transition_requests_.empty();
+bool LayerTreeImpl::HasViewTransitionRequests() const {
+ return !view_transition_requests_.empty();
}
bool LayerTreeImpl::IsReadyToActivate() const {
diff --git a/cc/trees/layer_tree_impl.h b/cc/trees/layer_tree_impl.h
index bc0a7f3..b76ed09c 100644
--- a/cc/trees/layer_tree_impl.h
+++ b/cc/trees/layer_tree_impl.h
@@ -49,7 +49,7 @@
enum class ActivelyScrollingType;
class DebugRectHistory;
-class DocumentTransitionRequest;
+class ViewTransitionRequest;
class DroppedFrameCounter;
class HeadsUpDisplayLayerImpl;
class ImageDecodeCache;
@@ -791,16 +791,15 @@
return host_impl_->viewport_mobile_optimized();
}
- // Add a document transition request from the embedder.
- void AddDocumentTransitionRequest(
- std::unique_ptr<DocumentTransitionRequest> request);
+ // Add a view transition request from the embedder.
+ void AddViewTransitionRequest(std::unique_ptr<ViewTransitionRequest> request);
- // Returns all of the document transition requests stored so far, and empties
+ // Returns all of the view transition requests stored so far, and empties
// the internal list.
- std::vector<std::unique_ptr<DocumentTransitionRequest>>
- TakeDocumentTransitionRequests();
+ std::vector<std::unique_ptr<ViewTransitionRequest>>
+ TakeViewTransitionRequests();
- bool HasDocumentTransitionRequests() const;
+ bool HasViewTransitionRequests() const;
void ClearVisualUpdateDurations();
void SetVisualUpdateDurations(
@@ -969,8 +968,7 @@
std::unique_ptr<gfx::DelegatedInkMetadata> delegated_ink_metadata_;
// Document transition requests to be transferred to Viz.
- std::vector<std::unique_ptr<DocumentTransitionRequest>>
- document_transition_requests_;
+ std::vector<std::unique_ptr<ViewTransitionRequest>> view_transition_requests_;
// The cumulative time spent performing visual updates for all Surfaces before
// this one.
diff --git a/cc/trees/occlusion_tracker.cc b/cc/trees/occlusion_tracker.cc
index d3248926..298c2ef 100644
--- a/cc/trees/occlusion_tracker.cc
+++ b/cc/trees/occlusion_tracker.cc
@@ -202,7 +202,7 @@
!IsOccludingBlendMode(finished_target_surface->BlendMode()) ||
target_is_only_for_copy_request_or_force_render_surface ||
finished_target_surface->Filters().HasFilterThatAffectsOpacity() ||
- finished_target_surface->GetDocumentTransitionSharedElementId().valid()) {
+ finished_target_surface->GetViewTransitionElementId().valid()) {
stack_.back().occlusion_from_outside_target.Clear();
stack_.back().occlusion_from_inside_target.Clear();
}
diff --git a/cc/trees/paint_holding_commit_trigger.cc b/cc/trees/paint_holding_commit_trigger.cc
index fd67cb71..ac2e1d7 100644
--- a/cc/trees/paint_holding_commit_trigger.cc
+++ b/cc/trees/paint_holding_commit_trigger.cc
@@ -12,8 +12,8 @@
switch (reason) {
case PaintHoldingReason::kFirstContentfulPaint:
return PaintHoldingCommitTrigger::kTimeoutFCP;
- case PaintHoldingReason::kDocumentTransition:
- return PaintHoldingCommitTrigger::kTimeoutDocumentTransition;
+ case PaintHoldingReason::kViewTransition:
+ return PaintHoldingCommitTrigger::kTimeoutViewTransition;
}
NOTREACHED();
return PaintHoldingCommitTrigger::kTimeoutFCP;
diff --git a/cc/trees/paint_holding_commit_trigger.h b/cc/trees/paint_holding_commit_trigger.h
index b9869f04..a86e96e 100644
--- a/cc/trees/paint_holding_commit_trigger.h
+++ b/cc/trees/paint_holding_commit_trigger.h
@@ -23,12 +23,12 @@
kTimeoutFCP = 3,
// The timeout was never set, probably due to non-main frame
kNotDeferred = 4,
- // The commit was triggered by a document transition start
- kDocumentTransition = 5,
- // The commit was triggered by a timeout waiting for document transition start
- kTimeoutDocumentTransition = 6,
+ // The commit was triggered by a view transition start
+ kViewTransition = 5,
+ // The commit was triggered by a timeout waiting for view transition start
+ kTimeoutViewTransition = 6,
// Required for UMA enum
- kMaxValue = kTimeoutDocumentTransition
+ kMaxValue = kTimeoutViewTransition
};
PaintHoldingCommitTrigger ReasonToTimeoutTrigger(PaintHoldingReason reason);
diff --git a/cc/trees/paint_holding_reason.h b/cc/trees/paint_holding_reason.h
index a97c2d5..066195c7 100644
--- a/cc/trees/paint_holding_reason.h
+++ b/cc/trees/paint_holding_reason.h
@@ -13,7 +13,7 @@
// Deferred to allow the document to be updated asynchronously for a
// transition.
- kDocumentTransition,
+ kViewTransition,
};
} // namespace cc
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index 8dd4eb0..05075d0 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -895,7 +895,7 @@
EffectNode* parent_node) {
node->only_draws_visible_content =
!node->has_copy_request && !node->subtree_capture_id.is_valid() &&
- !node->shared_element_resource_id.IsValid();
+ !node->view_transition_element_resource_id.IsValid();
if (parent_node)
node->only_draws_visible_content &= parent_node->only_draws_visible_content;
if (!node->backdrop_filters.IsEmpty()) {
@@ -999,7 +999,7 @@
void EffectTree::UpdateClosestAncestorSharedElement(EffectNode* node,
EffectNode* parent_node) {
- if (node->shared_element_resource_id.IsValid()) {
+ if (node->view_transition_element_resource_id.IsValid()) {
node->closest_ancestor_with_shared_element_id = node->id;
} else if (parent_node) {
node->closest_ancestor_with_shared_element_id =
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h
index ffd0ad5..6c36ce7 100644
--- a/cc/trees/property_tree.h
+++ b/cc/trees/property_tree.h
@@ -30,7 +30,7 @@
#include "cc/trees/scroll_node.h"
#include "cc/trees/sticky_position_constraint.h"
#include "cc/trees/transform_node.h"
-#include "components/viz/common/shared_element_resource_id.h"
+#include "components/viz/common/view_transition_element_resource_id.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect_f.h"
diff --git a/cc/document_transition/README.md b/cc/view_transition/README.md
similarity index 67%
rename from cc/document_transition/README.md
rename to cc/view_transition/README.md
index 3b764d35..10bf4070 100644
--- a/cc/document_transition/README.md
+++ b/cc/view_transition/README.md
@@ -1,5 +1,5 @@
# cc/document\_transition
-The document transition direction supports the Document Transition and Shared
+The view transition direction supports the Document Transition and Shared
Element Transition projects in Blink. Please see
//third\_party/blink/renderer/core/document\_transition/README.md for more details.
diff --git a/cc/document_transition/document_transition_request.cc b/cc/view_transition/view_transition_request.cc
similarity index 69%
rename from cc/document_transition/document_transition_request.cc
rename to cc/view_transition/view_transition_request.cc
index ba2ae07..70030766 100644
--- a/cc/document_transition/document_transition_request.cc
+++ b/cc/view_transition/view_transition_request.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cc/document_transition/document_transition_request.h"
+#include "cc/view_transition/view_transition_request.h"
#include <map>
#include <memory>
@@ -14,7 +14,7 @@
#include "base/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/ranges/algorithm.h"
-#include "cc/document_transition/document_transition_shared_element_id.h"
+#include "cc/view_transition/view_transition_shared_element_id.h"
#include "components/viz/common/quads/compositor_frame_transition_directive.h"
#include "components/viz/common/quads/compositor_render_pass.h"
@@ -35,45 +35,43 @@
} // namespace
-uint32_t DocumentTransitionRequest::s_next_sequence_id_ = 1;
+uint32_t ViewTransitionRequest::s_next_sequence_id_ = 1;
// static
-std::unique_ptr<DocumentTransitionRequest>
-DocumentTransitionRequest::CreateCapture(
+std::unique_ptr<ViewTransitionRequest> ViewTransitionRequest::CreateCapture(
uint32_t document_tag,
uint32_t shared_element_count,
viz::NavigationID navigation_id,
- std::vector<viz::SharedElementResourceId> capture_ids,
+ std::vector<viz::ViewTransitionElementResourceId> capture_ids,
base::OnceClosure commit_callback) {
- return base::WrapUnique(new DocumentTransitionRequest(
+ return base::WrapUnique(new ViewTransitionRequest(
Type::kSave, document_tag, shared_element_count, navigation_id,
std::move(capture_ids), std::move(commit_callback)));
}
// static
-std::unique_ptr<DocumentTransitionRequest>
-DocumentTransitionRequest::CreateAnimateRenderer(
- uint32_t document_tag,
- viz::NavigationID navigation_id) {
+std::unique_ptr<ViewTransitionRequest>
+ViewTransitionRequest::CreateAnimateRenderer(uint32_t document_tag,
+ viz::NavigationID navigation_id) {
return base::WrapUnique(
- new DocumentTransitionRequest(Type::kAnimateRenderer, document_tag, 0u,
- navigation_id, {}, base::OnceClosure()));
+ new ViewTransitionRequest(Type::kAnimateRenderer, document_tag, 0u,
+ navigation_id, {}, base::OnceClosure()));
}
// static
-std::unique_ptr<DocumentTransitionRequest>
-DocumentTransitionRequest::CreateRelease(uint32_t document_tag) {
- return base::WrapUnique(new DocumentTransitionRequest(
+std::unique_ptr<ViewTransitionRequest> ViewTransitionRequest::CreateRelease(
+ uint32_t document_tag) {
+ return base::WrapUnique(new ViewTransitionRequest(
Type::kRelease, document_tag, 0u, viz::NavigationID::Null(), {},
base::OnceClosure()));
}
-DocumentTransitionRequest::DocumentTransitionRequest(
+ViewTransitionRequest::ViewTransitionRequest(
Type type,
uint32_t document_tag,
uint32_t shared_element_count,
viz::NavigationID navigation_id,
- std::vector<viz::SharedElementResourceId> capture_ids,
+ std::vector<viz::ViewTransitionElementResourceId> capture_ids,
base::OnceClosure commit_callback)
: type_(type),
document_tag_(document_tag),
@@ -85,10 +83,10 @@
DCHECK(type_ == Type::kSave || !commit_callback_);
}
-DocumentTransitionRequest::~DocumentTransitionRequest() = default;
+ViewTransitionRequest::~ViewTransitionRequest() = default;
viz::CompositorFrameTransitionDirective
-DocumentTransitionRequest::ConstructDirective(
+ViewTransitionRequest::ConstructDirective(
const SharedElementMap& shared_element_render_pass_id_map) const {
std::vector<viz::CompositorFrameTransitionDirective::SharedElement>
shared_elements(shared_element_count_);
@@ -102,7 +100,8 @@
if (it == shared_element_render_pass_id_map.end())
continue;
shared_elements[i].render_pass_id = it->second.render_pass_id;
- shared_elements[i].shared_element_resource_id = it->second.resource_id;
+ shared_elements[i].view_transition_element_resource_id =
+ it->second.resource_id;
// Remove the resource id from our capture ids, since we just want to have
// "empty" resource ids left -- the ones that don't have a render pass
@@ -116,21 +115,22 @@
// Add invalid render pass id for each empty resource id left in capture ids.
for (auto& empty_resource_id : capture_resource_ids) {
shared_elements.emplace_back();
- shared_elements.back().shared_element_resource_id = empty_resource_id;
+ shared_elements.back().view_transition_element_resource_id =
+ empty_resource_id;
}
return viz::CompositorFrameTransitionDirective(
navigation_id_, sequence_id_, type_, std::move(shared_elements));
}
-std::string DocumentTransitionRequest::ToString() const {
+std::string ViewTransitionRequest::ToString() const {
std::ostringstream str;
str << "[type: " << TypeToString(type_) << " sequence_id: " << sequence_id_
<< "]";
return str.str();
}
-DocumentTransitionRequest::SharedElementInfo::SharedElementInfo() = default;
-DocumentTransitionRequest::SharedElementInfo::~SharedElementInfo() = default;
+ViewTransitionRequest::SharedElementInfo::SharedElementInfo() = default;
+ViewTransitionRequest::SharedElementInfo::~SharedElementInfo() = default;
} // namespace cc
diff --git a/cc/document_transition/document_transition_request.h b/cc/view_transition/view_transition_request.h
similarity index 68%
rename from cc/document_transition/document_transition_request.h
rename to cc/view_transition/view_transition_request.h
index 4ead637..9a476df3 100644
--- a/cc/document_transition/document_transition_request.h
+++ b/cc/view_transition/view_transition_request.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CC_DOCUMENT_TRANSITION_DOCUMENT_TRANSITION_REQUEST_H_
-#define CC_DOCUMENT_TRANSITION_DOCUMENT_TRANSITION_REQUEST_H_
+#ifndef CC_VIEW_TRANSITION_VIEW_TRANSITION_REQUEST_H_
+#define CC_VIEW_TRANSITION_VIEW_TRANSITION_REQUEST_H_
#include <map>
#include <memory>
@@ -13,49 +13,48 @@
#include "base/callback.h"
#include "cc/cc_export.h"
-#include "cc/document_transition/document_transition_shared_element_id.h"
+#include "cc/view_transition/view_transition_shared_element_id.h"
#include "components/viz/common/quads/compositor_frame_transition_directive.h"
#include "components/viz/common/quads/compositor_render_pass.h"
namespace cc {
-// This class represents a document transition request. It is constructed in
+// This class represents a view transition request. It is constructed in
// Blink with an intent of translating this request into a viz directive for the
// transition to occur.
-class CC_EXPORT DocumentTransitionRequest {
+class CC_EXPORT ViewTransitionRequest {
public:
struct CC_EXPORT SharedElementInfo {
SharedElementInfo();
~SharedElementInfo();
viz::CompositorRenderPassId render_pass_id;
- viz::SharedElementResourceId resource_id;
+ viz::ViewTransitionElementResourceId resource_id;
};
- using SharedElementMap =
- std::map<DocumentTransitionSharedElementId, SharedElementInfo>;
+ using SharedElementMap = std::map<ViewTransitionElementId, SharedElementInfo>;
// Creates a Type::kCapture type of request.
- static std::unique_ptr<DocumentTransitionRequest> CreateCapture(
+ static std::unique_ptr<ViewTransitionRequest> CreateCapture(
uint32_t document_tag,
uint32_t shared_element_count,
viz::NavigationID navigation_id,
- std::vector<viz::SharedElementResourceId> capture_ids,
+ std::vector<viz::ViewTransitionElementResourceId> capture_ids,
base::OnceClosure commit_callback);
// Creates a Type::kAnimateRenderer type of request.
- static std::unique_ptr<DocumentTransitionRequest> CreateAnimateRenderer(
+ static std::unique_ptr<ViewTransitionRequest> CreateAnimateRenderer(
uint32_t document_tag,
viz::NavigationID navigation_id);
// Creates a Type::kRelease type of request.
- static std::unique_ptr<DocumentTransitionRequest> CreateRelease(
+ static std::unique_ptr<ViewTransitionRequest> CreateRelease(
uint32_t document_tag);
- DocumentTransitionRequest(DocumentTransitionRequest&) = delete;
- ~DocumentTransitionRequest();
+ ViewTransitionRequest(ViewTransitionRequest&) = delete;
+ ~ViewTransitionRequest();
- DocumentTransitionRequest& operator=(DocumentTransitionRequest&) = delete;
+ ViewTransitionRequest& operator=(ViewTransitionRequest&) = delete;
// The callback is run when the request is sufficiently processed for us to be
// able to begin the next step in the animation. In other words, when this
@@ -80,12 +79,12 @@
private:
using Type = viz::CompositorFrameTransitionDirective::Type;
- DocumentTransitionRequest(
+ ViewTransitionRequest(
Type type,
uint32_t document_tag,
uint32_t shared_element_count,
viz::NavigationID navigation_id,
- std::vector<viz::SharedElementResourceId> capture_ids,
+ std::vector<viz::ViewTransitionElementResourceId> capture_ids,
base::OnceClosure commit_callback);
const Type type_;
@@ -94,11 +93,11 @@
const viz::NavigationID navigation_id_;
base::OnceClosure commit_callback_;
const uint32_t sequence_id_;
- const std::vector<viz::SharedElementResourceId> capture_resource_ids_;
+ const std::vector<viz::ViewTransitionElementResourceId> capture_resource_ids_;
static uint32_t s_next_sequence_id_;
};
} // namespace cc
-#endif // CC_DOCUMENT_TRANSITION_DOCUMENT_TRANSITION_REQUEST_H_
+#endif // CC_VIEW_TRANSITION_VIEW_TRANSITION_REQUEST_H_
diff --git a/cc/document_transition/document_transition_request_unittest.cc b/cc/view_transition/view_transition_request_unittest.cc
similarity index 81%
rename from cc/document_transition/document_transition_request_unittest.cc
rename to cc/view_transition/view_transition_request_unittest.cc
index f226b15..1032437 100644
--- a/cc/document_transition/document_transition_request_unittest.cc
+++ b/cc/view_transition/view_transition_request_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "cc/document_transition/document_transition_request.h"
+#include "cc/view_transition/view_transition_request.h"
#include <utility>
@@ -11,11 +11,11 @@
namespace cc {
-TEST(DocumentTransitionRequestTest, PrepareRequest) {
+TEST(ViewTransitionRequestTest, PrepareRequest) {
bool called = false;
auto callback = base::BindLambdaForTesting([&called]() { called = true; });
- auto request = DocumentTransitionRequest::CreateCapture(
+ auto request = ViewTransitionRequest::CreateCapture(
/*document_tag=*/0, /*shared_element_count=*/0, viz::NavigationID::Null(),
{}, std::move(callback));
@@ -34,8 +34,8 @@
EXPECT_EQ(duplicate.type(), directive.type());
}
-TEST(DocumentTransitionRequestTest, StartRequest) {
- auto request = DocumentTransitionRequest::CreateAnimateRenderer(
+TEST(ViewTransitionRequestTest, StartRequest) {
+ auto request = ViewTransitionRequest::CreateAnimateRenderer(
/*document_tag=*/0, viz::NavigationID::Null());
EXPECT_TRUE(request->TakeFinishedCallback().is_null());
diff --git a/cc/view_transition/view_transition_shared_element_id.cc b/cc/view_transition/view_transition_shared_element_id.cc
new file mode 100644
index 0000000..ed88e6e1
--- /dev/null
+++ b/cc/view_transition/view_transition_shared_element_id.cc
@@ -0,0 +1,51 @@
+// Copyright 2021 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/view_transition/view_transition_shared_element_id.h"
+
+#include <sstream>
+#include <string>
+
+#include "base/check_op.h"
+#include "base/containers/flat_set.h"
+
+namespace cc {
+
+ViewTransitionElementId::ViewTransitionElementId() = default;
+
+ViewTransitionElementId::ViewTransitionElementId(uint32_t document_tag)
+ : document_tag_(document_tag) {}
+
+ViewTransitionElementId::ViewTransitionElementId(ViewTransitionElementId&&) =
+ default;
+
+ViewTransitionElementId::ViewTransitionElementId(
+ const ViewTransitionElementId&) = default;
+
+ViewTransitionElementId::~ViewTransitionElementId() = default;
+
+void ViewTransitionElementId::AddIndex(uint32_t index) {
+ DCHECK_NE(document_tag_, 0u);
+ element_indices_.insert(index);
+}
+
+bool ViewTransitionElementId::Matches(uint32_t document_tag,
+ uint32_t index) const {
+ return document_tag_ == document_tag && element_indices_.count(index) != 0;
+}
+
+std::string ViewTransitionElementId::ToString() const {
+ std::ostringstream str;
+ str << "ViewTransitionElementId{ document_tag: " << document_tag_
+ << " element_indices: [";
+ std::string separator = "";
+ for (auto index : element_indices_) {
+ str << separator << index;
+ separator = ", ";
+ }
+ str << "]}";
+ return str.str();
+}
+
+} // namespace cc
diff --git a/cc/view_transition/view_transition_shared_element_id.h b/cc/view_transition/view_transition_shared_element_id.h
new file mode 100644
index 0000000..f3e4118
--- /dev/null
+++ b/cc/view_transition/view_transition_shared_element_id.h
@@ -0,0 +1,64 @@
+// Copyright 2021 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_VIEW_TRANSITION_VIEW_TRANSITION_SHARED_ELEMENT_ID_H_
+#define CC_VIEW_TRANSITION_VIEW_TRANSITION_SHARED_ELEMENT_ID_H_
+
+#include <stdint.h>
+
+#include <string>
+#include <tuple>
+
+#include "base/containers/flat_set.h"
+#include "cc/cc_export.h"
+
+namespace cc {
+
+class CC_EXPORT ViewTransitionElementId {
+ public:
+ ViewTransitionElementId();
+ explicit ViewTransitionElementId(uint32_t document_tag);
+ ViewTransitionElementId(const ViewTransitionElementId&);
+ ViewTransitionElementId(ViewTransitionElementId&&);
+ ~ViewTransitionElementId();
+
+ // Add a shared index to this id. It must have a valid document tag.
+ void AddIndex(uint32_t index);
+
+ // Returns true if the document tag matches this id and the index is in the
+ // list of indices for this id.
+ bool Matches(uint32_t document_tag, uint32_t index) const;
+
+ ViewTransitionElementId& operator=(ViewTransitionElementId&&) = default;
+
+ ViewTransitionElementId& operator=(const ViewTransitionElementId&) = default;
+
+ bool operator==(const ViewTransitionElementId& other) const {
+ return element_indices_ == other.element_indices_ &&
+ document_tag_ == other.document_tag_;
+ }
+
+ bool operator!=(const ViewTransitionElementId& other) const {
+ return !(*this == other);
+ }
+
+ bool operator<(const ViewTransitionElementId& other) const {
+ return std::tie(document_tag_, element_indices_) <
+ std::tie(other.document_tag_, other.element_indices_);
+ }
+
+ bool valid() const {
+ return document_tag_ != 0u && !element_indices_.empty();
+ }
+
+ std::string ToString() const;
+
+ private:
+ uint32_t document_tag_ = 0u;
+ base::flat_set<uint32_t> element_indices_;
+};
+
+} // namespace cc
+
+#endif // CC_VIEW_TRANSITION_VIEW_TRANSITION_SHARED_ELEMENT_ID_H_