Skip to content

Commit

Permalink
Support partial window (flutter-tizen#114)
Browse files Browse the repository at this point in the history
* Support user made window

* This is a necessary feature for partial window.

Signed-off-by: MuHong Byun <[email protected]>

* Apply Review's commit

Signed-off-by: MuHong Byun <[email protected]>
  • Loading branch information
bwikbs committed Jun 22, 2021
1 parent 9ebcb6a commit 0709d84
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 24 deletions.
3 changes: 2 additions & 1 deletion shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ FlutterDesktopEngineRef FlutterDesktopRunEngine(
bool headed) {
StartLogging();

auto engine = std::make_unique<FlutterTizenEngine>(headed);
auto engine = std::make_unique<FlutterTizenEngine>(
headed, engine_properties.custom_win);
if (!engine->RunEngine(engine_properties)) {
FT_LOGE("Failed to run the Flutter engine.");
return nullptr;
Expand Down
11 changes: 9 additions & 2 deletions shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ static DeviceProfile GetDeviceProfile() {
return DeviceProfile::kUnknown;
}

FlutterTizenEngine::FlutterTizenEngine(bool headed)
: device_profile(GetDeviceProfile()) {
FlutterTizenEngine::FlutterTizenEngine(bool headed, void* win)
: device_profile(GetDeviceProfile()), custom_window_(win) {
embedder_api_.struct_size = sizeof(FlutterEngineProcTable);
FlutterEngineGetProcAddresses(&embedder_api_);

Expand Down Expand Up @@ -429,6 +429,13 @@ bool FlutterTizenEngine::MarkExternalTextureFrameAvailable(int64_t texture_id) {
engine_, texture_id) == kSuccess);
}

bool FlutterTizenEngine::hasCustomWindow() {
return custom_window_ != nullptr;
}
void* FlutterTizenEngine::CustomWindow() {
return custom_window_;
}

// The Flutter Engine calls out to this function when new platform messages are
// available.

Expand Down
8 changes: 7 additions & 1 deletion shell/platform/tizen/flutter_tizen_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum DeviceProfile { kUnknown, kMobile, kWearable, kTV, kCommon };
// Manages state associated with the underlying FlutterEngine.
class FlutterTizenEngine : public TizenRenderer::Delegate {
public:
explicit FlutterTizenEngine(bool headed);
explicit FlutterTizenEngine(bool headed, void* win );
virtual ~FlutterTizenEngine();

// Prevent copying.
Expand Down Expand Up @@ -119,6 +119,10 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {
// given |texture_id|.
bool MarkExternalTextureFrameAvailable(int64_t texture_id);

// This is an experimental feature to support partial window.
bool hasCustomWindow() override;
void* CustomWindow() override;

// The plugin messenger handle given to API clients.
std::unique_ptr<FlutterDesktopMessenger> messenger;

Expand Down Expand Up @@ -187,6 +191,8 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {

// The current renderer transformation.
FlutterTransformation transformation_;

void* custom_window_;
};

#endif // EMBEDDER_FLUTTER_TIZEN_ENGINE_H_
2 changes: 2 additions & 0 deletions shell/platform/tizen/public/flutter_tizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ typedef struct {
const char** switches;
// The number of elements in |switches|.
size_t switches_count;
// This is an experimental feature to support partial window.
void* custom_win;
} FlutterDesktopEngineProperties;

// Runs an instance of a Flutter engine with the given properties.
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/tizen/tizen_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class TizenRenderer {
class Delegate {
public:
virtual void OnOrientationChange(int32_t degree) = 0;
// This is an experimental feature to support partial window.
virtual bool hasCustomWindow() = 0;
virtual void* CustomWindow() = 0;
};

virtual ~TizenRenderer();
Expand Down
20 changes: 13 additions & 7 deletions shell/platform/tizen/tizen_renderer_ecore_wl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,19 @@ bool TizenRendererEcoreWl2::SetupEcoreWlWindow(int32_t width, int32_t height) {
FT_LOGE("Invalid screen size: %d x %d", width, height);
return false;
}
ecore_wl2_window_ =
ecore_wl2_window_new(ecore_wl2_display_, nullptr, 0, 0, width, height);
ecore_wl2_window_type_set(ecore_wl2_window_, ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_FALSE);
ecore_wl2_window_position_set(ecore_wl2_window_, 0, 0);
ecore_wl2_window_aux_hint_add(ecore_wl2_window_, 0,
"wm.policy.win.user.geometry", "1");
if (delegate_.hasCustomWindow()) {
ecore_wl2_window_ =
reinterpret_cast<Ecore_Wl2_Window*>(delegate_.CustomWindow());
} else {
ecore_wl2_window_ =
ecore_wl2_window_new(ecore_wl2_display_, nullptr, 0, 0, width, height);
ecore_wl2_window_type_set(ecore_wl2_window_,
ECORE_WL2_WINDOW_TYPE_TOPLEVEL);
ecore_wl2_window_alpha_set(ecore_wl2_window_, EINA_FALSE);
ecore_wl2_window_position_set(ecore_wl2_window_, 0, 0);
ecore_wl2_window_aux_hint_add(ecore_wl2_window_, 0,
"wm.policy.win.user.geometry", "1");
}
int rotations[4] = {0, 90, 180, 270};
ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations,
sizeof(rotations) / sizeof(int));
Expand Down
30 changes: 17 additions & 13 deletions shell/platform/tizen/tizen_renderer_evas_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -635,21 +635,25 @@ Evas_Object* TizenRendererEvasGL::SetupEvasWindow(int32_t& width,
int32_t& height) {
elm_config_accel_preference_set("hw:opengl");

evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
auto* ecore_evas =
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_));
int32_t x, y;
ecore_evas_screen_geometry_get(ecore_evas, &x, &y, &width, &height);
if (width == 0 || height == 0) {
FT_LOGE("Invalid screen size: %d x %d", width, height);
return nullptr;
if (delegate_.hasCustomWindow()) {
evas_window_ = reinterpret_cast<Evas_Object*>(delegate_.CustomWindow());
} else {
evas_window_ = elm_win_add(NULL, NULL, ELM_WIN_BASIC);
auto* ecore_evas =
ecore_evas_ecore_evas_get(evas_object_evas_get(evas_window_));
int32_t x = 0, y = 0;
ecore_evas_screen_geometry_get(ecore_evas, &x, &y, &width, &height);
if (width == 0 || height == 0) {
FT_LOGE("Invalid screen size: %d x %d", width, height);
return nullptr;
}

elm_win_alpha_set(evas_window_, EINA_FALSE);
evas_object_move(evas_window_, 0, 0);
evas_object_resize(evas_window_, width, height);
evas_object_raise(evas_window_);
}

elm_win_alpha_set(evas_window_, EINA_FALSE);
evas_object_move(evas_window_, 0, 0);
evas_object_resize(evas_window_, width, height);
evas_object_raise(evas_window_);

Evas_Object* bg = elm_bg_add(evas_window_);
evas_object_color_set(bg, 0x00, 0x00, 0x00, 0x00);

Expand Down

0 comments on commit 0709d84

Please sign in to comment.