X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwindow_manager.cpp;h=aa42d82878b82d2b39b3c26aca10a4658db52774;hb=38255dcda8e7e9462ed3b16ebe39c638bc9b349f;hp=76b59393573a3c0ed1684a937c04261ec4ebea6b;hpb=40ec5ee486893ccb1d259c7980b077cb087494aa;p=apps%2Fagl-service-windowmanager.git diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 76b5939..aa42d82 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -19,7 +19,6 @@ #include "window_manager.hpp" #include "json_helper.hpp" -#include "wm_config.hpp" #include "applist.hpp" extern "C" @@ -51,6 +50,7 @@ const char kKeyWidthPixel[] = "width_pixel"; const char kKeyHeightPixel[] = "height_pixel"; const char kKeyWidthMm[] = "width_mm"; const char kKeyHeightMm[] = "height_mm"; +const char kKeyScale[] = "scale"; const char kKeyIds[] = "ids"; static sd_event_source *g_timer_ev_src = nullptr; @@ -147,7 +147,6 @@ WindowManager::WindowManager(wl::display *d) int WindowManager::init() { - int ret; if (!this->display->ok()) { return -1; @@ -203,8 +202,7 @@ int WindowManager::init() // Third level objects this->display->roundtrip(); - ret = init_layers(); - return ret; + return init_layers(); } int WindowManager::dispatch_pending_events() @@ -463,10 +461,9 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) result WindowManager::api_get_display_info() { - // Check controller - if (!this->controller) + if (!this->display->ok()) { - return Err("ivi_controller global not available"); + return Err("Wayland compositor is not available"); } // Set display info @@ -478,6 +475,7 @@ result WindowManager::api_get_display_info() json_object_object_add(object, kKeyHeightPixel, json_object_new_int(o_size.h)); json_object_object_add(object, kKeyWidthMm, json_object_new_int(p_size.w)); json_object_object_add(object, kKeyHeightMm, json_object_new_int(p_size.h)); + json_object_object_add(object, kKeyScale, json_object_new_double(this->controller->scale)); return Ok(object); } @@ -659,27 +657,32 @@ int WindowManager::init_layers() return -1; } - WMConfig wm_config; - wm_config.loadConfigs(); - auto &c = this->controller; auto &o = this->outputs.front(); auto &s = c->screens.begin()->second; auto &layers = c->layers; - this->layers.loadAreaDb(); - const compositor::rect base = this->layers.getAreaSize("fullscreen"); - - const std::string aspect_setting = wm_config.getConfigAspect(); - const compositor::rect scale_rect = - this->layers.getScaleDestRect(o->width, o->height, aspect_setting); - // Write output dimensions to ivi controller... c->output_size = compositor::size{uint32_t(o->width), uint32_t(o->height)}; c->physical_size = compositor::size{uint32_t(o->physical_width), uint32_t(o->physical_height)}; + + HMI_DEBUG("wm", "SCALING: screen (%dx%d), physical (%dx%d)", + o->width, o->height, o->physical_width, o->physical_height); + + this->layers.loadAreaDb(); + + const compositor::rect css_bg = this->layers.getAreaSize("fullscreen"); + rectangle dp_bg(o->width, o->height); + + dp_bg.set_aspect(static_cast(css_bg.w) / css_bg.h); + dp_bg.fit(o->width, o->height); + dp_bg.center(o->width, o->height); + HMI_DEBUG("wm", "SCALING: CSS BG(%dx%d) -> DDP %dx%d,(%dx%d)", + css_bg.w, css_bg.h, dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height()); + // Clear scene layers.clear(); @@ -689,11 +692,9 @@ int WindowManager::init_layers() // Quick and dirty setup of layers for (auto const &i : this->layers.mapping) { - c->layer_create(i.second.layer_id, scale_rect.w, scale_rect.h); + c->layer_create(i.second.layer_id, dp_bg.width(), dp_bg.height()); auto &l = layers[i.second.layer_id]; - l->set_source_rectangle(0, 0, base.w, base.h); - l->set_destination_rectangle( - scale_rect.x, scale_rect.y, scale_rect.w, scale_rect.h); + l->set_destination_rectangle(dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height()); l->set_visibility(1); HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"", i.second.name.c_str(), i.second.layer_id, i.second.role.c_str()); @@ -704,6 +705,9 @@ int WindowManager::init_layers() this->layout_commit(); + c->scale = static_cast(dp_bg.height()) / css_bg.h; + this->layers.setupArea(c->scale); + return 0; }