!14782 代码日落

Merge pull request !14782 from 李明康/905a
This commit is contained in:
openharmony_ci 2024-09-06 06:13:17 +00:00 committed by Gitee
commit 02da58a62c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
53 changed files with 27 additions and 1556 deletions

View File

@ -71,10 +71,6 @@ ohos_executable("bootanimation") {
"$graphic_2d_root/rosen/modules/render_service_client:librender_service_client",
]
if (defined(use_new_render_context) && use_new_render_context) {
deps += [ "$graphic_2d_root/rosen/modules/render_service_base/src/render_backend:librender_backend" ]
}
external_deps = [
"cJSON:cjson_static",
"c_utils:utils",

View File

@ -24,10 +24,6 @@
#include "boot_compile_progress.h"
#include "boot_player.h"
#include "event_handler.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_context_factory.h"
#include "rs_surface_factory.h"
#endif
#include <render_context/render_context.h>
#include <ui/rs_display_node.h>
#include <ui/rs_surface_extractor.h>
@ -69,9 +65,6 @@ private:
std::thread eventThread_;
std::condition_variable eventCon_;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<OHOS::Rosen::RSRenderSurface> rsSurface_;
#endif
std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface_;
std::shared_ptr<OHOS::Rosen::RSDisplayNode> rsDisplayNode_;
std::shared_ptr<OHOS::Rosen::RSSurfaceNode> rsSurfaceNode_;

View File

@ -16,12 +16,7 @@
#ifndef FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILE_PROGRESS_H
#define FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILE_PROGRESS_H
#ifdef NEW_RENDER_CONTEXT
#include "render_context_bash.h"
#include "rs_render_surface.h"
#else
#include <render_context/render_context.h>
#endif
#include <ui/rs_canvas_node.h>
#include <ui/rs_display_node.h>
#include <ui/rs_surface_extractor.h>

View File

@ -50,9 +50,6 @@ private:
int32_t freq_ = 30;
ImageStructVec imageVector_;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<OHOS::Rosen::RSRenderSurface> rsSurface_;
#endif
std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface_;
std::unique_ptr<OHOS::Rosen::RSSurfaceFrame> rsSurfaceFrame_;
std::shared_ptr<OHOS::Rosen::VSyncReceiver> receiver_;

View File

@ -120,11 +120,7 @@ using PlayerParams = struct PlayerParams {
#ifdef PLAYER_FRAMEWORK_ENABLE
OHOS::sptr<OHOS::Surface> surface;
#endif
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<OHOS::Rosen::RSRenderSurface> rsSurface;
#else
std::shared_ptr<OHOS::Rosen::RSSurface> rsSurface;
#endif
Rosen::ScreenId screenId;
bool soundEnabled = false;
BootAnimationCallback* callback;

View File

@ -189,21 +189,6 @@ void BootAnimationOperation::PlaySound(const std::string& path)
bool BootAnimationOperation::InitRsSurface()
{
LOGI("InitRsSurface start");
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<OHOS::Rosen::RenderContextBase> renderContext =
Rosen::RenderContextBaseFactory::CreateRenderContext();
if (renderContext == nullptr) {
LOGE("create render context failed");
return false;
}
renderContext->Init();
std::shared_ptr<Rosen::DrawingContext> drawingContext = std::make_shared<Rosen::DrawingContext>(
renderContext->GetRenderType());
sptr<Surface> surface = rsSurfaceNode_->GetSurface();
drawingContext->SetUpDrawingContext();
rsSurface_ = Rosen::RSSurfaceFactory::CreateRSSurface(Rosen::PlatformName::OHOS, surface, drawingContext);
rsSurface_->SetRenderContext(renderContext);
#else
rsSurface_ = OHOS::Rosen::RSSurfaceExtractor::ExtractRSSurface(rsSurfaceNode_);
if (rsSurface_ == nullptr) {
LOGE("rsSurface is nullptr");
@ -223,7 +208,6 @@ bool BootAnimationOperation::InitRsSurface()
}
}
#endif // ACE_ENABLE_GL
#endif // NEW_RENDER_CONTEXT
return true;
}

View File

@ -21,10 +21,6 @@
#include "parameters.h"
#include "platform/common/rs_system_properties.h"
#include "recording/recording_canvas.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_context_factory.h"
#include "rs_surface_factory.h"
#endif
#include "animation/rs_animation_common.h"
#include "animation/rs_cubic_bezier_interpolator.h"
#include "animation/rs_interpolator.h"

View File

@ -146,25 +146,12 @@ bool BootPicturePlayer::Draw()
AppExecFwk::EventRunner::Current()->Stop();
return false;
}
#ifdef NEW_RENDER_CONTEXT
if (rsSurface_ == nullptr) {
LOGE("rsSurface is nullptr");
AppExecFwk::EventRunner::Current()->Stop();
return false;
}
auto canvas = rsSurface_->GetCanvas();
OnDraw(canvas, picCurNo_);
ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "BootAnimation::Draw FlushFrame");
rsSurface_->FlushFrame();
ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
#else
rsSurfaceFrame_ = std::move(frame);
auto canvas = rsSurfaceFrame_->GetCanvas();
OnDraw(canvas, picCurNo_);
ROSEN_TRACE_BEGIN(HITRACE_TAG_GRAPHIC_AGP, "BootAnimation::Draw FlushFrame");
rsSurface_->FlushFrame(rsSurfaceFrame_);
ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
#endif
return true;
}

View File

@ -55,10 +55,6 @@ ohos_unittest("bootanimation_test") {
"//third_party/googletest:gtest_main",
]
if (defined(use_new_render_context) && use_new_render_context) {
deps += [ "$graphic_2d_root/rosen/modules/render_service_base/src/render_backend:librender_backend" ]
}
external_deps = [
"cJSON:cjson_static",
"c_utils:utils",

View File

@ -51,11 +51,9 @@ declare_args() {
graphic_2d_feature_enable_prefetch = true
if (defined(is_arkui_x) && is_arkui_x) {
use_new_render_context = false
is_cross_platform = true
} else {
is_cross_platform = false
use_new_render_context = false
}
}
@ -180,10 +178,6 @@ if (graphic_2d_feature_parallel_render_enable) {
rs_enable_parallel_render = true
gpu_defines += [ "RS_ENABLE_PARALLEL_RENDER" ]
}
if (defined(use_new_render_context) && use_new_render_context) {
rs_enable_parallel_render = false
gpu_defines -= [ "RS_ENABLE_PARALLEL_RENDER" ]
}
if (graphic_2d_feature_enable_dvsync) {
gpu_defines += [ "RS_ENABLE_DVSYNC" ]

View File

@ -254,11 +254,6 @@ ohos_shared_library("librender_service") {
public_external_deps = [ "skia:skia_canvaskit" ]
if (defined(use_new_render_context) && use_new_render_context) {
include_dirs += [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
defines += [ "NEW_RENDER_CONTEXT" ]
}
if (defined(rs_enable_parallel_upload) && rs_enable_parallel_upload) {
sources += [
"core/pipeline/parallel_render/resource/rs_upload_resource_thread.cpp",

View File

@ -1318,15 +1318,9 @@ void RSDisplayRenderNodeDrawable::SwitchColorFilter(RSPaintFilterCanvas& canvas)
Drawing::Brush brush;
RSBaseRenderUtil::SetColorFilterModeToPaint(colorFilterMode, brush);
#if defined (RS_ENABLE_GL) || defined (RS_ENABLE_VK)
#ifdef NEW_RENDER_CONTEXT
RSTagTracker tagTracker(
renderEngine->GetDrawingContext()->GetDrawingContext(),
RSTagTracker::TAG_SAVELAYER_COLOR_FILTER);
#else
RSTagTracker tagTracker(
renderEngine->GetRenderContext()->GetDrGPUContext(),
RSTagTracker::TAG_SAVELAYER_COLOR_FILTER);
#endif
#endif
Drawing::SaveLayerOps slr(nullptr, &brush, Drawing::SaveLayerOps::INIT_WITH_PREVIOUS);
canvas.SaveLayer(slr);

View File

@ -89,22 +89,6 @@ public:
{
return surfaceCreated_;
}
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> GetRSSurface() const
{
return surface_;
}
void SetVirtualSurface(std::shared_ptr<RSRenderSurface>& virtualSurface, uint64_t pSurfaceUniqueId)
{
virtualSurface_ = virtualSurface;
virtualSurfaceUniqueId_ = pSurfaceUniqueId;
}
std::shared_ptr<RSRenderSurface> GetVirtualSurface(uint64_t pSurfaceUniqueId)
{
return virtualSurfaceUniqueId_ != pSurfaceUniqueId ? nullptr : virtualSurface_;
}
#else
std::shared_ptr<RSSurface> GetRSSurface() const
{
return surface_;
@ -118,7 +102,6 @@ public:
{
return virtualSurfaceUniqueId_ != pSurfaceUniqueId ? nullptr : virtualSurface_;
}
#endif
bool IsFirstTimeToProcessor() const
{
@ -208,13 +191,8 @@ private:
// surface create in render thread
static constexpr uint32_t BUFFER_SIZE = 4;
bool surfaceCreated_ = false;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> surface_ = nullptr;
std::shared_ptr<RSRenderSurface> virtualSurface_ = nullptr;
#else
std::shared_ptr<RSSurface> surface_ = nullptr;
std::shared_ptr<RSSurface> virtualSurface_ = nullptr;
#endif
#ifndef ROSEN_CROSS_PLATFORM
sptr<IBufferConsumerListener> consumerListener_ = nullptr;

View File

@ -21,11 +21,7 @@
#include <iconsumer_surface.h>
#include <surface.h>
#endif
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "common/rs_common_def.h"
#include "drawable/rs_render_node_drawable.h"
@ -290,11 +286,7 @@ private:
#ifndef ROSEN_CROSS_PLATFORM
sptr<IBufferConsumerListener> consumerListener_ = nullptr;
#endif
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> surface_ = nullptr;
#else
std::shared_ptr<RSSurface> surface_ = nullptr;
#endif
bool surfaceCreated_ = false;
// UIFIRST

View File

@ -31,9 +31,6 @@
#include "common/rs_obj_abs_geometry.h"
#include "common/rs_singleton.h"
#include "memory/rs_tag_tracker.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_context/memory_handler.h"
#endif
#include "pipeline/rs_main_thread.h"
#include "pipeline/rs_surface_render_node.h"
#include "platform/common/rs_log.h"
@ -409,12 +406,8 @@ void MemoryManager::DumpDrawingGpuMemory(DfxString& log, const Drawing::GPUConte
/* ShaderCache */
log.AppendFormat("\n---------------\nShader Caches:\n");
#ifdef NEW_RENDER_CONTEXT
log.AppendFormat(MemoryHandler::QuerryShader().c_str());
#else
std::shared_ptr<RenderContext> rendercontext = std::make_shared<RenderContext>();
log.AppendFormat(rendercontext->GetShaderCacheSize().c_str());
#endif
// gpu stat
log.AppendFormat("\n---------------\ndumpGpuStats:\n");
std::string stat;

View File

@ -111,13 +111,8 @@ void RSRcdRenderVisitor::ProcessRcdSurfaceRenderNode(RSRcdSurfaceRenderNode& nod
return;
}
#ifdef NEW_RENDER_CONTEXT
auto renderFrame = renderEngine_->RequestFrame(std::static_pointer_cast<RSRenderSurfaceOhos>(rsSurface),
node.GetHardenBufferRequestConfig(), true, false);
#else
auto renderFrame = renderEngine_->RequestFrame(std::static_pointer_cast<RSSurfaceOhos>(rsSurface),
node.GetHardenBufferRequestConfig(), true, false);
#endif
if (renderFrame == nullptr) {
RS_LOGE("RSRcdRenderVisitor Request Frame Failed");
return;

View File

@ -254,11 +254,7 @@ bool RSRcdSurfaceRenderNode::IsSurfaceCreated() const
return rcdExtInfo_.surfaceCreated;
}
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> RSRcdSurfaceRenderNode::GetRSSurface() const
#else
std::shared_ptr<RSSurface> RSRcdSurfaceRenderNode::GetRSSurface() const
#endif
{
return surface_;
}

View File

@ -24,13 +24,8 @@
#include "pipeline/rs_render_node.h"
#include "pipeline/rs_surface_handler.h"
#include "pipeline/round_corner_display/rs_round_corner_config.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#include "render_context_base.h"
#else
#include "platform/drawing/rs_surface.h"
#include "render_context/render_context.h"
#endif
#include "sync_fence.h"
#include <filesystem>
#include "include/core/SkBitmap.h"
@ -111,11 +106,7 @@ public:
bool CreateSurface(sptr<IBufferConsumerListener> listener);
bool IsSurfaceCreated() const;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> GetRSSurface() const;
#else
std::shared_ptr<RSSurface> GetRSSurface() const;
#endif
sptr<IBufferConsumerListener> GetConsumerListener() const;
RcdSourceInfo rcdSourceInfo;
void SetRcdBufferWidth(uint32_t width);
@ -147,11 +138,7 @@ private:
uint32_t GetRcdBufferHeight() const;
uint32_t GetRcdBufferSize() const;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> surface_ = nullptr;
#else
std::shared_ptr<RSSurface> surface_ = nullptr;
#endif
sptr<IBufferConsumerListener> consumerListener_;
RcdExtInfo rcdExtInfo_;

View File

@ -26,18 +26,12 @@
#include "pipeline/rs_uni_render_judgement.h"
#include "platform/common/rs_log.h"
#include "platform/common/rs_system_properties.h"
#if defined(NEW_RENDER_CONTEXT)
#include "render_context_factory.h"
#include "rs_surface_factory.h"
#include "ohos/rs_render_surface_ohos.h"
#else
#include "platform/ohos/backend/rs_surface_ohos_gl.h"
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
#ifdef RS_ENABLE_VK
#include "platform/ohos/backend/rs_vulkan_context.h"
#include "platform/ohos/backend/rs_surface_ohos_vulkan.h"
#endif
#endif
#include "render/rs_drawing_filter.h"
#include "render/rs_skia_filter.h"
#include "metadata_helper.h"
@ -57,20 +51,6 @@ RSBaseRenderEngine::~RSBaseRenderEngine() noexcept
void RSBaseRenderEngine::Init(bool independentContext)
{
(void)independentContext;
#if defined(NEW_RENDER_CONTEXT)
RenderType renderType = RenderType::RASTER;
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
if (OHOS::Rosen::RSSystemProperties::GetGpuApiType() == OHOS::Rosen::GpuApiType::OPENGL) {
renderType = RenderType::GLES;
} else if (RSSystemProperties::IsUseVulkan()) {
renderType = RenderType::VULKAN;
}
#endif
renderContext_ = RenderContextBaseFactory::CreateRenderContext(renderType);
renderContext_->Init();
drawingContext_ = std::make_shared<Rosen::DrawingContext>(renderContext_->GetRenderType());
drawingContext_->SetUpDrawingContext();
#else
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
renderContext_ = std::make_shared<RenderContext>();
#ifdef RS_ENABLE_GL
@ -94,14 +74,8 @@ void RSBaseRenderEngine::Init(bool independentContext)
renderContext_->SetUpGpuContext();
#endif
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#endif
#if defined(RS_ENABLE_EGLIMAGE)
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RSRenderSurfaceFrame> frame = renderContext_->GetRSRenderSurfaceFrame();
eglImageManager_ = std::make_shared<RSEglImageManager>(frame->eglState->eglDisplay);
#else
eglImageManager_ = std::make_shared<RSEglImageManager>(renderContext_->GetEGLDisplay());
#endif
#endif // RS_ENABLE_EGLIMAGE
#ifdef RS_ENABLE_VK
if (RSSystemProperties::IsUseVulkan()) {
@ -271,17 +245,10 @@ std::shared_ptr<Drawing::Image> RSBaseRenderEngine::CreateEglImageFromBuffer(RSP
#endif // RS_ENABLE_EGLIMAGE
}
#ifdef NEW_RENDER_CONTEXT
std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(
const std::shared_ptr<RSRenderSurfaceOhos>& rsSurface,
const BufferRequestConfig& config, bool forceCPU, bool useAFBC,
const FrameContextConfig& frameContextConfig)
#else
std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(
const std::shared_ptr<RSSurfaceOhos>& rsSurface,
const BufferRequestConfig& config, bool forceCPU, bool useAFBC,
const FrameContextConfig& frameContextConfig)
#endif
{
#ifdef RS_ENABLE_VK
if (RSSystemProperties::GetGpuApiType() == GpuApiType::VULKAN ||
@ -322,26 +289,6 @@ std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(
rsSurface->SetSurfaceBufferUsage(bufferUsage);
// check if we can use GPU context
#if defined(NEW_RENDER_CONTEXT)
#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)
if (forceCPU) {
std::shared_ptr<RenderContextBase> renderContextRaster = RenderContextBaseFactory::CreateRenderContext(
RenderType::RASTER);
renderContextRaster->Init();
std::shared_ptr<DrawingContext> drawingContextRaster = std::make_shared<DrawingContext>(RenderType::RASTER);
rsSurface->SetRenderContext(renderContextRaster);
rsSurface->SetDrawingContext(drawingContextRaster);
RS_LOGD("RSBaseRenderEngine::RequestFrame force CPU");
} else {
if (renderContext_ != nullptr) {
rsSurface->SetRenderContext(renderContext_);
}
if (drawingContext_ != nullptr) {
rsSurface->SetDrawingContext(drawingContext_);
}
}
#endif
#else
#ifdef RS_ENABLE_GL
if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL &&
renderContext_ != nullptr) {
@ -352,7 +299,6 @@ std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(
if (RSSystemProperties::IsUseVulkan() && skContext_ != nullptr) {
std::static_pointer_cast<RSSurfaceOhosVulkan>(rsSurface)->SetSkContext(skContext_);
}
#endif
#endif
auto surfaceFrame = rsSurface->RequestFrame(config.width, config.height, 0, useAFBC,
frameContextConfig.isProtected);
@ -361,11 +307,7 @@ std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(
RS_LOGE("RSBaseRenderEngine::RequestFrame: request SurfaceFrame failed!");
return nullptr;
}
#ifdef NEW_RENDER_CONTEXT
return std::make_unique<RSRenderFrame>(rsSurface);
#else
return std::make_unique<RSRenderFrame>(rsSurface, std::move(surfaceFrame));
#endif
}
std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(const sptr<Surface>& targetSurface,
@ -379,12 +321,6 @@ std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(const sptr<Surfa
return nullptr;
}
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RSRenderSurfaceOhos> rsSurface = nullptr;
std::shared_ptr<RSRenderSurface> renderSurface = RSSurfaceFactory::CreateRSSurface(PlatformName::OHOS,
targetSurface);
rsSurface = std::static_pointer_cast<RSRenderSurfaceOhos>(renderSurface);
#else
std::shared_ptr<RSSurfaceOhos> rsSurface = nullptr;
#if (defined RS_ENABLE_GL) && (defined RS_ENABLE_EGLIMAGE)
if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) {
@ -403,17 +339,11 @@ std::unique_ptr<RSRenderFrame> RSBaseRenderEngine::RequestFrame(const sptr<Surfa
if (rsSurface == nullptr) {
rsSurface = std::make_shared<RSSurfaceOhosRaster>(targetSurface);
}
#endif
RS_OPTIONAL_TRACE_END();
return RequestFrame(rsSurface, config, forceCPU, useAFBC, frameContextConfig);
}
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurfaceOhos> RSBaseRenderEngine::MakeRSSurface(const sptr<Surface>& targetSurface,
bool forceCPU)
#else
std::shared_ptr<RSSurfaceOhos> RSBaseRenderEngine::MakeRSSurface(const sptr<Surface>& targetSurface, bool forceCPU)
#endif
{
RS_TRACE_FUNC();
if (targetSurface == nullptr) {
@ -422,12 +352,6 @@ std::shared_ptr<RSSurfaceOhos> RSBaseRenderEngine::MakeRSSurface(const sptr<Surf
return nullptr;
}
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RSRenderSurfaceOhos> rsSurface = nullptr;
std::shared_ptr<RSRenderSurface> renderSurface = RSSurfaceFactory::CreateRSSurface(PlatformName::OHOS,
targetSurface);
rsSurface = std::static_pointer_cast<RSRenderSurfaceOhos>(renderSurface);
#else
std::shared_ptr<RSSurfaceOhos> rsSurface = nullptr;
#if (defined RS_ENABLE_GL) && (defined RS_ENABLE_EGLIMAGE)
if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) {
@ -446,17 +370,11 @@ std::shared_ptr<RSSurfaceOhos> RSBaseRenderEngine::MakeRSSurface(const sptr<Surf
if (rsSurface == nullptr) {
rsSurface = std::make_shared<RSSurfaceOhosRaster>(targetSurface);
}
#endif
return rsSurface;
}
#ifdef NEW_RENDER_CONTEXT
void RSBaseRenderEngine::SetUiTimeStamp(const std::unique_ptr<RSRenderFrame>& renderFrame,
std::shared_ptr<RSRenderSurfaceOhos> surfaceOhos)
#else
void RSBaseRenderEngine::SetUiTimeStamp(const std::unique_ptr<RSRenderFrame>& renderFrame,
std::shared_ptr<RSSurfaceOhos> surfaceOhos)
#endif
{
if (surfaceOhos == nullptr) {
RS_LOGE("RSBaseRenderEngine::SetUiTimeStamp: surfaceOhos is null!");
@ -468,12 +386,8 @@ void RSBaseRenderEngine::SetUiTimeStamp(const std::unique_ptr<RSRenderFrame>& re
return;
}
#ifdef NEW_RENDER_CONTEXT
surfaceOhos->SetUiTimeStamp();
#else
auto& frame = renderFrame->GetFrame();
surfaceOhos->SetUiTimeStamp(frame);
#endif
}
void RSBaseRenderEngine::DrawDisplayNodeWithParams(RSPaintFilterCanvas& canvas, RSDisplayRenderNode& node,

View File

@ -28,17 +28,11 @@
#include "include/gpu/GrDirectContext.h"
#include "rs_base_render_util.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_backend/rs_render_surface_frame.h"
#include "ohos/rs_render_surface_ohos.h"
#include "render_context_base.h"
#else
#include "platform/drawing/rs_surface_frame.h"
#include "platform/ohos/rs_surface_ohos.h"
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
#include "render_context/render_context.h"
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#endif
#ifdef RS_ENABLE_EGLIMAGE
#include "rs_egl_image_manager.h"
#endif // RS_ENABLE_EGLIMAGE
@ -68,17 +62,10 @@ public:
class RSRenderFrame {
public:
// we guarantee when constructing this object, all parameters are valid.
#ifdef NEW_RENDER_CONTEXT
explicit RSRenderFrame(const std::shared_ptr<RSRenderSurfaceOhos>& target)
: targetSurface_(target)
{
}
#else
RSRenderFrame(const std::shared_ptr<RSSurfaceOhos>& target, std::unique_ptr<RSSurfaceFrame>&& frame)
: targetSurface_(target), surfaceFrame_(std::move(frame))
{
}
#endif
~RSRenderFrame() noexcept
{
Flush();
@ -87,15 +74,6 @@ public:
// noncopyable
RSRenderFrame(const RSRenderFrame&) = delete;
void operator=(const RSRenderFrame&) = delete;
#ifdef NEW_RENDER_CONTEXT
void Flush() noexcept
{
if (targetSurface_ != nullptr) {
targetSurface_->FlushFrame();
targetSurface_ = nullptr;
}
}
#else
void Flush() noexcept
{
if (targetSurface_ != nullptr && surfaceFrame_ != nullptr) {
@ -104,58 +82,33 @@ public:
surfaceFrame_ = nullptr;
}
}
#endif
#ifdef NEW_RENDER_CONTEXT
const std::shared_ptr<RSRenderSurfaceOhos>& GetSurface() const
#else
const std::shared_ptr<RSSurfaceOhos>& GetSurface() const
#endif
{
return targetSurface_;
}
#ifndef NEW_RENDER_CONTEXT
const std::unique_ptr<RSSurfaceFrame>& GetFrame() const
{
return surfaceFrame_;
}
#endif
std::unique_ptr<RSPaintFilterCanvas> GetCanvas()
{
#ifdef NEW_RENDER_CONTEXT
return std::make_unique<RSPaintFilterCanvas>(targetSurface_->GetSurface().get());
#else
return std::make_unique<RSPaintFilterCanvas>(surfaceFrame_->GetSurface().get());
#endif
}
int32_t GetBufferAge()
{
#ifdef NEW_RENDER_CONTEXT
return targetSurface_ != nullptr ? targetSurface_->GetBufferAge() : 0;
#else
return surfaceFrame_ != nullptr ? surfaceFrame_->GetBufferAge() : 0;
#endif
}
void SetDamageRegion(const std::vector<RectI> &rects)
{
#ifdef NEW_RENDER_CONTEXT
if (targetSurface_ != nullptr) {
targetSurface_ ->SetDamageRegion(rects);
}
#else
if (surfaceFrame_ != nullptr) {
surfaceFrame_->SetDamageRegion(rects);
}
#endif
}
private:
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurfaceOhos> targetSurface_;
#else
std::shared_ptr<RSSurfaceOhos> targetSurface_;
std::unique_ptr<RSSurfaceFrame> surfaceFrame_;
#endif
};
// function that will be called before drawing Buffer / Image.
@ -187,21 +140,12 @@ public:
BufferDrawParam& params, Drawing::SamplingOptions& samplingOptions);
// There would only one user(thread) to renderFrame(request frame) at one time.
#ifdef NEW_RENDER_CONTEXT
std::unique_ptr<RSRenderFrame> RequestFrame(const std::shared_ptr<RSRenderSurfaceOhos>& rsSurface,
const BufferRequestConfig& config, bool forceCPU = false, bool useAFBC = true,
const FrameContextConfig& frameContextConfig = {false, false});
std::shared_ptr<RSRenderSurfaceOhos> MakeRSSurface(const sptr<Surface>& targetSurface, bool forceCPU);
void SetUiTimeStamp(const std::unique_ptr<RSRenderFrame>& renderFrame,
std::shared_ptr<RSRenderSurfaceOhos> surfaceOhos);
#else
std::unique_ptr<RSRenderFrame> RequestFrame(const std::shared_ptr<RSSurfaceOhos>& rsSurface,
const BufferRequestConfig& config, bool forceCPU = false, bool useAFBC = true,
const FrameContextConfig& frameContextConfig = {false, false});
std::shared_ptr<RSSurfaceOhos> MakeRSSurface(const sptr<Surface>& targetSurface, bool forceCPU);
void SetUiTimeStamp(const std::unique_ptr<RSRenderFrame>& renderFrame,
std::shared_ptr<RSSurfaceOhos> surfaceOhos);
#endif
virtual void DrawSurfaceNodeWithParams(RSPaintFilterCanvas& canvas, RSSurfaceRenderNode& node,
BufferDrawParam& params, PreProcessFunc preProcess = nullptr, PostProcessFunc postProcess = nullptr) = 0;
@ -235,16 +179,6 @@ public:
static void SetHighContrast(bool enabled);
static bool IsHighContrastEnabled();
#if defined(NEW_RENDER_CONTEXT)
const std::shared_ptr<RenderContextBase>& GetRenderContext() const
{
return renderContext_;
}
const std::shared_ptr<DrawingContext>& GetDrawingContext() const
{
return drawingContext_;
}
#else
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
const std::shared_ptr<RenderContext>& GetRenderContext()
{
@ -255,7 +189,6 @@ public:
return captureRenderContext_;
}
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#endif
void ResetCurrentContext();
#ifdef RS_ENABLE_EGLIMAGE
@ -296,15 +229,10 @@ private:
const sptr<SurfaceBuffer>& buffer, const sptr<SyncFence>& acquireFence,
const uint32_t threadIndex = UNI_MAIN_THREAD_INDEX, GraphicColorGamut colorGamut = GRAPHIC_COLOR_GAMUT_SRGB);
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RenderContextBase> renderContext_ = nullptr;
std::shared_ptr<DrawingContext> drawingContext_ = nullptr;
#else
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
std::shared_ptr<RenderContext> renderContext_ = nullptr;
std::shared_ptr<RenderContext> captureRenderContext_ = nullptr;
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#endif
#ifdef RS_ENABLE_EGLIMAGE
std::shared_ptr<RSEglImageManager> eglImageManager_ = nullptr;
#endif // RS_ENABLE_EGLIMAGE

View File

@ -109,10 +109,6 @@
#include "rs_upload_resource_thread.h"
#endif
#ifdef NEW_RENDER_CONTEXT
#include "render_context/memory_handler.h"
#endif
#if defined(ACCESSIBILITY_ENABLE)
#include "accessibility_config.h"
#endif
@ -573,13 +569,8 @@ void RSMainThread::Init()
/* move to render thread ? */
if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) {
int cacheLimitsTimes = 3;
#ifdef NEW_RENDER_CONTEXT
auto gpuContext = isUniRender_? uniRenderEngine_->GetDrawingContext()->GetDrawingContext() :
renderEngine_->GetDrawingContext()->GetDrawingContext();
#else
auto gpuContext = isUniRender_? GetRenderEngine()->GetRenderContext()->GetDrGPUContext() :
renderEngine_->GetRenderContext()->GetDrGPUContext();
#endif
if (gpuContext == nullptr) {
RS_LOGE("RSMainThread::Init gpuContext is nullptr!");
return;

View File

@ -27,11 +27,7 @@
#include "pipeline/rs_surface_render_node.h"
#include "platform/common/rs_log.h"
#include "platform/common/rs_innovation.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "screen_manager/rs_screen_manager.h"
#include "screen_manager/screen_types.h"

View File

@ -23,9 +23,7 @@
#include "common/rs_optional_trace.h"
#include "drawable/rs_display_render_node_drawable.h"
#include "platform/common/rs_log.h"
#ifndef NEW_RENDER_CONTEXT
#include "platform/ohos/backend/rs_surface_frame_ohos_raster.h"
#endif
#include "pipeline/rs_uni_render_util.h"
#include "pipeline/rs_main_thread.h"
#include "string_utils.h"
@ -101,15 +99,9 @@ bool RSUniRenderVirtualProcessor::InitForRenderThread(DrawableV2::RSDisplayRende
rsSurface = renderEngine_->MakeRSSurface(producerSurface_, forceCPU_);
displayDrawable.SetVirtualSurface(rsSurface, pSurfaceUniqueId);
}
#ifdef NEW_RENDER_CONTEXT
renderFrame_ = renderEngine_->RequestFrame(
std::static_pointer_cast<RSRenderSurfaceOhos>(rsSurface), renderFrameConfig_, forceCPU_, false,
frameContextConfig);
#else
renderFrame_ = renderEngine_->RequestFrame(
std::static_pointer_cast<RSSurfaceOhos>(rsSurface), renderFrameConfig_, forceCPU_, false,
frameContextConfig);
#endif
}
if (renderFrame_ == nullptr) {
RS_LOGE("RSUniRenderVirtualProcessor::Init for Screen(id %{public}" PRIu64 "): RenderFrame is null!",
@ -160,13 +152,8 @@ bool RSUniRenderVirtualProcessor::RequestVirtualFrame(DrawableV2::RSDisplayRende
rsSurface = renderEngine->MakeRSSurface(producerSurface_, forceCPU_);
displayDrawable.SetVirtualSurface(rsSurface, pSurfaceUniqueId);
}
#ifdef NEW_RENDER_CONTEXT
renderFrame_ = renderEngine->RequestFrame(
std::static_pointer_cast<RSRenderSurfaceOhos>(rsSurface), renderFrameConfig_, forceCPU_, false);
#else
renderFrame_ = renderEngine->RequestFrame(
std::static_pointer_cast<RSSurfaceOhos>(rsSurface), renderFrameConfig_, forceCPU_, false);
#endif
}
if (renderFrame_ == nullptr) {
RS_LOGE("RSUniRenderVirtualProcessor::RequestVirtualFrame RenderFrame is null!");

View File

@ -20,9 +20,6 @@
#include "draw/color.h"
#include "platform/common/rs_log.h"
#ifndef NEW_RENDER_CONTEXT
#include "platform/ohos/backend/rs_surface_frame_ohos_raster.h"
#endif
#include "rs_base_render_util.h"
#include "rs_divided_render_util.h"
#include "rs_trace.h"

View File

@ -629,10 +629,6 @@ ohos_shared_library("librender_service_base") {
external_deps = [ "hilog:libhilog" ]
if (defined(use_new_render_context) && use_new_render_context) {
public_deps += [ "src/render_backend:librender_backend" ]
}
public_external_deps = []
if (rosen_is_ohos) {
public_external_deps += [
@ -671,10 +667,6 @@ ohos_source_set("librender_service_base_static") {
"src/platform:platform",
]
if (defined(use_new_render_context) && use_new_render_context) {
public_deps += [ "src/render_backend:librender_backend" ]
}
public_external_deps = []
if (rosen_is_ohos) {
public_external_deps += [

View File

@ -34,11 +34,7 @@
#include "pipeline/rs_surface_handler.h"
#include <screen_manager/screen_types.h>
#include "screen_manager/rs_screen_info.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
namespace OHOS {
namespace Rosen {

View File

@ -18,9 +18,6 @@
#include "common/rs_macros.h"
#include "memory/rs_memory_track.h"
#include "pipeline/rs_canvas_render_node.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#endif
namespace OHOS {
namespace Rosen {
@ -43,11 +40,7 @@ public:
void AttachRSSurfaceNode(NodeId SurfaceNodeId);
std::shared_ptr<RSDirtyRegionManager> GetDirtyManager() const;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> GetSurface();
#else
std::shared_ptr<RSSurface> GetSurface();
#endif
NodeId GetRSSurfaceNodeId();
float GetSuggestedBufferWidth() const;
float GetSuggestedBufferHeight() const;
@ -69,11 +62,7 @@ private:
explicit RSRootRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {},
bool isTextureExportNode = false);
std::shared_ptr<RSDirtyRegionManager> dirtyManager_ = nullptr;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> rsSurface_ = nullptr;
#else
std::shared_ptr<RSSurface> rsSurface_ = nullptr;
#endif
NodeId surfaceNodeId_ = 0;
bool enableRender_ = true;
float suggestedBufferWidth_ = 0.f;

View File

@ -15,11 +15,7 @@
#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_CONVERTER_H
#define RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_CONVERTER_H
#ifdef NEW_RENDER_CONTEXT
#include "render_backend/rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "surface.h"
namespace OHOS {
@ -27,11 +23,7 @@ namespace Rosen {
class RSB_EXPORT RSSurfaceConverter {
public:
#ifdef NEW_RENDER_CONTEXT
static RSB_EXPORT sptr<Surface> ConvertToOhosSurface(std::shared_ptr<RSRenderSurface> surface);
#else
static RSB_EXPORT sptr<Surface> ConvertToOhosSurface(std::shared_ptr<RSSurface> surface);
#endif
};
} // namespace Rosen
} // namespace OHOS

View File

@ -19,11 +19,7 @@
#include <memory>
#include "common/rs_common_def.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_backend/rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "transaction/rs_transaction_data.h"
namespace OHOS {

View File

@ -34,11 +34,7 @@
#include "ipc_callbacks/screen_change_callback.h"
#include "ipc_callbacks/surface_capture_callback.h"
#include "memory/rs_memory_graphic.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_backend/rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "rs_irender_client.h"
#include "variable_frame_rate/rs_variable_frame_rate.h"
#include "screen_manager/rs_screen_capability.h"
@ -121,11 +117,7 @@ public:
bool CreateNode(const RSSurfaceRenderNodeConfig& config);
bool CreateNode(const RSDisplayNodeConfig& displayNodeConfig, NodeId nodeId);
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config);
#else
std::shared_ptr<RSSurface> CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config);
#endif
std::shared_ptr<VSyncReceiver> CreateVSyncReceiver(
const std::string& name,
const std::shared_ptr<OHOS::AppExecFwk::EventHandler> &looper = nullptr,
@ -146,11 +138,7 @@ public:
std::vector<ScreenId> GetAllScreenIds();
#ifndef ROSEN_CROSS_PLATFORM
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RSRenderSurface> CreateRSSurface(const sptr<Surface> &surface);
#else
std::shared_ptr<RSSurface> CreateRSSurface(const sptr<Surface> &surface);
#endif
ScreenId CreateVirtualScreen(const std::string& name, uint32_t width, uint32_t height, sptr<Surface> surface,
ScreenId mirrorId, int32_t flags, std::vector<NodeId> whiteList = {});

View File

@ -18,12 +18,7 @@
#include "pipeline/rs_root_render_node.h"
#include "pipeline/rs_surface_render_node.h"
#include "platform/common/rs_log.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "pipeline/rs_render_node_gc.h"
namespace OHOS {

View File

@ -15,11 +15,7 @@
#include "pipeline/rs_root_render_node.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "transaction/rs_transaction_proxy.h"
#include "visitor/rs_node_visitor.h"
#ifndef ROSEN_CROSS_PLATFORM
@ -64,11 +60,8 @@ void RSRootRenderNode::UpdateSuggestedBufferSize(float width, float height)
suggestedBufferHeight_ = height;
suggestedBufferWidth_ = width;
}
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> RSRootRenderNode::GetSurface()
#else
std::shared_ptr<RSSurface> RSRootRenderNode::GetSurface()
#endif
{
return rsSurface_;
}

View File

@ -24,9 +24,6 @@ config("export_config") {
"$graphic_2d_root/rosen/include",
"$graphic_2d_root/rosen/modules/composer/vsync/include",
]
if (defined(use_new_render_context) && use_new_render_context) {
include_dirs += [ "$graphic_2d_root/rosen/modules/render_service_base/include/render_backend" ]
}
defines = rs_common_define
}
@ -71,37 +68,35 @@ ohos_source_set("rosen_ohos_sources") {
sources += [ "rs_accessibility.cpp" ]
}
if (!defined(use_new_render_context) || !use_new_render_context) {
sources += [
"backend/rs_surface_frame_ohos_raster.cpp",
"backend/rs_surface_ohos_raster.cpp",
"rs_surface_frame_ohos.cpp",
"rs_surface_ohos.cpp",
]
if (ace_enable_gpu) {
if (graphic_2d_feature_enable_vulkan) {
sources += [
"backend/native_buffer_utils.cpp",
"backend/rs_surface_frame_ohos_vulkan.cpp",
"backend/rs_surface_ohos_vulkan.cpp",
"backend/rs_vulkan_context.cpp",
]
}
if (graphic_2d_feature_enable_opengl) {
sources += [
"backend/rs_surface_frame_ohos_gl.cpp",
"backend/rs_surface_ohos_gl.cpp",
]
}
sources += [
"backend/rs_surface_frame_ohos_raster.cpp",
"backend/rs_surface_ohos_raster.cpp",
"rs_surface_frame_ohos.cpp",
"rs_surface_ohos.cpp",
]
if (ace_enable_gpu) {
if (graphic_2d_feature_enable_vulkan) {
sources += [
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/cache_data.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/memory_handler.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/render_context.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/shader_cache.cpp",
"backend/native_buffer_utils.cpp",
"backend/rs_surface_frame_ohos_vulkan.cpp",
"backend/rs_surface_ohos_vulkan.cpp",
"backend/rs_vulkan_context.cpp",
]
}
if (graphic_2d_feature_enable_opengl) {
sources += [
"backend/rs_surface_frame_ohos_gl.cpp",
"backend/rs_surface_ohos_gl.cpp",
]
}
sources += [
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/cache_data.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/memory_handler.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/render_context.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/shader_cache.cpp",
]
}
include_dirs = [
@ -124,10 +119,6 @@ ohos_source_set("rosen_ohos_sources") {
"$graphic_2d_root/rosen/modules/composer/vsync:libvsync",
]
if (defined(use_new_render_context) && use_new_render_context) {
defines += [ "NEW_RENDER_CONTEXT" ]
}
if (rs_enable_gpu) {
include_dirs += [ "$graphic_2d_root/interfaces/inner_api/common" ]

View File

@ -36,9 +36,6 @@
#include "ipc_callbacks/rs_uiextension_callback_stub.h"
#include "platform/common/rs_log.h"
#include "platform/common/rs_system_properties.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_backend/rs_surface_factory.h"
#endif
#include "render/rs_typeface_cache.h"
#include "rs_render_service_connect_hub.h"
#include "rs_surface_ohos.h"
@ -126,11 +123,7 @@ bool RSRenderServiceClient::CreateNode(const RSSurfaceRenderNodeConfig& config)
return renderService->CreateNode(config);
}
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> RSRenderServiceClient::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config)
#else
std::shared_ptr<RSSurface> RSRenderServiceClient::CreateNodeAndSurface(const RSSurfaceRenderNodeConfig& config)
#endif
{
auto renderService = RSRenderServiceConnectHub::GetRenderService();
if (renderService == nullptr) {
@ -140,13 +133,6 @@ std::shared_ptr<RSSurface> RSRenderServiceClient::CreateNodeAndSurface(const RSS
return CreateRSSurface(surface);
}
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RSRenderSurface> RSRenderServiceClient::CreateRSSurface(const sptr<Surface> &surface)
{
std::shared_ptr<RSRenderSurface> producer = RSSurfaceFactory::CreateRSSurface(PlatformName::OHOS, surface);
return producer;
}
#else
std::shared_ptr<RSSurface> RSRenderServiceClient::CreateRSSurface(const sptr<Surface> &surface)
{
#if defined (ACE_ENABLE_VK)
@ -162,7 +148,6 @@ std::shared_ptr<RSSurface> RSRenderServiceClient::CreateRSSurface(const sptr<Sur
#endif
return std::make_shared<RSSurfaceOhosRaster>(surface); // CPU render
}
#endif
std::shared_ptr<VSyncReceiver> RSRenderServiceClient::CreateVSyncReceiver(
const std::string& name,

View File

@ -15,30 +15,15 @@
#include "platform/common/rs_log.h"
#include "platform/common/rs_system_properties.h"
#include "platform/drawing/rs_surface_converter.h"
#if defined(NEW_RENDER_CONTEXT)
#include "render_backend/ohos/rs_render_surface_ohos.h"
#else
#include "rs_surface_ohos.h"
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
#include "platform/ohos/backend/rs_surface_ohos_gl.h"
#ifdef RS_ENABLE_VK
#include "platform/ohos/backend/rs_surface_ohos_vulkan.h"
#endif
#endif
namespace OHOS {
namespace Rosen {
#if defined(NEW_RENDER_CONTEXT)
sptr<Surface> RSSurfaceConverter::ConvertToOhosSurface(std::shared_ptr<RSRenderSurface> surface)
{
if (surface == nullptr) {
ROSEN_LOGE("nullptr input");
return nullptr;
}
auto derivedPtr = std::static_pointer_cast<RSRenderSurfaceOhos>(surface);
return derivedPtr->GetSurfaceOhos();
}
#else
sptr<Surface> RSSurfaceConverter::ConvertToOhosSurface(std::shared_ptr<RSSurface> surface)
{
if (surface == nullptr) {
@ -62,7 +47,6 @@ sptr<Surface> RSSurfaceConverter::ConvertToOhosSurface(std::shared_ptr<RSSurface
auto derivedPtr = std::static_pointer_cast<RSSurfaceOhosRaster>(surface); // cpu render
return derivedPtr->GetSurface();
}
#endif
} // namespace Rosen
} // namespace OHOS

View File

@ -21,7 +21,6 @@ config("export_config") {
"$graphic_2d_root/rosen/modules/render_service_base/include",
"$graphic_2d_root/rosen/modules/render_service_base/src",
]
defines = [ "NEW_RENDER_CONTEXT" ]
}
ohos_static_library("librender_backend") {
@ -46,8 +45,6 @@ ohos_static_library("librender_backend") {
sources = [
"drawing_context.cpp",
"ohos/render_context_ohos_raster.cpp",
"ohos/rs_render_surface_ohos.cpp",
"render_backend_utils.cpp",
"render_context_factory.cpp",
"rs_surface_factory.cpp",
@ -63,7 +60,6 @@ ohos_static_library("librender_backend") {
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/cache_data.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/memory_handler.cpp",
"$graphic_2d_root/rosen/modules/2d_graphics/src/render_context/shader_cache.cpp",
"ohos/render_context_ohos_gl.cpp",
]
include_dirs += [ "//third_party/skia" ]

View File

@ -1,377 +0,0 @@
/*
* Copyright (c) 2023 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 "ohos/render_context_ohos_gl.h"
#include <EGL/egl.h>
#include "platform/common/rs_system_properties.h"
#include "rs_trace.h"
#include "window.h"
#include "utils/log.h"
#include "render_backend_utils.h"
namespace OHOS {
namespace Rosen {
using GetPlatformDisplayExt = PFNEGLGETPLATFORMDISPLAYEXTPROC;
constexpr const char* EGL_EXT_PLATFORM_WAYLAND = "EGL_EXT_platform_wayland";
constexpr const char* EGL_KHR_PLATFORM_WAYLAND = "EGL_KHR_platform_wayland";
constexpr int32_t EGL_CONTEXT_CLIENT_VERSION_NUM = 2;
constexpr char CHARACTER_WHITESPACE = ' ';
constexpr const char* CHARACTER_STRING_WHITESPACE = " ";
constexpr const char* EGL_GET_PLATFORM_DISPLAY_EXT = "eglGetPlatformDisplayEXT";
constexpr const char* EGL_KHR_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
// use functor to call gel*KHR API
static PFNEGLSETDAMAGEREGIONKHRPROC GetEGLSetDamageRegionKHRFunc()
{
static auto func = reinterpret_cast<PFNEGLSETDAMAGEREGIONKHRPROC>(eglGetProcAddress("eglSetDamageRegionKHR"));
return func;
}
static bool CheckEglExtension(const char* extensions, const char* extension)
{
size_t extlen = strlen(extension);
const char* end = extensions + strlen(extensions);
while (extensions < end) {
size_t n = 0;
/* Skip whitespaces, if any */
if (*extensions == CHARACTER_WHITESPACE) {
extensions++;
continue;
}
n = strcspn(extensions, CHARACTER_STRING_WHITESPACE);
/* Compare strings */
if (n == extlen && strncmp(extension, extensions, n) == 0) {
return true; /* Found */
}
extensions += n;
}
/* Not found */
return false;
}
static EGLDisplay GetPlatformEglDisplay(EGLenum platform, EGLNativeDisplayType nativeDisplay,
const EGLint* attributeList)
{
static GetPlatformDisplayExt eglGetPlatformDisplayExt = NULL;
if (!eglGetPlatformDisplayExt) {
const char* extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (extensions &&
(CheckEglExtension(extensions, EGL_EXT_PLATFORM_WAYLAND) ||
CheckEglExtension(extensions, EGL_KHR_PLATFORM_WAYLAND))) {
eglGetPlatformDisplayExt = reinterpret_cast<GetPlatformDisplayExt>(
eglGetProcAddress(EGL_GET_PLATFORM_DISPLAY_EXT));
}
}
if (eglGetPlatformDisplayExt) {
return eglGetPlatformDisplayExt(platform, nativeDisplay, attributeList);
}
return eglGetDisplay(nativeDisplay);
}
RenderContextOhosGl::RenderContextOhosGl() noexcept: nativeWindow_(nullptr), eglDisplay_(EGL_NO_DISPLAY),
eglContext_(EGL_NO_CONTEXT), eglSurface_(EGL_NO_SURFACE), config_(nullptr)
{}
RenderContextOhosGl::~RenderContextOhosGl()
{
if (eglDisplay_ == EGL_NO_DISPLAY) {
return;
}
eglDestroyContext(eglDisplay_, eglContext_);
if (pbufferSurface_ != EGL_NO_SURFACE) {
eglDestroySurface(eglDisplay_, pbufferSurface_);
}
eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(eglDisplay_);
eglReleaseThread();
eglDisplay_ = EGL_NO_DISPLAY;
eglContext_ = EGL_NO_CONTEXT;
eglSurface_ = EGL_NO_SURFACE;
pbufferSurface_ = EGL_NO_SURFACE;
}
void RenderContextOhosGl::Init()
{
if (IsContextReady()) {
LOGD("Egl context has ready initialized");
return;
}
eglDisplay_ = GetPlatformEglDisplay(EGL_PLATFORM_OHOS_KHR, EGL_DEFAULT_DISPLAY, NULL);
if (eglDisplay_ == EGL_NO_DISPLAY) {
LOGW("Failed to create EGLDisplay gl errno : %{public}x", eglGetError());
return;
}
EGLint major, minor;
if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE) {
LOGE("Failed to initialize EGLDisplay");
return;
}
if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE) {
LOGE("Failed to bind OpenGL ES API");
return;
}
unsigned int ret;
EGLint count;
EGLint configAttribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE };
ret = eglChooseConfig(eglDisplay_, configAttribs, &config_, 1, &count);
if (!(ret && static_cast<unsigned int>(count) >= 1)) {
LOGE("Failed to eglChooseConfig");
return;
}
static const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE };
eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, contextAttribs);
if (eglContext_ == EGL_NO_CONTEXT) {
LOGE("Failed to create egl context %{public}x", eglGetError());
return;
}
CreatePbufferSurface();
if (!eglMakeCurrent(eglDisplay_, pbufferSurface_, pbufferSurface_, eglContext_)) {
LOGE("Failed to make current on surface, error is %{public}x", eglGetError());
return;
}
SetEGLState();
LOGD("Init egl render context successfully, version %{public}d.%{public}d", major, minor);
}
bool RenderContextOhosGl::IsContextReady()
{
return eglContext_ != EGL_NO_DISPLAY;
}
void RenderContextOhosGl::MakeCurrent(void* curSurface, void* curContext)
{
EGLSurface surface = EGL_NO_SURFACE;
EGLContext context = EGL_NO_CONTEXT;
if (curSurface != nullptr) {
surface = static_cast<EGLSurface>(curSurface);
}
if (curContext != nullptr) {
context = static_cast<EGLContext>(curContext);
}
if (surface == EGL_NO_SURFACE) {
surface = pbufferSurface_;
}
if (context == EGL_NO_CONTEXT) {
context = eglContext_;
}
if (!eglMakeCurrent(eglDisplay_, surface, surface, context)) {
LOGE("Failed to make current on surface, error is %{public}x", eglGetError());
}
eglSurface_ = surface;
}
void* RenderContextOhosGl::CreateContext(bool share)
{
static const EGLint context_attribs[] = {EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE};
EGLContext context = EGL_NO_CONTEXT;
if (!share) {
context = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, context_attribs);
} else {
std::unique_lock<std::mutex> lock(shareContextMutex_);
context = eglCreateContext(eglDisplay_, config_, eglContext_, context_attribs);
}
return static_cast<void*>(context);
}
bool RenderContextOhosGl::CreateSurface(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to create surface, frame is invalid");
return false;
}
std::shared_ptr<SurfaceConfig> surfaceConfig = frame->surfaceConfig;
if (surfaceConfig->nativeWindow == nullptr) {
sptr<Surface> producer = surfaceConfig->producer;
surfaceConfig->nativeWindow = CreateNativeWindowFromSurface(&producer);
nativeWindow_ = static_cast<EGLNativeWindowType>(surfaceConfig->nativeWindow);
if (!IsContextReady()) {
LOGE("Failed to create surface, EGL context has not initialized");
return false;
}
eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
EGLSurface surface = eglCreateWindowSurface(eglDisplay_, config_, nativeWindow_, NULL);
if (surface == EGL_NO_SURFACE) {
LOGE("Failed to create eglsurface!!! %{public}x", eglGetError());
return false;
}
eglSurface_ = surface;
std::shared_ptr<EGLState> eglState = frame->eglState;
eglState->eglSurface = surface;
}
std::shared_ptr<FrameConfig> frameConfig = frame->frameConfig;
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_FORMAT, frameConfig->pixelFormat);
#ifdef RS_ENABLE_AFBC
if (RSSystemProperties::GetAFBCEnabled()) {
int32_t format = 0;
bool useAFBC = frameConfig->useAFBC;
NativeWindowHandleOpt(surfaceConfig->nativeWindow, GET_FORMAT, &format);
if (format == GRAPHIC_PIXEL_FMT_RGBA_8888 && useAFBC) {
frameConfig->bufferUsage =
(BUFFER_USAGE_HW_RENDER | BUFFER_USAGE_HW_TEXTURE | BUFFER_USAGE_HW_COMPOSER | BUFFER_USAGE_MEM_DMA);
}
}
#endif
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_USAGE, frameConfig->bufferUsage);
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_BUFFER_GEOMETRY, frameConfig->width, frameConfig->height);
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_COLOR_GAMUT, frameConfig->colorSpace);
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_UI_TIMESTAMP, frameConfig->uiTimestamp);
MakeCurrent(frame->eglState->eglSurface);
return true;
}
void RenderContextOhosGl::DestroySurface(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to destroy surface, frame is invalid");
return;
}
std::shared_ptr<EGLState> eglState = frame->eglState;
auto surface = eglState->eglSurface;
if (eglState->eglSurface == EGL_NO_SURFACE) {
LOGE("Failed to DestroySurface surface, eglSurface is EGL_NO_SURFACE");
return;
}
if (!eglDestroySurface(eglDisplay_, surface)) {
LOGE("Failed to DestroySurface surface, error is %{public}x", eglGetError());
}
eglState->eglSurface = EGL_NO_SURFACE;
}
void RenderContextOhosGl::DamageFrame(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to damage frame, frame is invalid");
return;
}
if ((eglDisplay_ == nullptr) || (eglSurface_ == nullptr)) {
LOGE("Failed to damage frame, eglDisplay or eglSurface is nullptr");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame->frameConfig;
auto& rects = frameConfig->damageRects;
size_t size = rects.size();
if (size == 0) {
LOGE("Failed to damage frame, invalid rects size");
return;
}
EGLint eglRect[size * 4]; // 4 is size of RectI.
int index = 0;
for (const RectI& rect : rects) {
eglRect[index * 4] = rect.left_; // 4 is size of RectI.
eglRect[index * 4 + 1] = rect.top_; // 4 is size of RectI.
eglRect[index * 4 + 2] = rect.width_; // 4 is size of RectI, 2 is the index of the width_ subscript.
eglRect[index * 4 + 3] = rect.height_; // 4 is size of RectI, 3 is the index of the height_ subscript.
index++;
}
EGLBoolean ret = GetEGLSetDamageRegionKHRFunc()(eglDisplay_, eglSurface_, eglRect, size);
if (ret == EGL_FALSE) {
LOGE("Failed to damage frame, eglSetDamageRegionKHR is failed");
}
}
int32_t RenderContextOhosGl::GetBufferAge()
{
if ((eglDisplay_ == nullptr) || (eglSurface_ == nullptr)) {
LOGE("Failed to get buffer age, eglDisplay or eglSurface is nullptr");
return EGL_UNKNOWN;
}
EGLint bufferAge = EGL_UNKNOWN;
EGLBoolean ret = eglQuerySurface(eglDisplay_, eglSurface_, EGL_BUFFER_AGE_KHR, &bufferAge);
if (ret == EGL_FALSE) {
LOGE("Failed to get buffer age, eglQuerySurface is failed");
return EGL_UNKNOWN;
}
return static_cast<int32_t>(bufferAge);
}
void RenderContextOhosGl::SwapBuffers(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
RS_TRACE_FUNC();
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to swap buffers, frame is invalid");
return;
}
std::shared_ptr<EGLState> eglState = frame->eglState;
auto surface = eglState->eglSurface;
if (!eglSwapBuffers(eglDisplay_, surface)) {
LOGE("Failed to SwapBuffers on surface, error is %{public}x", eglGetError());
} else {
LOGD("SwapBuffers in egl successfully");
}
}
void RenderContextOhosGl::CreatePbufferSurface()
{
const char* extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if ((extensions != nullptr) && (!CheckEglExtension(extensions, EGL_KHR_SURFACELESS_CONTEXT)) &&
(pbufferSurface_ == EGL_NO_SURFACE)) {
EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE};
pbufferSurface_ = eglCreatePbufferSurface(eglDisplay_, config_, attribs);
if (pbufferSurface_ == EGL_NO_SURFACE) {
LOGE("Failed to create pbuffer surface");
return;
}
}
}
void RenderContextOhosGl::SetEGLState()
{
if (frame_ == nullptr) {
LOGE("Failed to set egl state, frame_ is nullptr");
return;
}
std::shared_ptr<EGLState> eglState = frame_->eglState;
if (eglState == nullptr) {
LOGE("Failed to set egl state, frame_->eglState is nullptr");
return;
}
eglState->eglDisplay = eglDisplay_;
eglState->eglContext = eglContext_;
LOGD("Set egl state successfully");
}
}
}

View File

@ -1,129 +0,0 @@
/*
* Copyright (c) 2023 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 "ohos/render_context_ohos_raster.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkSurface.h"
#include "sync_fence.h"
#include "utils/log.h"
#include "render_backend_utils.h"
namespace OHOS {
namespace Rosen {
void RenderContextOhosRaster::Init()
{
}
RenderContextOhosRaster::~RenderContextOhosRaster()
{
frame_ = nullptr;
}
bool RenderContextOhosRaster::CreateSurface(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to create surface, frame is invalid");
return false;
}
std::shared_ptr<FrameConfig> frameConfig = frame->frameConfig;
frameConfig->requestConfig.width = frameConfig->width;
frameConfig->requestConfig.height = frameConfig->height;
frameConfig->requestConfig.usage = frameConfig->bufferUsage;
frameConfig->requestConfig.format = frameConfig->pixelFormat;
frameConfig->flushConfig.damage.w = frameConfig->width;
frameConfig->flushConfig.damage.h = frameConfig->height;
frameConfig->releaseFence = -1;
std::shared_ptr<SurfaceConfig> surfaceConfig = frame->surfaceConfig;
if (surfaceConfig->producer == nullptr) {
LOGE("Failed to create surface, producer is nullptr");
return false;
}
SurfaceError err = surfaceConfig->producer->RequestBuffer(frameConfig->buffer, frameConfig->releaseFence,
frameConfig->requestConfig);
if (err != SURFACE_ERROR_OK) {
LOGE("Failed to create surface, error is : %{public}s", SurfaceErrorStr(err).c_str());
return false;
}
if (frameConfig->buffer == nullptr) {
LOGE("Failed to create surface, producer is nullptr");
return false;
}
err = frameConfig->buffer->Map();
if (err != SURFACE_ERROR_OK) {
LOGE("Failed to create surface, map failed, error is : %{public}s", SurfaceErrorStr(err).c_str());
return false;
}
sptr<SyncFence> tempFence = new SyncFence(frameConfig->releaseFence);
int res = tempFence->Wait(3000);
if (res < 0) {
LOGE("Failed to create surface, this buffer is not available");
}
return true;
}
void RenderContextOhosRaster::DamageFrame(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to damage frame, frame is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame->frameConfig;
std::vector<RectI> damageRects = frameConfig->damageRects;
if (damageRects.size() == 0) {
LOGE("Failed to damage frame, damageRects is empty");
return;
}
frameConfig->flushConfig.damage.x = damageRects[0].left_;
frameConfig->flushConfig.damage.y = damageRects[0].top_;
frameConfig->flushConfig.damage.w = damageRects[0].width_;
frameConfig->flushConfig.damage.h = damageRects[0].height_;
}
void RenderContextOhosRaster::SwapBuffers(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to swap buffers, frame is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame->frameConfig;
frameConfig->flushConfig.timestamp = static_cast<int64_t>(frameConfig->uiTimestamp);
std::shared_ptr<SurfaceConfig> surfaceConfig = frame->surfaceConfig;
if (surfaceConfig->producer == nullptr) {
LOGE("Failed to swap buffers, producer is nullptr");
return;
}
SurfaceError err = surfaceConfig->producer->FlushBuffer(frameConfig->buffer, -1, frameConfig->flushConfig);
if (err != SURFACE_ERROR_OK) {
LOGE("Failed to swap buffers, error is : %s", SurfaceErrorStr(err).c_str());
return;
}
LOGD("SwapBuffers in raster successfully");
}
}
}

View File

@ -1,113 +0,0 @@
/*
* Copyright (c) 2023 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 "ohos/render_context_ohos_vk.h"
#include "rs_trace.h"
#include "utils/log.h"
#include "window.h"
#include "render_backend_utils.h"
namespace OHOS {
namespace Rosen {
RenderContextOhosVk::~RenderContextOhosVk()
{
vulkanWindow_ = nullptr;
}
void RenderContextOhosVk::Init()
{
vulkan::VulkanWindow::InitializeVulkan();
}
bool RenderContextOhosVk::IsContextReady()
{
return vulkanWindow_ != nullptr;
}
bool RenderContextOhosVk::CreateSurface(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (!RenderBackendUtils::IsValidFrame(frame)) {
LOGE("Failed to create surface, frame is invalid");
return false;
}
std::shared_ptr<SurfaceConfig> surfaceConfig = frame->surfaceConfig;
if (surfaceConfig->producer == nullptr) {
LOGE("Failed to create surface, producer is nullptr");
return false;
}
if (surfaceConfig->nativeWindow == nullptr) {
sptr<Surface> producer = surfaceConfig->producer;
surfaceConfig->nativeWindow = CreateNativeWindowFromSurface(&producer);
if (surfaceConfig->nativeWindow == nullptr) {
LOGE("Failed to create surface, native window is nullptr");
return false;
}
}
std::shared_ptr<FrameConfig> frameConfig = frame->frameConfig;
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_FORMAT, frameConfig->pixelFormat);
#ifdef RS_ENABLE_AFBC
if (RSSystemProperties::GetAFBCEnabled()) {
int32_t format = 0;
bool useAFBC = frameConfig->useAFBC;
NativeWindowHandleOpt(surfaceConfig->nativeWindow, GET_FORMAT, &format);
if (format == GRAPHIC_PIXEL_FMT_RGBA_8888 && useAFBC) {
frameConfig->bufferUsage =
(BUFFER_USAGE_HW_RENDER | BUFFER_USAGE_HW_TEXTURE | BUFFER_USAGE_HW_COMPOSER | BUFFER_USAGE_MEM_DMA);
}
}
#endif
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_USAGE, frameConfig->bufferUsage);
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_BUFFER_GEOMETRY, frameConfig->width, frameConfig->height);
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_COLOR_GAMUT, frameConfig->colorSpace);
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_UI_TIMESTAMP, frameConfig->uiTimestamp);
VulkanState* vulkanState = frame->vulkanState;
if (vulkanState == nullptr) {
LOGE("Failed to acquire surface in vulkan, vulkanState is nullptr");
return nullptr;
}
if (vulkanState->vulkanWindow == nullptr) {
auto vulkanSurface = std::make_unique<vulkan::VulkanNativeSurfaceOHOS>(surfaceConfig->nativeWindow);
vulkanState->vulkanWindow = std::make_unique<vulkan::VulkanWindow>(std::move(vulkanSurface));
}
return true;
}
void RenderContextOhosVk::DamageFrame(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
LOGI("Failed to damage frame, not support now");
}
int32_t RenderContextOhosVk::GetBufferAge()
{
LOGI("Failed to get buffer age, not support now");
return -1;
}
void RenderContextOhosVk::SwapBuffers(const std::shared_ptr<RSRenderSurfaceFrame>& frame)
{
if (IsContextReady()) {
vulkanWindow_->SwapBuffers();
LOGD("SwapBuffers in vulkan successfully");
} else {
LOGE("Failed to swap buffers, vulkanWindow_ is nullptr");
}
}
}
}

View File

@ -1,332 +0,0 @@
/*
* Copyright (c) 2023 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 "ohos/rs_render_surface_ohos.h"
#include "include/core/SkSurface.h"
#include "utils/log.h"
#include "rs_trace.h"
#include "window.h"
#if !defined(NEW_SKIA)
#include "memory/rs_tag_tracker.h"
#endif
#include "render_backend_utils.h"
namespace OHOS {
namespace Rosen {
RSRenderSurfaceOhos::RSRenderSurfaceOhos(const sptr<Surface>& surface,
const std::shared_ptr<DrawingContext>& drawingContext)
{
drawingContext_ = drawingContext;
frame_ = std::make_shared<RSRenderSurfaceFrame>();
std::shared_ptr<FrameConfig> frameConfig = std::make_shared<FrameConfig>();
std::shared_ptr<SurfaceConfig> surfaceConfig = std::make_shared<SurfaceConfig>();
std::shared_ptr<EGLState> eglState = std::make_shared<EGLState>();
surfaceConfig->producer = surface;
frame_->frameConfig = frameConfig;
frame_->surfaceConfig = surfaceConfig;
frame_->eglState = eglState;
}
RSRenderSurfaceOhos::~RSRenderSurfaceOhos()
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to ~RSRenderSurfaceOhos, frame_ is invalid");
return;
}
std::shared_ptr<SurfaceConfig> surfaceConfig = frame_->surfaceConfig;
if (surfaceConfig->nativeWindow != nullptr) {
DestoryNativeWindow(surfaceConfig->nativeWindow);
surfaceConfig->nativeWindow = nullptr;
}
if (renderContext_ != nullptr) {
renderContext_->DestroySurface(frame_);
}
frame_ = nullptr;
drawingContext_ = nullptr;
renderContext_ = nullptr;
}
bool RSRenderSurfaceOhos::IsValid() const
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to check surface is valid, frame_ is invalid");
return false;
}
return frame_->surfaceConfig->producer != nullptr;
}
sptr<Surface> RSRenderSurfaceOhos::GetSurfaceOhos() const
{
if (!IsValid()) {
LOGE("Failed to get ohos render surface, render surface is invalid");
return nullptr;
}
return frame_->surfaceConfig->producer;
}
uint32_t RSRenderSurfaceOhos::GetQueueSize() const
{
sptr<Surface> producer = GetSurfaceOhos();
if (producer == nullptr) {
LOGE("Failed to get queue size, render surface is invalid");
return 0;
}
return producer->GetQueueSize();
}
std::shared_ptr<RSRenderSurfaceFrame> RSRenderSurfaceOhos::RequestFrame(
int32_t width, int32_t height, uint64_t uiTimestamp, bool useAFBC)
{
if (renderContext_ == nullptr) {
LOGE("Failed to request frame, renderContext_ is nullptr");
return nullptr;
}
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to request frame, frame_ is invalid");
return nullptr;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
frameConfig->width = width;
frameConfig->height = height;
frameConfig->uiTimestamp = uiTimestamp;
frameConfig->useAFBC = useAFBC;
frameConfig->skSurface = nullptr;
std::shared_ptr<SurfaceConfig> surfaceConfig = frame_->surfaceConfig;
if (surfaceConfig->producer == nullptr) {
LOGE("Failed to request frame, surfaceConfig->producer is invalid");
return nullptr;
}
bool isSuccess = renderContext_->CreateSurface(frame_);
if (!isSuccess) {
LOGE("Failed to request frame, create surface by renderContext_ failed");
return nullptr;
}
LOGD("Request frame successfully, width is %{public}d, height is %{public}d", width, height);
return frame_;
}
bool RSRenderSurfaceOhos::FlushFrame(uint64_t uiTimestamp)
{
if (renderContext_ == nullptr) {
LOGE("Failed to flush frame, renderContext_ is nullptr");
return false;
}
// gles render flush
RenderType renderType = renderContext_->GetRenderType();
if (renderType == RenderType::GLES) {
RenderFrame();
}
renderContext_->SwapBuffers(frame_);
LOGD("FlushFrame successfully");
return true;
}
void RSRenderSurfaceOhos::SetUiTimeStamp(uint64_t uiTimestamp)
{
if (renderContext_ == nullptr) {
LOGE("Failed to set ui timestamp, renderContext_ is nullptr");
return;
}
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to set ui timestamp, frame_ is invalid");
return;
}
RenderType renderType = renderContext_->GetRenderType();
struct timespec curTime = {0, 0};
clock_gettime(CLOCK_MONOTONIC, &curTime);
// 1000000000 is used for transfer second to nsec
uint64_t duration = static_cast<uint64_t>(curTime.tv_sec) * 1000000000 + static_cast<uint64_t>(curTime.tv_nsec);
std::shared_ptr<SurfaceConfig> surfaceConfig = frame_->surfaceConfig;
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
if (renderType == RenderType::GLES || renderType == RenderType::VULKAN) {
NativeWindowHandleOpt(surfaceConfig->nativeWindow, SET_UI_TIMESTAMP, duration);
} else {
if (frameConfig->buffer == nullptr) {
LOGE("Failed to set ui timestamp, frameConfig buffer is nullptr");
return;
}
if (frameConfig->buffer->GetExtraData() == nullptr) {
LOGE("Failed to set ui timestamp, frame_->buffer_->GetExtraData is nullptr");
return;
}
GSError ret = frameConfig->buffer->GetExtraData()->ExtraSet("timeStamp", static_cast<int64_t>(duration));
if (ret != GSERROR_OK) {
LOGE("Failed to set ui timestamp, frame buffer get ExtraSet failed");
}
}
}
void RSRenderSurfaceOhos::SetDamageRegion(const std::vector<RectI>& rects)
{
if (renderContext_ == nullptr) {
LOGE("Failed to set damage region, renderContext_ is nullptr");
return;
}
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to set damage region, frame_ is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
frameConfig->damageRects = rects;
renderContext_->DamageFrame(frame_);
}
int32_t RSRenderSurfaceOhos::GetBufferAge()
{
if (renderContext_ == nullptr) {
LOGE("Failed to set damage region, renderContext_ is nullptr");
return 0;
}
return renderContext_->GetBufferAge();
}
void RSRenderSurfaceOhos::ClearBuffer()
{
if (renderContext_ == nullptr) {
LOGE("Failed to clear buffer, renderContext_ is nullptr");
return;
}
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to clear buffer, frame_ is invalid");
return;
}
std::shared_ptr<SurfaceConfig> surfaceConfig = frame_->surfaceConfig;
DestoryNativeWindow(surfaceConfig->nativeWindow);
surfaceConfig->nativeWindow = nullptr;
renderContext_->MakeCurrent();
renderContext_->DestroySurface(frame_);
if (!IsValid()) {
LOGE("Failed to clear buffer, render surface is invalid");
return;
}
surfaceConfig->producer->GoBackground();
LOGD("Clear buffer successfully");
}
SkCanvas* RSRenderSurfaceOhos::GetCanvas()
{
sk_sp<SkSurface> skSurface = GetSurface();
if (skSurface == nullptr) {
LOGE("Failed to get canvas, skSurface is nullptr");
return nullptr;
}
return skSurface->getCanvas();
}
sk_sp<SkSurface> RSRenderSurfaceOhos::GetSurface()
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to get surface, frame_ is invalid");
return nullptr;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
if (frameConfig->skSurface == nullptr) {
if (drawingContext_ == nullptr) {
LOGE("Failed to get surface, drawingContext_ is nullptr");
return nullptr;
}
drawingContext_->SetUpDrawingContext();
frameConfig->skSurface = drawingContext_->AcquireSurface(frame_);
}
return frameConfig->skSurface;
}
GraphicColorGamut RSRenderSurfaceOhos::GetColorSpace()
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to get color space, frame_ is invalid");
return GraphicColorGamut::GRAPHIC_COLOR_GAMUT_SRGB;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
return frameConfig->colorSpace;
}
void RSRenderSurfaceOhos::SetColorSpace(GraphicColorGamut colorSpace)
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to set color space, frame_ is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
frameConfig->colorSpace = colorSpace;
}
void RSRenderSurfaceOhos::SetSurfaceBufferUsage(uint64_t usage)
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to set surface buffer usage, frame_ is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
frameConfig->bufferUsage = usage;
}
void RSRenderSurfaceOhos::SetSurfacePixelFormat(uint64_t pixelFormat)
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to set suface pixel format, frame_ is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
frameConfig->pixelFormat = pixelFormat;
}
void RSRenderSurfaceOhos::SetReleaseFence(const int32_t& fence)
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to set release fence, frame_ is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
frameConfig->releaseFence = fence;
}
int32_t RSRenderSurfaceOhos::GetReleaseFence() const
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to get release fence, frame_ is invalid");
return -1;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
return frameConfig->releaseFence;
}
void RSRenderSurfaceOhos::RenderFrame()
{
if (!RenderBackendUtils::IsValidFrame(frame_)) {
LOGE("Failed to render frame, frame_ is invalid");
return;
}
std::shared_ptr<FrameConfig> frameConfig = frame_->frameConfig;
if (frameConfig->skSurface == nullptr) {
LOGE("Failed to render frame, frameConfig skSurface is nullptr");
return;
}
RS_TRACE_FUNC();
if (frameConfig->skSurface->getCanvas() != nullptr) {
LOGD("Render frame successfully");
frameConfig->skSurface->getCanvas()->flush();
} else {
LOGE("Failed to render frame, canvas is nullptr");
}
}
}
}

View File

@ -259,10 +259,6 @@ template("render_service_client_source_set") {
defines += tp_defines
}
if (defined(use_new_render_context) && use_new_render_context) {
public_deps += [ "$graphic_2d_root/rosen/modules/render_service_base/src/render_backend:librender_backend" ]
}
public_configs = [ ":render_service_client_config" ]
part_name = "graphic_2d"

View File

@ -148,13 +148,11 @@ RSRenderThread::RSRenderThread()
RSRenderThread::~RSRenderThread()
{
Stop();
#ifndef NEW_RENDER_CONTEXT
if (renderContext_ != nullptr) {
ROSEN_LOGD("Destroy renderContext!!");
delete renderContext_;
renderContext_ = nullptr;
}
#endif
}
void RSRenderThread::Start()
@ -229,20 +227,6 @@ int32_t RSRenderThread::GetTid()
void RSRenderThread::CreateAndInitRenderContextIfNeed()
{
#if defined(NEW_RENDER_CONTEXT)
#if !defined(ROSEN_PREVIEW)
if (renderContext_ == nullptr) {
renderContext_ = RenderContextBaseFactory::CreateRenderContext();
drawingContext_ = std::make_shared<Rosen::DrawingContext>(renderContext_->GetRenderType());
RS_TRACE_NAME("Init Context");
renderContext_->Init(); // init egl context on RT
if (!cacheDir_.empty()) {
ShaderCache::Instance().SetFilePath(cacheDir_);
}
ROSEN_LOGD("Create and Init RenderContext");
}
#endif
#else
#if (defined(RS_ENABLE_GL) || defined (RS_ENABLE_VK)) && !defined(ROSEN_PREVIEW)
if (renderContext_ == nullptr) {
renderContext_ = new RenderContext();
@ -265,7 +249,6 @@ void RSRenderThread::CreateAndInitRenderContextIfNeed()
#endif
}
#endif
#endif
}
void RSRenderThread::RenderLoop()

View File

@ -30,12 +30,7 @@
#include "pipeline/rs_canvas_render_node.h"
#include "pipeline/rs_render_thread_visitor.h"
#include "platform/drawing/rs_vsync_client.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_backend/render_context_factory.h"
#include "drawing_context.h"
#else
#include "render_context/render_context.h"
#endif
#include "transaction/rs_transaction_proxy.h"
#include "vsync_receiver.h"
@ -60,21 +55,10 @@ public:
int32_t GetTid();
std::string DumpRenderTree() const;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RenderContextBase> GetRenderContext() const
{
return renderContext_;
}
std::shared_ptr<DrawingContext> GetDrawingContext() const
{
return drawingContext_;
}
#else
RenderContext* GetRenderContext()
{
return renderContext_;
}
#endif
RSContext& GetContext()
{
return *context_;
@ -177,12 +161,7 @@ private:
std::shared_ptr<RSContext> context_;
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RenderContextBase> renderContext_;
std::shared_ptr<Rosen::DrawingContext> drawingContext_;
#else
RenderContext* renderContext_ = nullptr;
#endif
std::shared_ptr<HighContrastObserver> highContrastObserver_;
std::atomic_bool isHighContrastEnabled_ = false;

View File

@ -33,11 +33,7 @@
#include "pipeline/rs_root_render_node.h"
#include "pipeline/rs_surface_render_node.h"
#include "platform/common/rs_log.h"
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "transaction/rs_transaction_proxy.h"
#include "ui/rs_surface_extractor.h"
#include "ui/rs_surface_node.h"
@ -303,26 +299,13 @@ void RSRenderThreadVisitor::DrawDirtyRegion()
}
}
}
#ifdef NEW_RENDER_CONTEXT
void RSRenderThreadVisitor::UpdateDirtyAndSetEGLDamageRegion(std::shared_ptr<RSRenderSurface>& surface)
#else
void RSRenderThreadVisitor::UpdateDirtyAndSetEGLDamageRegion(std::unique_ptr<RSSurfaceFrame>& surfaceFrame)
#endif
{
RS_TRACE_BEGIN("UpdateDirtyAndSetEGLDamageRegion");
#ifdef RS_ENABLE_EGLQUERYSURFACE
if (isEglSetDamageRegion_) {
// get and update valid buffer age(>0) to merge history
#if defined(NEW_RENDER_CONTEXT)
if (surface == nullptr) {
ROSEN_LOGE("Failed to UpdateDirtyAndSetEGLDamageRegion, surface is nullptr");
return;
}
int32_t bufferAge = surface->GetBufferAge();
#else
int32_t bufferAge = surfaceFrame->GetBufferAge();
#endif
if (!curDirtyManager_->SetBufferAge(bufferAge)) {
ROSEN_LOGD("ProcessRootRenderNode SetBufferAge with invalid buffer age %{public}d", bufferAge);
curDirtyManager_->ResetDirtyAsSurfaceSize();
@ -335,14 +318,8 @@ void RSRenderThreadVisitor::UpdateDirtyAndSetEGLDamageRegion(std::unique_ptr<RSS
// get dirty rect coordinated from upper left to lower left corner in current surface
RectI dirtyRectFlip = curDirtyManager_->GetRectFlipWithinSurface(curDirtyRegion_);
// set dirty rect as eglSurfaceFrame's damage region
#if defined(NEW_RENDER_CONTEXT)
std::vector<RectI> dirtyRects;
dirtyRects.push_back(dirtyRectFlip);
surface->SetDamageRegion(dirtyRects);
#else
surfaceFrame->SetDamageRegion(dirtyRectFlip.left_, dirtyRectFlip.top_, dirtyRectFlip.width_,
dirtyRectFlip.height_);
#endif
// flip aligned rect for op drops
curDirtyRegion_ = curDirtyManager_->GetRectFlipWithinSurface(dirtyRectFlip);
ROSEN_LOGD("GetPartialRenderEnabled buffer age %{public}d, dirtyRectFlip ="
@ -414,11 +391,7 @@ void RSRenderThreadVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
}
auto surfaceNodeColorSpace = ptr->GetColorSpace();
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(ptr);
#else
std::shared_ptr<RSSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(ptr);
#endif
if (rsSurface == nullptr) {
ROSEN_LOGE("ProcessRoot %{public}s: No RSSurface found", ptr->GetName().c_str());
return;
@ -433,13 +406,7 @@ void RSRenderThreadVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
}
#if defined(ACE_ENABLE_GL) || defined (ACE_ENABLE_VK)
#if defined(NEW_RENDER_CONTEXT)
std::shared_ptr<RenderContextBase> rc = RSRenderThread::Instance().GetRenderContext();
std::shared_ptr<DrawingContext> dc = RSRenderThread::Instance().GetDrawingContext();
rsSurface->SetDrawingContext(dc);
#else
RenderContext* rc = RSRenderThread::Instance().GetRenderContext();
#endif
rsSurface->SetRenderContext(rc);
#endif
@ -527,11 +494,7 @@ void RSRenderThreadVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
!(gravityMatrix == Drawing::Matrix())) {
curDirtyManager_->ResetDirtyAsSurfaceSize();
}
#ifdef NEW_RENDER_CONTEXT
UpdateDirtyAndSetEGLDamageRegion(rsSurface);
#else
UpdateDirtyAndSetEGLDamageRegion(surfaceFrame);
#endif
if (isOpDropped_) {
canvas_->ClipRect(Drawing::Rect(curDirtyRegion_.GetLeft(), curDirtyRegion_.GetTop(),
@ -591,11 +554,7 @@ void RSRenderThreadVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
RS_TRACE_BEGIN(ptr->GetName() + " rsSurface->FlushFrame");
ROSEN_LOGD("RSRenderThreadVisitor FlushFrame surfaceNodeId = %{public}" PRIu64 ", uiTimestamp = %{public}" PRIu64,
node.GetRSSurfaceNodeId(), uiTimestamp_);
#ifdef NEW_RENDER_CONTEXT
rsSurface->FlushFrame(uiTimestamp_);
#else
rsSurface->FlushFrame(surfaceFrame, uiTimestamp_);
#endif
#ifdef ROSEN_OHOS
FrameCollector::GetInstance().MarkFrameEvent(FrameEventType::FlushEnd);
#endif

View File

@ -71,11 +71,7 @@ private:
int strokeWidth = 6);
void DrawDirtyRegion();
// Update damageRegion based on buffer age, and then set it through egl api
#ifdef NEW_RENDER_CONTEXT
void UpdateDirtyAndSetEGLDamageRegion(std::shared_ptr<RSRenderSurface>& surface);
#else
void UpdateDirtyAndSetEGLDamageRegion(std::unique_ptr<RSSurfaceFrame>& surfaceFrame);
#endif
// Reset and update children node's info like outOfParent and isRemoveChild
void ResetAndPrepareChildrenNode(RSRenderNode& node, std::shared_ptr<RSBaseRenderNode> nodeParent);
void ProcessSurfaceViewInRT(RSSurfaceRenderNode& node);

View File

@ -19,11 +19,7 @@
namespace OHOS {
namespace Rosen {
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> RSSurfaceExtractor::ExtractRSSurface(std::shared_ptr<RSSurfaceNode> node)
#else
std::shared_ptr<RSSurface> RSSurfaceExtractor::ExtractRSSurface(std::shared_ptr<RSSurfaceNode> node)
#endif
{
if (node == nullptr) {
ROSEN_LOGE("RSSurfaceExtractor::ExtractRSSurface, node is nullptr");

View File

@ -15,11 +15,7 @@
#ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_EXECTOR_H
#define RENDER_SERVICE_CLIENT_CORE_UI_RS_SURFACE_EXECTOR_H
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#endif
#include "ui/rs_surface_node.h"
namespace OHOS {
@ -27,11 +23,7 @@ namespace Rosen {
class RSC_EXPORT RSSurfaceExtractor {
public:
#ifdef NEW_RENDER_CONTEXT
static std::shared_ptr<RSRenderSurface> ExtractRSSurface(std::shared_ptr<RSSurfaceNode> node);
#else
static std::shared_ptr<RSSurface> ExtractRSSurface(std::shared_ptr<RSSurfaceNode> node);
#endif
};
} // namespace Rosen
} // namespace OHOS

View File

@ -29,11 +29,7 @@
#ifndef ROSEN_CROSS_PLATFORM
#include "platform/drawing/rs_surface_converter.h"
#endif
#ifdef NEW_RENDER_CONTEXT
#include "render_context_base.h"
#else
#include "render_context/render_context.h"
#endif
#include "transaction/rs_render_service_client.h"
#include "transaction/rs_transaction_proxy.h"
#include "ui/rs_hdr_manager.h"

View File

@ -30,12 +30,8 @@
#include "surface_delegate.h"
#endif
#ifdef NEW_RENDER_CONTEXT
#include "rs_render_surface.h"
#else
#include "platform/drawing/rs_surface.h"
#include "platform/common/rs_surface_ext.h"
#endif
#include "transaction/rs_transaction_proxy.h"
#include "ui/rs_node.h"
@ -173,11 +169,7 @@ private:
void CreateTextureExportRenderNodeInRT() override;
void SetIsTextureExportNode(bool isTextureExportNode);
std::pair<std::string, std::string> SplitSurfaceNodeName(std::string surfaceNodeName);
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> surface_;
#else
std::shared_ptr<RSSurface> surface_;
#endif
std::string name_;
std::string bundleName_;
mutable std::mutex mutex_;

View File

@ -36,9 +36,6 @@
#include "ui/rs_root_node.h"
#include "ui/rs_surface_extractor.h"
#include "ui/rs_surface_node.h"
#ifdef NEW_RENDER_CONTEXT
#include "render_context/memory_handler.h"
#endif
#ifdef _WIN32
#include <windows.h>
@ -165,11 +162,7 @@ void RSUIDirector::GoBackground(bool isTextureExport)
// clean bufferQueue cache
RSRenderThread::Instance().PostTask([surfaceNode]() {
if (surfaceNode != nullptr) {
#ifdef NEW_RENDER_CONTEXT
std::shared_ptr<RSRenderSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(surfaceNode);
#else
std::shared_ptr<RSSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(surfaceNode);
#endif
if (rsSurface == nullptr) {
ROSEN_LOGE("rsSurface is nullptr");
return;
@ -182,12 +175,7 @@ void RSUIDirector::GoBackground(bool isTextureExport)
auto renderContext = RSRenderThread::Instance().GetRenderContext();
if (renderContext != nullptr) {
#ifndef ROSEN_CROSS_PLATFORM
#if defined(NEW_RENDER_CONTEXT)
auto drawingContext = RSRenderThread::Instance().GetDrawingContext();
MemoryHandler::ClearRedundantResources(drawingContext->GetDrawingContext());
#else
renderContext->ClearRedundantResources();
#endif
#endif
}
});

View File

@ -25,23 +25,11 @@ RSUIShareContext& RSUIShareContext::GetInstance()
EGLContext RSUIShareContext::GetRsRenderContext() const
{
#ifdef NEW_RENDER_CONTEXT
auto context = RSRenderThread::Instance().GetRenderContext();
if (!context) {
return EGL_NO_CONTEXT;
}
auto frame = context->GetRSRenderSurfaceFrame();
if (frame == nullptr || frame->eglState == nullptr) {
return EGL_NO_CONTEXT;
}
return frame->eglState->eglContext;
#else
auto context = RSRenderThread::Instance().GetRenderContext();
if (!context) {
return EGL_NO_CONTEXT;
}
return context->GetEGLContext();
#endif
}
}
}

View File

@ -72,11 +72,7 @@ HWTEST_F(RSSkpCaptureDFXTest, captureTest001, TestSize.Level1)
ASSERT_EQ(capture.recordingCanvas_, nullptr);
}
{
#if defined(NEW_RENDER_CONTEXT)
rtThread.uniRenderEngine_->renderContext_ = std::shared_ptr<RenderContextBase>();
#else
rtThread.uniRenderEngine_->renderContext_ = std::shared_ptr<RenderContext>();
#endif
RSSkpCaptureDfx capture(canvas);
ASSERT_EQ(capture.recordingCanvas_, nullptr);
}

View File

@ -17,11 +17,8 @@
#include "platform/drawing/rs_surface_converter.h"
#include "iconsumer_surface.h"
#if defined(NEW_RENDER_CONTEXT)
#include "render_backend/drawing_context.h"
#else
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
#endif
using namespace testing;
using namespace testing::ext;
@ -48,15 +45,6 @@ void RSSurfaceConverterTest::TearDown() {}
*/
HWTEST_F(RSSurfaceConverterTest, ConvertToOhosSurface, TestSize.Level1)
{
#if defined(NEW_RENDER_CONTEXT)
auto csurf = IConsumerSurface::Create();
auto producer = csurf->GetProducer();
auto pSurface = Surface::CreateSurfaceAsProducer(producer);
RenderType renderType = RenderType::RASTER;
DrawingContext drawingContext(renderType);
std::shared_ptr<RSRenderSurface> surface = std::make_shared<RSRenderSurfaceOhos>(pSurface, drawingContext);
RSSurfaceConverter::ConvertToOhosSurface(surface);
#else
std::shared_ptr<RSSurfaceOhosRaster> surface;
RSSurfaceConverter::ConvertToOhosSurface(surface);
@ -65,7 +53,6 @@ HWTEST_F(RSSurfaceConverterTest, ConvertToOhosSurface, TestSize.Level1)
sptr<Surface> pSurface = Surface::CreateSurfaceAsProducer(producer);
surface = std::make_shared<RSSurfaceOhosRaster>(pSurface);
RSSurfaceConverter::ConvertToOhosSurface(surface);
#endif
ASSERT_TRUE(true);
}
} // namespace Rosen