Commit d422b5d9 authored by Illia Martyniuk's avatar Illia Martyniuk Committed by Commit Bot

Viz: Handling the change in hierarchy of surface references

This is called every time the surface reference is added or removed. It
will be used in Viz DevTools to update the tree of surfaces.

Bug: 816802
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: Id07fc469a8fd395fac114dafb0d7c15e9809192d
Reviewed-on: https://chromium-review.googlesource.com/998411Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Commit-Queue: Illia Martyniuk <illiam@google.com>
Cr-Commit-Position: refs/heads/master@{#549253}
parent defa3554
......@@ -199,6 +199,13 @@ const SurfaceId& SurfaceManager::GetRootSurfaceId() const {
return root_surface_id_;
}
std::vector<SurfaceId> SurfaceManager::GetCreatedSurfaceIds() const {
std::vector<SurfaceId> surface_ids;
for (auto& map_entry : surface_map_)
surface_ids.push_back(map_entry.first);
return surface_ids;
}
void SurfaceManager::AddSurfaceReferences(
const std::vector<SurfaceReference>& references) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......@@ -330,6 +337,9 @@ void SurfaceManager::AddSurfaceReferenceImpl(const SurfaceId& parent_id,
references_[parent_id].children.insert(child_id);
references_[child_id].parents.insert(parent_id);
for (auto& observer : observer_list_)
observer.OnAddedSurfaceReference(parent_id, child_id);
if (HasTemporaryReference(child_id))
RemoveTemporaryReference(child_id, RemovedReason::EMBEDDED);
}
......@@ -341,6 +351,9 @@ void SurfaceManager::RemoveSurfaceReferenceImpl(const SurfaceId& parent_id,
if (iter_parent == references_.end() || iter_child == references_.end())
return;
for (auto& observer : observer_list_)
observer.OnRemovedSurfaceReference(parent_id, child_id);
iter_parent->second.children.erase(child_id);
iter_child->second.parents.erase(parent_id);
}
......
......@@ -164,6 +164,10 @@ class VIZ_SERVICE_EXPORT SurfaceManager {
// SurfaceId and will never correspond to a surface.
const SurfaceId& GetRootSurfaceId() const;
// Returns SurfaceIds of currently alive Surfaces. This may include ids of
// Surfaces that are about to be destroyed.
std::vector<SurfaceId> GetCreatedSurfaceIds() const;
// Adds all surface references in |references|. This will remove any temporary
// references for child surface in a surface reference.
void AddSurfaceReferences(const std::vector<SurfaceReference>& references);
......
......@@ -54,6 +54,16 @@ class SurfaceObserver {
// Called whenever |surface| will be drawn in the next display frame.
virtual void OnSurfaceWillBeDrawn(Surface* surface) {}
// Called whenever the surface reference from the surface that has |parent_id|
// to the surface that has |child_id| is added.
virtual void OnAddedSurfaceReference(const SurfaceId& parent_id,
const SurfaceId& child_id) {}
// Called whenever the surface reference from the surface that has |parent_id|
// to the surface that has |child_id| is removed.
virtual void OnRemovedSurfaceReference(const SurfaceId& parent_id,
const SurfaceId& child_id) {}
};
} // namespace viz
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment