mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-27 01:00:50 +00:00
add id from Xcomponent
Signed-off-by: leafly2021 <figo.yefei@huawei.com>
This commit is contained in:
parent
d4041e8121
commit
34478c00d9
@ -58,6 +58,20 @@ typedef void (*OH_NativeVSync_FrameCallback)(long long timestamp, void *data);
|
||||
*/
|
||||
OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length);
|
||||
|
||||
/**
|
||||
* @brief Creates a associated with Xcomponentid <b>NativeVsync</b> instance.\n
|
||||
* A new associated with Xcomponentid<b>NativeVsync</b> instance is created each time this function is called.
|
||||
*
|
||||
* @syscap SystemCapability.Graphic.Graphic2D.NativeVsync
|
||||
* @param windowID Indicates the Xcomponentid of the associated window.
|
||||
* @param name Indicates the vsync connection name.
|
||||
* @param length Indicates the name's length.
|
||||
* @return Returns the pointer to the <b>NativeVsync</b> instance created.
|
||||
* @since 14
|
||||
* @version 1.0
|
||||
*/
|
||||
OH_NativeVSync* OH_NativeVSync_Create_ForAssociatedWindow(uint64_t windowID, const char* name, unsigned int length);
|
||||
|
||||
/**
|
||||
* @brief Delete the NativeVsync instance.
|
||||
*
|
||||
|
@ -35,15 +35,18 @@ static OH_NativeVSync* OH_NativeVSync_NativeVSyncToOHNativeVSync(NativeVSync* na
|
||||
return reinterpret_cast<OH_NativeVSync*>(nativeVSync);
|
||||
}
|
||||
|
||||
OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length)
|
||||
std::shared_ptr<OHOS::Rosen::VSyncReceiver> CreateAndInitVSyncReceiver(
|
||||
const std::string& vsyncName,
|
||||
uint64_t windowID = 0,
|
||||
bool isAssociatedWindow = false)
|
||||
{
|
||||
if (name == nullptr) {
|
||||
VLOGE("name is nullptr, please check");
|
||||
return nullptr;
|
||||
}
|
||||
std::string vsyncName(name, length);
|
||||
auto& rsClient = OHOS::Rosen::RSInterfaces::GetInstance();
|
||||
std::shared_ptr<OHOS::Rosen::VSyncReceiver> receiver = rsClient.CreateVSyncReceiver(vsyncName);
|
||||
std::shared_ptr<OHOS::Rosen::VSyncReceiver> receiver;
|
||||
if (isAssociatedWindow) {
|
||||
receiver = rsClient.CreateVSyncReceiver(vsyncName, 0, nullptr, windowID, true);
|
||||
} else {
|
||||
receiver = rsClient.CreateVSyncReceiver(vsyncName);
|
||||
}
|
||||
if (receiver == nullptr) {
|
||||
VLOGE("Create VSyncReceiver failed");
|
||||
return nullptr;
|
||||
@ -53,6 +56,37 @@ OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length)
|
||||
VLOGE("VSyncReceiver Init failed, ret:%{public}d", ret);
|
||||
return nullptr;
|
||||
}
|
||||
return receiver;
|
||||
}
|
||||
|
||||
OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length)
|
||||
{
|
||||
if (name == nullptr) {
|
||||
VLOGE("name is nullptr, please check");
|
||||
return nullptr;
|
||||
}
|
||||
std::string vsyncName(name, length);
|
||||
auto receiver = CreateAndInitVSyncReceiver(vsyncName);
|
||||
if (receiver == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
NativeVSync* nativeVSync = new NativeVSync;
|
||||
nativeVSync->receiver_ = receiver;
|
||||
return OH_NativeVSync_NativeVSyncToOHNativeVSync(nativeVSync);
|
||||
}
|
||||
|
||||
OH_NativeVSync* OH_NativeVSync_Create_ForAssociatedWindow(uint64_t windowID, const char* name, unsigned int length)
|
||||
{
|
||||
if (name == nullptr) {
|
||||
VLOGE("name is nullptr, please check");
|
||||
return nullptr;
|
||||
}
|
||||
std::string vsyncName(name, length);
|
||||
auto receiver = CreateAndInitVSyncReceiver(vsyncName, windowID, true);
|
||||
if (receiver == nullptr) {
|
||||
VLOGE("receiver is nullptr, please check");
|
||||
return nullptr;
|
||||
}
|
||||
NativeVSync* nativeVSync = new NativeVSync;
|
||||
nativeVSync->receiver_ = receiver;
|
||||
return OH_NativeVSync_NativeVSyncToOHNativeVSync(nativeVSync);
|
||||
|
@ -419,15 +419,24 @@ sptr<Surface> RSRenderServiceConnection::CreateNodeAndSurface(const RSSurfaceRen
|
||||
return pSurface;
|
||||
}
|
||||
|
||||
|
||||
sptr<IVSyncConnection> RSRenderServiceConnection::CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
NodeId windowNodeId,
|
||||
bool fromXcomponent)
|
||||
{
|
||||
if (!mainThread_) {
|
||||
return nullptr;
|
||||
}
|
||||
if (fromXcomponent) {
|
||||
auto& node = RSMainThread::Instance()->GetContext().GetNodeMap()
|
||||
.GetRenderNode<RSRenderNode>(windowNodeId);
|
||||
if (node == nullptr) {
|
||||
RS_LOGE("RSRenderServiceConnection::CreateVSyncConnection:node is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
windowNodeId = node->GetInstanceRootNodeId();
|
||||
}
|
||||
sptr<VSyncConnection> conn = new VSyncConnection(appVSyncDistributor_, name, token->AsObject(), 0, windowNodeId);
|
||||
if (ExtractPid(id) == remotePid_) {
|
||||
mainThread_->ScheduleTask([weakThis = wptr<RSRenderServiceConnection>(this), id]() {
|
||||
|
@ -71,7 +71,8 @@ private:
|
||||
sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id,
|
||||
NodeId windowNodeId = 0) override;
|
||||
NodeId windowNodeId = 0,
|
||||
bool fromXcomponent = false) override;
|
||||
|
||||
std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurface(sptr<Surface> surface, const Rect &srcRect) override;
|
||||
|
||||
|
@ -66,7 +66,8 @@ public:
|
||||
virtual sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token = nullptr,
|
||||
uint64_t id = 0,
|
||||
NodeId windowNodeId = 0) = 0;
|
||||
NodeId windowNodeId = 0,
|
||||
bool fromXcomponent = false) = 0;
|
||||
|
||||
virtual std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurface(sptr<Surface> surface,
|
||||
const Rect &srcRect) = 0;
|
||||
|
@ -131,7 +131,8 @@ public:
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr,
|
||||
uint64_t id = 0,
|
||||
NodeId windowNodeId = 0);
|
||||
NodeId windowNodeId = 0,
|
||||
bool fromXcomponent = false);
|
||||
|
||||
std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurfaceId(uint64_t surfaceid, const Rect &srcRect);
|
||||
|
||||
|
@ -115,7 +115,8 @@ std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
NodeId windowNodeId,
|
||||
bool fromXcomponent)
|
||||
{
|
||||
return std::make_shared<VSyncReceiverDarwin>();
|
||||
}
|
||||
|
@ -157,7 +157,8 @@ std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
NodeId windowNodeId,
|
||||
bool fromXcomponent)
|
||||
{
|
||||
ROSEN_LOGD("RSRenderServiceClient::CreateVSyncReceiver Start");
|
||||
auto renderService = RSRenderServiceConnectHub::GetRenderService();
|
||||
@ -165,7 +166,8 @@ std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
return nullptr;
|
||||
}
|
||||
sptr<VSyncIConnectionToken> token = new IRemoteStub<VSyncIConnectionToken>();
|
||||
sptr<IVSyncConnection> conn = renderService->CreateVSyncConnection(name, token, id, windowNodeId);
|
||||
sptr<IVSyncConnection> conn = renderService->
|
||||
CreateVSyncConnection(name, token, id, windowNodeId, fromXcomponent);
|
||||
if (conn == nullptr) {
|
||||
ROSEN_LOGE("RSRenderServiceClient::CreateVSyncReceiver Failed");
|
||||
return nullptr;
|
||||
|
@ -272,7 +272,8 @@ sptr<Surface> RSRenderServiceConnectionProxy::CreateNodeAndSurface(const RSSurfa
|
||||
sptr<IVSyncConnection> RSRenderServiceConnectionProxy::CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
NodeId windowNodeId,
|
||||
bool fromXcomponent)
|
||||
{
|
||||
if (token == nullptr) {
|
||||
ROSEN_LOGE("RSRenderServiceConnectionProxy::CreateVSyncConnection: token is nullptr.");
|
||||
|
@ -46,7 +46,8 @@ public:
|
||||
virtual sptr<IVSyncConnection> CreateVSyncConnection(const std::string& name,
|
||||
const sptr<VSyncIConnectionToken>& token,
|
||||
uint64_t id = 0,
|
||||
NodeId windowNodeId = 0) override;
|
||||
NodeId windowNodeId = 0,
|
||||
bool fromXcomponent = false) override;
|
||||
|
||||
std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurface(sptr<Surface> surface, const Rect &srcRect) override;
|
||||
|
||||
|
@ -115,7 +115,8 @@ std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
uint64_t id,
|
||||
NodeId windowNodeId)
|
||||
NodeId windowNodeId,
|
||||
bool fromXcomponent)
|
||||
{
|
||||
return std::make_shared<VSyncReceiverWindows>();
|
||||
}
|
||||
|
@ -497,9 +497,10 @@ std::shared_ptr<VSyncReceiver> RSInterfaces::CreateVSyncReceiver(
|
||||
const std::string& name,
|
||||
uint64_t id,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper,
|
||||
NodeId windowNodeId)
|
||||
NodeId windowNodeId,
|
||||
bool fromXcomponent)
|
||||
{
|
||||
return renderServiceClient_->CreateVSyncReceiver(name, looper, id, windowNodeId);
|
||||
return renderServiceClient_->CreateVSyncReceiver(name, looper, id, windowNodeId, fromXcomponent);
|
||||
}
|
||||
|
||||
std::shared_ptr<Media::PixelMap> RSInterfaces::CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect)
|
||||
|
@ -219,7 +219,8 @@ public:
|
||||
const std::string& name,
|
||||
uint64_t id,
|
||||
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr,
|
||||
NodeId windowNodeId = 0);
|
||||
NodeId windowNodeId = 0,
|
||||
bool fromXcomponent = false);
|
||||
|
||||
std::shared_ptr<Media::PixelMap> CreatePixelMapFromSurfaceId(uint64_t surfaceId, const Rect &srcRect);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user