当前位置: 首页>>代码示例>>C++>>正文


C++ StyleContext::initFunctions方法代码示例

本文整理汇总了C++中StyleContext::initFunctions方法的典型用法代码示例。如果您正苦于以下问题:C++ StyleContext::initFunctions方法的具体用法?C++ StyleContext::initFunctions怎么用?C++ StyleContext::initFunctions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StyleContext的用法示例。


在下文中一共展示了StyleContext::initFunctions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

void TileWorker::run() {

    setCurrentThreadPriority(WORKER_NICENESS);

    StyleContext context;

    while (true) {

        std::shared_ptr<TileTask> task;
        {
            std::unique_lock<std::mutex> lock(m_mutex);

            m_condition.wait(lock, [&, this]{
                    return !m_running || !m_queue.empty();
                });

            // Check if thread should stop
            if (!m_running) {
                break;
            }

            // Remove all canceled tasks
            auto removes = std::remove_if(m_queue.begin(), m_queue.end(),
                                          [](const auto& a) { return a->isCanceled(); });

            m_queue.erase(removes, m_queue.end());

            if (m_queue.empty()) {
                continue;
            }

            // Pop highest priority tile from queue
            auto it = std::min_element(m_queue.begin(), m_queue.end(),
                [](const auto& a, const auto& b) {
                    if (a->isProxy() != b->isProxy()) {
                        return !a->isProxy();
                    }
                    if (a->source().id() == b->source().id() &&
                        a->sourceGeneration() != b->sourceGeneration()) {
                        return a->sourceGeneration() < b->sourceGeneration();
                    }
                    return a->getPriority() < b->getPriority();
                });

            task = std::move(*it);
            m_queue.erase(it);
        }

        if (task->isCanceled()) { continue; }

        // Save shared reference to Scene while building tile
        // FIXME: Scene could be released on Worker-Thread and
        // therefore call unsafe glDelete* functions...
        auto scene = m_scene;
        if (!scene) { continue; }

        auto tileData = task->source().parse(*task, *scene->mapProjection());

        // const clock_t begin = clock();

        context.initFunctions(*scene);

        if (tileData) {
            auto tile = std::make_shared<Tile>(task->tileId(),
                                               *scene->mapProjection(),
                                               &task->source());

            tile->build(context, *scene, *tileData, task->source());

            // Mark task as ready
            task->setTile(std::move(tile));

            // float loadTime = (float(clock() - begin) / CLOCKS_PER_SEC) * 1000;
            // LOG("loadTime %s - %f", task->tile()->getID().toString().c_str(), loadTime);
        } else {
            task->cancel();
        }

        m_pendingTiles = true;

        requestRender();
    }
}
开发者ID:rmarianski,项目名称:tangram-es,代码行数:83,代码来源:tileWorker.cpp

示例2: run

void TileWorker::run() {

    setCurrentThreadPriority(WORKER_NICENESS);

    StyleContext context;

    while (true) {

        std::shared_ptr<TileTask> task;
        {
            std::unique_lock<std::mutex> lock(m_mutex);

            m_condition.wait(lock, [&, this]{
                    return !m_running || !m_queue.empty();
                });

            // Check if thread should stop
            if (!m_running) {
                break;
            }

            // Remove all canceled tasks
            auto removes = std::remove_if(m_queue.begin(), m_queue.end(),
                [](const auto& a) { return a->tile->isCanceled(); });

            m_queue.erase(removes, m_queue.end());

            if (m_queue.empty()) {
                continue;
            }

            // Pop highest priority tile from queue
            auto it = std::min_element(m_queue.begin(), m_queue.end(),
                [](const auto& a, const auto& b) {
                    if (a->tile->isVisible() != b->tile->isVisible()) {
                        return a->tile->isVisible();
                    }
                    return a->tile->getPriority() < b->tile->getPriority();
                });

            task = std::move(*it);
            m_queue.erase(it);
        }

        if (task->tile->isCanceled()) {
            continue;
        }

        auto tileData = task->process();

        // NB: Save shared reference to Scene while building tile
        auto scene = m_tileManager.getScene();

        const clock_t begin = clock();

        context.initFunctions(*scene);

        if (tileData) {
            task->tile->build(context, *scene, *tileData, *task->source);

            float loadTime = (float(clock() - begin) / CLOCKS_PER_SEC) * 1000;
            LOG("loadTime %s - %f", task->tile->getID().toString().c_str(), loadTime);

            m_tileManager.tileProcessed(std::move(task));
        }

        requestRender();
    }
}
开发者ID:UIKit0,项目名称:tangram-es,代码行数:69,代码来源:tileWorker.cpp


注:本文中的StyleContext::initFunctions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。