!17049 rollbackGPU0

Merge pull request !17049 from 郜宇凡/back0
This commit is contained in:
openharmony_ci 2024-11-20 12:37:15 +00:00 committed by Gitee
commit 249aec76c4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
93 changed files with 1029 additions and 226 deletions

View File

@ -24,7 +24,9 @@
#include "boot_compile_progress.h"
#include "boot_player.h"
#include "event_handler.h"
#ifdef RS_ENABLE_GPU
#include <render_context/render_context.h>
#endif
#include <ui/rs_display_node.h>
#include <ui/rs_surface_extractor.h>
#include "util.h"

View File

@ -16,7 +16,9 @@
#ifndef FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILE_PROGRESS_H
#define FRAMEWORKS_BOOTANIMATION_INCLUDE_BOOT_COMPILE_PROGRESS_H
#ifdef RS_ENABLE_GPU
#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

@ -333,7 +333,9 @@ bool CheckImageData(const std::string& fileName, std::shared_ptr<ImageStruct> im
imageStruct->memPtr.setOwnerShip(data);
imageStruct->fileName = fileName;
imageStruct->imageData = std::make_shared<Rosen::Drawing::Image>();
#ifdef RS_ENABLE_GPU
imageStruct->imageData->MakeFromEncoded(data);
#endif
imgVec.push_back(imageStruct);
return true;
}

View File

@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import("//foundation/graphic/graphic_2d/graphic_config.gni")
group("napi_packages") {
deps = [
"graphic/animation/window_animation_manager:windowanimationmanager_napi",
@ -24,9 +22,6 @@ group("napi_packages") {
"graphic/hyper_graphic_manager:libhgmnapi",
"graphic/text:textnapi",
"graphic/ui_effect:uieffect_napi",
"graphic/webgl:libwebglnapi",
]
if (rs_enable_gpu) {
deps += [ "graphic/webgl:libwebglnapi" ]
}
}

View File

@ -26,44 +26,9 @@ ohos_source_set("webgl_src") {
"$graphic_2d_root/interfaces/kits/napi/graphic/webgl/common",
]
sources = [
"common/napi/n_class.cpp",
"common/napi/n_func_arg.cpp",
"common/napi/n_val.cpp",
"src/egl_manager.cpp",
"src/module.cpp",
"src/util.cpp",
"src/webgl2_rendering_context.cpp",
"src/webgl2_rendering_context_base.cpp",
"src/webgl2_rendering_context_impl.cpp",
"src/webgl2_rendering_context_override.cpp",
"src/webgl_active_info.cpp",
"src/webgl_arg.cpp",
"src/webgl_buffer.cpp",
"src/webgl_framebuffer.cpp",
"src/webgl_program.cpp",
"src/webgl_query.cpp",
"src/webgl_renderbuffer.cpp",
"src/webgl_rendering_context.cpp",
"src/webgl_rendering_context_base.cpp",
"src/webgl_rendering_context_base_impl.cpp",
"src/webgl_rendering_context_basic_base.cpp",
"src/webgl_rendering_context_common.cpp",
"src/webgl_rendering_context_draw.cpp",
"src/webgl_rendering_context_ext.cpp",
"src/webgl_rendering_context_overloads.cpp",
"src/webgl_sampler.cpp",
"src/webgl_shader.cpp",
"src/webgl_shader_precision_format.cpp",
"src/webgl_sync.cpp",
"src/webgl_texture.cpp",
"src/webgl_transform_feedback.cpp",
"src/webgl_uniform_location.cpp",
"src/webgl_vertex_array_object.cpp",
]
sources = [ "common/napi/n_class.cpp" ]
external_deps = [
"bounds_checking_function:libsec_shared",
"c_utils:utils",
"egl:libEGL",
"graphic_surface:surface_headers",
@ -72,10 +37,48 @@ ohos_source_set("webgl_src") {
"napi:ace_napi",
]
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
]
if (rs_enable_gpu) {
sources += [
"common/napi/n_func_arg.cpp",
"common/napi/n_val.cpp",
"src/egl_manager.cpp",
"src/module.cpp",
"src/util.cpp",
"src/webgl2_rendering_context.cpp",
"src/webgl2_rendering_context_base.cpp",
"src/webgl2_rendering_context_impl.cpp",
"src/webgl2_rendering_context_override.cpp",
"src/webgl_active_info.cpp",
"src/webgl_arg.cpp",
"src/webgl_buffer.cpp",
"src/webgl_framebuffer.cpp",
"src/webgl_program.cpp",
"src/webgl_query.cpp",
"src/webgl_renderbuffer.cpp",
"src/webgl_rendering_context.cpp",
"src/webgl_rendering_context_base.cpp",
"src/webgl_rendering_context_base_impl.cpp",
"src/webgl_rendering_context_basic_base.cpp",
"src/webgl_rendering_context_common.cpp",
"src/webgl_rendering_context_draw.cpp",
"src/webgl_rendering_context_ext.cpp",
"src/webgl_rendering_context_overloads.cpp",
"src/webgl_sampler.cpp",
"src/webgl_shader.cpp",
"src/webgl_shader_precision_format.cpp",
"src/webgl_sync.cpp",
"src/webgl_texture.cpp",
"src/webgl_transform_feedback.cpp",
"src/webgl_uniform_location.cpp",
"src/webgl_vertex_array_object.cpp",
]
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
]
external_deps += [ "bounds_checking_function:libsec_shared" ]
}
cflags = [
"-Wall",
@ -96,8 +99,12 @@ ohos_source_set("webgl_src") {
ohos_shared_library("libwebglnapi") {
external_deps = [ "hilog:libhilog" ]
deps = [ ":webgl_src" ]
install_enable = true
relative_install_dir = "module"
if (rs_enable_gpu) {
install_enable = true
relative_install_dir = "module"
} else {
install_enable = false
}
part_name = "graphic_2d"
subsystem_name = "graphic"
}

View File

@ -131,6 +131,7 @@ template("graphics2d_source_set") {
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_surface.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_text_blob.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_text_blob_builder.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_texture_info.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_trace_memory_dump.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_typeface.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_utils.cpp",
@ -140,6 +141,7 @@ template("graphics2d_source_set") {
"$drawing_core_src_dir/image/image.cpp",
"$drawing_core_src_dir/image/picture.cpp",
"$drawing_core_src_dir/image/pixmap.cpp",
"$drawing_core_src_dir/image/trace_memory_dump.cpp",
"$drawing_core_src_dir/recording/cmd_list.cpp",
"$drawing_core_src_dir/recording/cmd_list_helper.cpp",
"$drawing_core_src_dir/recording/draw_cmd.cpp",
@ -206,9 +208,7 @@ template("graphics2d_source_set") {
sources += [
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_gpu_context.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_task_executor.cpp",
"$drawing_core_src_dir/engine_adapter/skia_adapter/skia_texture_info.cpp",
"$drawing_core_src_dir/image/gpu_context.cpp",
"$drawing_core_src_dir/image/trace_memory_dump.cpp",
]
defines += [ "RS_ENABLE_GPU" ]

View File

@ -68,6 +68,7 @@ template("drawing_ndk_source_set") {
"$drawing_ndk_src_dir/drawing_font.cpp",
"$drawing_ndk_src_dir/drawing_font_collection.cpp",
"$drawing_ndk_src_dir/drawing_font_mgr.cpp",
"$drawing_ndk_src_dir/drawing_gpu_context.cpp",
"$drawing_ndk_src_dir/drawing_image.cpp",
"$drawing_ndk_src_dir/drawing_image_filter.cpp",
"$drawing_ndk_src_dir/drawing_mask_filter.cpp",
@ -104,7 +105,6 @@ template("drawing_ndk_source_set") {
}
if (rs_enable_gpu) {
defines += [ "RS_ENABLE_GPU" ]
sources += [ "$drawing_ndk_src_dir/drawing_gpu_context.cpp" ]
}
if (is_emulator) {
defines += [ "ROSEN_EMULATOR" ]

View File

@ -28,6 +28,7 @@ static GPUContext* CastToGPUContext(OH_Drawing_GpuContext* cGpuContext)
OH_Drawing_GpuContext* OH_Drawing_GpuContextCreateFromGL(OH_Drawing_GpuContextOptions ops)
{
#ifdef RS_ENABLE_GPU
GPUContextOptions contextOps;
contextOps.SetAllowPathMaskCaching(ops.allowPathMaskCaching);
GPUContext* context = new GPUContext();
@ -37,6 +38,7 @@ OH_Drawing_GpuContext* OH_Drawing_GpuContextCreateFromGL(OH_Drawing_GpuContextOp
}
delete context;
context = nullptr;
#endif
return nullptr;
}

View File

@ -35,15 +35,16 @@ static Surface* CastToSurface(OH_Drawing_Surface* cSurface)
{
return reinterpret_cast<Surface*>(cSurface);
}
#ifdef RS_ENABLE_GPU
static GPUContext* CastToGpuContext(OH_Drawing_GpuContext* cGpuContext)
{
return reinterpret_cast<GPUContext*>(cGpuContext);
}
#endif
OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext(OH_Drawing_GpuContext* cGpuContext,
bool budgeted, OH_Drawing_Image_Info cImageInfo)
{
#ifdef RS_ENABLE_GPU
if (cGpuContext == nullptr) {
g_drawingErrorCode = OH_DRAWING_ERROR_INVALID_PARAMETER;
return nullptr;
@ -58,6 +59,9 @@ OH_Drawing_Surface* OH_Drawing_SurfaceCreateFromGpuContext(OH_Drawing_GpuContext
std::lock_guard<std::mutex> lock(g_surfaceMutex);
g_surfaceMap.insert({surface.get(), surface});
return (OH_Drawing_Surface*)(surface.get());
#else
return nullptr;
#endif
}
OH_Drawing_Canvas* OH_Drawing_SurfaceGetCanvas(OH_Drawing_Surface* cSurface)

View File

@ -61,12 +61,14 @@ void SkiaImage::PostSkImgToTargetThread()
if (skiaImage_ == nullptr) {
return;
}
#ifdef RS_ENABLE_GPU
auto context = as_IB(skiaImage_.get())->directContext();
auto func = SkiaGPUContext::GetPostFunc(sk_ref_sp(context));
if (func) {
auto image = skiaImage_;
func([image]() {});
}
#endif
}
std::shared_ptr<Image> SkiaImage::MakeFromRaster(const Pixmap& pixmap,

View File

@ -57,6 +57,7 @@ std::shared_ptr<Image> SkiaRuntimeShaderBuilder::MakeImage(GPUContext* grContext
if (!skRuntimeShaderBuilder_ || !grContext) {
return nullptr;
}
#ifdef RS_ENABLE_GPU
sk_sp<SkImage> skImage = skRuntimeShaderBuilder_->makeImage(
grContext->GetImpl<SkiaGPUContext>()->GetGrContext().get(),
localMatrix ? &localMatrix->GetImpl<SkiaMatrix>()->ExportSkiaMatrix() : nullptr,
@ -65,6 +66,9 @@ std::shared_ptr<Image> SkiaRuntimeShaderBuilder::MakeImage(GPUContext* grContext
image->GetImpl<SkiaImage>()->SetSkImage(skImage);
return image;
#else
return {};
#endif
}
void SkiaRuntimeShaderBuilder::SetChild(const std::string& name, std::shared_ptr<ShaderEffect> shader)

View File

@ -55,7 +55,6 @@ SkSurface::BackendHandleAccess ConvertToSkiaBackendAccess(BackendAccess access)
}
}
#endif
SkiaSurface::SkiaSurface() {}
void SkiaSurface::PostSkSurfaceToTargetThread()
@ -378,9 +377,9 @@ std::shared_ptr<Image> SkiaSurface::GetImageSnapshot(const RectI& bounds) const
return image;
}
#ifdef RS_ENABLE_GPU
BackendTexture SkiaSurface::GetBackendTexture(BackendAccess access) const
{
#ifdef RS_ENABLE_GPU
if (skSurface_ == nullptr) {
LOGD("skSurface is nullptr");
return {};
@ -400,8 +399,11 @@ BackendTexture SkiaSurface::GetBackendTexture(BackendAccess access) const
backendTexture.SetTextureInfo(SkiaTextureInfo::ConvertToTextureInfo(grBackendTexture));
#endif
return backendTexture;
}
#else
return {};
#endif
}
std::shared_ptr<Surface> SkiaSurface::MakeSurface(int width, int height) const
{

View File

@ -41,7 +41,7 @@ public:
#ifdef RS_ENABLE_GPU
bool Bind(const Image& image) override;
bool Bind(const FrameBuffer& frameBuffer) override;
BackendTexture GetBackendTexture(BackendAccess access) const override;
#ifdef RS_ENABLE_VK
static std::shared_ptr<Surface> MakeFromBackendRenderTarget(GPUContext* gpuContext, const TextureInfo& info,
TextureOrigin origin, ColorType colorType, std::shared_ptr<ColorSpace> colorSpace,
@ -61,6 +61,7 @@ public:
std::shared_ptr<Image> GetImageSnapshot(const RectI& bounds) const override;
std::shared_ptr<Surface> MakeSurface(int width, int height) const override;
std::shared_ptr<Surface> MakeSurface(const ImageInfo& imageInfo) const override;
BackendTexture GetBackendTexture(BackendAccess access) const override;
void SetSkSurface(const sk_sp<SkSurface>& skSurface);
void FlushAndSubmit(bool syncCpu) override;

View File

@ -114,7 +114,7 @@ void SkiaTextureInfo::ConvertToVKTexture(const GrBackendTexture& backendTexture,
info.SetVKTextureInfo(vkInfo);
}
#endif
#ifdef RS_ENABLE_GPU
GrBackendTexture SkiaTextureInfo::ConvertToGrBackendTexture(const TextureInfo& info)
{
#ifdef RS_ENABLE_VK
@ -148,6 +148,7 @@ TextureInfo SkiaTextureInfo::ConvertToTextureInfo(const GrBackendTexture& grBack
delete grGLTextureInfo;
return textureInfo;
}
#endif
} // namespace Drawing
} // namespace Rosen

View File

@ -42,10 +42,11 @@ public:
static void ConvertToVKTexture(const GrBackendTexture& backendTexture, TextureInfo& info);
#endif
#ifdef RS_ENABLE_GPU
static TextureInfo ConvertToTextureInfo(const GrBackendTexture& grBackendTexture);
static GrBackendTexture ConvertToGrBackendTexture(const TextureInfo& info);
#endif
};
} // namespace Drawing
} // namespace Rosen

View File

@ -39,18 +39,13 @@ ohos_source_set("create_pixelmap_surface_src") {
sources = [ "src/pixel_map_from_surface.cpp" ]
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
"$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics",
"$graphic_2d_root/rosen/modules/render_service_base:librender_service_base",
"$graphic_2d_root/utils:scoped_bytrace",
]
if (rs_enable_gpu) {
deps += [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
]
}
external_deps = [ "graphic_surface:sync_fence" ]
subsystem_name = "graphic"

View File

@ -56,6 +56,7 @@ namespace OHOS {
namespace Rosen {
using namespace OHOS::Media;
#ifdef RS_ENABLE_GPU
static sptr<SurfaceBuffer> LocalDmaMemAlloc(const uint32_t &width, const uint32_t &height,
const std::unique_ptr<Media::PixelMap>& pixelmap)
{
@ -94,6 +95,7 @@ static sptr<SurfaceBuffer> LocalDmaMemAlloc(const uint32_t &width, const uint32_
return surfaceBuffer;
#endif
}
#endif
#if defined(RS_ENABLE_GL)
class DmaMem {

View File

@ -99,14 +99,13 @@ if (is_arkui_x) {
}
} else {
ohos_shared_library("skeffectchain") {
public_deps = []
public_deps = [ "$graphic_2d_root/rosen/modules/effect/egl:libegl_effect" ]
if (rs_enable_gpu) {
defines = gpu_defines
public_deps += [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/frameworks/opengl_wrapper:GLESv3",
"$graphic_2d_root/rosen/modules/effect/egl:libegl_effect",
]
}

View File

@ -14,8 +14,10 @@
*/
#ifndef IOS_PLATFORM
#ifdef RS_ENABLE_GPU
#include "egl_manager.h"
#endif
#endif
#if defined(NEW_SKIA)
#include <include/gpu/GrDirectContext.h>
@ -120,7 +122,7 @@ bool SKImageChain::CreateCPUCanvas()
bool SKImageChain::CreateGPUCanvas()
{
#if defined(ACE_ENABLE_GL) && (!defined(IOS_PLATFORM))
#if defined(RS_ENABLE_GL) && (!defined(IOS_PLATFORM))
if (!EglManager::GetInstance().Init()) {
LOGE("Failed to init for GPU.");
return false;

View File

@ -49,25 +49,20 @@ ohos_source_set("graphics_effect_src") {
]
sources = [
"src/ge_aibar_shader_filter.cpp",
"src/ge_grey_shader_filter.cpp",
"src/ge_kawase_blur_shader_filter.cpp",
"src/ge_linear_gradient_blur_shader_filter.cpp",
"src/ge_magnifier_shader_filter.cpp",
"src/ge_mesa_blur_shader_filter.cpp",
"src/ge_render.cpp",
"src/ge_system_properties.cpp",
"src/ge_visual_effect.cpp",
"src/ge_visual_effect_container.cpp",
"src/ge_visual_effect_impl.cpp",
"src/ge_water_ripple_filter.cpp",
]
if (rs_enable_gpu) {
sources += [
"src/ge_aibar_shader_filter.cpp",
"src/ge_grey_shader_filter.cpp",
"src/ge_kawase_blur_shader_filter.cpp",
"src/ge_linear_gradient_blur_shader_filter.cpp",
"src/ge_magnifier_shader_filter.cpp",
"src/ge_water_ripple_filter.cpp",
]
}
deps = [ "$graphic_2d_root/rosen/modules/2d_graphics:2d_graphics" ]
if (is_arkui_x) {
deps += [

View File

@ -48,7 +48,11 @@ std::shared_ptr<Drawing::Image> GEAIBarShaderFilter::ProcessImage(Drawing::Canva
float imageWidth = image->GetWidth();
float imageHeight = image->GetHeight();
auto builder = MakeBinarizationShader(imageWidth, imageHeight, imageShader);
#ifdef RS_ENABLE_GPU
auto invertedImage = builder->MakeImage(canvas.GetGPUContext().get(), nullptr, image->GetImageInfo(), false);
#else
auto invertedImage = builder->MakeImage(nullptr, nullptr, image->GetImageInfo(), false);
#endif
if (invertedImage == nullptr) {
LOGE("GEAIBarShaderFilter::ProcessImage invertedImage is null");
return image;

View File

@ -53,7 +53,11 @@ std::shared_ptr<Drawing::Image> GEGreyShaderFilter::ProcessImage(Drawing::Canvas
builder.SetChild("imageShader", imageShader);
builder.SetUniform("coefficient1", greyCoef1_);
builder.SetUniform("coefficient2", greyCoef2_);
#ifdef RS_ENABLE_GPU
auto greyImage = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, image->GetImageInfo(), false);
#else
auto greyImage = builder.MakeImage(nullptr, nullptr, image->GetImageInfo(), false);
#endif
if (greyImage == nullptr) {
LOGE("DrawGreyAdjustment successful");
return image;

View File

@ -151,8 +151,12 @@ std::shared_ptr<Drawing::ShaderEffect> GEKawaseBlurShaderFilter::ApplySimpleFilt
{
Drawing::RuntimeShaderBuilder simpleBlurBuilder(g_simpleFilter);
simpleBlurBuilder.SetChild("imageInput", prevShader);
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpSimpleBlur(simpleBlurBuilder.MakeImage(
canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpSimpleBlur(simpleBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
return Drawing::ShaderEffect::CreateImageShader(*tmpSimpleBlur, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP,
linear, Drawing::Matrix());
}
@ -199,8 +203,11 @@ std::shared_ptr<Drawing::Image> GEKawaseBlurShaderFilter::ProcessImage(Drawing::
auto offsetXY = radiusByPasses * blurScale_;
SetBlurBuilderParam(blurBuilder, offsetXY, scaledInfo, width, height);
#ifdef RS_ENABLE_GPU
auto tmpBlur(blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
auto tmpBlur(blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
if (!tmpBlur) {
return image;
@ -216,7 +223,11 @@ std::shared_ptr<Drawing::Image> GEKawaseBlurShaderFilter::ProcessImage(Drawing::
// Advanced Filter
auto offsetXYFilter = radiusByPasses * stepScale;
SetBlurBuilderParam(blurBuilder, offsetXYFilter, scaledInfo, width, height);
#ifdef RS_ENABLE_GPU
tmpBlur = blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
tmpBlur = blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
auto output = ScaleAndAddRandomColor(canvas, input, tmpBlur, src, dst, width, height);
@ -406,6 +417,7 @@ Drawing::Matrix GEKawaseBlurShaderFilter::GetShaderTransform(
void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
std::shared_ptr<Drawing::Image>& checkedImage, const Drawing::Rect& src) const
{
#ifdef RS_ENABLE_GPU
auto srcRect = Drawing::RectI(src.GetLeft(), src.GetTop(), src.GetRight(), src.GetBottom());
if (image->GetImageInfo().GetBound() != srcRect) {
auto resizedImage = std::make_shared<Drawing::Image>();
@ -421,6 +433,7 @@ void GEKawaseBlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const st
LOGD("GEKawaseBlurShaderFilter::resize image failed, use original image");
}
}
#endif
}
void GEKawaseBlurShaderFilter::OutputOriginalImage(Drawing::Canvas& canvas,
@ -486,7 +499,11 @@ std::shared_ptr<Drawing::Image> GEKawaseBlurShaderFilter::ScaleAndAddRandomColor
auto scaledInfo = Drawing::ImageInfo(width, height, blurImage->GetImageInfo().GetColorType(),
blurImage->GetImageInfo().GetAlphaType(), blurImage->GetImageInfo().GetColorSpace());
#ifdef RS_ENABLE_GPU
auto output = mixBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
auto output = mixBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
return output;
}

View File

@ -423,7 +423,11 @@ std::shared_ptr<Drawing::Image> GELinearGradientBlurShaderFilter::BuildMeanLinea
hBlurBuilder.SetChild("imageShader", shader1);
hBlurBuilder.SetChild("gradientShader", alphaGradientShader);
std::shared_ptr<Drawing::Image> tmpBlur(
#ifdef RS_ENABLE_GPU
hBlurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
hBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
Drawing::RuntimeShaderBuilder vBlurBuilder(verticalMeanBlurShaderEffect_);
vBlurBuilder.SetUniform("r", radius);
@ -432,19 +436,31 @@ std::shared_ptr<Drawing::Image> GELinearGradientBlurShaderFilter::BuildMeanLinea
vBlurBuilder.SetChild("imageShader", tmpBlurShader);
vBlurBuilder.SetChild("gradientShader", alphaGradientShader);
std::shared_ptr<Drawing::Image> tmpBlur2(
#ifdef RS_ENABLE_GPU
vBlurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
vBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
auto tmpBlur2Shader = Drawing::ShaderEffect::CreateImageShader(
*tmpBlur2, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, linear, m);
hBlurBuilder.SetChild("imageShader", tmpBlur2Shader);
std::shared_ptr<Drawing::Image> tmpBlur3(
#ifdef RS_ENABLE_GPU
hBlurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
hBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
auto tmpBlur3Shader = Drawing::ShaderEffect::CreateImageShader(
*tmpBlur3, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, linear, m);
vBlurBuilder.SetChild("imageShader", tmpBlur3Shader);
std::shared_ptr<Drawing::Image> tmpBlur4(
#ifdef RS_ENABLE_GPU
vBlurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
vBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
return tmpBlur4;
}
@ -476,7 +492,11 @@ std::shared_ptr<Drawing::Image> GELinearGradientBlurShaderFilter::DrawMaskLinear
auto builder = MakeMaskLinearGradientBlurShader(srcImageShader, blurImageShader, alphaGradientShader);
auto outImageInfo = Drawing::ImageInfo(dst.GetWidth(), dst.GetHeight(), blurImage->GetImageInfo().GetColorType(),
blurImage->GetImageInfo().GetAlphaType(), blurImage->GetImageInfo().GetColorSpace());
#ifdef RS_ENABLE_GPU
auto outImage = builder->MakeImage(canvas.GetGPUContext().get(), nullptr, outImageInfo, false);
#else
auto outImage = builder->MakeImage(nullptr, nullptr, outImageInfo, false);
#endif
return outImage;
}

View File

@ -71,7 +71,11 @@ std::shared_ptr<Drawing::Image> GEMagnifierShaderFilter::ProcessImage(Drawing::C
Drawing::Matrix invMatrix;
invMatrix.Rotate(-magnifierPara_->rotateDegree_, src.GetLeft() + src.GetWidth() / 2.0f,
src.GetTop() + src.GetHeight() / 2.0f); // 2.0 center of rect
#ifdef RS_ENABLE_GPU
auto resultImage = builder->MakeImage(canvas.GetGPUContext().get(), &invMatrix, image->GetImageInfo(), false);
#else
auto resultImage = builder->MakeImage(nullptr, &invMatrix, image->GetImageInfo(), false);
#endif
if (resultImage == nullptr) {
LOGE("GEMagnifierShaderFilter::ProcessImage resultImage is null");
return image;

View File

@ -251,8 +251,12 @@ std::shared_ptr<Drawing::ShaderEffect> GEMESABlurShaderFilter::ApplyGreyAdjustme
builder.SetChild("imageShader", prevShader);
builder.SetUniform("coefficient1", greyCoef1_);
builder.SetUniform("coefficient2", greyCoef2_);
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpBlur(builder.MakeImage(
canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpBlur(builder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
return GetShaderEffect(tmpBlur, linear, Drawing::Matrix());
}
@ -283,7 +287,11 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling2X(Drawing::
}
blurBuilder.SetChild("imageInput", tmpShader);
blurBuilder.SetUniform("in_blurOffset", blur.offsets[0], blur.offsets[1]);
#ifdef RS_ENABLE_GPU
return blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
return blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling4X(Drawing::Canvas& canvas,
@ -304,7 +312,11 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling4X(Drawing::
blurBuilder.SetChild("imageInput", tmpShader);
blurBuilder.SetUniform("in_blurOffset", blur.offsets[0], blur.offsets[1]);
}
#ifdef RS_ENABLE_GPU
return blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
return blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling8X(Drawing::Canvas& canvas,
@ -319,8 +331,12 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling8X(Drawing::
blurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*input,
tileMode_, tileMode_, linear, inputMatrix));
blurBuilder.SetUniform("in_blurOffset", BLUR_SCALE_1, BLUR_SCALE_1);
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpBlur_pre(blurBuilder.MakeImage(canvas.GetGPUContext().get(),
nullptr, middleInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpBlur_pre(blurBuilder.MakeImage(nullptr, nullptr, middleInfo, false));
#endif
if (!tmpBlur_pre) {
return nullptr;
}
@ -337,7 +353,11 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling8X(Drawing::
blurBuilder.SetChild("imageInput", tmpShader);
blurBuilder.SetUniform("in_blurOffset", blur.offsets[0], blur.offsets[1]);
} else {
#ifdef RS_ENABLE_GPU
tmpBlur_pre = simpleBlurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
tmpBlur_pre = simpleBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
if (!tmpBlur_pre) {
return nullptr;
}
@ -345,7 +365,11 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling8X(Drawing::
Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, linear, Drawing::Matrix()));
blurBuilder.SetUniform("in_blurOffset", blur.offsets[0], blur.offsets[1]);
}
#ifdef RS_ENABLE_GPU
return blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
return blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSamplingMoreX(Drawing::Canvas& canvas,
@ -360,8 +384,12 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSamplingMoreX(Drawin
blurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*input,
tileMode_, tileMode_, linear, inputMatrix));
blurBuilder.SetUniform("in_blurOffset", BLUR_SCALE_1, BLUR_SCALE_1);
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpBlur_pre(blurBuilder.MakeImage(canvas.GetGPUContext().get(),
nullptr, middleInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpBlur_pre(blurBuilder.MakeImage(nullptr, nullptr, middleInfo, false));
#endif
if (!tmpBlur_pre) {
return nullptr;
}
@ -374,15 +402,27 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSamplingMoreX(Drawin
builder.SetChild("imageShader", blurBuilder.MakeShader(nullptr, input->IsOpaque()));
builder.SetUniform("coefficient1", greyCoef1_);
builder.SetUniform("coefficient2", greyCoef2_);
#ifdef RS_ENABLE_GPU
tmpBlur_pre = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, middleInfo2, false);
#else
tmpBlur_pre = builder.MakeImage(nullptr, nullptr, middleInfo2, false);
#endif
} else {
#ifdef RS_ENABLE_GPU
tmpBlur_pre = blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, middleInfo2, false);
#else
tmpBlur_pre = blurBuilder.MakeImage(nullptr, nullptr, middleInfo2, false);
#endif
}
Drawing::Matrix blurMatrix2 = BuildMiddleMatrix(scaledInfo, middleInfo2);
blurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*tmpBlur_pre,
Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, linear, blurMatrix2));
blurBuilder.SetUniform("in_blurOffset", blur.offsets[0], blur.offsets[1]);
#ifdef RS_ENABLE_GPU
return blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
return blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::DownSampling(Drawing::Canvas& canvas,
@ -451,7 +491,11 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::ProcessImage(Drawing::Ca
blurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*tmpBlur,
Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP, linear, Drawing::Matrix()));
blurBuilder.SetUniform("in_blurOffset", blur.offsets[stride * i], blur.offsets[stride * i + 1]);
#ifdef RS_ENABLE_GPU
tmpBlur = blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
tmpBlur = blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
auto output = ScaleAndAddRandomColor(canvas, input, tmpBlur, src, dst, width, height);
@ -652,6 +696,7 @@ bool GEMESABlurShaderFilter::InitGreyAdjustmentEffect()
void GEMESABlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
std::shared_ptr<Drawing::Image>& checkedImage, const Drawing::Rect& src) const
{
#ifdef RS_ENABLE_GPU
auto srcRect = Drawing::RectI(src.GetLeft(), src.GetTop(), src.GetRight(), src.GetBottom());
if (image->GetImageInfo().GetBound() != srcRect) {
auto resizedImage = std::make_shared<Drawing::Image>();
@ -667,6 +712,7 @@ void GEMESABlurShaderFilter::CheckInputImage(Drawing::Canvas& canvas, const std:
LOGD("GEMESABlurShaderFilter::resize image failed, use original image");
}
}
#endif
}
std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::OutputImageWithoutBlur(Drawing::Canvas& canvas,
@ -693,12 +739,20 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::OutputImageWithoutBlur(D
builder.SetChild("imageShader", inputShader);
builder.SetUniform("coefficient1", greyCoef1_);
builder.SetUniform("coefficient2", greyCoef2_);
#ifdef RS_ENABLE_GPU
output = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, imageInfo, false);
#else
output = builder.MakeImage(nullptr, nullptr, imageInfo, false);
#endif
} else {
Drawing::RuntimeShaderBuilder builder(g_simpleFilter);
auto inputShader = Drawing::ShaderEffect::CreateImageShader(*image, tileMode_, tileMode_, linear, inputMatrix);
builder.SetChild("imageInput", inputShader);
#ifdef RS_ENABLE_GPU
output = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, imageInfo, false);
#else
output = builder.MakeImage(nullptr, nullptr, imageInfo, false);
#endif
}
if (!output) {
LOGE("GEMESABlurShaderFilter::OutputImageWithoutBlur make image error");
@ -745,7 +799,11 @@ std::shared_ptr<Drawing::Image> GEMESABlurShaderFilter::ScaleAndAddRandomColor(D
static auto factor = 1.75; // 1.75 from experience
mixBuilder.SetUniform("inColorFactor", factor);
#ifdef RS_ENABLE_GPU
auto output = mixBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
auto output = mixBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
return output;
}

View File

@ -80,8 +80,11 @@ std::shared_ptr<Drawing::Image> GEWaterRippleFilter::ProcessImage(Drawing::Canva
builder.SetUniform("progress", progress_);
builder.SetUniform("waveCount", static_cast<float>(waveCount_));
builder.SetUniform("rippleCenter", rippleCenterX_, rippleCenterY_);
#ifdef RS_ENABLE_GPU
auto invertedImage = builder.MakeImage(canvas.GetGPUContext().get(), nullptr, imageInfo, false);
#else
auto invertedImage = builder.MakeImage(nullptr, nullptr, imageInfo, false);
#endif
if (invertedImage == nullptr) {
LOGE("GEWaterRippleFilter::ProcessImage make image failed");
return nullptr;

View File

@ -27,7 +27,9 @@ config("native_display_soloist_config") {
}
ohos_shared_library("libnative_display_soloist") {
sources = [ "native_display_soloist.cpp" ]
if (rs_enable_gpu) {
sources = [ "native_display_soloist.cpp" ]
}
include_dirs = [
"$graphic_2d_root/utils/log",

View File

@ -83,22 +83,12 @@ ohos_shared_library("librender_service") {
}
sources = [
"core/memory/rs_memory_manager.cpp",
"core/pipeline/round_corner_display/rs_rcd_render_listener.cpp",
"core/pipeline/round_corner_display/rs_rcd_render_manager.cpp",
"core/pipeline/round_corner_display/rs_rcd_render_visitor.cpp",
"core/pipeline/round_corner_display/rs_rcd_surface_render_node.cpp",
"core/pipeline/round_corner_display/rs_round_corner_config.cpp",
"core/pipeline/round_corner_display/rs_round_corner_display.cpp",
"core/pipeline/round_corner_display/rs_round_corner_display_manager.cpp",
"core/pipeline/rs_anco_manager.cpp",
"core/pipeline/rs_base_render_engine.cpp",
"core/pipeline/rs_base_render_util.cpp",
"core/pipeline/rs_composer_adapter.cpp",
"core/pipeline/rs_divided_render_util.cpp",
"core/pipeline/rs_draw_frame.cpp",
"core/pipeline/rs_draw_window_cache.cpp",
"core/pipeline/rs_hardware_thread.cpp",
"core/pipeline/rs_main_thread.cpp",
"core/pipeline/rs_physical_screen_processor.cpp",
"core/pipeline/rs_pointer_window_manager.cpp",
@ -111,19 +101,6 @@ ohos_shared_library("librender_service") {
"core/pipeline/rs_render_service_listener.cpp",
"core/pipeline/rs_render_service_visitor.cpp",
"core/pipeline/rs_surface_capture_task.cpp",
"core/pipeline/rs_surface_capture_task_parallel.cpp",
"core/pipeline/rs_ui_capture_task_parallel.cpp",
"core/pipeline/rs_uifirst_manager.cpp",
"core/pipeline/rs_uni_hwc_prevalidate_util.cpp",
"core/pipeline/rs_uni_render_composer_adapter.cpp",
"core/pipeline/rs_uni_render_engine.cpp",
"core/pipeline/rs_uni_render_listener.cpp",
"core/pipeline/rs_uni_render_processor.cpp",
"core/pipeline/rs_uni_render_thread.cpp",
"core/pipeline/rs_uni_render_util.cpp",
"core/pipeline/rs_uni_render_virtual_processor.cpp",
"core/pipeline/rs_uni_render_visitor.cpp",
"core/pipeline/rs_uni_ui_capture.cpp",
"core/pipeline/rs_unmarshal_thread.cpp",
"core/pipeline/rs_vblank_idle_corrector.cpp",
"core/pipeline/rs_virtual_screen_processor.cpp",
@ -138,25 +115,8 @@ ohos_shared_library("librender_service") {
"core/transaction/rs_render_service_stub.cpp",
]
#drawable
sources += [
"core/drawable/rs_canvas_drawing_render_node_drawable.cpp",
"core/drawable/rs_canvas_render_node_drawable.cpp",
"core/drawable/rs_display_render_node_drawable.cpp",
"core/drawable/rs_dma_buffer_surface_render_node_drawable.cpp",
"core/drawable/rs_effect_render_node_drawable.cpp",
"core/drawable/rs_render_node_drawable.cpp",
"core/drawable/rs_render_node_drawable_autocache.cpp",
"core/drawable/rs_root_render_node_drawable.cpp",
"core/drawable/rs_surface_render_node_drawable.cpp",
"core/drawable/rs_ui_first_surface_render_node_drawable.cpp",
]
#dfx
sources += [
"core/drawable/dfx/rs_dirty_rects_dfx.cpp",
"core/drawable/dfx/rs_skp_capture_dfx.cpp",
]
sources += [ "core/drawable/dfx/rs_skp_capture_dfx.cpp" ]
if (defined(input_ext_feature_magiccursor) && input_ext_feature_magiccursor) {
sources += [
@ -164,6 +124,46 @@ ohos_shared_library("librender_service") {
]
}
if (rs_enable_gpu) {
sources += [
#drawable
"core/drawable/dfx/rs_dirty_rects_dfx.cpp",
"core/drawable/rs_canvas_drawing_render_node_drawable.cpp",
"core/drawable/rs_canvas_render_node_drawable.cpp",
"core/drawable/rs_display_render_node_drawable.cpp",
"core/drawable/rs_dma_buffer_surface_render_node_drawable.cpp",
"core/drawable/rs_effect_render_node_drawable.cpp",
"core/drawable/rs_render_node_drawable.cpp",
"core/drawable/rs_render_node_drawable_autocache.cpp",
"core/drawable/rs_root_render_node_drawable.cpp",
"core/drawable/rs_surface_render_node_drawable.cpp",
"core/drawable/rs_ui_first_surface_render_node_drawable.cpp",
"core/memory/rs_memory_manager.cpp",
"core/pipeline/round_corner_display/rs_rcd_render_listener.cpp",
"core/pipeline/round_corner_display/rs_rcd_render_manager.cpp",
"core/pipeline/round_corner_display/rs_rcd_render_visitor.cpp",
"core/pipeline/round_corner_display/rs_rcd_surface_render_node.cpp",
"core/pipeline/round_corner_display/rs_round_corner_config.cpp",
"core/pipeline/round_corner_display/rs_round_corner_display.cpp",
"core/pipeline/round_corner_display/rs_round_corner_display_manager.cpp",
"core/pipeline/rs_draw_frame.cpp",
"core/pipeline/rs_hardware_thread.cpp",
"core/pipeline/rs_surface_capture_task_parallel.cpp",
"core/pipeline/rs_ui_capture_task_parallel.cpp",
"core/pipeline/rs_uifirst_manager.cpp",
"core/pipeline/rs_uni_hwc_prevalidate_util.cpp",
"core/pipeline/rs_uni_render_composer_adapter.cpp",
"core/pipeline/rs_uni_render_engine.cpp",
"core/pipeline/rs_uni_render_listener.cpp",
"core/pipeline/rs_uni_render_processor.cpp",
"core/pipeline/rs_uni_render_thread.cpp",
"core/pipeline/rs_uni_render_util.cpp",
"core/pipeline/rs_uni_render_virtual_processor.cpp",
"core/pipeline/rs_uni_render_visitor.cpp",
"core/pipeline/rs_uni_ui_capture.cpp",
]
}
if (rs_enable_eglimage && rs_enable_gpu) {
sources += [ "core/pipeline/rs_egl_image_manager.cpp" ]
}
@ -378,8 +378,6 @@ ohos_shared_library("librender_service") {
defines += tp_defines
}
deps += [ "$graphic_2d_root/frameworks/opengl_wrapper:EGL" ]
part_name = "graphic_2d"
subsystem_name = "graphic"
}

View File

@ -109,6 +109,7 @@ void RSDirtyRectsDfx::OnDrawVirtual(RSPaintFilterCanvas& canvas)
void RSDirtyRectsDfx::DrawHwcRegionForDFX(RSPaintFilterCanvas& canvas) const
{
#ifdef RS_ENABLE_GPU
auto& hardwareDrawables =
RSUniRenderThread::Instance().GetRSRenderThreadParams()->GetHardwareEnabledTypeDrawables();
static uint32_t updateCnt = 0;
@ -129,6 +130,7 @@ void RSDirtyRectsDfx::DrawHwcRegionForDFX(RSPaintFilterCanvas& canvas) const
HWC_DFX_FILL_ALPHA, extraInfo);
}
}
#endif
}
void RSDirtyRectsDfx::DrawDirtyRegionInVirtual(RSPaintFilterCanvas& canvas) const
@ -348,7 +350,7 @@ bool RSDirtyRectsDfx::DrawDetailedTypesOfDirtyRegionForDFX(RSPaintFilterCanvas&
}
return true;
}
#ifdef RS_ENABLE_GPU
void RSDirtyRectsDfx::DrawSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas,
RSSurfaceRenderParams& surfaceParams) const
{
@ -357,7 +359,7 @@ void RSDirtyRectsDfx::DrawSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas,
DrawDirtyRectForDFX(canvas, subRect.ToRectI(), Drawing::Color::COLOR_GREEN, RSPaintStyle::FILL, 0);
}
}
#endif
void RSDirtyRectsDfx::DrawAllSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canvas) const
{
const auto& visibleDirtyRects = dirtyRegion_.GetRegionRects();
@ -374,6 +376,7 @@ void RSDirtyRectsDfx::DrawAllSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canva
void RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas) const
{
#ifdef RS_ENABLE_GPU
if (!displayParams_) {
RS_LOGE("RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX displayParams is null ptr.");
return;
@ -385,6 +388,7 @@ void RSDirtyRectsDfx::DrawAllSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canv
DrawSurfaceOpaqueRegionForDFX(canvas, *surfaceParams);
}
}
#endif
}
void RSDirtyRectsDfx::DrawTargetSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& canvas) const
@ -426,6 +430,7 @@ void RSDirtyRectsDfx::DrawTargetSurfaceDirtyRegionForDFX(RSPaintFilterCanvas& ca
void RSDirtyRectsDfx::DrawTargetSurfaceVisibleRegionForDFX(RSPaintFilterCanvas& canvas) const
{
#ifdef RS_ENABLE_GPU
if (!displayParams_) {
RS_LOGE("RSDirtyRectsDfx: displayParams is null ptr.");
return;
@ -445,6 +450,7 @@ void RSDirtyRectsDfx::DrawTargetSurfaceVisibleRegionForDFX(RSPaintFilterCanvas&
DrawDirtyRegionForDFX(canvas, rects);
}
}
#endif
}
} // namespace OHOS::Rosen

View File

@ -67,7 +67,9 @@ private:
const Drawing::Color color, const RSPaintStyle fillType, int edgeWidth = 6) const;
bool DrawDetailedTypesOfDirtyRegionForDFX(RSPaintFilterCanvas& canvas,
DrawableV2::RSSurfaceRenderNodeDrawable& surfaceDrawable) const;
#ifdef RS_ENABLE_GPU
void DrawSurfaceOpaqueRegionForDFX(RSPaintFilterCanvas& canvas, RSSurfaceRenderParams& surfaceParams) const;
#endif
void DrawHwcRegionForDFX(RSPaintFilterCanvas& canvas) const;
void DrawDirtyRegionForDFX(RSPaintFilterCanvas& canvas, const std::vector<RectI>& dirtyRects) const;

View File

@ -49,11 +49,13 @@ void RSSkpCaptureDfx::TryCapture() const
void RSSkpCaptureDfx::EndCapture() const
{
#ifdef RS_ENABLE_GPU
auto renderContext = RSUniRenderThread::Instance().GetRenderEngine()->GetRenderContext();
if (!renderContext) {
RS_LOGE("EndCapture renderContext is nullptr");
return;
}
#endif
#ifdef RS_PROFILER_ENABLED
RSCaptureRecorder::GetInstance().EndInstantCapture();
#endif

View File

@ -18,7 +18,9 @@
#include "pipeline/rs_paint_filter_canvas.h"
#include "pipeline/rs_recording_canvas.h"
#ifdef RS_ENABLE_GPU
#include "render_context/render_context.h"
#endif
namespace OHOS::Rosen {

View File

@ -42,6 +42,7 @@ RSRenderNodeDrawable::Ptr RSCanvasRenderNodeDrawable::OnGenerate(std::shared_ptr
*/
void RSCanvasRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
{
#ifdef RS_ENABLE_GPU
SetDrawSkipType(DrawSkipType::NONE);
if (!ShouldPaint()) {
SetDrawSkipType(DrawSkipType::SHOULD_NOT_PAINT);
@ -81,6 +82,7 @@ void RSCanvasRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
RSRenderNodeDrawable::OnDraw(canvas);
}
RSRenderNodeDrawable::ProcessedNodeCountInc();
#endif
}
/*
@ -88,6 +90,7 @@ void RSCanvasRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
*/
void RSCanvasRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas)
{
#ifdef RS_ENABLE_GPU
if (!ShouldPaint()) {
return;
}
@ -104,5 +107,6 @@ void RSCanvasRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas)
} else {
RSRenderNodeDrawable::OnDraw(canvas);
}
#endif
}
} // namespace OHOS::Rosen::DrawableV2

View File

@ -32,6 +32,7 @@ RSRenderNodeDrawable::Ptr RSEffectRenderNodeDrawable::OnGenerate(std::shared_ptr
void RSEffectRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
{
#ifdef RS_ENABLE_GPU
SetDrawSkipType(DrawSkipType::NONE);
if (!ShouldPaint()) {
SetDrawSkipType(DrawSkipType::SHOULD_NOT_PAINT);
@ -63,11 +64,13 @@ void RSEffectRenderNodeDrawable::OnDraw(Drawing::Canvas& canvas)
}
RSRenderNodeDrawableAdapter::DrawImpl(canvas, bounds, drawCmdIndex_.childrenIndex_);
#endif
}
bool RSEffectRenderNodeDrawable::GenerateEffectDataOnDemand(RSEffectRenderParams* effectParams,
Drawing::Canvas& canvas, const Drawing::Rect& bounds, RSPaintFilterCanvas* paintFilterCanvas)
{
#ifdef RS_ENABLE_GPU
if (drawCmdIndex_.childrenIndex_ == -1) {
// case 0: No children, skip
return false;
@ -115,6 +118,9 @@ bool RSEffectRenderNodeDrawable::GenerateEffectDataOnDemand(RSEffectRenderParams
}
}
return true;
#else
return false;
#endif
}
void RSEffectRenderNodeDrawable::OnCapture(Drawing::Canvas& canvas)

View File

@ -32,7 +32,11 @@ constexpr int32_t OPINC_CACHE_SIZE_MAX = 1314000;
bool RSRenderNodeDrawable::ShouldPaint() const
{
#ifdef RS_ENABLE_GPU
return LIKELY(renderParams_ != nullptr) && renderParams_->GetShouldPaint();
#else
return false;
#endif
}
bool RSRenderNodeDrawable::IsOpincRenderCacheEnable()
@ -53,12 +57,14 @@ bool RSRenderNodeDrawable::IsAutoCacheDebugEnable()
void RSRenderNodeDrawable::OpincCalculateBefore(Drawing::Canvas& canvas,
const RSRenderParams& params, bool& isOpincDropNodeExt)
{
#ifdef RS_ENABLE_GPU
isOpincDropNodeExtTemp_ = isOpincDropNodeExt;
isOpincCaculateStart_ = false;
if (IsOpincRealDrawCacheEnable() && IsOpListDrawAreaEnable()) {
isOpincCaculateStart_ = canvas.OpCalculateBefore(params.GetMatrix());
isOpincDropNodeExt = false;
}
#endif
}
void RSRenderNodeDrawable::OpincCalculateAfter(Drawing::Canvas& canvas, bool& isOpincDropNodeExt)
@ -83,11 +89,15 @@ void RSRenderNodeDrawable::OpincCalculateAfter(Drawing::Canvas& canvas, bool& is
bool RSRenderNodeDrawable::PreDrawableCacheState(RSRenderParams& params, bool& isOpincDropNodeExt)
{
#ifdef RS_ENABLE_GPU
if (params.OpincGetCacheChangeState()) {
RS_OPTIONAL_TRACE_NAME_FMT("OpincGetCacheChangeState Changed %llx", GetId());
DrawableCacheStateReset(params);
}
return isOpincDropNodeExt && (!IsOpincRootNode());
#else
return false;
#endif
}
void RSRenderNodeDrawable::OpincCanvasUnionTranslate(RSPaintFilterCanvas& canvas)
@ -147,6 +157,7 @@ void RSRenderNodeDrawable::NodeCacheStateDisable()
bool RSRenderNodeDrawable::BeforeDrawCacheProcessChildNode(NodeStrategyType& cacheStragy,
RSRenderParams& params)
{
#ifdef RS_ENABLE_GPU
#ifdef DDGR_ENABLE_FEATURE_OPINC_DFX
RS_TRACE_NAME_FMT("BeforeDrawCacheProcessChildNode cs:%d rs:%d csBak:%d",
cacheStragy, recordState_, temNodeStragyType_);
@ -163,11 +174,15 @@ bool RSRenderNodeDrawable::BeforeDrawCacheProcessChildNode(NodeStrategyType& cac
return false;
}
return true;
#else
return false;
#endif
}
void RSRenderNodeDrawable::BeforeDrawCacheFindRootNode(Drawing::Canvas& canvas,
const RSRenderParams& params, bool& isOpincDropNodeExt)
{
#ifdef RS_ENABLE_GPU
if (IsOpincRealDrawCacheEnable() && !params.OpincGetRootFlag()) {
return;
}
@ -187,6 +202,7 @@ void RSRenderNodeDrawable::BeforeDrawCacheFindRootNode(Drawing::Canvas& canvas,
RS_TRACE_NAME_FMT("BeforeDrawCacheFindRootNode rootS:%d xy:%d", rootNodeStragyType_,
(size.y_ > BITMAP_CACHE_SIZE_MIN && size.x_ > BITMAP_CACHE_SIZE_MIN));
#endif
#endif
}
void RSRenderNodeDrawable::BeforeDrawCache(NodeStrategyType& cacheStragy,

View File

@ -231,6 +231,7 @@ bool RSMagicPointerRenderManager::GetIntersectImageBySubset(std::shared_ptr<Draw
bool RSMagicPointerRenderManager::CalculateTargetLayer(std::shared_ptr<RSProcessor> processor)
{
#ifdef RS_ENABLE_GPU
auto uniRenderProcessor = std::static_pointer_cast<RSUniRenderProcessor>(processor);
if (uniRenderProcessor == nullptr) {
ROSEN_LOGE("RSMagicPointerRenderManager::CalculateTargetLayer uniRenderProcessor is null!");
@ -267,7 +268,7 @@ bool RSMagicPointerRenderManager::CalculateTargetLayer(std::shared_ptr<RSProcess
CalculateColorRange(pRect);
// calculate the max intersection layer and rect
GetRectAndTargetLayer(layers, pRect, displayNodeIndex);
#endif
return true;
}

View File

@ -89,7 +89,7 @@ bool RSAncoManager::AncoOptimizeDisplayNode(std::shared_ptr<RSSurfaceHandler>& s
!surfaceNode->GetRSSurfaceHandler()->GetBuffer()) {
continue;
}
#ifdef RS_ENABLE_GPU
auto params = static_cast<RSSurfaceRenderParams*>(surfaceNode->GetStagingRenderParams().get());
if (params == nullptr) {
continue;
@ -104,6 +104,7 @@ bool RSAncoManager::AncoOptimizeDisplayNode(std::shared_ptr<RSSurfaceHandler>& s
sfvNodesCnt++;
}
}
#endif
}
return AncoOptimizeCheck(isHebc, nodesCnt, sfvNodesCnt);

View File

@ -27,7 +27,9 @@
#include "pipeline/rs_uni_render_judgement.h"
#include "platform/common/rs_log.h"
#include "platform/common/rs_system_properties.h"
#if (defined(RS_ENABLE_GPU) && defined(RS_ENABLE_GL))
#include "platform/ohos/backend/rs_surface_ohos_gl.h"
#endif
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
#ifdef RS_ENABLE_VK
#include "platform/ohos/backend/rs_vulkan_context.h"
@ -36,8 +38,9 @@
#include "render/rs_drawing_filter.h"
#include "render/rs_skia_filter.h"
#include "metadata_helper.h"
#ifdef RS_ENABLE_GPU
#include "drawable/rs_display_render_node_drawable.h"
#endif
namespace OHOS {
namespace Rosen {
@ -75,7 +78,7 @@ void RSBaseRenderEngine::Init(bool independentContext)
renderContext_->SetUpGpuContext();
#endif
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#if defined(RS_ENABLE_EGLIMAGE)
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
eglImageManager_ = std::make_shared<RSEglImageManager>(renderContext_->GetEGLDisplay());
#endif // RS_ENABLE_EGLIMAGE
#ifdef RS_ENABLE_VK
@ -91,10 +94,12 @@ void RSBaseRenderEngine::Init(bool independentContext)
void RSBaseRenderEngine::InitCapture(bool independentContext)
{
#ifdef RS_ENABLE_GPU
(void)independentContext;
if (captureRenderContext_) {
return;
}
#endif
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
captureRenderContext_ = std::make_shared<RenderContext>();
@ -121,10 +126,12 @@ void RSBaseRenderEngine::InitCapture(bool independentContext)
void RSBaseRenderEngine::ResetCurrentContext()
{
#ifdef RS_ENABLE_GPU
if (renderContext_ == nullptr) {
RS_LOGE("This render context is nullptr.");
return;
}
#endif
#if (defined RS_ENABLE_GL)
if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) {
renderContext_->ShareMakeCurrentNoSurface(EGL_NO_CONTEXT);
@ -173,7 +180,7 @@ std::shared_ptr<Drawing::Image> RSBaseRenderEngine::CreateEglImageFromBuffer(RSP
const sptr<SurfaceBuffer>& buffer, const sptr<SyncFence>& acquireFence, const uint32_t threadIndex,
const std::shared_ptr<Drawing::ColorSpace>& drawingColorSpace)
{
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
#if defined(RS_ENABLE_GL)
if (!RSSystemProperties::IsUseVulkan() && canvas.GetGPUContext() == nullptr) {
RS_LOGE("RSBaseRenderEngine::CreateEglImageFromBuffer GrContext is null!");
@ -390,7 +397,9 @@ void RSBaseRenderEngine::DrawDisplayNodeWithParams(RSPaintFilterCanvas& canvas,
{
if (params.useCPU) {
DrawBuffer(canvas, params);
} else {
}
#ifdef RS_ENABLE_GPU
else {
auto drawable = node.GetRenderDrawable();
if (!drawable) {
return;
@ -399,6 +408,7 @@ void RSBaseRenderEngine::DrawDisplayNodeWithParams(RSPaintFilterCanvas& canvas,
RegisterDeleteBufferListener(displayDrawable->GetRSSurfaceHandlerOnDraw()->GetConsumer());
DrawImage(canvas, params);
}
#endif
}
void RSBaseRenderEngine::DrawDisplayNodeWithParams(RSPaintFilterCanvas& canvas, RSSurfaceHandler& surfaceHandler,
@ -824,7 +834,7 @@ void RSBaseRenderEngine::RegisterDeleteBufferListener(const sptr<IConsumerSurfac
}
#endif // #ifdef RS_ENABLE_VK
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
auto regUnMapEglImageFunc = [this, isForUniRedraw](int32_t bufferId) {
if (isForUniRedraw) {
eglImageManager_->UnMapEglImageFromSurfaceBufferForUniRedraw(bufferId);
@ -853,7 +863,7 @@ void RSBaseRenderEngine::RegisterDeleteBufferListener(RSSurfaceHandler& handler)
}
#endif // #ifdef RS_ENABLE_VK
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
auto regUnMapEglImageFunc = [this](int32_t bufferId) {
eglImageManager_->UnMapEglImageFromSurfaceBuffer(bufferId);
};
@ -872,7 +882,7 @@ void RSBaseRenderEngine::ShrinkCachesIfNeeded(bool isForUniRedraw)
}
#endif // RS_ENABLE_VK
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
if (eglImageManager_ != nullptr) {
eglImageManager_->ShrinkCachesIfNeeded(isForUniRedraw);
}
@ -892,7 +902,7 @@ void RSBaseRenderEngine::ClearCacheSet(const std::set<int32_t> unmappedCache)
}
#endif // RS_ENABLE_VK
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
if (eglImageManager_ != nullptr) {
for (auto id : unmappedCache) {
eglImageManager_->UnMapEglImageFromSurfaceBuffer(id);

View File

@ -33,7 +33,7 @@
#if (defined RS_ENABLE_GL) || (defined RS_ENABLE_VK)
#include "render_context/render_context.h"
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
#include "rs_egl_image_manager.h"
#endif // RS_ENABLE_EGLIMAGE
#ifdef USE_VIDEO_PROCESSING_ENGINE
@ -189,7 +189,7 @@ public:
#endif // RS_ENABLE_GL || RS_ENABLE_VK
void ResetCurrentContext();
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
const std::shared_ptr<RSEglImageManager>& GetEglImageManager()
{
return eglImageManager_;
@ -234,7 +234,7 @@ private:
std::shared_ptr<RenderContext> renderContext_ = nullptr;
std::shared_ptr<RenderContext> captureRenderContext_ = nullptr;
#endif // RS_ENABLE_GL || RS_ENABLE_VK
#ifdef RS_ENABLE_EGLIMAGE
#if (defined(RS_ENABLE_EGLIMAGE) && defined(RS_ENABLE_GPU))
std::shared_ptr<RSEglImageManager> eglImageManager_ = nullptr;
#endif // RS_ENABLE_EGLIMAGE
#ifdef RS_ENABLE_VK

View File

@ -1017,12 +1017,16 @@ bool RSBaseRenderUtil::ConsumeAndUpdateBuffer(RSSurfaceHandler& surfaceHandler,
surfaceHandler.SetAvailableBufferCount(static_cast<int32_t>(consumer->GetAvailableBufferCount()));
// should drop frame after acquire buffer to avoid drop key frame
DropFrameProcess(surfaceHandler, acquireTimeStamp);
#ifdef RS_ENABLE_GPU
auto renderEngine = RSUniRenderThread::Instance().GetRenderEngine();
if (!renderEngine) {
return true;
}
renderEngine->RegisterDeleteBufferListener(surfaceHandler);
return true;
#else
return true;
#endif
}
bool RSBaseRenderUtil::ReleaseBuffer(RSSurfaceHandler& surfaceHandler)
@ -1209,7 +1213,7 @@ Drawing::Matrix RSBaseRenderUtil::GetGravityMatrix(
return gravityMatrix;
}
#ifdef RS_ENABLE_GPU
void RSBaseRenderUtil::DealWithSurfaceRotationAndGravity(GraphicTransformType transform, Gravity gravity,
RectF &localBounds, BufferDrawParam &params, RSSurfaceRenderParams *nodeParams)
{
@ -1250,7 +1254,7 @@ void RSBaseRenderUtil::DealWithSurfaceRotationAndGravity(GraphicTransformType tr
// we must disable the scale effect that from srcRect to dstRect.
params.dstRect = params.srcRect;
}
#endif
void RSBaseRenderUtil::FlipMatrix(GraphicTransformType transform, BufferDrawParam& params)
{
GraphicTransformType type = GetFlipTransform(transform);

View File

@ -52,8 +52,9 @@ struct ComposeInfo {
int32_t displayNit { 0 };
float brightnessRatio { 0.0 };
};
#ifdef RS_ENABLE_GPU
class RSSurfaceRenderParams;
#endif
class RSTransactionData;
#ifdef USE_VIDEO_PROCESSING_ENGINE
constexpr float DEFAULT_SCREEN_LIGHT_NITS = 500;
@ -160,8 +161,10 @@ public:
static bool WriteSurfaceBufferToPng(sptr<SurfaceBuffer>& buffer, uint64_t id = 0);
static bool WritePixelMapToPng(Media::PixelMap& pixelMap);
#ifdef RS_ENABLE_GPU
static void DealWithSurfaceRotationAndGravity(GraphicTransformType transform, Gravity gravity,
RectF& localBounds, BufferDrawParam& params, RSSurfaceRenderParams* nodeParams = nullptr);
#endif
static void FlipMatrix(GraphicTransformType transform, BufferDrawParam& params);
// GraphicTransformType has two attributes: rotation and flip, it take out one of the attributes separately

View File

@ -78,8 +78,10 @@ BufferDrawParam RSDividedRenderUtil::CreateBufferDrawParam(
params.buffer = buffer;
params.acquireFence = surfaceHandler->GetAcquireFence();
params.srcRect = Drawing::Rect(0, 0, buffer->GetSurfaceBufferWidth(), buffer->GetSurfaceBufferHeight());
#ifdef RS_ENABLE_GPU
RSBaseRenderUtil::DealWithSurfaceRotationAndGravity(surface->GetTransform(), property.GetFrameGravity(),
localBounds, params);
#endif
RSBaseRenderUtil::FlipMatrix(surface->GetTransform(), params);
return params;
}

View File

@ -61,7 +61,7 @@ void RSDrawWindowCache::DrawAndCacheWindowContent(DrawableV2::RSSurfaceRenderNod
windowCanvas->SetDisableFilterCache(true);
auto acr = std::make_unique<RSAutoCanvasRestore>(windowCanvas, RSPaintFilterCanvas::SaveType::kCanvasAndAlpha);
windowCanvas->Clear(Drawing::Color::COLOR_TRANSPARENT);
#ifdef RS_ENABLE_GPU
// draw window content/children onto offscreen canvas
auto& uniParams = RSUniRenderThread::Instance().GetRSRenderThreadParams();
bool isOpDropped = uniParams != nullptr ? uniParams->IsOpDropped() : true;
@ -73,7 +73,7 @@ void RSDrawWindowCache::DrawAndCacheWindowContent(DrawableV2::RSSurfaceRenderNod
if (uniParams) {
uniParams->SetOpDropped(isOpDropped);
}
#endif
// cache and draw snapshot of offscreen canvas onto target canvas
image_ = windowSurface->GetImageSnapshot();
if (image_ == nullptr) {
@ -87,7 +87,7 @@ void RSDrawWindowCache::DrawAndCacheWindowContent(DrawableV2::RSSurfaceRenderNod
canvas.DrawImage(*image_, 0, 0, samplingOptions);
canvas.DetachBrush();
}
#ifdef RS_ENABLE_GPU
bool RSDrawWindowCache::DealWithCachedWindow(DrawableV2::RSSurfaceRenderNodeDrawable* surfaceDrawable,
RSPaintFilterCanvas& canvas, RSSurfaceRenderParams& surfaceParams, RSRenderThreadParams& uniParam)
{
@ -154,7 +154,7 @@ bool RSDrawWindowCache::DealWithCachedWindow(DrawableV2::RSSurfaceRenderNodeDraw
surfaceDrawable->DrawWatermark(canvas, surfaceParams);
return true;
}
#endif
void RSDrawWindowCache::ClearCache()
{
image_ = nullptr;

View File

@ -52,8 +52,10 @@ public:
* @param surfaceParams Indicates the render params
* @return true if success, otherwise false
*/
#ifdef RS_ENABLE_GPU
bool DealWithCachedWindow(DrawableV2::RSSurfaceRenderNodeDrawable* surfaceDrawable,
RSPaintFilterCanvas& canvas, RSSurfaceRenderParams& surfaceParams, RSRenderThreadParams& uniParam);
#endif
private:
bool HasCache() const;
void ClearCache();

View File

@ -55,7 +55,9 @@ public:
std::future<Return> ScheduleTask(Task&& task)
{
auto [scheduledTask, taskFuture] = Detail::ScheduledTask<Task>::Create(std::forward<Task&&>(task));
#ifdef RS_ENABLE_GPU
PostTask([t(std::move(scheduledTask))]() { t->Run(); });
#endif
return std::move(taskFuture);
}
uint32_t GetunExecuteTaskNum();

View File

@ -21,6 +21,7 @@
#include <cstdint>
#include <list>
#include <malloc.h>
#include <parameters.h>
#include <securec.h>
#include <stdint.h>
#include <string>
@ -58,9 +59,6 @@
#include "memory/rs_memory_track.h"
#include "metadata_helper.h"
#include "params/rs_surface_render_params.h"
#include "pipeline/parallel_render/rs_sub_thread_manager.h"
#include "pipeline/round_corner_display/rs_rcd_render_manager.h"
#include "pipeline/round_corner_display/rs_round_corner_display_manager.h"
#include "pipeline/rs_anco_manager.h"
#include "pipeline/rs_base_render_node.h"
#include "pipeline/rs_base_render_util.h"
@ -76,11 +74,6 @@
#include "pipeline/rs_surface_buffer_callback_manager.h"
#include "pipeline/rs_surface_render_node.h"
#include "pipeline/rs_task_dispatcher.h"
#include "pipeline/rs_ui_capture_task_parallel.h"
#include "pipeline/rs_uni_render_engine.h"
#include "pipeline/rs_uni_render_thread.h"
#include "pipeline/rs_uni_render_util.h"
#include "pipeline/rs_uni_render_visitor.h"
#include "pipeline/rs_unmarshal_thread.h"
#include "pipeline/rs_render_node_gc.h"
#include "pipeline/rs_uifirst_manager.h"
@ -104,6 +97,17 @@
#include "transaction/rs_transaction_metric_collector.h"
#include "transaction/rs_transaction_proxy.h"
#ifdef RS_ENABLE_GPU
#include "pipeline/parallel_render/rs_sub_thread_manager.h"
#include "pipeline/round_corner_display/rs_rcd_render_manager.h"
#include "pipeline/round_corner_display/rs_round_corner_display_manager.h"
#include "pipeline/rs_ui_capture_task_parallel.h"
#include "pipeline/rs_uni_render_engine.h"
#include "pipeline/rs_uni_render_thread.h"
#include "pipeline/rs_uni_render_util.h"
#include "pipeline/rs_uni_render_visitor.h"
#endif
#ifdef RS_ENABLE_GL
#include "GLES3/gl3.h"
#include "EGL/egl.h"
@ -232,6 +236,7 @@ void PerfRequest(int32_t perfRequestCode, bool onOffTag)
#endif
}
#ifdef RS_ENABLE_GPU
void DoScreenRcdTask(NodeId id, std::shared_ptr<RSProcessor>& processor, std::unique_ptr<RcdInfo>& rcdInfo,
const ScreenInfo& screenInfo)
{
@ -249,6 +254,7 @@ void DoScreenRcdTask(NodeId id, std::shared_ptr<RSProcessor>& processor, std::un
});
}
}
#endif
void UpdateSurfaceNodeNit(const sptr<SurfaceBuffer>& surfaceBuffer, RSSurfaceRenderNode& surfaceNode, bool isHdrSurface)
{
@ -440,8 +446,10 @@ void RSMainThread::Init()
mainLoop_ = [&]() {
RS_PROFILER_ON_FRAME_BEGIN();
if (isUniRender_ && !renderThreadParams_) {
#ifdef RS_ENABLE_GPU
// fill the params, and sync to render thread later
renderThreadParams_ = std::make_unique<RSRenderThreadParams>();
#endif
}
RenderFrameStart(timestamp_);
RSRenderNodeGC::Instance().SetGCTaskEnable(true);
@ -454,7 +462,9 @@ void RSMainThread::Init()
Animate(timestamp_);
DvsyncCheckRequestNextVsync();
CollectInfoForHardwareComposer();
#ifdef RS_ENABLE_GPU
RSUifirstManager::Instance().PrepareCurrentFrameEvent();
#endif
ProcessHgmFrameRate(timestamp_);
RS_PROFILER_ON_RENDER_BEGIN();
// cpu boost feature start
@ -524,10 +534,11 @@ void RSMainThread::Init()
.OnAfterAcquireBuffer = RSSurfaceBufferCallbackManager::Instance().GetOnAfterAcquireBufferCb(),
});
RSSurfaceBufferCallbackManager::Instance().SetIsUniRender(true);
#ifdef RS_ENABLE_GPU
RSSurfaceBufferCallbackManager::Instance().SetRunPolicy([](auto task) {
RSHardwareThread::Instance().PostTask(task);
});
#endif
RSSurfaceBufferCallbackManager::Instance().SetVSyncFuncs({
.requestNextVsync = []() {
RSMainThread::Instance()->RequestNextVSync();
@ -546,10 +557,12 @@ void RSMainThread::Init()
context_->SetTaskRunner(taskDispatchFunc);
rsVsyncRateReduceManager_.Init(appVSyncDistributor_);
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
auto rtTaskDispatchFunc = [](const RSTaskDispatcher::RSTask& task) {
RSUniRenderThread::Instance().PostRTTask(task);
};
context_->SetRTTaskRunner(rtTaskDispatchFunc);
#endif
}
context_->SetVsyncRequestFunc([]() {
RSMainThread::Instance()->RequestNextVSync();
@ -560,6 +573,7 @@ void RSMainThread::Init()
RSSystemProperties::WatchSystemProperty(HIDE_NOTCH_STATUS, OnHideNotchStatusCallback, nullptr);
RSSystemProperties::WatchSystemProperty(DRAWING_CACHE_DFX, OnDrawingCacheDfxSwitchCallback, nullptr);
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
unmarshalBarrierTask_ = [this]() {
auto cachedTransactionData = RSUnmarshalThread::Instance().GetCachedTransactionData();
MergeToEffectiveTransactionDataMap(cachedTransactionData);
@ -570,6 +584,7 @@ void RSMainThread::Init()
unmarshalTaskCond_.notify_all();
};
RSUnmarshalThread::Instance().Start();
#endif
}
runner_ = AppExecFwk::EventRunner::Create(false);
@ -630,9 +645,9 @@ void RSMainThread::Init()
/* move to render thread ? */
RSBackgroundThread::Instance().InitRenderContext(GetRenderEngine()->GetRenderContext().get());
#endif
#ifdef RS_ENABLE_GPU
RSRcdRenderManager::InitInstance();
#endif
#ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
#if defined (RS_ENABLE_VK)
RSMagicPointerRenderManager::InitInstance(GetRenderEngine()->GetVkImageManager());
@ -695,14 +710,17 @@ void RSMainThread::Init()
PrintCurrentStatus();
UpdateGpuContextCacheSize();
RSLuminanceControl::Get().Init();
#ifdef RS_ENABLE_GPU
if (deviceType_ == DeviceType::PHONE || deviceType_ == DeviceType::TABLET) {
MemoryManager::InitMemoryLimit(GetRenderEngine()->GetRenderContext()->GetDrGPUContext());
}
#endif
}
void RSMainThread::UpdateGpuContextCacheSize()
{
#ifdef RS_ENABLE_GPU
auto gpuContext = isUniRender_? GetRenderEngine()->GetRenderContext()->GetDrGPUContext() :
renderEngine_->GetRenderContext()->GetDrGPUContext();
if (gpuContext == nullptr) {
@ -729,6 +747,7 @@ void RSMainThread::UpdateGpuContextCacheSize()
if (cacheLimitsResourceSize > maxResourcesSize) {
gpuContext->SetResourceCacheLimits(maxResources, cacheLimitsResourceSize);
}
#endif
}
void RSMainThread::RsEventParamDump(std::string& dumpString)
@ -810,8 +829,10 @@ void RSMainThread::SetRSEventDetectorLoopFinishTag()
{
if (rsCompositionTimeoutDetector_ != nullptr) {
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
rsCompositionTimeoutDetector_->SetLoopFinishTag(
focusAppPid_, focusAppUid_, focusAppBundleName_, focusAppAbilityName_);
#endif
} else {
std::string defaultFocusAppInfo = "";
rsCompositionTimeoutDetector_->SetLoopFinishTag(
@ -879,10 +900,13 @@ void RSMainThread::ProcessCommand()
}
RS_PROFILER_ON_PROCESS_COMMAND();
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
ProcessCommandForUniRender();
#endif
} else {
ProcessCommandForDividedRender();
}
#ifdef RS_ENABLE_GPU
switch(context_->purgeType_) {
case RSContext::PurgeType::GENTLY:
isUniRender_ ? RSUniRenderThread::Instance().ClearMemoryCache(context_->clearMoment_, false) :
@ -897,6 +921,7 @@ void RSMainThread::ProcessCommand()
default:
break;
}
#endif
context_->purgeType_ = RSContext::PurgeType::NONE;
if (RsFrameReport::GetInstance().GetEnable()) {
RsFrameReport::GetInstance().AnimateStart();
@ -905,6 +930,7 @@ void RSMainThread::ProcessCommand()
void RSMainThread::PrintCurrentStatus()
{
#ifdef RS_ENABLE_GPU
std::string gpuType = "";
switch (OHOS::Rosen::RSSystemProperties::GetGpuApiType()) {
case OHOS::Rosen::GpuApiType::OPENGL:
@ -921,6 +947,7 @@ void RSMainThread::PrintCurrentStatus()
}
RS_LOGI("[Drawing] Version: Non-released");
RS_LOGE("RSMainThread::PrintCurrentStatus: drawing is opened, gpu type is %{public}s", gpuType.c_str());
#endif
}
void RSMainThread::SubScribeSystemAbility()
@ -975,9 +1002,11 @@ bool RSMainThread::CheckParallelSubThreadNodesStatus()
cacheCmdSkippedNodes_.clear();
if (subThreadNodes_.empty() &&
(deviceType_ != DeviceType::PC || (leashWindowCount_ > 0 && isUiFirstOn_ == false))) {
#ifdef RS_ENABLE_GPU
if (!isUniRender_) {
RSSubThreadManager::Instance()->ResetSubThreadGrContext(); // planning: move to prepare
}
#endif
return false;
}
for (auto& node : subThreadNodes_) {
@ -1159,6 +1188,7 @@ void RSMainThread::CheckAndUpdateTransactionIndex(std::shared_ptr<TransactionDat
void RSMainThread::ProcessCommandForUniRender()
{
#ifdef RS_ENABLE_GPU
std::shared_ptr<TransactionDataMap> transactionDataEffective = std::make_shared<TransactionDataMap>();
std::string transactionFlags;
bool isNeedCacheCmd = CheckParallelSubThreadNodesStatus();
@ -1219,6 +1249,7 @@ void RSMainThread::ProcessCommandForUniRender()
transactionDataEffective->clear();
});
}
#endif
}
void RSMainThread::ProcessCommandForDividedRender()
@ -1401,10 +1432,12 @@ void RSMainThread::ConsumeAndUpdateAllNodes()
this->dividedRenderbufferTimestamps_[surfaceNode->GetId()] =
static_cast<uint64_t>(surfaceHandler->GetTimestamp());
}
#ifdef RS_ENABLE_GPU
if (surfaceHandler->IsCurrentFrameBufferConsumed() && surfaceNode->IsHardwareEnabledType()) {
GpuDirtyRegionCollection::GetInstance().UpdateActiveDirtyInfoForDFX(surfaceNode->GetId(),
surfaceNode->GetName(), surfaceHandler->GetDamageRegion());
}
#endif
if (surfaceHandler->IsCurrentFrameBufferConsumed() && !surfaceNode->IsHardwareEnabledType()) {
surfaceNode->SetContentDirty();
doDirectComposition_ = false;
@ -1413,6 +1446,7 @@ void RSMainThread::ConsumeAndUpdateAllNodes()
surfaceNode->GetName().c_str(), surfaceNode->GetId());
}
if (isUniRender_ && surfaceHandler->IsCurrentFrameBufferConsumed()) {
#ifdef RS_ENABLE_GPU
auto buffer = surfaceHandler->GetBuffer();
auto preBuffer = surfaceHandler->GetPreBuffer();
surfaceNode->UpdateBufferInfo(buffer,
@ -1430,6 +1464,7 @@ void RSMainThread::ConsumeAndUpdateAllNodes()
preBuffer ? preBuffer->GetSurfaceBufferWidth() : 0,
preBuffer ? preBuffer->GetSurfaceBufferHeight() : 0);
}
#endif
}
if (deviceType_ == DeviceType::PC && isUiFirstOn_ && surfaceHandler->IsCurrentFrameBufferConsumed()
&& surfaceNode->IsHardwareEnabledType() && surfaceNode->IsHardwareForcedDisabledByFilter()) {
@ -1508,6 +1543,7 @@ bool RSMainThread::CheckSubThreadNodeStatusIsDoing(NodeId appNodeId) const
void RSMainThread::CollectInfoForHardwareComposer()
{
#ifdef RS_ENABLE_GPU
if (!isUniRender_) {
return;
}
@ -1603,6 +1639,7 @@ void RSMainThread::CollectInfoForHardwareComposer()
isHardwareEnabledBufferUpdated_ = true;
}
});
#endif
}
bool RSMainThread::IsLastFrameUIFirstEnabled(NodeId appNodeId) const
@ -1710,7 +1747,9 @@ void RSMainThread::ReleaseAllNodesBuffer()
}
};
surfaceHandler->ResetPreBuffer();
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().PostTask(releaseTask);
#endif
}
}
surfaceNode->ResetCurrentFrameHardwareEnabledState();
@ -1751,6 +1790,7 @@ uint32_t RSMainThread::GetDynamicRefreshRate() const
void RSMainThread::ClearMemoryCache(ClearMemoryMoment moment, bool deeply, pid_t pid)
{
#ifdef RS_ENABLE_GPU
if (!RSSystemProperties::GetReleaseResourceEnabled()) {
return;
}
@ -1797,6 +1837,7 @@ void RSMainThread::ClearMemoryCache(ClearMemoryMoment moment, bool deeply, pid_t
AppExecFwk::EventQueue::Priority::HIGH);
}
}
#endif
}
void RSMainThread::WaitUntilUnmarshallingTaskFinished()
@ -1930,9 +1971,11 @@ void RSMainThread::SetFrameIsRender(bool isRender)
void RSMainThread::WaitUntilUploadTextureTaskFinishedForGL()
{
#if (defined(RS_ENABLE_GPU) && defined(RS_ENABLE_GL))
if (RSSystemProperties::GetGpuApiType() != GpuApiType::DDGR) {
WaitUntilUploadTextureTaskFinished(isUniRender_);
}
#endif
}
void RSMainThread::AddUiCaptureTask(NodeId id, std::function<void()> task)
@ -1960,6 +2003,7 @@ void RSMainThread::PrepareUiCaptureTasks(std::shared_ptr<RSUniRenderVisitor> uni
void RSMainThread::ProcessUiCaptureTasks()
{
#ifdef RS_ENABLE_GPU
while (!uiCaptureTasks_.empty()) {
if (RSUiCaptureTaskParallel::GetCaptureCount() >= MAX_CAPTURE_COUNT) {
return;
@ -1968,6 +2012,7 @@ void RSMainThread::ProcessUiCaptureTasks()
uiCaptureTasks_.pop();
captureTask();
}
#endif
}
void RSMainThread::CheckBlurEffectCountStatistics(std::shared_ptr<RSRenderNode> rootNode)
@ -2012,6 +2057,7 @@ void RSMainThread::CheckBlurEffectCountStatistics(std::shared_ptr<RSRenderNode>
void RSMainThread::UniRender(std::shared_ptr<RSBaseRenderNode> rootNode)
{
#ifdef RS_ENABLE_GPU
if (isAccessibilityConfigChanged_) {
RS_LOGD("RSMainThread::UniRender AccessibilityConfig has Changed");
}
@ -2116,10 +2162,12 @@ void RSMainThread::UniRender(std::shared_ptr<RSBaseRenderNode> rootNode)
} else if (RSSystemProperties::GetGpuApiType() != GpuApiType::DDGR) {
WaitUntilUploadTextureTaskFinished(isUniRender_);
}
PrepareUiCaptureTasks(uniVisitor);
screenPowerOnChanged_ = false;
forceUpdateUniRenderFlag_ = false;
idleTimerExpiredFlag_ = false;
#endif
}
bool RSMainThread::DoDirectComposition(std::shared_ptr<RSBaseRenderNode> rootNode, bool waitForRT)
@ -2145,6 +2193,7 @@ bool RSMainThread::DoDirectComposition(std::shared_ptr<RSBaseRenderNode> rootNod
RS_LOGE("RSMainThread::DoDirectComposition: ScreenState error!");
return false;
}
#ifdef RS_ENABLE_GPU
auto processor = RSProcessorFactory::CreateProcessor(displayNode->GetCompositeType());
auto renderEngine = GetRenderEngine();
if (processor == nullptr || renderEngine == nullptr) {
@ -2157,20 +2206,27 @@ bool RSMainThread::DoDirectComposition(std::shared_ptr<RSBaseRenderNode> rootNod
RS_LOGE("RSMainThread::DoDirectComposition: processor init failed!");
return false;
}
#endif
auto drawable = displayNode->GetRenderDrawable();
if (drawable != nullptr) {
#ifdef RS_ENABLE_GPU
auto displayDrawable = std::static_pointer_cast<DrawableV2::RSDisplayRenderNodeDrawable>(drawable);
auto surfaceHandler = displayDrawable->GetRSSurfaceHandlerOnDraw();
#else
auto surfaceHandler = nullptr;
#endif
#ifdef RS_ENABLE_GPU
if (RSAncoManager::Instance()->AncoOptimizeDisplayNode(surfaceHandler, hardwareEnabledNodes_,
displayNode->GetRotation(), screenInfo.GetRotatedPhyWidth(), screenInfo.GetRotatedPhyHeight())) {
return false;
}
#endif
}
if (!RSMainThread::Instance()->WaitHardwareThreadTaskExecute()) {
RS_LOGW("RSMainThread::DoDirectComposition: hardwareThread task has too many to Execute");
}
#ifdef RS_ENABLE_GPU
for (auto& surfaceNode : hardwareEnabledNodes_) {
auto surfaceHandler = surfaceNode->GetRSSurfaceHandler();
if (!surfaceNode->IsHardwareForcedDisabled()) {
@ -2184,11 +2240,15 @@ bool RSMainThread::DoDirectComposition(std::shared_ptr<RSBaseRenderNode> rootNod
params->SetBufferSynced(true);
}
}
#endif
#ifdef RS_ENABLE_GPU
RSPointerWindowManager::Instance().HardCursorCreateLayerForDirect(processor);
RSUifirstManager::Instance().CreateUIFirstLayer(processor);
auto rcdInfo = std::make_unique<RcdInfo>();
DoScreenRcdTask(displayNode->GetId(), processor, rcdInfo, screenInfo);
#endif
if (waitForRT) {
#ifdef RS_ENABLE_GPU
RSUniRenderThread::Instance().PostSyncTask([processor, displayNode]() {
RS_TRACE_NAME("DoDirectComposition PostProcess");
auto& hgmCore = OHOS::Rosen::HgmCore::Instance();
@ -2196,11 +2256,14 @@ bool RSMainThread::DoDirectComposition(std::shared_ptr<RSBaseRenderNode> rootNod
processor->ProcessDisplaySurface(*displayNode);
processor->PostProcess();
});
#endif
} else {
auto& hgmCore = OHOS::Rosen::HgmCore::Instance();
hgmCore.SetDirectCompositionFlag(true);
#ifdef RS_ENABLE_GPU
processor->ProcessDisplaySurface(*displayNode);
processor->PostProcess();
#endif
}
RS_LOGD("RSMainThread::DoDirectComposition end");
@ -2219,13 +2282,16 @@ void RSMainThread::Render()
}
const std::shared_ptr<RSBaseRenderNode> rootNode = context_->GetGlobalRootRenderNode();
if (rootNode == nullptr) {
#ifdef RS_ENABLE_GPU
if (RSSystemProperties::GetGpuApiType() != GpuApiType::DDGR) {
WaitUntilUploadTextureTaskFinished(isUniRender_);
}
#endif
RS_LOGE("RSMainThread::Render GetGlobalRootRenderNode fail");
return;
}
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
auto& hgmCore = OHOS::Rosen::HgmCore::Instance();
renderThreadParams_->SetTimestamp(hgmCore.GetCurrentTimestamp());
renderThreadParams_->SetActualTimestamp(hgmCore.GetActualTimestamp());
@ -2243,6 +2309,7 @@ void RSMainThread::Render()
// so we use hgmCore to keep force refresh flag, then reset flag.
hgmCore.SetForceRefreshFlag(isForceRefresh_);
isForceRefresh_ = false;
#endif
}
if (RSSystemProperties::GetRenderNodeTraceEnabled()) {
RSPropertyTrace::GetInstance().RefreshNodeTraceInfo();
@ -2257,6 +2324,7 @@ void RSMainThread::Render()
RSSystemParameters::SetDumpRSTreeCount(dumpTreeCount - 1);
}
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
renderThreadParams_->SetWatermark(watermarkFlag_, watermarkImg_);
{
std::lock_guard<std::mutex> lock(watermarkMutex_);
@ -2264,8 +2332,11 @@ void RSMainThread::Render()
}
renderThreadParams_->SetCurtainScreenUsingStatus(isCurtainScreenOn_);
#ifdef RS_ENABLE_GPU
UniRender(rootNode);
#endif
frameCount_++;
#endif
} else {
auto rsVisitor = std::make_shared<RSRenderServiceVisitor>();
rsVisitor->SetAnimateState(doWindowAnimate_);
@ -2296,7 +2367,7 @@ void RSMainThread::OnUniRenderDraw()
if (!isUniRender_) {
return;
}
#ifdef RS_ENABLE_GPU
if (!doDirectComposition_ && needDrawFrame_ && !RSSystemProperties::GetScreenSwitchStatus()) {
renderThreadParams_->SetContext(context_);
renderThreadParams_->SetDiscardJankFrames(GetDiscardJankFrames());
@ -2317,6 +2388,7 @@ void RSMainThread::OnUniRenderDraw()
if (fr.GetEnable()) {
fr.RSRenderEnd();
}
#endif
}
void RSMainThread::CheckSystemSceneStatus()
@ -2343,8 +2415,13 @@ void RSMainThread::CheckSystemSceneStatus()
void RSMainThread::CallbackDrawContextStatusToWMS(bool isUniRender)
{
#ifdef RS_ENABLE_GPU
auto& curDrawStatusVec = isUniRender ? RSUniRenderThread::Instance().GetDrawStatusVec() : curDrawStatusVec_;
auto timestamp = isUniRender ? RSUniRenderThread::Instance().GetCurrentTimestamp() : timestamp_;
#else
auto& curDrawStatusVec = curDrawStatusVec_;
auto timestamp = timestamp_;
#endif
VisibleData drawStatusVec;
for (auto dynamicNodeId : curDrawStatusVec) {
if (lastDrawStatusMap_.find(dynamicNodeId) == lastDrawStatusMap_.end()) {
@ -2734,10 +2811,14 @@ bool RSMainThread::CheckSurfaceOcclusionNeedProcess(NodeId id)
bool RSMainThread::WaitHardwareThreadTaskExecute()
{
#ifdef RS_ENABLE_GPU
std::unique_lock<std::mutex> lock(hardwareThreadTaskMutex_);
return hardwareThreadTaskCond_.wait_until(lock, std::chrono::system_clock::now() +
std::chrono::milliseconds(WAIT_FOR_HARDWARE_THREAD_TASK_TIMEOUT),
[]() { return RSHardwareThread::Instance().GetunExecuteTaskNum() <= HARDWARE_THREAD_TASK_NUM; });
#else
return false;
#endif
}
void RSMainThread::NotifyHardwareThreadCanExecuteTask()
@ -2771,7 +2852,7 @@ void RSMainThread::ProcessScreenHotPlugEvents()
if (!screenManager_) {
return;
}
#ifdef RS_ENABLE_GPU
if (!screenManager_->TrySimpleProcessHotPlugEvents()) {
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
@ -2780,6 +2861,7 @@ void RSMainThread::ProcessScreenHotPlugEvents()
PostTask([=]() { screenManager_->ProcessScreenHotPlugEvents(); });
}
}
#endif
}
void RSMainThread::OnVsync(uint64_t timestamp, uint64_t frameCount, void* data)
@ -2799,6 +2881,7 @@ void RSMainThread::OnVsync(uint64_t timestamp, uint64_t frameCount, void* data)
vsyncId_ = frameCount;
frameCount_++;
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
MergeToEffectiveTransactionDataMap(cachedTransactionDataMap_);
if (RSUnmarshalThread::Instance().CachedTransactionDataEmpty()) {
// set needWaitUnmarshalFinished_ to false, it means mainLoop do not wait unmarshalBarrierTask_
@ -2808,6 +2891,7 @@ void RSMainThread::OnVsync(uint64_t timestamp, uint64_t frameCount, void* data)
RSUnmarshalThread::Instance().PostTask(unmarshalBarrierTask_);
}
}
#endif
}
mainLoop_();
#if defined(RS_ENABLE_CHIPSET_VSYNC)
@ -2821,6 +2905,7 @@ void RSMainThread::RSJankStatsOnVsyncStart(int64_t onVsyncStartTime, int64_t onV
float onVsyncStartTimeSteadyFloat)
{
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
if (!renderThreadParams_) {
// fill the params, and sync to render thread later
renderThreadParams_ = std::make_unique<RSRenderThreadParams>();
@ -2830,6 +2915,7 @@ void RSMainThread::RSJankStatsOnVsyncStart(int64_t onVsyncStartTime, int64_t onV
renderThreadParams_->SetOnVsyncStartTimeSteady(onVsyncStartTimeSteady);
renderThreadParams_->SetOnVsyncStartTimeSteadyFloat(onVsyncStartTimeSteadyFloat);
SetSkipJankAnimatorFrame(false);
#endif
}
}
@ -2847,15 +2933,16 @@ void RSMainThread::ClearSelfDrawingNodes()
{
selfDrawingNodes_.clear();
}
#ifdef RS_ENABLE_GPU
const std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& RSMainThread::GetSelfDrawables() const
{
return selfDrawables_;
}
#endif
void RSMainThread::RSJankStatsOnVsyncEnd(int64_t onVsyncStartTime, int64_t onVsyncStartTimeSteady,
float onVsyncStartTimeSteadyFloat)
{
#ifdef RS_ENABLE_GPU
if (isUniRender_ && doDirectComposition_) {
const JankDurationParams rsParams = { .timeStart_ = onVsyncStartTime,
.timeStartSteady_ = onVsyncStartTimeSteady,
@ -2871,6 +2958,7 @@ void RSMainThread::RSJankStatsOnVsyncEnd(int64_t onVsyncStartTime, int64_t onVsy
if (isUniRender_) {
SetDiscardJankFrames(false);
}
#endif
}
#if defined(RS_ENABLE_CHIPSET_VSYNC)
@ -2965,8 +3053,10 @@ void RSMainThread::Animate(uint64_t timestamp)
isCalculateAnimationValue = isCalculateAnimationValue || nodeCalculateAnimationValue;
if (node->template IsInstanceOf<RSSurfaceRenderNode>() && hasRunningAnimation) {
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
auto surfacenode = RSBaseRenderNode::ReinterpretCast<RSSurfaceRenderNode>(node);
surfacenode->SetAnimateState();
#endif
}
curWinAnim = true;
}
@ -3000,7 +3090,9 @@ void RSMainThread::Animate(uint64_t timestamp)
RS_TRACE_NAME("rs_RequestNextVSync");
}
} else if (isUniRender_) {
#ifdef RS_ENABLE_GPU
renderThreadParams_->SetImplicitAnimationEnd(true);
#endif
}
context_->SetRequestedNextVsyncAnimate(needRequestNextVsync);
@ -3060,9 +3152,11 @@ void RSMainThread::RecvRSTransactionData(std::unique_ptr<RSTransactionData>& rsT
return;
}
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
std::lock_guard<std::mutex> lock(transitionDataMutex_);
RSTransactionMetricCollector::GetInstance().Collect(rsTransactionData);
cachedTransactionDataMap_[rsTransactionData->GetSendingPid()].emplace_back(std::move(rsTransactionData));
#endif
} else {
ClassifyRSTransactionData(rsTransactionData);
}
@ -3276,9 +3370,10 @@ void RSMainThread::RenderServiceTreeDump(std::string& dumpString, bool forceDump
return;
}
rootNode->DumpTree(0, dumpString);
#ifdef RS_ENABLE_GPU
dumpString += "\n====================================\n";
RSUniRenderThread::Instance().RenderServiceTreeDump(dumpString);
#endif
} else {
dumpString += g_dumpStr;
g_dumpStr = "";
@ -3668,6 +3763,7 @@ void RSMainThread::PerfAfterAnim(bool needRequestNextVsync)
void RSMainThread::ForceRefreshForUni()
{
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
PostTask([=]() {
MergeToEffectiveTransactionDataMap(cachedTransactionDataMap_);
if (!RSSystemProperties::GetUnmarshParallelFlag()) {
@ -3693,6 +3789,7 @@ void RSMainThread::ForceRefreshForUni()
PostTask([=]() { screenManager_->ProcessScreenHotPlugEvents(); });
}
}
#endif
} else {
RequestNextVSync();
}
@ -3772,11 +3869,13 @@ void RSMainThread::RenderFrameStart(uint64_t timestamp)
RsFrameReport::GetInstance().RenderStart(timestamp);
}
RenderFrameTrace::GetInstance().RenderStartFrameTrace(RS_INTERVAL_NAME);
#ifdef RS_ENABLE_GPU
int hardwareTid = RSHardwareThread::Instance().GetHardwareTid();
if (hardwareTid_ != hardwareTid) {
hardwareTid_ = hardwareTid;
RsFrameReport::GetInstance().SetFrameParam(EVENT_SET_HARDWARE_UTIL, 0, 0, hardwareTid_);
}
#endif
}
void RSMainThread::SetAppWindowNum(uint32_t num)
@ -3890,6 +3989,7 @@ void RSMainThread::CheckAndUpdateInstanceContentStaticStatus(std::shared_ptr<RSS
void RSMainThread::ResetHardwareEnabledState(bool isUniRender)
{
if (isUniRender) {
#ifdef RS_ENABLE_GPU
isHardwareForcedDisabled_ = !RSSystemProperties::GetHardwareComposerEnabled();
isLastFrameDirectComposition_ = doDirectComposition_;
doDirectComposition_ = !isHardwareForcedDisabled_;
@ -3900,12 +4000,14 @@ void RSMainThread::ResetHardwareEnabledState(bool isUniRender)
ClearSelfDrawingNodes();
selfDrawables_.clear();
RSPointerWindowManager::Instance().ResetHardCursorDrawables();
#endif
}
}
bool RSMainThread::IsHardwareEnabledNodesNeedSync()
{
bool needSync = false;
#ifdef RS_ENABLE_GPU
for (const auto& node : hardwareEnabledNodes_) {
if (node != nullptr && ((!doDirectComposition_ && node->GetStagingRenderParams() != nullptr &&
node->GetStagingRenderParams()->NeedSync()) ||
@ -3914,6 +4016,7 @@ bool RSMainThread::IsHardwareEnabledNodesNeedSync()
break;
}
}
#endif
RS_TRACE_NAME_FMT("%s %u", __func__, needSync);
RS_LOGD("%{public}s %{public}u", __func__, needSync);
@ -4083,6 +4186,7 @@ const uint32_t FOLD_DEVICE_SCREEN_NUMBER = 2; // alt device has two screens
void RSMainThread::UpdateUIFirstSwitch()
{
#ifdef RS_ENABLE_GPU
const std::shared_ptr<RSBaseRenderNode> rootNode = context_->GetGlobalRootRenderNode();
if (!rootNode) {
RSUifirstManager::Instance().SetUiFirstSwitch(isUiFirstOn_);
@ -4109,6 +4213,7 @@ void RSMainThread::UpdateUIFirstSwitch()
}
isUiFirstOn_ = RSSystemProperties::GetUIFirstEnabled();
RSUifirstManager::Instance().SetUiFirstSwitch(isUiFirstOn_);
#endif
}
bool RSMainThread::IsUIFirstOn() const
@ -4163,11 +4268,13 @@ void RSMainThread::AddToReleaseQueue(std::shared_ptr<Drawing::Surface>&& surface
void RSMainThread::GetAppMemoryInMB(float& cpuMemSize, float& gpuMemSize)
{
#ifdef RS_ENABLE_GPU
RSUniRenderThread::Instance().PostSyncTask([&cpuMemSize, &gpuMemSize] {
gpuMemSize = MemoryManager::GetAppGpuMemoryInMB(
RSUniRenderThread::Instance().GetRenderEngine()->GetRenderContext()->GetDrGPUContext());
cpuMemSize = MemoryTrack::Instance().GetAppMemorySizeInMB();
});
#endif
}
void RSMainThread::SubscribeAppState()
@ -4202,8 +4309,10 @@ void RSMainThread::HandleOnTrim(Memory::SystemMemoryLevel level)
switch (level) {
case Memory::SystemMemoryLevel::MEMORY_LEVEL_CRITICAL:
if (isUniRender_) {
#ifdef RS_ENABLE_GPU
RSUniRenderThread::Instance().ClearMemoryCache(ClearMemoryMoment::LOW_MEMORY, true);
isNeedResetClearMemoryTask_ = true;
#endif
} else {
ClearMemoryCache(ClearMemoryMoment::LOW_MEMORY, true);
}
@ -4222,6 +4331,7 @@ void RSMainThread::HandleOnTrim(Memory::SystemMemoryLevel level)
void RSMainThread::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
{
#ifdef RS_ENABLE_GPU
if (isCurtainScreenOn_ == isCurtainScreenOn) {
RS_LOGD("RSMainThread::SetCurtainScreenUsingStatus: curtain screen status not change");
return;
@ -4232,6 +4342,7 @@ void RSMainThread::SetCurtainScreenUsingStatus(bool isCurtainScreenOn)
SetDirtyFlag();
RequestNextVSync();
RS_LOGD("RSMainThread::SetCurtainScreenUsingStatus %{public}d", isCurtainScreenOn);
#endif
}
void RSMainThread::SetLuminanceChangingStatus(ScreenId id, bool isLuminanceChanged)
@ -4337,7 +4448,9 @@ void RSMainThread::SetAncoForceDoDirect(bool direct)
void RSMainThread::UIExtensionNodesTraverseAndCallback()
{
std::lock_guard<std::mutex> lock(uiExtensionMutex_);
#ifdef RS_ENABLE_GPU
RSUniRenderUtil::UIExtensionFindAndTraverseAncestor(context_->GetNodeMap(), uiExtensionCallbackData_);
#endif
if (CheckUIExtensionCallbackDataChanged()) {
RS_OPTIONAL_TRACE_NAME_FMT("RSMainThread::UIExtensionNodesTraverseAndCallback data size: [%lu]",
uiExtensionCallbackData_.size());

View File

@ -128,7 +128,11 @@ public:
const std::shared_ptr<RSBaseRenderEngine> GetRenderEngine() const
{
RS_LOGD("You'd better to call GetRenderEngine from RSUniRenderThread directly");
#ifdef RS_ENABLE_GPU
return isUniRender_ ? std::move(RSUniRenderThread::Instance().GetRenderEngine()) : renderEngine_;
#else
return renderEngine_;
#endif
}
bool GetClearMemoryFinished() const
@ -301,8 +305,9 @@ public:
void AddSelfDrawingNodes(std::shared_ptr<RSSurfaceRenderNode> selfDrawingNode);
const std::vector<std::shared_ptr<RSSurfaceRenderNode>>& GetSelfDrawingNodes() const;
void ClearSelfDrawingNodes();
#ifdef RS_ENABLE_GPU
const std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr>& GetSelfDrawables() const;
#endif
bool GetDiscardJankFrames() const
{
return discardJankFrames_.load();
@ -610,16 +615,21 @@ private:
// used for hardware enabled case
bool doDirectComposition_ = true;
#ifdef RS_ENABLE_GPU
bool needDrawFrame_ = true;
#endif
bool isLastFrameDirectComposition_ = false;
bool isNeedResetClearMemoryTask_ = false;
bool isHardwareEnabledBufferUpdated_ = false;
std::vector<std::shared_ptr<RSSurfaceRenderNode>> hardwareEnabledNodes_;
std::vector<std::shared_ptr<RSSurfaceRenderNode>> selfDrawingNodes_;
#ifdef RS_ENABLE_GPU
std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> selfDrawables_;
#endif
bool isHardwareForcedDisabled_ = false; // if app node has shadow or filter, disable hardware composer for all
#ifdef RS_ENABLE_GPU
std::vector<DrawableV2::RSRenderNodeDrawableAdapter::SharedPtr> hardwareEnabledDrwawables_;
#endif
// for client node tree dump
struct NodeTreeDumpTask {
size_t count = 0;
@ -710,7 +720,9 @@ private:
#endif
pid_t exitedPid_ = -1;
std::set<pid_t> exitedPidSet_;
#ifdef RS_ENABLE_GPU
RSDrawFrame drawFrame_;
#endif
std::unique_ptr<RSRenderThreadParams> renderThreadParams_ = nullptr; // sync to render thread
RsParallelType rsParallelType_;
bool isCurtainScreenOn_ = false;

View File

@ -34,10 +34,12 @@ RSPhysicalScreenProcessor::~RSPhysicalScreenProcessor() noexcept
bool RSPhysicalScreenProcessor::Init(RSDisplayRenderNode& node, int32_t offsetX, int32_t offsetY, ScreenId mirroredId,
std::shared_ptr<RSBaseRenderEngine> renderEngine)
{
#ifdef RS_ENABLE_GPU
// planning: adapt isRenderThread
if (!RSProcessor::Init(node, offsetX, offsetY, mirroredId, renderEngine)) {
return false;
}
#endif
return composerAdapter_->Init(node, screenInfo_, mirroredScreenInfo_, mirrorAdaptiveCoefficient_,
[this](const auto& surface, const auto& layers) { Redraw(surface, layers); });

View File

@ -16,9 +16,10 @@
#include "pipeline/rs_pointer_window_manager.h"
#include "common/rs_optional_trace.h"
#include "pipeline/rs_main_thread.h"
#ifdef RS_ENABLE_GPU
#include "pipeline/rs_uni_render_util.h"
#include "screen_manager/screen_types.h"
#endif
namespace OHOS {
namespace Rosen {
RSPointerWindowManager& RSPointerWindowManager::Instance()
@ -52,6 +53,7 @@ void RSPointerWindowManager::UpdatePointerDirtyToGlobalDirty(std::shared_ptr<RSS
void RSPointerWindowManager::UpdatePointerInfo()
{
#ifdef RS_ENABLE_GPU
int64_t rsNodeId = 0;
BoundParam boundTemp = {0.0f, 0.0f, 0.0f, 0.0f};
{
@ -97,11 +99,13 @@ void RSPointerWindowManager::UpdatePointerInfo()
auto transform = RSUniRenderUtil::GetLayerTransform(*surfaceNode, screenInfo);
surfaceNode->UpdateHwcNodeLayerInfo(transform, isPointerEnableHwc_);
}
#endif
}
void RSPointerWindowManager::SetHwcNodeBounds(int64_t rsNodeId, float positionX, float positionY,
float positionZ, float positionW)
{
#ifdef RS_ENABLE_GPU
// record status here
{
std::lock_guard<std::mutex> lock(mtx_);
@ -109,6 +113,7 @@ void RSPointerWindowManager::SetHwcNodeBounds(int64_t rsNodeId, float positionX,
SetRsNodeId(rsNodeId);
}
SetBoundHasUpdate(true);
#endif
}
void RSPointerWindowManager::SetHardCursorNodeInfo(std::shared_ptr<RSSurfaceRenderNode> hardCursorNode)
@ -129,6 +134,7 @@ const std::shared_ptr<RSSurfaceRenderNode>& RSPointerWindowManager::GetHardCurso
void RSPointerWindowManager::HardCursorCreateLayerForDirect(std::shared_ptr<RSProcessor> processor)
{
#ifdef RS_ENABLE_GPU
auto hardCursorNode = GetHardCursorNode();
if (hardCursorNode && hardCursorNode->IsHardwareEnabledTopSurface()) {
auto surfaceHandler = hardCursorNode->GetRSSurfaceHandler();
@ -140,6 +146,7 @@ void RSPointerWindowManager::HardCursorCreateLayerForDirect(std::shared_ptr<RSPr
RS_OPTIONAL_TRACE_NAME("HardCursorCreateLayerForDirect create layer");
processor->CreateLayer(*hardCursorNode, *params);
}
#endif
}
bool RSPointerWindowManager::CheckHardCursorSupport(std::shared_ptr<RSDisplayRenderNode>& curDisplayNode)

View File

@ -65,6 +65,7 @@ void PerfRequest(int32_t perfRequestCode, bool onOffTag)
bool RSProcessor::InitForRenderThread(DrawableV2::RSDisplayRenderNodeDrawable& displayDrawable, ScreenId mirroredId,
std::shared_ptr<RSBaseRenderEngine> renderEngine)
{
#ifdef RS_ENABLE_GPU
if (renderEngine == nullptr) {
RS_LOGE("renderEngine is nullptr");
return false;
@ -100,6 +101,7 @@ bool RSProcessor::InitForRenderThread(DrawableV2::RSDisplayRenderNodeDrawable& d
// set default render frame config
renderFrameConfig_ = RSBaseRenderUtil::GetFrameBufferRequestConfig(screenInfo_);
#endif
return true;
}

View File

@ -28,7 +28,9 @@
namespace OHOS {
namespace Rosen {
class RSRcdSurfaceRenderNode;
#ifdef RS_ENABLE_GPU
class RSDisplayRenderParams;
#endif
class RSSurfaceRenderParams;
namespace DrawableV2 {
class RSDisplayRenderNodeDrawable;

View File

@ -30,11 +30,15 @@ std::shared_ptr<RSProcessor> RSProcessorFactory::CreateProcessor(RSDisplayRender
return std::make_shared<RSVirtualScreenProcessor>();
case RSDisplayRenderNode::CompositeType::HARDWARE_COMPOSITE:
return std::make_shared<RSPhysicalScreenProcessor>();
#ifdef RS_ENABLE_GPU
case RSDisplayRenderNode::CompositeType::UNI_RENDER_COMPOSITE:
return std::make_shared<RSUniRenderProcessor>();
#endif
case RSDisplayRenderNode::CompositeType::UNI_RENDER_MIRROR_COMPOSITE:
case RSDisplayRenderNode::CompositeType::UNI_RENDER_EXPAND_COMPOSITE:
#ifdef RS_ENABLE_GPU
return std::make_shared<RSUniRenderVirtualProcessor>();
#endif
default:
return nullptr;
}

View File

@ -33,10 +33,11 @@
#include "common/rs_singleton.h"
#include "graphic_2d_configure.h"
#include "pipeline/parallel_render/rs_sub_thread_manager.h"
#include "pipeline/round_corner_display/rs_message_bus.h"
#ifdef RS_ENABLE_GPU
#include "pipeline/round_corner_display/rs_rcd_render_manager.h"
#include "pipeline/round_corner_display/rs_round_corner_display_manager.h"
#endif
#include "pipeline/rs_hardware_thread.h"
#include "pipeline/rs_surface_render_node.h"
#include "pipeline/rs_uni_render_judgement.h"
@ -96,9 +97,11 @@ bool RSRenderService::Init()
return false;
}
} else {
#ifdef RS_ENABLE_GPU
RSUniRenderThread::Instance().Start();
RSHardwareThread::Instance().Start();
RegisterRcdMsg();
#endif
}
auto generator = CreateVSyncGenerator();
@ -167,6 +170,7 @@ void RSRenderService::Run()
void RSRenderService::RegisterRcdMsg()
{
#ifdef RS_ENABLE_GPU
if (RSSingleton<RoundCornerDisplayManager>::GetInstance().GetRcdEnable()) {
RS_LOGD("RSSubThreadManager::RegisterRcdMsg");
if (!isRcdServiceRegister_) {
@ -191,6 +195,7 @@ void RSRenderService::RegisterRcdMsg()
}
RS_LOGD("RSSubThreadManager::RegisterRcdMsg Registed rcd renderservice already.");
}
#endif
}
sptr<RSIRenderServiceConnection> RSRenderService::CreateConnection(const sptr<RSIConnectionToken>& token)
@ -361,8 +366,10 @@ void RSRenderService::FPSDUMPProcess(std::unordered_set<std::u16string>& argSets
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[this, &dumpString, &layerArg]() { return screenManager_->FpsDump(dumpString, layerArg); }).wait();
#endif
} else {
mainThread_->ScheduleTask(
[this, &dumpString, &layerArg]() { return screenManager_->FpsDump(dumpString, layerArg); }).wait();
@ -383,10 +390,12 @@ void RSRenderService::FPSDUMPClearProcess(std::unordered_set<std::u16string>& ar
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[this, &dumpString, &layerArg]() {
return screenManager_->ClearFpsDump(dumpString, layerArg);
}).wait();
#endif
} else {
mainThread_->ScheduleTask(
[this, &dumpString, &layerArg]() {
@ -407,21 +416,27 @@ void RSRenderService::DumpRenderServiceTree(std::string& dumpString, bool forceD
{
dumpString.append("\n");
dumpString.append("-- RenderServiceTreeDump: \n");
#ifdef RS_ENABLE_GPU
mainThread_->RenderServiceTreeDump(dumpString, forceDumpSingleFrame);
#endif
}
void RSRenderService::DumpRefreshRateCounts(std::string& dumpString) const
{
dumpString.append("\n");
dumpString.append("-- RefreshRateCounts: \n");
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().RefreshRateCounts(dumpString);
#endif
}
void RSRenderService::DumpClearRefreshRateCounts(std::string& dumpString) const
{
dumpString.append("\n");
dumpString.append("-- ClearRefreshRateCounts: \n");
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ClearRefreshRateCounts(dumpString);
#endif
}
void RSRenderService::WindowHitchsDump(
@ -436,8 +451,10 @@ void RSRenderService::WindowHitchsDump(
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[this, &dumpString, &layerArg]() { return screenManager_->HitchsDump(dumpString, layerArg); }).wait();
#endif
} else {
mainThread_->ScheduleTask(
[this, &dumpString, &layerArg]() { return screenManager_->HitchsDump(dumpString, layerArg); }).wait();
@ -611,8 +628,10 @@ void RSRenderService::DoDump(std::unordered_set<std::u16string>& argSets, std::s
if (argSets.count(arg9) || argSets.count(arg1) != 0) {
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[this, &dumpString]() { screenManager_->DisplayDump(dumpString); }).wait();
#endif
} else {
mainThread_->ScheduleTask(
[this, &dumpString]() { screenManager_->DisplayDump(dumpString); }).wait();

View File

@ -31,7 +31,9 @@
#include "common/rs_background_thread.h"
#include "drawable/rs_canvas_drawing_render_node_drawable.h"
#include "include/gpu/GrDirectContext.h"
#ifdef RS_ENABLE_GPU
#include "pipeline/parallel_render/rs_sub_thread_manager.h"
#endif
#include "pipeline/rs_canvas_drawing_render_node.h"
#include "pipeline/rs_pointer_window_manager.h"
#ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
@ -84,7 +86,9 @@ RSRenderServiceConnection::RSRenderServiceConnection(
: remotePid_(remotePid),
renderService_(renderService),
mainThread_(mainThread),
#ifdef RS_ENABLE_GPU
renderThread_(RSUniRenderThread::Instance()),
#endif
screenManager_(screenManager),
token_(token),
connDeathRecipient_(new RSConnectionDeathRecipient(this)),
@ -694,8 +698,10 @@ void RSRenderServiceConnection::SetScreenActiveMode(ScreenId id, uint32_t modeId
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { screenManager_->SetScreenActiveMode(id, modeId); }).wait();
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { screenManager_->SetScreenActiveMode(id, modeId); }).wait();
@ -818,6 +824,7 @@ std::string RSRenderServiceConnection::GetRefreshInfo(pid_t pid)
std::string dumpString;
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[weakThis = wptr<RSRenderServiceConnection>(this), &dumpString, &surfaceName]() {
sptr<RSRenderServiceConnection> connection = weakThis.promote();
@ -826,6 +833,7 @@ std::string RSRenderServiceConnection::GetRefreshInfo(pid_t pid)
}
connection->screenManager_->FpsDump(dumpString, surfaceName);
}).wait();
#endif
} else {
mainThread_->ScheduleTask(
[weakThis = wptr<RSRenderServiceConnection>(this), &dumpString, &surfaceName]() {
@ -853,8 +861,12 @@ int32_t RSRenderServiceConnection::SetVirtualScreenResolution(ScreenId id, uint3
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetVirtualScreenResolution(id, width, height); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetVirtualScreenResolution(id, width, height); }).get();
@ -865,6 +877,7 @@ void RSRenderServiceConnection::MarkPowerOffNeedProcessOneFrame()
{
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
renderThread_.PostTask(
[weakThis = wptr<RSRenderServiceConnection>(this)]() {
sptr<RSRenderServiceConnection> connection = weakThis.promote();
@ -874,6 +887,7 @@ void RSRenderServiceConnection::MarkPowerOffNeedProcessOneFrame()
connection->screenManager_->MarkPowerOffNeedProcessOneFrame();
}
);
#endif
}
}
@ -881,6 +895,7 @@ void RSRenderServiceConnection::DisablePowerOffRenderControl(ScreenId id)
{
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
renderThread_.PostTask(
[weakThis = wptr<RSRenderServiceConnection>(this), id]() {
sptr<RSRenderServiceConnection> connection = weakThis.promote();
@ -890,6 +905,7 @@ void RSRenderServiceConnection::DisablePowerOffRenderControl(ScreenId id)
connection->screenManager_->DisablePowerOffRenderControl(id);
}
);
#endif
}
}
@ -900,6 +916,7 @@ void RSRenderServiceConnection::SetScreenPowerStatus(ScreenId id, ScreenPowerSta
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[=]() { screenManager_->SetScreenPowerStatus(id, status); }).wait();
mainThread_->SetDiscardJankFrames(true);
@ -907,6 +924,7 @@ void RSRenderServiceConnection::SetScreenPowerStatus(ScreenId id, ScreenPowerSta
HgmTaskHandleThread::Instance().PostTask([id, status]() {
OHOS::Rosen::HgmCore::Instance().NotifyScreenPowerStatus(id, status);
});
#endif
} else {
mainThread_->ScheduleTask(
[=]() { screenManager_->SetScreenPowerStatus(id, status); }).wait();
@ -917,6 +935,7 @@ namespace {
void TakeSurfaceCaptureForUiParallel(
NodeId id, sptr<RSISurfaceCaptureCallback> callback, const RSSurfaceCaptureConfig& captureConfig)
{
#ifdef RS_ENABLE_GPU
RS_LOGI("TakeSurfaceCaptureForUiParallel nodeId:[%{public}" PRIu64 "], issync:%{public}s", id,
captureConfig.isSync ? "true" : "false");
std::function<void()> captureTask = [id, callback, captureConfig]() {
@ -940,11 +959,13 @@ void TakeSurfaceCaptureForUiParallel(
} else {
RSMainThread::Instance()->AddUiCaptureTask(id, captureTask);
}
#endif
}
void TakeSurfaceCaptureForUIWithUni(NodeId id, sptr<RSISurfaceCaptureCallback> callback,
const RSSurfaceCaptureConfig& captureConfig)
{
#ifdef RS_ENABLE_GPU
std::function<void()> offscreenRenderTask = [id, callback, captureConfig]() -> void {
RS_LOGD("RSRenderService::TakeSurfaceCaptureForUIWithUni callback->OnOffscreenRender"
" nodeId:[%{public}" PRIu64 "]", id);
@ -965,6 +986,7 @@ void TakeSurfaceCaptureForUIWithUni(NodeId id, sptr<RSISurfaceCaptureCallback> c
RSOffscreenRenderThread::Instance().PostTask(offscreenRenderTask);
node->SetCommandExecuted(false);
}
#endif
}
}
@ -1023,8 +1045,10 @@ void RSRenderServiceConnection::TakeSurfaceCapture(NodeId id, sptr<RSISurfaceCap
}
ROSEN_TRACE_END(HITRACE_TAG_GRAPHIC_AGP);
} else {
#ifdef RS_ENABLE_GPU
RSSurfaceCaptureTaskParallel::CheckModifiers(id, captureConfig.useCurWindow);
RSSurfaceCaptureTaskParallel::Capture(id, callback, captureConfig, isSystemCalling);
#endif
}
};
mainThread_->PostTask(captureTask);
@ -1094,8 +1118,12 @@ RSScreenModeInfo RSRenderServiceConnection::GetScreenActiveMode(ScreenId id)
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ScheduleTask(
[=, &screenModeInfo]() { return screenManager_->GetScreenActiveMode(id, screenModeInfo); }).wait();
#else
return screenModeInfo;
#endif
} else {
mainThread_->ScheduleTask(
[=, &screenModeInfo]() { return screenManager_->GetScreenActiveMode(id, screenModeInfo); }).wait();
@ -1105,8 +1133,10 @@ RSScreenModeInfo RSRenderServiceConnection::GetScreenActiveMode(ScreenId id)
bool RSRenderServiceConnection::GetTotalAppMemSize(float& cpuMemSize, float& gpuMemSize)
{
#ifdef RS_ENABLE_GPU
RSMainThread::Instance()->GetAppMemoryInMB(cpuMemSize, gpuMemSize);
gpuMemSize += RSSubThreadManager::Instance()->GetAppGpuMemoryInMB();
#endif
return true;
}
@ -1157,8 +1187,12 @@ std::vector<RSScreenModeInfo> RSRenderServiceConnection::GetScreenSupportedModes
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->GetScreenSupportedModes(id); }).get();
#else
return std::vector<RSScreenModeInfo>();
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->GetScreenSupportedModes(id); }).get();
@ -1173,8 +1207,12 @@ RSScreenCapability RSRenderServiceConnection::GetScreenCapability(ScreenId id)
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->GetScreenCapability(id); }).get();
#else
return screenCapability;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->GetScreenCapability(id); }).get();
@ -1188,8 +1226,12 @@ ScreenPowerStatus RSRenderServiceConnection::GetScreenPowerStatus(ScreenId id)
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->GetScreenPowerStatus(id); }).get();
#else
return ScreenPowerStatus::INVALID_POWER_STATUS;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->GetScreenPowerStatus(id); }).get();
@ -1204,8 +1246,12 @@ RSScreenData RSRenderServiceConnection::GetScreenData(ScreenId id)
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->GetScreenData(id); }).get();
#else
return screenData;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->GetScreenData(id); }).get();
@ -1219,8 +1265,12 @@ int32_t RSRenderServiceConnection::GetScreenBacklight(ScreenId id)
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->GetScreenBacklight(id); }).get();
#else
return INVALID_BACKLIGHT_VALUE;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->GetScreenBacklight(id); }).get();
@ -1250,7 +1300,9 @@ void RSRenderServiceConnection::SetScreenBacklight(ScreenId id, uint32_t level)
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
screenManager_->SetScreenBacklight(id, level);
#endif
} else {
mainThread_->ScheduleTask(
[=]() { screenManager_->SetScreenBacklight(id, level); }).wait();
@ -1311,8 +1363,12 @@ int32_t RSRenderServiceConnection::GetScreenSupportedColorGamuts(ScreenId id, st
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &mode]() { return screenManager_->GetScreenSupportedColorGamuts(id, mode); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &mode]() { return screenManager_->GetScreenSupportedColorGamuts(id, mode); }).get();
@ -1326,8 +1382,12 @@ int32_t RSRenderServiceConnection::GetScreenSupportedMetaDataKeys(ScreenId id, s
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &keys]() { return screenManager_->GetScreenSupportedMetaDataKeys(id, keys); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &keys]() { return screenManager_->GetScreenSupportedMetaDataKeys(id, keys); }).get();
@ -1341,8 +1401,12 @@ int32_t RSRenderServiceConnection::GetScreenColorGamut(ScreenId id, ScreenColorG
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &mode]() { return screenManager_->GetScreenColorGamut(id, mode); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &mode]() { return screenManager_->GetScreenColorGamut(id, mode); }).get();
@ -1356,8 +1420,12 @@ int32_t RSRenderServiceConnection::SetScreenColorGamut(ScreenId id, int32_t mode
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetScreenColorGamut(id, modeIdx); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetScreenColorGamut(id, modeIdx); }).get();
@ -1371,8 +1439,12 @@ int32_t RSRenderServiceConnection::SetScreenGamutMap(ScreenId id, ScreenGamutMap
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetScreenGamutMap(id, mode); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetScreenGamutMap(id, mode); }).get();
@ -1431,8 +1503,12 @@ int32_t RSRenderServiceConnection::GetScreenGamutMap(ScreenId id, ScreenGamutMap
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &mode]() { return screenManager_->GetScreenGamutMap(id, mode); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &mode]() { return screenManager_->GetScreenGamutMap(id, mode); }).get();
@ -1455,8 +1531,12 @@ int32_t RSRenderServiceConnection::GetPixelFormat(ScreenId id, GraphicPixelForma
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &pixelFormat]() { return screenManager_->GetPixelFormat(id, pixelFormat); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &pixelFormat]() { return screenManager_->GetPixelFormat(id, pixelFormat); }).get();
@ -1470,8 +1550,12 @@ int32_t RSRenderServiceConnection::SetPixelFormat(ScreenId id, GraphicPixelForma
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetPixelFormat(id, pixelFormat); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetPixelFormat(id, pixelFormat); }).get();
@ -1485,8 +1569,12 @@ int32_t RSRenderServiceConnection::GetScreenSupportedHDRFormats(ScreenId id, std
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &hdrFormats]() { return screenManager_->GetScreenSupportedHDRFormats(id, hdrFormats); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &hdrFormats]() { return screenManager_->GetScreenSupportedHDRFormats(id, hdrFormats); }).get();
@ -1500,8 +1588,12 @@ int32_t RSRenderServiceConnection::GetScreenHDRFormat(ScreenId id, ScreenHDRForm
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &hdrFormat]() { return screenManager_->GetScreenHDRFormat(id, hdrFormat); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &hdrFormat]() { return screenManager_->GetScreenHDRFormat(id, hdrFormat); }).get();
@ -1515,8 +1607,12 @@ int32_t RSRenderServiceConnection::SetScreenHDRFormat(ScreenId id, int32_t modeI
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetScreenHDRFormat(id, modeIdx); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetScreenHDRFormat(id, modeIdx); }).get();
@ -1531,8 +1627,12 @@ int32_t RSRenderServiceConnection::GetScreenSupportedColorSpaces(
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &colorSpaces]() { return screenManager_->GetScreenSupportedColorSpaces(id, colorSpaces); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &colorSpaces]() { return screenManager_->GetScreenSupportedColorSpaces(id, colorSpaces); }).get();
@ -1546,8 +1646,12 @@ int32_t RSRenderServiceConnection::GetScreenColorSpace(ScreenId id, GraphicCM_Co
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=, &colorSpace]() { return screenManager_->GetScreenColorSpace(id, colorSpace); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=, &colorSpace]() { return screenManager_->GetScreenColorSpace(id, colorSpace); }).get();
@ -1561,8 +1665,12 @@ int32_t RSRenderServiceConnection::SetScreenColorSpace(ScreenId id, GraphicCM_Co
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetScreenColorSpace(id, colorSpace); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetScreenColorSpace(id, colorSpace); }).get();
@ -1586,6 +1694,7 @@ bool RSRenderServiceConnection::GetBitmap(NodeId id, Drawing::Bitmap& bitmap)
std::promise<bool> result;
std::future<bool> future = result.get_future();
RSMainThread* mainThread = mainThread_;
#ifdef RS_ENABLE_GPU
RSUniRenderThread* renderThread = &renderThread_;
auto getBitmapTask = [id, &bitmap, mainThread, renderThread, &result]() {
auto node = mainThread->GetContext().GetNodeMap().GetRenderNode<RSCanvasDrawingRenderNode>(id);
@ -1609,6 +1718,7 @@ bool RSRenderServiceConnection::GetBitmap(NodeId id, Drawing::Bitmap& bitmap)
renderThread->PostTask(getDrawableBitmapTask);
};
mainThread_->PostTask(getBitmapTask);
#endif
return future.get();
}
@ -1620,6 +1730,7 @@ bool RSRenderServiceConnection::GetPixelmap(NodeId id, const std::shared_ptr<Med
}
std::promise<bool> result;
std::future<bool> future = result.get_future();
#ifdef RS_ENABLE_GPU
RSMainThread* mainThread = mainThread_;
RSUniRenderThread* renderThread = &renderThread_;
auto getPixelMapTask = [id, pixelmap, rect, drawCmdList, mainThread, renderThread, &result]() {
@ -1661,6 +1772,7 @@ bool RSRenderServiceConnection::GetPixelmap(NodeId id, const std::shared_ptr<Med
}
};
mainThread_->PostTask(getPixelMapTask);
#endif
return future.get();
}
@ -1689,8 +1801,12 @@ int32_t RSRenderServiceConnection::SetScreenSkipFrameInterval(ScreenId id, uint3
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[=]() { return screenManager_->SetScreenSkipFrameInterval(id, skipFrameInterval); }).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[=]() { return screenManager_->SetScreenSkipFrameInterval(id, skipFrameInterval); }).get();
@ -1821,8 +1937,12 @@ bool RSRenderServiceConnection::SetSystemAnimatedScenes(SystemAnimatedScenes sys
if (!mainThread_) {
return false;
}
#ifdef RS_ENABLE_GPU
RSUifirstManager::Instance().OnProcessAnimateScene(systemAnimatedScenes);
return mainThread_->SetSystemAnimatedScenes(systemAnimatedScenes);
#else
return false;
#endif
}
void RSRenderServiceConnection::ShowWatermark(const std::shared_ptr<Media::PixelMap> &watermarkImg, bool isShow)
@ -1847,6 +1967,7 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid
}
auto renderType = RSUniRenderJudgement::GetUniRenderEnabledType();
if (renderType == UniRenderEnabledType::UNI_RENDER_ENABLED_FOR_ALL) {
#ifdef RS_ENABLE_GPU
return RSHardwareThread::Instance().ScheduleTask(
[weakThis = wptr<RSRenderServiceConnection>(this), id, width, height]() -> int32_t {
sptr<RSRenderServiceConnection> connection = weakThis.promote();
@ -1856,6 +1977,9 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid
return connection->screenManager_->ResizeVirtualScreen(id, width, height);
}
).get();
#else
return StatusCode::SCREEN_NOT_FOUND;
#endif
} else {
return mainThread_->ScheduleTask(
[weakThis = wptr<RSRenderServiceConnection>(this), id, width, height]() -> int32_t {
@ -1871,8 +1995,10 @@ int32_t RSRenderServiceConnection::ResizeVirtualScreen(ScreenId id, uint32_t wid
void RSRenderServiceConnection::ReportJankStats()
{
#ifdef RS_ENABLE_GPU
auto task = []() -> void { RSJankStats::GetInstance().ReportJankStats(); };
renderThread_.PostTask(task);
#endif
}
void RSRenderServiceConnection::NotifyLightFactorStatus(bool isSafe)
@ -1930,8 +2056,10 @@ void RSRenderServiceConnection::ReportEventResponse(DataBaseRs info)
auto task = [info]() -> void {
RSJankStats::GetInstance().SetReportEventResponse(info);
};
#ifdef RS_ENABLE_GPU
renderThread_.PostTask(task);
RSUifirstManager::Instance().OnProcessEventResponse(info);
#endif
}
void RSRenderServiceConnection::ReportEventComplete(DataBaseRs info)
@ -1939,17 +2067,21 @@ void RSRenderServiceConnection::ReportEventComplete(DataBaseRs info)
auto task = [info]() -> void {
RSJankStats::GetInstance().SetReportEventComplete(info);
};
#ifdef RS_ENABLE_GPU
renderThread_.PostTask(task);
RSUifirstManager::Instance().OnProcessEventComplete(info);
#endif
}
void RSRenderServiceConnection::ReportEventJankFrame(DataBaseRs info)
{
#ifdef RS_ENABLE_GPU
bool isReportTaskDelayed = renderThread_.IsMainLooping();
auto task = [info, isReportTaskDelayed]() -> void {
RSJankStats::GetInstance().SetReportEventJankFrame(info, isReportTaskDelayed);
};
renderThread_.PostTask(task);
#endif
}
void RSRenderServiceConnection::ReportGameStateData(GameStateData info)
@ -2031,16 +2163,24 @@ void RSRenderServiceConnection::SetDefaultDeviceRotationOffset(uint32_t offset)
std::vector<ActiveDirtyRegionInfo> RSRenderServiceConnection::GetActiveDirtyRegionInfo()
{
#ifdef RS_ENABLE_GPU
const auto& activeDirtyRegionInfos = GpuDirtyRegionCollection::GetInstance().GetActiveDirtyRegionInfo();
GpuDirtyRegionCollection::GetInstance().ResetActiveDirtyRegionInfo();
return activeDirtyRegionInfos;
#else
return {};
#endif
}
GlobalDirtyRegionInfo RSRenderServiceConnection::GetGlobalDirtyRegionInfo()
{
#ifdef RS_ENABLE_GPU
const auto& globalDirtyRegionInfo = GpuDirtyRegionCollection::GetInstance().GetGlobalDirtyRegionInfo();
GpuDirtyRegionCollection::GetInstance().ResetGlobalDirtyRegionInfo();
return globalDirtyRegionInfo;
#else
return {};
#endif
}
LayerComposeInfo RSRenderServiceConnection::GetLayerComposeInfo()
@ -2057,7 +2197,9 @@ HwcDisabledReasonInfos RSRenderServiceConnection::GetHwcDisabledReasonInfo()
void RSRenderServiceConnection::SetVmaCacheStatus(bool flag)
{
#ifdef RS_ENABLE_GPU
renderThread_.SetVmaCacheStatus(flag);
#endif
}
#ifdef TP_FEATURE_ENABLE
@ -2156,10 +2298,12 @@ bool RSRenderServiceConnection::SetAncoForceDoDirect(bool direct)
void RSRenderServiceConnection::SetFreeMultiWindowStatus(bool enable)
{
#ifdef RS_ENABLE_GPU
auto task = [enable]() -> void {
RSUifirstManager::Instance().SetFreeMultiWindowStatus(enable);
};
mainThread_->PostTask(task);
#endif
}
void RSRenderServiceConnection::RegisterSurfaceBufferCallback(pid_t pid, uint64_t uid,

View File

@ -328,7 +328,9 @@ private:
pid_t remotePid_;
wptr<RSRenderService> renderService_;
RSMainThread* mainThread_ = nullptr;
#ifdef RS_ENABLE_GPU
RSUniRenderThread& renderThread_;
#endif
sptr<RSScreenManager> screenManager_;
sptr<IRemoteObject> token_;

View File

@ -334,6 +334,7 @@ void RSUifirstManager::ProcessDoneNode()
void RSUifirstManager::SyncHDRDisplayParam(std::shared_ptr<DrawableV2::RSSurfaceRenderNodeDrawable> drawable)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(drawable->GetRenderParams().get());
if (!surfaceParams || !surfaceParams->GetAncestorDisplayNode().lock()) {
return;
@ -362,6 +363,7 @@ void RSUifirstManager::SyncHDRDisplayParam(std::shared_ptr<DrawableV2::RSSurface
}
RS_LOGD("UIFirstHDR SyncDisplayParam:%{public}d, ratio:%{public}f", drawable->GetHDRPresent(),
surfaceParams->GetBrightnessRatio());
#endif
}
bool RSUifirstManager::CheckVisibleDirtyRegionIsEmpty(const std::shared_ptr<RSSurfaceRenderNode>& node)

View File

@ -18,7 +18,9 @@
#include "luminance/rs_luminance_control.h"
#include "pipeline/rs_uni_render_engine.h"
#include "pipeline/rs_uni_render_util.h"
#ifdef RS_ENABLE_GPU
#include "pipeline/round_corner_display/rs_round_corner_display_manager.h"
#endif
#ifdef USE_VIDEO_PROCESSING_ENGINE
#include "metadata_helper.h"
#endif

View File

@ -1407,10 +1407,12 @@ bool RSUniRenderVisitor::BeforeUpdateSurfaceDirtyCalc(RSSurfaceRenderNode& node)
if (node.GetRSSurfaceHandler() && node.GetRSSurfaceHandler()->GetBuffer()) {
node.SetBufferRelMatrix(RSUniRenderUtil::GetMatrixOfBufferToRelRect(node));
}
#ifdef RS_ENABLE_GPU
if (node.IsHardwareEnabledTopSurface() && node.ShouldPaint()) {
RSPointerWindowManager::Instance().CollectInfoForHardCursor(curDisplayNode_->GetId(),
node.GetRenderDrawable());
}
#endif
node.setQosCal((RSMainThread::Instance()->GetDeviceType() == DeviceType::PC) &&
RSSystemParameters::GetVSyncControlEnabled());
return true;

View File

@ -38,9 +38,11 @@ RSVirtualScreenProcessor::~RSVirtualScreenProcessor() noexcept
bool RSVirtualScreenProcessor::Init(RSDisplayRenderNode& node, int32_t offsetX, int32_t offsetY, ScreenId mirroredId,
std::shared_ptr<RSBaseRenderEngine> renderEngine)
{
#ifdef RS_ENABLE_GPU
if (!RSProcessor::Init(node, offsetX, offsetY, mirroredId, renderEngine)) {
return false;
}
#endif
if (mirroredId != INVALID_SCREEN_ID) {
SetMirrorScreenSwap(node);

View File

@ -411,7 +411,9 @@ void RSScreenManager::OnHwcDeadEvent()
if (screen->IsVirtual()) {
continue;
} else {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().ClearFrameBuffers(screen->GetOutput());
#endif
}
}
}
@ -438,9 +440,11 @@ void RSScreenManager::OnScreenVBlankIdleEvent(uint32_t devId, uint64_t ns)
RS_LOGW("RSScreenManager %{public}s: There is no screen for id %{public}" PRIu64 ".", __func__, screenId);
return;
}
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().PostTask([screenId, ns]() {
RSHardwareThread::Instance().OnScreenVBlankIdleCallback(screenId, ns);
});
#endif
}
void RSScreenManager::CleanAndReinit()
@ -472,6 +476,7 @@ void RSScreenManager::CleanAndReinit()
}
});
} else {
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().PostTask([screenManager, this]() {
RS_LOGW("RSScreenManager %{public}s: clean and reinit in hardware thread.", __func__);
screenManager->OnHwcDeadEvent();
@ -486,6 +491,7 @@ void RSScreenManager::CleanAndReinit()
return;
}
});
#endif
}
}
@ -737,6 +743,7 @@ void RSScreenManager::RegSetScreenVsyncEnabledCallbackForHardwareThread(ScreenId
RS_LOGE("RegSetScreenVsyncEnabledCallbackForHardwareThread failed, vsyncSampler is null");
return;
}
#ifdef RS_ENABLE_GPU
vsyncSampler->RegSetScreenVsyncEnabledCallback([this, vsyncEnabledScreenId](bool enabled) {
RSHardwareThread::Instance().PostTask([this, vsyncEnabledScreenId, enabled]() {
std::lock_guard<std::mutex> lock(mutex_);
@ -749,6 +756,7 @@ void RSScreenManager::RegSetScreenVsyncEnabledCallbackForHardwareThread(ScreenId
screensIt->second->SetScreenVsyncEnabled(enabled);
});
});
#endif
}
// If the previous primary screen disconnected, we traversal the left screens
@ -1493,6 +1501,7 @@ void RSScreenManager::GetDefaultScreenActiveMode(RSScreenModeInfo& screenModeInf
void RSScreenManager::ReleaseScreenDmaBuffer(uint64_t screenId)
{
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().PostTask([screenId]() {
RS_TRACE_NAME("RSScreenManager ReleaseScreenDmaBuffer");
auto screenManager = CreateOrGetScreenManager();
@ -1508,6 +1517,7 @@ void RSScreenManager::ReleaseScreenDmaBuffer(uint64_t screenId)
std::vector<LayerInfoPtr> layer;
output->SetLayerInfo(layer);
});
#endif
}
std::vector<RSScreenModeInfo> RSScreenManager::GetScreenSupportedModes(ScreenId id) const
@ -1820,6 +1830,7 @@ void RSScreenManager::ClearFpsDump(std::string& dumpString, std::string& arg)
void RSScreenManager::ClearFrameBufferIfNeed()
{
#ifdef RS_ENABLE_GPU
RSHardwareThread::Instance().PostTask([this]() {
std::lock_guard<std::mutex> lock(mutex_);
for (const auto& [id, screen] : screens_) {
@ -1833,6 +1844,7 @@ void RSScreenManager::ClearFrameBufferIfNeed()
}
}
});
#endif
}
int32_t RSScreenManager::SetScreenConstraint(ScreenId id, uint64_t timestamp, ScreenConstraintType type)

View File

@ -181,14 +181,6 @@ ohos_source_set("render_service_base_src") {
"src/memory/rs_memory_track.cpp",
"src/memory/rs_tag_tracker.cpp",
#params
"src/params/rs_canvas_drawing_render_params.cpp",
"src/params/rs_display_render_params.cpp",
"src/params/rs_effect_render_params.cpp",
"src/params/rs_render_params.cpp",
"src/params/rs_render_thread_params.cpp",
"src/params/rs_surface_render_params.cpp",
#pipeline
"src/pipeline/rs_canvas_drawing_render_node.cpp",
"src/pipeline/rs_canvas_render_node.cpp",
@ -231,16 +223,6 @@ ohos_source_set("render_service_base_src") {
"src/property/rs_property_drawable_utilities.cpp",
"src/property/rs_property_trace.cpp",
#drawable
"src/drawable/rs_drawable.cpp",
"src/drawable/rs_misc_drawable.cpp",
"src/drawable/rs_property_drawable.cpp",
"src/drawable/rs_property_drawable_background.cpp",
"src/drawable/rs_property_drawable_foreground.cpp",
"src/drawable/rs_property_drawable_utils.cpp",
"src/drawable/rs_render_node_drawable_adapter.cpp",
"src/drawable/rs_render_node_shadow_drawable.cpp",
#render
"src/render/rs_aibar_shader_filter.cpp",
"src/render/rs_attraction_effect_filter.cpp",
@ -303,6 +285,28 @@ ohos_source_set("render_service_base_src") {
"src/info_collection/rs_layer_compose_collection.cpp",
]
if (rs_enable_gpu) {
sources += [
#drawable
"src/drawable/rs_drawable.cpp",
"src/drawable/rs_misc_drawable.cpp",
"src/drawable/rs_property_drawable.cpp",
"src/drawable/rs_property_drawable_background.cpp",
"src/drawable/rs_property_drawable_foreground.cpp",
"src/drawable/rs_property_drawable_utils.cpp",
"src/drawable/rs_render_node_drawable_adapter.cpp",
"src/drawable/rs_render_node_shadow_drawable.cpp",
#params
"src/params/rs_canvas_drawing_render_params.cpp",
"src/params/rs_display_render_params.cpp",
"src/params/rs_effect_render_params.cpp",
"src/params/rs_render_params.cpp",
"src/params/rs_render_thread_params.cpp",
"src/params/rs_surface_render_params.cpp",
]
}
if (defined(input_ext_feature_magiccursor) && input_ext_feature_magiccursor) {
sources += [
#ipc_callbacks

View File

@ -222,7 +222,9 @@ private:
friend class RSRenderThread;
friend class RSMainThread;
#ifdef RS_ENABLE_GPU
friend class RSDrawFrame;
#endif
friend class RSSurfaceCaptureTaskParallel;
#ifdef RS_PROFILER_ENABLED
friend class RSProfiler;

View File

@ -84,8 +84,10 @@ public:
protected:
RectI GetFilterRect() const override;
void UpdateFilterCacheWithSelfDirty() override;
#ifdef RS_ENABLE_GPU
void MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable,
RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync) override;
#endif
private:
explicit RSEffectRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {},

View File

@ -538,8 +538,10 @@ public:
virtual void UpdateFilterCacheWithSelfDirty();
bool IsBackgroundInAppOrNodeSelfDirty() const;
void PostPrepareForBlurFilterNode(RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync);
#ifdef RS_ENABLE_GPU
void CheckFilterCacheAndUpdateDirtySlots(
std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable, RSDrawableSlot slot);
#endif
bool IsFilterCacheValid() const;
bool IsAIBarFilterCacheValid() const;
void MarkForceClearFilterCacheWithInvisible();
@ -671,13 +673,13 @@ public:
{
return;
}
#ifdef RS_ENABLE_GPU
std::unique_ptr<RSRenderParams>& GetStagingRenderParams();
// Deprecated! Do not use this interface.
// This interface has crash risks and will be deleted in later versions.
const std::unique_ptr<RSRenderParams>& GetRenderParams() const;
#endif
void UpdatePointLightDirtySlot();
void AccmulateDirtyInOcclusion(bool isOccluded);
void RecordCurDirtyStatus();
@ -862,12 +864,12 @@ protected:
{
renderContent_->DrawPropertyDrawableRange(begin, end, canvas);
}
#ifdef RS_ENABLE_GPU
std::shared_ptr<DrawableV2::RSFilterDrawable> GetFilterDrawable(bool isForeground) const;
virtual void MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable,
RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync);
bool IsForceClearOrUseFilterCache(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable);
#endif
void UpdateDirtySlotsAndPendingNodes(RSDrawableSlot slot);
mutable bool isFullChildrenListValid_ = true;
bool isOnTheTree_ = false;

View File

@ -53,7 +53,9 @@ namespace DrawableV2 {
class RSBackgroundImageDrawable;
class RSBackgroundFilterDrawable;
class RSShadowDrawable;
#ifdef RS_ENABLE_GPU
class RSFilterDrawable;
#endif
}
class RSB_EXPORT RSProperties final {
public:
@ -734,7 +736,9 @@ private:
friend class DrawableV2::RSBackgroundImageDrawable;
friend class DrawableV2::RSBackgroundFilterDrawable;
friend class DrawableV2::RSShadowDrawable;
#ifdef RS_ENABLE_GPU
friend class DrawableV2::RSFilterDrawable;
#endif
#ifdef RS_PROFILER_ENABLED
friend class RSProfiler;
#endif

View File

@ -16,7 +16,7 @@
#include "offscreen_render/rs_offscreen_render_thread.h"
#include "platform/common/rs_log.h"
#include "platform/common/rs_system_properties.h"
#ifdef ROSEN_OHOS
#if (defined(ROSEN_OHOS) && defined(RS_ENABLE_GPU))
#include "render_context/render_context.h"
#endif
@ -39,7 +39,7 @@ RSOffscreenRenderThread::RSOffscreenRenderThread()
if (!RSSystemProperties::GetUniRenderEnabled()) {
return;
}
#ifdef ROSEN_OHOS
#if (defined(ROSEN_OHOS) && defined(RS_ENABLE_GPU))
PostTask([this]() {
renderContext_ = std::make_shared<RenderContext>();
#if defined(RS_ENABLE_GL)
@ -92,7 +92,7 @@ const std::function<void()> RSOffscreenRenderThread::GetCaptureTask(NodeId nodeI
return nullptr;
}
#ifdef ROSEN_OHOS
#if (defined(ROSEN_OHOS) && defined(RS_ENABLE_GPU))
const std::shared_ptr<RenderContext> RSOffscreenRenderThread::GetRenderContext()
{
if (!renderContext_) {

View File

@ -209,21 +209,29 @@ bool RSCanvasDrawingRenderNode::IsNeedProcess() const
void RSCanvasDrawingRenderNode::ContentStyleSlotUpdate()
{
//update content_style when node not on tree, need check (waitSync_ false, not on tree, surface not changed)
#ifdef RS_ENABLE_GPU
if (IsWaitSync() || IsOnTheTree() || isNeverOnTree_ || !stagingRenderParams_ ||
stagingRenderParams_->GetCanvasDrawingSurfaceChanged() || RSUniRenderJudgement::IsUniRender()) {
return;
}
#else
if (IsWaitSync() || IsOnTheTree() || isNeverOnTree_ || !stagingRenderParams_ ||
RSUniRenderJudgement::IsUniRender()) {
return;
}
#endif
if (!dirtyTypes_.test(static_cast<size_t>(RSModifierType::CONTENT_STYLE))) {
return;
}
#ifdef RS_ENABLE_GPU
auto surfaceParams = GetStagingRenderParams()->GetCanvasDrawingSurfaceParams();
if (surfaceParams.width == 0 || surfaceParams.height == 0) {
RS_LOGE("RSCanvasDrawingRenderNode::ContentStyleSlotUpdate Area Size Error, NodeId[%{public}" PRIu64 "]"
"width[%{public}d], height[%{public}d]", GetId(), surfaceParams.width, surfaceParams.height);
return;
}
#endif
playbackNotOnTreeCmdSize_ += drawCmdLists_[RSModifierType::CONTENT_STYLE].size();
RS_OPTIONAL_TRACE_NAME_FMT("node[%llu], NotOnTreeDraw Cmdlist Size[%lu]", GetId(), playbackNotOnTreeCmdSize_);
@ -242,9 +250,12 @@ void RSCanvasDrawingRenderNode::SetNeedProcess(bool needProcess)
if (!stagingRenderParams_) {
return;
}
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetNeedSync(needProcess);
isNeedProcess_ = needProcess;
#else
isNeedProcess_ = false;
#endif
}
void RSCanvasDrawingRenderNode::PlaybackInCorrespondThread()
@ -483,12 +494,14 @@ bool RSCanvasDrawingRenderNode::IsNeedResetSurface() const
void RSCanvasDrawingRenderNode::InitRenderParams()
{
#ifdef RS_ENABLE_GPU
stagingRenderParams_ = std::make_unique<RSCanvasDrawingRenderParams>(GetId());
DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(shared_from_this());
if (renderDrawable_ == nullptr) {
RS_LOGE("RSCanvasDrawingRenderNode::InitRenderParams failed");
return;
}
#endif
}
void RSCanvasDrawingRenderNode::CheckDrawCmdListSize(RSModifierType type)
@ -560,8 +573,10 @@ void RSCanvasDrawingRenderNode::ResetSurface(int width, int height)
}
surface_ = nullptr;
recordingCanvas_ = nullptr;
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetCanvasDrawingSurfaceChanged(true);
stagingRenderParams_->SetCanvasDrawingSurfaceParams(width, height);
#endif
}
const std::map<RSModifierType, std::list<Drawing::DrawCmdListPtr>>& RSCanvasDrawingRenderNode::GetDrawCmdLists() const

View File

@ -167,12 +167,14 @@ bool RSDisplayRenderNode::GetBootAnimation() const
void RSDisplayRenderNode::InitRenderParams()
{
#ifdef RS_ENABLE_GPU
stagingRenderParams_ = std::make_unique<RSDisplayRenderParams>(GetId());
DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(shared_from_this());
if (renderDrawable_ == nullptr) {
RS_LOGE("RSDisplayRenderNode::InitRenderParams failed");
return;
}
#endif
}
ReleaseDmaBufferTask RSDisplayRenderNode::releaseScreenDmaBufferTask_;
@ -187,6 +189,7 @@ void RSDisplayRenderNode::SetReleaseTask(ReleaseDmaBufferTask callback)
void RSDisplayRenderNode::OnSync()
{
#ifdef RS_ENABLE_GPU
RS_OPTIONAL_TRACE_NAME_FMT("RSDisplayRenderNode::OnSync global dirty[%s]",
dirtyManager_->GetCurrentFrameDirtyRegion().ToString().c_str());
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
@ -202,6 +205,7 @@ void RSDisplayRenderNode::OnSync()
displayParams->SetZoomed(curZoomState_);
displayParams->SetNeedSync(true);
RSRenderNode::OnSync();
#endif
}
void RSDisplayRenderNode::HandleCurMainAndLeashSurfaceNodes()
@ -224,6 +228,7 @@ void RSDisplayRenderNode::RecordMainAndLeashSurfaces(RSBaseRenderNode::SharedPtr
void RSDisplayRenderNode::UpdateRenderParams()
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("RSDisplayRenderNode::UpdateRenderParams displayParams is null");
@ -245,10 +250,12 @@ void RSDisplayRenderNode::UpdateRenderParams()
displayParams->hasSecLayerInVisibleRect_ = hasSecLayerInVisibleRect_;
displayParams->hasSecLayerInVisibleRectChanged_ = hasSecLayerInVisibleRectChanged_;
RSRenderNode::UpdateRenderParams();
#endif
}
void RSDisplayRenderNode::UpdateScreenRenderParams(ScreenRenderParams& screenRenderParams)
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("RSDisplayRenderNode::UpdateScreenRenderParams displayParams is null");
@ -268,26 +275,31 @@ void RSDisplayRenderNode::UpdateScreenRenderParams(ScreenRenderParams& screenRen
displayParams->displayHasProtectedSurface_ = std::move(screenRenderParams.displayHasProtectedSurface);
displayParams->displaySpecailSurfaceChanged_ = std::move(screenRenderParams.displaySpecailSurfaceChanged);
displayParams->hasCaptureWindow_ = std::move(screenRenderParams.hasCaptureWindow);
#endif
}
void RSDisplayRenderNode::UpdateOffscreenRenderParams(bool needOffscreen)
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("RSDisplayRenderNode::UpdateOffscreenRenderParams displayParams is null");
return;
}
displayParams->SetNeedOffscreen(needOffscreen);
#endif
}
void RSDisplayRenderNode::UpdatePartialRenderParams()
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("RSDisplayRenderNode::UpdatePartialRenderParams displayParams is null");
return;
}
displayParams->SetAllMainAndLeashSurfaces(curMainAndLeashSurfaceNodes_);
#endif
}
bool RSDisplayRenderNode::SkipFrame(uint32_t refreshRate, uint32_t skipFrameInterval)
@ -327,12 +339,14 @@ bool RSDisplayRenderNode::SkipFrame(uint32_t refreshRate, uint32_t skipFrameInte
void RSDisplayRenderNode::SetDisplayGlobalZOrder(float zOrder)
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("RSDisplayRenderNode::SetDisplayGlobalZOrder displayParams is null");
return;
}
displayParams->SetGlobalZOrder(zOrder);
#endif
}
@ -360,6 +374,7 @@ bool RSDisplayRenderNode::IsRotationChanged() const
void RSDisplayRenderNode::UpdateRotation()
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("%{public}s displayParams is nullptr", __func__);
@ -376,6 +391,7 @@ void RSDisplayRenderNode::UpdateRotation()
preRotationStatus_ = curRotationStatus_;
curRotationStatus_ = IsRotationChanged();
displayParams->SetRotationChanged(curRotationStatus_);
#endif
}
void RSDisplayRenderNode::UpdateDisplayDirtyManager(int32_t bufferage, bool useAlignedDirtyRegion)
@ -392,6 +408,7 @@ void RSDisplayRenderNode::ClearCurrentSurfacePos()
void RSDisplayRenderNode::SetMainAndLeashSurfaceDirty(bool isDirty)
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("%{public}s displayParams is nullptr", __func__);
@ -401,10 +418,12 @@ void RSDisplayRenderNode::SetMainAndLeashSurfaceDirty(bool isDirty)
if (stagingRenderParams_->NeedSync()) {
AddToPendingSyncList();
}
#endif
}
void RSDisplayRenderNode::SetFingerprint(bool hasFingerprint)
{
#ifdef RS_ENABLE_GPU
if (hasFingerprint_ == hasFingerprint) {
return;
}
@ -418,10 +437,12 @@ void RSDisplayRenderNode::SetFingerprint(bool hasFingerprint)
AddToPendingSyncList();
}
hasFingerprint_ = hasFingerprint;
#endif
}
void RSDisplayRenderNode::SetHDRPresent(bool hdrPresent)
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
if (displayParams == nullptr) {
RS_LOGE("%{public}s displayParams is nullptr", __func__);
@ -431,15 +452,18 @@ void RSDisplayRenderNode::SetHDRPresent(bool hdrPresent)
if (stagingRenderParams_->NeedSync()) {
AddToPendingSyncList();
}
#endif
}
void RSDisplayRenderNode::SetBrightnessRatio(float brightnessRatio)
{
#ifdef RS_ENABLE_GPU
auto displayParams = static_cast<RSDisplayRenderParams*>(stagingRenderParams_.get());
displayParams->SetBrightnessRatio(brightnessRatio);
if (stagingRenderParams_->NeedSync()) {
AddToPendingSyncList();
}
#endif
}
RSRenderNode::ChildrenListSharedPtr RSDisplayRenderNode::GetSortedChildren() const

View File

@ -43,7 +43,7 @@
namespace OHOS {
namespace Rosen {
constexpr int32_t CORNER_SIZE = 4;
#ifdef ROSEN_OHOS
#if (defined(ROSEN_OHOS) && defined(RS_ENABLE_GPU))
constexpr uint32_t FENCE_WAIT_TIME = 3000; // ms
#endif
#if defined(ROSEN_OHOS) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK))
@ -1015,6 +1015,7 @@ void DrawSurfaceBufferOpItem::DrawWithGles(Canvas* canvas)
bool DrawSurfaceBufferOpItem::CreateEglTextureId()
{
#ifdef RS_ENABLE_GL
EGLint attrs[] = { EGL_IMAGE_PRESERVED, EGL_TRUE, EGL_NONE };
auto disp = eglGetDisplay(EGL_DEFAULT_DISPLAY);
@ -1054,7 +1055,7 @@ bool DrawSurfaceBufferOpItem::CreateEglTextureId()
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, magFilter);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, wrapS);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, wrapT);
#endif
return true;
}

View File

@ -127,6 +127,7 @@ void RSEffectRenderNode::SetEffectRegion(const std::optional<Drawing::RectI>& ef
void RSEffectRenderNode::CheckBlurFilterCacheNeedForceClearOrSave(bool rotationChanged, bool rotationStatusChanged)
{
#ifdef RS_ENABLE_GPU
if (GetRenderProperties().GetBackgroundFilter() == nullptr) {
return;
}
@ -144,14 +145,18 @@ void RSEffectRenderNode::CheckBlurFilterCacheNeedForceClearOrSave(bool rotationC
} else if (CheckFilterCacheNeedForceSave()) {
filterDrawable->MarkFilterForceUseCache();
}
#endif
}
void RSEffectRenderNode::UpdateFilterCacheWithSelfDirty()
{
#ifdef RS_ENABLE_GPU
#if defined(NEW_SKIA) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK))
if (!RSProperties::FilterCacheEnabled) {
ROSEN_LOGE("RSEffectRenderNode::UpdateFilterCacheManagerWithCacheRegion filter cache is disabled.");
return;
}
#endif
auto filterDrawable = GetFilterDrawable(false);
if (filterDrawable == nullptr || IsForceClearOrUseFilterCache(filterDrawable)) {
return;
@ -163,8 +168,10 @@ void RSEffectRenderNode::UpdateFilterCacheWithSelfDirty()
}
// effect render node only support background filter
MarkFilterStatusChanged(false, true);
#endif
}
#ifdef RS_ENABLE_GPU
void RSEffectRenderNode::MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable,
RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync)
{
@ -179,6 +186,7 @@ void RSEffectRenderNode::MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilt
}
RSRenderNode::MarkFilterCacheFlags(filterDrawable, dirtyManager, needRequestNextVsync);
}
#endif
bool RSEffectRenderNode::CheckFilterCacheNeedForceSave()
{
@ -226,16 +234,19 @@ void RSEffectRenderNode::SetFoldStatusChanged(bool foldStatusChanged)
void RSEffectRenderNode::InitRenderParams()
{
#ifdef RS_ENABLE_GPU
stagingRenderParams_ = std::make_unique<RSEffectRenderParams>(GetId());
DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(shared_from_this());
if (renderDrawable_ == nullptr) {
RS_LOGE("RSEffectRenderNode::InitRenderParams failed");
return;
}
#endif
}
void RSEffectRenderNode::MarkFilterHasEffectChildren()
{
#ifdef RS_ENABLE_GPU
if (GetRenderProperties().GetBackgroundFilter() == nullptr) {
return;
}
@ -244,19 +255,24 @@ void RSEffectRenderNode::MarkFilterHasEffectChildren()
return;
}
effectParams->SetHasEffectChildren(ChildHasVisibleEffect());
#if defined(NEW_SKIA) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK))
if (!RSProperties::FilterCacheEnabled) {
UpdateDirtySlotsAndPendingNodes(RSDrawableSlot::BACKGROUND_FILTER);
}
#endif
#endif
}
void RSEffectRenderNode::OnFilterCacheStateChanged()
{
#ifdef RS_ENABLE_GPU
auto filterDrawable = GetFilterDrawable(false);
auto effectParams = static_cast<RSEffectRenderParams*>(stagingRenderParams_.get());
if (filterDrawable == nullptr || effectParams == nullptr) {
return;
}
effectParams->SetCacheValid(filterDrawable->IsFilterCacheValid());
#endif
}
bool RSEffectRenderNode::EffectNodeShouldPaint() const
@ -280,6 +296,7 @@ bool RSEffectRenderNode::FirstFrameHasNoEffectChildren() const
void RSEffectRenderNode::MarkClearFilterCacheIfEffectChildrenChanged()
{
#ifdef RS_ENABLE_GPU
// the first frame node has no effect child, it should not be painted and filter cache need to be cleared.
auto filterDrawable = GetFilterDrawable(false);
if (filterDrawable == nullptr || filterDrawable->IsForceClearFilterCache()) {
@ -293,6 +310,7 @@ void RSEffectRenderNode::MarkClearFilterCacheIfEffectChildrenChanged()
if (filterDrawable->IsForceUseFilterCache()) {
filterDrawable->MarkFilterForceUseCache(false);
}
#endif
}
} // namespace Rosen
} // namespace OHOS

View File

@ -352,6 +352,7 @@ void RSRenderNode::RemoveChild(SharedPtr child, bool skipTransition)
void RSRenderNode::SetIsOnTheTree(bool flag, NodeId instanceRootNodeId, NodeId firstLevelNodeId,
NodeId cacheNodeId, NodeId uifirstRootNodeId)
{
#ifdef RS_ENABLE_GPU
// We do not need to label a child when the child is removed from a parent that is not on the tree
if (flag == isOnTheTree_) {
return;
@ -404,6 +405,7 @@ void RSRenderNode::SetIsOnTheTree(bool flag, NodeId instanceRootNodeId, NodeId f
for (auto& [child, _] : disappearingChildren_) {
child->SetIsOnTheTree(flag, instanceRootNodeId, firstLevelNodeId, cacheNodeId);
}
#endif
}
void RSRenderNode::ResetChildRelevantFlags()
@ -1053,6 +1055,7 @@ void RSRenderNode::PrepareChildrenForApplyModifiers()
void RSRenderNode::PrepareSelfNodeForApplyModifiers()
{
#ifdef RS_ENABLE_GPU
ApplyModifiers();
PrepareChildrenForApplyModifiers();
@ -1060,6 +1063,7 @@ void RSRenderNode::PrepareSelfNodeForApplyModifiers()
UpdateRenderParams();
AddToPendingSyncList();
#endif
}
bool RSRenderNode::IsUifirstArkTsCardNode()
@ -1098,7 +1102,9 @@ void RSRenderNode::UpdateDrawingCacheInfoBeforeChildren(bool isScreenRotation)
RS_OPTIONAL_TRACE_NAME_FMT("DrawingCacheInfo id:%llu contentDirty:%d subTreeDirty:%d nodeGroupType:%d",
GetId(), IsContentDirty(), IsSubTreeDirty(), nodeGroupType_);
SetDrawingCacheChanged((IsContentDirty() || IsSubTreeDirty() || IsAccessibilityConfigChanged()));
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetDrawingCacheIncludeProperty(nodeGroupIncludeProperty_);
#endif
}
void RSRenderNode::UpdateDrawingCacheInfoAfterChildren()
@ -1113,7 +1119,9 @@ void RSRenderNode::UpdateDrawingCacheInfoAfterChildren()
RS_OPTIONAL_TRACE_NAME_FMT("DrawingCacheInfoAfter ChildrenOutOfRect id:%llu", GetId());
SetDrawingCacheType(RSDrawingCacheType::DISABLED_CACHE);
}
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetDrawingCacheType(GetDrawingCacheType());
#endif
if (GetDrawingCacheType() != RSDrawingCacheType::DISABLED_CACHE) {
RS_OPTIONAL_TRACE_NAME_FMT("DrawingCacheInfoAfter id:%llu cacheType:%d childHasVisibleFilter:%d " \
"childHasVisibleEffect:%d",
@ -1165,7 +1173,9 @@ RSRenderNode::~RSRenderNode()
clearCacheSurfaceFunc_(std::move(cacheSurface_), std::move(cacheCompletedSurface_), cacheSurfaceThreadIndex_,
completedSurfaceThreadIndex_);
}
#ifdef RS_ENABLE_GPU
DrawableV2::RSRenderNodeDrawableAdapter::RemoveDrawableFromCache(GetId());
#endif
ClearCacheSurface();
auto context = GetContext().lock();
if (!context) {
@ -1274,7 +1284,7 @@ const std::shared_ptr<RSRenderContent> RSRenderNode::GetRenderContent() const
{
return renderContent_;
}
#ifdef RS_ENABLE_GPU
std::unique_ptr<RSRenderParams>& RSRenderNode::GetStagingRenderParams()
{
return stagingRenderParams_;
@ -1289,7 +1299,7 @@ const std::unique_ptr<RSRenderParams>& RSRenderNode::GetRenderParams() const
}
return renderDrawable_->renderParams_;
}
#endif
void RSRenderNode::CollectAndUpdateLocalShadowRect()
{
// update shadow if shadow changes
@ -1875,6 +1885,7 @@ void RSRenderNode::UpdateParentChildrenRect(std::shared_ptr<RSRenderNode> parent
bool RSRenderNode::IsFilterCacheValid() const
{
#ifdef RS_ENABLE_GPU
if (!RSSystemProperties::GetBlurEnabled() || !RSProperties::FilterCacheEnabled) {
ROSEN_LOGD("IsBackgroundFilterCacheValid::blur is disabled or filter cache is disabled.");
return false;
@ -1885,10 +1896,13 @@ bool RSRenderNode::IsFilterCacheValid() const
return false;
}
return filterDrawable->IsFilterCacheValid();
#endif
return false;
}
bool RSRenderNode::IsAIBarFilterCacheValid() const
{
#ifdef RS_ENABLE_GPU
if (!RSSystemProperties::GetBlurEnabled() || !RSProperties::FilterCacheEnabled) {
ROSEN_LOGD("IsBackgroundFilterCacheValid::blur is disabled or filter cache is disabled.");
return false;
@ -1899,6 +1913,8 @@ bool RSRenderNode::IsAIBarFilterCacheValid() const
return false;
}
return filterDrawable->IsAIBarCacheValid();
#endif
return false;
}
const RectI RSRenderNode::GetFilterCachedRegion() const
@ -1970,6 +1986,7 @@ void RSRenderNode::UpdateFilterRegionInSkippedSubTree(RSDirtyRegionManager& dirt
void RSRenderNode::CheckBlurFilterCacheNeedForceClearOrSave(bool rotationChanged, bool rotationStatusChanged)
{
#ifdef RS_ENABLE_GPU
bool rotationClear = false;
if (!IsInstanceOf<RSEffectRenderNode>() && rotationChanged) {
rotationClear = true;
@ -1999,15 +2016,17 @@ void RSRenderNode::CheckBlurFilterCacheNeedForceClearOrSave(bool rotationChanged
}
}
}
#endif
}
#ifdef RS_ENABLE_GPU
bool RSRenderNode::IsForceClearOrUseFilterCache(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable)
{
return filterDrawable->IsForceUseFilterCache() || filterDrawable->IsForceClearFilterCache();
}
#endif
void RSRenderNode::MarkFilterStatusChanged(bool isForeground, bool isFilterRegionChanged)
{
#ifdef RS_ENABLE_GPU
auto filterDrawable = GetFilterDrawable(isForeground);
if (filterDrawable == nullptr) {
return;
@ -2018,8 +2037,9 @@ void RSRenderNode::MarkFilterStatusChanged(bool isForeground, bool isFilterRegio
flag = true;
isFilterRegionChanged ?
filterDrawable->MarkFilterRegionChanged() : filterDrawable->MarkFilterRegionInteractWithDirty();
#endif
}
#ifdef RS_ENABLE_GPU
std::shared_ptr<DrawableV2::RSFilterDrawable> RSRenderNode::GetFilterDrawable(bool isForeground) const
{
auto slot = isForeground ? RSDrawableSlot::COMPOSITING_FILTER : RSDrawableSlot::BACKGROUND_FILTER;
@ -2030,7 +2050,7 @@ std::shared_ptr<DrawableV2::RSFilterDrawable> RSRenderNode::GetFilterDrawable(bo
}
return nullptr;
}
#endif
void RSRenderNode::UpdateFilterCacheWithBackgroundDirty()
{
#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)
@ -2114,15 +2134,16 @@ void RSRenderNode::UpdateDirtySlotsAndPendingNodes(RSDrawableSlot slot)
dirtySlots_.emplace(slot);
AddToPendingSyncList();
}
#ifdef RS_ENABLE_GPU
inline static bool IsLargeArea(int width, int height)
{
static const auto threshold = RSSystemProperties::GetFilterCacheSizeThreshold();
return width > threshold && height > threshold;
}
#endif
void RSRenderNode::PostPrepareForBlurFilterNode(RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync)
{
#ifdef RS_ENABLE_GPU
MarkFilterHasEffectChildren();
if (!RSProperties::FilterCacheEnabled) {
ROSEN_LOGE("RSRenderNode::PostPrepareForBlurFilterNode filter cache is disabled.");
@ -2145,8 +2166,9 @@ void RSRenderNode::PostPrepareForBlurFilterNode(RSDirtyRegionManager& dirtyManag
}
OnFilterCacheStateChanged();
UpdateLastFilterCacheRegion();
#endif
}
#ifdef RS_ENABLE_GPU
void RSRenderNode::MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable,
RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync)
{
@ -2183,9 +2205,10 @@ void RSRenderNode::CheckFilterCacheAndUpdateDirtySlots(
filterDrawable->MarkNeedClearFilterCache();
UpdateDirtySlotsAndPendingNodes(slot);
}
#endif
void RSRenderNode::MarkForceClearFilterCacheWithInvisible()
{
#ifdef RS_ENABLE_GPU
if (GetRenderProperties().GetBackgroundFilter()) {
auto filterDrawable = GetFilterDrawable(false);
if (filterDrawable != nullptr) {
@ -2200,10 +2223,12 @@ void RSRenderNode::MarkForceClearFilterCacheWithInvisible()
CheckFilterCacheAndUpdateDirtySlots(filterDrawable, RSDrawableSlot::COMPOSITING_FILTER);
}
}
#endif
}
void RSRenderNode::SetOccludedStatus(bool occluded)
{
#ifdef RS_ENABLE_GPU
if (GetRenderProperties().GetBackgroundFilter()) {
auto filterDrawable = GetFilterDrawable(false);
if (filterDrawable != nullptr) {
@ -2217,6 +2242,7 @@ void RSRenderNode::SetOccludedStatus(bool occluded)
}
}
isOccluded_ = occluded;
#endif
}
void RSRenderNode::RenderTraceDebug() const
@ -2577,6 +2603,7 @@ int RSRenderNode::GetBlurEffectDrawbleCount()
void RSRenderNode::UpdateDrawableVecV2()
{
#ifdef RS_ENABLE_GPU
// Step 1: Collect dirty slots
auto dirtySlots = RSDrawable::CalculateDirtySlots(dirtyTypes_, drawableVec_);
if (dirtySlots.empty()) {
@ -2613,6 +2640,7 @@ void RSRenderNode::UpdateDrawableVecV2()
}
waitSync_ = true;
#endif
}
void RSRenderNode::UpdateDrawableVecInternal(std::unordered_set<RSPropertyDrawableSlot> dirtySlots)
@ -2633,6 +2661,7 @@ void RSRenderNode::UpdateDrawableVecInternal(std::unordered_set<RSPropertyDrawab
void RSRenderNode::UpdateShadowRect()
{
#ifdef RS_ENABLE_GPU
if (drawableVec_[static_cast<int8_t>(RSDrawableSlot::SHADOW)] != nullptr &&
GetRenderProperties().GetShadowColorStrategy() != SHADOW_COLOR_STRATEGY::COLOR_STRATEGY_NONE) {
RectI shadowRect;
@ -2648,6 +2677,7 @@ void RSRenderNode::UpdateShadowRect()
} else {
stagingRenderParams_->SetShadowRect(Drawing::Rect());
}
#endif
}
void RSRenderNode::UpdateDisplayList()
@ -2655,16 +2685,18 @@ void RSRenderNode::UpdateDisplayList()
#ifndef ROSEN_ARKUI_X
// Planning: use the mask from DrawableVecStatus in rs_drawable.cpp
constexpr uint8_t FRAME_NOT_EMPTY = 1 << 4;
#ifdef RS_ENABLE_GPU
constexpr uint8_t NODE_NOT_EMPTY = 1 << 5;
#endif
stagingDrawCmdList_.clear();
drawCmdListNeedSync_ = true;
#ifdef RS_ENABLE_GPU
if (UNLIKELY((drawableVecStatus_ & NODE_NOT_EMPTY) == 0)) {
// NODE_NOT_EMPTY is not set, so nothing to draw, just skip
stagingRenderParams_->SetContentEmpty(IsInstanceOf<RSCanvasRenderNode>());
return;
}
#endif
int8_t index = 0;
// Process all drawables in [index, end], end is included.
@ -2730,8 +2762,10 @@ void RSRenderNode::UpdateDisplayList()
stagingDrawCmdIndex_.foregroundFilterEndIndex_ = static_cast<int8_t>(stagingDrawCmdList_.size());
AppendDrawFunc(RSDrawableSlot::RESTORE_ALL);
stagingDrawCmdIndex_.endIndex_ = static_cast<int8_t>(stagingDrawCmdList_.size());
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetContentEmpty(false);
#endif
#endif
}
void RSRenderNode::UpdateEffectRegion(std::optional<Drawing::RectI>& region, bool isForced)
@ -2818,9 +2852,11 @@ void RSRenderNode::SetGlobalAlpha(float alpha)
OnAlphaChanged();
}
globalAlpha_ = alpha;
#ifdef RS_ENABLE_GPU
if (stagingRenderParams_) {
stagingRenderParams_->SetGlobalAlpha(alpha);
}
#endif
}
float RSRenderNode::GetGlobalAlpha() const
@ -3267,9 +3303,11 @@ void RSRenderNode::MarkNodeGroup(NodeGroupType type, bool isNodeGroup, bool incl
if (context && context->GetNodeMap().IsResidentProcessNode(GetId())) {
nodeGroupType_ |= type;
SetDirty();
#ifdef RS_ENABLE_GPU
if (stagingRenderParams_) {
stagingRenderParams_->SetDirtyType(RSRenderParamsDirtyType::DRAWING_CACHE_TYPE_DIRTY);
}
#endif
}
} else {
if (isNodeGroup) {
@ -3278,9 +3316,11 @@ void RSRenderNode::MarkNodeGroup(NodeGroupType type, bool isNodeGroup, bool incl
nodeGroupType_ &= ~type;
}
SetDirty();
#ifdef RS_ENABLE_GPU
if (stagingRenderParams_) {
stagingRenderParams_->SetDirtyType(RSRenderParamsDirtyType::DRAWING_CACHE_TYPE_DIRTY);
}
#endif
}
if (nodeGroupType_ == static_cast<uint8_t>(NodeGroupType::NONE) && !isNodeGroup) {
needClearSurface_ = true;
@ -3665,7 +3705,9 @@ bool RSRenderNode::ChildHasVisibleFilter() const
void RSRenderNode::SetChildHasVisibleFilter(bool val)
{
childHasVisibleFilter_ = val;
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetChildHasVisibleFilter(val);
#endif
}
bool RSRenderNode::ChildHasVisibleEffect() const
{
@ -3674,7 +3716,9 @@ bool RSRenderNode::ChildHasVisibleEffect() const
void RSRenderNode::SetChildHasVisibleEffect(bool val)
{
childHasVisibleEffect_ = val;
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetChildHasVisibleEffect(val);
#endif
}
const std::vector<NodeId>& RSRenderNode::GetVisibleFilterChild() const
{
@ -3714,6 +3758,7 @@ const std::shared_ptr<RSRenderNode> RSRenderNode::GetInstanceRootNode() const
void RSRenderNode::UpdateTreeUifirstRootNodeId(NodeId id)
{
#ifdef RS_ENABLE_GPU
uifirstRootNodeId_ = id;
if (stagingRenderParams_ && stagingRenderParams_->SetUiFirstRootNode(uifirstRootNodeId_)) {
AddToPendingSyncList();
@ -3723,6 +3768,7 @@ void RSRenderNode::UpdateTreeUifirstRootNodeId(NodeId id)
child->UpdateTreeUifirstRootNodeId(id);
}
}
#endif
}
const std::shared_ptr<RSRenderNode> RSRenderNode::GetFirstLevelNode() const
@ -3785,7 +3831,11 @@ void RSRenderNode::SetStaticCached(bool isStaticCached)
{
isStaticCached_ = isStaticCached;
// ensure defrost subtree would be updated
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetRSFreezeFlag(isStaticCached);
#else
isStaticCached = false;
#endif
if (!isStaticCached_) {
SetContentDirty();
}
@ -3885,11 +3935,17 @@ RSDrawingCacheType RSRenderNode::GetDrawingCacheType() const
}
void RSRenderNode::SetDrawingCacheChanged(bool cacheChanged)
{
#ifdef RS_ENABLE_GPU
stagingRenderParams_->SetDrawingCacheChanged(cacheChanged, lastFrameSynced_);
#endif
}
bool RSRenderNode::GetDrawingCacheChanged() const
{
#ifdef RS_ENABLE_GPU
return stagingRenderParams_->GetDrawingCacheChanged();
#else
return false;
#endif
}
void RSRenderNode::ResetDrawingCacheNeedUpdate()
{
@ -4126,16 +4182,19 @@ void RSRenderNode::SetLastIsNeedAssignToSubThread(bool lastIsNeedAssignToSubThre
void RSRenderNode::InitRenderParams()
{
#ifdef RS_ENABLE_GPU
stagingRenderParams_ = std::make_unique<RSRenderParams>(GetId());
DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(shared_from_this());
if (renderDrawable_ == nullptr) {
RS_LOGE("RSRenderNode::InitRenderParams failed");
return;
}
#endif
}
void RSRenderNode::UpdateRenderParams()
{
#ifdef RS_ENABLE_GPU
auto& boundGeo = GetRenderProperties().GetBoundsGeometry();
if (!boundGeo) {
return;
@ -4159,12 +4218,17 @@ void RSRenderNode::UpdateRenderParams()
stagingRenderParams_->SetNodeType(GetType());
stagingRenderParams_->SetEffectNodeShouldPaint(EffectNodeShouldPaint());
stagingRenderParams_->SetHasGlobalCorner(!globalCornerRadius_.IsZero());
#endif
}
bool RSRenderNode::UpdateLocalDrawRect()
{
#ifdef RS_ENABLE_GPU
auto drawRect = selfDrawRect_.JoinRect(childrenRect_.ConvertTo<float>());
return stagingRenderParams_->SetLocalDrawRect(drawRect);
#else
return false;
#endif
}
void RSRenderNode::UpdateAbsDrawRect()
@ -4213,14 +4277,13 @@ void RSRenderNode::OnSync()
SyncPurgeFunc();
drawCmdListNeedSync_ = false;
}
#ifdef RS_ENABLE_GPU
renderDrawable_->backgroundFilterDrawable_ = GetFilterDrawable(false);
renderDrawable_->compositingFilterDrawable_ = GetFilterDrawable(true);
if (stagingRenderParams_->NeedSync()) {
stagingRenderParams_->OnSync(renderDrawable_->renderParams_);
}
#endif
if (!uifirstSkipPartialSync_) {
if (!dirtySlots_.empty()) {
for (const auto& slot : dirtySlots_) {
@ -4259,10 +4322,12 @@ void RSRenderNode::OnSync()
uifirstSkipPartialSync_ = false;
isLeashWindowPartialSkip = true;
}
#ifdef RS_ENABLE_GPU
if (ShouldClearSurface()) {
renderDrawable_->TryClearSurfaceOnSync();
needClearSurface_ = false;
}
#endif
// Reset FilterCache Flags
backgroundFilterRegionChanged_ = false;
backgroundFilterInteractWithDirty_ = false;
@ -4278,10 +4343,14 @@ void RSRenderNode::OnSync()
bool RSRenderNode::ShouldClearSurface()
{
#ifdef RS_ENABLE_GPU
bool renderGroupFlag = GetDrawingCacheType() != RSDrawingCacheType::DISABLED_CACHE || isOpincRootFlag_;
bool freezeFlag = stagingRenderParams_->GetRSFreezeFlag();
return (renderGroupFlag || freezeFlag || nodeGroupType_ == static_cast<uint8_t>(NodeGroupType::NONE)) &&
needClearSurface_;
#else
return (nodeGroupType_ == static_cast<uint8_t>(NodeGroupType::NONE)) && needClearSurface_;
#endif
}
void RSRenderNode::ValidateLightResources()
@ -4298,12 +4367,14 @@ void RSRenderNode::ValidateLightResources()
void RSRenderNode::MarkBlurIntersectWithDRM(bool intersectWithDRM, bool isDark)
{
#ifdef RS_ENABLE_GPU
const auto& properties = GetRenderProperties();
if (properties.GetBackgroundFilter()) {
if (auto filterDrawable = GetFilterDrawable(false)) {
filterDrawable->MarkBlurIntersectWithDRM(intersectWithDRM, isDark);
}
}
#endif
}
bool RSRenderNode::GetUifirstSupportFlag()

View File

@ -72,9 +72,11 @@ void RSRenderNode::OpincUpdateRootFlag(bool& unchangeMarkEnable)
if (unchangeMarkEnable) {
if (IsOpincUnchangeState()) {
isOpincRootFlag_ = true;
#ifdef RS_ENABLE_GPU
if (stagingRenderParams_) {
stagingRenderParams_->OpincUpdateRootFlag(true);
}
#endif
}
}
if (isUnchangeMarkEnable_) {
@ -154,9 +156,11 @@ void RSRenderNode::NodeCacheStateChange(NodeChangeType type)
if (unchangeCount_ > unchangeCountUpper_) {
nodeCacheState_ = NodeCacheState::STATE_UNCHANGE;
}
#ifdef RS_ENABLE_GPU
if (stagingRenderParams_) {
stagingRenderParams_->OpincSetCacheChangeFlag(false, lastFrameSynced_);
}
#endif
break;
case NodeChangeType::SELF_DIRTY:
NodeCacheStateReset(NodeCacheState::STATE_CHANGE);
@ -183,10 +187,12 @@ void RSRenderNode::NodeCacheStateReset(NodeCacheState nodeCacheState)
if (OpincGetRootFlag()) {
SetCacheStateByRetrytime();
}
#ifdef RS_ENABLE_GPU
if (stagingRenderParams_) {
stagingRenderParams_->OpincSetCacheChangeFlag(true, lastFrameSynced_);
stagingRenderParams_->OpincUpdateRootFlag(false);
}
#endif
isOpincRootFlag_ = false;
}
} // namespace Rosen

View File

@ -426,12 +426,14 @@ bool RSSurfaceRenderNode::HasSubSurfaceNodes() const
void RSSurfaceRenderNode::SetIsSubSurfaceNode(bool isSubSurfaceNode)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetIsSubSurfaceNode(isSubSurfaceNode);
isSubSurfaceNode_ = isSubSurfaceNode;
AddToPendingSyncList();
}
#endif
}
bool RSSurfaceRenderNode::IsSubSurfaceNode() const
@ -514,12 +516,14 @@ std::string RSSurfaceRenderNode::SubSurfaceNodesDump() const
void RSSurfaceRenderNode::SetIsNodeToBeCaptured(bool isNodeToBeCaptured)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetIsNodeToBeCaptured(isNodeToBeCaptured);
isNodeToBeCaptured_ = isNodeToBeCaptured;
AddToPendingSyncList();
}
#endif
}
bool RSSurfaceRenderNode::IsNodeToBeCaptured() const
@ -790,6 +794,7 @@ bool RSSurfaceRenderNode::GetBootAnimation() const
void RSSurfaceRenderNode::SetGlobalPositionEnabled(bool isEnabled)
{
#ifdef RS_ENABLE_GPU
if (isGlobalPositionEnabled_ == isEnabled) {
return;
}
@ -805,6 +810,7 @@ void RSSurfaceRenderNode::SetGlobalPositionEnabled(bool isEnabled)
isGlobalPositionEnabled_ = isEnabled;
ROSEN_LOGI("RSSurfaceRenderNode::SetGlobalPositionEnabled id:%{public}" PRIu64 ", isEnabled:%{public}d",
GetId(), isEnabled);
#endif
}
bool RSSurfaceRenderNode::GetGlobalPositionEnabled() const
@ -814,6 +820,7 @@ bool RSSurfaceRenderNode::GetGlobalPositionEnabled() const
void RSSurfaceRenderNode::SetForceHardwareAndFixRotation(bool flag)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams == nullptr) {
return;
@ -822,6 +829,7 @@ void RSSurfaceRenderNode::SetForceHardwareAndFixRotation(bool flag)
AddToPendingSyncList();
isFixRotationByUser_ = flag;
#endif
}
bool RSSurfaceRenderNode::GetFixRotationByUser() const
@ -838,12 +846,14 @@ void RSSurfaceRenderNode::SetInFixedRotation(bool isRotating)
{
if (isFixRotationByUser_ && !isInFixedRotation_ && isRotating) {
#ifndef ROSEN_CROSS_PLATFORM
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
auto layer = surfaceParams->GetLayerInfo();
originalSrcRect_ = { layer.srcRect.x, layer.srcRect.y, layer.srcRect.w, layer.srcRect.h };
originalDstRect_ = { layer.dstRect.x, layer.dstRect.y, layer.dstRect.w, layer.dstRect.h };
}
#endif
#endif
}
isInFixedRotation_ = isFixRotationByUser_ && isRotating;
@ -1185,6 +1195,7 @@ void RSSurfaceRenderNode::NotifyTreeStateChange()
void RSSurfaceRenderNode::SetLayerTop(bool isTop)
{
#ifdef RS_ENABLE_GPU
isLayerTop_ = isTop;
SetContentDirty();
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
@ -1193,6 +1204,7 @@ void RSSurfaceRenderNode::SetLayerTop(bool isTop)
}
surfaceParams->SetLayerTop(isTop);
AddToPendingSyncList();
#endif
}
bool RSSurfaceRenderNode::IsHardwareEnabledTopSurface() const
@ -1203,6 +1215,7 @@ bool RSSurfaceRenderNode::IsHardwareEnabledTopSurface() const
void RSSurfaceRenderNode::SetHardCursorStatus(bool status)
{
#ifdef RS_ENABLE_GPU
if (isHardCursor_ == status) {
isLastHardCursor_ = isHardCursor_;
return;
@ -1215,6 +1228,7 @@ void RSSurfaceRenderNode::SetHardCursorStatus(bool status)
surfaceParams->SetHardCursorStatus(status);
AddToPendingSyncList();
}
#endif
}
bool RSSurfaceRenderNode::GetHardCursorStatus() const
@ -1283,6 +1297,7 @@ void RSSurfaceRenderNode::UpdateSurfaceDefaultSize(float width, float height)
void RSSurfaceRenderNode::UpdateBufferInfo(const sptr<SurfaceBuffer>& buffer, const Rect& damageRect,
const sptr<SyncFence>& acquireFence, const sptr<SurfaceBuffer>& preBuffer)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (!surfaceParams->IsBufferSynced()) {
auto curBuffer = surfaceParams->GetBuffer();
@ -1299,10 +1314,12 @@ void RSSurfaceRenderNode::UpdateBufferInfo(const sptr<SurfaceBuffer>& buffer, co
surfaceParams->SetAcquireFence(acquireFence);
surfaceParams->SetBufferSynced(false);
AddToPendingSyncList();
#endif
}
void RSSurfaceRenderNode::NeedClearBufferCache()
{
#ifdef RS_ENABLE_GPU
if (!surfaceHandler_) {
return;
}
@ -1317,6 +1334,7 @@ void RSSurfaceRenderNode::NeedClearBufferCache()
}
surfaceParams->SetBufferClearCacheSet(bufferCacheSet);
AddToPendingSyncList();
#endif
}
#endif
@ -1626,6 +1644,7 @@ bool RSSurfaceRenderNode::IsSCBNode() const
void RSSurfaceRenderNode::UpdateHwcNodeLayerInfo(GraphicTransformType transform, bool isHardCursorEnable)
{
#ifdef RS_ENABLE_GPU
#ifndef ROSEN_CROSS_PLATFORM
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
auto layer = surfaceParams->GetLayerInfo();
@ -1682,15 +1701,18 @@ void RSSurfaceRenderNode::UpdateHwcNodeLayerInfo(GraphicTransformType transform,
}
AddToPendingSyncList();
#endif
#endif
}
void RSSurfaceRenderNode::UpdateHardwareDisabledState(bool disabled)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
surfaceParams->SetLastFrameHardwareEnabled(!IsHardwareForcedDisabled());
SetHardwareForcedDisabledState(disabled);
surfaceParams->SetHardwareEnabled(!IsHardwareForcedDisabled());
AddToPendingSyncList();
#endif
}
void RSSurfaceRenderNode::SetVisibleRegionRecursive(const Occlusion::Region& region,
@ -1803,13 +1825,16 @@ void RSSurfaceRenderNode::CheckValidFilterCacheFullyCoverTarget(const RSRenderNo
void RSSurfaceRenderNode::UpdateOccludedByFilterCache(bool val)
{
#ifdef RS_ENABLE_GPU
isOccludedByFilterCache_ = val;
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
surfaceParams->SetOccludedByFilterCache(isOccludedByFilterCache_);
#endif
}
void RSSurfaceRenderNode::UpdateSurfaceCacheContentStaticFlag()
{
#ifdef RS_ENABLE_GPU
auto contentStatic = false;
if (IsLeashWindow() || IsAbilityComponent()) {
contentStatic = (!IsSubTreeDirty() || GetForceUpdateByUifirst()) && !IsContentDirty() && !HasRemovedChild();
@ -1826,6 +1851,7 @@ void RSSurfaceRenderNode::UpdateSurfaceCacheContentStaticFlag()
RS_OPTIONAL_TRACE_NAME_FMT("RSSurfaceRenderNode::UpdateSurfaceCacheContentStaticFlag: "
"[%d] name:[%s] Id:[%" PRIu64 "] subDirty:[%d] contentDirty:[%d] forceUpdate:[%d]",
contentStatic, GetName().c_str(), GetId(), IsSubTreeDirty(), IsContentDirty(), GetForceUpdateByUifirst());
#endif
}
bool RSSurfaceRenderNode::IsOccludedByFilterCache() const
@ -1835,6 +1861,7 @@ bool RSSurfaceRenderNode::IsOccludedByFilterCache() const
void RSSurfaceRenderNode::UpdateSurfaceSubTreeDirtyFlag()
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetSurfaceSubTreeDirty(IsSubTreeDirty());
@ -1842,6 +1869,7 @@ void RSSurfaceRenderNode::UpdateSurfaceSubTreeDirtyFlag()
if (stagingRenderParams_->NeedSync()) {
AddToPendingSyncList();
}
#endif
}
void RSSurfaceRenderNode::UpdateDrawingCacheNodes(const std::shared_ptr<RSRenderNode>& nodePtr)
@ -2073,6 +2101,7 @@ RSSurfaceRenderNode::ContainerConfig RSSurfaceRenderNode::GetAbsContainerConfig(
void RSSurfaceRenderNode::OnSync()
{
#ifdef RS_ENABLE_GPU
RS_OPTIONAL_TRACE_NAME_FMT("RSSurfaceRenderNode::OnSync name[%s] dirty[%s]",
GetName().c_str(), dirtyManager_->GetCurrentFrameDirtyRegion().ToString().c_str());
if (!renderDrawable_) {
@ -2092,6 +2121,7 @@ void RSSurfaceRenderNode::OnSync()
renderDrawable_->RegisterDeleteBufferListenerOnSync(GetRSSurfaceHandler()->GetConsumer());
#endif
RSRenderNode::OnSync();
#endif
}
bool RSSurfaceRenderNode::CheckIfOcclusionReusable(std::queue<NodeId>& surfaceNodesIds) const
@ -2740,6 +2770,7 @@ Vector2f RSSurfaceRenderNode::GetGravityTranslate(float imgWidth, float imgHeigh
void RSSurfaceRenderNode::UpdateUIFirstFrameGravity()
{
#ifdef RS_ENABLE_GPU
Gravity gravity = GetRenderProperties().GetFrameGravity();
if (IsLeashWindow()) {
std::vector<Gravity> subGravity{};
@ -2761,10 +2792,12 @@ void RSSurfaceRenderNode::UpdateUIFirstFrameGravity()
}
stagingSurfaceParams->SetUIFirstFrameGravity(gravity);
AddToPendingSyncList();
#endif
}
void RSSurfaceRenderNode::SetOcclusionVisible(bool visible)
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetOcclusionVisible(visible);
@ -2774,10 +2807,12 @@ void RSSurfaceRenderNode::SetOcclusionVisible(bool visible)
}
isOcclusionVisible_ = visible;
#endif
}
void RSSurfaceRenderNode::UpdatePartialRenderParams()
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams == nullptr) {
RS_LOGE("RSSurfaceRenderNode::UpdatePartialRenderParams surfaceParams is null");
@ -2792,10 +2827,12 @@ void RSSurfaceRenderNode::UpdatePartialRenderParams()
surfaceParams->SetTransparentRegion(GetTransparentRegion());
surfaceParams->SetOpaqueRegion(GetOpaqueRegion());
surfaceParams->SetRoundedCornerRegion(GetRoundedCornerRegion());
#endif
}
void RSSurfaceRenderNode::UpdateExtendVisibleRegion(Occlusion::Region& region)
{
#ifdef RS_ENABLE_GPU
extendVisibleRegion_.Reset();
extendVisibleRegion_ = region.Or(visibleRegion_);
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
@ -2804,20 +2841,24 @@ void RSSurfaceRenderNode::UpdateExtendVisibleRegion(Occlusion::Region& region)
return;
}
surfaceParams->SetVisibleRegion(extendVisibleRegion_);
#endif
}
void RSSurfaceRenderNode::InitRenderParams()
{
#ifdef RS_ENABLE_GPU
stagingRenderParams_ = std::make_unique<RSSurfaceRenderParams>(GetId());
DrawableV2::RSRenderNodeDrawableAdapter::OnGenerate(shared_from_this());
if (renderDrawable_ == nullptr) {
RS_LOGE("RSSurfaceRenderNode::InitRenderParams failed");
return;
}
#endif
}
void RSSurfaceRenderNode::UpdateRenderParams()
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams == nullptr) {
RS_LOGE("RSSurfaceRenderNode::UpdateRenderParams surfaceParams is null");
@ -2865,10 +2906,12 @@ void RSSurfaceRenderNode::UpdateRenderParams()
surfaceParams->SetNeedSync(true);
RSRenderNode::UpdateRenderParams();
#endif
}
void RSSurfaceRenderNode::SetNeedOffscreen(bool needOffscreen)
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetNeedOffscreen(needOffscreen);
@ -2877,10 +2920,12 @@ void RSSurfaceRenderNode::SetNeedOffscreen(bool needOffscreen)
} else {
RS_LOGE("RSSurfaceRenderNode::SetNeedOffscreen stagingSurfaceParams is null");
}
#endif
}
void RSSurfaceRenderNode::UpdateAncestorDisplayNodeInRenderParams()
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams == nullptr) {
RS_LOGE("RSSurfaceRenderNode::UpdateAncestorDisplayNodeInRenderParams surfaceParams is null");
@ -2888,56 +2933,68 @@ void RSSurfaceRenderNode::UpdateAncestorDisplayNodeInRenderParams()
}
surfaceParams->SetAncestorDisplayNode(ancestorDisplayNode_);
surfaceParams->SetNeedSync(true);
#endif
}
void RSSurfaceRenderNode::SetUifirstChildrenDirtyRectParam(RectI rect)
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetUifirstChildrenDirtyRectParam(rect);
AddToPendingSyncList();
}
#endif
}
void RSSurfaceRenderNode::SetLeashWindowVisibleRegionEmptyParam()
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (!stagingSurfaceParams) {
RS_LOGE("RSSurfaceRenderNode::SetLeashWindowVisibleRegionEmptyParam staingSurfaceParams is null");
return;
}
stagingSurfaceParams->SetLeashWindowVisibleRegionEmptyParam(isLeashWindowVisibleRegionEmpty_);
#endif
}
void RSSurfaceRenderNode::SetUifirstNodeEnableParam(MultiThreadCacheType b)
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetUifirstNodeEnableParam(b);
AddToPendingSyncList();
}
#endif
}
void RSSurfaceRenderNode::SetIsParentUifirstNodeEnableParam(bool b)
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetIsParentUifirstNodeEnableParam(b);
AddToPendingSyncList();
}
#endif
}
void RSSurfaceRenderNode::SetUifirstUseStarting(NodeId id)
{
#ifdef RS_ENABLE_GPU
auto stagingSurfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (stagingSurfaceParams) {
stagingSurfaceParams->SetUifirstUseStarting(id);
AddToPendingSyncList();
}
#endif
}
void RSSurfaceRenderNode::SetCornerRadiusInfoForDRM(const std::vector<float>& drmCornerRadiusInfo)
{
#ifdef RS_ENABLE_GPU
if (drmCornerRadiusInfo_ != drmCornerRadiusInfo) {
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
@ -2946,6 +3003,7 @@ void RSSurfaceRenderNode::SetCornerRadiusInfoForDRM(const std::vector<float>& dr
}
AddToPendingSyncList();
}
#endif
}
void RSSurfaceRenderNode::SetSkipDraw(bool skip)
@ -2976,29 +3034,35 @@ bool RSSurfaceRenderNode::IsWatermarkEmpty() const
void RSSurfaceRenderNode::SetSdrNit(int32_t sdrNit)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetSdrNit(sdrNit);
}
AddToPendingSyncList();
#endif
}
void RSSurfaceRenderNode::SetDisplayNit(int32_t displayNit)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetDisplayNit(displayNit);
}
AddToPendingSyncList();
#endif
}
void RSSurfaceRenderNode::SetBrightnessRatio(float brightnessRatio)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetBrightnessRatio(brightnessRatio);
}
AddToPendingSyncList();
#endif
}
void RSSurfaceRenderNode::SetWatermarkEnabled(const std::string& name, bool isEnabled)
@ -3006,10 +3070,12 @@ void RSSurfaceRenderNode::SetWatermarkEnabled(const std::string& name, bool isEn
if (isEnabled) {
RS_LOGI("RSSurfaceRenderNode::SetWatermarkEnabled[%{public}d], Name:%{public}s", isEnabled, name.c_str());
}
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetWatermarkEnabled(name, isEnabled);
}
#endif
AddToPendingSyncList();
}
@ -3049,11 +3115,13 @@ void RSSurfaceRenderNode::SetWaitUifirstFirstFrame(bool wait)
void RSSurfaceRenderNode::SetNeedCacheSurface(bool needCacheSurface)
{
#ifdef RS_ENABLE_GPU
auto surfaceParams = static_cast<RSSurfaceRenderParams*>(stagingRenderParams_.get());
if (surfaceParams) {
surfaceParams->SetNeedCacheSurface(needCacheSurface);
}
AddToPendingSyncList();
#endif
}
bool RSSurfaceRenderNode::NeedUpdateDrawableBehindWindow()

View File

@ -45,6 +45,7 @@ ohos_source_set("rosen_ohos_sources") {
#overdraw
"overdraw/rs_cpu_overdraw_canvas_listener.cpp",
"overdraw/rs_gpu_overdraw_canvas_listener.cpp",
"overdraw/rs_listened_canvas.cpp",
"overdraw/rs_overdraw_controller.cpp",
"rs_event_detector.cpp",
@ -83,7 +84,7 @@ ohos_source_set("rosen_ohos_sources") {
"backend/rs_vulkan_context.cpp",
]
}
if (graphic_2d_feature_enable_opengl) {
if (graphic_2d_feature_enable_opengl && rs_enable_gpu) {
sources += [
"backend/rs_surface_frame_ohos_gl.cpp",
"backend/rs_surface_ohos_gl.cpp",
@ -95,7 +96,6 @@ ohos_source_set("rosen_ohos_sources") {
"$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",
"overdraw/rs_gpu_overdraw_canvas_listener.cpp",
]
}

View File

@ -27,6 +27,7 @@ namespace Rosen {
RSGPUOverdrawCanvasListener::RSGPUOverdrawCanvasListener(Drawing::Canvas& canvas)
: RSCanvasListener(canvas)
{
#ifdef RS_ENABLE_GPU
auto gpuContext = canvas.GetGPUContext();
if (gpuContext == nullptr) {
ROSEN_LOGE("RSGPUOverdrawCanvasListener, construction failed: need gpu canvas");
@ -45,6 +46,7 @@ RSGPUOverdrawCanvasListener::RSGPUOverdrawCanvasListener(Drawing::Canvas& canvas
surface->Bind(image);
listenedSurface_ = surface;
overdrawCanvas_ = std::make_shared<Drawing::OverDrawCanvas>(surface->GetCanvas());
#endif
}
RSGPUOverdrawCanvasListener::~RSGPUOverdrawCanvasListener()

View File

@ -139,13 +139,13 @@ std::shared_ptr<RSSurface> RSRenderServiceClient::CreateNodeAndSurface(const RSS
std::shared_ptr<RSSurface> RSRenderServiceClient::CreateRSSurface(const sptr<Surface> &surface)
{
#if defined (ACE_ENABLE_VK)
#if defined (RS_ENABLE_VK)
if (RSSystemProperties::IsUseVulkan()) {
return std::make_shared<RSSurfaceOhosVulkan>(surface); // GPU render
}
#endif
#if defined (ACE_ENABLE_GL)
#if defined (RS_ENABLE_GL)
if (RSSystemProperties::GetGpuApiType() == Rosen::GpuApiType::OPENGL) {
return std::make_shared<RSSurfaceOhosGl>(surface); // GPU render
}

View File

@ -17,7 +17,9 @@
#include "platform/drawing/rs_surface_converter.h"
#include "rs_surface_ohos.h"
#include "platform/ohos/backend/rs_surface_ohos_raster.h"
#ifdef RS_ENABLE_GPU
#include "platform/ohos/backend/rs_surface_ohos_gl.h"
#endif
#ifdef RS_ENABLE_VK
#include "platform/ohos/backend/rs_surface_ohos_vulkan.h"
#endif
@ -30,14 +32,14 @@ sptr<Surface> RSSurfaceConverter::ConvertToOhosSurface(std::shared_ptr<RSSurface
ROSEN_LOGE("nullptr input");
return nullptr;
}
#if defined(ACE_ENABLE_VK)
#if defined(RS_ENABLE_VK)
if (RSSystemProperties::IsUseVulkan()) {
auto derivedPtr = std::static_pointer_cast<RSSurfaceOhosVulkan>(surface); // gpu render
return derivedPtr->GetSurface();
}
#endif
#if defined(ACE_ENABLE_GL)
#if defined(RS_ENABLE_GL)
if (RSSystemProperties::GetGpuApiType() == GpuApiType::OPENGL) {
auto derivedPtr = std::static_pointer_cast<RSSurfaceOhosGl>(surface); // gpu render
return derivedPtr->GetSurface();

View File

@ -4431,11 +4431,13 @@ bool RSProperties::GetHaveEffectRegion() const
void RSProperties::SetHaveEffectRegion(bool haveEffectRegion)
{
#if defined(NEW_SKIA) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK))
// clear cache if new region is null or outside current region
if (auto& manager = GetFilterCacheManager(false);
manager && manager->IsCacheValid() && haveEffectRegion == false) {
manager->UpdateCacheStateWithFilterRegion();
}
#endif
haveEffectRegion_ = haveEffectRegion;
}
} // namespace Rosen

View File

@ -507,6 +507,7 @@ std::shared_ptr<Drawing::RuntimeEffect> RSPropertiesPainter::MakeGreyAdjustmentE
std::shared_ptr<Drawing::Image> RSPropertiesPainter::DrawGreyAdjustment(Drawing::Canvas& canvas,
const std::shared_ptr<Drawing::Image>& image, const Vector2f& greyCoeff)
{
#ifdef RS_ENABLE_GPU
if (image == nullptr) {
ROSEN_LOGE("RSPropertiesPainter::DrawGreyAdjustment image is null");
return nullptr;
@ -527,6 +528,9 @@ std::shared_ptr<Drawing::Image> RSPropertiesPainter::DrawGreyAdjustment(Drawing:
builder->SetUniform("coefficient1", greyCoeff.x_);
builder->SetUniform("coefficient2", greyCoeff.y_);
return builder->MakeImage(canvas.GetGPUContext().get(), nullptr, image->GetImageInfo(), false);
#else
return nullptr;
#endif
}
void RSPropertiesPainter::DrawForegroundFilter(const RSProperties& properties, RSPaintFilterCanvas& canvas)
@ -687,10 +691,10 @@ void RSPropertiesPainter::DrawFilter(const RSProperties& properties, RSPaintFilt
void RSPropertiesPainter::DrawBackgroundImageAsEffect(const RSProperties& properties, RSPaintFilterCanvas& canvas)
{
RS_TRACE_FUNC();
auto boundsRect = properties.GetBoundsRect();
// Optional use cacheManager to draw filter, cache is valid, skip drawing background image
#if defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK)
auto boundsRect = properties.GetBoundsRect();
if (auto& cacheManager = properties.GetFilterCacheManager(false);
cacheManager != nullptr && !canvas.GetDisableFilterCache() && cacheManager->IsCacheValid()) {
// no need to validate parameters, the caller already do it

View File

@ -188,9 +188,12 @@ void RSForegroundEffectFilter::ApplyForegroundEffect(Drawing::Canvas& canvas,
imgInfo.GetAlphaType(), imgInfo.GetColorSpace());
Drawing::Matrix blurMatrixGeo;
blurMatrixGeo.Translate(halfExtension, halfExtension);
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Surface> surface = Drawing::Surface::MakeRenderTarget(canvas.GetGPUContext().get(),
false, scaledInfoGeo);
#else
std::shared_ptr<Drawing::Surface> surface = nullptr;
#endif
if (!surface) {
ROSEN_LOGE("RSForegroundEffectFilter surface is null");
return;

View File

@ -190,6 +190,7 @@ Drawing::Matrix KawaseBlurFilter::GetShaderTransform(const Drawing::Canvas* canv
void KawaseBlurFilter::CheckInputImage(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
const KawaseParameter& param, std::shared_ptr<Drawing::Image>& checkedImage)
{
#ifdef RS_ENABLE_GPU
auto src = param.src;
auto srcRect = Drawing::RectI(src.GetLeft(), src.GetTop(), src.GetRight(), src.GetBottom());
if (image->GetImageInfo().GetBound() != srcRect) {
@ -207,6 +208,7 @@ void KawaseBlurFilter::CheckInputImage(Drawing::Canvas& canvas, const std::share
ROSEN_LOGE("KawaseBlurFilter::resize image failed, use original image");
}
}
#endif
}
void KawaseBlurFilter::OutputOriginalImage(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
@ -244,8 +246,12 @@ std::shared_ptr<Drawing::ShaderEffect> KawaseBlurFilter::ApplySimpleFilter(Drawi
Drawing::RuntimeShaderBuilder simpleBlurBuilder(simpleFilter_);
simpleBlurBuilder.SetChild("imageInput", Drawing::ShaderEffect::CreateImageShader(*input, Drawing::TileMode::CLAMP,
Drawing::TileMode::CLAMP, linear, blurMatrix));
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpSimpleBlur(simpleBlurBuilder.MakeImage(
canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpSimpleBlur(simpleBlurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
return Drawing::ShaderEffect::CreateImageShader(*tmpSimpleBlur, Drawing::TileMode::CLAMP, Drawing::TileMode::CLAMP,
linear, Drawing::Matrix());
}
@ -322,9 +328,12 @@ std::shared_ptr<Drawing::Image> KawaseBlurFilter::ExecutePingPongBlur(Drawing::C
blurBuilder.SetUniform("in_blurOffset", blur.radiusByPass * blurScale_, blur.radiusByPass * blurScale_);
blurBuilder.SetUniform("in_maxSizeXY", blur.width * blurScale_, blur.height * blurScale_);
}
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpBlur(blurBuilder.MakeImage(
canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpBlur(blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false));
#endif
// And now we'll build our chain of scaled blur stages
for (auto i = 1; i < blur.numberOfPasses; i++) {
const float stepScale = static_cast<float>(i) * blurScale_;
@ -343,7 +352,11 @@ std::shared_ptr<Drawing::Image> KawaseBlurFilter::ExecutePingPongBlur(Drawing::C
blurBuilder.SetUniform("in_blurOffset", blur.radiusByPass * stepScale, blur.radiusByPass * stepScale);
blurBuilder.SetUniform("in_maxSizeXY", blur.width * blurScale_, blur.height * blurScale_);
}
#ifdef RS_ENABLE_GPU
tmpBlur = blurBuilder.MakeImage(canvas.GetGPUContext().get(), nullptr, scaledInfo, false);
#else
tmpBlur = blurBuilder.MakeImage(nullptr, nullptr, scaledInfo, false);
#endif
}
return tmpBlur;
}

View File

@ -105,8 +105,13 @@ void RSMotionBlurFilter::DrawMotionBlur(Drawing::Canvas& canvas, const std::shar
std::ceil(image->GetHeight() * FLOAT_IMAGE_SCALE), originImageInfo.GetColorType(),
originImageInfo.GetAlphaType(), originImageInfo.GetColorSpace());
Drawing::SamplingOptions linear(Drawing::FilterMode::LINEAR, Drawing::MipmapMode::NONE);
#ifdef RS_ENABLE_GPU
std::shared_ptr<Drawing::Image> tmpBlur(builder->MakeImage(
canvas.GetGPUContext().get(), nullptr, scaledInfo, false));
#else
std::shared_ptr<Drawing::Image> tmpBlur(builder->MakeImage(
nullptr, nullptr, scaledInfo, false));
#endif
float invBlurScale = 1.0f / FLOAT_IMAGE_SCALE;
Drawing::Matrix invBlurMatrix;

View File

@ -294,8 +294,10 @@ std::shared_ptr<Drawing::Image> RSPixelMapUtil::ConvertYUVPixelMapToDrawingImage
YUVPixelFormatToSubSampling(imageInfo.pixelFormat),
YUVPixelFormatToYUVColorSpace(imageInfo.pixelFormat),
YUVPixelFormatToYUVDataType(imageInfo.pixelFormat));
#ifdef RS_ENABLE_GPU
return Drawing::Image::MakeFromYUVAPixmaps(*gpuContext, info,
const_cast<void *>(reinterpret_cast<const void*>(pixelMap->GetPixels())));
#endif
}
return nullptr;
}

View File

@ -176,7 +176,6 @@ template("render_service_client_source_set") {
]
deps = [
"$graphic_2d_root/frameworks/opengl_wrapper:EGL",
"$graphic_2d_root/rosen/modules/platform:ipc_core",
"$graphic_2d_root/rosen/modules/render_frame_trace:render_frame_trace",
]

View File

@ -118,8 +118,10 @@ RSRenderThread::RSRenderThread()
#endif
prevTimestamp_ = timestamp_;
ProcessCommands();
#ifdef RS_ENABLE_GPU
ROSEN_LOGD("RSRenderThread DrawFrame(%{public}" PRIu64 ") in %{public}s",
prevTimestamp_, renderContext_ ? "GPU" : "CPU");
#endif
Animate(prevTimestamp_);
Render();
SendCommands();
@ -185,11 +187,13 @@ RSRenderThread::RSRenderThread()
RSRenderThread::~RSRenderThread()
{
Stop();
#ifdef RS_ENABLE_GPU
if (renderContext_ != nullptr) {
ROSEN_LOGD("Destroy renderContext!!");
delete renderContext_;
renderContext_ = nullptr;
}
#endif
}
void RSRenderThread::Start()

View File

@ -30,7 +30,9 @@
#include "pipeline/rs_canvas_render_node.h"
#include "pipeline/rs_render_thread_visitor.h"
#include "platform/drawing/rs_vsync_client.h"
#ifdef RS_ENABLE_GPU
#include "render_context/render_context.h"
#endif
#include "transaction/rs_transaction_proxy.h"
#include "vsync_receiver.h"
@ -55,10 +57,12 @@ public:
int32_t GetTid();
std::string DumpRenderTree() const;
#ifdef RS_ENABLE_GPU
RenderContext* GetRenderContext()
{
return renderContext_;
}
#endif
RSContext& GetContext()
{
return *context_;
@ -170,8 +174,9 @@ private:
std::shared_ptr<RSJankDetector> jankDetector_;
std::shared_ptr<RSContext> context_;
#ifdef RS_ENABLE_GPU
RenderContext* renderContext_ = nullptr;
#endif
std::shared_ptr<HighContrastObserver> highContrastObserver_;
std::atomic_bool isHighContrastEnabled_ = false;
std::atomic_bool isHighContrastChanged_ = false;

View File

@ -410,12 +410,12 @@ void RSRenderThreadVisitor::ProcessRootRenderNode(RSRootRenderNode& node)
rsSurface->SetColorSpace(surfaceNodeColorSpace);
}
#if defined(ACE_ENABLE_GL) || defined (ACE_ENABLE_VK)
#if defined(RS_ENABLE_GL) || defined (RS_ENABLE_VK)
RenderContext* rc = RSRenderThread::Instance().GetRenderContext();
rsSurface->SetRenderContext(rc);
#endif
#ifdef ACE_ENABLE_VK
#ifdef RS_ENABLE_VK
if (RSSystemProperties::IsUseVulkan()) {
auto skContext = RsVulkanContext::GetSingleton().CreateDrawingContext();
if (skContext == nullptr) {
@ -631,7 +631,11 @@ void RSRenderThreadVisitor::ProcessCanvasRenderNode(RSCanvasRenderNode& node)
bool RSRenderThreadVisitor::UpdateAnimatePropertyCacheSurface(RSRenderNode& node)
{
if (!node.GetCacheSurface()) {
#ifdef RS_ENABLE_GPU
node.InitCacheSurface(canvas_ ? canvas_->GetGPUContext().get() : nullptr);
#else
node.InitCacheSurface(nullptr);
#endif
}
if (!node.GetCacheSurface()) {
return false;

View File

@ -28,7 +28,9 @@
#ifndef ROSEN_CROSS_PLATFORM
#include "platform/drawing/rs_surface_converter.h"
#endif
#ifdef RS_ENABLE_GPU
#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

@ -62,6 +62,7 @@ void RSDisplaySoloist::OnVsync(TimestampType timestamp, void* client)
void RSDisplaySoloist::VsyncCallbackInner(TimestampType timestamp)
{
#ifdef RS_ENABLE_GPU
{
std::lock_guard<std::mutex> lock(mtx_);
hasRequestedVsync_ = false;
@ -91,10 +92,12 @@ void RSDisplaySoloist::VsyncCallbackInner(TimestampType timestamp)
RequestNextVSync();
}
FlushFrameRate(frameRateRange_.preferred_);
#endif
}
void RSDisplaySoloist::Init()
{
#ifdef RS_ENABLE_GPU
if (useExclusiveThread_ && (!subReceiver_ || !hasInitVsyncReceiver_)) {
if (!subVsyncHandler_) {
subVsyncHandler_ = std::make_shared<AppExecFwk::EventHandler>(
@ -110,10 +113,12 @@ void RSDisplaySoloist::Init()
subStatus_ = ActiveStatus::ACTIVE;
hasInitVsyncReceiver_ = true;
}
#endif
}
void RSDisplaySoloist::RequestNextVSync()
{
#ifdef RS_ENABLE_GPU
{
std::lock_guard<std::mutex> lock(mtx_);
if (destroyed_) {
@ -134,6 +139,7 @@ void RSDisplaySoloist::RequestNextVSync()
subReceiver_->RequestNextVSync(subFrameCallback_);
hasRequestedVsync_ = true;
}
#endif
}
void RSDisplaySoloist::OnVsyncTimeOut()
@ -366,6 +372,7 @@ RSDisplaySoloistManager::~RSDisplaySoloistManager() noexcept {}
bool RSDisplaySoloistManager::InitVsyncReceiver()
{
#ifdef RS_ENABLE_GPU
if (hasInitVsyncReceiver_) {
return false;
}
@ -386,10 +393,14 @@ bool RSDisplaySoloistManager::InitVsyncReceiver()
managerStatus_ = ActiveStatus::ACTIVE;
return true;
#else
return false;
#endif
}
void RSDisplaySoloistManager::RequestNextVSync()
{
#ifdef RS_ENABLE_GPU
if (receiver_ == nullptr) {
ROSEN_LOGE("%{public}s, VSyncReceiver is null.", __func__);
return;
@ -409,6 +420,7 @@ void RSDisplaySoloistManager::RequestNextVSync()
}
receiver_->RequestNextVSync(managerFrameCallback_);
#endif
}
void RSDisplaySoloistManager::OnVsync(TimestampType timestamp, void* client)

View File

@ -120,8 +120,10 @@ public:
bool hasRequestedVsync_ = false;
bool destroyed_ = false;
std::string vsyncTimeoutTaskName_ = "";
#ifdef RS_ENABLE_GPU
AppExecFwk::EventHandler::Callback vsyncTimeoutCallback_ =
[this] { this->OnVsyncTimeOut(); };
#endif
};
using IdToSoloistMapType = std::unordered_map<SoloistIdType, std::shared_ptr<RSDisplaySoloist>>;
@ -171,7 +173,9 @@ private:
};
enum ActiveStatus managerStatus_ = ActiveStatus::INACTIVE;
#ifdef RS_ENABLE_GPU
bool hasInitVsyncReceiver_ = false;
#endif
int32_t sourceVsyncRate_ = 0;
FrameRateRange frameRateRange_;
@ -182,8 +186,10 @@ private:
std::mutex mtx_;
std::mutex dataUpdateMtx_;
std::string vsyncTimeoutTaskName_ = "soloist_manager_time_out_task";
#ifdef RS_ENABLE_GPU
AppExecFwk::EventHandler::Callback vsyncTimeoutCallback_ =
[this] { this->OnVsyncTimeOut(); };
#endif
};
} // namespace Rosen

View File

@ -147,6 +147,7 @@ static void SendTelemetry(double time)
*/
void RSProfiler::SetDirtyRegion(const Occlusion::Region& dirtyRegion)
{
#ifdef RS_ENABLE_GPU
if (!IsRecording()) {
return;
}
@ -184,6 +185,7 @@ void RSProfiler::SetDirtyRegion(const Occlusion::Region& dirtyRegion)
if (g_dirtyRegionPercentage > maxPercentValue) {
g_dirtyRegionPercentage = maxPercentValue;
}
#endif
}
void RSProfiler::Init(RSRenderService* renderService)

View File

@ -30,6 +30,7 @@ ohos_unittest("2d_graphics_draw_test") {
if (rs_enable_gpu) {
defines = [ "RS_ENABLE_GPU" ]
defines += [ "RS_ENABLE_GL" ]
}
include_dirs = [