Skip to content

Add native window handle to platform view #136

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
merged 2 commits into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void FlutterRegisterViewFactory(
FlutterDesktopPluginRegistrarRef registrar,
const char* view_type,
std::unique_ptr<PlatformViewFactory> view_factory) {
view_factory->SetWindow(registrar->engine->renderer->GetWindowHandle());
registrar->engine->platform_view_channel->ViewFactories().insert(
std::pair<std::string, std::unique_ptr<PlatformViewFactory>>(
view_type, std::move(view_factory)));
Expand Down
40 changes: 25 additions & 15 deletions shell/platform/tizen/public/flutter_platform_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ using ByteMessage = std::vector<uint8_t>;

class PlatformView {
public:
PlatformView(flutter::PluginRegistrar* registrar, int viewId)
: registrar_(registrar),
viewId_(viewId),
textureId_(0),
isFocused_(false) {}
PlatformView(flutter::PluginRegistrar* registrar,
int view_id,
void* platform_window)
: platform_window_(platform_window),
registrar_(registrar),
view_id_(view_id),
texture_id_(0),
is_focused_(false) {}
virtual ~PlatformView() {}
int GetViewId() { return viewId_; }
int GetTextureId() { return textureId_; }
void SetTextureId(int textureId) { textureId_ = textureId; }
int GetViewId() { return view_id_; }
int GetTextureId() { return texture_id_; }
void SetTextureId(int texture_id) { texture_id_ = texture_id; }
flutter::PluginRegistrar* GetPluginRegistrar() { return registrar_; }
virtual void Dispose() = 0;
virtual void Resize(double width, double height) = 0;
Expand All @@ -36,8 +39,8 @@ class PlatformView {
double dy) = 0;
virtual void SetDirection(int direction) = 0;
virtual void ClearFocus() = 0;
void SetFocus(bool f) { isFocused_ = f; }
bool IsFocused() { return isFocused_; }
void SetFocus(bool f) { is_focused_ = f; }
bool IsFocused() { return is_focused_; }

// Key input event
virtual void DispatchKeyDownEvent(Ecore_Event_Key* key) = 0;
Expand All @@ -47,11 +50,14 @@ class PlatformView {

virtual void SetSoftwareKeyboardContext(Ecore_IMF_Context* context) = 0;

protected:
void* platform_window_;

private:
flutter::PluginRegistrar* registrar_;
int viewId_;
int textureId_;
bool isFocused_;
int view_id_;
int texture_id_;
bool is_focused_;
};

class PlatformViewFactory {
Expand All @@ -64,11 +70,15 @@ class PlatformViewFactory {
const flutter::MessageCodec<flutter::EncodableValue>& GetCodec() {
return codec_;
}
virtual PlatformView* Create(int viewId,
virtual PlatformView* Create(int view_id,
double width,
double height,
const ByteMessage& createParams) = 0;
const ByteMessage& parameters) = 0;
virtual void Dispose() = 0;
void SetWindow(void* platform_window) { platform_window_ = platform_window; }

protected:
void* platform_window_;

private:
flutter::PluginRegistrar* registrar_;
Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class TizenRenderer {
virtual TizenWindowGeometry GetGeometry() = 0;
virtual int32_t GetDpi() = 0;
virtual uintptr_t GetWindowId() = 0;
virtual void* GetWindowHandle() = 0;

virtual void SetRotate(int angle) = 0;
virtual void ResizeWithRotation(int32_t x,
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/tizen/tizen_renderer_ecore_wl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ uintptr_t TizenRendererEcoreWl2::GetWindowId() {
return ecore_wl2_window_id_get(ecore_wl2_window_);
}

void* TizenRendererEcoreWl2::GetWindowHandle() {
return ecore_wl2_window_;
}

bool TizenRendererEcoreWl2::InitializeRenderer() {
int32_t width, height;
if (!SetupDisplay(width, height)) {
Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_renderer_ecore_wl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TizenRendererEcoreWl2 : public TizenRenderer {
TizenWindowGeometry GetGeometry() override;
int32_t GetDpi() override;
uintptr_t GetWindowId() override;
void* GetWindowHandle() override;

void ResizeWithRotation(int32_t x,
int32_t y,
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/tizen/tizen_renderer_evas_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,10 @@ uintptr_t TizenRendererEvasGL::GetWindowId() {
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_)));
}

void* TizenRendererEvasGL::GetWindowHandle() {
return nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional or just unimplemented?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's half and half 😄
Evasgl version is not implemented yet.. so This is for preventing tricky issues.

}

Evas_Object* TizenRendererEvasGL::GetImageHandle() {
return graphics_adapter_;
}
Expand Down
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_renderer_evas_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TizenRendererEvasGL : public TizenRenderer {
TizenWindowGeometry GetGeometry() override;
int32_t GetDpi() override;
uintptr_t GetWindowId() override;
void* GetWindowHandle() override;

void ResizeWithRotation(int32_t x,
int32_t y,
Expand Down