Skip to content

Commit

Permalink
Add native window handle to platform view (flutter#136)
Browse files Browse the repository at this point in the history
* Add native window handle to platform view

* This is a preparation to independently handle something (e.g. imf) in platform view.

* Apply review's comment

Signed-off-by: MuHong Byun <[email protected]>
  • Loading branch information
bwikbs authored and swift-kim committed Dec 17, 2021
1 parent 886b69a commit 9d56c35
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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 WindowGeometry GetCurrentGeometry() = 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 @@ -232,6 +232,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 {
WindowGeometry GetCurrentGeometry() 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 @@ -568,6 +568,10 @@ uintptr_t TizenRendererEvasGL::GetWindowId() {
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_)));
}

void* TizenRendererEvasGL::GetWindowHandle() {
return nullptr;
}

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 {
WindowGeometry GetCurrentGeometry() override;
int32_t GetDpi() override;
uintptr_t GetWindowId() override;
void* GetWindowHandle() override;

void ResizeWithRotation(int32_t x,
int32_t y,
Expand Down

0 comments on commit 9d56c35

Please sign in to comment.