mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-30 10:41:29 +00:00
!16009 拆分DUMP_CLIENT_NODE_TREE
Merge pull request !16009 from hashicop/splitcommand
This commit is contained in:
commit
b5a1c3b6b7
@ -386,7 +386,7 @@ RSMainThread::RSMainThread() : mainThreadId_(std::this_thread::get_id()),
|
||||
|
||||
RSMainThread::~RSMainThread() noexcept
|
||||
{
|
||||
RSNodeCommandHelper::SetDumpNodeTreeProcessor(nullptr);
|
||||
RSNodeCommandHelper::SetCommitDumpNodeTreeProcessor(nullptr);
|
||||
RemoveRSEventDetector();
|
||||
RSInnovation::CloseInnovationSo();
|
||||
if (rsAppStateListener_) {
|
||||
@ -493,8 +493,8 @@ void RSMainThread::Init()
|
||||
Drawing::DrawOpItem::SetTypefaceQueryCallBack(customTypefaceQueryfunc);
|
||||
{
|
||||
using namespace std::placeholders;
|
||||
RSNodeCommandHelper::SetDumpNodeTreeProcessor(
|
||||
std::bind(&RSMainThread::OnDumpClientNodeTree, this, _1, _2, _3, _4));
|
||||
RSNodeCommandHelper::SetCommitDumpNodeTreeProcessor(
|
||||
std::bind(&RSMainThread::OnCommitDumpClientNodeTree, this, _1, _2, _3, _4));
|
||||
}
|
||||
Drawing::DrawSurfaceBufferOpItem::RegisterSurfaceBufferCallback(
|
||||
RSSurfaceBufferCallbackManager::Instance().GetSurfaceBufferOpItemCallback());
|
||||
@ -3299,7 +3299,7 @@ void RSMainThread::SendClientDumpNodeTreeCommands(uint32_t taskId)
|
||||
}
|
||||
auto transactionData = std::make_shared<RSTransactionData>();
|
||||
for (auto id : nodeIds) {
|
||||
auto command = std::make_unique<RSDumpClientNodeTree>(id, pid, taskId, "");
|
||||
auto command = std::make_unique<RSDumpClientNodeTree>(id, pid, taskId);
|
||||
transactionData->AddCommand(std::move(command), id, FollowType::NONE);
|
||||
task.count++;
|
||||
RS_TRACE_NAME_FMT("DumpClientNodeTree add task[%u] pid[%u] node[%" PRIu64 "]",
|
||||
@ -3343,7 +3343,7 @@ void RSMainThread::CollectClientNodeTreeResult(uint32_t taskId, std::string& dum
|
||||
taskId, completed);
|
||||
}
|
||||
|
||||
void RSMainThread::OnDumpClientNodeTree(NodeId nodeId, pid_t pid, uint32_t taskId, const std::string& result)
|
||||
void RSMainThread::OnCommitDumpClientNodeTree(NodeId nodeId, pid_t pid, uint32_t taskId, const std::string& result)
|
||||
{
|
||||
RS_TRACE_NAME_FMT("DumpClientNodeTree collected task[%u] dataSize[%zu] pid[%d]",
|
||||
taskId, result.size(), pid);
|
||||
|
@ -509,7 +509,7 @@ private:
|
||||
bool CheckUIExtensionCallbackDataChanged() const;
|
||||
void ConfigureRenderService();
|
||||
|
||||
void OnDumpClientNodeTree(NodeId nodeId, pid_t pid, uint32_t taskId, const std::string& result);
|
||||
void OnCommitDumpClientNodeTree(NodeId nodeId, pid_t pid, uint32_t taskId, const std::string& result);
|
||||
|
||||
std::shared_ptr<AppExecFwk::EventRunner> runner_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_ = nullptr;
|
||||
|
@ -75,6 +75,7 @@ enum RSNodeCommandType : uint16_t {
|
||||
REMOVE_ALL_MODIFIERS,
|
||||
|
||||
DUMP_CLIENT_NODE_TREE,
|
||||
COMMIT_DUMP_CLIENT_NODE_TREE,
|
||||
};
|
||||
|
||||
class RSB_EXPORT RSNodeCommandHelper {
|
||||
@ -146,10 +147,14 @@ public:
|
||||
static void RegisterGeometryTransitionPair(RSContext& context, NodeId inNodeId, NodeId outNodeId);
|
||||
static void UnregisterGeometryTransitionPair(RSContext& context, NodeId inNodeId, NodeId outNodeId);
|
||||
|
||||
using DumpNodeTreeProcessor = std::function<void(NodeId, pid_t, uint32_t, const std::string&)>;
|
||||
static void DumpClientNodeTree(RSContext& context, NodeId nodeId, pid_t pid, uint32_t taskId,
|
||||
const std::string& result);
|
||||
using DumpNodeTreeProcessor = std::function<void(NodeId, pid_t, uint32_t)>;
|
||||
static void DumpClientNodeTree(RSContext& context, NodeId nodeId, pid_t pid, uint32_t taskId);
|
||||
static RSB_EXPORT void SetDumpNodeTreeProcessor(DumpNodeTreeProcessor processor);
|
||||
|
||||
using CommitDumpNodeTreeProcessor = std::function<void(NodeId, pid_t, uint32_t, const std::string&)>;
|
||||
static void CommitDumpClientNodeTree(RSContext& context, NodeId nodeId, pid_t pid, uint32_t taskId,
|
||||
const std::string& result);
|
||||
static RSB_EXPORT void SetCommitDumpNodeTreeProcessor(CommitDumpNodeTreeProcessor processor);
|
||||
};
|
||||
|
||||
ADD_COMMAND(RSAddModifier,
|
||||
@ -277,7 +282,10 @@ ADD_COMMAND(RSRemoveAllModifiers,
|
||||
ARG(RS_NODE, REMOVE_ALL_MODIFIERS, RSNodeCommandHelper::RemoveAllModifiers, NodeId))
|
||||
|
||||
ADD_COMMAND(RSDumpClientNodeTree,
|
||||
ARG(RS_NODE, DUMP_CLIENT_NODE_TREE, RSNodeCommandHelper::DumpClientNodeTree, NodeId, pid_t, uint32_t, std::string))
|
||||
ARG(RS_NODE, DUMP_CLIENT_NODE_TREE, RSNodeCommandHelper::DumpClientNodeTree, NodeId, pid_t, uint32_t))
|
||||
ADD_COMMAND(RSCommitDumpClientNodeTree,
|
||||
ARG(RS_NODE, COMMIT_DUMP_CLIENT_NODE_TREE,
|
||||
RSNodeCommandHelper::CommitDumpClientNodeTree, NodeId, pid_t, uint32_t, std::string))
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
|
@ -19,6 +19,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
RSNodeCommandHelper::DumpNodeTreeProcessor gDumpNodeTreeProcessor = nullptr;
|
||||
RSNodeCommandHelper::CommitDumpNodeTreeProcessor gCommitDumpNodeTreeProcessor = nullptr;
|
||||
}
|
||||
|
||||
void RSNodeCommandHelper::AddModifier(RSContext& context, NodeId nodeId,
|
||||
@ -147,11 +148,10 @@ void RSNodeCommandHelper::UnregisterGeometryTransitionPair(RSContext& context, N
|
||||
}
|
||||
}
|
||||
|
||||
void RSNodeCommandHelper::DumpClientNodeTree(RSContext& context, NodeId nodeId, pid_t pid, uint32_t taskId,
|
||||
const std::string& result)
|
||||
void RSNodeCommandHelper::DumpClientNodeTree(RSContext& context, NodeId nodeId, pid_t pid, uint32_t taskId)
|
||||
{
|
||||
if (gDumpNodeTreeProcessor) {
|
||||
gDumpNodeTreeProcessor(nodeId, pid, taskId, result);
|
||||
gDumpNodeTreeProcessor(nodeId, pid, taskId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,5 +159,18 @@ void RSNodeCommandHelper::SetDumpNodeTreeProcessor(DumpNodeTreeProcessor process
|
||||
{
|
||||
gDumpNodeTreeProcessor = processor;
|
||||
}
|
||||
|
||||
void RSNodeCommandHelper::CommitDumpClientNodeTree(RSContext& context, NodeId nodeId, pid_t pid, uint32_t taskId,
|
||||
const std::string& result)
|
||||
{
|
||||
if (gCommitDumpNodeTreeProcessor) {
|
||||
gCommitDumpNodeTreeProcessor(nodeId, pid, taskId, result);
|
||||
}
|
||||
}
|
||||
|
||||
void RSNodeCommandHelper::SetCommitDumpNodeTreeProcessor(CommitDumpNodeTreeProcessor processor)
|
||||
{
|
||||
gCommitDumpNodeTreeProcessor = processor;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -445,7 +445,7 @@ void RSUIDirector::AnimationCallbackProcessor(NodeId nodeId, AnimationId animId,
|
||||
}
|
||||
}
|
||||
|
||||
void RSUIDirector::DumpNodeTreeProcessor(NodeId nodeId, pid_t pid, uint32_t taskId, const std::string& result)
|
||||
void RSUIDirector::DumpNodeTreeProcessor(NodeId nodeId, pid_t pid, uint32_t taskId)
|
||||
{
|
||||
RS_TRACE_NAME_FMT("DumpClientNodeTree dump task[%u] node[%" PRIu64 "]", taskId, nodeId);
|
||||
ROSEN_LOGI("DumpNodeTreeProcessor task[%{public}u] node[%" PRIu64 "]", taskId, nodeId);
|
||||
@ -458,7 +458,8 @@ void RSUIDirector::DumpNodeTreeProcessor(NodeId nodeId, pid_t pid, uint32_t task
|
||||
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||
if (transactionProxy != nullptr) {
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSDumpClientNodeTree>(nodeId, getpid(), taskId, out);
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSCommitDumpClientNodeTree>(
|
||||
nodeId, getpid(), taskId, out);
|
||||
transactionProxy->AddCommand(command, true);
|
||||
RSTransaction::FlushImplicitTransaction();
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
static void RecvMessages(std::shared_ptr<RSTransactionData> cmds);
|
||||
static void ProcessMessages(std::shared_ptr<RSTransactionData> cmds); // receive message
|
||||
static void AnimationCallbackProcessor(NodeId nodeId, AnimationId animId, AnimationCallbackEvent event);
|
||||
static void DumpNodeTreeProcessor(NodeId nodeId, pid_t pid, uint32_t taskId, const std::string& result);
|
||||
static void DumpNodeTreeProcessor(NodeId nodeId, pid_t pid, uint32_t taskId);
|
||||
static void PostTask(const std::function<void()>& task, int32_t instanceId = INSTANCE_ID_UNDEFINED);
|
||||
static void PostDelayTask(
|
||||
const std::function<void()>& task, uint32_t delay = 0, int32_t instanceId = INSTANCE_ID_UNDEFINED);
|
||||
|
@ -3998,26 +3998,26 @@ HWTEST_F(RSMainThreadTest, OnDrawingCacheDfxSwitchCallback, TestSize.Level2)
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OnDumpClientNodeTree
|
||||
* @tc.desc: test OnDumpClientNodeTree
|
||||
* @tc.name: OnCommitDumpClientNodeTree
|
||||
* @tc.desc: test OnCommitDumpClientNodeTree
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueIAKME2
|
||||
*/
|
||||
HWTEST_F(RSMainThreadTest, OnDumpClientNodeTree, TestSize.Level2)
|
||||
HWTEST_F(RSMainThreadTest, OnCommitDumpClientNodeTree, TestSize.Level2)
|
||||
{
|
||||
auto mainThread = RSMainThread::Instance();
|
||||
ASSERT_NE(mainThread, nullptr);
|
||||
mainThread->nodeTreeDumpTasks_.clear();
|
||||
|
||||
uint32_t taskId = 0;
|
||||
mainThread->OnDumpClientNodeTree(0, 0, taskId, "testData");
|
||||
mainThread->OnCommitDumpClientNodeTree(0, 0, taskId, "testData");
|
||||
ASSERT_TRUE(mainThread->nodeTreeDumpTasks_.empty());
|
||||
|
||||
auto& task = mainThread->nodeTreeDumpTasks_[taskId];
|
||||
task.count++;
|
||||
|
||||
mainThread->OnDumpClientNodeTree(0, 0, taskId, "testData");
|
||||
mainThread->OnDumpClientNodeTree(0, 0, taskId, "testData");
|
||||
mainThread->OnCommitDumpClientNodeTree(0, 0, taskId, "testData");
|
||||
mainThread->OnCommitDumpClientNodeTree(0, 0, taskId, "testData");
|
||||
ASSERT_TRUE(!mainThread->nodeTreeDumpTasks_.empty());
|
||||
ASSERT_TRUE(!mainThread->nodeTreeDumpTasks_[taskId].data.empty());
|
||||
}
|
||||
|
@ -316,14 +316,14 @@ HWTEST_F(RSNodeCommandTest, DumpClientNodeTree001, TestSize.Level1)
|
||||
{
|
||||
RSContext context;
|
||||
bool flag = false;
|
||||
auto func = [&flag] (NodeId, pid_t, uint32_t, const std::string&) { flag = true; };
|
||||
auto func = [&flag] (NodeId, pid_t, uint32_t) { flag = true; };
|
||||
RSNodeCommandHelper::SetDumpNodeTreeProcessor(func);
|
||||
RSNodeCommandHelper::DumpClientNodeTree(context, 0, 0, 0, "");
|
||||
RSNodeCommandHelper::DumpClientNodeTree(context, 0, 0, 0);
|
||||
ASSERT_TRUE(flag);
|
||||
|
||||
flag = false;
|
||||
RSNodeCommandHelper::SetDumpNodeTreeProcessor(nullptr);
|
||||
RSNodeCommandHelper::DumpClientNodeTree(context, 0, 0, 0, "");
|
||||
RSNodeCommandHelper::DumpClientNodeTree(context, 0, 0, 0);
|
||||
ASSERT_FALSE(flag);
|
||||
|
||||
SUCCEED();
|
||||
|
@ -625,9 +625,9 @@ HWTEST_F(RSUIDirectorTest, DumpNodeTreeProcessor001, TestSize.Level1)
|
||||
std::shared_ptr<RSUIDirector> director = RSUIDirector::Create();
|
||||
ASSERT_TRUE(director != nullptr);
|
||||
RSNode::SharedPtr rsNode = RSCanvasNode::Create();
|
||||
director->DumpNodeTreeProcessor(rsNode->GetId(), 0, 0, "");
|
||||
director->DumpNodeTreeProcessor(rsNode->GetId(), 0, 0);
|
||||
const NodeId invalidId = 1;
|
||||
director->DumpNodeTreeProcessor(invalidId, 0, 0, "");
|
||||
director->DumpNodeTreeProcessor(invalidId, 0, 0);
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user