UVector& ICUService::getDisplayNames(UVector& result, const Locale& locale, const UnicodeString* matchID, UErrorCode& status) const { result.removeAllElements(); result.setDeleter(userv_deleteStringPair); if (U_SUCCESS(status)) { ICUService* ncthis = (ICUService*)this; // cast away semantic const Mutex mutex(&lock); if (dnCache != NULL && dnCache->locale != locale) { delete dnCache; ncthis->dnCache = NULL; } if (dnCache == NULL) { const Hashtable* m = getVisibleIDMap(status); if (U_FAILURE(status)) { return result; } ncthis->dnCache = new DNCache(locale); if (dnCache == NULL) { status = U_MEMORY_ALLOCATION_ERROR; return result; } int32_t pos = UHASH_FIRST; const UHashElement* entry = NULL; while ((entry = m->nextElement(pos)) != NULL) { const UnicodeString* id = (const UnicodeString*)entry->key.pointer; ICUServiceFactory* f = (ICUServiceFactory*)entry->value.pointer; UnicodeString dname; f->getDisplayName(*id, locale, dname); if (dname.isBogus()) { status = U_MEMORY_ALLOCATION_ERROR; } else { dnCache->cache.put(dname, (void*)id, status); // share pointer with visibleIDMap if (U_SUCCESS(status)) { continue; } } delete dnCache; ncthis->dnCache = NULL; return result; } } } ICUServiceKey* matchKey = createKey(matchID, status); /* To ensure that all elements in the hashtable are iterated, set pos to -1. * nextElement(pos) will skip the position at pos and begin the iteration * at the next position, which in this case will be 0. */ int32_t pos = UHASH_FIRST; const UHashElement *entry = NULL; while ((entry = dnCache->cache.nextElement(pos)) != NULL) { const UnicodeString* id = (const UnicodeString*)entry->value.pointer; if (matchKey != NULL && !matchKey->isFallbackOf(*id)) { continue; } const UnicodeString* dn = (const UnicodeString*)entry->key.pointer; StringPair* sp = StringPair::create(*id, *dn, status); result.addElement(sp, status); if (U_FAILURE(status)) { result.removeAllElements(); break; } } delete matchKey; return result; }
QPixmap QtopiaPicIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) { QString key = createKey(d->filename, size, mode, state, QApplication::palette().color(QPalette::Highlight)); QPixmap pm; // See if we have it in our local cache first. if (QPixmapCache::find(key, pm)) return pm; // Try explicitly added pixmaps if (d->pixmaps) { if (d->pixmaps->contains(key)) return d->pixmaps->value(key); } // Perhaps it has already been stored in the global cache. bool globalCandidate = false; if (size.height() == QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) || size.height() == QApplication::style()->pixelMetric(QStyle::PM_TabBarIconSize) || size.height() == QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize) || size.height() == QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize)) { if (QGlobalPixmapCache::find(key, pm)) { qLog(Resource) << "Icon found in global cache" << d->filename; // Put in local cache because we will probably use again soon. QPixmapCache::insert(key, pm); return pm; } globalCandidate = true; qLog(Resource) << "Icon not found in global cache" << d->filename; } if (!d->loaded) { if (!d->picture) d->picture = new QPicture; if (!d->picture->load(d->filename)) qWarning() << "Cannot load icon" << d->filename; else qLog(Resource) << "loaded pic icon" << d->filename; d->loaded = true; } QImage img(size, QImage::Format_ARGB32_Premultiplied); img.fill(0x00000000); QPainter p(&img); QRectF br = d->picture->boundingRect(); if (br.width() == 0 || br.height() == 0) return QPixmap(); if (br.width() > 0 && br.height() > 0) p.scale(qreal(size.width())/br.width(), qreal(size.height())/br.height()); p.drawPicture(0, 0, *d->picture); p.end(); pm = QPixmap::fromImage(img); QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); if (!generated.isNull()) pm = generated; // We'll only put the standard icon sizes in the global cache because // there's a high likelyhood that they'll be used by others. if (globalCandidate) QGlobalPixmapCache::insert(key, pm); // Still worthwhile putting in the local cache since it is very likely // to be rendered again QPixmapCache::insert(key, pm); return pm; }
QPixmap QtopiaSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) { QString key = createKey(d->filename, size, mode, state); QPixmap pm; // Try explicitly added pixmaps first if (d->pixmaps) { if (d->pixmaps->contains(key)) return d->pixmaps->value(key); } // See if we have it in our local cache first. if (QPixmapCache::find(key, pm)) return pm; // Perhaps it has already been stored in the global cache. bool globalCandidate = false; if (size.height() == QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) || size.height() == QApplication::style()->pixelMetric(QStyle::PM_TabBarIconSize) || size.height() == QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize) || size.height() == QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize)) { if (QGlobalPixmapCache::find(key, pm)) { qLog(Resource) << "Icon found in global cache" << d->filename; return pm; } globalCandidate = true; qLog(Resource) << "Icon not found in global cache" << d->filename; } if (!d->loaded) { if (!d->render) d->render = new QSvgRenderer; d->render->load(d->filename); qLog(Resource) << "loaded svg icon" << d->filename; d->loaded = true; } QImage img(size, QImage::Format_ARGB32_Premultiplied); img.fill(0x00000000); QPainter p(&img); d->render->render(&p); p.end(); pm = QPixmap::fromImage(img); QStyleOption opt(0); opt.palette = QApplication::palette(); QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt); if (!generated.isNull()) pm = generated; // We'll only put the standard icon sizes in the cache because // there's a high likelyhood that they'll be used by others. if (globalCandidate) { if (QGlobalPixmapCache::insert(key, pm)) return pm; } // Still worthwhile putting in the local cache since it is very likely // to be rendered again QPixmapCache::insert(key, pm); return pm; }
MInput::MInput(void) { // ASCII keys char name[2] = {0, 0}; for(int i=65; i<=90; i++) { name[0] = i; createKey(name); } // create touch data for(int i=0; i<10; i++) { m_touches[i] = TouchData(); } // keyboard keys createKey("BACKSPACE"); createKey("TAB"); createKey("ESCAPE"); createKey("SPACE"); createKey("DELETE"); createKey("0"); createKey("1"); createKey("2"); createKey("3"); createKey("4"); createKey("5"); createKey("6"); createKey("7"); createKey("8"); createKey("9"); createKey("ENTER"); createKey("UP"); createKey("DOWN"); createKey("LEFT"); createKey("RIGHT"); createKey("F1"); createKey("F2"); createKey("F3"); createKey("F4"); createKey("F5"); createKey("F6"); createKey("F7"); createKey("F8"); createKey("F9"); createKey("F10"); createKey("F11"); createKey("F12"); createKey("RSHIFT"); createKey("LSHIFT"); createKey("RCONTROL"); createKey("LCONTROL"); createKey("RALT"); createKey("LALT"); // mouse keys createKey("MOUSE_BUTTON1"); createKey("MOUSE_BUTTON2"); createKey("MOUSE_BUTTON3"); // joystick keys createKey("JOY1_BUTTON1"); createKey("JOY1_BUTTON2"); createKey("JOY1_BUTTON3"); createKey("JOY1_BUTTON4"); createKey("JOY1_BUTTON5"); createKey("JOY1_BUTTON6"); createKey("JOY1_BUTTON7"); createKey("JOY1_BUTTON8"); createKey("JOY2_BUTTON1"); createKey("JOY2_BUTTON2"); createKey("JOY2_BUTTON3"); createKey("JOY2_BUTTON4"); createKey("JOY2_BUTTON5"); createKey("JOY2_BUTTON6"); createKey("JOY2_BUTTON7"); createKey("JOY2_BUTTON8"); // axis createAxis("MOUSE_X"); createAxis("MOUSE_Y"); createAxis("MOUSE_WHEEL", 1); createAxis("JOY1_X"); createAxis("JOY1_Y"); createAxis("JOY1_Z"); createAxis("JOY1_R"); createAxis("JOY1_U"); createAxis("JOY1_V"); createAxis("JOY2_X"); createAxis("JOY2_Y"); createAxis("JOY2_Z"); createAxis("JOY2_R"); createAxis("JOY2_U"); createAxis("JOY2_V"); }
bool ZMQPollData::erase(const Variant& entry) { return eraseByKey(createKey(entry)); }
void ObjectRenderer::renderGeometry(Geometry* geom, const glm::mat4& modelMatrix, GameObject* object, RenderList& outList) { for (SubGeometry& subgeom : geom->subgeom) { bool isTransparent = false; Renderer::DrawParameters dp; dp.colour = {255, 255, 255, 255}; dp.count = subgeom.numIndices; dp.start = subgeom.start; dp.textures = {0}; dp.visibility = 1.f; if (object && object->type() == GameObject::Instance) { auto modelinfo = object->getModelInfo<SimpleModelInfo>(); dp.depthWrite = !(modelinfo->flags & SimpleModelInfo::NO_ZBUFFER_WRITE); } if (geom->materials.size() > subgeom.material) { Geometry::Material& mat = geom->materials[subgeom.material]; if (!mat.textures.empty()) { auto tex = mat.textures[0].texture; if (tex) { if (tex->isTransparent()) { isTransparent = true; } dp.textures = {tex->getName()}; } } if ((geom->flags & RW::BSGeometry::ModuleMaterialColor) == RW::BSGeometry::ModuleMaterialColor) { dp.colour = mat.colour; if (object && object->type() == GameObject::Vehicle) { auto vehicle = static_cast<VehicleObject*>(object); if (dp.colour.r == 60 && dp.colour.g == 255 && dp.colour.b == 0) { dp.colour = glm::u8vec4(vehicle->colourPrimary, 255); } else if (dp.colour.r == 255 && dp.colour.g == 0 && dp.colour.b == 175) { dp.colour = glm::u8vec4(vehicle->colourSecondary, 255); } } } dp.visibility = 1.f; if (dp.colour.a < 255) { isTransparent = true; } dp.diffuse = mat.diffuseIntensity; dp.ambient = mat.ambientIntensity; } dp.blend = isTransparent; glm::vec3 position(modelMatrix[3]); float distance = glm::length(m_camera.position - position); float depth = (distance - m_camera.frustum.near) / (m_camera.frustum.far - m_camera.frustum.near); outList.emplace_back( createKey(isTransparent, depth * depth, dp.textures), modelMatrix, &geom->dbuff, dp); } }
FLIConfiguration::FLIConfiguration() : Plus4Emu::ConfigurationDB() { resetDefaultSettings(); createKey("conversionType", conversionType); (*this)["conversionType"].setRange(0.0, 1.0); (*this)["conversionType"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("yMin", yMin); (*this)["yMin"].setRange(-0.5, 1.0); (*this)["yMin"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("yMax", yMax); (*this)["yMax"].setRange(0.0, 2.0); (*this)["yMax"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("scaleX", scaleX); (*this)["scaleX"].setRange(0.1, 10.0); (*this)["scaleX"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("scaleY", scaleY); (*this)["scaleY"].setRange(0.1, 10.0); (*this)["scaleY"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("offsetX", offsetX); (*this)["offsetX"].setRange(-10000.0, 10000.0); (*this)["offsetX"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("offsetY", offsetY); (*this)["offsetY"].setRange(-10000.0, 10000.0); (*this)["offsetY"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("saturationMult", saturationMult); (*this)["saturationMult"].setRange(0.0, 8.0); (*this)["saturationMult"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("saturationPow", saturationPow); (*this)["saturationPow"].setRange(0.1, 2.0); (*this)["saturationPow"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("gammaCorrection", gammaCorrection); (*this)["gammaCorrection"].setRange(0.25, 4.0); (*this)["gammaCorrection"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("monitorGamma", monitorGamma); (*this)["monitorGamma"].setRange(0.25, 4.0); (*this)["monitorGamma"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("ditherMode", ditherMode); (*this)["ditherMode"].setRange(0.0, 3.0); (*this)["ditherMode"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("ditherLimit", ditherLimit); (*this)["ditherLimit"].setRange(0.0, 1.0); (*this)["ditherLimit"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("ditherDiffusion", ditherDiffusion); (*this)["ditherDiffusion"].setRange(0.0, 1.0); (*this)["ditherDiffusion"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("enablePAL", enablePAL); (*this)["enablePAL"].setCallback(&configChangeCallbackBoolean, (void *) this, true); createKey("xShift0", xShift0); (*this)["xShift0"].setRange(-2.0, 7.0); (*this)["xShift0"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("xShift1", xShift1); (*this)["xShift1"].setRange(-2.0, 7.0); (*this)["xShift1"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("borderColor", borderColor); (*this)["borderColor"].setRange(0.0, 255.0); (*this)["borderColor"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("verticalSize", verticalSize); (*this)["verticalSize"].setRange(200.0, 496.0); (*this)["verticalSize"].setCallback(&configChangeCallbackVSize, (void *) this, true); createKey("luminance1BitMode", luminance1BitMode); (*this)["luminance1BitMode"].setCallback(&configChangeCallbackBoolean, (void *) this, true); createKey("noLuminanceInterlace", noLuminanceInterlace); (*this)["noLuminanceInterlace"].setCallback(&configChangeCallbackBoolean, (void *) this, true); createKey("colorInterlaceMode", colorInterlaceMode); (*this)["colorInterlaceMode"].setRange(0.0, 2.0); (*this)["colorInterlaceMode"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("luminanceSearchMode", luminanceSearchMode); (*this)["luminanceSearchMode"].setRange(0.0, 5.0); (*this)["luminanceSearchMode"].setCallback(&configChangeCallbackInteger, (void *) this, true); createKey("luminanceSearchModeParam", luminanceSearchModeParam); (*this)["luminanceSearchModeParam"].setRange(0.0, 16.0); (*this)["luminanceSearchModeParam"].setCallback(&configChangeCallbackFloat, (void *) this, true); createKey("prgCompressionLevel", prgCompressionLevel); (*this)["prgCompressionLevel"].setRange(0.0, 9.0); createKey("rawPRGMode", rawPRGMode); }
int createLog(char *fn) { logID = createRandomNum(); stepNum = 0; ////////////////STARTUP from U//////////////// //create first message //INIT values char *x = "aaaaaaaaaaaaa"; char *hashX = hash(x); _hashChain = (char *)malloc(20+1); // the initial hash chain memset(_hashChain, 'a', 20+1); _logAuthKey = intToStr(createRandomNum()); //A A0 = _logAuthKey; char *msgAuthCode; //Z //_sessionKey = createFirstKey(); //K _sessionKey = createKey(LOG_INIT, _logAuthKey); //create msg for T struct Msg *msg = createMsg(stepNum, ID_UNTRUSTED, PUB_KEY_T, PRIV_KEY_U, _sessionKey, x); //create first log entry char *data = logToStr(createLogEntry(LOG_INIT, logID, msg)); //char *data = logToStr2(createLogEntry(LOG_INIT, logID, msg)); char *encData = encryptData(data, _sessionKey, strlen(data)); _hashChain = createY(_hashChain, encData, LOG_INIT); msgAuthCode = genMAC(_logAuthKey, _hashChain); struct ALogEntry *firstLog = createALogEntry(LOG_INIT, encData, _hashChain, msgAuthCode); writeAEntry(firstLog, fn); //////////////END STARTUP from U//////////////// /////////////RECIEVE T////////////// //verify the message int result = verifyMsg(msg, PRIV_KEY_T, PUB_KEY_U); //printf("Result from T:%d\n", result); //TODO: check valid certificate //increment protocol step ID; int p = msg->p + 1; //create X1 char *x0 = getX(msg, PRIV_KEY_T, PUB_KEY_U); char *x1 = "ZZZ"; //create session key char *sessionKeyT = createKey(RESP_MSG, _logAuthKey); //create msg struct Msg *msg1 = createMsg(p, ID_TRUSTED, PUB_KEY_U, PRIV_KEY_T, sessionKeyT, x1); /////////////END RECIEVE T////////////// /////////////FINALIZE INIT U/////////////////// //verify the msg result = verifyMsg(msg1, PRIV_KEY_U, PUB_KEY_T); //printf("Result from U:%d\n", result); //get the data data = logToStr(createLogEntry(RESP_MSG, logID, msg1)); //update hash chains and keys _logAuthKey = hash(_logAuthKey); //A+1 = H(A) _sessionKey = createKey(NORMAL_MSG, _logAuthKey); //K encData = encryptData(data, _sessionKey, strlen(data)); //MSG Authentication _hashChain = createY(_hashChain, encData, RESP_MSG); //Y+1 = H(y, encData, logtype) msgAuthCode = genMAC(_logAuthKey, _hashChain); //Z = MAC(Y) struct ALogEntry *secondLog = createALogEntry(RESP_MSG, encData, _hashChain, msgAuthCode); writeAEntry(secondLog, fn); }