clip on parent surface (which means set drawing region of child surface

transparent) to make child surface visiable

Signed-off-by: AliceGao <gaobinbin3@huawei.com>
Change-Id: I1a3ee9a323d3d98524dc3309d83e14099f367291
This commit is contained in:
AliceGao 2022-01-26 11:13:51 +08:00
parent e3c8b651f5
commit b40f0f4ee4
27 changed files with 472 additions and 46 deletions

View File

@ -89,6 +89,11 @@ void RSHardwareProcessor::ProcessSurface(RSSurfaceRenderNode &node)
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface consume buffer fail");
return;
}
if (node.callback_ != nullptr && node.IsBufferAvailable() == false) {
// Only ipc for one time.
node.NotifyBufferAvailable(true);
node.callback_->OnBufferAvailable(true);
}
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(node.GetRenderProperties().GetBoundsGeometry());
if (geoPtr == nullptr) {
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface geoPtr == nullptr");
@ -114,13 +119,15 @@ void RSHardwareProcessor::ProcessSurface(RSSurfaceRenderNode &node)
.fence = node.GetFence(),
.preBuffer = node.GetPreBuffer(),
.preFence = node.GetPreFence(),
.isSetBlendTypeToSrc = node.IsBlendTypeSetToSrc(),
};
std::shared_ptr<HdiLayerInfo> layer = HdiLayerInfo::CreateHdiLayerInfo();
ROSEN_LOGE("RsDebug RSHardwareProcessor::ProcessSurface surfaceNode id:%llu name:[%s] [%d %d %d %d]"\
"buffer [%d %d] requestSize [%d %d] buffaddr:%p, z:%f, globalZOrder:%d", node.GetId(), node.GetName().c_str(),
"buffer [%d %d] requestSize [%d %d] buffaddr:%p, z:%f, globalZOrder:%d, IsBlendTypeSetToSrc = %s",
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.GetBuffer().GetRefPtr(),
node.GetRenderProperties().GetPositionZ(), info.zOrder);
node.GetRenderProperties().GetPositionZ(), info.zOrder, info.isSetBlendTypeToSrc ? "true" : "false");
RsRenderServiceUtil::ComposeSurface(layer, node.GetConsumer(), layers_, info);
}

View File

@ -328,5 +328,13 @@ 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

View File

@ -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_;

View File

@ -33,7 +33,11 @@ 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);
if (info.isSetBlendTypeToSrc == false) {
layer->SetBlendType(BlendType::BLEND_SRCOVER);
} else {
layer->SetBlendType(BlendType::BLEND_SRC);
}
layer->SetCropRect(info.srcRect);
layers.emplace_back(layer);
}

View File

@ -36,6 +36,7 @@ struct ComposeInfo {
int32_t fence;
sptr<SurfaceBuffer> preBuffer;
int32_t preFence;
bool isSetBlendTypeToSrc;
};
class RsRenderServiceUtil {

View File

@ -158,6 +158,7 @@ void RSRenderServiceVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode &node)
ROSEN_LOGI("RSRenderServiceVisitor::PrepareSurfaceRenderNode this child is not SurfaceNode");
continue;
}
surfaceChild->SetBlendTypeToSrc(true);
auto childGeoPtr = std::static_pointer_cast<RSObjAbsGeometry>(
surfaceChild->GetRenderProperties().GetBoundsGeometry());
if (childGeoPtr != nullptr) {
@ -173,10 +174,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)

View File

@ -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;

View File

@ -72,6 +72,8 @@ ohos_shared_library("librender_service_base") {
"src/ipc_callbacks/screen_change_callback_stub.cpp",
"src/ipc_callbacks/surface_capture_callback_proxy.cpp",
"src/ipc_callbacks/surface_capture_callback_stub.cpp",
"src/ipc_callbacks/buffer_available_callback_proxy.cpp",
"src/ipc_callbacks/buffer_available_callback_stub.cpp",
#pipeline
"src/pipeline/rs_base_render_node.cpp",

View File

@ -30,6 +30,7 @@ enum RSSurfaceNodeCommandType : uint16_t {
SURFACE_NODE_SET_PARENT_SURFACE,
SURFACE_NODE_REMOVE_SELF,
SURFACE_NODE_UPDATE_SURFACE_SIZE,
SURFACE_NODE_SET_BUFFER_AVAILABLE_LISTENER,
};
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 SetBufferAvailableListener(RSContext& context, NodeId id);
};
ADD_COMMAND(RSSurfaceNodeCreate, ARG(SURFACE_NODE, SURFACE_NODE_CREATE, SurfaceNodeCommandHelper::Create, NodeId))
@ -53,6 +55,8 @@ 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(RSSurfaceNodeSetBufferAvailableListener, ARG(SURFACE_NODE, SURFACE_NODE_SET_BUFFER_AVAILABLE_LISTENER,
SurfaceNodeCommandHelper::SetBufferAvailableListener, NodeId))
} // namespace Rosen
} // namespace OHOS

View File

@ -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

View File

@ -19,6 +19,8 @@
#include <surface.h>
#include "pipeline/rs_render_node.h"
#include "ipc_callbacks/buffer_available_callback.h"
#include "refbase.h"
class SkCanvas;
namespace OHOS {
@ -105,6 +107,17 @@ public:
static void SendPropertyCommand(std::unique_ptr<RSCommand>& command);
bool IsBlendTypeSetToSrc();
void SetBlendTypeToSrc(bool isBlendTypeSetToSrc);
void RegisterBufferAvailableListener(sptr<RSIBufferAvailableCallback> callback);
void SetBufferAvailableListener();
void NotifyBufferAvailable(bool isBufferAvailable);
bool IsBufferAvailable() const;
sptr<RSIBufferAvailableCallback> callback_ = nullptr;
private:
friend class RSRenderTransition;
sptr<Surface> consumer_;
@ -120,6 +133,8 @@ private:
int32_t preFence_ = -1;
Rect damageRect_;
std::string name_;
bool isBlendTypeSetToSrc_ = false;
std::atomic<bool> isBufferAvailable_ = false;
};
} // namespace Rosen
} // namespace OHOS

View File

@ -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

View File

@ -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,10 +88,13 @@ 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_;
sptr<RSIScreenChangeCallback> screenChangeCb_;
sptr<RSIBufferAvailableCallback> bufferAvailableCb_;
sptr<RSISurfaceCaptureCallback> surfaceCaptureCbDirector_;
std::map<NodeId, std::shared_ptr<SurfaceCaptureCallback>> surfaceCaptureCbMap_;

View File

@ -68,5 +68,12 @@ void SurfaceNodeCommandHelper::UpdateSurfaceDefaultSize(RSContext& context, Node
}
}
void SurfaceNodeCommandHelper::SetBufferAvailableListener(RSContext& context, NodeId id)
{
if (auto node = context.GetNodeMap().GetRenderNode<RSSurfaceRenderNode>(id)) {
node->SetBufferAvailableListener();
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -0,0 +1,49 @@
/*
* 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>
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) {
// TODO: Error log
}
}
} // namespace Rosen
} // namespace OHOS
#endif // ROSEN_OHOS

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -19,6 +19,7 @@
#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 +176,43 @@ void RSSurfaceRenderNode::SendPropertyCommand(std::unique_ptr<RSCommand>& comman
transactionProxy->AddCommand(command, true);
}
}
bool RSSurfaceRenderNode::IsBlendTypeSetToSrc()
{
return isBlendTypeSetToSrc_;
}
void RSSurfaceRenderNode::SetBlendTypeToSrc(bool isBlendTypeSetToSrc)
{
isBlendTypeSetToSrc_ = isBlendTypeSetToSrc;
}
void RSSurfaceRenderNode::RegisterBufferAvailableListener(sptr<RSIBufferAvailableCallback> callback)
{
callback_ = callback;
}
void RSSurfaceRenderNode::SetBufferAvailableListener()
{
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)
{
isBufferAvailable_ = isBufferAvailable;
}
bool RSSurfaceRenderNode::IsBufferAvailable() const
{
return isBufferAvailable_;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -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,35 @@ void RSRenderServiceClient::SetScreenBacklight(ScreenId id, uint32_t level)
renderService->SetScreenBacklight(id, level);
}
class CustomBufferAvailableCallback : public RSBufferAvailableCallbackStub
{
public:
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;
}
if (bufferAvailableCb_ == nullptr) {
bufferAvailableCb_ = new CustomBufferAvailableCallback(callback);
}
renderService->RegisterBufferAvailableListener(id, bufferAvailableCb_);
return true;
}
} // namespace Rosen
} // namespace OHOS

View File

@ -422,5 +422,30 @@ 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

View File

@ -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_;
};

View File

@ -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);
}

View File

@ -214,44 +214,56 @@ 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 (IsMessageNeedSendToBothSide()) { \
std::unique_ptr<RSCommand> commandForRemote = std::make_unique<RSNodeSet##propertyName##Delta>(GetId(), value); \
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 (IsMessageNeedSendToBothSide()) { \
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 (IsMessageNeedSendToBothSide()) { \
std::unique_ptr<RSCommand> commandForRemote = std::make_unique<RSNodeSet##propertyName>(GetId(), value); \
transactionProxy->AddCommand(commandForRemote, true); \
} \
} \
stagingProperties_.Set##propertyName(value); \
} while (0)
// alpha

View File

@ -174,9 +174,9 @@ protected:
void OnRemoveChildren() override;
void AnimationFinish(long long animationId);
virtual bool IsRenderServiceNodeForProperty() const
virtual bool IsMessageNeedSendToBothSide() const
{
return IsRenderServiceNode();
return false;
}
private:

View File

@ -50,6 +50,10 @@ RSSurfaceNode::SharedPtr RSSurfaceNode::Create(const RSSurfaceNodeConfig& surfac
if (transactionProxy != nullptr) {
transactionProxy->AddCommand(command, isWindow);
}
command = std::make_unique<RSSurfaceNodeSetBufferAvailableListener>(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::IsMessageNeedSendToBothSide() 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)
{}

View File

@ -58,15 +58,12 @@ public:
return RSUINodeType::SURFACE_NODE;
}
protected:
bool IsMessageNeedSendToBothSide() 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);