equal
deleted
inserted
replaced
56 system memory (RAM). When this signal is emitted, all entities, that have |
56 system memory (RAM). When this signal is emitted, all entities, that have |
57 anything to do with graphics memory, are expected to perform as much cleanup |
57 anything to do with graphics memory, are expected to perform as much cleanup |
58 as possible in order to increase the amount of free graphics memory. |
58 as possible in order to increase the amount of free graphics memory. |
59 */ |
59 */ |
60 |
60 |
|
61 static bool oogmWatcherDeleted = false; |
|
62 |
61 /*! |
63 /*! |
62 Returns the global HbOogmWatcher instance. |
64 Returns the global HbOogmWatcher instance. |
63 */ |
65 */ |
64 HbOogmWatcher *HbOogmWatcher::instance() |
66 HbOogmWatcher *HbOogmWatcher::instance() |
65 { |
67 { |
|
68 if (oogmWatcherDeleted) { |
|
69 return 0; |
|
70 } |
66 static HbOogmWatcher *watcher = new HbOogmWatcher(qApp); |
71 static HbOogmWatcher *watcher = new HbOogmWatcher(qApp); |
67 return watcher; |
72 return watcher; |
68 } |
73 } |
69 |
74 |
70 HbOogmWatcher::HbOogmWatcher(QObject *parent) |
75 HbOogmWatcher::HbOogmWatcher(QObject *parent) |
71 : QObject(parent), d_ptr(new HbOogmWatcherPrivate) |
76 : QObject(parent), d_ptr(new HbOogmWatcherPrivate) |
72 { |
77 { |
73 Q_D(HbOogmWatcher); |
78 Q_D(HbOogmWatcher); |
74 d->q_ptr = this; |
79 d->q_ptr = this; |
76 } |
81 } |
77 |
82 |
78 HbOogmWatcher::~HbOogmWatcher() |
83 HbOogmWatcher::~HbOogmWatcher() |
79 { |
84 { |
80 delete d_ptr; |
85 delete d_ptr; |
|
86 oogmWatcherDeleted = true; |
81 } |
87 } |
82 |
88 |
83 /*! |
89 /*! |
84 Forces the graphics-memory-low notifications to be sent. |
90 Forces the graphics-memory-low notifications to be sent. |
85 Useful for forcing icons to perform some cleanup, for example. |
91 Useful for forcing icons to perform some cleanup, for example. |
94 \internal |
100 \internal |
95 */ |
101 */ |
96 void HbOogmWatcherPrivate::graphicsMemoryLow() |
102 void HbOogmWatcherPrivate::graphicsMemoryLow() |
97 { |
103 { |
98 qWarning("HbOogmWatcher::graphicsMemoryLow()"); |
104 qWarning("HbOogmWatcher::graphicsMemoryLow()"); |
99 if (mRenderMode == EHWRendering) { |
105 if (mRenderMode == EHWRendering) { |
100 mRenderMode = ESWRendering; |
106 mRenderMode = ESWRendering; |
101 HbIconLoader::global()->switchRenderingMode(mRenderMode); |
107 HbIconLoader::global()->switchRenderingMode(mRenderMode); |
102 } |
108 } |
103 #ifdef HB_EFFECTS_OPENVG |
109 #ifdef HB_EFFECTS_OPENVG |
104 // Destroy the cached pixmaps of effects. This is also necessary |
110 // Destroy the cached pixmaps of effects. This is also necessary |
105 // to make the OpenVG filter effect caching working properly. (if |
111 // to make the OpenVG filter effect caching working properly. (if |
106 // Qt would free the pixmaps' underlying VGImage when graphics |
112 // Qt would free the pixmaps' underlying VGImage when graphics |
107 // memory is low then that would render the filter effects' cached |
113 // memory is low then that would render the filter effects' cached |
109 HbVgEffect::releaseCachedResources(); |
115 HbVgEffect::releaseCachedResources(); |
110 #endif |
116 #endif |
111 // Drop the underlying pixmap data (if possible) for all HbIconItems that |
117 // Drop the underlying pixmap data (if possible) for all HbIconItems that |
112 // are not currently visible. |
118 // are not currently visible. |
113 int n = 0; |
119 int n = 0; |
114 foreach (HbIconItem *iconItem, mIconItems) { |
120 foreach(HbIconItem * iconItem, mIconItems) { |
115 if (!iconItem->isVisible()) { |
121 if (!iconItem->isVisible()) { |
116 HbIconItemPrivate::d_ptr(iconItem)->clearStoredIconContent(); |
122 HbIconItemPrivate::d_ptr(iconItem)->clearStoredIconContent(); |
117 ++n; |
123 ++n; |
118 } |
124 } |
119 } |
125 } |
125 \internal |
131 \internal |
126 */ |
132 */ |
127 void HbOogmWatcherPrivate::graphicsMemoryGood() |
133 void HbOogmWatcherPrivate::graphicsMemoryGood() |
128 { |
134 { |
129 qWarning("HbOogmWatcher::graphicsMemoryGood()"); |
135 qWarning("HbOogmWatcher::graphicsMemoryGood()"); |
130 if (mRenderMode == ESWRendering) { |
136 if (mRenderMode == ESWRendering) { |
131 mRenderMode = EHWRendering; |
137 mRenderMode = EHWRendering; |
132 HbIconLoader::global()->switchRenderingMode(mRenderMode); |
138 HbIconLoader::global()->switchRenderingMode(mRenderMode); |
133 } |
139 } |
134 emit q_ptr->graphicsMemoryGood(); |
140 emit q_ptr->graphicsMemoryGood(); |
135 } |
141 } |
136 |
142 |
137 /*! Registers an HbIconItem instance. Whenever graphics memory is |
143 /*! Registers an HbIconItem instance. Whenever graphics memory is |
138 low, the registered iconitems will be examined and the ones that are |
144 low, the registered iconitems will be examined and the ones that are |