diff --git a/shell/platform/tizen/external_texture_gl.cc b/shell/platform/tizen/external_texture_gl.cc index 2ac068f88d928..cb8133f67b399 100644 --- a/shell/platform/tizen/external_texture_gl.cc +++ b/shell/platform/tizen/external_texture_gl.cc @@ -14,9 +14,9 @@ #undef EFL_BETA_API_SUPPORT #include #include -#include -extern Evas_GL* kEvasGl; -extern Evas_GL_API* kEvasGLApi; +#include +extern Evas_GL* g_evas_gl; +EVAS_GL_GLOBAL_GLES3_DECLARE(); #endif #include @@ -41,7 +41,7 @@ ExternalTextureGL::~ExternalTextureGL() { #ifndef FLUTTER_TIZEN_EVASGL glDeleteTextures(1, &state_->gl_texture); #else - kEvasGLApi->glDeleteTextures(1, &state_->gl_texture); + glDeleteTextures(1, &state_->gl_texture); #endif } state_.release(); @@ -95,12 +95,12 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); const EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE, EGL_NONE}; - EGLImageKHR eglSrcImage = n_eglCreateImageKHR( + EGLImageKHR egl_src_image = n_eglCreateImageKHR( eglGetCurrentDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_SURFACE_TIZEN, (EGLClientBuffer)texture_tbm_surface_, attrs); - if (!eglSrcImage) { - FT_LOGE("eglSrcImage create fail!!, errorcode == %d", eglGetError()); + if (!egl_src_image) { + FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError()); mutex_.unlock(); return false; } @@ -121,43 +121,40 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier( PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress( "glEGLImageTargetTexture2DOES"); - glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, eglSrcImage); - if (eglSrcImage) { + glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image); + if (egl_src_image) { PFNEGLDESTROYIMAGEKHRPROC n_eglDestoryImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); - n_eglDestoryImageKHR(eglGetCurrentDisplay(), eglSrcImage); + n_eglDestoryImageKHR(eglGetCurrentDisplay(), egl_src_image); } #else int eglImgAttr[] = {EVAS_GL_IMAGE_PRESERVED, GL_TRUE, 0}; - EvasGLImage eglSrcImage = kEvasGLApi->evasglCreateImageForContext( - kEvasGl, evas_gl_current_context_get(kEvasGl), + EvasGLImage egl_src_image = evasglCreateImageForContext( + g_evas_gl, evas_gl_current_context_get(g_evas_gl), EVAS_GL_NATIVE_SURFACE_TIZEN, (void*)(intptr_t)texture_tbm_surface_, eglImgAttr); - if (!eglSrcImage) { - // FT_LOGE("eglSrcImage create fail!!, errorcode == %d", eglGetError()); + if (!egl_src_image) { + // FT_LOGE("egl_src_image create fail!!, errorcode == %d", eglGetError()); mutex_.unlock(); return false; } if (state_->gl_texture == 0) { - kEvasGLApi->glGenTextures(1, &state_->gl_texture); - kEvasGLApi->glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture); + glGenTextures(1, &state_->gl_texture); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture); // set the texture wrapping parameters - kEvasGLApi->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, - GL_CLAMP_TO_BORDER); - kEvasGLApi->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, - GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_BORDER); // set texture filtering parameters - kEvasGLApi->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - kEvasGLApi->glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } else { - kEvasGLApi->glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture); + glBindTexture(GL_TEXTURE_EXTERNAL_OES, state_->gl_texture); } - kEvasGLApi->glEvasGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, - eglSrcImage); - if (eglSrcImage) { - kEvasGLApi->evasglDestroyImage(eglSrcImage); + glEvasGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_src_image); + if (egl_src_image) { + evasglDestroyImage(egl_src_image); } #endif diff --git a/shell/platform/tizen/tizen_embedder_engine.cc b/shell/platform/tizen/tizen_embedder_engine.cc index 43709531d536b..88c2f08ccd04a 100644 --- a/shell/platform/tizen/tizen_embedder_engine.cc +++ b/shell/platform/tizen/tizen_embedder_engine.cc @@ -48,6 +48,10 @@ TizenEmbedderEngine::TizenEmbedderEngine( tizen_renderer = std::make_unique( *this, window_properties.x, window_properties.y, window_properties.width, window_properties.height); + // clear once to remove noise + tizen_renderer->OnMakeCurrent(); + tizen_renderer->ClearColor(0, 0, 0, 0); + tizen_renderer->OnPresent(); #else #ifdef FLUTTER_TIZEN_4 tizen_renderer = std::make_unique( diff --git a/shell/platform/tizen/tizen_renderer.cc b/shell/platform/tizen/tizen_renderer.cc index 077a410eb8e1b..f4ba73418f7b3 100644 --- a/shell/platform/tizen/tizen_renderer.cc +++ b/shell/platform/tizen/tizen_renderer.cc @@ -8,8 +8,9 @@ #include #include #else -Evas_GL* kEvasGl = nullptr; -Evas_GL_API* kEvasGLApi = nullptr; +#include +Evas_GL* g_evas_gl = nullptr; +EVAS_GL_GLOBAL_GLES3_DEFINE(); #endif #include "flutter/shell/platform/tizen/tizen_log.h" @@ -467,6 +468,11 @@ void TizenRenderer::DestoryEglSurface() { } #else +void TizenRenderer::ClearColor(float r, float g, float b, float a) { + glClearColor(r, g, b, a); + glClear(GL_COLOR_BUFFER_BIT); +} + bool TizenRenderer::OnMakeCurrent() { if (!IsValid()) { FT_LOGE("Invalid TizenRenderer"); @@ -475,7 +481,7 @@ bool TizenRenderer::OnMakeCurrent() { if (evas_gl_make_current(evas_gl_, gl_surface_, gl_context_) != EINA_TRUE) { return false; } - evas_object_image_pixels_dirty_set((Evas_Object*)GetImageHandle(),EINA_TRUE); + evas_object_image_pixels_dirty_set((Evas_Object*)GetImageHandle(), EINA_TRUE); return true; } @@ -523,13 +529,12 @@ uint32_t TizenRenderer::OnGetFBO() { return 0; } -#define GL_FUNC(FunctionName) \ - else if (strcmp(name, #FunctionName) == 0) { \ - return reinterpret_cast(evas_glGlapi->FunctionName); \ +#define GL_FUNC(FunctionName) \ + else if (strcmp(name, #FunctionName) == 0) { \ + return reinterpret_cast(FunctionName); \ } void* TizenRenderer::OnProcResolver(const char* name) { - auto address = - evas_gl_proc_address_get(evas_gl_, name); + auto address = evas_gl_proc_address_get(evas_gl_, name); if (address != nullptr) { return reinterpret_cast(address); } @@ -646,7 +651,7 @@ void* TizenRenderer::OnProcResolver(const char* name) { bool TizenRenderer::InitializeRenderer(int32_t x, int32_t y, int32_t w, int32_t h) { - if (!SetupEvasGL(x,y,w, h)) { + if (!SetupEvasGL(x, y, w, h)) { FT_LOGE("SetupEvasGL fail"); return false; } @@ -658,21 +663,19 @@ bool TizenRenderer::InitializeRenderer(int32_t x, int32_t y, int32_t w, bool TizenRenderer::IsValid() { return is_valid_; } bool TizenRenderer::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { + evas_gl_ = evas_gl_new( + evas_object_evas_get((Evas_Object*)SetupEvasWindow(x, y, w, h))); - evas_gl_ = evas_gl_new(evas_object_evas_get((Evas_Object*)SetupEvasWindow(x, y, w, h))); - - if(!evas_gl_){ + if (!evas_gl_) { FT_LOGE("SetupEvasWindow fail"); return false; } - evas_glGlapi = evas_gl_api_get(evas_gl_); - kEvasGl = evas_gl_; - kEvasGLApi = evas_glGlapi; + g_evas_gl = evas_gl_; gl_config_ = evas_gl_config_new(); gl_config_->color_format = EVAS_GL_RGBA_8888; - gl_config_->depth_bits = EVAS_GL_DEPTH_BIT_24; + gl_config_->depth_bits = EVAS_GL_DEPTH_NONE; gl_config_->stencil_bits = EVAS_GL_STENCIL_NONE; gl_config_->options_bits = EVAS_GL_OPTIONS_NONE; @@ -683,11 +686,9 @@ bool TizenRenderer::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { // EVAS_GL_OPTIONS_DIRECT_MEMORY_OPTIMIZE | // EVAS_GL_OPTIONS_CLIENT_SIDE_ROTATION); - gl_context_ = - evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_2_X); - gl_resource_context_ = - evas_gl_context_version_create(evas_gl_, NULL, EVAS_GL_GLES_2_X); - + gl_context_ = evas_gl_context_create(evas_gl_, NULL); + gl_resource_context_ = evas_gl_context_create(evas_gl_, gl_context_); + EVAS_GL_GLOBAL_GLES3_USE(g_evas_gl, gl_context_); gl_surface_ = evas_gl_surface_create(evas_gl_, gl_config_, w, h); gl_resource_surface_ = @@ -695,12 +696,10 @@ bool TizenRenderer::SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h) { Evas_Native_Surface ns; evas_gl_native_surface_get(evas_gl_, gl_surface_, &ns); - evas_object_image_native_surface_set((Evas_Object*)GetImageHandle(), - &ns); - pixelDirtyCallback_ = [](void* data, Evas_Object* o) { - }; - evas_object_image_pixels_get_callback_set( - (Evas_Object*)GetImageHandle(), pixelDirtyCallback_, NULL); + evas_object_image_native_surface_set((Evas_Object*)GetImageHandle(), &ns); + pixelDirtyCallback_ = [](void* data, Evas_Object* o) {}; + evas_object_image_pixels_get_callback_set((Evas_Object*)GetImageHandle(), + pixelDirtyCallback_, NULL); return true; } @@ -710,8 +709,8 @@ void TizenRenderer::DestoryRenderer() { } void TizenRenderer::DestoryEvasGL() { - evas_gl_surface_destroy(evas_gl_,gl_surface_); - evas_gl_surface_destroy(evas_gl_,gl_resource_surface_); + evas_gl_surface_destroy(evas_gl_, gl_surface_); + evas_gl_surface_destroy(evas_gl_, gl_resource_surface_); evas_gl_context_destroy(evas_gl_, gl_context_); evas_gl_context_destroy(evas_gl_, gl_resource_context_); diff --git a/shell/platform/tizen/tizen_renderer.h b/shell/platform/tizen/tizen_renderer.h index 2e91daacb65c7..31d866dc951c8 100644 --- a/shell/platform/tizen/tizen_renderer.h +++ b/shell/platform/tizen/tizen_renderer.h @@ -9,7 +9,6 @@ #undef EFL_BETA_API_SUPPORT #include #include -#include #else #include #endif @@ -27,6 +26,10 @@ class TizenRenderer { TizenRenderer(TizenRenderer::Delegate& deleget); virtual ~TizenRenderer(); + +#ifdef FLUTTER_TIZEN_EVASGL + void ClearColor(float r, float g, float b, float a); +#endif bool OnMakeCurrent(); bool OnClearCurrent(); bool OnMakeResourceCurrent(); @@ -59,12 +62,11 @@ class TizenRenderer { void DestoryEglSurface(); bool SetupEglSurface(); #else - virtual void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, - int32_t h) = 0; + virtual void* SetupEvasWindow(int32_t x, int32_t y, int32_t w, int32_t h) = 0; virtual void DestoryEvasWindow() = 0; virtual void* GetImageHandle() = 0; - bool SetupEvasGL(int32_t x, int32_t y,int32_t w, int32_t h); + bool SetupEvasGL(int32_t x, int32_t y, int32_t w, int32_t h); void DestoryEvasGL(); #endif void DestoryRenderer(); @@ -75,7 +77,6 @@ class TizenRenderer { #ifdef FLUTTER_TIZEN_EVASGL Evas_GL_Config* gl_config_; Evas_GL* evas_gl_{nullptr}; - Evas_GL_API* evas_glGlapi{nullptr}; Evas_GL_Context* gl_context_; Evas_GL_Context* gl_resource_context_;