forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 17
Refactor tizen surface #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bwikbs
merged 1 commit into
flutter-tizen:flutter-1.22-candidate.12-tizen
from
bbrto21:refactor
Dec 17, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "tizen_native_window.h" | ||
|
||
#include "flutter/shell/platform/tizen/logger.h" | ||
|
||
class TizenWl2Display { | ||
public: | ||
TizenWl2Display() { | ||
if (!ecore_wl2_init()) { | ||
LoggerE("Could not initialize ecore_wl2"); | ||
return; | ||
swift-kim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
// ecore_wl2 DISPLAY | ||
wl2_display_ = ecore_wl2_display_connect(nullptr); | ||
if (wl2_display_ == nullptr) { | ||
LoggerE("Display not found"); | ||
return; | ||
} | ||
ecore_wl2_sync(); | ||
} | ||
|
||
~TizenWl2Display() { | ||
if (wl2_display_) { | ||
ecore_wl2_display_destroy(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) { | ||
LoggerE("Could not access EGL display"); | ||
return; | ||
} | ||
|
||
EGLint major_version; | ||
EGLint minor_version; | ||
if (eglInitialize(egl_display_, &major_version, &minor_version) != EGL_TRUE) { | ||
LoggerE("Could not initialize EGL display"); | ||
return; | ||
} | ||
|
||
LoggerD("eglInitialized: %d.%d", major_version, minor_version); | ||
|
||
if (eglBindAPI(EGL_OPENGL_ES_API) != EGL_TRUE) { | ||
LoggerE("Could not bind API"); | ||
return; | ||
} | ||
} | ||
|
||
TizenNativeEGLWindow::~TizenNativeEGLWindow() { | ||
if (egl_window_) { | ||
ecore_wl2_egl_window_destroy(egl_window_); | ||
egl_window_ = nullptr; | ||
} | ||
if (egl_display_ != EGL_NO_CONTEXT) { | ||
eglTerminate(egl_display_); | ||
} | ||
} | ||
|
||
TizenNativeWindow::TizenNativeWindow(int32_t x, int32_t y, int32_t w, | ||
int32_t h) { | ||
if (g_tizen_wl2_display.GetHandle() == nullptr) { | ||
LoggerE("Faild to get display handle"); | ||
return; | ||
} | ||
if (w == 0 || h == 0) { | ||
LoggerE("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_unique<TizenNativeEGLWindow>(this, w, h); | ||
is_valid_ = true; | ||
} | ||
|
||
TizenNativeWindow::~TizenNativeWindow() { | ||
if (wl2_window_) { | ||
ecore_wl2_window_free(wl2_window_); | ||
wl2_window_ = nullptr; | ||
} | ||
} | ||
|
||
TizenNativeWindow::TizenNativeWindowGeometry TizenNativeWindow::GetGeometry() { | ||
TizenNativeWindowGeometry result; | ||
ecore_wl2_window_geometry_get(wl2_window_, &result.x, &result.y, &result.w, | ||
&result.h); | ||
return result; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef EMBEDDER_TIZEN_WINDOW_H_ | ||
#define EMBEDDER_TIZEN_WINDOW_H_ | ||
#include <EGL/egl.h> | ||
#include <GLES2/gl2.h> | ||
#define EFL_BETA_API_SUPPORT | ||
#include <Ecore_Wl2.h> | ||
|
||
#include <memory> | ||
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_; } | ||
|
||
private: | ||
Ecore_Wl2_Egl_Window* egl_window_ = nullptr; | ||
EGLDisplay egl_display_ = EGL_NO_DISPLAY; | ||
}; | ||
|
||
class TizenNativeWindow { | ||
public: | ||
struct TizenNativeWindowGeometry { | ||
int32_t x{0}, y{0}, w{0}, h{0}; | ||
}; | ||
|
||
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_; } | ||
TizenNativeEGLWindow* GetTizenNativeEGLWindow() { | ||
return tizen_native_egl_window_.get(); | ||
}; | ||
TizenNativeWindowGeometry GetGeometry(); | ||
|
||
private: | ||
std::unique_ptr<TizenNativeEGLWindow> tizen_native_egl_window_; | ||
Ecore_Wl2_Window* wl2_window_{nullptr}; | ||
bool is_valid_{false}; | ||
}; | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.