mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-12-20 13:49:07 +00:00
fix rootnode command register, capture weakptr in lambda
Change-Id: Ib07ae61ebbadc49580d1c729b73bc1a598548b3d Signed-off-by: Zhang Peng <zhangpeng280@huawei.com>
This commit is contained in:
parent
8757403ab5
commit
6130776eaf
@ -25,6 +25,7 @@
|
||||
#include "command/rs_canvas_node_command.h"
|
||||
#include "command/rs_display_node_command.h"
|
||||
#include "command/rs_node_command.h"
|
||||
#include "command/rs_root_node_command.h"
|
||||
#include "command/rs_surface_node_command.h"
|
||||
// animation
|
||||
#include "command/rs_animation_command.h"
|
||||
@ -53,7 +54,8 @@ void RSCommandFactory::Register(uint16_t type, uint16_t subtype, UnmarshallingFu
|
||||
{
|
||||
auto result = unmarshallingFuncLUT_.try_emplace(MakeKey(type, subtype), func);
|
||||
if (!result.second) {
|
||||
ROSEN_LOGE("RSCommandFactory::Register, Duplicate command & sub_command detected! type: %d subtype: %d", type, subtype);
|
||||
ROSEN_LOGE("RSCommandFactory::Register, Duplicate command & sub_command detected! type: %d subtype: %d", type,
|
||||
subtype);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,12 +199,16 @@ void RSSurfaceRenderNode::RegisterBufferAvailableListener(sptr<RSIBufferAvailabl
|
||||
void RSSurfaceRenderNode::ConnectToNodeInRenderService()
|
||||
{
|
||||
ROSEN_LOGI("RSSurfaceRenderNode::ConnectToNodeInRenderService nodeId = %llu", this->GetId());
|
||||
auto renderServiceClinet =
|
||||
auto renderServiceClient =
|
||||
std::static_pointer_cast<RSRenderServiceClient>(RSIRenderClient::CreateRenderServiceClient());
|
||||
if (renderServiceClinet != nullptr) {
|
||||
renderServiceClinet->RegisterBufferAvailableListener(GetId(),
|
||||
[this](bool isBufferAvailable) {
|
||||
this->NotifyBufferAvailable(isBufferAvailable);
|
||||
if (renderServiceClient != nullptr) {
|
||||
renderServiceClient->RegisterBufferAvailableListener(
|
||||
GetId(), [weakThis = weak_from_this()](bool isBufferAvailable) {
|
||||
auto node = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(weakThis.lock());
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
node->NotifyBufferAvailable(isBufferAvailable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -105,13 +105,6 @@ RSRenderThread::RSRenderThread()
|
||||
ROSEN_LOGD("RSRenderThread DrawFrame took %fs.", drawTime);
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
RSRenderServiceConnectHub::SetOnConnectCallback([this](sptr<RSIRenderServiceConnection>& conn) {
|
||||
sptr<IApplicationRenderThread> renderThreadSptr = sptr<RSRenderThread>(this);
|
||||
conn->RegisterApplicationRenderThread(getpid(), renderThreadSptr);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
RSRenderThread::~RSRenderThread()
|
||||
@ -132,6 +125,17 @@ void RSRenderThread::Start()
|
||||
if (thread_ == nullptr) {
|
||||
thread_ = std::make_unique<std::thread>(&RSRenderThread::RenderLoop, this);
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
RSRenderServiceConnectHub::SetOnConnectCallback(
|
||||
[weakThis = wptr<RSRenderThread>(this)](sptr<RSIRenderServiceConnection>& conn) {
|
||||
sptr<IApplicationRenderThread> renderThreadSptr = weakThis.promote();
|
||||
if (renderThreadSptr == nullptr) {
|
||||
return;
|
||||
}
|
||||
conn->RegisterApplicationRenderThread(getpid(), renderThreadSptr);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void RSRenderThread::Stop()
|
||||
|
Loading…
Reference in New Issue
Block a user