本文整理汇总了C++中TransformState::getPixelRatio方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformState::getPixelRatio方法的具体用法?C++ TransformState::getPixelRatio怎么用?C++ TransformState::getPixelRatio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformState
的用法示例。
在下文中一共展示了TransformState::getPixelRatio方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Style::update(MapData& data,
const TransformState& transform,
TexturePool& texturePool) {
const float pixelRatio = transform.getPixelRatio();
if (!sprite || !sprite->hasPixelRatio(pixelRatio)) {
sprite = std::make_unique<Sprite>(spriteURL, pixelRatio);
sprite->setObserver(this);
spriteAtlas->resize(pixelRatio);
spriteAtlas->setSprite(sprite);
}
bool allTilesUpdated = true;
for (const auto& source : sources) {
if (!source->update(data, transform, *this, *glyphAtlas, *glyphStore,
*spriteAtlas, sprite, texturePool, shouldReparsePartialTiles)) {
allTilesUpdated = false;
}
}
// We can only stop updating "partial" tiles when all of them
// were notified of the arrival of the new resources.
if (allTilesUpdated) {
shouldReparsePartialTiles = false;
}
}
示例2: prepare
void Map::prepare() {
view.make_active();
// Update transform transitions.
animationTime = util::now();
if (transform.needsTransition()) {
transform.updateTransitions(animationTime);
}
const TransformState oldState = state;
state = transform.currentState();
bool pixelRatioChanged = oldState.getPixelRatio() != state.getPixelRatio();
bool dimensionsChanged = oldState.getFramebufferWidth() != state.getFramebufferWidth() ||
oldState.getFramebufferHeight() != state.getFramebufferHeight();
if (pixelRatioChanged) {
style->sprite = std::make_shared<Sprite>(*this, state.getPixelRatio());
style->sprite->load(kSpriteURL);
spriteAtlas->resize(state.getPixelRatio());
}
if (pixelRatioChanged || dimensionsChanged) {
painter.clearFramebuffers();
}
style->cascade(state.getNormalizedZoom());
// Update style transitions.
animationTime = util::now();
if (style->needsTransition()) {
style->updateTransitions(animationTime);
update();
}
// Allow the sprite atlas to potentially pull new sprite images if needed.
if (style->sprite && style->sprite->isLoaded()) {
spriteAtlas->update(*style->sprite);
}
updateTiles();
}
示例3: update
void ResourceLoader::update(MapData& data,
const TransformState& transform,
GlyphAtlas& glyphAtlas,
GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas,
TexturePool& texturePool) {
if (!style_) {
return;
}
const float pixelRatio = transform.getPixelRatio();
if (!sprite_ || !sprite_->hasPixelRatio(pixelRatio)) {
sprite_ = util::make_unique<Sprite>(style_->getSpriteURL(), pixelRatio);
sprite_->setObserver(this);
spriteAtlas.resize(pixelRatio);
spriteAtlas.setSprite(sprite_);
}
for (const auto& source : style_->sources) {
source->update(
data, transform, *style_, glyphAtlas, glyphStore, spriteAtlas, sprite_, texturePool);
}
}
示例4: getZoom
double Source::getZoom(const TransformState& state) const {
double offset = std::log(util::tileSize / info.tile_size) / std::log(2);
offset += (state.getPixelRatio() > 1.0 ? 1 :0);
return state.getZoom() + offset;
}