diff --git a/shell/platform/tizen/BUILD.gn b/shell/platform/tizen/BUILD.gn index 2fbafca3d8105..b3cad1c9746d5 100644 --- a/shell/platform/tizen/BUILD.gn +++ b/shell/platform/tizen/BUILD.gn @@ -74,12 +74,21 @@ source_set("flutter_tizen") { "$custom_sysroot/usr/include/ecore-input-1", "$custom_sysroot/usr/include/ecore-wl2-1", "$custom_sysroot/usr/include/efl-1", + "$custom_sysroot/usr/include/efl-1/interfaces", "$custom_sysroot/usr/include/eina-1", "$custom_sysroot/usr/include/eina-1/eina", "$custom_sysroot/usr/include/emile-1", "$custom_sysroot/usr/include/eo-1", "$custom_sysroot/usr/include/evas-1", "$custom_sysroot/usr/include/system", + "$custom_sysroot/usr/include/elementary-1", + "$custom_sysroot/usr/include/eet-1", + "$custom_sysroot/usr/include/ecore-file-1", + "$custom_sysroot/usr/include/ecore-con-1", + "$custom_sysroot/usr/include/edje-1", + "$custom_sysroot/usr/include/efreet-1", + "$custom_sysroot/usr/include/ethumb-1", + "$custom_sysroot/usr/include/ethumb-client-1", ] lib_dirs = [ "$custom_sysroot/usr/lib" ] @@ -105,6 +114,7 @@ source_set("flutter_tizen") { "tbm", "tdm-client", "wayland-client", + "elementary", ] } diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 8ffeeb9a2fd02..35cb1faf299f8 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -113,8 +113,7 @@ void TextInputChannel::InputPanelStateChangedCallback( int32_t surface_h = window_geometry.h - self->current_keyboard_geometry_.h; - self->engine_->tizen_native_window->GetTizenNativeEGLWindow() - ->ResizeWithRotation(0, 0, surface_w, surface_h, 0); + self->engine_->tizen_native_window->ResizeWithRotation(0, 0, surface_w, surface_h, 0); if (self->rotation == 90 || self->rotation == 270) { self->engine_->SendWindowMetrics(surface_h, surface_w, 0); } else { @@ -298,10 +297,10 @@ TextInputChannel::TextInputChannel(flutter::BinaryMessenger* messenger, imf_context_ = ecore_imf_context_add(GetImfMethod()); } if (imf_context_) { - Ecore_Wl2_Window* ecoreWindow = - engine_->tizen_native_window->GetWindowHandle(); - ecore_imf_context_client_window_set( - imf_context_, (void*)ecore_wl2_window_id_get(ecoreWindow)); + // Ecore_Wl2_Window* ecoreWindow = + // engine_->tizen_native_window->GetWindowHandle(); + // ecore_imf_context_client_window_set( + // imf_context_, (void*)ecore_wl2_window_id_get(ecoreWindow)); RegisterIMFCallback(); } else { FT_LOGE("Failed to create imfContext"); @@ -619,7 +618,7 @@ void TextInputChannel::HideSoftwareKeyboard() { } else { engine_->SendWindowMetrics(window_geometry.w, window_geometry.h, 0); } - engine_->tizen_native_window->GetTizenNativeEGLWindow() + engine_->tizen_native_window ->ResizeWithRotation(0, 0, window_geometry.w, window_geometry.h, 0); ecore_timer_add( 0.05, diff --git a/shell/platform/tizen/tizen_native_window.cc b/shell/platform/tizen/tizen_native_window.cc index 86b3efee5397d..ea7728e50be48 100644 --- a/shell/platform/tizen/tizen_native_window.cc +++ b/shell/platform/tizen/tizen_native_window.cc @@ -7,168 +7,55 @@ #include "tizen_native_window.h" +#include #include "flutter/shell/platform/tizen/tizen_log.h" void LogLastEGLError() { - struct EGLNameErrorPair { - const char* name; - EGLint code; - }; - -#define _EGL_ERROR_DESC(a) \ - { #a, a } - - const EGLNameErrorPair pairs[] = { - _EGL_ERROR_DESC(EGL_SUCCESS), - _EGL_ERROR_DESC(EGL_NOT_INITIALIZED), - _EGL_ERROR_DESC(EGL_BAD_ACCESS), - _EGL_ERROR_DESC(EGL_BAD_ALLOC), - _EGL_ERROR_DESC(EGL_BAD_ATTRIBUTE), - _EGL_ERROR_DESC(EGL_BAD_CONTEXT), - _EGL_ERROR_DESC(EGL_BAD_CONFIG), - _EGL_ERROR_DESC(EGL_BAD_CURRENT_SURFACE), - _EGL_ERROR_DESC(EGL_BAD_DISPLAY), - _EGL_ERROR_DESC(EGL_BAD_SURFACE), - _EGL_ERROR_DESC(EGL_BAD_MATCH), - _EGL_ERROR_DESC(EGL_BAD_PARAMETER), - _EGL_ERROR_DESC(EGL_BAD_NATIVE_PIXMAP), - _EGL_ERROR_DESC(EGL_BAD_NATIVE_WINDOW), - _EGL_ERROR_DESC(EGL_CONTEXT_LOST), - }; - -#undef _EGL_ERROR_DESC - - const auto count = sizeof(pairs) / sizeof(EGLNameErrorPair); - - EGLint last_error = eglGetError(); - - for (size_t i = 0; i < count; i++) { - if (last_error == pairs[i].code) { - FT_LOGE("EGL Error: %s (%d)", pairs[i].name, pairs[i].code); - return; - } - } - - FT_LOGE("Unknown EGL Error"); } -class TizenWl2Display { - public: - TizenWl2Display() { - if (!ecore_wl2_init()) { - FT_LOGE("Could not initialize ecore_wl2"); - return; - } - // ecore_wl2 DISPLAY - wl2_display_ = ecore_wl2_display_connect(nullptr); - if (wl2_display_ == nullptr) { - FT_LOGE("Display not found"); - return; - } - ecore_wl2_sync(); - } - - ~TizenWl2Display() { - if (wl2_display_) { - ecore_wl2_display_disconnect(wl2_display_); - wl2_display_ = nullptr; - } - ecore_wl2_shutdown(); - } - Ecore_Wl2_Display* GetHandle() { return wl2_display_; } - - private: - Ecore_Wl2_Display* wl2_display_{nullptr}; -}; -TizenWl2Display g_tizen_wl2_display; - -TizenNativeEGLWindow::TizenNativeEGLWindow( - TizenNativeWindow* tizen_native_window, int32_t w, int32_t h) { - egl_window_ = - ecore_wl2_egl_window_create(tizen_native_window->GetWindowHandle(), w, h); - - egl_display_ = eglGetDisplay((EGLNativeDisplayType)ecore_wl2_display_get( - g_tizen_wl2_display.GetHandle())); - if (egl_display_ == EGL_NO_DISPLAY) { - FT_LOGE("Could not access EGL display"); - LogLastEGLError(); - return; - } - - EGLint major_version; - EGLint minor_version; - if (eglInitialize(egl_display_, &major_version, &minor_version) != EGL_TRUE) { - FT_LOGE("Could not initialize EGL display"); - LogLastEGLError(); - return; - } - - FT_LOGD("eglInitialized: %d.%d", major_version, minor_version); - - if (eglBindAPI(EGL_OPENGL_ES_API) != EGL_TRUE) { - FT_LOGE("Could not bind API"); - LogLastEGLError(); - return; - } -} - -TizenNativeEGLWindow::~TizenNativeEGLWindow() { - if (egl_display_ != EGL_NO_DISPLAY) { - if (eglTerminate(egl_display_) != EGL_TRUE) { - FT_LOGE("Failed to terminate egl display"); - LogLastEGLError(); - } - egl_display_ = EGL_NO_DISPLAY; - } - - if (egl_window_ != nullptr) { - ecore_wl2_egl_window_destroy(egl_window_); - egl_window_ = nullptr; - } -} - -void TizenNativeEGLWindow::ResizeWithRotation(int32_t dx, int32_t dy, +void TizenNativeWindow::ResizeWithRotation(int32_t dx, int32_t dy, int32_t width, int32_t height, int32_t degree) { - ecore_wl2_egl_window_resize_with_rotation(egl_window_, dx, dy, width, height, - degree); + // ecore_wl2_egl_window_resize_with_rotation(egl_window_, dx, dy, width, height, + // degree); } TizenNativeWindow::TizenNativeWindow(int32_t x, int32_t y, int32_t w, int32_t h) { - if (g_tizen_wl2_display.GetHandle() == nullptr) { - FT_LOGE("Faild to get display handle"); - return; - } if (w == 0 || h == 0) { FT_LOGE("Failed to create because of the wrong size"); return; } - - wl2_window_ = ecore_wl2_window_new(g_tizen_wl2_display.GetHandle(), nullptr, - x, y, w, h); - - ecore_wl2_window_type_set(wl2_window_, ECORE_WL2_WINDOW_TYPE_TOPLEVEL); - ecore_wl2_window_alpha_set(wl2_window_, EINA_FALSE); - ecore_wl2_window_aux_hint_add(wl2_window_, 0, "wm.policy.win.user.geometry", - "1"); - ecore_wl2_window_show(wl2_window_); - - tizen_native_egl_window_ = std::make_shared(this, w, h); + elm_config_accel_preference_set("opengl"); + + evas_window_ = elm_win_util_standard_add("", ""); + evas_object_move(evas_window_,x,y); + evas_object_resize(evas_window_,w,h); + evas_object_show(evas_window_); + // ecore_wl2_window_type_set(evas_window_, ECORE_WL2_WINDOW_TYPE_TOPLEVEL); + // ecore_wl2_window_alpha_set(evas_window_, EINA_FALSE); + // ecore_wl2_window_aux_hint_add(evas_window_, 0, "wm.policy.win.user.geometry", + // "1"); + // ecore_wl2_window_show(evas_window_); + evas_gl_ = evas_gl_new(evas_object_evas_get(evas_window_)); + evas_glGlapi = evas_gl_api_get(evas_gl_); is_valid_ = true; } TizenNativeWindow::~TizenNativeWindow() { - tizen_native_egl_window_ = nullptr; - if (wl2_window_) { - ecore_wl2_window_free(wl2_window_); - wl2_window_ = nullptr; + if (evas_window_) { + evas_object_del(evas_window_); + evas_gl_free(evas_gl_); + evas_window_ = nullptr; + evas_gl_ = nullptr; } } TizenNativeWindow::TizenNativeWindowGeometry TizenNativeWindow::GetGeometry() { TizenNativeWindowGeometry result; - ecore_wl2_window_geometry_get(wl2_window_, &result.x, &result.y, &result.w, - &result.h); + result.w=100; + result.h=100; + // ecore_wl2_window_geometry_get(evas_window_, &result.x, &result.y, &result.w, + // &result.h); return result; } diff --git a/shell/platform/tizen/tizen_native_window.h b/shell/platform/tizen/tizen_native_window.h index 8ae0f2fb12ecf..72bbf1215f6c6 100644 --- a/shell/platform/tizen/tizen_native_window.h +++ b/shell/platform/tizen/tizen_native_window.h @@ -4,35 +4,17 @@ #ifndef EMBEDDER_TIZEN_WINDOW_H_ #define EMBEDDER_TIZEN_WINDOW_H_ -#include -#define EFL_BETA_API_SUPPORT -#include +#undef EFL_BETA_API_SUPPORT +// #ifndef EFL_BETA_API_SUPPORT +// #define EFL_BETA_API_SUPPORT +// #endif +#include +#include #include void LogLastEGLError(); -class TizenNativeWindow; - -class TizenNativeEGLWindow { - public: - TizenNativeEGLWindow(TizenNativeWindow* tizen_native_window, int32_t w, - int32_t h); - ~TizenNativeEGLWindow(); - bool IsValid() { - return egl_window_ != nullptr && egl_display_ != EGL_NO_DISPLAY; - }; - - Ecore_Wl2_Egl_Window* GetEglWindowHandle() { return egl_window_; }; - EGLDisplay GetEGLDisplayHandle() { return egl_display_; } - void ResizeWithRotation(int32_t dx, int32_t dy, int32_t width, int32_t height, - int32_t degree); - - private: - Ecore_Wl2_Egl_Window* egl_window_ = nullptr; - EGLDisplay egl_display_ = EGL_NO_DISPLAY; -}; - class TizenNativeWindow { public: struct TizenNativeWindowGeometry { @@ -42,15 +24,17 @@ class TizenNativeWindow { TizenNativeWindow(int32_t x, int32_t y, int32_t w, int32_t h); ~TizenNativeWindow(); bool IsValid() { return is_valid_; } - Ecore_Wl2_Window* GetWindowHandle() { return wl2_window_; } - std::shared_ptr GetTizenNativeEGLWindow() { - return tizen_native_egl_window_; - }; + Evas_Object* GetWindowHandle() { return evas_window_; } + Evas_GL* GetEvasGLHandle() { return evas_gl_; } + Evas_GL_API* GetEvasGLApiHandle() { return evas_glGlapi; } TizenNativeWindowGeometry GetGeometry(); + void ResizeWithRotation(int32_t dx, int32_t dy, int32_t width, int32_t height, + int32_t degree); private: - std::shared_ptr tizen_native_egl_window_; - Ecore_Wl2_Window* wl2_window_{nullptr}; + Evas_Object* evas_window_{nullptr}; + Evas_GL* evas_gl_{nullptr}; + Evas_GL_API* evas_glGlapi{nullptr};; bool is_valid_{false}; }; diff --git a/shell/platform/tizen/tizen_surface_gl.cc b/shell/platform/tizen/tizen_surface_gl.cc index b02cecdc95023..958a56630a726 100644 --- a/shell/platform/tizen/tizen_surface_gl.cc +++ b/shell/platform/tizen/tizen_surface_gl.cc @@ -2,133 +2,73 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "tizen_surface_gl.h" - -#include -#include +#include +#include +#include "tizen_surface_gl.h" #include "flutter/shell/platform/tizen/tizen_log.h" -template -using EGLResult = std::pair; +#include -static EGLResult CreateContext(EGLDisplay display, EGLConfig config, - EGLContext share = EGL_NO_CONTEXT) { - EGLint attributes[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE}; - - EGLContext context = eglCreateContext(display, config, share, attributes); - if (context == EGL_NO_CONTEXT) { - LogLastEGLError(); - } - return {context != EGL_NO_CONTEXT, context}; +TizenGLSurface::~TizenGLSurface() { + evas_gl_surface_destroy(tizen_native_window_->GetEvasGLHandle(),gl_surface_); + gl_surface_ = nullptr; + tizen_native_window_ = nullptr; } -static EGLResult ChooseEGLConfiguration(EGLDisplay display) { - EGLint attributes[] = { - // clang-format off - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_ALPHA_SIZE, 8, - EGL_DEPTH_SIZE, 0, - EGL_STENCIL_SIZE, 0, - EGL_NONE, // termination sentinel - // clang-format on - }; - - EGLint config_count = 0; - EGLConfig egl_config = nullptr; - - if (eglChooseConfig(display, attributes, &egl_config, 1, &config_count) != - EGL_TRUE) { - LogLastEGLError(); - return {false, nullptr}; - } - - bool success = config_count > 0 && egl_config != nullptr; - - return {success, success ? egl_config : nullptr}; -} +TizenGLContext::TizenGLContext( + std::shared_ptr tizen_native_window) + : tizen_native_window_(tizen_native_window) { -TizenEGLSurface::~TizenEGLSurface() { - if (eglDestroySurface(tizen_native_egl_window_->GetEGLDisplayHandle(), - egl_surface_) != EGL_TRUE) { - LogLastEGLError(); - } - tizen_native_egl_window_ = nullptr; -} + 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_->stencil_bits = EVAS_GL_STENCIL_NONE; + gl_config_->options_bits = EVAS_GL_OPTIONS_NONE; -TizenEGLContext::TizenEGLContext( - std::shared_ptr tizen_native_egl_window) - : tizen_native_egl_window_(tizen_native_egl_window) { - EGLDisplay egl_display = tizen_native_egl_window_->GetEGLDisplayHandle(); - auto config = ChooseEGLConfiguration(egl_display); - if (!config.first) { - FT_LOGE("Failed to ChooseEGLConfiguration"); + if (!gl_config_) { + FT_LOGE("Failed to ChooseGLConfiguration"); return; } - egl_config_ = config.second; - auto ctx = CreateContext(egl_display, egl_config_, EGL_NO_CONTEXT); - if (!ctx.first) { + gl_context_ = evas_gl_context_create(tizen_native_window_->GetEvasGLHandle(), NULL); + if (!gl_context_) { FT_LOGE("Failed to create egl context"); return; } - egl_context_ = ctx.second; - auto resource_ctx = CreateContext(egl_display, egl_config_, egl_context_); - if (!resource_ctx.first) { + gl_resource_context_ = evas_gl_context_create(tizen_native_window_->GetEvasGLHandle(), gl_context_); + if (!gl_resource_context_) { FT_LOGE("Failed to create egl resource context"); return; } - egl_resource_context_ = resource_ctx.second; } -TizenEGLContext::~TizenEGLContext() { - if (eglDestroyContext(tizen_native_egl_window_->GetEGLDisplayHandle(), - egl_context_) != EGL_TRUE) { - FT_LOGE("Failed to destroy egl context"); - LogLastEGLError(); - } - if (eglDestroyContext(tizen_native_egl_window_->GetEGLDisplayHandle(), - egl_resource_context_) != EGL_TRUE) { - FT_LOGE("Failed to destroy egl resource context"); - LogLastEGLError(); - } - tizen_native_egl_window_ = nullptr; +TizenGLContext::~TizenGLContext() { + evas_gl_config_free(gl_config_); + evas_gl_context_destroy(tizen_native_window_->GetEvasGLHandle(),gl_context_); + evas_gl_context_destroy(tizen_native_window_->GetEvasGLHandle(),gl_resource_context_); + tizen_native_window_ = nullptr; + gl_context_ = nullptr; + gl_resource_context_ = nullptr; + gl_config_ = nullptr; } -bool TizenEGLContext::IsValid() { - return tizen_native_egl_window_ && tizen_native_egl_window_->IsValid() && - egl_config_ != nullptr && egl_context_ != EGL_NO_CONTEXT && - egl_resource_context_ != EGL_NO_CONTEXT; +bool TizenGLContext::IsValid() { + // TODO + return true; } -std::unique_ptr -TizenEGLContext::CreateTizenEGLWindowSurface() { - const EGLint attribs[] = {EGL_NONE}; - EGLSurface surface = eglCreateWindowSurface( - tizen_native_egl_window_->GetEGLDisplayHandle(), egl_config_, - ecore_wl2_egl_window_native_get( - tizen_native_egl_window_->GetEglWindowHandle()), - attribs); - if (surface == EGL_NO_SURFACE) { - LogLastEGLError(); - } - return std::make_unique(tizen_native_egl_window_, surface); +std::unique_ptr +TizenGLContext::CreateTizenGLWindowSurface() { + auto surface = evas_gl_surface_create(tizen_native_window_->GetEvasGLHandle(),gl_config_,tizen_native_window_->GetGeometry().w,tizen_native_window_->GetGeometry().h); + return std::make_unique(tizen_native_window_,surface); } -std::unique_ptr -TizenEGLContext::CreateTizenEGLPbufferSurface() { - const EGLint attribs[] = {EGL_WIDTH, 1, EGL_HEIGHT, 1, EGL_NONE}; - EGLSurface surface = eglCreatePbufferSurface( - tizen_native_egl_window_->GetEGLDisplayHandle(), egl_config_, attribs); - if (surface == EGL_NO_SURFACE) { - LogLastEGLError(); - } - return std::make_unique(tizen_native_egl_window_, surface); +std::unique_ptr +TizenGLContext::CreateTizenGLPbufferSurface() { + auto surface = evas_gl_pbuffer_surface_create(tizen_native_window_->GetEvasGLHandle(),gl_config_,tizen_native_window_->GetGeometry().w,tizen_native_window_->GetGeometry().h,NULL); + return std::make_unique(tizen_native_window_,surface); } TizenSurfaceGL::TizenSurfaceGL( @@ -139,22 +79,21 @@ TizenSurfaceGL::TizenSurfaceGL( return; } - tizen_context_gl_ = std::make_unique( - tizen_native_window_->GetTizenNativeEGLWindow()); + tizen_context_gl_ = std::make_unique(tizen_native_window_); if (!tizen_context_gl_->IsValid()) { FT_LOGE("Invalid context gl"); return; } - tizen_egl_window_surface_ = tizen_context_gl_->CreateTizenEGLWindowSurface(); - if (!tizen_egl_window_surface_->IsValid()) { + tizen_gl_window_surface_ = tizen_context_gl_->CreateTizenGLWindowSurface(); + if (!tizen_gl_window_surface_->IsValid()) { FT_LOGE("Invalid egl window surface"); return; } - tizen_egl_pbuffer_surface_ = - tizen_context_gl_->CreateTizenEGLPbufferSurface(); - if (!tizen_egl_pbuffer_surface_->IsValid()) { + tizen_gl_pbuffer_surface_ = + tizen_context_gl_->CreateTizenGLPbufferSurface(); + if (!tizen_gl_pbuffer_surface_->IsValid()) { FT_LOGE("Invalid egl puffer surface"); return; } @@ -167,15 +106,16 @@ bool TizenSurfaceGL::OnMakeCurrent() { FT_LOGE("Invalid TizenSurfaceGL"); return false; } - if (eglMakeCurrent(tizen_native_window_->GetTizenNativeEGLWindow() - ->GetEGLDisplayHandle(), - tizen_egl_window_surface_->GetEGLSurfaceHandle(), - tizen_egl_window_surface_->GetEGLSurfaceHandle(), - tizen_context_gl_->GetEGLContextHandle()) != EGL_TRUE) { - FT_LOGE("Could not make the onscreen context current"); - LogLastEGLError(); - return false; - } + evas_gl_make_current(tizen_native_window_->GetEvasGLHandle(), tizen_gl_window_surface_->GetGLSurfaceHandle(), tizen_context_gl_->GetGLContextHandle()); + // if (eglMakeCurrent(tizen_native_window_->GetTizenNativeEGLWindow() + // ->GetEGLDisplayHandle(), + // tizen_egl_window_surface_->GetEGLSurfaceHandle(), + // tizen_egl_window_surface_->GetEGLSurfaceHandle(), + // tizen_context_gl_->GetEGLContextHandle()) != EGL_TRUE) { + // FT_LOGE("Could not make the onscreen context current"); + // LogLastEGLError(); + // return false; + // } return true; } @@ -184,16 +124,19 @@ bool TizenSurfaceGL::OnMakeResourceCurrent() { FT_LOGE("Invalid TizenSurfaceGL"); return false; } - if (eglMakeCurrent(tizen_native_window_->GetTizenNativeEGLWindow() - ->GetEGLDisplayHandle(), - tizen_egl_pbuffer_surface_->GetEGLSurfaceHandle(), - tizen_egl_pbuffer_surface_->GetEGLSurfaceHandle(), - tizen_context_gl_->GetEGLResourceContextHandle()) != - EGL_TRUE) { - FT_LOGE("Could not make the offscreen context current"); - LogLastEGLError(); - return false; - } + + FT_LOGE("[MONG] OnMakeResourceCurrent..."); + evas_gl_make_current(tizen_native_window_->GetEvasGLHandle(), tizen_gl_pbuffer_surface_->GetGLSurfaceHandle(), tizen_context_gl_->GetGLResourceContextHandle()); + // if (eglMakeCurrent(tizen_native_window_->GetTizenNativeEGLWindow() + // ->GetEGLDisplayHandle(), + // tizen_egl_pbuffer_surface_->GetEGLSurfaceHandle(), + // tizen_egl_pbuffer_surface_->GetEGLSurfaceHandle(), + // tizen_context_gl_->GetEGLResourceContextHandle()) != + // EGL_TRUE) { + // FT_LOGE("Could not make the offscreen context current"); + // LogLastEGLError(); + // return false; + // } return true; } @@ -202,32 +145,32 @@ bool TizenSurfaceGL::OnClearCurrent() { FT_LOGE("Invalid TizenSurfaceGL"); return false; } - - if (eglMakeCurrent(tizen_native_window_->GetTizenNativeEGLWindow() - ->GetEGLDisplayHandle(), - EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT) != EGL_TRUE) { - FT_LOGE("Could not clear context"); - LogLastEGLError(); - return false; - } + evas_gl_make_current(tizen_native_window_->GetEvasGLHandle(), NULL, NULL); + // if (eglMakeCurrent(tizen_native_window_->GetTizenNativeEGLWindow() + // ->GetEGLDisplayHandle(), + // EGL_NO_SURFACE, EGL_NO_SURFACE, + // EGL_NO_CONTEXT) != EGL_TRUE) { + // FT_LOGE("Could not clear context"); + // LogLastEGLError(); + // return false; + // } return true; } bool TizenSurfaceGL::OnPresent() { - if (!is_valid_) { - FT_LOGE("Invalid TizenSurfaceGL"); - return false; - } - - if (eglSwapBuffers(tizen_native_window_->GetTizenNativeEGLWindow() - ->GetEGLDisplayHandle(), - tizen_egl_window_surface_->GetEGLSurfaceHandle()) != - EGL_TRUE) { - FT_LOGE("Could not swap EGl buffer"); - LogLastEGLError(); - return false; - } + // if (!is_valid_) { + // FT_LOGE("Invalid TizenSurfaceGL"); + // return false; + // } + + // if (eglSwapBuffers(tizen_native_window_->GetTizenNativeEGLWindow() + // ->GetEGLDisplayHandle(), + // tizen_egl_window_surface_->GetEGLSurfaceHandle()) != + // EGL_TRUE) { + // FT_LOGE("Could not swap EGl buffer"); + // LogLastEGLError(); + // return false; + // } return true; } @@ -242,16 +185,16 @@ uint32_t TizenSurfaceGL::OnGetFBO() { #define GL_FUNC(FunctionName) \ else if (strcmp(name, #FunctionName) == 0) { \ - return reinterpret_cast(FunctionName); \ + if(!tizen_native_window_->GetEvasGLApiHandle()->FunctionName){ FT_LOGE("[MONG]! "#FunctionName""); return reinterpret_cast(tizen_native_window_->GetEvasGLApiHandle()->glGetStringi); } \ + return reinterpret_cast(tizen_native_window_->GetEvasGLApiHandle()->FunctionName); \ } void* TizenSurfaceGL::OnProcResolver(const char* name) { - auto address = eglGetProcAddress(name); + auto address = evas_gl_proc_address_get(tizen_native_window_->GetEvasGLHandle(),name); + // auto address = eglGetProcAddress(name); if (address != nullptr) { return reinterpret_cast(address); } - GL_FUNC(eglGetCurrentDisplay) - GL_FUNC(eglQueryString) GL_FUNC(glActiveTexture) GL_FUNC(glAttachShader) GL_FUNC(glBindAttribLocation) @@ -357,6 +300,13 @@ void* TizenSurfaceGL::OnProcResolver(const char* name) { GL_FUNC(glVertexAttrib4fv) GL_FUNC(glVertexAttribPointer) GL_FUNC(glViewport) + GL_FUNC(glGetStringi) + else if (strcmp(name, "eglGetCurrentDisplay") == 0) { + return reinterpret_cast(eglGetCurrentDisplay); + } + else if (strcmp(name, "eglQueryString") == 0) { + return reinterpret_cast(eglQueryString); + } FT_LOGD("Could not resolve: %s", name); return nullptr; } @@ -364,8 +314,8 @@ void* TizenSurfaceGL::OnProcResolver(const char* name) { TizenSurfaceGL::~TizenSurfaceGL() { OnClearCurrent(); - tizen_egl_window_surface_ = nullptr; - tizen_egl_pbuffer_surface_ = nullptr; + tizen_gl_window_surface_ = nullptr; + tizen_gl_pbuffer_surface_ = nullptr; tizen_context_gl_ = nullptr; tizen_native_window_ = nullptr; } diff --git a/shell/platform/tizen/tizen_surface_gl.h b/shell/platform/tizen/tizen_surface_gl.h index 8a83c82d4f85d..728006521a408 100644 --- a/shell/platform/tizen/tizen_surface_gl.h +++ b/shell/platform/tizen/tizen_surface_gl.h @@ -19,37 +19,35 @@ #include "flutter/shell/platform/tizen/tizen_native_window.h" #include "flutter/shell/platform/tizen/tizen_surface.h" -class TizenEGLSurface { +class TizenGLSurface { public: - TizenEGLSurface(std::shared_ptr tizen_native_egl_window, - EGLSurface egl_surface) - : tizen_native_egl_window_(tizen_native_egl_window), - egl_surface_(egl_surface){}; - ~TizenEGLSurface(); - bool IsValid() { return egl_surface_ != EGL_NO_SURFACE; } - EGLSurface GetEGLSurfaceHandle() { return egl_surface_; }; + TizenGLSurface(std::shared_ptr tizen_native_window, Evas_GL_Surface* gl_surface) + : gl_surface_(gl_surface){}; + ~TizenGLSurface(); + bool IsValid() { return gl_surface_ != nullptr; } + Evas_GL_Surface* GetGLSurfaceHandle() { return gl_surface_; }; private: - std::shared_ptr tizen_native_egl_window_; - EGLSurface egl_surface_{EGL_NO_SURFACE}; + std::shared_ptr tizen_native_window_; + Evas_GL_Surface* gl_surface_{nullptr}; }; -class TizenEGLContext { +class TizenGLContext { public: - TizenEGLContext( - std::shared_ptr tizen_native_egl_window); - ~TizenEGLContext(); + TizenGLContext( + std::shared_ptr tizen_native_window); + ~TizenGLContext(); bool IsValid(); - std::unique_ptr CreateTizenEGLWindowSurface(); - std::unique_ptr CreateTizenEGLPbufferSurface(); - EGLContext GetEGLContextHandle() { return egl_context_; } - EGLContext GetEGLResourceContextHandle() { return egl_resource_context_; } + std::unique_ptr CreateTizenGLWindowSurface(); + std::unique_ptr CreateTizenGLPbufferSurface(); + Evas_GL_Context* GetGLContextHandle() { return gl_context_; } + Evas_GL_Context* GetGLResourceContextHandle() { return gl_resource_context_; } public: - std::shared_ptr tizen_native_egl_window_; - EGLConfig egl_config_{nullptr}; - EGLContext egl_context_{EGL_NO_CONTEXT}; - EGLContext egl_resource_context_{EGL_NO_CONTEXT}; + std::shared_ptr tizen_native_window_; + Evas_GL_Config* gl_config_; + Evas_GL_Context* gl_context_; + Evas_GL_Context* gl_resource_context_; }; class TizenSurfaceGL : public TizenSurface { @@ -67,9 +65,9 @@ class TizenSurfaceGL : public TizenSurface { private: bool is_valid_{false}; std::shared_ptr tizen_native_window_; - std::unique_ptr tizen_context_gl_; - std::unique_ptr tizen_egl_window_surface_; - std::unique_ptr tizen_egl_pbuffer_surface_; + std::unique_ptr tizen_context_gl_; + std::unique_ptr tizen_gl_window_surface_; + std::unique_ptr tizen_gl_pbuffer_surface_; }; #endif // EMBEDDER_TIZEN_SURFACE_GL_H_