diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-12-18 15:35:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-12-18 17:39:01 +0100 |
commit | 9e5cbcf90f15f46f84900a58bcaee437b98587f6 (patch) | |
tree | b09a713114097908c9025e22437e39e71a8a045e /vcl | |
parent | 80deb9f71f29d76183f256afb92d3201998f14be (diff) |
load images by explicit type
speed ups dialog load time a little (10%)
Change-Id: Id64c50c27ffc5971049313a3b9105e4e36fc0b69
Reviewed-on: https://gerrit.libreoffice.org/85388
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index c75eb8b68858..71022de91bd6 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2892,9 +2892,15 @@ namespace namespace { - GdkPixbuf* load_icon_from_stream(SvMemoryStream& rStream) + GdkPixbuf* load_icon_from_stream(SvMemoryStream& rStream, const char* image_type) { - GdkPixbufLoader *pixbuf_loader = gdk_pixbuf_loader_new(); + // if we know the image type, it's a little faster to hand the type over and skip the type + // detection. + GdkPixbufLoader *pixbuf_loader; + if (image_type != nullptr) + pixbuf_loader = gdk_pixbuf_loader_new_with_type(image_type, nullptr); + else + pixbuf_loader = gdk_pixbuf_loader_new(); gdk_pixbuf_loader_write(pixbuf_loader, static_cast<const guchar*>(rStream.GetData()), rStream.TellEnd(), nullptr); gdk_pixbuf_loader_close(pixbuf_loader, nullptr); @@ -2910,7 +2916,8 @@ namespace auto xMemStm = ImageTree::get().getImageStream(rIconName, rIconTheme, rUILang); if (!xMemStm) return nullptr; - return load_icon_from_stream(*xMemStm); + OUString sImageType = rIconName.copy(rIconName.lastIndexOf('.')+1).toAsciiLowerCase(); + return load_icon_from_stream(*xMemStm, sImageType.toUtf8().getStr()); } } @@ -2941,7 +2948,7 @@ namespace vcl::PNGWriter aWriter(aImage.GetBitmapEx(), &aFilterData); aWriter.Write(*xMemStm); - return load_icon_from_stream(*xMemStm); + return load_icon_from_stream(*xMemStm, nullptr); } GdkPixbuf* getPixbuf(const VirtualDevice& rDevice) |