Merge lp:~mhr3/unity/fix-scale-inversion into lp:unity

Proposed by Michal Hruby
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 2341
Proposed branch: lp:~mhr3/unity/fix-scale-inversion
Merge into: lp:unity
Diff against target: 32 lines (+7/-2)
1 file modified
plugins/unityshell/src/ResultRendererTile.cpp (+7/-2)
To merge this branch: bzr merge lp:~mhr3/unity/fix-scale-inversion
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+103455@code.launchpad.net

Commit message

Fix scale inversion when processing non-rect tile textures

Description of the change

There were issues where non-rectangular icons were sometimes cropped, or were too small.

Fix inverted scale when adapting the size of non-rectangular tile textures.

No new tests, trivial change.

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

seems good, but we should link to a bug somewhere

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/ResultRendererTile.cpp'
2--- plugins/unityshell/src/ResultRendererTile.cpp 2012-04-19 11:26:26 +0000
3+++ plugins/unityshell/src/ResultRendererTile.cpp 2012-04-25 12:14:18 +0000
4@@ -323,7 +323,6 @@
5 pixbuf_width = style.GetTileWidth() - (padding * 2);
6 pixbuf_height = pixbuf_width * aspect;
7
8-
9 if (pixbuf_height > height)
10 {
11 // scaled too big, scale down
12@@ -337,13 +336,19 @@
13 pixbuf_width = pixbuf_height / aspect;
14 }
15
16+ if (gdk_pixbuf_get_height(pixbuf) == pixbuf_height)
17+ {
18+ // we changed our mind, fast path is good
19+ return nux::CreateTexture2DFromPixbuf(pixbuf, true);
20+ }
21+
22 nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, pixbuf_width, pixbuf_height);
23 cairo_t* cr = cairo_graphics.GetInternalContext();
24
25 cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
26 cairo_paint(cr);
27
28- float scale = gdk_pixbuf_get_height(pixbuf) / float(pixbuf_height);
29+ float scale = float(pixbuf_height) / gdk_pixbuf_get_height(pixbuf);
30
31 //cairo_translate(cr,
32 // static_cast<int>((width - (pixbuf_width * scale)) * 0.5),