--- a/src/hbcore/core/hbsharedcache.cpp Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbcore/core/hbsharedcache.cpp Wed Aug 18 10:05:37 2010 +0300
@@ -23,6 +23,11 @@
**
****************************************************************************/
+#include "hbsharedcache_p.h"
+#include "hbsharedmemorymanager_p.h"
+#ifdef HB_BIN_CSS
+#include "hbcssconverterutils_p.h"
+#endif
#include <QSystemSemaphore>
static QSystemSemaphore *Semaphore = 0;
@@ -34,13 +39,6 @@
static const QString WidgetMLFileExtension = ".widgetml";
static const QChar KeySeparator('\0');
-#include "hbsharedcache_p.h"
-#include "hbsharedmemorymanager_p.h"
-
-#ifdef HB_BIN_CSS
-#include "hbcssconverterutils_p.h"
-#endif
-
/*!
Helper class for locking the cache.
*/
@@ -93,7 +91,7 @@
doesn't check, if the item is already in the cache.
*/
-bool HbSharedCache::add(ItemType itemType, const QString &key, int offset)
+bool HbSharedCache::add(ItemType itemType, const QString &key, qptrdiff offset)
{
bool added = false;
if (offset >= 0) {
@@ -127,7 +125,7 @@
bool HbSharedCache::addLayoutDefinition(const QString &filePath,
const QString &layout,
const QString §ion,
- int offset)
+ qptrdiff offset)
{
return add(LayoutDefinition, layoutDefinitionKey(filePath, layout, section), offset);
}
@@ -137,11 +135,11 @@
Only acceptable separator for filePath is '/'.
*/
-int HbSharedCache::layoutDefinitionOffset(const QString &filePath,
+qptrdiff HbSharedCache::layoutDefinitionOffset(const QString &filePath,
const QString &layout,
const QString §ion) const
{
- int offset = -1;
+ qptrdiff offset = -1;
int position = 0;
int length = filePath.length();
if (filePath.at(0) == ':') {
@@ -163,7 +161,7 @@
#ifdef CSSBIN_TRACES
qDebug() << "Offset item found from static cache map for widget: " << widgetname;
#endif
- int tableSize = 0;
+ qint32 tableSize = 0;
const HbLayoutIndexItem *begin = layoutIndexItemBegin(
offsetItem->offsetLayoutIndexTable, &tableSize);
if (begin) {
@@ -200,9 +198,9 @@
Only acceptable separator for key is '/'.
*/
-int HbSharedCache::offset(ItemType itemType, const QString &key) const
+qptrdiff HbSharedCache::offset(ItemType itemType, const QString &key) const
{
- int offset = -1;
+ qptrdiff offset = -1;
int position = 0;
int length = key.length();
if (key.at(0) == ':') {
@@ -271,41 +269,64 @@
return remove(LayoutDefinition, layoutDefinitionKey(filePath, layout, section));
}
+HbLayoutParametersPrivate *HbSharedCache::layoutParameters() const
+{
+ HbLayoutParametersPrivate *parameters = 0;
+ qint32 size = 0;
+ const HbParameterItem *begin = parameterItemBegin(&size);
+ if (size > 0) {
+ GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory);
+ parameters = new HbLayoutParametersPrivate(begin, size,
+ static_cast<const char*>(manager->base()), reinterpret_cast<const char*>(begin));
+ }
+ return parameters;
+}
+
/*!
add static offset map.
*/
-void HbSharedCache::addOffsetMap(const char *offsetMapData, int size, int offsetItemCount)
+void HbSharedCache::setContent(const char *dataArray, int size,
+ int offsetItemCount, int globalParametersOffset)
{
- if (offsetMapData) {
- memcpy(mOffsetItems, offsetMapData, size);
+ if (dataArray) {
+ memcpy(mOffsetItems, dataArray, size);
mOffsetItemCount = offsetItemCount;
+ mGlobalParameterOffset = globalParametersOffset;
#ifdef HB_BIN_CSS
for (int i = 0; i < offsetItemCount; ++i) {
HbCssConverterUtils::registerOffsetHolder(&(mOffsetItems[i].offsetCSS));
HbCssConverterUtils::registerOffsetHolder(&(mOffsetItems[i].offsetColorCSS));
- int size = 0;
+ qint32 size = 0;
HbLayoutIndexItem *layoutItem = layoutIndexItemBegin(
mOffsetItems[i].offsetLayoutIndexTable, &size);
for(;size > 0; --size, ++layoutItem) {
HbCssConverterUtils::registerOffsetHolder(&(layoutItem->offset));
}
}
+ int size = 0;
+ HbParameterItem *parameterItem = parameterItemBegin(&size);
+ for (;size > 0; --size, ++parameterItem) {
+ HbCssConverterUtils::registerOffsetHolder(&(parameterItem->valueOffset));
+ }
#endif
} else {
mOffsetItemCount = 0;
+ mGlobalParameterOffset = -1;
}
}
HbSharedCache::HbSharedCache()
: mLayoutDefCache(HbMemoryManager::SharedMemory),
mStylesheetCache(HbMemoryManager::SharedMemory),
- mEffectCache(HbMemoryManager::SharedMemory)
+ mEffectCache(HbMemoryManager::SharedMemory),
+ mGlobalParameterOffset(-1),
+ mOffsetItemCount(0)
{
}
-int HbSharedCache::findOffsetFromDynamicMap(ItemType itemType, const QStringRef &key) const
+qptrdiff HbSharedCache::findOffsetFromDynamicMap(ItemType itemType, const QStringRef &key) const
{
- int offset = -1;
+ qptrdiff offset = -1;
const HbVector<CacheItem> &cacheVector = itemCache(itemType);
HbCacheLocker locker(*Semaphore);
Q_FOREACH(const CacheItem &item, cacheVector) {
@@ -321,14 +342,14 @@
return the first layoutindextitem and size in offset \a offset.
\a offset is a value in HbOffsetItem::offsetLayoutIndexTable.
*/
-HbLayoutIndexItem *HbSharedCache::layoutIndexItemBegin(int offset, int *size)
+HbLayoutIndexItem *HbSharedCache::layoutIndexItemBegin(qptrdiff offset, qint32 *size)
{
HbLayoutIndexItem *begin = 0;
*size = 0;
if (offset >= 0) {
void *layoutIndexBase = mOffsetItems;
- int *sizePtr = reinterpret_cast<int *>(
- static_cast<char *>(layoutIndexBase) + offset);
+ qint32 *sizePtr = reinterpret_cast<qint32 *>(
+ static_cast<char *>(layoutIndexBase) + offset);
*size = *sizePtr;
begin = reinterpret_cast<HbLayoutIndexItem *>(sizePtr + 1);
}
@@ -355,6 +376,20 @@
return key;
}
+HbParameterItem *HbSharedCache::parameterItemBegin(qint32 *size)
+{
+ HbParameterItem *item = 0;
+ *size = 0;
+ if (mGlobalParameterOffset >= 0) {
+ void *parameterIndexBase = mOffsetItems;
+ qint32 *sizePtr = reinterpret_cast<qint32 *>(
+ static_cast<char *>(parameterIndexBase) + mGlobalParameterOffset) - 1;
+ *size = *sizePtr;
+ item = reinterpret_cast<HbParameterItem*>(sizePtr + 1);
+ }
+ return item;
+}
+
void HbSharedCache::freeResources()
{
delete Semaphore;