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
1=== modified file 'lockscreen/BackgroundSettings.cpp'
2--- lockscreen/BackgroundSettings.cpp 2014-07-29 12:05:47 +0000
3+++ lockscreen/BackgroundSettings.cpp 2017-02-22 01:46:26 +0000
4@@ -53,23 +53,28 @@
5 auto& settings = Settings::Instance();
6
7 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, geo.width, geo.height);
8- cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale);
9 cairo_t* c = cairo_graphics.GetInternalContext();
10
11+ glib::Object<GnomeBG> gnome_bg;
12 double s_width = geo.width / scale;
13 double s_height = geo.height / scale;
14 cairo_surface_t* bg_surface = nullptr;
15
16 if (settings.use_user_background())
17 {
18- bg_surface = gnome_bg_create_surface(gnome_bg_, gdk_get_default_root_window(), s_width, s_height, FALSE);
19+ gnome_bg = gnome_bg_;
20 }
21 else if (!settings.background().empty())
22 {
23- glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file_at_scale(settings.background().c_str(), s_width, s_height, FALSE, NULL));
24+ gnome_bg = gnome_bg_new();
25+ gnome_bg_set_filename(gnome_bg, settings.background().c_str());
26+ gnome_bg_set_placement(gnome_bg, G_DESKTOP_BACKGROUND_STYLE_ZOOM);
27+ }
28
29- if (pixbuf)
30- bg_surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
31+ if (gnome_bg)
32+ {
33+ auto *root_window = gdk_get_default_root_window();
34+ bg_surface = gnome_bg_create_surface(gnome_bg, root_window, geo.width, geo.height, FALSE);
35 }
36
37 if (bg_surface)
38@@ -85,6 +90,8 @@
39 cairo_paint(c);
40 }
41
42+ cairo_surface_set_device_scale(cairo_graphics.GetSurface(), scale, scale);
43+
44 if (!settings.logo().empty())
45 {
46 int grid_x_offset = GetGridOffset(s_width);
47
48=== modified file 'lockscreen/LockScreenBaseShield.cpp'
49--- lockscreen/LockScreenBaseShield.cpp 2016-08-30 17:46:20 +0000
50+++ lockscreen/LockScreenBaseShield.cpp 2017-02-22 01:46:26 +0000
51@@ -145,6 +145,7 @@
52 {
53 auto background_texture = bg_settings_->GetBackgroundTexture(monitor);
54 background_layer_.reset(new nux::TextureLayer(background_texture->GetDeviceTexture(), nux::TexCoordXForm(), nux::color::White, true));
55+ background_layer_->SetGeometry(monitor_geo);
56 SetBackgroundLayer(background_layer_.get());
57 }
58 }