mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-12-21 14:20:46 +00:00
!315 在parent SurfaceNode上挖孔(即将child surfaceNode的绘制区域变为透明)以显示child SurfaceNode的绘制内容
Merge pull request !315 from AliceGao/master
This commit is contained in:
commit
b4998398f2
@ -89,6 +89,10 @@ void RSHardwareProcessor::ProcessSurface(RSSurfaceRenderNode &node)
|
||||
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface consume buffer fail");
|
||||
return;
|
||||
}
|
||||
if (node.IsBufferAvailable() == false) {
|
||||
// Only ipc for one time.
|
||||
node.NotifyBufferAvailable(true);
|
||||
}
|
||||
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(node.GetRenderProperties().GetBoundsGeometry());
|
||||
if (geoPtr == nullptr) {
|
||||
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface geoPtr == nullptr");
|
||||
@ -114,14 +118,16 @@ void RSHardwareProcessor::ProcessSurface(RSSurfaceRenderNode &node)
|
||||
.fence = node.GetFence(),
|
||||
.preBuffer = node.GetPreBuffer(),
|
||||
.preFence = node.GetPreFence(),
|
||||
.blendType = node.GetBlendType(),
|
||||
};
|
||||
std::shared_ptr<HdiLayerInfo> layer = HdiLayerInfo::CreateHdiLayerInfo();
|
||||
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface surfaceNode id:%llu name:[%s] [%d %d %d %d]"\
|
||||
"SrcRect [%d %d] bufferSize [%d %d] DamageSize [%d %d] buffaddr:%p, z:%f, globalZOrder:%d", node.GetId(),
|
||||
node.GetName().c_str(), info.dstRect.x, info.dstRect.y, info.dstRect.w, info.dstRect.h,
|
||||
"SrcRect [%d %d] bufferSize [%d %d] DamageSize [%d %d] buffaddr:%p, z:%f, globalZOrder:%d, blendType = %d",
|
||||
node.GetId(), node.GetName().c_str(),
|
||||
info.dstRect.x, info.dstRect.y, info.dstRect.w, info.dstRect.h,
|
||||
info.srcRect.w, info.srcRect.h, node.GetBuffer()->GetWidth(), node.GetBuffer()->GetHeight(),
|
||||
node.GetDamageRegion().w, node.GetDamageRegion().h, node.GetBuffer().GetRefPtr(),
|
||||
node.GetRenderProperties().GetPositionZ(), info.zOrder);
|
||||
node.GetRenderProperties().GetPositionZ(), info.zOrder, info.blendType);
|
||||
RsRenderServiceUtil::ComposeSurface(layer, node.GetConsumer(), layers_, info);
|
||||
}
|
||||
|
||||
|
@ -328,5 +328,14 @@ void RSRenderServiceConnection::SetScreenBacklight(ScreenId id, uint32_t level)
|
||||
screenManager_->SetScreenBacklight(id, level);
|
||||
}).wait();
|
||||
}
|
||||
|
||||
void RSRenderServiceConnection::RegisterBufferAvailableListener(NodeId id, sptr<RSIBufferAvailableCallback> callback)
|
||||
{
|
||||
std::shared_ptr<RSSurfaceRenderNode> node =
|
||||
mainThread_->GetContext().GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id);
|
||||
if (node != nullptr) {
|
||||
node->RegisterBufferAvailableListener(callback);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "ipc_callbacks/buffer_available_callback.h"
|
||||
#include "pipeline/rs_render_service.h"
|
||||
#include "screen_manager/rs_screen_manager.h"
|
||||
#include "transaction/rs_render_service_connection_stub.h"
|
||||
@ -88,6 +89,8 @@ private:
|
||||
|
||||
void SetScreenBacklight(ScreenId id, uint32_t level) override;
|
||||
|
||||
void RegisterBufferAvailableListener(NodeId id, sptr<RSIBufferAvailableCallback> callback) override;
|
||||
|
||||
wptr<RSRenderService> renderService_;
|
||||
RSMainThread* mainThread_ = nullptr;
|
||||
sptr<RSScreenManager> screenManager_;
|
||||
|
@ -33,7 +33,7 @@ void RsRenderServiceUtil::ComposeSurface(std::shared_ptr<HdiLayerInfo> layer, sp
|
||||
layer->SetCompositionType(CompositionType::COMPOSITION_DEVICE);
|
||||
layer->SetVisibleRegion(1, info.srcRect);
|
||||
layer->SetDirtyRegion(info.srcRect);
|
||||
layer->SetBlendType(BlendType::BLEND_SRCOVER);
|
||||
layer->SetBlendType(info.blendType);
|
||||
layer->SetCropRect(info.srcRect);
|
||||
layers.emplace_back(layer);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "hdi_layer_info.h"
|
||||
#include "hdi_backend.h"
|
||||
#include "display_type.h"
|
||||
#include <surface.h>
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
|
||||
@ -36,6 +37,7 @@ struct ComposeInfo {
|
||||
int32_t fence;
|
||||
sptr<SurfaceBuffer> preBuffer;
|
||||
int32_t preFence;
|
||||
BlendType blendType;
|
||||
};
|
||||
|
||||
class RsRenderServiceUtil {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <window.h>
|
||||
|
||||
#include "common/rs_obj_abs_geometry.h"
|
||||
#include "display_type.h"
|
||||
#include "pipeline/rs_base_render_node.h"
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
#include "pipeline/rs_processor.h"
|
||||
@ -158,6 +159,7 @@ void RSRenderServiceVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode &node)
|
||||
ROSEN_LOGI("RSRenderServiceVisitor::PrepareSurfaceRenderNode this child is not SurfaceNode");
|
||||
continue;
|
||||
}
|
||||
surfaceChild->SetBlendType(BlendType::BLEND_SRC);
|
||||
auto childGeoPtr = std::static_pointer_cast<RSObjAbsGeometry>(
|
||||
surfaceChild->GetRenderProperties().GetBoundsGeometry());
|
||||
if (childGeoPtr != nullptr) {
|
||||
@ -173,10 +175,10 @@ void RSRenderServiceVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode &node)
|
||||
ROSEN_LOGE("RSRenderServiceVisitor::ProcessSurfaceRenderNode processor is nullptr");
|
||||
return;
|
||||
}
|
||||
ProcessBaseRenderNode(node);
|
||||
node.SetGlobalZOrder(globalZOrder_);
|
||||
globalZOrder_ = globalZOrder_ + 1;
|
||||
processor_->ProcessSurface(node);
|
||||
ProcessBaseRenderNode(node);
|
||||
}
|
||||
|
||||
void RSRenderServiceVisitor::SortZOrder(RSBaseRenderNode &node)
|
||||
|
@ -254,6 +254,22 @@ int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
SetScreenBacklight(id, level);
|
||||
break;
|
||||
}
|
||||
case SET_BUFFER_AVAILABLE_LISTENER: {
|
||||
auto token = data.ReadInterfaceToken();
|
||||
if (token != RSIRenderServiceConnection::GetDescriptor()) {
|
||||
ret = ERR_INVALID_STATE;
|
||||
break;
|
||||
}
|
||||
NodeId id = data.ReadUint64();
|
||||
auto remoteObject = data.ReadRemoteObject();
|
||||
if (remoteObject == nullptr) {
|
||||
ret = ERR_NULL_OBJECT;
|
||||
break;
|
||||
}
|
||||
sptr<RSIBufferAvailableCallback> cb = iface_cast<RSIBufferAvailableCallback>(remoteObject);
|
||||
RegisterBufferAvailableListener(id, cb);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = ERR_UNKNOWN_TRANSACTION;
|
||||
break;
|
||||
|
@ -66,6 +66,8 @@ ohos_shared_library("librender_service_base") {
|
||||
"src/common/rs_thread_looper_impl.cpp",
|
||||
|
||||
#ipc_callbacks
|
||||
"src/ipc_callbacks/buffer_available_callback_proxy.cpp",
|
||||
"src/ipc_callbacks/buffer_available_callback_stub.cpp",
|
||||
"src/ipc_callbacks/rs_application_render_thread_proxy.cpp",
|
||||
"src/ipc_callbacks/rs_application_render_thread_stub.cpp",
|
||||
"src/ipc_callbacks/screen_change_callback_proxy.cpp",
|
||||
|
@ -30,6 +30,7 @@ enum RSSurfaceNodeCommandType : uint16_t {
|
||||
SURFACE_NODE_SET_PARENT_SURFACE,
|
||||
SURFACE_NODE_REMOVE_SELF,
|
||||
SURFACE_NODE_UPDATE_SURFACE_SIZE,
|
||||
SURFACE_NODE_CONNECT_TO_NODE_IN_RENDER_SERVICE,
|
||||
};
|
||||
|
||||
class SurfaceNodeCommandHelper {
|
||||
@ -40,6 +41,7 @@ public:
|
||||
static void SetParentSurface(RSContext& context, NodeId nodeId, NodeId parentId);
|
||||
static void RemoveSelf(RSContext& context, NodeId nodeId);
|
||||
static void UpdateSurfaceDefaultSize(RSContext& context, NodeId nodeId, float width, float height);
|
||||
static void ConnectToNodeInRenderService(RSContext& context, NodeId id);
|
||||
};
|
||||
|
||||
ADD_COMMAND(RSSurfaceNodeCreate, ARG(SURFACE_NODE, SURFACE_NODE_CREATE, SurfaceNodeCommandHelper::Create, NodeId))
|
||||
@ -53,6 +55,9 @@ ADD_COMMAND(RSSurfaceNodeRemoveSelf,
|
||||
ARG(SURFACE_NODE, SURFACE_NODE_REMOVE_SELF, SurfaceNodeCommandHelper::RemoveSelf, NodeId))
|
||||
ADD_COMMAND(RSSurfaceNodeUpdateSurfaceDefaultSize, ARG(SURFACE_NODE, SURFACE_NODE_UPDATE_SURFACE_SIZE,
|
||||
SurfaceNodeCommandHelper::UpdateSurfaceDefaultSize, NodeId, float, float))
|
||||
ADD_COMMAND(RSSurfaceNodeConnectToNodeInRenderService,
|
||||
ARG(SURFACE_NODE, SURFACE_NODE_CONNECT_TO_NODE_IN_RENDER_SERVICE,
|
||||
SurfaceNodeCommandHelper::ConnectToNodeInRenderService, NodeId))
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_H
|
||||
#define ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_H
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
#include <iremote_broker.h>
|
||||
|
||||
#include "common/rs_common_def.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSIBufferAvailableCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.BufferAvailableListener");
|
||||
|
||||
RSIBufferAvailableCallback() = default;
|
||||
virtual ~RSIBufferAvailableCallback() noexcept = default;
|
||||
|
||||
enum {
|
||||
ON_BUFFER_AVAILABLE,
|
||||
};
|
||||
|
||||
virtual void OnBufferAvailable(bool isBufferAvailable) = 0;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // ROSEN_OHOS
|
||||
|
||||
#endif // ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_H
|
@ -18,7 +18,11 @@
|
||||
#include <memory>
|
||||
#include <surface.h>
|
||||
|
||||
#include "display_type.h"
|
||||
|
||||
#include "pipeline/rs_render_node.h"
|
||||
#include "ipc_callbacks/buffer_available_callback.h"
|
||||
#include "refbase.h"
|
||||
|
||||
class SkCanvas;
|
||||
namespace OHOS {
|
||||
@ -105,10 +109,23 @@ public:
|
||||
|
||||
static void SendPropertyCommand(std::unique_ptr<RSCommand>& command);
|
||||
|
||||
BlendType GetBlendType();
|
||||
void SetBlendType(BlendType blendType);
|
||||
|
||||
// Only SurfaceNode in RS calls "RegisterBufferAvailableListener" to save callback method sent by RT
|
||||
void RegisterBufferAvailableListener(sptr<RSIBufferAvailableCallback> callback);
|
||||
|
||||
// Only SurfaceNode in RT calls "ConnectToNodeInRenderService" to send callback method to RS
|
||||
void ConnectToNodeInRenderService();
|
||||
|
||||
void NotifyBufferAvailable(bool isBufferAvailable);
|
||||
bool IsBufferAvailable() const;
|
||||
|
||||
private:
|
||||
friend class RSRenderTransition;
|
||||
sptr<Surface> consumer_;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::atomic<int> bufferAvailableCount_ = 0;
|
||||
SkMatrix matrix_;
|
||||
float alpha_ = 0.0f;
|
||||
@ -120,6 +137,9 @@ private:
|
||||
int32_t preFence_ = -1;
|
||||
Rect damageRect_;
|
||||
std::string name_;
|
||||
BlendType blendType_ = BlendType::BLEND_SRCOVER;
|
||||
std::atomic<bool> isBufferAvailable_ = false;
|
||||
sptr<RSIBufferAvailableCallback> callback_ = nullptr;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <surface.h>
|
||||
|
||||
#include "command/rs_command.h"
|
||||
#include "ipc_callbacks/buffer_available_callback.h"
|
||||
#include "ipc_callbacks/iapplication_render_thread.h"
|
||||
#include "ipc_callbacks/screen_change_callback.h"
|
||||
#include "ipc_callbacks/surface_capture_callback.h"
|
||||
@ -60,6 +61,7 @@ public:
|
||||
GET_SCREEN_DATA,
|
||||
EXECUTE_SYNCHRONOUS_TASK,
|
||||
REGISTER_APPLICATION_RENDER_THREAD,
|
||||
SET_BUFFER_AVAILABLE_LISTENER,
|
||||
};
|
||||
|
||||
virtual void CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData) = 0;
|
||||
@ -104,6 +106,8 @@ public:
|
||||
virtual int32_t GetScreenBacklight(ScreenId id) = 0;
|
||||
|
||||
virtual void SetScreenBacklight(ScreenId id, uint32_t level) = 0;
|
||||
|
||||
virtual void RegisterBufferAvailableListener(NodeId id, sptr<RSIBufferAvailableCallback> callback) = 0;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <refbase.h>
|
||||
#include <surface.h>
|
||||
|
||||
#include "ipc_callbacks/buffer_available_callback.h"
|
||||
#include "ipc_callbacks/iapplication_render_thread.h"
|
||||
#include "ipc_callbacks/screen_change_callback.h"
|
||||
#include "ipc_callbacks/surface_capture_callback.h"
|
||||
@ -37,6 +38,7 @@ namespace OHOS {
|
||||
namespace Rosen {
|
||||
// normal callback functor for client users.
|
||||
using ScreenChangeCallback = std::function<void(ScreenId, ScreenEvent)>;
|
||||
using BufferAvailableCallback = std::function<void(bool)>;
|
||||
class SurfaceCaptureCallback {
|
||||
public:
|
||||
SurfaceCaptureCallback() {}
|
||||
@ -86,9 +88,12 @@ public:
|
||||
|
||||
void SetScreenBacklight(ScreenId id, uint32_t level);
|
||||
|
||||
bool RegisterBufferAvailableListener(NodeId id, const BufferAvailableCallback &callback);
|
||||
|
||||
private:
|
||||
void TriggerSurfaceCaptureCallback(NodeId id, Media::PixelMap* pixelmap);
|
||||
std::mutex mutex_;
|
||||
std::map<NodeId, sptr<RSIBufferAvailableCallback>> bufferAvailableCbMap_;
|
||||
sptr<RSIScreenChangeCallback> screenChangeCb_;
|
||||
sptr<RSISurfaceCaptureCallback> surfaceCaptureCbDirector_;
|
||||
std::map<NodeId, std::shared_ptr<SurfaceCaptureCallback>> surfaceCaptureCbMap_;
|
||||
|
@ -68,5 +68,12 @@ void SurfaceNodeCommandHelper::UpdateSurfaceDefaultSize(RSContext& context, Node
|
||||
}
|
||||
}
|
||||
|
||||
void SurfaceNodeCommandHelper::ConnectToNodeInRenderService(RSContext& context, NodeId id)
|
||||
{
|
||||
if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
|
||||
node->ConnectToNodeInRenderService();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
#include "buffer_available_callback_proxy.h"
|
||||
|
||||
#include <message_option.h>
|
||||
#include <message_parcel.h>
|
||||
|
||||
#include "platform/common/rs_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
RSBufferAvailableCallbackProxy::RSBufferAvailableCallbackProxy(const sptr<IRemoteObject>& impl)
|
||||
: IRemoteProxy<RSIBufferAvailableCallback>(impl)
|
||||
{
|
||||
}
|
||||
|
||||
void RSBufferAvailableCallbackProxy::OnBufferAvailable(bool isBufferAvailable)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(RSIBufferAvailableCallback::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
|
||||
data.WriteBool(isBufferAvailable);
|
||||
|
||||
option.SetFlags(MessageOption::TF_ASYNC);
|
||||
int32_t err = Remote()->SendRequest(RSIBufferAvailableCallback::ON_BUFFER_AVAILABLE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
ROSEN_LOGE("RSBufferAvailableCallbackProxy::OnBufferAvailable error = %d", err);
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // ROSEN_OHOS
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_PROXY_H
|
||||
#define ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_PROXY_H
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
#include <iremote_proxy.h>
|
||||
|
||||
#include "ipc_callbacks/buffer_available_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSBufferAvailableCallbackProxy : public IRemoteProxy<RSIBufferAvailableCallback> {
|
||||
public:
|
||||
explicit RSBufferAvailableCallbackProxy(const sptr<IRemoteObject>& impl);
|
||||
virtual ~RSBufferAvailableCallbackProxy() noexcept = default;
|
||||
|
||||
void OnBufferAvailable(bool isBufferAvaiable) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<RSBufferAvailableCallbackProxy> delegator_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // ROSEN_OHOS
|
||||
|
||||
#endif // ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_PROXY_H
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
#include "buffer_available_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
int RSBufferAvailableCallbackStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
auto token = data.ReadInterfaceToken();
|
||||
if (token != RSIBufferAvailableCallback::GetDescriptor()) {
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
int ret = ERR_NONE;
|
||||
switch (code) {
|
||||
case ON_BUFFER_AVAILABLE: {
|
||||
bool isBufferAvailable = data.ReadBool();
|
||||
OnBufferAvailable(isBufferAvailable);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ret = ERR_UNKNOWN_TRANSACTION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // ROSEN_OHOS
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_STUB_H
|
||||
#define ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_STUB_H
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
#include <iremote_stub.h>
|
||||
|
||||
#include "ipc_callbacks/buffer_available_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSBufferAvailableCallbackStub : public IRemoteStub<RSIBufferAvailableCallback> {
|
||||
public:
|
||||
RSBufferAvailableCallbackStub() = default;
|
||||
~RSBufferAvailableCallbackStub() = default;
|
||||
|
||||
int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // ROSEN_OHOS
|
||||
|
||||
#endif // ROSEN_RENDER_SERVICE_BASE_IBUFFER_AVAILABLE_CALLBACK_STUB_H
|
@ -16,9 +16,11 @@
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
|
||||
#include "command/rs_surface_node_command.h"
|
||||
#include "display_type.h"
|
||||
#include "pipeline/rs_root_render_node.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "transaction/rs_transaction_proxy.h"
|
||||
#include "transaction/rs_render_service_client.h"
|
||||
#include "visitor/rs_node_visitor.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -175,5 +177,54 @@ void RSSurfaceRenderNode::SendPropertyCommand(std::unique_ptr<RSCommand>& comman
|
||||
transactionProxy->AddCommand(command, true);
|
||||
}
|
||||
}
|
||||
|
||||
BlendType RSSurfaceRenderNode::GetBlendType()
|
||||
{
|
||||
return blendType_;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::SetBlendType(BlendType blendType)
|
||||
{
|
||||
blendType_ = blendType;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::RegisterBufferAvailableListener(sptr<RSIBufferAvailableCallback> callback)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
callback_ = callback;
|
||||
}
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::ConnectToNodeInRenderService()
|
||||
{
|
||||
auto renderServiceClinet =
|
||||
std::static_pointer_cast<RSRenderServiceClient>(RSIRenderClient::CreateRenderServiceClient());
|
||||
if (renderServiceClinet != nullptr) {
|
||||
renderServiceClinet->RegisterBufferAvailableListener(GetId(),
|
||||
[this](bool isBufferAvailable) {
|
||||
this->NotifyBufferAvailable(isBufferAvailable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::NotifyBufferAvailable(bool isBufferAvailable)
|
||||
{
|
||||
// In RS, "isBufferAvailable_ = true" means buffer is ready and need to trigger ipc callback.
|
||||
// In RT, "isBufferAvailable_ = true" means RT know that RS have had available buffer
|
||||
// and ready to "clip" on parent surface.
|
||||
isBufferAvailable_ = isBufferAvailable;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (callback_ != nullptr) {
|
||||
callback_->OnBufferAvailable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RSSurfaceRenderNode::IsBufferAvailable() const
|
||||
{
|
||||
return isBufferAvailable_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "command/rs_command.h"
|
||||
#include "ipc_callbacks/screen_change_callback_stub.h"
|
||||
#include "ipc_callbacks/surface_capture_callback_stub.h"
|
||||
#include "ipc_callbacks/buffer_available_callback_stub.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "rs_render_service_connect_hub.h"
|
||||
#include "rs_surface_ohos.h"
|
||||
@ -280,5 +281,38 @@ void RSRenderServiceClient::SetScreenBacklight(ScreenId id, uint32_t level)
|
||||
|
||||
renderService->SetScreenBacklight(id, level);
|
||||
}
|
||||
|
||||
class CustomBufferAvailableCallback : public RSBufferAvailableCallbackStub
|
||||
{
|
||||
public:
|
||||
explicit CustomBufferAvailableCallback(const BufferAvailableCallback &callback) : cb_(callback) {}
|
||||
~CustomBufferAvailableCallback() override {};
|
||||
|
||||
void OnBufferAvailable(bool isBufferAvailable) override
|
||||
{
|
||||
if (cb_ != nullptr) {
|
||||
cb_(isBufferAvailable);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BufferAvailableCallback cb_;
|
||||
};
|
||||
|
||||
bool RSRenderServiceClient::RegisterBufferAvailableListener(NodeId id, const BufferAvailableCallback &callback)
|
||||
{
|
||||
auto renderService = RSRenderServiceConnectHub::GetRenderService();
|
||||
if (renderService == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto iter = bufferAvailableCbMap_.find(id);
|
||||
if (iter != bufferAvailableCbMap_.end()) {
|
||||
return true;
|
||||
}
|
||||
sptr<RSIBufferAvailableCallback> bufferAvailableCb = new CustomBufferAvailableCallback(callback);
|
||||
renderService->RegisterBufferAvailableListener(id, bufferAvailableCb);
|
||||
bufferAvailableCbMap_.emplace(id, bufferAvailableCb);
|
||||
return true;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -422,5 +422,29 @@ void RSRenderServiceConnectionProxy::SetScreenBacklight(ScreenId id, uint32_t le
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RSRenderServiceConnectionProxy::RegisterBufferAvailableListener(NodeId id, sptr<RSIBufferAvailableCallback> callback)
|
||||
{
|
||||
if (callback == nullptr) {
|
||||
ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: callback is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(RSIRenderServiceConnection::GetDescriptor())) {
|
||||
return;
|
||||
}
|
||||
|
||||
option.SetFlags(MessageOption::TF_ASYNC);
|
||||
data.WriteUint64(id);
|
||||
data.WriteRemoteObject(callback->AsObject());
|
||||
int32_t err = Remote()->SendRequest(RSIRenderServiceConnection::SET_BUFFER_AVAILABLE_LISTENER, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
ROSEN_LOGE("RSRenderServiceConnectionProxy::RegisterBufferAvailableListener: Send Request err.");
|
||||
}
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -69,6 +69,8 @@ public:
|
||||
|
||||
void SetScreenBacklight(ScreenId id, uint32_t level) override;
|
||||
|
||||
void RegisterBufferAvailableListener(NodeId id, sptr<RSIBufferAvailableCallback> callback) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<RSRenderServiceConnectionProxy> delegator_;
|
||||
};
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "pipeline/rs_render_thread_visitor.h"
|
||||
|
||||
#include <include/core/SkFont.h>
|
||||
#include <include/core/SkColor.h>
|
||||
#include <include/core/SkPaint.h>
|
||||
|
||||
#include "pipeline/rs_canvas_render_node.h"
|
||||
#include "pipeline/rs_dirty_region_manager.h"
|
||||
@ -167,6 +169,17 @@ void RSRenderThreadVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
node.SetMatrix(canvas_->getTotalMatrix());
|
||||
node.SetAlpha(canvas_->GetAlpha());
|
||||
node.SetParentId(node.GetParent().lock()->GetId());
|
||||
|
||||
canvas_->save();
|
||||
canvas_->clipRect({node.GetRenderProperties().GetBoundsPositionX(), node.GetRenderProperties().GetBoundsPositionY(),
|
||||
node.GetRenderProperties().GetBoundsWidth(), node.GetRenderProperties().GetBoundsHeight()});
|
||||
if (node.IsBufferAvailable() == true) {
|
||||
canvas_->clear(SK_ColorTRANSPARENT);
|
||||
} else {
|
||||
canvas_->clear(SK_ColorBLACK);
|
||||
}
|
||||
canvas_->restore();
|
||||
|
||||
#endif
|
||||
ProcessBaseRenderNode(node);
|
||||
}
|
||||
|
@ -215,44 +215,57 @@ bool IsValid(const Vector4f& value)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#define SET_ANIMATABLE_PROPERTY(propertyName, value, property) \
|
||||
do { \
|
||||
auto currentValue = stagingProperties_.Get##propertyName(); \
|
||||
if (ROSEN_EQ(value, currentValue)) { \
|
||||
return; \
|
||||
} \
|
||||
if (RSImplicitAnimator::Instance().NeedImplicitAnimaton() && IsValid(currentValue)) { \
|
||||
RSImplicitAnimator::Instance().CreateImplicitAnimation(*this, property, currentValue, value); \
|
||||
} else if (HasPropertyAnimation(property)) { \
|
||||
std::unique_ptr<RSCommand> command = \
|
||||
std::make_unique<RSNodeSet##propertyName##Delta>(GetId(), (value)-currentValue); \
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance(); \
|
||||
if (transactionProxy != nullptr) { \
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNodeForProperty()); \
|
||||
} \
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
} else { \
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance(); \
|
||||
if (transactionProxy != nullptr) { \
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNodeForProperty()); \
|
||||
} \
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
} \
|
||||
#define SET_ANIMATABLE_PROPERTY(propertyName, value, property) \
|
||||
do { \
|
||||
auto currentValue = stagingProperties_.Get##propertyName(); \
|
||||
if (ROSEN_EQ(value, currentValue)) { \
|
||||
return; \
|
||||
} \
|
||||
if (RSImplicitAnimator::Instance().NeedImplicitAnimaton() && IsValid(currentValue)) { \
|
||||
RSImplicitAnimator::Instance().CreateImplicitAnimation(*this, property, currentValue, value); \
|
||||
} else if (HasPropertyAnimation(property)) { \
|
||||
std::unique_ptr<RSCommand> command = \
|
||||
std::make_unique<RSNodeSet##propertyName##Delta>(GetId(), (value)-currentValue); \
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance(); \
|
||||
if (transactionProxy != nullptr) { \
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNode()); \
|
||||
if (NeedForcedSendToRemote()) { \
|
||||
std::unique_ptr<RSCommand> commandForRemote = \
|
||||
std::make_unique<RSNodeSet##propertyName##Delta>(GetId(), (value)-currentValue); \
|
||||
transactionProxy->AddCommand(commandForRemote, true); \
|
||||
} \
|
||||
} \
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
} else { \
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance(); \
|
||||
if (transactionProxy != nullptr) { \
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNode()); \
|
||||
if (NeedForcedSendToRemote()) { \
|
||||
std::unique_ptr<RSCommand> commandForRemote = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
|
||||
transactionProxy->AddCommand(commandForRemote, true); \
|
||||
} \
|
||||
} \
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SET_NONANIMATABLE_PROPERTY(propertyName, value) \
|
||||
do { \
|
||||
auto currentValue = stagingProperties_.Get##propertyName(); \
|
||||
if (ROSEN_EQ(value, currentValue)) { \
|
||||
return; \
|
||||
} \
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance(); \
|
||||
if (transactionProxy != nullptr) { \
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNodeForProperty()); \
|
||||
} \
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
#define SET_NONANIMATABLE_PROPERTY(propertyName, value) \
|
||||
do { \
|
||||
auto currentValue = stagingProperties_.Get##propertyName(); \
|
||||
if (ROSEN_EQ(value, currentValue)) { \
|
||||
return; \
|
||||
} \
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance(); \
|
||||
if (transactionProxy != nullptr) { \
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNode()); \
|
||||
if (NeedForcedSendToRemote()) { \
|
||||
std::unique_ptr<RSCommand> commandForRemote = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
|
||||
transactionProxy->AddCommand(commandForRemote, true); \
|
||||
} \
|
||||
} \
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
} while (0)
|
||||
|
||||
// alpha
|
||||
|
@ -175,9 +175,9 @@ protected:
|
||||
void OnRemoveChildren() override;
|
||||
void AnimationFinish(long long animationId);
|
||||
|
||||
virtual bool IsRenderServiceNodeForProperty() const
|
||||
virtual bool NeedForcedSendToRemote() const
|
||||
{
|
||||
return IsRenderServiceNode();
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -50,6 +50,10 @@ RSSurfaceNode::SharedPtr RSSurfaceNode::Create(const RSSurfaceNodeConfig& surfac
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, isWindow);
|
||||
}
|
||||
command = std::make_unique<RSSurfaceNodeConnectToNodeInRenderService>(node->GetId());
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, isWindow);
|
||||
}
|
||||
}
|
||||
ROSEN_LOGD("RsDebug RSSurfaceNode::Create id:%llu", node->GetId());
|
||||
return node;
|
||||
@ -142,6 +146,17 @@ sptr<OHOS::Surface> RSSurfaceNode::GetSurface() const
|
||||
}
|
||||
#endif
|
||||
|
||||
bool RSSurfaceNode::NeedForcedSendToRemote() const
|
||||
{
|
||||
if (IsRenderServiceNode()) {
|
||||
// RSRenderSurfaceNode in RS only need send property message to RenderService.
|
||||
return false;
|
||||
} else {
|
||||
// RSRenderSurfaceNode in RT need send property message both to RenderService & RenderThread.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
RSSurfaceNode::RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode)
|
||||
: RSNode(isRenderServiceNode), name_(config.SurfaceNodeName)
|
||||
{}
|
||||
|
@ -58,15 +58,12 @@ public:
|
||||
return RSUINodeType::SURFACE_NODE;
|
||||
}
|
||||
protected:
|
||||
bool NeedForcedSendToRemote() const override;
|
||||
explicit RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode);
|
||||
RSSurfaceNode(const RSSurfaceNode&) = delete;
|
||||
RSSurfaceNode(const RSSurfaceNode&&) = delete;
|
||||
RSSurfaceNode& operator=(const RSSurfaceNode&) = delete;
|
||||
RSSurfaceNode& operator=(const RSSurfaceNode&&) = delete;
|
||||
bool IsRenderServiceNodeForProperty() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config);
|
||||
|
Loading…
Reference in New Issue
Block a user