Merge lp:~mterry/unity-system-compositor/default-wallpaper into lp:unity-system-compositor

Proposed by Michael Terry
Status: Merged
Approved by: Michael Terry
Approved revision: 300
Merged at revision: 300
Proposed branch: lp:~mterry/unity-system-compositor/default-wallpaper
Merge into: lp:unity-system-compositor
Diff against target: 178 lines (+40/-15)
4 files modified
CMakeLists.txt (+1/-0)
debian/control (+2/-0)
spinner/CMakeLists.txt (+2/-7)
spinner/eglspinner.cpp (+35/-8)
To merge this branch: bzr merge lp:~mterry/unity-system-compositor/default-wallpaper
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Alexandros Frantzis (community) Approve
Review via email: mp+297791@code.launchpad.net

Commit message

Use system wallpaper instead of custom built-in one.

Additionally, crop it instead of stretching it.

Description of the change

I used gdk-pixbuf for loading the image. Is there a better library to use? We were already using glib, so it didn't seem like a big stretch.

Question for reviewers: how badly do we want performance here? It's good to reduce the gap between the firmware screen and the spinner screen. Here's rough timings from program launch to first frame for the old background and new (on my laptop, which is presumably beefier than my phone):

Old background (statically linked into binary): ~0.080s
New background (statically linked into binary): ~0.125s
New background (dynamically loaded): ~0.250s

This MP is currently dynamically loaded, since it's "most correct". But it might be worth statically linking the image for the time savings? It means we'd have to no-change rebuild the package every time ubuntu-wallpapers updates the default image before USC picks it up.

I'm open to options.

Also related:
- https://code.launchpad.net/~mterry/ubuntu-system-settings/default-wallpaper/+merge/297632
- https://code.launchpad.net/~mterry/unity8/default-wallpaper/+merge/297636

I've made silo 23 that includes all three for easier testing.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

/me looks into the startup timing changes involved in loading the image dynamically vs built in.

Revision history for this message
Michael Terry (mterry) wrote :

OK, added some brief timing notes in the description.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Code looks good.

On krillin the timings I get are:

static wallpaper.png 0.34s
dynamic wallpaper.png 0.28s !!!
static warty-final-ubuntu.png 0.62s
dynamic warty-final-ubuntu.png 0.82s

For the large background, the penalty for dynamically loading is 0.2s, whereas there seems to be a slight benefit for the small background.

Note that dynamically loading presents a net gain in installed size, which may be a concern on the phone. With static embedding unity-system-compositor-spinner size is ~28MB, whereas with dynamic loading usc-spinner is 0.3MB + 20MB for ubuntu-wallpaper(-vivid) packages. We could get even lower if there was a package that didn't pull in *all* the wallpapers for the distro.

Ideas for improved performance:
* Also provide a lower resolution (e.g. 1920x1080) version of the default background. If the display is not larger than that we could just go with the small version and improve performance a lot.
* We could experiment with using libpng directly to check if it reduces loading time.

My vote is to go with dynamic loading, since it's the lowest maintenance solution (no need for rebuilds etc), and the runtime cost is not prohibitive, especially if we implement idea (1) and provide a lower resolution image also.

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Actually small concern/needs info:

On krillin I see a horizontal line just behind the logo, as if like the image somehow restarts at that point. Could this be a cropping artifact?

review: Needs Information
Revision history for this message
Michael Terry (mterry) wrote :

You mentioned the size of installing ubuntu-wallpapers. We need ubuntu-wallpapers for the other components of this change (ubuntu-system-settings and unity8) anyway. So dynamic or not, those packages will be installed.

And I agree it's annoying that ubuntu-wallpapers assumes you want all of vivid-wallpapers too.

I'll test on krillin and see about that horizontal line...

Revision history for this message
Michael Terry (mterry) wrote :
Revision history for this message
Alexandros Frantzis (afrantzis) :
review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2016-06-09 08:36:48 +0000
3+++ CMakeLists.txt 2016-06-17 16:55:53 +0000
4@@ -39,6 +39,7 @@
5
6 find_package(PkgConfig)
7 pkg_check_modules(ANDROIDPROPS libandroid-properties)
8+pkg_check_modules(GDKPIXBUF REQUIRED gdk-pixbuf-2.0)
9 pkg_check_modules(GLIB REQUIRED glib-2.0)
10 pkg_check_modules(MIRCLIENT REQUIRED mirclient)
11 pkg_check_modules(MIRSERVER REQUIRED mirserver)
12
13=== modified file 'debian/control'
14--- debian/control 2016-06-09 08:32:32 +0000
15+++ debian/control 2016-06-17 16:55:53 +0000
16@@ -11,6 +11,7 @@
17 libboost-dev,
18 libboost-system-dev,
19 libdbus-1-dev,
20+ libgdk-pixbuf2.0-dev,
21 libglib2.0-dev,
22 libgles2-mesa-dev,
23 libglm-dev,
24@@ -31,6 +32,7 @@
25 Architecture: any
26 Depends: ${misc:Depends},
27 ${shlibs:Depends},
28+ ubuntu-wallpapers,
29 Suggests: repowerd,
30 Description: System compositor for Ubuntu
31 System compositor used by the Mir display server in Ubuntu. If the Unity
32
33=== modified file 'spinner/CMakeLists.txt'
34--- spinner/CMakeLists.txt 2015-06-25 15:47:06 +0000
35+++ spinner/CMakeLists.txt 2016-06-17 16:55:53 +0000
36@@ -23,12 +23,6 @@
37 endfunction()
38
39 png2header(
40- ${CMAKE_CURRENT_SOURCE_DIR}/wallpaper.png
41- ${CMAKE_CURRENT_BINARY_DIR}/wallpaper.h
42- wallpaper
43-)
44-
45-png2header(
46 ${CMAKE_CURRENT_SOURCE_DIR}/logo.png
47 ${CMAKE_CURRENT_BINARY_DIR}/logo.h
48 logo
49@@ -47,6 +41,7 @@
50 )
51
52 include_directories(
53+ ${GDKPIXBUF_INCLUDE_DIRS}
54 ${GLIB_INCLUDE_DIRS}
55 ${ANDROIDPROPS_INCLUDE_DIRS}
56 ${GLESv2_INCLUDE_DIRS}
57@@ -66,7 +61,6 @@
58 eglspinner.cpp
59 miregl.h
60 miregl.cpp
61- ${CMAKE_CURRENT_BINARY_DIR}/wallpaper.h
62 ${CMAKE_CURRENT_BINARY_DIR}/logo.h
63 ${CMAKE_CURRENT_BINARY_DIR}/white_dot.h
64 ${CMAKE_CURRENT_BINARY_DIR}/orange_dot.h
65@@ -74,6 +68,7 @@
66
67 target_link_libraries(unity-system-compositor-spinner
68 EGL
69+ ${GDKPIXBUF_LDFLAGS}
70 ${GLIB_LDFLAGS}
71 ${ANDROIDPROPS_LDFLAGS}
72 ${GLESv2_LIBRARIES}
73
74=== modified file 'spinner/eglspinner.cpp'
75--- spinner/eglspinner.cpp 2016-02-17 11:04:24 +0000
76+++ spinner/eglspinner.cpp 2016-06-17 16:55:53 +0000
77@@ -1,5 +1,5 @@
78 /*
79- * Copyright © 2013-2015 Canonical Ltd.
80+ * Copyright © 2013-2016 Canonical Ltd.
81 *
82 * This program is free software: you can redistribute it and/or modify
83 * it under the terms of the GNU General Public License version 3 as
84@@ -12,16 +12,12 @@
85 *
86 * You should have received a copy of the GNU General Public License
87 * along with this program. If not, see <http://www.gnu.org/licenses/>.
88- *
89- * Authors: Daniel van Vugt <daniel.van.vugt@canonical.com>
90- * Mirco Müller <mirco.mueller@canonical.com>
91- * Alan Griffiths <alan@octopull.co.uk>
92- * Kevin DuBois <kevin.dubois@canonical.com>
93 */
94
95 #include "eglapp.h"
96 #include "miregl.h"
97 #include <assert.h>
98+#include <gdk-pixbuf/gdk-pixbuf.h>
99 #include <glib.h>
100 #include <string.h>
101 #include <GLES2/gl2.h>
102@@ -40,11 +36,12 @@
103 #include <glm/gtc/matrix_transform.hpp>
104 #include <glm/gtc/type_ptr.hpp>
105
106-#include "wallpaper.h"
107 #include "logo.h"
108 #include "white_dot.h"
109 #include "orange_dot.h"
110
111+#define WALLPAPER_FILE "/usr/share/backgrounds/warty-final-ubuntu.png"
112+
113 enum TextureIds {
114 WALLPAPER = 0,
115 LOGO,
116@@ -158,6 +155,13 @@
117 #define BLACK 0.0f, 0.0f, 0.0f
118 //#define WHITE 1.0f, 1.0f, 1.0f
119
120+static struct {
121+ unsigned int width = 0;
122+ unsigned int height = 0;
123+ unsigned int bytes_per_pixel = 3; /* 3:RGB, 4:RGBA */
124+ unsigned char *pixel_data = nullptr;
125+} wallpaper;
126+
127 template <typename Image>
128 void uploadTexture (GLuint id, Image& image)
129 {
130@@ -300,6 +304,19 @@
131
132 SessionConfig session_config;
133
134+ // Load wallpaper
135+ GError *error = nullptr;
136+ auto wallpaperPixbuf = gdk_pixbuf_new_from_file(WALLPAPER_FILE, &error);
137+ if (wallpaperPixbuf) {
138+ wallpaper.width = gdk_pixbuf_get_width(wallpaperPixbuf);
139+ wallpaper.height = gdk_pixbuf_get_height(wallpaperPixbuf);
140+ wallpaper.bytes_per_pixel = gdk_pixbuf_get_has_alpha(wallpaperPixbuf) ? 4 : 3;
141+ wallpaper.pixel_data = (unsigned char*)gdk_pixbuf_read_pixels(wallpaperPixbuf);
142+ } else {
143+ printf("Could not load wallpaper: %s\n", error->message);
144+ }
145+ g_clear_error(&error);
146+
147 auto const surfaces = mir_eglapp_init(argc, argv);
148
149 if (!surfaces.size())
150@@ -430,6 +447,16 @@
151 mvpMatrix = glm::translate(mvpMatrix, glm::vec3(-1.0, -1.0, 0.0f));
152 mvpMatrix = glm::scale(mvpMatrix,
153 glm::vec3(2.0f / render_width, 2.0f / render_height, 1.0f));
154+
155+ auto widthRatio = (1.0f * wallpaper.height * render_width) / (wallpaper.width * render_height);
156+ auto heightRatio = 1.0f;
157+ if (widthRatio > 1.0f) {
158+ heightRatio = 1.0f / widthRatio;
159+ widthRatio = 1.0f;
160+ }
161+ auto const wallpaperProjMatrix = glm::ortho(-widthRatio, widthRatio, heightRatio, -heightRatio, -1.0f, 1.0f);
162+ auto wallpaperMatrix = wallpaperProjMatrix * mvpMatrix;
163+
164 auto const projMatrix = glm::ortho(-1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f);
165 mvpMatrix = projMatrix * mvpMatrix;
166
167@@ -444,7 +471,7 @@
168 glBindTexture(GL_TEXTURE_2D, texture[WALLPAPER]);
169 glUniform1i(sampler[WALLPAPER], 0);
170 glUniform2f(offset[WALLPAPER], 0.0f, 0.0f);
171- glUniformMatrix4fv(projMat[WALLPAPER], 1, GL_FALSE, glm::value_ptr(mvpMatrix));
172+ glUniformMatrix4fv(projMat[WALLPAPER], 1, GL_FALSE, glm::value_ptr(wallpaperMatrix));
173 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
174
175 // draw logo
176
177=== removed file 'spinner/wallpaper.png'
178Binary files spinner/wallpaper.png 2015-08-27 15:25:37 +0000 and spinner/wallpaper.png 1970-01-01 00:00:00 +0000 differ

Subscribers

People subscribed via source and target branches