Commit 38f1e58b authored by yiyix's avatar yiyix Committed by Commit Bot

VizDevTools: Observing static Surface tree

Builds the Surface tree considering Surfaces that correspond to
RootFrameSinks and detached Surfaces as root Surfaces. All of these are
attached to RootElement.

Bug:816802

TBR=sadrul@chromium.org

Change-Id: I74d11ddb0fed9dc31712dc6e98cf20e936856400
Reviewed-on: https://chromium-review.googlesource.com/1185964
Commit-Queue: Yi Xu <yiyix@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589302}
parent 9c4e31f4
......@@ -34,6 +34,8 @@ std::string UIElement::GetTypeName() const {
return "View";
case UIElementType::FRAMESINK:
return "FrameSink";
case UIElementType::SURFACE:
return "Surface";
}
NOTREACHED();
return std::string();
......
......@@ -23,7 +23,7 @@ class Array;
}
// UIElement type.
enum UIElementType { WINDOW, WIDGET, VIEW, ROOT, FRAMESINK };
enum UIElementType { WINDOW, WIDGET, VIEW, ROOT, FRAMESINK, SURFACE };
class UI_DEVTOOLS_EXPORT UIElement {
public:
......
......@@ -12,6 +12,8 @@ source_set("viz_views") {
"frame_sink_element.h",
"overlay_agent_viz.cc",
"overlay_agent_viz.h",
"surface_element.cc",
"surface_element.h",
]
deps = [
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/ui_devtools/viz_views/surface_element.h"
#include "components/ui_devtools/Protocol.h"
#include "components/ui_devtools/ui_element_delegate.h"
#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
#include "components/viz/service/surfaces/surface.h"
#include "components/viz/service/surfaces/surface_manager.h"
namespace ui_devtools {
SurfaceElement::SurfaceElement(const viz::SurfaceId& surface_id,
viz::FrameSinkManagerImpl* frame_sink_manager,
UIElementDelegate* ui_element_delegate,
UIElement* parent,
bool is_detached)
: UIElement(UIElementType::SURFACE, ui_element_delegate, parent),
surface_id_(surface_id),
frame_sink_manager_(frame_sink_manager) {
viz::Surface* surface =
frame_sink_manager_->surface_manager()->GetSurfaceForId(surface_id_);
DCHECK(surface);
surface_bounds_ = gfx::Rect(surface->size_in_pixels());
}
SurfaceElement::~SurfaceElement() = default;
void SurfaceElement::GetBounds(gfx::Rect* bounds) const {
// We cannot really know real bounds on the surface unless we do
// aggregation. Here we just return size of the surface.
*bounds = surface_bounds_;
}
void SurfaceElement::SetBounds(const gfx::Rect& bounds) {
NOTREACHED();
}
void SurfaceElement::GetVisible(bool* visible) const {
// Currently not real data.
*visible = true;
}
void SurfaceElement::SetVisible(bool visible) {}
std::unique_ptr<protocol::Array<std::string>> SurfaceElement::GetAttributes()
const {
auto attributes = protocol::Array<std::string>::create();
attributes->addItem("SurfaceId");
attributes->addItem(surface_id_.ToString());
attributes->addItem("FrameSink Debug Label");
attributes->addItem(
frame_sink_manager_->GetFrameSinkDebugLabel(surface_id_.frame_sink_id())
.data());
return attributes;
}
std::pair<gfx::NativeWindow, gfx::Rect> SurfaceElement::GetNodeWindowAndBounds()
const {
return {};
}
// static
const viz::SurfaceId& SurfaceElement::From(const UIElement* element) {
DCHECK_EQ(UIElementType::SURFACE, element->type());
return static_cast<const SurfaceElement*>(element)->surface_id_;
}
} // namespace ui_devtools
\ No newline at end of file
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_UI_DEVTOOLS_VIZ_VIEWS_SURFACE_ELEMENT_H_
#define COMPONENTS_UI_DEVTOOLS_VIZ_VIEWS_SURFACE_ELEMENT_H_
#include "base/macros.h"
#include "components/ui_devtools/ui_element.h"
#include "components/viz/common/surfaces/surface_id.h"
namespace viz {
class FrameSinkManagerImpl;
}
namespace ui_devtools {
// A type of UIElement. Each SurfaceElement is corresponding to a SurfaceId.
class SurfaceElement : public UIElement {
public:
SurfaceElement(const viz::SurfaceId& surface_id,
viz::FrameSinkManagerImpl* frame_sink_manager,
UIElementDelegate* ui_element_delegate,
UIElement* parent,
bool is_detached);
~SurfaceElement() override;
// UIElement:
std::vector<std::pair<std::string, std::string>> GetCustomProperties()
const override;
void GetBounds(gfx::Rect* bounds) const override;
void SetBounds(const gfx::Rect& bounds) override;
void GetVisible(bool* visible) const override;
void SetVisible(bool visible) override;
std::unique_ptr<protocol::Array<std::string>> GetAttributes() const override;
std::pair<gfx::NativeWindow, gfx::Rect> GetNodeWindowAndBounds()
const override;
static const viz::SurfaceId& From(const UIElement* element);
private:
const viz::SurfaceId surface_id_;
viz::FrameSinkManagerImpl* const frame_sink_manager_;
gfx::Rect surface_bounds_;
DISALLOW_COPY_AND_ASSIGN(SurfaceElement);
};
} // namespace ui_devtools
#endif // COMPONENTS_UI_DEVTOOLS_VIZ_VIEWS_SURFACE_ELEMENT_H_
\ No newline at end of file
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