summaryrefslogtreecommitdiff
diff options
authorJason Smith <jason.smith@canonical.com>2012-02-08 20:57:24 -0500
committerTarmac <>2012-02-08 20:57:24 -0500
commitbe016f6f6155c603f200a7aa2acfd4251166ecb9 (patch)
tree819624a0f2bc9e8bc7991a9d26a85f5590ada9f7
parent3a21128cdd55a604bbeab49374d6743065654da7 (diff)
parent15f9c6da5607024b8c47cc83b7b3d7f27527044a (diff)
. Fixes: . Approved by Tim Penhey.
(bzr r1937)
-rw-r--r--plugins/unityshell/src/Launcher.cpp61
-rw-r--r--plugins/unityshell/src/unityshell.cpp10
2 files changed, 37 insertions, 34 deletions
diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp
index 22a44d6f7..b1bc213b8 100644
--- a/plugins/unityshell/src/Launcher.cpp
+++ b/plugins/unityshell/src/Launcher.cpp
@@ -43,6 +43,8 @@
#include "QuicklistView.h"
#include "IconRenderer.h"
#include "TimeUtil.h"
+#include "TextureCache.h"
+#include "IconLoader.h"
#include "WindowManager.h"
#include "UScreen.h"
@@ -52,6 +54,22 @@
#include <UnityCore/GLibWrapper.h>
#include <UnityCore/Variant.h>
+#include <type_traits>
+#include <sigc++/sigc++.h>
+
+namespace sigc
+{
+template <typename Functor>
+struct functor_trait<Functor, false>
+{
+typedef decltype (::sigc::mem_fun (std::declval<Functor&> (),
+&Functor::operator())) _intermediate;
+
+typedef typename _intermediate::result_type result_type;
+typedef Functor functor_type;
+};
+}
+
namespace unity
{
using ui::RenderArg;
@@ -266,36 +284,23 @@ Launcher::Launcher(nux::BaseWindow* parent,
bg_effect_helper_.owner = this;
bg_effect_helper_.enabled = false;
- //FIXME (gord)- replace with async loading
- unity::glib::Object<GdkPixbuf> pixbuf;
- unity::glib::Error error;
- pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR"/dash_sheen.png", &error);
- if (error)
- {
- LOG_WARN(logger) << "Unable to texture " << PKGDATADIR << "/dash_sheen.png" << ": " << error;
- }
- else
+ TextureCache& cache = TextureCache::GetDefault();
+ TextureCache::CreateTextureCallback cb = [&](std::string const& name, int width, int height) -> nux::BaseTexture*
{
- launcher_sheen_ = nux::CreateTexture2DFromPixbuf(pixbuf, true);
- // TODO: when nux has the ability to create a smart pointer that takes
- // ownership without adding a reference, we can remove the unref here. By
- // unreferencing, the object is solely owned by the smart pointer.
- launcher_sheen_->UnReference();
- }
+ unity::glib::Object<GdkPixbuf> pixbuf;
+ unity::glib::Error error;
- pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR"/launcher_pressure_effect.png", &error);
- if (error)
- {
- LOG_WARN(logger) << "Unable to texture " << PKGDATADIR << "/launcher_pressure_effect.png" << ": " << error;
- }
- else
- {
- launcher_pressure_effect_ = nux::CreateTexture2DFromPixbuf(pixbuf, true);
- // TODO: when nux has the ability to create a smart pointer that takes
- // ownership without adding a reference, we can remove the unref here. By
- // unreferencing, the object is solely owned by the smart pointer.
- launcher_pressure_effect_->UnReference();
- }
+ pixbuf = gdk_pixbuf_new_from_file((PKGDATADIR"/" + name + ".png").c_str(), &error);
+ if (error)
+ LOG_WARN(logger) << "Unable to load texture " << PKGDATADIR"/" << name << ": " << error;
+ else
+ return nux::CreateTexture2DFromPixbuf(pixbuf, true);
+
+ return nullptr;
+ };
+
+ launcher_sheen_ = cache.FindTexture("dash_sheen", 0, 0, cb);
+ launcher_pressure_effect_ = cache.FindTexture("launcher_pressure_effect", 0, 0, cb);
_pointer_barrier = PointerBarrierWrapper::Ptr(new PointerBarrierWrapper());
_pointer_barrier->barrier_event.connect(sigc::mem_fun(this, &Launcher::OnPointerBarrierEvent));
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index cdb2f7d0a..bc2ee10fb 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -1272,17 +1272,15 @@ void UnityScreen::damageNuxRegions()
it != end; ++it)
{
nux::Geometry const& geo = *it;
- nux_damage = CompRegion(geo.x, geo.y, geo.width, geo.height);
- cScreen->damageRegion(nux_damage);
+ nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height);
}
nux::Geometry geo = wt->GetWindowCompositor().GetTooltipMainWindowGeometry();
- nux_damage = CompRegion(geo.x, geo.y, geo.width, geo.height);
- cScreen->damageRegion(nux_damage);
+ nux_damage += CompRegion(geo.x, geo.y, geo.width, geo.height);
geo = lastTooltipArea;
- nux_damage = CompRegion(lastTooltipArea.x, lastTooltipArea.y,
- lastTooltipArea.width, lastTooltipArea.height);
+ nux_damage += CompRegion(lastTooltipArea.x, lastTooltipArea.y,
+ lastTooltipArea.width, lastTooltipArea.height);
cScreen->damageRegion(nux_damage);
wt->ClearDrawList();