After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 643866 - images gets stretched in search results
images gets stretched in search results
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-03-04 12:47 UTC by Andreas Nilsson
Modified: 2011-03-22 18:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot of the issue (580.48 KB, image/png)
2011-03-04 12:47 UTC, Andreas Nilsson
  Details
st-texture-cache: Fix stretched images (4.34 KB, patch)
2011-03-22 04:10 UTC, Florian Müllner
none Details | Review
st-texture-cache: Fix stretched images (4.64 KB, patch)
2011-03-22 15:11 UTC, Florian Müllner
needs-work Details | Review
st-texture-cache: Fix stretched images (5.96 KB, patch)
2011-03-22 17:52 UTC, Florian Müllner
committed Details | Review

Description Andreas Nilsson 2011-03-04 12:47:14 UTC
Created attachment 182456 [details]
screenshot of the issue

Images that does not have a 1x1 width/height ratio gets stretched in the overview.
Comment 1 Andreas Nilsson 2011-03-04 12:55:39 UTC
btw, that's the toolbar-small images in the search results.
The Miramar (Thunderbird dev version) icon in the dash is probably my fault somehow :)
Comment 2 Florian Müllner 2011-03-04 13:08:36 UTC
Yes, that's a known issue. I located the bug in StTextureCache, where a correctly created Cogl texture is scaled to fit a square ClutterTexture. No fix yet, unfortunately. The patch from bug 642043 might impose a problem too once the texture cache issue is fixed.
Comment 3 Florian Müllner 2011-03-22 04:10:29 UTC
Created attachment 184035 [details] [review]
st-texture-cache: Fix stretched images

Some functions in StTextureCache enforce square textures, even if
the underlying image may have a different width:height ratio. Add
padding in those cases to keep the resulting image from being
stretched.
Comment 4 Florian Müllner 2011-03-22 15:11:43 UTC
Created attachment 184082 [details] [review]
st-texture-cache: Fix stretched images

*grumble*

Clutter start re-using memory after a while, and if we don't set the entire image (which we do when we add padding), the new image ends up being drawn on top of the old one ...

So make sure to clear the entire image before setting the region.
Comment 5 Owen Taylor 2011-03-22 16:32:43 UTC
Review of attachment 184082 [details] [review]:

Works, seems OK as a simple approach that avoids fixing multiple callers.

According to my reading, the result of your patch is:

NO PADDING
==========
st_texture_cache_load_sliced_image
st_texture_cache_bind_pixbuf_property
st_texture_cache_load_uri_sync
st_texture_cache_load_file_to_cogl_texture
st_texture_cache_load_file_to_cairo_surface
st_texture_cache_load_file_simple
st_texture_cache_load_from_raw

PADDING
=======
st_texture_cache_load_icon_name
st_texture_cache_load_gicon
st_texture_cache_load_thumbnail
st_texture_cache_load_recent_thumbnail
st_texture_cache_load_from_data

BOTH
====
st_texture_cache_load_uri_async [pads iff available_width == available_height]

* Ones that pad should have a note in their docs that the result will be padded to be square
* Last is IMO wrong - doesn't make sense. Either it should always pad to the aspect ratio of available_width/height or never pad. Never pad would be consistent with an interpretation that only functions passed a single size parameter pad
* Commit message is weird because:
    Some functions in StTextureCache enforce square textures
  The functions didn't  before, but now they do

::: src/st/st-texture-cache.c
@@ +801,3 @@
+  size = MAX (width, height);
+
+  if (!add_padding)

Should definitely add a '|| width == height - clear' isn't free and most of the icons we load will be square

@@ +820,3 @@
+  cogl_pop_framebuffer ();
+  cogl_handle_unref (offscreen);
+

It's may be cheaper to set_region() the region above/below or right/left to avoid swapping between cpu/gpu access, but on the other hand, in an atlas'ed texture the atlas texture is likely already mapped for the GPU, and anyways, this is less code, so OK.
Comment 6 Florian Müllner 2011-03-22 17:30:44 UTC
(In reply to comment #5)
> * Ones that pad should have a note in their docs that the result will be padded
> to be square

Is that necessary? The functions under PADDING all take a single size parameter, so padding is what I'd expect rather than stretching the image to a size x size square


> * Last is IMO wrong - doesn't make sense. Either it should always pad to the
> aspect ratio of available_width/height or never pad. Never pad would be
> consistent with an interpretation that only functions passed a single size
> parameter pad

I agree, but as it is using the same internal code path as the functions under PADDING it's a bit tricky. I now figured that a possible check which covers all uses of on_pixbuf_loaded from functions with size parameter but not st_texture_cache_load_uri_async is:

data->uri == NULL || data->thumbnail

That's horribly obscure and easy to break by future additions, so I'd rather add an additional member to AsyncTextureLoadData - is_square maybe?


> * Commit message is weird because:
>     Some functions in StTextureCache enforce square textures
>   The functions didn't  before, but now they do

IMO they did - they call clutter_actor_set_size (texture, size, size); the underlying CoglTexture may not be square, but the ClutterTexture certainly is.


> ::: src/st/st-texture-cache.c
> Should definitely add a '|| width == height - clear' isn't free and most of the
> icons we load will be square

Took me a while to parse, but yeah, will do that.
Comment 7 Florian Müllner 2011-03-22 17:52:10 UTC
Created attachment 184103 [details] [review]
st-texture-cache: Fix stretched images

(In reply to comment #6)
> (In reply to comment #5)
> > * Ones that pad should have a note in their docs that the result will be padded
> > to be square

I didn't change this. With this patch version, only functions with a single size parameter get padding.


> data->uri == NULL || data->thumbnail
> 
> That's horribly obscure and easy to break by future additions, so I'd rather
> add an additional member to AsyncTextureLoadData - is_square maybe?

I went with enforced_square - still not entirely happy, I'm open for better suggestions.


> > * Commit message is weird because:
> >     Some functions in StTextureCache enforce square textures
> >   The functions didn't  before, but now they do
> 
> IMO they did - they call clutter_actor_set_size (texture, size, size); the
> underlying CoglTexture may not be square, but the ClutterTexture certainly is.

I tried to clear that up by replacing "textures" with "ClutterTextures" and "underlying image" with "underlying CoglTexture".


> > ::: src/st/st-texture-cache.c
> > Should definitely add a '|| width == height - clear' isn't free and most of the
> > icons we load will be square

Done.
Comment 8 Owen Taylor 2011-03-22 18:21:32 UTC
(In reply to comment #6)
> (In reply to comment #5)
> > * Ones that pad should have a note in their docs that the result will be padded
> > to be square
> 
> Is that necessary? The functions under PADDING all take a single size
> parameter, so padding is what I'd expect rather than stretching the image to a
> size x size square

Hmm, didn't notice that we did clutter_actor_set_size(texturem size, size) - verified we do that for all ones taking a size parameter.
 
> > * Last is IMO wrong - doesn't make sense. Either it should always pad to the
> > aspect ratio of available_width/height or never pad. Never pad would be
> > consistent with an interpretation that only functions passed a single size
> > parameter pad
> 
> I agree, but as it is using the same internal code path as the functions under
> PADDING it's a bit tricky. I now figured that a possible check which covers all
> uses of on_pixbuf_loaded from functions with size parameter but not
> st_texture_cache_load_uri_async is:
> 
> data->uri == NULL || data->thumbnail
> 
> That's horribly obscure and easy to break by future additions, so I'd rather
> add an additional member to AsyncTextureLoadData - is_square maybe?
 
enforced_square is fine, it's not like it's exposed.
 
> > * Commit message is weird because:
> >     Some functions in StTextureCache enforce square textures
> >   The functions didn't  before, but now they do
> 
> IMO they did - they call clutter_actor_set_size (texture, size, size); the
> underlying CoglTexture may not be square, but the ClutterTexture certainly is.

Yeah, your current commit message looks fine.

> > ::: src/st/st-texture-cache.c
> > Should definitely add a '|| width == height - clear' isn't free and most of the
> > icons we load will be square
> 
> Took me a while to parse, but yeah, will do that.

Would help if I added the quotes in the right place.
Comment 9 Owen Taylor 2011-03-22 18:23:31 UTC
Review of attachment 184103 [details] [review]:

Looks good
Comment 10 Florian Müllner 2011-03-22 18:36:29 UTC
Attachment 184103 [details] pushed as 4208078 - st-texture-cache: Fix stretched images