~robertcarr/unity/rightalign-filter

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/QuicklistView.cpp

  • Committer: Neil Jagdish Patel
  • Author(s): Tim Penhey
  • Date: 2011-09-05 14:57:56 UTC
  • mfrom: (1468.2.14 texture-from-bitmap)
  • Revision ID: neil.patel@canonical.com-20110905145756-m5vnc7jumubxtp04
I noticed that quite a few of the memory leaks were do to
making a texture from a CairoGraphics object. Instead of having
to remember at all the call sites, I've created a couple of helper
methods.

I had to control myself a lot during this change to not change too
many other things at once. Sometimes I couldn't help myself though.

In particular I changed the TextureContainer to use smart pointers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "Nux/TextureArea.h"
30
30
#include "NuxImage/CairoGraphics.h"
31
31
 
 
32
#include "CairoTexture.h"
 
33
 
32
34
#include "QuicklistView.h"
33
35
#include "QuicklistMenuItem.h"
34
36
#include "QuicklistMenuItemLabel.h"
48
50
#define NUX_KP_LEFT  0xFF96
49
51
#define NUX_KP_RIGHT 0xFF98
50
52
 
 
53
using unity::texture_from_cairo_graphics;
 
54
 
51
55
NUX_IMPLEMENT_OBJECT_TYPE(QuicklistView);
52
56
 
53
57
QuicklistView::QuicklistView()
1454
1458
  cairo_destroy(cr_outline);
1455
1459
  cairo_destroy(cr_mask);
1456
1460
 
1457
 
  nux::NBitmapData* bitmap = cairo_bg->GetBitmap();
1458
 
 
1459
1461
  if (_texture_bg)
1460
1462
    _texture_bg->UnReference();
1461
 
  _texture_bg = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
1462
 
  _texture_bg->Update(bitmap);
1463
 
  delete bitmap;
 
1463
  _texture_bg = texture_from_cairo_graphics(*cairo_bg);
1464
1464
 
1465
 
  bitmap = cairo_mask->GetBitmap();
1466
1465
  if (_texture_mask)
1467
1466
    _texture_mask->UnReference();
1468
 
  _texture_mask = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
1469
 
  _texture_mask->Update(bitmap);
1470
 
  delete bitmap;
 
1467
  _texture_mask = texture_from_cairo_graphics(*cairo_mask);
1471
1468
 
1472
 
  bitmap = cairo_outline->GetBitmap();
1473
1469
  if (_texture_outline)
1474
1470
    _texture_outline->UnReference();
1475
 
  _texture_outline = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
1476
 
  _texture_outline->Update(bitmap);
1477
 
  delete bitmap;
 
1471
  _texture_outline = texture_from_cairo_graphics(*cairo_outline);
1478
1472
 
1479
1473
  delete cairo_bg;
1480
1474
  delete cairo_mask;