Merge lp:~3v1n0/unity/lockscreen-background-scaling-fixes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4221
Proposed branch: lp:~3v1n0/unity/lockscreen-background-scaling-fixes
Merge into: lp:unity
Diff against target: 58 lines (+13/-5)
2 files modified
lockscreen/BackgroundSettings.cpp (+12/-5)
lockscreen/LockScreenBaseShield.cpp (+1/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/lockscreen-background-scaling-fixes
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+317932@code.launchpad.net

Commit message

BackgroundSettings: use gnome-bg to generate textures with proper scaling

When using non-user background, we ensure that the texture size matches
the screen size, and also we now generate the background using an high
quality pixmap, instead of stretching a non-scaled one.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lockscreen/BackgroundSettings.cpp'
--- lockscreen/BackgroundSettings.cpp 2014-07-29 12:05:47 +0000
+++ lockscreen/BackgroundSettings.cpp 2017-02-22 01:46:26 +0000
@@ -53,23 +53,28 @@
53 auto& settings = Settings::Instance();53 auto& settings = Settings::Instance();
5454
55 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);55 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);
56 cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale);
57 cairo_t* c = cairo_graphics.GetInternalContext();56 cairo_t* c = cairo_graphics.GetInternalContext();
5857
58 glib::Object<GnomeBG> gnome_bg;
59 double s_width = geo.width / scale;59 double s_width = geo.width / scale;
60 double s_height = geo.height / scale;60 double s_height = geo.height / scale;
61 cairo_surface_t* bg_surface = nullptr;61 cairo_surface_t* bg_surface = nullptr;
6262
63 if (settings.use_user_background())63 if (settings.use_user_background())
64 {64 {
65 bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), s_width, s_height, FALSE);65 gnome_bg = gnome_bg_;
66 }66 }
67 else if (!settings.background().empty())67 else if (!settings.background().empty())
68 {68 {
69 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), s_width, s_height, FALSE, NULL));69 gnome_bg = gnome_bg_new();
70 gnome_bg_set_filename(gnome_bg, settings.background().c_str());
71 gnome_bg_set_placement(gnome_bg, G_DESKTOP_BACKGROUND_STYLE_ZOOM);
72 }
7073
71 if (pixbuf)74 if (gnome_bg)
72 bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);75 {
76 auto *root_window = gdk_get_default_root_window();
77 bg_surface = gnome_bg_create_surface(gnome_bg, root_window, geo.width, geo.height, FALSE);
73 }78 }
7479
75 if (bg_surface)80 if (bg_surface)
@@ -85,6 +90,8 @@
85 cairo_paint(c);90 cairo_paint(c);
86 }91 }
8792
93 cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale);
94
88 if (!settings.logo().empty())95 if (!settings.logo().empty())
89 {96 {
90 int grid_x_offset = GetGridOffset(s_width);97 int grid_x_offset = GetGridOffset(s_width);
9198
=== modified file 'lockscreen/LockScreenBaseShield.cpp'
--- lockscreen/LockScreenBaseShield.cpp 2016-08-30 17:46:20 +0000
+++ lockscreen/LockScreenBaseShield.cpp 2017-02-22 01:46:26 +0000
@@ -145,6 +145,7 @@
145 {145 {
146 auto background_texture = bg_settings_->GetBackgroundTexture(monitor);146 auto background_texture = bg_settings_->GetBackgroundTexture(monitor);
147 background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true));147 background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true));
148 background_layer_->SetGeometry(monitor_geo);
148 SetBackgroundLayer(background_layer_.get());149 SetBackgroundLayer(background_layer_.get());
149 }150 }
150}151}