!307 增加dumpnode维测接口

Merge pull request !307 from lee/master
This commit is contained in:
openharmony_ci 2022-01-26 08:42:38 +00:00 committed by Gitee
commit b5d3c39ce7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 54 additions and 28 deletions

View File

@ -40,6 +40,17 @@ enum class RSUINodeType {
ROOT_NODE = 0x12210,
TEXTURE_NODE = 0x22210,
};
static const std::map<RSUINodeType, std::string> RSUINodeTypeStrs = {
{RSUINodeType::BASE_NODE, "BaseNode"},
{RSUINodeType::DISPLAY_NODE, "DisplayNode"},
{RSUINodeType::RS_NODE, "RsNode"},
{RSUINodeType::SURFACE_NODE, "SurfaceNode"},
{RSUINodeType::CANVAS_NODE, "CanvasNode"},
{RSUINodeType::ROOT_NODE, "RootNode"},
{RSUINodeType::TEXTURE_NODE, "TextureNode"},
};
// types for RenderNode
enum class RSRenderNodeType {
BASE_NODE = 0x00011,

View File

@ -176,6 +176,7 @@ public:
void SetVisible(bool visible);
bool GetVisible() const;
bool SetId(NodeId id);
std::string Dump() const;
const std::shared_ptr<RSObjGeometry>& GetBoundsGeometry() const;
const std::shared_ptr<RSObjGeometry>& GetFrameGeometry() const;

View File

@ -16,6 +16,7 @@
#include "property/rs_properties.h"
#include <algorithm>
#include <securec.h>
#include "command/rs_node_command.h"
#include "platform/common/rs_log.h"
@ -910,5 +911,15 @@ void RSProperties::ResetBounds()
boundsGeo_->SetRect(0.f, 0.f, 0.f, 0.f);
}
}
std::string RSProperties::Dump() const
{
char buffer[UINT8_MAX];
if (sprintf_s(buffer, UINT8_MAX, "Bounds[%.2f %.2f %.2f %.2f] bgcolor[#%08X]",
GetBoundsPositionX(), GetBoundsPositionY(), GetBoundsWidth(), GetBoundsHeight(), GetBackgroundColor().AsArgbInt()) != -1) {
return std::string(buffer);
}
return "";
}
} // namespace Rosen
} // namespace OHOS

View File

@ -61,6 +61,7 @@ RSRenderThread::RSRenderThread()
if (hasRunningAnimation_) {
RSRenderThread::Instance().RequestNextVSync();
}
ROSEN_TRACE_END(BYTRACE_TAG_GRAPHIC_AGP);
return;
}
prevTimestamp_ = timestamp_;
@ -69,6 +70,7 @@ RSRenderThread::RSRenderThread()
}
}
ROSEN_LOGD("RSRenderThread DrawFrame(%llu) in %s", prevTimestamp_, renderContext_ ? "GPU" : "CPU");
Animate(prevTimestamp_);
Render();
RS_ASYNC_TRACE_BEGIN("waiting GPU running", 1111); // 1111 means async trace code for gpu

View File

@ -111,7 +111,7 @@ private:
RSContext context_;
RenderContext* renderContext_;
RenderContext* renderContext_ = nullptr;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -105,8 +105,8 @@ void RSRenderThreadVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
std::shared_ptr<RSSurface> rsSurface = nullptr;
NodeId surfaceId = node.GetRSSurfaceNodeId();
auto ptr = RSNodeMap::Instance().GetNode<RSSurfaceNode>(surfaceId);
if (ptr == nullptr) {
ROSEN_LOGE("No RSSurfaceNode found");
if (ptr == nullptr || node.GetSurfaceWidth() <= 0 || node.GetSurfaceHeight() <= 0) {
ROSEN_LOGE("No valid RSSurfaceNode");
return;
}
rsSurface = RSSurfaceExtractor::ExtractRSSurface(ptr);

View File

@ -16,7 +16,7 @@
#include "ui/rs_base_node.h"
#include <algorithm>
#include <string>
#include <sstream>
#include "command/rs_base_node_command.h"
#include "pipeline/rs_node_map.h"
@ -151,31 +151,19 @@ RSBaseNode::SharedPtr RSBaseNode::GetParent()
return RSNodeMap::Instance().GetNode(parent_);
}
void RSBaseNode::DumpTree(std::string& out)
std::string RSBaseNode::DumpNode(int depth) const
{
out += "id: " + std::to_string(GetId()) + "\n";
auto p = RSNodeMap::Instance().GetNode(parent_);
if (p != nullptr) {
out += "parent: " + std::to_string(p->GetId()) + "\n";
} else {
out += "parent: null\n";
std::stringstream ss;
auto it = RSUINodeTypeStrs.find(GetType());
if (it == RSUINodeTypeStrs.end()) {
return "";
}
for (unsigned i = 0; i < children_.size(); ++i) {
auto c = RSNodeMap::Instance().GetNode(children_[i]);
if (c != nullptr) {
out += "child[" + std::to_string(i) + "]: " + std::to_string(c->GetId()) + "\n";
} else {
out += "child[" + std::to_string(i) + "]: null\n";
}
}
ss << it->second << "[" << std::to_string(id_) << "] child[";
for (auto child : children_) {
auto c = RSNodeMap::Instance().GetNode(child);
if (c != nullptr) {
c->DumpTree(out);
}
ss << std::to_string(child) << " ";
}
ss << "]";
return ss.str();
}
template<typename T>

View File

@ -62,7 +62,7 @@ public:
{
return (IsInstanceOf<T>()) ? std::static_pointer_cast<T>(shared_from_this()) : nullptr;
}
virtual std::string DumpNode(int depth) const;
protected:
RSBaseNode(bool isRenderServiceNode);
RSBaseNode(const RSBaseNode&) = delete;
@ -79,8 +79,6 @@ protected:
id_ = id;
}
void DumpTree(std::string& out);
bool IsRenderServiceNode() const
{
return isRenderServiceNode_;

View File

@ -16,6 +16,7 @@
#include "ui/rs_node.h"
#include <algorithm>
#include <sstream>
#include <string>
#include "animation/rs_animation.h"
@ -683,5 +684,16 @@ void RSNode::SetPaintOrder(bool drawContentLast)
drawContentLast_ = drawContentLast;
}
std::string RSNode::DumpNode(int depth) const
{
std::stringstream ss;
ss << RSBaseNode::DumpNode(depth);
if (!animations_.empty()) {
ss << " animation:" << std::to_string(animations_.size());
}
ss << " " << stagingProperties_.Dump();
return ss.str();
}
} // namespace Rosen
} // namespace OHOS

View File

@ -45,6 +45,7 @@ public:
static inline constexpr RSUINodeType Type = RSUINodeType::RS_NODE;
virtual ~RSNode();
std::string DumpNode(int depth) const override;
static std::vector<std::shared_ptr<RSAnimation>> Animate(const RSAnimationTimingProtocol& timingProtocol,
const RSAnimationTimingCurve& timingCurve, const PropertyCallback& callback,

View File

@ -56,11 +56,13 @@ void RSUIDirector::Init()
void RSUIDirector::GoForeground()
{
ROSEN_LOGI("RSUIDirector::GoForeground");
RSRenderThread::Instance().SetBackgroundStatus(false);
}
void RSUIDirector::GoBackground()
{
ROSEN_LOGI("RSUIDirector::GoBackground");
RSRenderThread::Instance().SetBackgroundStatus(true);
}