mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-02-17 02:20:59 +00:00
commit
8143106ab4
@ -170,7 +170,8 @@ rosen_skia_common_defines = [
|
||||
"XML_STATIC",
|
||||
"XML_POOR_ENTROPY",
|
||||
"SK_DISABLE_AAA",
|
||||
"SK_DISABLE_READBUFFER",
|
||||
|
||||
# "SK_DISABLE_READBUFFER",
|
||||
"SK_DISABLE_EFFECT_DESERIALIZATION",
|
||||
"SK_DISABLE_LEGACY_SHADERCONTEXT",
|
||||
"SK_DISABLE_LOWP_RASTER_PIPELINE",
|
||||
|
@ -40,6 +40,8 @@ ohos_shared_library("librender_service") {
|
||||
"core/pipeline/rs_render_service_visitor.cpp",
|
||||
"core/pipeline/rs_software_processor.cpp",
|
||||
"core/pipeline/rs_surface_capture_task.cpp",
|
||||
"core/pipeline/rs_uni_render_listener.cpp",
|
||||
"core/pipeline/rs_uni_render_visitor.cpp",
|
||||
"core/screen_manager/rs_screen.cpp",
|
||||
"core/screen_manager/rs_screen_manager.cpp",
|
||||
"core/transaction/rs_render_service_connection_stub.cpp",
|
||||
@ -77,6 +79,7 @@ ohos_shared_library("librender_service") {
|
||||
"hitrace_native:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
"startup_l2:syspara",
|
||||
]
|
||||
|
||||
part_name = "graphic_standard"
|
||||
|
@ -77,19 +77,8 @@ void RSCompatibleProcessor::ProcessSurface(RSSurfaceRenderNode& node)
|
||||
RS_LOGE("RsDebug RSCompatibleProcessor::ProcessSurface canvas is nullptr");
|
||||
return;
|
||||
}
|
||||
OHOS::sptr<SurfaceBuffer> cbuffer;
|
||||
RSProcessor::SpecialTask task = [&node, &cbuffer] () -> void{
|
||||
if (cbuffer != node.GetBuffer() && node.GetBuffer() != nullptr) {
|
||||
auto& surfaceConsumer = node.GetConsumer();
|
||||
SurfaceError ret = surfaceConsumer->ReleaseBuffer(node.GetBuffer(), SyncFence::INVALID_FENCE);
|
||||
if (ret != SURFACE_ERROR_OK) {
|
||||
RS_LOGE("RSCompatibleProcessor::ProcessSurface: ReleaseBuffer buffer error! error: %d.", ret);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
bool ret = ConsumeAndUpdateBuffer(node, task, cbuffer);
|
||||
if (!ret) {
|
||||
|
||||
if (!RsRenderServiceUtil::ConsumeAndUpdateBuffer(node)) {
|
||||
RS_LOGE("RsDebug RSCompatibleProcessor::ProcessSurface consume buffer fail");
|
||||
return;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
RSCompatibleProcessor();
|
||||
~RSCompatibleProcessor() override;
|
||||
void ProcessSurface(RSSurfaceRenderNode& node) override;
|
||||
void ProcessSurface(RSDisplayRenderNode& node) override {}
|
||||
void Init(ScreenId id, int32_t offsetX, int32_t offsetY) override;
|
||||
void PostProcess() override;
|
||||
void DoComposeSurfaces();
|
||||
|
@ -36,8 +36,9 @@
|
||||
#include "pipeline/rs_render_service_util.h"
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/ohos/backend/rs_surface_ohos_gl.h"
|
||||
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
|
||||
#include "platform/common/rs_system_properties.h"
|
||||
#include <platform/ohos/backend/rs_surface_ohos_gl.h>
|
||||
#include <platform/ohos/backend/rs_surface_ohos_raster.h>
|
||||
#include "property/rs_properties_painter.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -197,10 +198,7 @@ void RSHardwareProcessor::ProcessSurface(RSSurfaceRenderNode &node)
|
||||
RS_LOGI("RsDebug RSHardwareProcessor::ProcessSurface start node id:%llu available buffer:%d name:[%s]"\
|
||||
"[%d %d %d %d]", node.GetId(), node.GetAvailableBufferCount(), node.GetName().c_str(),
|
||||
node.GetDstRect().left_, node.GetDstRect().top_, node.GetDstRect().width_, node.GetDstRect().height_);
|
||||
OHOS::sptr<SurfaceBuffer> cbuffer;
|
||||
RSProcessor::SpecialTask task = [] () -> void {};
|
||||
bool ret = ConsumeAndUpdateBuffer(node, task, cbuffer);
|
||||
if (!ret) {
|
||||
if (!RsRenderServiceUtil::ConsumeAndUpdateBuffer(node)) {
|
||||
RS_LOGI("RsDebug RSHardwareProcessor::ProcessSurface consume buffer fail");
|
||||
return;
|
||||
}
|
||||
@ -287,6 +285,58 @@ void RSHardwareProcessor::ProcessSurface(RSSurfaceRenderNode &node)
|
||||
}
|
||||
}
|
||||
|
||||
void RSHardwareProcessor::ProcessSurface(RSDisplayRenderNode& node)
|
||||
{
|
||||
RS_LOGI("RSHardwareProcessor::ProcessSurface displayNode id:%llu available buffer:%d", node.GetId(),
|
||||
node.GetAvailableBufferCount());
|
||||
if (!output_) {
|
||||
RS_LOGE("RSHardwareProcessor::ProcessSurface output is nullptr");
|
||||
return;
|
||||
}
|
||||
if (!RsRenderServiceUtil::ConsumeAndUpdateBuffer(node)) {
|
||||
RS_LOGE("RSHardwareProcessor::ProcessSurface consume buffer fail");
|
||||
return;
|
||||
}
|
||||
ComposeInfo info = {
|
||||
.srcRect = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.w = node.GetBuffer()->GetSurfaceBufferWidth(),
|
||||
.h = node.GetBuffer()->GetSurfaceBufferHeight(),
|
||||
},
|
||||
.dstRect = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.w = static_cast<int32_t>(currScreenInfo_.width),
|
||||
.h = static_cast<int32_t>(currScreenInfo_.height),
|
||||
},
|
||||
.visibleRect = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.w = static_cast<int32_t>(currScreenInfo_.width),
|
||||
.h = static_cast<int32_t>(currScreenInfo_.height),
|
||||
},
|
||||
.zOrder = static_cast<int32_t>(node.GetGlobalZOrder()),
|
||||
.alpha = {
|
||||
.enGlobalAlpha = false,
|
||||
},
|
||||
.buffer = node.GetBuffer(),
|
||||
.fence = node.GetFence(),
|
||||
.preBuffer = node.GetPreBuffer(),
|
||||
.preFence = node.GetPreFence(),
|
||||
.blendType = BLEND_NONE,
|
||||
};
|
||||
std::shared_ptr<HdiLayerInfo> layer = HdiLayerInfo::CreateHdiLayerInfo();
|
||||
RS_LOGI("RSHardwareProcessor::ProcessSurface displayNode id:%llu dst [%d %d %d %d]"\
|
||||
"SrcRect [%d %d] rawbuffer [%d %d] surfaceBuffer [%d %d] buffaddr:%p, globalZOrder:%d, blendType = %d",
|
||||
node.GetId(),
|
||||
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()->GetSurfaceBufferWidth(),
|
||||
node.GetBuffer()->GetSurfaceBufferHeight(), node.GetBuffer().GetRefPtr(),
|
||||
info.zOrder, info.blendType);
|
||||
RsRenderServiceUtil::ComposeSurface(layer, node.GetConsumer(), layers_, info, &node);
|
||||
}
|
||||
|
||||
void RSHardwareProcessor::CalculateSrcRect(ComposeInfo& info, RectI clipRegion, RectI originDstRect)
|
||||
{
|
||||
info.srcRect.x = clipRegion.IsEmpty() ? 0 : std::ceil((clipRegion.left_ - originDstRect.left_) *
|
||||
@ -349,8 +399,9 @@ void RSHardwareProcessor::Redraw(
|
||||
.usage = HBM_USE_CPU_READ | HBM_USE_CPU_WRITE | HBM_USE_MEM_DMA | HBM_USE_MEM_FB,
|
||||
.timeout = 0,
|
||||
};
|
||||
bool isUni = RSSystemProperties::GetUniRenderEnabledType() != UniRenderEnabledType::UNI_RENDER_DISABLED;
|
||||
RS_TRACE_NAME("Redraw");
|
||||
bool ifUseGPU = IfUseGPUClient(param);
|
||||
bool ifUseGPU = !isUni && IfUseGPUClient(param);
|
||||
RS_LOGE("RSHardwareProcessor::Redraw if use GPU client: %d!", ifUseGPU);
|
||||
#ifdef RS_ENABLE_GL
|
||||
if (ifUseGPU) {
|
||||
@ -371,6 +422,9 @@ void RSHardwareProcessor::Redraw(
|
||||
}
|
||||
std::unique_ptr<RSPaintFilterCanvas> canvas = std::make_unique<RSPaintFilterCanvas>(skCanvas);
|
||||
for (auto it = param.layers.begin(); it != param.layers.end(); ++it) {
|
||||
if (isUni) {
|
||||
break;
|
||||
}
|
||||
LayerInfoPtr layerInfo = *it;
|
||||
if (layerInfo == nullptr) {
|
||||
continue;
|
||||
@ -438,6 +492,9 @@ void RSHardwareProcessor::Redraw(
|
||||
|
||||
void RSHardwareProcessor::OnRotate()
|
||||
{
|
||||
if (RSSystemProperties::GetUniRenderEnabledType() != UniRenderEnabledType::UNI_RENDER_DISABLED) {
|
||||
return;
|
||||
}
|
||||
int32_t width = static_cast<int32_t>(currScreenInfo_.width);
|
||||
int32_t height = static_cast<int32_t>(currScreenInfo_.height);
|
||||
for (auto& layer: layers_) {
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
RSHardwareProcessor();
|
||||
~RSHardwareProcessor() override;
|
||||
void ProcessSurface(RSSurfaceRenderNode& node) override;
|
||||
void ProcessSurface(RSDisplayRenderNode& node) override;
|
||||
void Init(ScreenId id, int32_t offsetX, int32_t offsetY) override;
|
||||
void PostProcess() override;
|
||||
void CropLayers();
|
||||
|
@ -18,7 +18,9 @@
|
||||
#include "pipeline/rs_base_render_node.h"
|
||||
#include "pipeline/rs_render_service_util.h"
|
||||
#include "pipeline/rs_render_service_visitor.h"
|
||||
#include "pipeline/rs_uni_render_visitor.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/common/rs_system_properties.h"
|
||||
#include "platform/drawing/rs_vsync_client.h"
|
||||
#include "rs_trace.h"
|
||||
#include "screen_manager/rs_screen_manager.h"
|
||||
@ -99,7 +101,14 @@ void RSMainThread::Render()
|
||||
RS_LOGE("RSMainThread::Draw GetGlobalRootRenderNode fail");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<RSNodeVisitor> visitor = std::make_shared<RSRenderServiceVisitor>();
|
||||
static bool isUniRender = RSSystemProperties::GetUniRenderEnabledType() != UniRenderEnabledType::UNI_RENDER_DISABLED;
|
||||
std::shared_ptr<RSNodeVisitor> visitor;
|
||||
if (isUniRender) {
|
||||
RS_LOGI("RSMainThread::Render isUni");
|
||||
visitor = std::make_shared<RSUniRenderVisitor>();
|
||||
} else {
|
||||
visitor = std::make_shared<RSRenderServiceVisitor>();
|
||||
}
|
||||
rootNode->Prepare(visitor);
|
||||
rootNode->Process(visitor);
|
||||
}
|
||||
|
@ -72,96 +72,5 @@ void RSProcessor::SetBufferTimeStamp()
|
||||
RS_LOGE("RSProcessor::SetBufferTimeStamp buffer ExtraSet failed");
|
||||
}
|
||||
}
|
||||
|
||||
void RSProcessor::DropFrameProcess(RSSurfaceRenderNode& node)
|
||||
{
|
||||
auto availableBufferCnt = node.GetAvailableBufferCount();
|
||||
RS_LOGI("RsDebug RSProcessor::DropFrameProcess start node:%llu available buffer:%d", node.GetId(),
|
||||
availableBufferCnt);
|
||||
|
||||
const auto& surfaceConsumer = node.GetConsumer();
|
||||
if (surfaceConsumer == nullptr) {
|
||||
RS_LOGE("RsDebug RSProcessor::DropFrameProcess (node: %llu): surfaceConsumer is null!", node.GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
// availableBufferCnt>= 2 means QueueSize >=2 too
|
||||
if (availableBufferCnt >= 2 && surfaceConsumer->GetQueueSize() == static_cast<uint32_t>(availableBufferCnt)) {
|
||||
RS_LOGI("RsDebug RSProcessor::DropFrameProcess (node: %llu) queueBlock, start to drop one frame", node.GetId());
|
||||
OHOS::sptr<SurfaceBuffer> cbuffer;
|
||||
Rect damage;
|
||||
sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
|
||||
int64_t timestamp = 0;
|
||||
auto ret = surfaceConsumer->AcquireBuffer(cbuffer, acquireFence, timestamp, damage);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
RS_LOGW("RSProcessor::DropFrameProcess(node: %llu): AcquireBuffer failed(ret: %d), do nothing ",
|
||||
node.GetId(), ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = surfaceConsumer->ReleaseBuffer(cbuffer, SyncFence::INVALID_FENCE);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
RS_LOGW("RSProcessor::DropFrameProcess(node: %llu): ReleaseBuffer failed(ret: %d), Acquire done ",
|
||||
node.GetId(), ret);
|
||||
return;
|
||||
}
|
||||
availableBufferCnt = node.ReduceAvailableBuffer();
|
||||
RS_LOGI("RsDebug RSProcessor::DropFrameProcess (node: %llu), drop one frame finished", node.GetId());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool RSProcessor::ConsumeAndUpdateBuffer(RSSurfaceRenderNode& node, SpecialTask& task, sptr<SurfaceBuffer>& buffer)
|
||||
{
|
||||
DropFrameProcess(node);
|
||||
|
||||
sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
|
||||
Rect damage = {0};
|
||||
|
||||
auto availableBufferCnt = node.GetAvailableBufferCount();
|
||||
if (availableBufferCnt == 0) {
|
||||
RS_LOGD("RSProcessor::ProcessSurface(node: %llu): no new buffer, try use old buffer.", node.GetId());
|
||||
buffer = node.GetBuffer();
|
||||
acquireFence = node.GetFence();
|
||||
damage = node.GetDamageRegion();
|
||||
} else {
|
||||
const auto& surfaceConsumer = node.GetConsumer();
|
||||
if (surfaceConsumer == nullptr) {
|
||||
RS_LOGE("RSProcessor::ProcessSurface(node: %llu): surfaceConsumer is null!", node.GetId());
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
|
||||
int64_t timestamp = 0;
|
||||
auto ret = surfaceConsumer->AcquireBuffer(buffer, acquireFence, timestamp, damage);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
RS_LOGW("RSProcessor::ProcessSurface(node: %llu): AcquireBuffer failed(ret: %d), try use old buffer.",
|
||||
node.GetId(), ret);
|
||||
buffer = node.GetBuffer();
|
||||
acquireFence = node.GetFence();
|
||||
damage = node.GetDamageRegion();
|
||||
} else {
|
||||
availableBufferCnt = node.ReduceAvailableBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer == nullptr) {
|
||||
RS_LOGE("RSProcessor::ProcessSurface(node: %llu): no avaliable buffer!", node.GetId());
|
||||
return false;
|
||||
}
|
||||
|
||||
task();
|
||||
node.SetBuffer(buffer);
|
||||
node.SetFence(acquireFence);
|
||||
node.SetDamageRegion(damage);
|
||||
|
||||
// still hava buffer(s) to consume.
|
||||
if (availableBufferCnt > 0) {
|
||||
RSMainThread::Instance()->RequestNextVSync();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
using SpecialTask = std::function<void()>;
|
||||
RSProcessor() {}
|
||||
virtual ~RSProcessor() {}
|
||||
virtual void ProcessSurface(RSSurfaceRenderNode &node) = 0;
|
||||
virtual void ProcessSurface(RSSurfaceRenderNode& node) = 0;
|
||||
virtual void ProcessSurface(RSDisplayRenderNode& node) = 0;
|
||||
virtual void Init(ScreenId id, int32_t offsetX, int32_t offsetY) = 0;
|
||||
virtual void PostProcess() = 0;
|
||||
|
||||
@ -50,12 +51,11 @@ protected:
|
||||
SkCanvas* CreateCanvas(
|
||||
const std::shared_ptr<RSSurfaceOhos>& surface,
|
||||
const BufferRequestConfig& requestConfig);
|
||||
bool ConsumeAndUpdateBuffer(RSSurfaceRenderNode& node, SpecialTask& task, sptr<SurfaceBuffer>& buffer);
|
||||
|
||||
void SetBufferTimeStamp();
|
||||
int32_t GetOffsetX();
|
||||
int32_t GetOffsetY();
|
||||
void DropFrameProcess(RSSurfaceRenderNode& node);
|
||||
|
||||
|
||||
#ifdef RS_ENABLE_GL
|
||||
std::shared_ptr<RenderContext> renderContext_;
|
||||
std::shared_ptr<RSEglImageManager> eglImageManager_;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "display_type.h"
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "pipeline/rs_main_thread.h"
|
||||
#include "common/rs_vector2.h"
|
||||
#include "pipeline/rs_paint_filter_canvas.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
@ -531,7 +532,7 @@ bool ConvertYUV420SPToRGBA(std::vector<uint8_t>& rgbaBuf, const sptr<OHOS::Surfa
|
||||
bool RsRenderServiceUtil::enableClient = false;
|
||||
|
||||
void RsRenderServiceUtil::ComposeSurface(std::shared_ptr<HdiLayerInfo> layer, sptr<Surface> consumerSurface,
|
||||
std::vector<LayerInfoPtr>& layers, ComposeInfo info, RSSurfaceRenderNode* node)
|
||||
std::vector<LayerInfoPtr>& layers, ComposeInfo info, RSBaseRenderNode* node)
|
||||
{
|
||||
layer->SetSurface(consumerSurface);
|
||||
layer->SetBuffer(info.buffer, info.fence, info.preBuffer, info.preFence);
|
||||
@ -539,8 +540,14 @@ void RsRenderServiceUtil::ComposeSurface(std::shared_ptr<HdiLayerInfo> layer, sp
|
||||
layer->SetAlpha(info.alpha);
|
||||
layer->SetLayerSize(info.dstRect);
|
||||
layer->SetLayerAdditionalInfo(node);
|
||||
layer->SetCompositionType(IsNeedClient(node) ?
|
||||
CompositionType::COMPOSITION_CLIENT : CompositionType::COMPOSITION_DEVICE);
|
||||
|
||||
if (node->IsInstanceOf<RSSurfaceRenderNode>()) {
|
||||
layer->SetCompositionType(IsNeedClient(static_cast<RSSurfaceRenderNode*>(node)) ?
|
||||
CompositionType::COMPOSITION_CLIENT : CompositionType::COMPOSITION_DEVICE);
|
||||
} else {
|
||||
layer->SetCompositionType(CompositionType::COMPOSITION_DEVICE);
|
||||
}
|
||||
|
||||
layer->SetVisibleRegion(1, info.visibleRect);
|
||||
layer->SetDirtyRegion(info.srcRect);
|
||||
layer->SetBlendType(info.blendType);
|
||||
@ -548,6 +555,104 @@ void RsRenderServiceUtil::ComposeSurface(std::shared_ptr<HdiLayerInfo> layer, sp
|
||||
layers.emplace_back(layer);
|
||||
}
|
||||
|
||||
void RsRenderServiceUtil::DropFrameProcess(RSSurfaceHandler& node)
|
||||
{
|
||||
auto availableBufferCnt = node.GetAvailableBufferCount();
|
||||
RS_LOGI("RsDebug RsRenderServiceUtil::DropFrameProcess start node:%llu available buffer:%d", node.GetId(),
|
||||
availableBufferCnt);
|
||||
|
||||
const auto& surfaceConsumer = node.GetConsumer();
|
||||
if (surfaceConsumer == nullptr) {
|
||||
RS_LOGE("RsDebug RsRenderServiceUtil::DropFrameProcess (node: %llu): surfaceConsumer is null!", node.GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
// availableBufferCnt>= 2 means QueueSize >=2 too
|
||||
if (availableBufferCnt >= 2 && surfaceConsumer->GetQueueSize() == static_cast<uint32_t>(availableBufferCnt)) {
|
||||
RS_LOGI("RsRenderServiceUtil::DropFrameProcess(node: %llu) queueBlock, start to drop one frame", node.GetId());
|
||||
OHOS::sptr<SurfaceBuffer> cbuffer;
|
||||
Rect damage;
|
||||
sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
|
||||
int64_t timestamp = 0;
|
||||
auto ret = surfaceConsumer->AcquireBuffer(cbuffer, acquireFence, timestamp, damage);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
RS_LOGW("RsRenderServiceUtil::DropFrameProcess(node: %llu): AcquireBuffer failed(ret: %d), do nothing ",
|
||||
node.GetId(), ret);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = surfaceConsumer->ReleaseBuffer(cbuffer, SyncFence::INVALID_FENCE);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
RS_LOGW("RsRenderServiceUtil::DropFrameProcess(node: %llu): ReleaseBuffer failed(ret: %d), Acquire done ",
|
||||
node.GetId(), ret);
|
||||
return;
|
||||
}
|
||||
availableBufferCnt = node.ReduceAvailableBuffer();
|
||||
RS_LOGI("RsDebug RsRenderServiceUtil::DropFrameProcess (node: %llu), drop one frame finished", node.GetId());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool RsRenderServiceUtil::ConsumeAndUpdateBuffer(RSSurfaceHandler& node, bool toReleaseBuffer)
|
||||
{
|
||||
DropFrameProcess(node);
|
||||
|
||||
sptr<SurfaceBuffer> buffer;
|
||||
sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
|
||||
Rect damage = {0};
|
||||
const auto& surfaceConsumer = node.GetConsumer();
|
||||
|
||||
auto availableBufferCnt = node.GetAvailableBufferCount();
|
||||
if (availableBufferCnt == 0) {
|
||||
RS_LOGD("RsRenderServiceUtil::ConsumeAndUpdateBuffer(node:%llu): no new buffer, try old buffer", node.GetId());
|
||||
buffer = node.GetBuffer();
|
||||
acquireFence = node.GetFence();
|
||||
damage = node.GetDamageRegion();
|
||||
} else {
|
||||
if (surfaceConsumer == nullptr) {
|
||||
RS_LOGE("RsRenderServiceUtil::ConsumeAndUpdateBuffer(node: %llu): surfaceConsumer is null!", node.GetId());
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<SyncFence> acquireFence = SyncFence::INVALID_FENCE;
|
||||
int64_t timestamp = 0;
|
||||
auto ret = surfaceConsumer->AcquireBuffer(buffer, acquireFence, timestamp, damage);
|
||||
if (ret != OHOS::SURFACE_ERROR_OK) {
|
||||
RS_LOGW("RsRenderServiceUtil::ConsumeAndUpdateBuffer (node: %llu): AcquireBuffer failed (ret: %d)," \
|
||||
"try old buffer", node.GetId(), ret);
|
||||
buffer = node.GetBuffer();
|
||||
acquireFence = node.GetFence();
|
||||
damage = node.GetDamageRegion();
|
||||
} else {
|
||||
availableBufferCnt = node.ReduceAvailableBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer == nullptr) {
|
||||
RS_LOGE("RsRenderServiceUtil::ConsumeAndUpdateBuffer(node: %llu): no available buffer!", node.GetId());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (toReleaseBuffer && node.GetBuffer() != nullptr && node.GetBuffer() != buffer) {
|
||||
SurfaceError ret = surfaceConsumer->ReleaseBuffer(node.GetBuffer(), -1);
|
||||
if (ret != SURFACE_ERROR_OK) {
|
||||
RS_LOGE("RsRenderServiceUtil::ConsumeAndUpdateBuffer ReleaseBuffer error:%d.", ret);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
node.SetBuffer(buffer);
|
||||
node.SetFence(acquireFence);
|
||||
node.SetDamageRegion(damage);
|
||||
|
||||
// still hava buffer(s) to consume.
|
||||
if (availableBufferCnt > 0) {
|
||||
RSMainThread::Instance()->RequestNextVSync();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RsRenderServiceUtil::IsNeedClient(RSSurfaceRenderNode* node)
|
||||
{
|
||||
if (enableClient) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkMatrix.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "pipeline/rs_paint_filter_canvas.h"
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
@ -67,7 +68,7 @@ class RsRenderServiceUtil {
|
||||
public:
|
||||
using CanvasPostProcess = std::function<void(RSPaintFilterCanvas&, BufferDrawParam&)>;
|
||||
static void ComposeSurface(std::shared_ptr<HdiLayerInfo> layer, sptr<Surface> consumerSurface,
|
||||
std::vector<LayerInfoPtr>& layers, ComposeInfo info, RSSurfaceRenderNode* node = nullptr);
|
||||
std::vector<LayerInfoPtr>& layers, ComposeInfo info, RSBaseRenderNode* node = nullptr);
|
||||
static void DrawBuffer(RSPaintFilterCanvas& canvas, BufferDrawParam& bufferDrawParam,
|
||||
CanvasPostProcess process = nullptr);
|
||||
|
||||
@ -75,18 +76,24 @@ public:
|
||||
static void DrawImage(std::shared_ptr<RSEglImageManager> eglImageManager, GrContext* grContext,
|
||||
RSPaintFilterCanvas& canvas, BufferDrawParam& bufferDrawParam, CanvasPostProcess process);
|
||||
#endif // RS_ENABLE_GL
|
||||
|
||||
static BufferDrawParam CreateBufferDrawParam(RSSurfaceRenderNode& node, SkMatrix canvasMatrix = SkMatrix(),
|
||||
ScreenRotation rotation = ScreenRotation::ROTATION_0);
|
||||
static void DealAnimation(RSPaintFilterCanvas& canvas, RSSurfaceRenderNode& node, BufferDrawParam& params,
|
||||
const Vector2f& center);
|
||||
static void InitEnableClient();
|
||||
static bool CreateYuvToRGBABitMap(sptr<OHOS::SurfaceBuffer> buffer, std::vector<uint8_t>& newBuffer,
|
||||
SkBitmap& bitmap);
|
||||
|
||||
static void DropFrameProcess(RSSurfaceHandler& node);
|
||||
static bool ConsumeAndUpdateBuffer(RSSurfaceHandler& node, bool toReleaseBuffer = false);
|
||||
|
||||
private:
|
||||
static SkMatrix GetCanvasTransform(const RSSurfaceRenderNode& node, const SkMatrix& canvasMatrix,
|
||||
ScreenRotation rotation, SkRect clipRect);
|
||||
static bool IsNeedClient(RSSurfaceRenderNode* node);
|
||||
static bool CreateBitmap(sptr<OHOS::SurfaceBuffer> buffer, SkBitmap& bitmap);
|
||||
static bool CreateYuvToRGBABitMap(sptr<OHOS::SurfaceBuffer> buffer, std::vector<uint8_t>& newBuffer,
|
||||
SkBitmap& bitmap);
|
||||
|
||||
static bool CreateNewColorGamutBitmap(sptr<OHOS::SurfaceBuffer> buffer, std::vector<uint8_t>& newGamutBuffer,
|
||||
SkBitmap& bitmap, ColorGamut srcGamut, ColorGamut dstGamut);
|
||||
static bool enableClient;
|
||||
|
@ -82,7 +82,7 @@ void RSSoftwareProcessor::ProcessSurface(RSSurfaceRenderNode& node)
|
||||
return;
|
||||
}
|
||||
|
||||
DropFrameProcess(node);
|
||||
RsRenderServiceUtil::DropFrameProcess(node);
|
||||
|
||||
auto consumerSurface = node.GetConsumer();
|
||||
if (!consumerSurface) {
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
RSSoftwareProcessor();
|
||||
~RSSoftwareProcessor() override;
|
||||
void ProcessSurface(RSSurfaceRenderNode& node) override;
|
||||
void ProcessSurface(RSDisplayRenderNode& node) override {}
|
||||
void Init(ScreenId id, int32_t offsetX, int32_t offsetY) override;
|
||||
void PostProcess() override;
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#include "pipeline/rs_uni_render_listener.h"
|
||||
|
||||
#include "pipeline/rs_main_thread.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
RSUniRenderListener::~RSUniRenderListener() {}
|
||||
|
||||
RSUniRenderListener::RSUniRenderListener(std::weak_ptr<RSDisplayRenderNode> displayRenderNode)
|
||||
: displayRenderNode_(displayRenderNode) {}
|
||||
|
||||
void RSUniRenderListener::OnBufferAvailable()
|
||||
{
|
||||
auto node = displayRenderNode_.lock();
|
||||
if (node == nullptr) {
|
||||
RS_LOGE("RSUniRenderListener::OnBufferAvailable node is nullptr");
|
||||
return;
|
||||
}
|
||||
RS_LOGD("RSUniRenderListener::OnBufferAvailable node id:%llu", node->GetId());
|
||||
node->IncreaseAvailableBuffer();
|
||||
|
||||
std::shared_ptr<RSProcessor> processor;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
processor = processor_;
|
||||
}
|
||||
RSMainThread::Instance()->PostTask([node, processor]() {
|
||||
if (processor != nullptr) {
|
||||
processor->ProcessSurface(*node);
|
||||
processor->PostProcess();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void RSUniRenderListener::UpdateProcessor(std::shared_ptr<RSProcessor> processor)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
processor_ = processor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 RENDER_SERVICE_PIPELINE_RS_UNI_RENDER_LISTENER_H
|
||||
#define RENDER_SERVICE_PIPELINE_RS_UNI_RENDER_LISTENER_H
|
||||
|
||||
#include <mutex>
|
||||
#include <ibuffer_consumer_listener.h>
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
#include "pipeline/rs_processor.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSUniRenderListener : public IBufferConsumerListener {
|
||||
public:
|
||||
RSUniRenderListener(std::weak_ptr<RSDisplayRenderNode> displayRenderNode);
|
||||
~RSUniRenderListener() override;
|
||||
void OnBufferAvailable() override;
|
||||
void UpdateProcessor(std::shared_ptr<RSProcessor> processor);
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::weak_ptr<RSDisplayRenderNode> displayRenderNode_;
|
||||
std::shared_ptr<RSProcessor> processor_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // RENDER_SERVICE_PIPELINE_RS_UNI_RENDER_LISTENER_H
|
@ -0,0 +1,348 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#include "pipeline/rs_uni_render_visitor.h"
|
||||
|
||||
#include "common/rs_obj_abs_geometry.h"
|
||||
#include "display_type.h"
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
#include "pipeline/rs_main_thread.h"
|
||||
#include "pipeline/rs_processor_factory.h"
|
||||
#include "pipeline/rs_render_service_util.h"
|
||||
#include "pipeline/rs_root_render_node.h"
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
#include "pipeline/rs_uni_render_listener.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/common/rs_system_properties.h"
|
||||
#include "property/rs_properties_painter.h"
|
||||
#include "render/rs_skia_filter.h"
|
||||
#include "rs_trace.h"
|
||||
#include "screen_manager/screen_types.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
RSUniRenderVisitor::RSUniRenderVisitor() {}
|
||||
|
||||
RSUniRenderVisitor::~RSUniRenderVisitor() {}
|
||||
|
||||
void RSUniRenderVisitor::PrepareBaseRenderNode(RSBaseRenderNode& node)
|
||||
{
|
||||
for (auto& child : node.GetSortedChildren()) {
|
||||
child->Prepare(shared_from_this());
|
||||
}
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::PrepareDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
{
|
||||
isUniRenderForAll_ =
|
||||
RSSystemProperties::GetUniRenderEnabledType() == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL;
|
||||
if (!isUniRenderForAll_) {
|
||||
RS_LOGI("RSUniRenderVisitor::PrepareDisplayRenderNode isUniRenderForAll_ false");
|
||||
uniRenderList_ = RSSystemProperties::GetUniRenderEnabledList();
|
||||
}
|
||||
PrepareBaseRenderNode(node);
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::PrepareSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
{
|
||||
if (isUniRenderForAll_ || uniRenderList_.find(node.GetName()) != uniRenderList_.end()) {
|
||||
isUniRender_ = true;
|
||||
hasUniRender_ = true;
|
||||
}
|
||||
if (IsChildOfDisplayNode(node)) {
|
||||
auto currentGeoPtr = std::static_pointer_cast<RSObjAbsGeometry>(node.GetRenderProperties().GetBoundsGeometry());
|
||||
if (currentGeoPtr != nullptr) {
|
||||
currentGeoPtr->UpdateByMatrixFromParent(nullptr);
|
||||
currentGeoPtr->UpdateByMatrixFromRenderThread(node.GetMatrix());
|
||||
currentGeoPtr->UpdateByMatrixFromSelf();
|
||||
}
|
||||
PrepareBaseRenderNode(node);
|
||||
} else {
|
||||
bool dirtyFlag = dirtyFlag_;
|
||||
dirtyFlag_ = node.Update(dirtyManager_, parent_ ? &(parent_->GetRenderProperties()) : nullptr, dirtyFlag_);
|
||||
PrepareBaseRenderNode(node);
|
||||
dirtyFlag_ = dirtyFlag;
|
||||
}
|
||||
isUniRender_ = false;
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::PrepareRootRenderNode(RSRootRenderNode& node)
|
||||
{
|
||||
if (!isUniRender_ || !IsChildOfSurfaceNode(node)) {
|
||||
return;
|
||||
}
|
||||
parent_ = nullptr;
|
||||
dirtyFlag_ = false;
|
||||
PrepareCanvasRenderNode(node);
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::PrepareCanvasRenderNode(RSCanvasRenderNode &node)
|
||||
{
|
||||
bool dirtyFlag = dirtyFlag_;
|
||||
dirtyFlag_ = node.Update(dirtyManager_, parent_ ? &(parent_->GetRenderProperties()) : nullptr, dirtyFlag_);
|
||||
PrepareBaseRenderNode(node);
|
||||
dirtyFlag_ = dirtyFlag;
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ProcessBaseRenderNode(RSBaseRenderNode& node)
|
||||
{
|
||||
for (auto& child : node.GetSortedChildren()) {
|
||||
child->Process(shared_from_this());
|
||||
}
|
||||
// clear SortedChildren, it will be generated again in next frame
|
||||
node.ResetSortedChildren();
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ProcessDisplayRenderNode(RSDisplayRenderNode& node)
|
||||
{
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessDisplayRenderNode node: %llu, child size:%u", node.GetChildrenCount(),
|
||||
node.GetId());
|
||||
globalZOrder_ = 0.0f;
|
||||
sptr<RSScreenManager> screenManager = CreateOrGetScreenManager();
|
||||
if (!screenManager) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode ScreenManager is nullptr");
|
||||
return;
|
||||
}
|
||||
screenInfo_ = screenManager->QueryScreenInfo(node.GetScreenId());
|
||||
switch (screenInfo_.state) {
|
||||
case ScreenState::PRODUCER_SURFACE_ENABLE:
|
||||
node.SetCompositeType(RSDisplayRenderNode::CompositeType::SOFTWARE_COMPOSITE);
|
||||
break;
|
||||
case ScreenState::HDI_OUTPUT_ENABLE:
|
||||
node.SetCompositeType(node.IsForceSoftComposite() ? RSDisplayRenderNode::CompositeType::COMPATIBLE_COMPOSITE
|
||||
: RSDisplayRenderNode::CompositeType::HARDWARE_COMPOSITE);
|
||||
break;
|
||||
default:
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode ScreenState unsupported");
|
||||
return;
|
||||
}
|
||||
processor_ = RSProcessorFactory::CreateProcessor(node.GetCompositeType());
|
||||
if (processor_ == nullptr) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode: RSProcessor is null!");
|
||||
return;
|
||||
}
|
||||
processor_->Init(node.GetScreenId(), node.GetDisplayOffsetX(), node.GetDisplayOffsetY());
|
||||
|
||||
if (hasUniRender_) {
|
||||
std::shared_ptr<RSBaseRenderNode> nodePtr = node.shared_from_this();
|
||||
auto displayNodePtr = nodePtr->ReinterpretCastTo<RSDisplayRenderNode>();
|
||||
if (!displayNodePtr) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode ReinterpretCastTo fail");
|
||||
return;
|
||||
}
|
||||
if (!node.IsSurfaceCreated()) {
|
||||
sptr<IBufferConsumerListener> listener = new RSUniRenderListener(displayNodePtr);
|
||||
if (!node.CreateSurface(listener)) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode CreateSurface failed");
|
||||
return;
|
||||
}
|
||||
#ifdef ACE_ENABLE_GL
|
||||
RS_LOGI("RSUniRenderVisitor::ProcessDisplayRenderNode SetRenderContext");
|
||||
node.GetRSSurface()->SetRenderContext(RSMainThread::Instance()->GetRenderContext().get());
|
||||
#endif
|
||||
}
|
||||
auto consumerListener = static_cast<RSUniRenderListener*>(node.GetConsumerListener().GetRefPtr());
|
||||
if (consumerListener != nullptr) {
|
||||
consumerListener->UpdateProcessor(processor_);
|
||||
}
|
||||
auto rsSurface = node.GetRSSurface();
|
||||
if (rsSurface == nullptr) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessDisplayRenderNode No RSSurface found");
|
||||
return;
|
||||
}
|
||||
auto surfaceFrame = rsSurface->RequestFrame(screenInfo_.width, screenInfo_.height);
|
||||
if (surfaceFrame == nullptr) {
|
||||
RS_LOGE("RSUniRenderVisitor Request Frame Failed");
|
||||
return;
|
||||
}
|
||||
canvas_ = new RSPaintFilterCanvas(surfaceFrame->GetCanvas());
|
||||
canvas_->clear(SK_ColorTRANSPARENT);
|
||||
|
||||
ProcessBaseRenderNode(node);
|
||||
RS_TRACE_BEGIN("RSUniRender:FlushFrame");
|
||||
rsSurface->FlushFrame(surfaceFrame);
|
||||
RS_TRACE_END();
|
||||
delete canvas_;
|
||||
canvas_ = nullptr;
|
||||
|
||||
node.SetGlobalZOrder(uniZOrder_);
|
||||
} else {
|
||||
RsRenderServiceUtil::ConsumeAndUpdateBuffer(node, true);
|
||||
ProcessBaseRenderNode(node);
|
||||
}
|
||||
if (!hasUniRender_) {
|
||||
processor_->PostProcess();
|
||||
}
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessDisplayRenderNode end");
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ProcessSurfaceRenderNode(RSSurfaceRenderNode& node)
|
||||
{
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessSurfaceRenderNode node: %llu, child size:%u %s", node.GetId(),
|
||||
node.GetChildrenCount(), node.GetName().c_str());
|
||||
if (isUniRenderForAll_ || uniRenderList_.find(node.GetName()) != uniRenderList_.end()) {
|
||||
isUniRender_ = true;
|
||||
}
|
||||
if (isUniRender_) {
|
||||
if (IsChildOfDisplayNode(node)) {
|
||||
if (!node.GetRenderProperties().GetVisible()) {
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessSurfaceRenderNode node: %llu invisible", node.GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canvas_) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessSurfaceRenderNode, canvas is nullptr");
|
||||
return;
|
||||
}
|
||||
auto geoPtr = std::static_pointer_cast<RSObjAbsGeometry>(node.GetRenderProperties().GetBoundsGeometry());
|
||||
if (!geoPtr) {
|
||||
RS_LOGI("RSUniRenderVisitor::ProcessSurfaceRenderNode node:%llu, get geoPtr failed",
|
||||
node.GetId());
|
||||
return;
|
||||
}
|
||||
RsRenderServiceUtil::ConsumeAndUpdateBuffer(node, true);
|
||||
RS_TRACE_BEGIN("RSUniRender::Process:" + node.GetName());
|
||||
uniZOrder_ = globalZOrder_++;
|
||||
canvas_->save();
|
||||
canvas_->SaveAlpha();
|
||||
canvas_->MultiplyAlpha(node.GetAlpha());
|
||||
canvas_->setMatrix(geoPtr->GetAbsMatrix());
|
||||
ProcessBaseRenderNode(node);
|
||||
canvas_->RestoreAlpha();
|
||||
canvas_->restore();
|
||||
RS_TRACE_END();
|
||||
} else {
|
||||
if (IsChildOfSurfaceNode(node)) {
|
||||
RS_LOGI("RSUniRenderVisitor::ProcessSurfaceRenderNode not ChildOfSurfaceNode");
|
||||
return;
|
||||
}
|
||||
RS_TRACE_BEGIN("UniRender::Process:" + node.GetName());
|
||||
canvas_->save();
|
||||
canvas_->clipRect(SkRect::MakeXYWH(
|
||||
node.GetRenderProperties().GetBoundsPositionX(), node.GetRenderProperties().GetBoundsPositionY(),
|
||||
node.GetRenderProperties().GetBoundsWidth(), node.GetRenderProperties().GetBoundsHeight()));
|
||||
if (!RsRenderServiceUtil::ConsumeAndUpdateBuffer(node, true)) {
|
||||
RS_LOGI("RSUniRenderVisitor::ProcessSurfaceRenderNode buffer is not available, set black");
|
||||
canvas_->clear(SK_ColorBLACK);
|
||||
} else {
|
||||
RS_LOGI("RSUniRenderVisitor::ProcessSurfaceRenderNode draw buffer on canvas");
|
||||
DrawBufferOnCanvas(node);
|
||||
}
|
||||
canvas_->restore();
|
||||
RS_TRACE_END();
|
||||
}
|
||||
} else {
|
||||
ProcessBaseRenderNode(node);
|
||||
node.SetGlobalZOrder(globalZOrder_++);
|
||||
processor_->ProcessSurface(node);
|
||||
}
|
||||
isUniRender_ = false;
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
|
||||
{
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessRootRenderNode node: %llu, child size:%u", node.GetId(),
|
||||
node.GetChildrenCount());
|
||||
if (!isUniRender_ || !node.GetRenderProperties().GetVisible() || !IsChildOfSurfaceNode(node)) {
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessRootRenderNode, no need process");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canvas_) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessRootRenderNode, canvas is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
canvas_->save();
|
||||
ProcessCanvasRenderNode(node);
|
||||
canvas_->restore();
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::ProcessCanvasRenderNode(RSCanvasRenderNode& node)
|
||||
{
|
||||
if (!node.GetRenderProperties().GetVisible()) {
|
||||
RS_LOGD("RSUniRenderVisitor::ProcessCanvasRenderNode, no need process");
|
||||
return;
|
||||
}
|
||||
if (!canvas_) {
|
||||
RS_LOGE("RSUniRenderVisitor::ProcessCanvasRenderNode, canvas is nullptr");
|
||||
return;
|
||||
}
|
||||
node.ProcessRenderBeforeChildren(*canvas_);
|
||||
ProcessBaseRenderNode(node);
|
||||
node.ProcessRenderAfterChildren(*canvas_);
|
||||
}
|
||||
|
||||
bool RSUniRenderVisitor::IsChildOfDisplayNode(RSBaseRenderNode& node)
|
||||
{
|
||||
auto parent = node.GetParent().lock();
|
||||
return parent && parent->IsInstanceOf<RSDisplayRenderNode>();
|
||||
}
|
||||
|
||||
bool RSUniRenderVisitor::IsChildOfSurfaceNode(RSBaseRenderNode& node)
|
||||
{
|
||||
auto parent = node.GetParent().lock();
|
||||
return parent && parent->IsInstanceOf<RSSurfaceRenderNode>();
|
||||
}
|
||||
|
||||
void RSUniRenderVisitor::DrawBufferOnCanvas(RSSurfaceRenderNode& node)
|
||||
{
|
||||
if (!canvas_) {
|
||||
RS_LOGE("RSUniRenderVisitor::DrawBufferOnCanvas canvas is nullptr");
|
||||
}
|
||||
|
||||
bool bitmapCreated = false;
|
||||
SkBitmap bitmap;
|
||||
std::vector<uint8_t> newTmpBuffer;
|
||||
auto buffer = node.GetBuffer();
|
||||
if (buffer->GetFormat() == PIXEL_FMT_YCRCB_420_SP || buffer->GetFormat() == PIXEL_FMT_YCBCR_420_SP) {
|
||||
bitmapCreated = RsRenderServiceUtil::CreateYuvToRGBABitMap(buffer, newTmpBuffer, bitmap);
|
||||
} else {
|
||||
SkColorType colorType = (buffer->GetFormat() == PIXEL_FMT_BGRA_8888) ?
|
||||
kBGRA_8888_SkColorType : kRGBA_8888_SkColorType;
|
||||
SkImageInfo imageInfo = SkImageInfo::Make(buffer->GetWidth(), buffer->GetHeight(),
|
||||
colorType, kPremul_SkAlphaType);
|
||||
auto pixmap = SkPixmap(imageInfo, buffer->GetVirAddr(), buffer->GetStride());
|
||||
bitmapCreated = bitmap.installPixels(pixmap);
|
||||
}
|
||||
if (!bitmapCreated) {
|
||||
RS_LOGE("RSUniRenderVisitor::DrawBufferOnCanvas installPixels failed");
|
||||
return;
|
||||
}
|
||||
|
||||
SkPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
paint.setAlphaf(node.GetAlpha() * node.GetRenderProperties().GetAlpha());
|
||||
|
||||
canvas_->save();
|
||||
const RSProperties& property = node.GetRenderProperties();
|
||||
auto filter = std::static_pointer_cast<RSSkiaFilter>(property.GetBackgroundFilter());
|
||||
if (filter != nullptr) {
|
||||
auto skRectPtr = std::make_unique<SkRect>();
|
||||
skRectPtr->setXYWH(node.GetRenderProperties().GetBoundsPositionX(),
|
||||
node.GetRenderProperties().GetBoundsPositionY(),
|
||||
node.GetRenderProperties().GetBoundsWidth(), node.GetRenderProperties().GetBoundsHeight());
|
||||
RSPropertiesPainter::SaveLayerForFilter(property, *canvas_, filter, skRectPtr);
|
||||
RSPropertiesPainter::RestoreForFilter(*canvas_);
|
||||
}
|
||||
canvas_->drawBitmapRect(bitmap,
|
||||
SkRect::MakeXYWH(0, 0, buffer->GetSurfaceBufferWidth(), buffer->GetSurfaceBufferHeight()),
|
||||
SkRect::MakeXYWH(node.GetRenderProperties().GetBoundsPositionX(),
|
||||
node.GetRenderProperties().GetBoundsPositionY(),
|
||||
node.GetRenderProperties().GetBoundsWidth(), node.GetRenderProperties().GetBoundsHeight()), &paint);
|
||||
canvas_->restore();
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 RENDER_SERVICE_CORE_PIPELINE_RS_UNI_RENDER_VISITOR_H
|
||||
#define RENDER_SERVICE_CORE_PIPELINE_RS_UNI_RENDER_VISITOR_H
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "pipeline/rs_processor.h"
|
||||
#include "pipeline/rs_dirty_region_manager.h"
|
||||
#include "pipeline/rs_paint_filter_canvas.h"
|
||||
#include "screen_manager/rs_screen_manager.h"
|
||||
#include "visitor/rs_node_visitor.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSUniRenderVisitor : public RSNodeVisitor {
|
||||
public:
|
||||
RSUniRenderVisitor();
|
||||
~RSUniRenderVisitor() override;
|
||||
|
||||
void PrepareBaseRenderNode(RSBaseRenderNode& node) override;
|
||||
void PrepareDisplayRenderNode(RSDisplayRenderNode& node) override;
|
||||
void PrepareSurfaceRenderNode(RSSurfaceRenderNode& node) override;
|
||||
void PrepareRootRenderNode(RSRootRenderNode& node) override;
|
||||
void PrepareCanvasRenderNode(RSCanvasRenderNode& node) override;
|
||||
|
||||
void ProcessBaseRenderNode(RSBaseRenderNode& node) override;
|
||||
void ProcessDisplayRenderNode(RSDisplayRenderNode& node) override;
|
||||
void ProcessSurfaceRenderNode(RSSurfaceRenderNode& node) override;
|
||||
void ProcessRootRenderNode(RSRootRenderNode& node) override;
|
||||
void ProcessCanvasRenderNode(RSCanvasRenderNode& node) override;
|
||||
|
||||
private:
|
||||
void DrawBufferOnCanvas(RSSurfaceRenderNode& node);
|
||||
static bool IsChildOfDisplayNode(RSBaseRenderNode& node);
|
||||
static bool IsChildOfSurfaceNode(RSBaseRenderNode& node);
|
||||
|
||||
ScreenInfo screenInfo_;
|
||||
RSDirtyRegionManager dirtyManager_;
|
||||
RSRenderNode* parent_ = nullptr;
|
||||
bool dirtyFlag_ { false };
|
||||
RSPaintFilterCanvas* canvas_ = nullptr;
|
||||
|
||||
float globalZOrder_ { 0.0f };
|
||||
float uniZOrder_ { 0.0f };
|
||||
std::shared_ptr<RSProcessor> processor_;
|
||||
bool isUniRender_ { false };
|
||||
bool hasUniRender_ { false };
|
||||
bool isUniRenderForAll_ { false };
|
||||
std::set<std::string> uniRenderList_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RENDER_SERVICE_CORE_PIPELINE_RS_UNI_RENDER_VISITOR_H
|
@ -17,17 +17,24 @@
|
||||
#include "ivsync_connection.h"
|
||||
|
||||
#include "command/rs_command_factory.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "rs_trace.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
int RSRenderServiceConnectionStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
|
||||
{
|
||||
RS_ASYNC_TRACE_END("RSProxySendRequest", data.GetDataSize());
|
||||
int ret = ERR_NONE;
|
||||
switch (code) {
|
||||
case COMMIT_TRANSACTION: {
|
||||
auto token = data.ReadInterfaceToken();
|
||||
|
||||
RS_TRACE_BEGIN("UnMarsh RSTransactionData: data size:" + std::to_string(data.GetDataSize()));
|
||||
auto transactionData = data.ReadParcelable<RSTransactionData>();
|
||||
RS_TRACE_END();
|
||||
|
||||
std::unique_ptr<RSTransactionData> transData(transactionData);
|
||||
CommitTransaction(transData);
|
||||
break;
|
||||
|
@ -95,6 +95,7 @@ ohos_shared_library("librender_service_base") {
|
||||
"src/pipeline/rs_render_node.cpp",
|
||||
"src/pipeline/rs_render_node_map.cpp",
|
||||
"src/pipeline/rs_root_render_node.cpp",
|
||||
"src/pipeline/rs_surface_handler.cpp",
|
||||
"src/pipeline/rs_surface_render_node.cpp",
|
||||
|
||||
#property
|
||||
@ -125,6 +126,11 @@ ohos_shared_library("librender_service_base") {
|
||||
"src/screen_manager/rs_screen_props.cpp",
|
||||
]
|
||||
|
||||
include_dirs =
|
||||
[ "//foundation/graphic/graphic/rosen/modules/render_service_base/src" ]
|
||||
|
||||
deps = [ "//foundation/graphic/graphic/rosen/modules/render_service_base/src/platform:platform" ]
|
||||
|
||||
public_deps = [
|
||||
"src/platform:platform",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
|
@ -49,6 +49,20 @@ class RSCommand {
|
||||
public:
|
||||
virtual ~RSCommand() noexcept = default;
|
||||
virtual void Process(RSContext& context) = 0;
|
||||
virtual std::string PrintType() const
|
||||
{
|
||||
return "RSCommand";
|
||||
}
|
||||
|
||||
virtual uint16_t GetType() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual uint16_t GetSubType() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class RSSyncTask : public RSCommand {
|
||||
|
@ -48,6 +48,19 @@ class RSCommandTemplate<commandType, commandSubType, processFunc> : public RSCom
|
||||
public:
|
||||
RSCommandTemplate() {}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
@ -77,6 +90,19 @@ class RSCommandTemplate<commandType, commandSubType, processFunc, T1> : public R
|
||||
public:
|
||||
RSCommandTemplate(const T1& p1) : parameter1_(p1) {}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
@ -112,6 +138,19 @@ class RSCommandTemplate<commandType, commandSubType, processFunc, T1, T2> : publ
|
||||
public:
|
||||
RSCommandTemplate(const T1& p1, const T2& p2) : parameter1_(p1), parameter2_(p2) {}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
@ -153,6 +192,19 @@ class RSCommandTemplate<commandType, commandSubType, processFunc, T1, T2, T3> :
|
||||
public:
|
||||
RSCommandTemplate(const T1& p1, const T2& p2, const T3& p3) : parameter1_(p1), parameter2_(p2), parameter3_(p3) {}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
@ -203,6 +255,19 @@ public:
|
||||
: parameter1_(p1), parameter2_(p2), parameter3_(p3), parameter4_(p4)
|
||||
{}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
@ -259,6 +324,19 @@ public:
|
||||
: parameter1_(p1), parameter2_(p2), parameter3_(p3), parameter4_(p4), parameter5_(p5)
|
||||
{}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
@ -321,6 +399,19 @@ public:
|
||||
: parameter1_(p1), parameter2_(p2), parameter3_(p3), parameter4_(p4), parameter5_(p5), parameter6_(p6)
|
||||
{}
|
||||
virtual ~RSCommandTemplate() = default;
|
||||
std::string PrintType() const override
|
||||
{
|
||||
return "commandType:[" + std::to_string(commandType) + ", " + std::to_string
|
||||
(commandSubType) + "], ";
|
||||
}
|
||||
uint16_t GetType() const override
|
||||
{
|
||||
return commandType;
|
||||
}
|
||||
uint16_t GetSubType() const override
|
||||
{
|
||||
return commandSubType;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
|
@ -25,17 +25,22 @@ namespace Rosen {
|
||||
enum RSRootNodeCommandType : uint16_t {
|
||||
ROOT_NODE_CREATE,
|
||||
ROOT_NODE_ATTACH,
|
||||
ATTACH_TO_UNI_SURFACENODE,
|
||||
};
|
||||
|
||||
class RootNodeCommandHelper {
|
||||
public:
|
||||
static void Create(RSContext& context, NodeId id);
|
||||
static void AttachRSSurfaceNode(RSContext& context, NodeId id, NodeId surfaceNodeId);
|
||||
static void AttachToUniSurfaceNode(RSContext& context, NodeId id, NodeId surfaceNodeId);
|
||||
};
|
||||
|
||||
ADD_COMMAND(RSRootNodeCreate, ARG(ROOT_NODE, ROOT_NODE_CREATE, RootNodeCommandHelper::Create, NodeId))
|
||||
ADD_COMMAND(RSRootNodeAttachRSSurfaceNode,
|
||||
ARG(ROOT_NODE, ROOT_NODE_ATTACH, RootNodeCommandHelper::AttachRSSurfaceNode, NodeId, NodeId))
|
||||
// unirender
|
||||
ADD_COMMAND(RSRootNodeAttachToUniSurfaceNode,
|
||||
ARG(ROOT_NODE, ATTACH_TO_UNI_SURFACENODE, RootNodeCommandHelper::AttachToUniSurfaceNode, NodeId, NodeId))
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -16,12 +16,18 @@
|
||||
#define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_DISPLAY_RENDER_NODE_H
|
||||
|
||||
#include <memory>
|
||||
#include <surface.h>
|
||||
#include <ibuffer_consumer_listener.h>
|
||||
|
||||
#include "platform/drawing/rs_surface.h"
|
||||
#include "pipeline/rs_base_render_node.h"
|
||||
#include "pipeline/rs_surface_handler.h"
|
||||
#include "render_context/render_context.h"
|
||||
#include "sync_fence.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSDisplayRenderNode : public RSBaseRenderNode {
|
||||
class RSDisplayRenderNode : public RSBaseRenderNode, public RSSurfaceHandler {
|
||||
public:
|
||||
enum CompositeType {
|
||||
COMPATIBLE_COMPOSITE = 0,
|
||||
@ -89,6 +95,28 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
NodeId GetId() const override
|
||||
{
|
||||
return RSBaseRenderNode::GetId();
|
||||
}
|
||||
|
||||
bool CreateSurface(sptr<IBufferConsumerListener> listener);
|
||||
|
||||
std::shared_ptr<RSSurface> GetRSSurface() const
|
||||
{
|
||||
return surface_;
|
||||
}
|
||||
|
||||
sptr<IBufferConsumerListener> GetConsumerListener() const
|
||||
{
|
||||
return consumerListener_;
|
||||
}
|
||||
|
||||
bool IsSurfaceCreated() const
|
||||
{
|
||||
return surfaceCreated_;
|
||||
}
|
||||
|
||||
private:
|
||||
CompositeType compositeType_ { HARDWARE_COMPOSITE };
|
||||
uint64_t screenId_;
|
||||
@ -98,6 +126,10 @@ private:
|
||||
bool isMirroredDisplay_ = false;
|
||||
bool isSecurityDisplay_ = false;
|
||||
WeakPtr mirrorSource_;
|
||||
|
||||
std::shared_ptr<RSSurface> surface_;
|
||||
bool surfaceCreated_ { false };
|
||||
sptr<IBufferConsumerListener> consumerListener_;
|
||||
};
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -31,17 +31,72 @@
|
||||
#include "pipeline/rs_draw_cmd_list.h"
|
||||
#include "render/rs_image.h"
|
||||
#include "property/rs_properties_def.h"
|
||||
#include "transaction/rs_marshalling_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSPaintFilterCanvas;
|
||||
|
||||
enum RSOpType : uint16_t {
|
||||
OPITEM,
|
||||
OPITEM_WITH_PAINT,
|
||||
RECT_OPITEM,
|
||||
ROUND_RECT_OPITEM,
|
||||
IMAGE_WITH_PARM_OPITEM,
|
||||
DRRECT_OPITEM,
|
||||
OVAL_OPITEM,
|
||||
REGION_OPITEM,
|
||||
ARC_OPITEM,
|
||||
SAVE_OPITEM,
|
||||
RESTORE_OPITEM,
|
||||
FLUSH_OPITEM,
|
||||
MATRIX_OPITEM,
|
||||
CLIP_RECT_OPITEM,
|
||||
CLIP_RRECT_OPITEM,
|
||||
CLIP_REGION_OPITEM,
|
||||
TRANSLATE_OPITEM,
|
||||
TEXTBLOB_OPITEM,
|
||||
BITMAP_OPITEM,
|
||||
BITMAP_RECT_OPITEM,
|
||||
BITMAP_LATTICE_OPITEM, // marshalling func planning to be implemented
|
||||
BITMAP_NINE_OPITEM,
|
||||
ADAPTIVE_RRECT_OPITEM,
|
||||
CLIP_ADAPTIVE_RRECT_OPITEM,
|
||||
PATH_OPITEM,
|
||||
CLIP_PATH_OPITEM,
|
||||
PAINT_OPITEM,
|
||||
CONCAT_OPITEM,
|
||||
SAVE_LAYER_OPITEM,
|
||||
DRAWABLE_OPITEM,
|
||||
PICTURE_OPITEM,
|
||||
POINTS_OPITEM,
|
||||
VERTICES_OPITEM,
|
||||
MULTIPLY_ALPHA_OPITEM,
|
||||
SAVE_ALPHA_OPITEM,
|
||||
RESTORE_ALPHA_OPITEM,
|
||||
};
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
class OpItem : public MemObject, public Parcelable {
|
||||
#else
|
||||
class OpItem : public MemObject {
|
||||
#endif
|
||||
public:
|
||||
explicit OpItem(size_t size) : MemObject(size) {}
|
||||
virtual ~OpItem() {}
|
||||
|
||||
virtual void Draw(RSPaintFilterCanvas& canvas, const SkRect* rect) const {};
|
||||
|
||||
virtual RSOpType GetType() const
|
||||
{
|
||||
return RSOpType::OPITEM;
|
||||
}
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class OpItemWithPaint : public OpItem {
|
||||
@ -50,6 +105,11 @@ public:
|
||||
|
||||
~OpItemWithPaint() override {}
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::OPITEM_WITH_PAINT;
|
||||
}
|
||||
|
||||
protected:
|
||||
SkPaint paint_;
|
||||
};
|
||||
@ -60,6 +120,16 @@ public:
|
||||
~RectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::RECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRect rect_;
|
||||
};
|
||||
@ -70,6 +140,16 @@ public:
|
||||
~RoundRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::ROUND_RECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRRect rrect_;
|
||||
};
|
||||
@ -82,6 +162,16 @@ public:
|
||||
~ImageWithParmOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::IMAGE_WITH_PARM_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::shared_ptr<RSImage> rsImage_;
|
||||
};
|
||||
@ -92,6 +182,16 @@ public:
|
||||
~DRRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::DRRECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRRect outer_;
|
||||
SkRRect inner_;
|
||||
@ -103,6 +203,16 @@ public:
|
||||
~OvalOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::OVAL_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRect rect_;
|
||||
};
|
||||
@ -113,6 +223,16 @@ public:
|
||||
~RegionOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::REGION_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRegion region_;
|
||||
};
|
||||
@ -123,6 +243,16 @@ public:
|
||||
~ArcOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::ARC_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRect rect_;
|
||||
float startAngle_;
|
||||
@ -135,6 +265,15 @@ public:
|
||||
SaveOpItem();
|
||||
~SaveOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::SAVE_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
};
|
||||
|
||||
class RestoreOpItem : public OpItem {
|
||||
@ -142,6 +281,15 @@ public:
|
||||
RestoreOpItem();
|
||||
~RestoreOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::RESTORE_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
};
|
||||
|
||||
class FlushOpItem : public OpItem {
|
||||
@ -149,6 +297,15 @@ public:
|
||||
FlushOpItem();
|
||||
~FlushOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::FLUSH_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
};
|
||||
|
||||
class MatrixOpItem : public OpItem {
|
||||
@ -157,6 +314,16 @@ public:
|
||||
~MatrixOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::MATRIX_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkMatrix matrix_;
|
||||
};
|
||||
@ -167,6 +334,16 @@ public:
|
||||
~ClipRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::CLIP_RECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRect rect_;
|
||||
SkClipOp clipOp_;
|
||||
@ -179,6 +356,16 @@ public:
|
||||
~ClipRRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::CLIP_RRECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRRect rrect_;
|
||||
SkClipOp clipOp_;
|
||||
@ -191,6 +378,16 @@ public:
|
||||
~ClipRegionOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::CLIP_REGION_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRegion region_;
|
||||
SkClipOp clipOp_;
|
||||
@ -202,6 +399,16 @@ public:
|
||||
~TranslateOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::TRANSLATE_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
float distanceX_;
|
||||
float distanceY_;
|
||||
@ -213,6 +420,15 @@ public:
|
||||
~TextBlobOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::TEXTBLOB_OPITEM;
|
||||
}
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
sk_sp<SkTextBlob> textBlob_;
|
||||
float x_;
|
||||
@ -225,6 +441,16 @@ public:
|
||||
~BitmapOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::BITMAP_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
float left_;
|
||||
float top_;
|
||||
@ -238,6 +464,16 @@ public:
|
||||
~BitmapRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::BITMAP_RECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRect rectSrc_;
|
||||
SkRect rectDst_;
|
||||
@ -251,6 +487,11 @@ public:
|
||||
~BitmapLatticeOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::BITMAP_LATTICE_OPITEM;
|
||||
}
|
||||
|
||||
private:
|
||||
SkRect rect_;
|
||||
SkCanvas::Lattice lattice_;
|
||||
@ -264,6 +505,16 @@ public:
|
||||
~BitmapNineOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::BITMAP_NINE_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkIRect center_;
|
||||
SkRect rectDst_;
|
||||
@ -276,6 +527,16 @@ public:
|
||||
~AdaptiveRRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::ADAPTIVE_RRECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
float radius_;
|
||||
SkPaint paint_;
|
||||
@ -287,6 +548,16 @@ public:
|
||||
~ClipAdaptiveRRectOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::CLIP_ADAPTIVE_RRECT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
float radius_;
|
||||
};
|
||||
@ -297,6 +568,16 @@ public:
|
||||
~PathOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::PATH_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkPath path_;
|
||||
};
|
||||
@ -307,6 +588,16 @@ public:
|
||||
~ClipPathOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::CLIP_PATH_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkPath path_;
|
||||
SkClipOp clipOp_;
|
||||
@ -318,6 +609,16 @@ public:
|
||||
PaintOpItem(const SkPaint& paint);
|
||||
~PaintOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::PAINT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
};
|
||||
|
||||
class ConcatOpItem : public OpItem {
|
||||
@ -326,6 +627,16 @@ public:
|
||||
~ConcatOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::CONCAT_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkMatrix matrix_;
|
||||
};
|
||||
@ -336,6 +647,16 @@ public:
|
||||
~SaveLayerOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::SAVE_LAYER_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkRect* rectPtr_ = nullptr;
|
||||
SkRect rect_ = SkRect::MakeEmpty();
|
||||
@ -351,6 +672,16 @@ public:
|
||||
~DrawableOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::DRAWABLE_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
sk_sp<SkDrawable> drawable_;
|
||||
SkMatrix matrix_ = SkMatrix::I();
|
||||
@ -362,6 +693,16 @@ public:
|
||||
~PictureOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::PICTURE_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
sk_sp<SkPicture> picture_ { nullptr };
|
||||
SkMatrix matrix_;
|
||||
@ -376,6 +717,16 @@ public:
|
||||
}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::POINTS_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SkCanvas::PointMode mode_;
|
||||
int count_;
|
||||
@ -389,6 +740,16 @@ public:
|
||||
~VerticesOpItem() override;
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::VERTICES_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
sk_sp<SkVertices> vertices_;
|
||||
SkVertices::Bone* bones_;
|
||||
@ -402,6 +763,16 @@ public:
|
||||
~MultiplyAlphaOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::MULTIPLY_ALPHA_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
float alpha_;
|
||||
};
|
||||
@ -411,6 +782,15 @@ public:
|
||||
SaveAlphaOpItem();
|
||||
~SaveAlphaOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::SAVE_ALPHA_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
};
|
||||
|
||||
class RestoreAlphaOpItem : public OpItem {
|
||||
@ -418,6 +798,15 @@ public:
|
||||
RestoreAlphaOpItem();
|
||||
~RestoreAlphaOpItem() override {}
|
||||
void Draw(RSPaintFilterCanvas& canvas, const SkRect*) const override;
|
||||
|
||||
RSOpType GetType() const override
|
||||
{
|
||||
return RSOpType::RESTORE_ALPHA_OPITEM;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
static OpItem* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include <vector>
|
||||
|
||||
#include "common/rs_common_def.h"
|
||||
#ifdef ROSEN_OHOS
|
||||
#include <parcel.h>
|
||||
#endif
|
||||
|
||||
class SkCanvas;
|
||||
struct SkRect;
|
||||
@ -29,7 +32,11 @@ namespace Rosen {
|
||||
class OpItem;
|
||||
class RSPaintFilterCanvas;
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
class DrawCmdList : public Parcelable {
|
||||
#else
|
||||
class DrawCmdList {
|
||||
#endif
|
||||
public:
|
||||
DrawCmdList(int w, int h);
|
||||
DrawCmdList& operator=(DrawCmdList&& that);
|
||||
@ -45,6 +52,11 @@ public:
|
||||
int GetWidth() const;
|
||||
int GetHeight() const;
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const override;
|
||||
static DrawCmdList* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<OpItem>> ops_;
|
||||
std::recursive_mutex mutex_;
|
||||
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SURFACE_HANDLER_H
|
||||
#define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SURFACE_HANDLER_H
|
||||
|
||||
#include <surface.h>
|
||||
|
||||
#include "common/rs_common_def.h"
|
||||
#include "sync_fence.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSSurfaceHandler {
|
||||
public:
|
||||
RSSurfaceHandler() = default;
|
||||
virtual ~RSSurfaceHandler() = default;
|
||||
virtual NodeId GetId() const = 0;
|
||||
void SetConsumer(const sptr<Surface>& consumer);
|
||||
void SetBuffer(const sptr<SurfaceBuffer>& buffer);
|
||||
void SetFence(sptr<SyncFence> fence);
|
||||
void SetDamageRegion(const Rect& damage);
|
||||
void IncreaseAvailableBuffer();
|
||||
int32_t ReduceAvailableBuffer();
|
||||
|
||||
sptr<SurfaceBuffer>& GetBuffer()
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
sptr<SyncFence> GetFence() const
|
||||
{
|
||||
return fence_;
|
||||
}
|
||||
|
||||
sptr<SurfaceBuffer>& GetPreBuffer()
|
||||
{
|
||||
return preBuffer_;
|
||||
}
|
||||
|
||||
sptr<SyncFence> GetPreFence() const
|
||||
{
|
||||
return preFence_;
|
||||
}
|
||||
|
||||
const Rect& GetDamageRegion() const
|
||||
{
|
||||
return damageRect_;
|
||||
}
|
||||
|
||||
const sptr<Surface>& GetConsumer() const
|
||||
{
|
||||
return consumer_;
|
||||
}
|
||||
|
||||
int32_t GetAvailableBufferCount() const
|
||||
{
|
||||
return bufferAvailableCount_;
|
||||
}
|
||||
|
||||
void SetGlobalZOrder(float globalZOrder);
|
||||
float GetGlobalZOrder() const;
|
||||
|
||||
protected:
|
||||
sptr<Surface> consumer_;
|
||||
|
||||
private:
|
||||
Rect damageRect_;
|
||||
float globalZOrder_ = 0.0f;
|
||||
std::atomic<int> bufferAvailableCount_ = 0;
|
||||
sptr<SurfaceBuffer> buffer_;
|
||||
sptr<SurfaceBuffer> preBuffer_;
|
||||
sptr<SyncFence> fence_;
|
||||
sptr<SyncFence> preFence_;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_SURFACE_HANDLER_H
|
@ -25,13 +25,14 @@
|
||||
#include "pipeline/rs_paint_filter_canvas.h"
|
||||
#include "property/rs_properties_painter.h"
|
||||
#include "include/core/SkRect.h"
|
||||
#include "pipeline/rs_surface_handler.h"
|
||||
#include "refbase.h"
|
||||
#include "sync_fence.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RSCommand;
|
||||
class RSSurfaceRenderNode : public RSRenderNode {
|
||||
class RSSurfaceRenderNode : public RSRenderNode, public RSSurfaceHandler {
|
||||
public:
|
||||
using WeakPtr = std::weak_ptr<RSSurfaceRenderNode>;
|
||||
using SharedPtr = std::shared_ptr<RSSurfaceRenderNode>;
|
||||
@ -41,50 +42,9 @@ public:
|
||||
explicit RSSurfaceRenderNode(const RSSurfaceRenderNodeConfig& config, std::weak_ptr<RSContext> context = {});
|
||||
virtual ~RSSurfaceRenderNode();
|
||||
|
||||
void SetConsumer(const sptr<Surface>& consumer);
|
||||
void SetBuffer(const sptr<SurfaceBuffer>& buffer);
|
||||
void SetFence(sptr<SyncFence> fence);
|
||||
void SetDamageRegion(const Rect& damage);
|
||||
void IncreaseAvailableBuffer();
|
||||
int32_t ReduceAvailableBuffer();
|
||||
void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override;
|
||||
void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override;
|
||||
|
||||
sptr<SurfaceBuffer>& GetBuffer()
|
||||
{
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
sptr<SyncFence> GetFence() const
|
||||
{
|
||||
return fence_;
|
||||
}
|
||||
|
||||
sptr<SurfaceBuffer>& GetPreBuffer()
|
||||
{
|
||||
return preBuffer_;
|
||||
}
|
||||
|
||||
sptr<SyncFence> GetPreFence() const
|
||||
{
|
||||
return preFence_;
|
||||
}
|
||||
|
||||
const Rect& GetDamageRegion() const
|
||||
{
|
||||
return damageRect_;
|
||||
}
|
||||
|
||||
const sptr<Surface>& GetConsumer() const
|
||||
{
|
||||
return consumer_;
|
||||
}
|
||||
|
||||
int32_t GetAvailableBufferCount() const
|
||||
{
|
||||
return bufferAvailableCount_;
|
||||
}
|
||||
|
||||
std::string GetName() const
|
||||
{
|
||||
return name_;
|
||||
@ -172,9 +132,10 @@ public:
|
||||
return globalAlpha_;
|
||||
}
|
||||
|
||||
// Only use in Render Service
|
||||
void SetGlobalZOrder(float globalZOrder);
|
||||
float GetGlobalZOrder() const;
|
||||
NodeId GetId() const override
|
||||
{
|
||||
return RSBaseRenderNode::GetId();
|
||||
}
|
||||
|
||||
void SetParentId(NodeId parentId, bool sendMsg = true);
|
||||
NodeId GetParentId() const;
|
||||
@ -209,20 +170,12 @@ public:
|
||||
private:
|
||||
RectI CalculateClipRegion(RSPaintFilterCanvas& canvas);
|
||||
friend class RSRenderTransition;
|
||||
sptr<Surface> consumer_;
|
||||
|
||||
std::mutex mutex_;
|
||||
std::atomic<int> bufferAvailableCount_ = 0;
|
||||
SkMatrix matrix_;
|
||||
float alpha_ = 1.0f;
|
||||
float globalZOrder_ = 0.0f;
|
||||
bool isSecurityLayer_ = false;
|
||||
NodeId parentId_ = 0;
|
||||
sptr<SurfaceBuffer> buffer_;
|
||||
sptr<SurfaceBuffer> preBuffer_;
|
||||
sptr<SyncFence> fence_;
|
||||
sptr<SyncFence> preFence_;
|
||||
Rect damageRect_ = {0, 0, 0, 0};
|
||||
RectI dstRect_;
|
||||
int32_t offsetX_ = 0;
|
||||
int32_t offsetY_ = 0;
|
||||
|
@ -16,19 +16,29 @@
|
||||
#ifndef RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H
|
||||
#define RENDER_SERVICE_BASE_COMMON_RS_COMMON_DEF_H
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
enum class UniRenderEnabledType {
|
||||
UNI_RENDER_DISABLED = 0,
|
||||
UNI_RENDER_ENABLED_FOR_ALL,
|
||||
UNI_RENDER_PARTIALLY_ENABLED,
|
||||
};
|
||||
|
||||
class RSSystemProperties final {
|
||||
public:
|
||||
~RSSystemProperties() = default;
|
||||
|
||||
static bool GetUniRenderEnabled();
|
||||
static UniRenderEnabledType GetUniRenderEnabledType();
|
||||
static const std::set<std::string>& GetUniRenderEnabledList();
|
||||
|
||||
private:
|
||||
RSSystemProperties() = default;
|
||||
|
||||
static bool isUniRenderEnabled_;
|
||||
static inline UniRenderEnabledType uniRenderEnabledType_ = UniRenderEnabledType::UNI_RENDER_DISABLED;
|
||||
static inline std::set<std::string> uniRenderEnabledList_ { "clock0" };
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "include/core/SkCanvas.h"
|
||||
#include "include/core/SkColorFilter.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "transaction/rs_marshalling_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -53,6 +54,10 @@ public:
|
||||
void SetImageRepeat(int repeatNum);
|
||||
void SetRadius(float radius);
|
||||
void SetScale(double scale);
|
||||
#ifdef ROSEN_OHOS
|
||||
bool Marshalling(Parcel& parcel) const;
|
||||
static RSImage* Unmarshalling(Parcel& parcel);
|
||||
#endif
|
||||
|
||||
private:
|
||||
void ApplyImageFit();
|
||||
|
@ -26,12 +26,23 @@
|
||||
template<typename T>
|
||||
class sk_sp;
|
||||
class SkData;
|
||||
class SkDrawable;
|
||||
class SkFlattenable;
|
||||
class SkImage;
|
||||
class SkImageFilter;
|
||||
class SkPaint;
|
||||
class SkPath;
|
||||
class SkPicture;
|
||||
class SkRegion;
|
||||
class SkTextBlob;
|
||||
class SkVertices;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DrawCmdList;
|
||||
class RSFilter;
|
||||
class RSImage;
|
||||
class RSMask;
|
||||
class RSPath;
|
||||
class RSShader;
|
||||
template<typename T>
|
||||
@ -44,6 +55,9 @@ class RSRenderTransitionEffect;
|
||||
|
||||
class RSMarshallingHelper {
|
||||
public:
|
||||
static bool WriteToParcel(Parcel &parcel, const void* data, size_t size);
|
||||
static const void* ReadFromParcel(Parcel& parcel, size_t size);
|
||||
|
||||
// default marshalling and unmarshalling method for POD types
|
||||
// [PLANNING]: implement marshalling & unmarshalling methods for other types (e.g. RSImage, drawCMDList)
|
||||
template<typename T>
|
||||
@ -61,6 +75,21 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static bool Marshalling(Parcel& parcel, const T* val, int count)
|
||||
{
|
||||
return parcel.WriteUnpadBuffer(val, count * sizeof(T));
|
||||
}
|
||||
template<typename T>
|
||||
static bool Unmarshalling(Parcel& parcel, T*& val, int count)
|
||||
{
|
||||
if (const uint8_t* buff = parcel.ReadUnpadBuffer(count * sizeof(T))) {
|
||||
val = reinterpret_cast<const T*>(buff);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// reloaded marshalling & unmarshalling function for types
|
||||
#define DECLARE_FUNCTION_OVERLOAD(TYPE) \
|
||||
static bool Marshalling(Parcel& parcel, const TYPE& val); \
|
||||
@ -79,12 +108,24 @@ public:
|
||||
DECLARE_FUNCTION_OVERLOAD(float)
|
||||
DECLARE_FUNCTION_OVERLOAD(double)
|
||||
// skia types
|
||||
DECLARE_FUNCTION_OVERLOAD(SkPath)
|
||||
DECLARE_FUNCTION_OVERLOAD(SkPaint)
|
||||
DECLARE_FUNCTION_OVERLOAD(SkRegion)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkData>)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkFlattenable>)
|
||||
DECLARE_FUNCTION_OVERLOAD(SkPath)
|
||||
DECLARE_FUNCTION_OVERLOAD(RSShader)
|
||||
DECLARE_FUNCTION_OVERLOAD(RSPath)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkTextBlob>)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkPicture>)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkDrawable>)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkImageFilter>)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkImage>)
|
||||
DECLARE_FUNCTION_OVERLOAD(sk_sp<SkVertices>)
|
||||
// RS types
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSShader>)
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSPath>)
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSFilter>)
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSMask>)
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSImage>)
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<DrawCmdList>)
|
||||
// animation
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSRenderPathAnimation>)
|
||||
DECLARE_FUNCTION_OVERLOAD(std::shared_ptr<RSRenderTransition>)
|
||||
@ -107,6 +148,11 @@ public:
|
||||
static bool Marshalling(Parcel& parcel, const std::vector<T>& val);
|
||||
template<typename T>
|
||||
static bool Unmarshalling(Parcel& parcel, std::vector<T>& val);
|
||||
private:
|
||||
static void ReleaseMemory(void* data, int* fd, size_t size);
|
||||
inline static std::atomic<uint32_t> shmemCount = 0;
|
||||
static constexpr size_t MAX_DATA_SIZE = 128 * 1024 * 1024; // 128M
|
||||
static constexpr size_t MIN_DATA_SIZE = 8 * 1024; // 8k
|
||||
};
|
||||
|
||||
} // namespace Rosen
|
||||
|
@ -63,7 +63,7 @@ UnmarshallingFunc RSCommandFactory::GetUnmarshallingFunc(uint16_t type, uint16_t
|
||||
{
|
||||
auto it = unmarshallingFuncLUT_.find(MakeKey(type, subtype));
|
||||
if (it == unmarshallingFuncLUT_.end()) {
|
||||
ROSEN_LOGE("RSCommandFactory::GetUnmarshallingFunc, Func is not found");
|
||||
ROSEN_LOGE("RSCommandFactory::GetUnmarshallingFunc, Func is not found, type=%d subtype=%d", type, subtype);
|
||||
return nullptr;
|
||||
}
|
||||
return it->second;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "pipeline/rs_root_render_node.h"
|
||||
#include "pipeline/rs_surface_render_node.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -35,5 +36,21 @@ void RootNodeCommandHelper::AttachRSSurfaceNode(RSContext& context, NodeId id, N
|
||||
}
|
||||
}
|
||||
|
||||
void RootNodeCommandHelper::AttachToUniSurfaceNode(RSContext& context, NodeId id, NodeId surfaceNodeId)
|
||||
{
|
||||
auto& nodeMap = context.GetNodeMap();
|
||||
auto parent = nodeMap.GetRenderNode<RSSurfaceRenderNode>(surfaceNodeId);
|
||||
auto node = nodeMap.GetRenderNode<RSRootRenderNode>(id);
|
||||
if (!parent) {
|
||||
RS_LOGE("unirender: RootNodeCommandHelper::AddToSurfaceNode no parent surfaceNode");
|
||||
}
|
||||
if (!node) {
|
||||
RS_LOGE("unirender: RootNodeCommandHelper::AddToSurfaceNode no RootRenderNode");
|
||||
}
|
||||
if (node && parent) {
|
||||
parent->AddChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "pipeline/rs_display_render_node.h"
|
||||
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/ohos/backend/rs_surface_ohos_gl.h"
|
||||
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
|
||||
#include "visitor/rs_node_visitor.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -86,5 +88,37 @@ bool RSDisplayRenderNode::GetSecurityDisplay() const
|
||||
return isSecurityDisplay_;
|
||||
}
|
||||
|
||||
bool RSDisplayRenderNode::CreateSurface(sptr<IBufferConsumerListener> listener)
|
||||
{
|
||||
if (consumer_ != nullptr && surface_ != nullptr) {
|
||||
RS_LOGI("RSDisplayRenderNode::CreateSurface already created, return");
|
||||
return true;
|
||||
}
|
||||
consumer_ = Surface::CreateSurfaceAsConsumer("DisplayNode");
|
||||
if (consumer_ == nullptr) {
|
||||
RS_LOGE("RSDisplayRenderNode::CreateSurface get consumer surface fail");
|
||||
return false;
|
||||
}
|
||||
SurfaceError ret = consumer_->RegisterConsumerListener(listener);
|
||||
if (ret != SURFACE_ERROR_OK) {
|
||||
RS_LOGE("RSDisplayRenderNode::CreateSurface RegisterConsumerListener fail");
|
||||
return false;
|
||||
}
|
||||
consumerListener_ = listener;
|
||||
auto producer = consumer_->GetProducer();
|
||||
sptr<Surface> surface = Surface::CreateSurfaceAsProducer(producer);
|
||||
|
||||
#ifdef ACE_ENABLE_GL
|
||||
// GPU render
|
||||
surface_ = std::make_shared<RSSurfaceOhosGl>(surface);
|
||||
#else
|
||||
// CPU render
|
||||
surface_ = std::make_shared<RSSurfaceOhosRaster>(surface);
|
||||
#endif
|
||||
|
||||
RS_LOGI("RSDisplayRenderNode::CreateSurface end");
|
||||
surfaceCreated_ = true;
|
||||
return true;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -446,5 +446,788 @@ void RestoreAlphaOpItem::Draw(RSPaintFilterCanvas& canvas, const SkRect*) const
|
||||
{
|
||||
canvas.RestoreAlpha();
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
|
||||
// RectOpItem
|
||||
bool RectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* RectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRect rect;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new RectOpItem(rect, paint);
|
||||
}
|
||||
|
||||
// RoundRectOpItem
|
||||
bool RoundRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rrect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* RoundRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRRect rrect;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rrect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new RoundRectOpItem(rrect, paint);
|
||||
}
|
||||
|
||||
// ImageWithParmOpItem
|
||||
bool ImageWithParmOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= rsImage_->Marshalling(parcel);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ImageWithParmOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkImage> img;
|
||||
int fitNum;
|
||||
int repeatNum;
|
||||
float radius;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, img)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, fitNum)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, repeatNum)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, radius)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new ImageWithParmOpItem(img, fitNum, repeatNum, radius, paint);
|
||||
}
|
||||
|
||||
// DRRectOpItem
|
||||
bool DRRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, outer_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, inner_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* DRRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRRect outer;
|
||||
SkRRect inner;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, outer)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, inner)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new DRRectOpItem(outer, inner, paint);
|
||||
}
|
||||
|
||||
// OvalOpItem
|
||||
bool OvalOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* OvalOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRect rect;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new OvalOpItem(rect, paint);
|
||||
}
|
||||
|
||||
// RegionOpItem
|
||||
bool RegionOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, region_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* RegionOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRegion region;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, region)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new RegionOpItem(region, paint);
|
||||
}
|
||||
|
||||
// ArcOpItem
|
||||
bool ArcOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, startAngle_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, sweepAngle_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, useCenter_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ArcOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRect rect;
|
||||
float startAngle;
|
||||
float sweepAngle;
|
||||
bool useCenter;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, startAngle)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, sweepAngle)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, useCenter)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new ArcOpItem(rect, startAngle, sweepAngle, useCenter, paint);
|
||||
}
|
||||
|
||||
// SaveOpItem
|
||||
OpItem* SaveOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
return new SaveOpItem();
|
||||
}
|
||||
|
||||
// RestoreOpItem
|
||||
OpItem* RestoreOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
return new RestoreOpItem();
|
||||
}
|
||||
|
||||
// FlushOpItem
|
||||
OpItem* FlushOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
return new FlushOpItem();
|
||||
}
|
||||
|
||||
// MatrixOpItem
|
||||
bool MatrixOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, matrix_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* MatrixOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkMatrix matrix;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, matrix)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new MatrixOpItem(matrix);
|
||||
}
|
||||
|
||||
// ClipRectOpItem
|
||||
bool ClipRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, clipOp_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, doAA_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ClipRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRect rect;
|
||||
SkClipOp clipOp;
|
||||
bool doAA;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, clipOp)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, doAA)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new ClipRectOpItem(rect, clipOp, doAA);
|
||||
}
|
||||
|
||||
// ClipRRectOpItem
|
||||
bool ClipRRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rrect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, clipOp_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, doAA_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ClipRRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRRect rrect;
|
||||
SkClipOp clipOp;
|
||||
bool doAA;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rrect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, clipOp)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, doAA)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new ClipRRectOpItem(rrect, clipOp, doAA);
|
||||
}
|
||||
|
||||
// ClipRegionOpItem
|
||||
bool ClipRegionOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, region_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, clipOp_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ClipRegionOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRegion region;
|
||||
SkClipOp clipOp;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, region)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, clipOp)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new ClipRegionOpItem(region, clipOp);
|
||||
}
|
||||
|
||||
// TranslateOpItem
|
||||
bool TranslateOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, distanceX_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, distanceY_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* TranslateOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
float distanceX;
|
||||
float distanceY;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, distanceX)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, distanceY)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new TranslateOpItem(distanceX, distanceY);
|
||||
}
|
||||
|
||||
// TextBlobOpItem
|
||||
bool TextBlobOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, textBlob_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, x_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, y_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* TextBlobOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkTextBlob> textBlob;
|
||||
float x;
|
||||
float y;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, textBlob)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, x)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, y)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new TextBlobOpItem(textBlob, x, y, paint);
|
||||
}
|
||||
|
||||
// BitmapOpItem
|
||||
bool BitmapOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, bitmapInfo_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, left_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, top_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* BitmapOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkImage> bitmapInfo;
|
||||
float left;
|
||||
float top;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, bitmapInfo)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, left)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, top)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new BitmapOpItem(bitmapInfo, left, top, &paint);
|
||||
}
|
||||
|
||||
// BitmapRectOpItem
|
||||
bool BitmapRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, bitmapInfo_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rectSrc_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rectDst_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* BitmapRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkImage> bitmapInfo;
|
||||
SkRect rectSrc;
|
||||
SkRect rectDst;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, bitmapInfo)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rectSrc)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rectDst)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new BitmapRectOpItem(bitmapInfo, &rectSrc, rectDst, &paint);
|
||||
}
|
||||
|
||||
// BitmapNineOpItem
|
||||
bool BitmapNineOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, bitmapInfo_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, center_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rectDst_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* BitmapNineOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkImage> bitmapInfo;
|
||||
SkIRect center;
|
||||
SkRect rectDst;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, bitmapInfo)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, center)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rectDst)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new BitmapNineOpItem(bitmapInfo, center, rectDst, &paint);
|
||||
}
|
||||
|
||||
// AdaptiveRRectOpItem
|
||||
bool AdaptiveRRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, radius_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* AdaptiveRRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
float radius;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, radius)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new AdaptiveRRectOpItem(radius, paint);
|
||||
}
|
||||
|
||||
// ClipAdaptiveRRectOpItem
|
||||
bool ClipAdaptiveRRectOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, radius_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ClipAdaptiveRRectOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
float radius;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, radius)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new ClipAdaptiveRRectOpItem(radius);
|
||||
}
|
||||
|
||||
// PathOpItem
|
||||
bool PathOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, path_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* PathOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkPath path;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, path)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new PathOpItem(path, paint);
|
||||
}
|
||||
|
||||
// ClipPathOpItem
|
||||
bool ClipPathOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, path_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, clipOp_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, doAA_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ClipPathOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkPath path;
|
||||
SkClipOp clipOp;
|
||||
bool doAA;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, path)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, clipOp)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, doAA)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new ClipPathOpItem(path, clipOp, doAA);
|
||||
}
|
||||
|
||||
// PaintOpItem
|
||||
bool PaintOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* PaintOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new PaintOpItem(paint);
|
||||
}
|
||||
|
||||
// ConcatOpItem
|
||||
bool ConcatOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, matrix_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* ConcatOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkMatrix matrix;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, matrix)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new ConcatOpItem(matrix);
|
||||
}
|
||||
|
||||
// SaveLayerOpItem
|
||||
bool SaveLayerOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, rect_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, backdrop_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, mask_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, matrix_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, flags_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* SaveLayerOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkRect rect;
|
||||
sk_sp<SkImageFilter> backdrop;
|
||||
sk_sp<SkImage> mask;
|
||||
SkMatrix matrix;
|
||||
SkCanvas::SaveLayerFlags flags;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, rect)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, backdrop)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, mask)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, matrix)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, flags)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
SkCanvas::SaveLayerRec rec = { &rect, &paint, backdrop.get(), mask.get(), &matrix, flags };
|
||||
|
||||
return new SaveLayerOpItem(rec);
|
||||
}
|
||||
|
||||
// DrawableOpItem
|
||||
bool DrawableOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, drawable_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, matrix_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* DrawableOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkDrawable> drawable;
|
||||
SkMatrix matrix;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, drawable)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, matrix)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new DrawableOpItem(drawable.release(), &matrix);
|
||||
}
|
||||
|
||||
// PictureOpItem
|
||||
bool PictureOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, picture_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, matrix_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* PictureOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkPicture> picture;
|
||||
SkMatrix matrix;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, picture)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, matrix)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new PictureOpItem(picture, &matrix, &paint);
|
||||
}
|
||||
|
||||
// PointsOpItem
|
||||
bool PointsOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, mode_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, count_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, processedPoints_, count_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* PointsOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
SkCanvas::PointMode mode;
|
||||
int count;
|
||||
const SkPoint* processedPoints = nullptr;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, count)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, processedPoints, count)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new PointsOpItem(mode, count, processedPoints, paint);
|
||||
}
|
||||
|
||||
// VerticesOpItem
|
||||
bool VerticesOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, vertices_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, boneCount_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, bones_, boneCount_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, mode_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, paint_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* VerticesOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkVertices> vertices;
|
||||
const SkVertices::Bone* bones = nullptr;
|
||||
int boneCount;
|
||||
SkBlendMode mode;
|
||||
SkPaint paint;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, vertices)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, boneCount)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, bones, boneCount)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, paint)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new VerticesOpItem(vertices.get(), bones, boneCount, mode, paint);
|
||||
}
|
||||
|
||||
// MultiplyAlphaOpItem
|
||||
bool MultiplyAlphaOpItem::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, alpha_);
|
||||
return success;
|
||||
}
|
||||
|
||||
OpItem* MultiplyAlphaOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
float alpha;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, alpha)) {
|
||||
return nullptr;
|
||||
}
|
||||
return new MultiplyAlphaOpItem(alpha);
|
||||
}
|
||||
|
||||
// SaveAlphaOpItem
|
||||
OpItem* SaveAlphaOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
return new SaveAlphaOpItem();
|
||||
}
|
||||
|
||||
// RestoreAlphaOpItem
|
||||
OpItem* RestoreAlphaOpItem::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
return new RestoreAlphaOpItem();
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -15,12 +15,64 @@
|
||||
|
||||
#include "pipeline/rs_draw_cmd_list.h"
|
||||
|
||||
#include "platform/common/rs_log.h"
|
||||
#include <unordered_map>
|
||||
|
||||
#include "pipeline/rs_draw_cmd.h"
|
||||
#include "pipeline/rs_paint_filter_canvas.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "transaction/rs_marshalling_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
#ifdef ROSEN_OHOS
|
||||
using OpUnmarshallingFunc = OpItem* (*)(Parcel& parcel);
|
||||
|
||||
static std::unordered_map<RSOpType, OpUnmarshallingFunc> opUnmarshallingFuncLUT = {
|
||||
{ RECT_OPITEM, RectOpItem::Unmarshalling },
|
||||
{ ROUND_RECT_OPITEM, RoundRectOpItem::Unmarshalling },
|
||||
{ IMAGE_WITH_PARM_OPITEM, ImageWithParmOpItem::Unmarshalling },
|
||||
{ DRRECT_OPITEM, DRRectOpItem::Unmarshalling },
|
||||
{ OVAL_OPITEM, OvalOpItem::Unmarshalling },
|
||||
{ REGION_OPITEM, RegionOpItem::Unmarshalling },
|
||||
{ ARC_OPITEM, ArcOpItem::Unmarshalling },
|
||||
{ SAVE_OPITEM, SaveOpItem::Unmarshalling },
|
||||
{ RESTORE_OPITEM, RestoreOpItem::Unmarshalling },
|
||||
{ FLUSH_OPITEM, FlushOpItem::Unmarshalling },
|
||||
{ MATRIX_OPITEM, MatrixOpItem::Unmarshalling },
|
||||
{ CLIP_RECT_OPITEM, ClipRectOpItem::Unmarshalling },
|
||||
{ CLIP_RRECT_OPITEM, ClipRRectOpItem::Unmarshalling },
|
||||
{ CLIP_REGION_OPITEM, ClipRegionOpItem::Unmarshalling },
|
||||
{ TRANSLATE_OPITEM, TranslateOpItem::Unmarshalling },
|
||||
{ TEXTBLOB_OPITEM, TextBlobOpItem::Unmarshalling },
|
||||
{ BITMAP_OPITEM, BitmapOpItem::Unmarshalling },
|
||||
{ BITMAP_RECT_OPITEM, BitmapRectOpItem::Unmarshalling },
|
||||
{ BITMAP_NINE_OPITEM, BitmapNineOpItem::Unmarshalling },
|
||||
{ ADAPTIVE_RRECT_OPITEM, AdaptiveRRectOpItem::Unmarshalling },
|
||||
{ CLIP_ADAPTIVE_RRECT_OPITEM, ClipAdaptiveRRectOpItem::Unmarshalling },
|
||||
{ PATH_OPITEM, PathOpItem::Unmarshalling },
|
||||
{ CLIP_PATH_OPITEM, ClipPathOpItem::Unmarshalling },
|
||||
{ PAINT_OPITEM, PaintOpItem::Unmarshalling },
|
||||
{ CONCAT_OPITEM, ConcatOpItem::Unmarshalling },
|
||||
{ SAVE_LAYER_OPITEM, SaveLayerOpItem::Unmarshalling },
|
||||
{ DRAWABLE_OPITEM, DrawableOpItem::Unmarshalling },
|
||||
{ PICTURE_OPITEM, PictureOpItem::Unmarshalling },
|
||||
{ POINTS_OPITEM, PointsOpItem::Unmarshalling },
|
||||
{ VERTICES_OPITEM, VerticesOpItem::Unmarshalling },
|
||||
{ MULTIPLY_ALPHA_OPITEM, MultiplyAlphaOpItem::Unmarshalling },
|
||||
{ SAVE_ALPHA_OPITEM, SaveAlphaOpItem::Unmarshalling },
|
||||
{ RESTORE_ALPHA_OPITEM, RestoreAlphaOpItem::Unmarshalling },
|
||||
};
|
||||
|
||||
static OpUnmarshallingFunc GetOpUnmarshallingFunc(RSOpType type)
|
||||
{
|
||||
auto it = opUnmarshallingFuncLUT.find(type);
|
||||
if (it == opUnmarshallingFuncLUT.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
#endif
|
||||
|
||||
DrawCmdList::DrawCmdList(int w, int h) : width_(w), height_(h) {}
|
||||
|
||||
DrawCmdList::~DrawCmdList()
|
||||
@ -80,5 +132,68 @@ int DrawCmdList::GetHeight() const
|
||||
{
|
||||
return height_;
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool DrawCmdList::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, width_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, height_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, GetSize());
|
||||
ROSEN_LOGD("unirender: DrawCmdList::Marshalling start, size = %d", GetSize());
|
||||
for (const auto& item : ops_) {
|
||||
auto type = item->GetType();
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, type);
|
||||
success &= item->Marshalling(parcel);
|
||||
if (!success) {
|
||||
ROSEN_LOGE("unirender: failed opItem Marshalling, optype = %d, UnmarshallingFunc define = %d",
|
||||
type, GetOpUnmarshallingFunc(type) != nullptr);
|
||||
return success;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
DrawCmdList* DrawCmdList::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int size;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, width)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, height)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, size)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ROSEN_LOGD("unirender: DrawCmdList::Unmarshalling start, size = %d", size);
|
||||
std::unique_ptr<DrawCmdList> drawCmdList = std::make_unique<DrawCmdList>(width, height);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
RSOpType type;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, type)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto func = GetOpUnmarshallingFunc(type);
|
||||
if (!func) {
|
||||
ROSEN_LOGW("unirender: opItem Unmarshalling func not define, optype = %d", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
OpItem* item = (*func)(parcel);
|
||||
if (!item) {
|
||||
ROSEN_LOGE("unirender: failed opItem Unmarshalling, optype = %d", type);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
drawCmdList->AddOp(std::unique_ptr<OpItem>(item));
|
||||
}
|
||||
ROSEN_LOGD("unirender: DrawCmdList::Unmarshalling success, size = %d", drawCmdList->GetSize());
|
||||
|
||||
return drawCmdList.release();
|
||||
}
|
||||
#endif
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#include "pipeline/rs_surface_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
void RSSurfaceHandler::SetConsumer(const sptr<Surface>& consumer)
|
||||
{
|
||||
consumer_ = consumer;
|
||||
}
|
||||
|
||||
void RSSurfaceHandler::SetBuffer(const sptr<SurfaceBuffer>& buffer)
|
||||
{
|
||||
if (buffer_ != nullptr) {
|
||||
preBuffer_ = buffer_;
|
||||
buffer_ = buffer;
|
||||
} else {
|
||||
buffer_ = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void RSSurfaceHandler::SetFence(sptr<SyncFence> fence)
|
||||
{
|
||||
preFence_ = fence_;
|
||||
fence_ = std::move(fence);
|
||||
}
|
||||
|
||||
void RSSurfaceHandler::SetDamageRegion(const Rect& damage)
|
||||
{
|
||||
damageRect_ = damage;
|
||||
}
|
||||
|
||||
void RSSurfaceHandler::IncreaseAvailableBuffer()
|
||||
{
|
||||
bufferAvailableCount_++;
|
||||
}
|
||||
|
||||
int32_t RSSurfaceHandler::ReduceAvailableBuffer()
|
||||
{
|
||||
return --bufferAvailableCount_;
|
||||
}
|
||||
|
||||
void RSSurfaceHandler::SetGlobalZOrder(float globalZOrder)
|
||||
{
|
||||
globalZOrder_ = globalZOrder;
|
||||
}
|
||||
|
||||
float RSSurfaceHandler::GetGlobalZOrder() const
|
||||
{
|
||||
return globalZOrder_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,21 +41,6 @@ RSSurfaceRenderNode::RSSurfaceRenderNode(const RSSurfaceRenderNodeConfig& config
|
||||
|
||||
RSSurfaceRenderNode::~RSSurfaceRenderNode() {}
|
||||
|
||||
void RSSurfaceRenderNode::SetConsumer(const sptr<Surface>& consumer)
|
||||
{
|
||||
consumer_ = consumer;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::SetBuffer(const sptr<SurfaceBuffer>& buffer)
|
||||
{
|
||||
if (buffer_ != nullptr) {
|
||||
preBuffer_ = buffer_;
|
||||
buffer_ = buffer;
|
||||
} else {
|
||||
buffer_ = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas)
|
||||
{
|
||||
canvas.SaveAlpha();
|
||||
@ -102,27 +87,6 @@ void RSSurfaceRenderNode::ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas
|
||||
canvas.RestoreAlpha();
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::SetFence(sptr<SyncFence> fence)
|
||||
{
|
||||
preFence_ = fence_;
|
||||
fence_ = std::move(fence);
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::SetDamageRegion(const Rect& damage)
|
||||
{
|
||||
damageRect_ = damage;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::IncreaseAvailableBuffer()
|
||||
{
|
||||
bufferAvailableCount_++;
|
||||
}
|
||||
|
||||
int32_t RSSurfaceRenderNode::ReduceAvailableBuffer()
|
||||
{
|
||||
return --bufferAvailableCount_;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::Prepare(const std::shared_ptr<RSNodeVisitor>& visitor)
|
||||
{
|
||||
if (!visitor) {
|
||||
@ -201,16 +165,6 @@ bool RSSurfaceRenderNode::GetSecurityLayer() const
|
||||
return isSecurityLayer_;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::SetGlobalZOrder(float globalZOrder)
|
||||
{
|
||||
globalZOrder_ = globalZOrder;
|
||||
}
|
||||
|
||||
float RSSurfaceRenderNode::GetGlobalZOrder() const
|
||||
{
|
||||
return globalZOrder_;
|
||||
}
|
||||
|
||||
void RSSurfaceRenderNode::SetParentId(NodeId parentId, bool sendMsg)
|
||||
{
|
||||
parentId_ = parentId;
|
||||
|
@ -17,13 +17,14 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
bool RSSystemProperties::isUniRenderEnabled_ = false;
|
||||
|
||||
bool RSSystemProperties::GetUniRenderEnabled()
|
||||
UniRenderEnabledType RSSystemProperties::GetUniRenderEnabledType()
|
||||
{
|
||||
return isUniRenderEnabled_;
|
||||
return uniRenderEnabledType_;
|
||||
}
|
||||
|
||||
const std::set<std::string>& RSSystemProperties::GetUniRenderEnabledList()
|
||||
{
|
||||
return uniRenderEnabledList_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -69,6 +69,7 @@ ohos_source_set("rosen_ohos_sources") {
|
||||
"//foundation/graphic/graphic/prebuilts/librarys/gpu/include",
|
||||
"//drivers/peripheral/display/interfaces/include/",
|
||||
"//foundation/graphic/graphic/rosen/modules/render_service_client/core",
|
||||
"//foundation/graphic/graphic/utils/log",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
@ -86,6 +87,7 @@ ohos_source_set("rosen_ohos_sources") {
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <message_option.h>
|
||||
#include <message_parcel.h>
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "rs_trace.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
@ -36,11 +37,16 @@ void RSRenderServiceConnectionProxy::CommitTransaction(std::unique_ptr<RSTransac
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(transactionData.get())) {
|
||||
RS_TRACE_BEGIN("Marsh RSTransactionData: cmd count:" + std::to_string(transactionData->GetCommandCount()));
|
||||
bool success = data.WriteParcelable(transactionData.get());
|
||||
RS_TRACE_END();
|
||||
if (!success) {
|
||||
ROSEN_LOGE("RSRenderServiceConnectionProxy::CommitTransaction data.WriteParcelable failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
option.SetFlags(MessageOption::TF_ASYNC);
|
||||
RS_ASYNC_TRACE_BEGIN("RSProxySendRequest", data.GetDataSize());
|
||||
int32_t err = Remote()->SendRequest(RSIRenderServiceConnection::COMMIT_TRANSACTION, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
return;
|
||||
|
@ -15,17 +15,46 @@
|
||||
|
||||
#include "platform/common/rs_system_properties.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <parameters.h>
|
||||
#include "platform/common/rs_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
bool RSSystemProperties::isUniRenderEnabled_ = system::GetParameter("rosen.unirenderenabled", "0") == "1";
|
||||
|
||||
bool RSSystemProperties::GetUniRenderEnabled()
|
||||
template <typename Out>
|
||||
void SplitHelper(const std::string &s, char delimiter, Out result)
|
||||
{
|
||||
return isUniRenderEnabled_;
|
||||
std::istringstream iss(s);
|
||||
std::string item;
|
||||
while (std::getline(iss, item, delimiter)) {
|
||||
*result++ = item;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> GetSplitResult(const std::string &s, char delimiter)
|
||||
{
|
||||
std::vector<std::string> elems;
|
||||
SplitHelper(s, delimiter, std::back_inserter(elems));
|
||||
return elems;
|
||||
}
|
||||
|
||||
UniRenderEnabledType RSSystemProperties::GetUniRenderEnabledType()
|
||||
{
|
||||
return static_cast<UniRenderEnabledType>(std::atoi((system::GetParameter("rosen.unirender.enabled", "0")).c_str()));
|
||||
}
|
||||
|
||||
const std::set<std::string>& RSSystemProperties::GetUniRenderEnabledList()
|
||||
{
|
||||
uniRenderEnabledList_.clear();
|
||||
std::string paramUniLayers = system::GetParameter("rosen.unirender.layers", "clock0");
|
||||
auto uniLayers = GetSplitResult(paramUniLayers, ',');
|
||||
for (auto& layer: uniLayers) {
|
||||
RS_LOGI("RSSystemProperties::GetUniRenderEnabledList uniRender for:%s", layer.c_str());
|
||||
uniRenderEnabledList_.insert(layer);
|
||||
}
|
||||
return uniRenderEnabledList_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -18,12 +18,14 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
bool RSSystemProperties::isUniRenderEnabled_ = false;
|
||||
|
||||
bool RSSystemProperties::GetUniRenderEnabled()
|
||||
UniRenderEnabledType RSSystemProperties::GetUniRenderEnabledType()
|
||||
{
|
||||
return isUniRenderEnabled_;
|
||||
return uniRenderEnabledType_;
|
||||
}
|
||||
|
||||
const std::set<std::string>& RSSystemProperties::GetUniRenderEnabledList()
|
||||
{
|
||||
return uniRenderEnabledList_;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -239,7 +239,6 @@ void RSPropertiesPainter::DrawFrame(
|
||||
canvas.concat(mat);
|
||||
}
|
||||
auto frameRect = Rect2SkRect(properties.GetFrameRect());
|
||||
|
||||
cmds->Playback(canvas, &frameRect);
|
||||
}
|
||||
}
|
||||
|
@ -163,5 +163,46 @@ void RSImage::SetScale(double scale)
|
||||
scale_ = scale;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
bool RSImage::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
int imageFit = static_cast<int>(imageFit_);
|
||||
int imageRepeat = static_cast<int>(imageRepeat_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, image_);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, imageFit);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, imageRepeat);
|
||||
success &= RSMarshallingHelper::Marshalling(parcel, cornerRadius_);
|
||||
return success;
|
||||
}
|
||||
RSImage* RSImage::Unmarshalling(Parcel& parcel)
|
||||
{
|
||||
sk_sp<SkImage> img;
|
||||
int fitNum;
|
||||
int repeatNum;
|
||||
float radius;
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, img)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, fitNum)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, repeatNum)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!RSMarshallingHelper::Unmarshalling(parcel, radius)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RSImage* rsImage = new RSImage();
|
||||
rsImage->SetImage(img);
|
||||
rsImage->SetImageFit(fitNum);
|
||||
rsImage->SetImageRepeat(repeatNum);
|
||||
rsImage->SetRadius(radius);
|
||||
|
||||
return rsImage;
|
||||
}
|
||||
#endif
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
|
@ -43,7 +43,10 @@ std::shared_ptr<RSPath> RSPath::CreateRSPath(const std::string& path)
|
||||
return RSPath::CreateRSPath(skAnimationPath);
|
||||
}
|
||||
|
||||
RSPath::RSPath() {}
|
||||
RSPath::RSPath()
|
||||
{
|
||||
skPath_ = new SkPath();
|
||||
}
|
||||
|
||||
RSPath::~RSPath()
|
||||
{
|
||||
|
@ -15,6 +15,26 @@
|
||||
|
||||
#include "transaction/rs_marshalling_helper.h"
|
||||
|
||||
#include <memory>
|
||||
#include <message_parcel.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ashmem.h"
|
||||
#include "include/core/SkDrawable.h"
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "include/core/SkPicture.h"
|
||||
#include "include/core/SkSerialProcs.h"
|
||||
#include "include/core/SkTextBlob.h"
|
||||
#include "include/core/SkVertices.h"
|
||||
#include "securec.h"
|
||||
#include "src/core/SkAutoMalloc.h"
|
||||
#include "src/core/SkPaintPriv.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include "src/image/SkImage_Base.h"
|
||||
|
||||
#include "animation/rs_render_curve_animation.h"
|
||||
#include "animation/rs_render_keyframe_animation.h"
|
||||
#include "animation/rs_render_path_animation.h"
|
||||
@ -22,16 +42,12 @@
|
||||
#include "common/rs_color.h"
|
||||
#include "common/rs_matrix3.h"
|
||||
#include "common/rs_vector4.h"
|
||||
#include "include/core/SkPaint.h"
|
||||
#include "pipeline/rs_draw_cmd_list.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "render/rs_blur_filter.h"
|
||||
#include "render/rs_filter.h"
|
||||
#include "render/rs_path.h"
|
||||
#include "render/rs_shader.h"
|
||||
#include "src/core/SkAutoMalloc.h"
|
||||
#include "src/core/SkPaintPriv.h"
|
||||
#include "src/core/SkReadBuffer.h"
|
||||
#include "src/core/SkWriteBuffer.h"
|
||||
#include <memory>
|
||||
|
||||
#ifdef ROSEN_OHOS
|
||||
namespace OHOS {
|
||||
@ -64,45 +80,255 @@ MARSHALLING_AND_UNMARSHALLING(double, Double)
|
||||
|
||||
namespace {
|
||||
template<typename T, typename P>
|
||||
static inline sk_sp<T> sk_reinterprat_cast(sk_sp<P> ptr)
|
||||
static inline sk_sp<T> sk_reinterpret_cast(sk_sp<P> ptr)
|
||||
{
|
||||
return sk_sp<T>(static_cast<T*>(ptr.get()));
|
||||
return sk_sp<T>(static_cast<T*>(SkSafeRef(ptr.get())));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// SkData
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkData>& val)
|
||||
{
|
||||
return parcel.WriteUint32(val->size()) && parcel.WriteUnpadBuffer(val->data(), val->size());
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkData is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = parcel.WriteInt32(val->size());
|
||||
if (val->size() == 0) {
|
||||
ROSEN_LOGW("unirender: RSMarshallingHelper::Marshalling SkData size is 0");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret &= RSMarshallingHelper::WriteToParcel(parcel, val->data(), val->size());
|
||||
if (!ret) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Marshalling SkData");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkData>& val)
|
||||
{
|
||||
auto size = parcel.ReadUint32();
|
||||
const void* data = parcel.ReadUnpadBuffer(size);
|
||||
if (data != nullptr) {
|
||||
val = SkData::MakeWithoutCopy(data, size);
|
||||
size_t size = parcel.ReadInt32();
|
||||
if (size == 0) {
|
||||
ROSEN_LOGW("unirender: RSMarshallingHelper::Unmarshalling SkData size is 0");
|
||||
val = SkData::MakeEmpty();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
const void* data = RSMarshallingHelper::ReadFromParcel(parcel, size);
|
||||
if (data == nullptr) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkData");
|
||||
return false;
|
||||
}
|
||||
|
||||
val = SkData::MakeWithoutCopy(data, size);
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// SkFlattenable
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkFlattenable>& val)
|
||||
// SkTextBlob
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkTextBlob>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkTextBlob is nullptr");
|
||||
return false;
|
||||
}
|
||||
sk_sp<SkData> data = val->serialize(SkSerialProcs());
|
||||
return Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkTextBlob>& val)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkTextBlob");
|
||||
return false;
|
||||
}
|
||||
val = SkTextBlob::Deserialize(data->data(), data->size(), SkDeserialProcs());
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// SkPaint
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const SkPaint& val)
|
||||
{
|
||||
SkBinaryWriteBuffer writer;
|
||||
writer.writeFlattenable(val.get());
|
||||
SkAutoMalloc buf(writer.bytesWritten());
|
||||
writer.writeToMemory(buf.get());
|
||||
auto skData = SkData::MakeFromMalloc(buf.get(), writer.bytesWritten());
|
||||
return parcel.WriteUint32(val->getFlattenableType()) && Marshalling(parcel, skData);
|
||||
writer.writePaint(val);
|
||||
size_t length = writer.bytesWritten();
|
||||
sk_sp<SkData> data = SkData::MakeUninitialized(length);
|
||||
writer.writeToMemory(data->writable_data());
|
||||
return Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkFlattenable>& val)
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, SkPaint& val)
|
||||
{
|
||||
auto type = static_cast<SkFlattenable::Type>(parcel.ReadUint32());
|
||||
sk_sp<SkData> data;
|
||||
Unmarshalling(parcel, data);
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkPaint");
|
||||
return false;
|
||||
}
|
||||
SkReadBuffer reader(data->data(), data->size());
|
||||
val = sk_sp<SkFlattenable>(reader.readFlattenable(type));
|
||||
reader.readPaint(&val, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
// SkImage
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkImage>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::Marshalling SkImage is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (val->isLazyGenerated()) {
|
||||
ROSEN_LOGD("RSMarshallingHelper::Marshalling SkImage isLazyGenerated");
|
||||
parcel.WriteUint32(1);
|
||||
SkBinaryWriteBuffer writer;
|
||||
writer.writeImage(val.get());
|
||||
size_t length = writer.bytesWritten();
|
||||
sk_sp<SkData> data = SkData::MakeUninitialized(length);
|
||||
writer.writeToMemory(data->writable_data());
|
||||
return Marshalling(parcel, data);
|
||||
} else {
|
||||
parcel.WriteUint32(0);
|
||||
SkBitmap bitmap;
|
||||
if (!as_IB(val.get())->getROPixels(&bitmap)) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::Marshalling SkImage getROPixels failed");
|
||||
return false;
|
||||
}
|
||||
SkPixmap pixmap;
|
||||
if (!bitmap.peekPixels(&pixmap)) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::Marshalling SkImage peekPixels failed");
|
||||
return false;
|
||||
}
|
||||
size_t rb = pixmap.rowBytes();
|
||||
int width = pixmap.width();
|
||||
int height = pixmap.height();
|
||||
const void* addr = pixmap.addr();
|
||||
size_t size = rb * height;
|
||||
|
||||
parcel.WriteUint32(size);
|
||||
if (!WriteToParcel(parcel, addr, size)) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::Marshalling SkImage WriteToParcel failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
parcel.WriteUint32(rb);
|
||||
parcel.WriteInt32(width);
|
||||
parcel.WriteInt32(height);
|
||||
|
||||
parcel.WriteUint32(pixmap.colorType());
|
||||
parcel.WriteUint32(pixmap.alphaType());
|
||||
|
||||
auto data = pixmap.colorSpace()->serialize();
|
||||
parcel.WriteUint32(data->size());
|
||||
if (!WriteToParcel(parcel, data->data(), data->size())) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::Marshalling SkImage WriteToParcel colorSpace failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkImage>& val)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
if (parcel.ReadUint32() == 1) {
|
||||
ROSEN_LOGD("RSMarshallingHelper::Unmarshalling lazy");
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("failed RSMarshallingHelper::Unmarshalling SkImage");
|
||||
return false;
|
||||
}
|
||||
SkReadBuffer reader(data->data(), data->size());
|
||||
val = reader.readImage();
|
||||
return val != nullptr;
|
||||
} else {
|
||||
size_t pixmapSize = parcel.ReadUint32();
|
||||
const void* addr = RSMarshallingHelper::ReadFromParcel(parcel, pixmapSize);
|
||||
if (addr == nullptr) {
|
||||
ROSEN_LOGE("failed RSMarshallingHelper::Unmarshalling SkData addr");
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t rb = parcel.ReadUint32();
|
||||
int width = parcel.ReadInt32();
|
||||
int height = parcel.ReadInt32();
|
||||
|
||||
SkColorType colorType = static_cast<SkColorType>(parcel.ReadUint32());
|
||||
SkAlphaType alphaType = static_cast<SkAlphaType>(parcel.ReadUint32());
|
||||
|
||||
size_t size = parcel.ReadUint32();
|
||||
const void* data = RSMarshallingHelper::ReadFromParcel(parcel, size);
|
||||
if (data == nullptr) {
|
||||
ROSEN_LOGE("failed RSMarshallingHelper::Unmarshalling SkData data");
|
||||
return false;
|
||||
}
|
||||
auto colorSpace = SkColorSpace::Deserialize(data, size);
|
||||
|
||||
SkImageInfo imageInfo = SkImageInfo::Make(width, height, colorType, alphaType, colorSpace);
|
||||
auto skData = SkData::MakeWithoutCopy(addr, pixmapSize);
|
||||
val = SkImage::MakeRasterData(imageInfo, skData, rb);
|
||||
return val != nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// SkPicture
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkPicture>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkPicture is nullptr");
|
||||
return false;
|
||||
}
|
||||
sk_sp<SkData> data = val->serialize();
|
||||
return Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkPicture>& val)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkPicture");
|
||||
return false;
|
||||
}
|
||||
val = SkPicture::MakeFromData(data->data(), data->size());
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// SkVertices
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkVertices>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkVertices is nullptr");
|
||||
return false;
|
||||
}
|
||||
sk_sp<SkData> data = val->encode();
|
||||
return Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkVertices>& val)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkVertices");
|
||||
return false;
|
||||
}
|
||||
val = SkVertices::Decode(data->data(), data->size());
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// SkRegion
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const SkRegion& region)
|
||||
{
|
||||
SkBinaryWriteBuffer writer;
|
||||
writer.writeRegion(region);
|
||||
size_t length = writer.bytesWritten();
|
||||
sk_sp<SkData> data = SkData::MakeUninitialized(length);
|
||||
writer.writeToMemory(data->writable_data());
|
||||
return Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, SkRegion& region)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkRegion");
|
||||
return false;
|
||||
}
|
||||
SkReadBuffer reader(data->data(), data->size());
|
||||
reader.readRegion(®ion);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,54 +337,141 @@ bool RSMarshallingHelper::Marshalling(Parcel& parcel, const SkPath& val)
|
||||
{
|
||||
SkBinaryWriteBuffer writer;
|
||||
writer.writePath(val);
|
||||
SkAutoMalloc buf(writer.bytesWritten());
|
||||
writer.writeToMemory(buf.get());
|
||||
auto skData = SkData::MakeFromMalloc(buf.get(), writer.bytesWritten());
|
||||
return Marshalling(parcel, skData);
|
||||
size_t length = writer.bytesWritten();
|
||||
sk_sp<SkData> data = SkData::MakeUninitialized(length);
|
||||
writer.writeToMemory(data->writable_data());
|
||||
return Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, SkPath& val)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
Unmarshalling(parcel, data);
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SKPath");
|
||||
return false;
|
||||
}
|
||||
SkReadBuffer reader(data->data(), data->size());
|
||||
reader.readPath(&val);
|
||||
return true;
|
||||
}
|
||||
|
||||
// RSShader
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const RSShader& val)
|
||||
// SkFlattenable
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkFlattenable>& val)
|
||||
{
|
||||
return Marshalling(parcel, sk_reinterprat_cast<SkFlattenable>(val.GetSkShader()));
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkFlattenable is nullptr");
|
||||
return false;
|
||||
}
|
||||
sk_sp<SkData> data = val->serialize();
|
||||
return parcel.WriteUint32(val->getFlattenableType()) && Marshalling(parcel, data);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, RSShader& val)
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkFlattenable>& val)
|
||||
{
|
||||
auto type = static_cast<SkFlattenable::Type>(parcel.ReadUint32());
|
||||
sk_sp<SkData> data;
|
||||
if (!Unmarshalling(parcel, data)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkFlattenable");
|
||||
return false;
|
||||
}
|
||||
val = SkFlattenable::Deserialize(type, data->data(), data->size());
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// SkDrawable
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkDrawable>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkDrawable is nullptr");
|
||||
return false;
|
||||
}
|
||||
return Marshalling(parcel, sk_sp<SkFlattenable>(val));
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkDrawable>& val)
|
||||
{
|
||||
sk_sp<SkFlattenable> flattenablePtr;
|
||||
if (!Unmarshalling(parcel, flattenablePtr)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkDrawable");
|
||||
return false;
|
||||
}
|
||||
auto shaderPtr = sk_reinterprat_cast<SkShader>(flattenablePtr);
|
||||
val.SetSkShader(shaderPtr);
|
||||
val = sk_reinterpret_cast<SkDrawable>(flattenablePtr);
|
||||
return true;
|
||||
}
|
||||
|
||||
// RSPath
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const RSPath& val)
|
||||
// SkImageFilter
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const sk_sp<SkImageFilter>& val)
|
||||
{
|
||||
SkBinaryWriteBuffer writer;
|
||||
writer.writePath(val.GetSkiaPath());
|
||||
SkAutoMalloc buf(writer.bytesWritten());
|
||||
writer.writeToMemory(buf.get());
|
||||
auto skData = SkData::MakeFromMalloc(buf.get(), writer.bytesWritten());
|
||||
return Marshalling(parcel, skData);
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling SkImageFilter is nullptr");
|
||||
return false;
|
||||
}
|
||||
return Marshalling(parcel, sk_sp<SkFlattenable>(val));
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, RSPath& val)
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, sk_sp<SkImageFilter>& val)
|
||||
{
|
||||
sk_sp<SkFlattenable> flattenablePtr;
|
||||
if (!Unmarshalling(parcel, flattenablePtr)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling SkImageFilter");
|
||||
return false;
|
||||
}
|
||||
val = sk_reinterpret_cast<SkImageFilter>(flattenablePtr);
|
||||
return true;
|
||||
}
|
||||
|
||||
// RSShader
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr<RSShader>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling RSShader is nullptr");
|
||||
return false;
|
||||
}
|
||||
return Marshalling(parcel, sk_sp<SkFlattenable>(val->GetSkShader()));
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<RSShader>& val)
|
||||
{
|
||||
sk_sp<SkFlattenable> flattenablePtr;
|
||||
if (!Unmarshalling(parcel, flattenablePtr)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling RSShader");
|
||||
return false;
|
||||
}
|
||||
auto shaderPtr = sk_reinterpret_cast<SkShader>(flattenablePtr);
|
||||
val = RSShader::CreateRSShader(shaderPtr);
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// RSPath
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr<RSPath>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling RSPath is nullptr");
|
||||
return false;
|
||||
}
|
||||
return Marshalling(parcel, val->GetSkiaPath());
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<RSPath>& val)
|
||||
{
|
||||
sk_sp<SkData> data;
|
||||
Unmarshalling(parcel, data);
|
||||
SkReadBuffer reader(data->data(), data->size());
|
||||
SkPath path;
|
||||
reader.readPath(&path);
|
||||
val.SetSkiaPath(path);
|
||||
if (!Unmarshalling(parcel, path)) {
|
||||
ROSEN_LOGE("unirender: failed RSMarshallingHelper::Unmarshalling RSPath");
|
||||
return false;
|
||||
}
|
||||
val = RSPath::CreateRSPath(path);
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
// RSMask
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr<RSMask>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling RSMask is nullptr");
|
||||
return false;
|
||||
}
|
||||
// marshalling func planning to be implemented
|
||||
ROSEN_LOGW("unirender: RSMask Marshalling not define");
|
||||
return true;
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<RSMask>& val)
|
||||
{
|
||||
// marshalling func planning to be implemented
|
||||
ROSEN_LOGW("unirender: RSMask Unmarshalling not define");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -202,6 +515,21 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<RSFilter
|
||||
return success;
|
||||
}
|
||||
|
||||
// RSImage
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr<RSImage>& val)
|
||||
{
|
||||
if (!val) {
|
||||
ROSEN_LOGE("unirender: RSMarshallingHelper::Marshalling RSImage is nullptr");
|
||||
return false;
|
||||
}
|
||||
return val->Marshalling(parcel);
|
||||
}
|
||||
bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<RSImage>& val)
|
||||
{
|
||||
val.reset(RSImage::Unmarshalling(parcel));
|
||||
return val != nullptr;
|
||||
}
|
||||
|
||||
#define MARSHALLING_AND_UNMARSHALLING(TYPE) \
|
||||
bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr<TYPE>& val) \
|
||||
{ \
|
||||
@ -215,6 +543,7 @@ bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<RSFilter
|
||||
MARSHALLING_AND_UNMARSHALLING(RSRenderPathAnimation)
|
||||
MARSHALLING_AND_UNMARSHALLING(RSRenderTransition)
|
||||
MARSHALLING_AND_UNMARSHALLING(RSRenderTransitionEffect)
|
||||
MARSHALLING_AND_UNMARSHALLING(DrawCmdList)
|
||||
#undef MARSHALLING_AND_UNMARSHALLING
|
||||
|
||||
#define MARSHALLING_AND_UNMARSHALLING(TEMPLATE) \
|
||||
@ -238,17 +567,17 @@ MARSHALLING_AND_UNMARSHALLING(RSRenderKeyframeAnimation)
|
||||
template bool RSMarshallingHelper::Marshalling(Parcel& parcel, const std::shared_ptr<TEMPLATE<TYPE>>& val); \
|
||||
template bool RSMarshallingHelper::Unmarshalling(Parcel& parcel, std::shared_ptr<TEMPLATE<TYPE>>& val);
|
||||
|
||||
#define BATCH_EXPLICIT_INSTANTIATION(TEMPLATE) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, int) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, float) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Color) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Matrix3f) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Vector2f) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Vector4f) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Quaternion) \
|
||||
#define BATCH_EXPLICIT_INSTANTIATION(TEMPLATE) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, int) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, float) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Color) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Matrix3f) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Vector2f) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Vector4f) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Quaternion) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr<RSFilter>) \
|
||||
EXPLICIT_INSTANTIATION(TEMPLATE, Vector4<Color>)
|
||||
// [PLANNING]:complete the marshing and unmarshalling
|
||||
// [PLANNING]:complete the marshing and unmarshalling
|
||||
// EXPLICIT_INSTANTIATION(TEMPLATE, std::shared_ptr<RSFilter>)
|
||||
|
||||
BATCH_EXPLICIT_INSTANTIATION(RSRenderCurveAnimation)
|
||||
@ -291,6 +620,113 @@ template bool RSMarshallingHelper::Marshalling(
|
||||
template bool RSMarshallingHelper::Unmarshalling(
|
||||
Parcel& parcel, std::vector<std::shared_ptr<RSRenderTransitionEffect>>& val);
|
||||
|
||||
void RSMarshallingHelper::ReleaseMemory(void* data, int* fd, size_t size)
|
||||
{
|
||||
if (data != nullptr) {
|
||||
::munmap(data, size);
|
||||
data = nullptr;
|
||||
}
|
||||
if (fd != nullptr && (*fd) > 0) {
|
||||
::close(*fd);
|
||||
*fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool RSMarshallingHelper::WriteToParcel(Parcel& parcel, const void* data, size_t size)
|
||||
{
|
||||
if (data == nullptr) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel data is nullptr");
|
||||
return false;
|
||||
}
|
||||
if (data == nullptr || size > MAX_DATA_SIZE) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel data exceed MAX_DATA_SIZE");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteInt32(size)) {
|
||||
return false;
|
||||
}
|
||||
if (size <= MIN_DATA_SIZE) {
|
||||
return parcel.WriteUnpadBuffer(data, size);
|
||||
}
|
||||
static pid_t pid_ = getpid();
|
||||
uint64_t id = ((uint64_t)pid_ << 32) | shmemCount++;
|
||||
std::string name = "Parcel RS" + std::to_string(id);
|
||||
int fd = AshmemCreate(name.c_str(), size);
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel fd:%d", fd);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int result = AshmemSetProt(fd, PROT_READ | PROT_WRITE);
|
||||
if (result < 0) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel result:%d", result);
|
||||
return false;
|
||||
}
|
||||
void* ptr = ::mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (ptr == MAP_FAILED) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel MAP_FAILED");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(static_cast<MessageParcel*>(&parcel)->WriteFileDescriptor(fd))) {
|
||||
::munmap(ptr, size);
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel WriteFileDescriptor error");
|
||||
return false;
|
||||
}
|
||||
if (memcpy_s(ptr, size, data, size) != EOK) {
|
||||
::munmap(ptr, size);
|
||||
ROSEN_LOGE("RSMarshallingHelper::WriteToParcel memcpy_s failed");
|
||||
return false;
|
||||
}
|
||||
ROSEN_LOGI("RSMarshallingHelper::WriteToParcel success");
|
||||
return true;
|
||||
}
|
||||
|
||||
const void* RSMarshallingHelper::ReadFromParcel(Parcel& parcel, size_t size)
|
||||
{
|
||||
int32_t bufferSize = parcel.ReadInt32();
|
||||
if (static_cast<unsigned int>(bufferSize) != size) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::ReadFromParcel size mismatch");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (static_cast<unsigned int>(bufferSize) <= MIN_DATA_SIZE) {
|
||||
return parcel.ReadUnpadBuffer(size);
|
||||
}
|
||||
|
||||
int fd = static_cast<MessageParcel*>(&parcel)->ReadFileDescriptor();
|
||||
if (fd < 0) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::ReadFromParcel fd < 0");
|
||||
return nullptr;
|
||||
}
|
||||
int ashmemSize = AshmemGetSize(fd);
|
||||
if (ashmemSize < 0 || size_t(ashmemSize) < size) {
|
||||
// do not close fd here. fd will be closed in FileDescriptor, ::close(fd)
|
||||
ROSEN_LOGE("RSMarshallingHelper::ReadFromParcel ashmemSize < size");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* ptr = ::mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (ptr == MAP_FAILED) {
|
||||
// do not close fd here. fd will be closed in FileDescriptor, ::close(fd)
|
||||
ROSEN_LOGE("RSMarshallingHelper::ReadFromParcel MAP_FAILED");
|
||||
return nullptr;
|
||||
}
|
||||
uint8_t* base = static_cast<uint8_t*>(malloc(size));
|
||||
if (base == nullptr) {
|
||||
ROSEN_LOGE("RSMarshallingHelper::ReadFromParcel malloc(size) failed");
|
||||
return nullptr;
|
||||
}
|
||||
if (memcpy_s(base, size, ptr, size) != 0) {
|
||||
free(base);
|
||||
base = nullptr;
|
||||
ROSEN_LOGE("RSMarshallingHelper::ReadFromParcel memcpy_s failed");
|
||||
return nullptr;
|
||||
}
|
||||
ReleaseMemory(ptr, &fd, size);
|
||||
return base;
|
||||
}
|
||||
} // namespace Rosen
|
||||
} // namespace OHOS
|
||||
#endif // ROSEN_OHOS
|
||||
|
@ -41,7 +41,11 @@ bool RSTransactionData::Marshalling(Parcel& parcel) const
|
||||
{
|
||||
bool success = true;
|
||||
for (auto& command : commands_) {
|
||||
success = success && command->Marshalling(parcel);
|
||||
success &= command->Marshalling(parcel);
|
||||
if (!success) {
|
||||
ROSEN_LOGE("failed RSTransactionData::Marshalling type:%s", command->PrintType().c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
@ -90,6 +94,8 @@ bool RSTransactionData::UnmarshallingCommand(Parcel& parcel)
|
||||
}
|
||||
auto command = (*func)(parcel);
|
||||
if (command == nullptr) {
|
||||
ROSEN_LOGE("failed RSTransactionData::UnmarshallingCommand, type=%d subtype=%d", commandType,
|
||||
commandSubType);
|
||||
break;
|
||||
}
|
||||
AddCommand(std::unique_ptr<RSCommand>(command));
|
||||
|
@ -109,6 +109,7 @@ ohos_source_set("render_service_client_src") {
|
||||
external_deps = [
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"startup_l2:syspara",
|
||||
]
|
||||
public_deps =
|
||||
[ "$rosen_root/modules/render_service_base:librender_service_base" ]
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "pipeline/rs_render_node_map.h"
|
||||
#include "pipeline/rs_root_render_node.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/common/rs_system_properties.h"
|
||||
#ifdef OHOS_RSS_CLIENT
|
||||
#include "res_sched_client.h"
|
||||
#include "res_type.h"
|
||||
@ -82,6 +83,11 @@ RSRenderThread::RSRenderThread()
|
||||
renderContext_ = new RenderContext();
|
||||
ROSEN_LOGD("Create RenderContext, its pointer is %p", renderContext_);
|
||||
#endif
|
||||
isUniRenderEnabled_ = RSSystemProperties::GetUniRenderEnabledType() != UniRenderEnabledType::UNI_RENDER_DISABLED;
|
||||
if (isUniRenderEnabled_) {
|
||||
ROSEN_LOGD("RSRenderThread is invalid under UniRender");
|
||||
return;
|
||||
}
|
||||
mainFunc_ = [&]() {
|
||||
clock_t startTime = clock();
|
||||
std::string str = "RSRenderThread DrawFrame: " + std::to_string(timestamp_);
|
||||
@ -125,6 +131,10 @@ RSRenderThread::~RSRenderThread()
|
||||
|
||||
void RSRenderThread::Start()
|
||||
{
|
||||
if (isUniRenderEnabled_) {
|
||||
ROSEN_LOGD("RSRenderThread start is invalid under UniRender");
|
||||
return;
|
||||
}
|
||||
ROSEN_LOGD("RSRenderThread start.");
|
||||
running_.store(true);
|
||||
if (thread_ == nullptr) {
|
||||
@ -145,6 +155,11 @@ void RSRenderThread::Start()
|
||||
|
||||
void RSRenderThread::Stop()
|
||||
{
|
||||
if (isUniRenderEnabled_) {
|
||||
ROSEN_LOGD("RSRenderThread stop is invalid under UniRender");
|
||||
return;
|
||||
}
|
||||
|
||||
running_.store(false);
|
||||
|
||||
if (runner_ != nullptr) {
|
||||
|
@ -101,6 +101,7 @@ private:
|
||||
std::vector<std::unique_ptr<RSTransactionData>> cmds_;
|
||||
bool hasRunningAnimation_ = false;
|
||||
std::shared_ptr<RSNodeVisitor> visitor_;
|
||||
bool isUniRenderEnabled_ = false;
|
||||
|
||||
uint64_t timestamp_ = 0;
|
||||
uint64_t prevTimestamp_ = 0;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "command/rs_base_node_command.h"
|
||||
#include "pipeline/rs_node_map.h"
|
||||
#include "platform/common/rs_log.h"
|
||||
#include "platform/common/rs_system_properties.h"
|
||||
#include "transaction/rs_transaction_proxy.h"
|
||||
#include "ui/rs_canvas_node.h"
|
||||
#include "ui/rs_display_node.h"
|
||||
@ -45,6 +46,9 @@ NodeId RSBaseNode::GenerateId()
|
||||
return ((NodeId)pid_ << 32) | currentId_;
|
||||
}
|
||||
|
||||
bool RSBaseNode::isUniRenderEnabled_ =
|
||||
RSSystemProperties::GetUniRenderEnabledType() != UniRenderEnabledType::UNI_RENDER_DISABLED;
|
||||
|
||||
RSBaseNode::RSBaseNode(bool isRenderServiceNode) : id_(GenerateId()), isRenderServiceNode_(isRenderServiceNode) {}
|
||||
|
||||
RSBaseNode::~RSBaseNode()
|
||||
|
@ -64,6 +64,8 @@ public:
|
||||
}
|
||||
virtual std::string DumpNode(int depth) const;
|
||||
protected:
|
||||
static bool isUniRenderEnabled_;
|
||||
|
||||
RSBaseNode(bool isRenderServiceNode);
|
||||
RSBaseNode(const RSBaseNode&) = delete;
|
||||
RSBaseNode(const RSBaseNode&&) = delete;
|
||||
@ -81,7 +83,7 @@ protected:
|
||||
|
||||
bool IsRenderServiceNode() const
|
||||
{
|
||||
return isRenderServiceNode_;
|
||||
return isUniRenderEnabled_ || isRenderServiceNode_;
|
||||
}
|
||||
|
||||
void SetRenderServiceNodeType(bool isRenderServiceNode)
|
||||
|
@ -37,7 +37,7 @@ RSCanvasNode::SharedPtr RSCanvasNode::Create(bool isRenderServiceNode)
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSCanvasNodeCreate>(node->GetId());
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, isRenderServiceNode);
|
||||
transactionProxy->AddCommand(command, isUniRenderEnabled_ || isRenderServiceNode);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
@ -32,8 +32,9 @@ std::shared_ptr<RSNode> RSRootNode::Create(bool isRenderServiceNode)
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSRootNodeCreate>(node->GetId());
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, isRenderServiceNode);
|
||||
transactionProxy->AddCommand(command, isUniRenderEnabled_ || isRenderServiceNode);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -41,10 +42,20 @@ RSRootNode::RSRootNode(bool isRenderServiceNode) : RSCanvasNode(isRenderServiceN
|
||||
|
||||
void RSRootNode::AttachRSSurfaceNode(std::shared_ptr<RSSurfaceNode> surfaceNode) const
|
||||
{
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSRootNodeAttachRSSurfaceNode>(GetId(), surfaceNode->GetId());
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNode());
|
||||
if (!isUniRenderEnabled_) {
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSRootNodeAttachRSSurfaceNode>(GetId(),
|
||||
surfaceNode->GetId());
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, IsRenderServiceNode());
|
||||
}
|
||||
} else {
|
||||
std::unique_ptr<RSCommand> command = std::make_unique<RSRootNodeAttachToUniSurfaceNode>(GetId(),
|
||||
surfaceNode->GetId());
|
||||
auto transactionProxy = RSTransactionProxy::GetInstance();
|
||||
if (transactionProxy != nullptr) {
|
||||
transactionProxy->AddCommand(command, isUniRenderEnabled_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,11 @@ public:
|
||||
{
|
||||
return colorSpace_;
|
||||
}
|
||||
std::string GetName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool NeedForcedSendToRemote() const override;
|
||||
explicit RSSurfaceNode(const RSSurfaceNodeConfig& config, bool isRenderServiceNode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user