void OsmAnd::MapMarker_P::setPosition(const PointI position) { QWriteLocker scopedLocker(&_lock); _position = position; _hasUnappliedChanges = true; }
void OsmAnd::MapMarker_P::setOnMapSurfaceIconDirection(const MapMarker::OnSurfaceIconKey key, const float direction) { QWriteLocker scopedLocker(&_lock); _directions[key] = direction; _hasUnappliedChanges = true; }
void OsmAnd::MapMarker_P::setIsAccuracyCircleVisible(const bool visible) { QWriteLocker scopedLocker(&_lock); _isAccuracyCircleVisible = visible; _hasUnappliedChanges = true; }
void OsmAnd::MapMarker_P::setAccuracyCircleRadius(const double radius) { QWriteLocker scopedLocker(&_lock); _accuracyCircleRadius = radius; _hasUnappliedChanges = true; }
void OsmAnd::MapMarker_P::setPinIconModulationColor(const ColorARGB colorValue) { QWriteLocker scopedLocker(&_lock); _pinIconModulationColor = colorValue; _hasUnappliedChanges = true; }
void OsmAnd::MapMarker_P::setIsHidden(const bool hidden) { QWriteLocker scopedLocker(&_lock); _isHidden = hidden; _hasUnappliedChanges = true; }
std::shared_ptr<OsmAnd::MapMarker> OsmAnd::MapMarkerBuilder_P::buildAndAddToCollection( const std::shared_ptr<MapMarkersCollection>& collection) { QReadLocker scopedLocker(&_lock); // Construct map symbols group for this marker const std::shared_ptr<MapMarker> marker(new MapMarker( _baseOrder, _pinIcon, _pinIconAlignment, detachedOf(_onMapSurfaceIcons), _isAccuracyCircleSupported, _accuracyCircleBaseColor)); marker->setIsHidden(_isHidden); if (_isAccuracyCircleSupported) { marker->setIsAccuracyCircleVisible(_isAccuracyCircleVisible); marker->setAccuracyCircleRadius(_accuracyCircleRadius); } marker->setPosition(_position); marker->setPinIconModulationColor(_pinIconModulationColor); marker->applyChanges(); // Add marker to collection and return it if adding was successful if (!collection->_p->addMarker(marker)) return nullptr; return marker; }
bool OsmAnd::ObfsCollection_P::remove(const ObfsCollection::SourceOriginId entryId) { QWriteLocker scopedLocker(&_sourcesOriginsLock); const auto itSourceOrigin = _sourcesOrigins.find(entryId); if (itSourceOrigin == _sourcesOrigins.end()) return false; const auto& sourceOrigin = *itSourceOrigin; if (sourceOrigin->type == SourceOriginType::Directory) { const auto& directoryAsSourceOrigin = std::static_pointer_cast<const DirectoryAsSourceOrigin>(sourceOrigin); for(const auto watchedSubdirectory : constOf(directoryAsSourceOrigin->watchedSubdirectories)) _fileSystemWatcher->removePath(watchedSubdirectory); _fileSystemWatcher->removePath(directoryAsSourceOrigin->directory.canonicalPath()); } else if (sourceOrigin->type == SourceOriginType::File) { const auto& fileAsSourceOrigin = std::static_pointer_cast<const FileAsSourceOrigin>(sourceOrigin); _fileSystemWatcher->removePath(fileAsSourceOrigin->fileInfo.canonicalFilePath()); } _sourcesOrigins.erase(itSourceOrigin); invalidateCollectedSources(); return true; }
QHash< OsmAnd::MapMarker::OnSurfaceIconKey, std::shared_ptr<const SkBitmap> > OsmAnd::MapMarkerBuilder_P::getOnMapSurfaceIcons() const { QReadLocker scopedLocker(&_lock); return detachedOf(_onMapSurfaceIcons); }
std::shared_ptr<OsmAnd::ObfDataInterface> OsmAnd::ObfsCollection_P::obtainDataInterface() const { // Check if sources were invalidated if (_collectedSourcesInvalidated.loadAcquire() > 0) collectSources(); // Create ObfReaders from collected sources QList< std::shared_ptr<const ObfReader> > obfReaders; { QReadLocker scopedLocker(&_collectedSourcesLock); for(const auto& collectedSources : constOf(_collectedSources)) { obfReaders.reserve(obfReaders.size() + collectedSources.size()); for(const auto& obfFile : constOf(collectedSources)) { std::shared_ptr<const ObfReader> obfReader(new ObfReader(obfFile)); if (!obfReader->isOpened() || !obfReader->obtainInfo()) continue; obfReaders.push_back(qMove(obfReader)); } } } return std::shared_ptr<ObfDataInterface>(new ObfDataInterface(obfReaders)); }
void OsmAnd::MapPresentationEnvironment_P::applyTo(MapStyleEvaluator& evaluator) const { QMutexLocker scopedLocker(&_settingsChangeMutex); for (const auto& settingEntry : rangeOf(constOf(_settings))) { const auto& valueDef = settingEntry.key(); const auto& settingValue = settingEntry.value(); switch (valueDef->dataType) { case MapStyleValueDataType::Integer: evaluator.setIntegerValue(valueDef->id, settingValue.isComplex ? settingValue.asComplex.asInt.evaluate(owner->displayDensityFactor) : settingValue.asSimple.asInt); break; case MapStyleValueDataType::Float: evaluator.setFloatValue(valueDef->id, settingValue.isComplex ? settingValue.asComplex.asFloat.evaluate(owner->displayDensityFactor) : settingValue.asSimple.asFloat); break; case MapStyleValueDataType::Boolean: case MapStyleValueDataType::String: case MapStyleValueDataType::Color: assert(!settingValue.isComplex); evaluator.setIntegerValue(valueDef->id, settingValue.asSimple.asUInt); break; } } }
OsmAnd::ObfsCollection::SourceOriginId OsmAnd::ObfsCollection_P::addDirectory(const QDir& dir, bool recursive) { QWriteLocker scopedLocker(&_sourcesOriginsLock); const auto allocatedId = _lastUnusedSourceOriginId++; auto sourceOrigin = new DirectoryAsSourceOrigin(); sourceOrigin->directory = dir; sourceOrigin->isRecursive = recursive; _sourcesOrigins.insert(allocatedId, qMove(std::shared_ptr<const SourceOrigin>(sourceOrigin))); _fileSystemWatcher->addPath(dir.canonicalPath()); if (recursive) { QFileInfoList subdirs; Utilities::findDirectories(dir, QStringList() << QLatin1String("*"), subdirs, true); for(const auto& subdir : subdirs) { const auto canonicalPath = subdir.canonicalFilePath(); sourceOrigin->watchedSubdirectories.insert(canonicalPath); _fileSystemWatcher->addPath(canonicalPath); } } invalidateCollectedSources(); return allocatedId; }
OsmAnd::MapPresentationEnvironment_P::~MapPresentationEnvironment_P() { { QMutexLocker scopedLocker(&_shadersBitmapsMutex); _shadersBitmaps.clear(); } }
void OsmAnd::Concurrent::Dispatcher::shutdown() { QMutexLocker scopedLocker(&_performedShutdownConditionMutex); shutdownAsync(); REPEAT_UNTIL(_performedShutdown.wait(&_performedShutdownConditionMutex)); }
QString OsmAnd::MapSymbolIntersectionClassesRegistry_P::getClassNameById(const ClassId classId) const { QReadLocker scopedLocker(&_lock); if (_nameById.size() <= classId) return QString::null; return _nameById[classId]; }
void OsmAnd::OnlineMapRasterTileProvider_P::unlockTile( const TileId tileId, const ZoomLevel zoom ) { QMutexLocker scopedLocker(&_tilesInProcessMutex); _tilesInProcess[zoom].remove(tileId); _waitUntilAnyTileIsProcessed.wakeAll(); }
void OsmAnd::MapMarkerBuilder_P::addOnMapSurfaceIcon( const MapMarker::OnSurfaceIconKey key, const std::shared_ptr<const SkBitmap>& bitmap) { QWriteLocker scopedLocker(&_lock); _onMapSurfaceIcons.insert(key, bitmap); }
void OsmAnd::FavoriteLocationsCollection_P::clearFavoriteLocations() { QWriteLocker scopedLocker(&_collectionLock); doClearFavoriteLocations(); notifyCollectionChanged(); }
void OsmAnd::ObfFile_P::unlockFromWriting() const { QMutexLocker scopedLocker(&_lockCounterMutex); assert(_lockCounter < 0); _lockCounter++; _lockCounterWaitCondition.wakeAll(); }
unsigned int OsmAnd::BaseSearchEngine_P::removeAllDataSources() { QWriteLocker scopedLocker(&_dataSourcesLock); const auto removedCount = _dataSources.size(); _dataSources.clear(); return removedCount; }
void OsmAnd::TextRasterizer_P::clearFontsCache() { QMutexLocker scopedLocker(&_fontTypefacesCacheMutex); for (const auto& typeface : _fontTypefacesCache) typeface->unref(); _fontTypefacesCache.clear(); }
void OsmAnd::OnlineRasterMapLayerProvider::setLocalCachePath( const QString& localCachePath, const bool appendPathSuffix /*= true*/) { QMutexLocker scopedLocker(&_p->_localCachePathMutex); _p->_localCachePath = appendPathSuffix ? QDir(localCachePath).absoluteFilePath(pathSuffix) : localCachePath; }
std::shared_ptr<const OsmAnd::MapStyle> OsmAnd::MapStylesCollection_P::getAsIsStyle(const QString& name) const { QReadLocker scopedLocker(&_stylesLock); const auto citStyle = _styles.constFind(name); if (citStyle == _styles.cend()) return nullptr; return *citStyle; }
void OsmAnd::OnlineMapRasterTileProvider_P::lockTile( const TileId tileId, const ZoomLevel zoom ) { QMutexLocker scopedLocker(&_tilesInProcessMutex); while(_tilesInProcess[zoom].contains(tileId)) _waitUntilAnyTileIsProcessed.wait(&_tilesInProcessMutex); _tilesInProcess[zoom].insert(tileId); }
OsmAnd::MapRasterizer_P::~MapRasterizer_P() { { QMutexLocker scopedLocker(&_pathEffectsMutex); for (auto& pathEffect : _pathEffects) pathEffect->unref(); } }
void OsmAnd::FavoriteLocation_P::setColor(const ColorRGB newColor) { QWriteLocker scopedLocker(&_lock); _color = newColor; if (const auto link = _weakLink.lock()) link->_p->notifyFavoriteLocationChanged(owner); }
void OsmAnd::FavoriteLocation_P::setGroup(const QString& newGroup) { QWriteLocker scopedLocker(&_lock); _group = newGroup; if (const auto link = _weakLink.lock()) link->_p->notifyFavoriteLocationChanged(owner); }
void OsmAnd::FavoriteLocation_P::setTitle(const QString& newTitle) { QWriteLocker scopedLocker(&_lock); _title = newTitle; if (const auto link = _weakLink.lock()) link->_p->notifyFavoriteLocationChanged(owner); }
void OsmAnd::ObfFile_P::lockForWriting() const { QMutexLocker scopedLocker(&_lockCounterMutex); while(_lockCounter > 0) REPEAT_UNTIL(_lockCounterWaitCondition.wait(&_lockCounterMutex)); _lockCounter--; _lockCounterWaitCondition.wakeAll(); }
std::shared_ptr<const OsmAnd::MapStyleBuiltinValueDefinitions> OsmAnd::MapStyle::getBuiltinValueDefinitions() { QMutexLocker scopedLocker(&g_OsmAnd_MapStyle_builtinValueDefinitionsMutex); if(!static_cast<bool>(g_OsmAnd_MapStyle_builtinValueDefinitions)) g_OsmAnd_MapStyle_builtinValueDefinitions.reset(new OsmAnd::MapStyleBuiltinValueDefinitions()); return g_OsmAnd_MapStyle_builtinValueDefinitions; }