diff --git a/build/configs/system_deps.toml b/build/configs/system_deps.toml index 95e42a4287452b30b79a2238200721dc59a66449..f2fbffb15f61e6446bb455baba129f6c1fc63e94 100755 --- a/build/configs/system_deps.toml +++ b/build/configs/system_deps.toml @@ -37,4 +37,6 @@ package_deps = [ "libpng-devel", "libexif-devel", "cjson-devel", + # GPU render + "openssl-devel", ] diff --git a/display_server/ft_build/ds_config.gni b/display_server/ft_build/ds_config.gni index 53c47d054f2138158458ee7d707339057081fac7..550530d9ca98aeab84bd24dfbd414cc67a2fd98c 100644 --- a/display_server/ft_build/ds_config.gni +++ b/display_server/ft_build/ds_config.gni @@ -13,8 +13,8 @@ import("//config.gni") declare_args() { - graphic_standard_feature_ace_enable_gpu = false - graphic_standard_feature_rs_enable_eglimage = false + graphic_standard_feature_ace_enable_gpu = true + graphic_standard_feature_rs_enable_eglimage = true graphic_standard_feature_rs_enable_uni_render = false graphic_standard_feature_enable_afbc = false } diff --git a/display_server/rosen/modules/2d_graphics/src/render_context/render_context.cpp b/display_server/rosen/modules/2d_graphics/src/render_context/render_context.cpp index 0b7b2dc3dfcb6e2c64d02e6b607f25e7ebacef1f..df24d5a11546b520c6a647cd813d6a5b7515b7c6 100644 --- a/display_server/rosen/modules/2d_graphics/src/render_context/render_context.cpp +++ b/display_server/rosen/modules/2d_graphics/src/render_context/render_context.cpp @@ -17,9 +17,6 @@ #include #include - -#include "EGL/egl.h" -#include "EGL/eglext.h" #include "rs_trace.h" #include "window.h" @@ -166,13 +163,28 @@ void RenderContext::InitializeEglContext() EGLint count; EGLint config_attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; + EGLConfig configs[GET_MAX_EGL_CONFIG]; - ret = eglChooseConfig(eglDisplay_, config_attribs, &config_, 1, &count); + ret = eglChooseConfig(eglDisplay_, config_attribs, configs, GET_MAX_EGL_CONFIG, &count); if (!(ret && static_cast(count) >= 1)) { LOGE("Failed to eglChooseConfig"); return; } + EGLint value; + for (int i = 0; i< count; i++) { + if (eglGetConfigAttrib(eglDisplay_, configs[i], EGL_NATIVE_VISUAL_ID, &value)) { + if (value == PIXEL_FMT_BGRA_8888) { // get from hal + config_ = configs[i]; + break; + } + } + } + if (config_ == nullptr) { + LOGE("Failed to get egl config, default set first config\n"); + config_ = configs[0]; + } + static const EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, EGL_CONTEXT_CLIENT_VERSION_NUM, EGL_NONE }; eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, context_attribs); @@ -291,7 +303,6 @@ sk_sp RenderContext::AcquireSurface(int width, int height) GrGLFramebufferInfo framebufferInfo; framebufferInfo.fFBOID = 0; - framebufferInfo.fFormat = GL_RGBA8; SkColorType colorType = kRGBA_8888_SkColorType; diff --git a/display_server/rosen/modules/2d_graphics/src/render_context/render_context.h b/display_server/rosen/modules/2d_graphics/src/render_context/render_context.h index 54561bf346470a8c3bf0f612c885aa3dca15443b..f059247973822d34d23a61a355fbcd6af60e808a 100644 --- a/display_server/rosen/modules/2d_graphics/src/render_context/render_context.h +++ b/display_server/rosen/modules/2d_graphics/src/render_context/render_context.h @@ -20,6 +20,8 @@ #include "common/rs_rect.h" #include "EGL/egl.h" #include "EGL/eglext.h" +#include "GLES2/gl2.h" +#include "GLES2/gl2ext.h" #include "GLES3/gl32.h" #include "include/core/SkCanvas.h" #include "include/core/SkColorSpace.h" @@ -34,6 +36,8 @@ #endif #define GLES_VERSION 2 +#define GET_MAX_EGL_CONFIG 5 + namespace OHOS { namespace Rosen { class RenderContext { @@ -111,7 +115,7 @@ private: EGLContext eglContext_ = EGL_NO_CONTEXT; EGLSurface eglSurface_ = EGL_NO_SURFACE; EGLSurface pbufferSurface_= EGL_NO_SURFACE; - EGLConfig config_; + EGLConfig config_ = nullptr; #ifndef ROSEN_CROSS_PLATFORM ColorGamut colorSpace_ = ColorGamut::COLOR_GAMUT_SRGB; #endif diff --git a/samples/BUILD.gn b/samples/BUILD.gn index a8ff75596c58431096c220e829af1b9df73690eb..e22ba7fd0f5a49d7e5a090c2d700a788c8dc78e2 100644 --- a/samples/BUILD.gn +++ b/samples/BUILD.gn @@ -16,7 +16,7 @@ import("//config.gni") declare_args() { - enable_gpu = false + enable_gpu = true } ft_executable("clock") {