Merge lp:~3v1n0/unity/fix-scaling-not-squared-icons 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: 4022
Proposed branch: lp:~3v1n0/unity/fix-scaling-not-squared-icons
Merge into: lp:unity
Diff against target: 59 lines (+6/-11)
2 files modified
dash/ResultRendererTile.cpp (+5/-10)
dash/ResultRendererTile.h (+1/-1)
To merge this branch: bzr merge lp:~3v1n0/unity/fix-scaling-not-squared-icons
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+273312@code.launchpad.net

Commit message

ResultRendererTile: consider global scaling when scaling a not-squared icon

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 'dash/ResultRendererTile.cpp'
2--- dash/ResultRendererTile.cpp 2014-07-09 11:17:35 +0000
3+++ dash/ResultRendererTile.cpp 2015-10-03 01:27:44 +0000
4@@ -290,7 +290,7 @@
5 if (icon.IsType(G_TYPE_ICON))
6 {
7 bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON);
8- container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name,
9+ container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name,
10 tile_size,
11 use_large_icon ?
12 tile_size : tile_gsize, slot);
13@@ -326,7 +326,7 @@
14 {
15 // slow path for non square icons that must be resized to fit in the square
16 // texture
17- float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
18+ double aspect = static_cast<double>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0
19 if (aspect < 1.0f)
20 {
21 pixbuf_width = Style::Instance().GetTileImageSize().CP(scale);
22@@ -358,13 +358,8 @@
23 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
24 cairo_paint(cr);
25
26- float scale = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf);
27-
28- //cairo_translate(cr,
29- // static_cast<int>((width - (pixbuf_width * scale)) * 0.5),
30- // static_cast<int>((height - (pixbuf_height * scale)) * 0.5));
31-
32- cairo_scale(cr, scale, scale);
33+ double pixmap_scale = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf) / scale();
34+ cairo_scale(cr, pixmap_scale, pixmap_scale);
35
36 cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
37 gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
38@@ -378,7 +373,7 @@
39 int max_width,
40 int max_height,
41 glib::Object<GdkPixbuf> const& pixbuf,
42- std::string icon_name,
43+ std::string const& icon_name,
44 Result const& row)
45 {
46 TextureContainer *container = row.renderer<TextureContainer*>();
47
48=== modified file 'dash/ResultRendererTile.h'
49--- dash/ResultRendererTile.h 2014-03-20 04:05:39 +0000
50+++ dash/ResultRendererTile.h 2015-10-03 01:27:44 +0000
51@@ -87,7 +87,7 @@
52 //icon loading callbacks
53 void IconLoaded(std::string const& texid, int max_width, int max_height,
54 glib::Object<GdkPixbuf> const& pixbuf,
55- std::string icon_name, Result const& row);
56+ std::string const& icon_name, Result const& row);
57 nux::BaseTexture* CreateTextureCallback(std::string const& texid,
58 int width, int height,
59 glib::Object<GdkPixbuf> const& pixbuf);