From kde-commits Mon Jan 31 23:24:52 2011 From: Hugo Pereira Da Costa Date: Mon, 31 Jan 2011 23:24:52 +0000 To: kde-commits Subject: =?utf-8?q?=5Boxygen-gtk/1=2E0=5D_src=3A_Use_roundSlabFocusedCach?= Message-Id: <20110131232452.CDFE2A609B () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129651632305272 Git commit ac828dc29e77054766bbaa4981fc5860d02b6386 by Hugo Pereira Da Costa. Pushed by hpereiradacosta into branch '1.0'. Use roundSlabFocusedCache for hovered radio buttons M +9 -5 src/oxygenstylehelper.cpp http://commits.kde.org/oxygen-gtk/ac828dc29e77054766bbaa4981fc5860d02b6386 diff --git a/src/oxygenstylehelper.cpp b/src/oxygenstylehelper.cpp index 1429802..a749a91 100644 --- a/src/oxygenstylehelper.cpp +++ b/src/oxygenstylehelper.cpp @@ -437,13 +437,16 @@ namespace Oxygen GdkPixbuf* StyleHelper::roundSlabFocused(const ColorUtils::Rgba& base, const ColorUtils::Rgba& glow, double shade, int size) { - const int w( 3*size ); - const int h( 3*size ); - GdkPixbuf* pixbuf( gdk_pixbuf_new( GDK_COLORSPACE_RGB, true, 8, w, h ) ); - gdk_pixbuf_fill( pixbuf, ColorUtils::Rgba::transparent( base ).toInt() ); - + SlabFocusedKey key( base, glow, shade, size ); + GdkPixbuf* pixbuf( m_roundSlabFocusedCache.value( key ) ); + if( !pixbuf ) { + const int w( 3*size ); + const int h( 3*size ); + pixbuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB, true, 8, w, h ); + gdk_pixbuf_fill( pixbuf, ColorUtils::Rgba::transparent( base ).toInt() ); + // create cairo context Cairo::Context context( pixbuf ); cairo_scale( context, double(size)/7, double(size)/7 ); @@ -454,6 +457,7 @@ namespace Oxygen if( base.isValid() ) drawRoundSlab( context, base, shade ); context.updateGdkPixbuf(); + m_roundSlabFocusedCache.insert( key, pixbuf ); }