Ejemplo n.º 1
0
void EngineCore::mainLoop() {
    int ident;
    int events;
    struct android_poll_source* source;
    shared_ptr<EngineContext> engineContext(getEngineContext());
    app_dummy();

    while (true) {
        // If not animating, block forever waiting for events.
        // otherwise,  loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident = ALooper_pollAll(
                    engineContext->isRendering() ? 0 : -1,
                    NULL, &events, (void**)&source)) >= 0) {
            if (ident == LOOPER_ID_MAIN || ident == LOOPER_ID_INPUT) {
                if (source != NULL) {
                    source->process(mApp, source);
                }
            }

            if (mApp->destroyRequested != 0) {
                DEBUG(Log::F_APP_CMD_EVENT, "destroy request received");
                return;
            }
        }

        // check needQuit() to give an early chance to stop drawing.
        if (engineContext->isRendering() && !engineContext->needQuit()) {
            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            getEngineContext()->updateDisplay();
        }
    }

}
Ejemplo n.º 2
0
void GraphicsEngine::LoadPipeline(const std::string& graphDesc) {
	FlushPipelineQueue();

	Pipeline pipeline;
	pipeline.CreateFromDescription(graphDesc, GraphicsNodeFactory_Singleton::GetInstance());

	EngineContext engineContext(1, 1);
	for (auto& node : pipeline) {
		if (auto graphicsNode = dynamic_cast<GraphicsNode*>(&node)) {
			graphicsNode->Initialize(engineContext);
		}
	}

	auto specialNodes = SelectSpecialNodes(pipeline);

	m_specialNodes = specialNodes;
	m_pipeline = std::move(pipeline);
	m_scheduler.SetPipeline(std::move(m_pipeline));
}