void CanvasContext::buildLayer(RenderNode* node) {
    ATRACE_CALL();
    if (!mEglManager.hasEglContext() || !mCanvas) {
        return;
    }
    requireGlContext();
    // buildLayer() will leave the tree in an unknown state, so we must stop drawing
    stopDrawing();

    TreeInfo info(TreeInfo::MODE_FULL, mRenderThread.renderState());
    info.damageAccumulator = &mDamageAccumulator;
    info.renderer = mCanvas;
    info.runAnimations = false;
    node->prepareTree(info);
    SkRect ignore;
    mDamageAccumulator.finish(&ignore);
    // Tickle the GENERIC property on node to mark it as dirty for damaging
    // purposes when the frame is actually drawn
    node->setPropertyFieldsDirty(RenderNode::GENERIC);

    mCanvas->markLayersAsBuildLayers();
    mCanvas->flushLayerUpdates();

    node->incStrong(0);
    mPrefetechedLayers.insert(node);
}
void CanvasContext::destroyHardwareResources() {
    stopDrawing();
    if (mEglManager.hasEglContext()) {
        requireGlContext();
        freePrefetechedLayers();
        mRootRenderNode->destroyHardwareResources();
        Caches::getInstance().flush(Caches::kFlushMode_Layers);
    }
}
Пример #3
0
void GLMoblet::setPreferredFramesPerSecond(float fps) {
	if((int)fps == 0) maPanic(1, "Invalid fps!");
	// we want milliseconds per frame.
	float secondsPerFrame = 1.0f/fps;
	float millisecondsPerFrame = 1000.0f * secondsPerFrame;
	mPreferredMillisecondsPerFrame = (int)millisecondsPerFrame;
	stopDrawing();
	startDrawing();
}
void CanvasContext::destroy() {
    stopDrawing();
    setSurface(NULL);
    freePrefetechedLayers();
    destroyHardwareResources();
    mAnimationContext->destroy();
    if (mCanvas) {
        delete mCanvas;
        mCanvas = 0;
    }
}
Пример #5
0
void Overlay::drawGameOver(std::vector<Player *> players, int playerId, bool haswon) {
	//init glut overlay
	initdraw();

	//first player to get camera size
	Player * playerone = players[0];
	
	
	//Draw overlay red is lose otherwise green
	//glColor3f(!haswon, haswon, 0);
	
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f(!haswon, haswon, 0, (GLfloat)0.55);

	//space between objects
	int margin = 200;


	//drawBackground:
	glBegin(GL_QUADS);
	glVertex2f((GLfloat)margin, (GLfloat)playerone->getCamera()->height - margin);
	glVertex2f((GLfloat)margin, (GLfloat)margin);
	glVertex2f((GLfloat)playerone->getCamera()->width - margin, (GLfloat)margin);
	glVertex2f((GLfloat)playerone->getCamera()->width - margin, (GLfloat)playerone->getCamera()->height - margin);
	glEnd();

	margin += 25;

	//draw players
	for (int i = 0; i < players.size(); i++) {
		int x0 = margin;
		int y0 = margin + (i*125);
		int x1 = playerone->getCamera()->width - margin;
		int y1 = margin + 100 + (i * 125);
		bool isCurrentPlayer = false;

		//highlight if current player
		if (i == playerId) {
			isCurrentPlayer = true;
		}

		//draw player information
		drawPlayerInfo(players[i], x0, y0, x1, y1, isCurrentPlayer);

	}



	glutdrawstring("Game Over " ,  playerone->getCamera()->width / 2 - 75, 100, GLUT_BITMAP_TIMES_ROMAN_24);

	//reset settings:
	stopDrawing();
}
void CanvasContext::destroyHardwareResources() {
    stopDrawing();
    if (mEglManager.hasEglContext()) {
        freePrefetechedLayers();
        mRootRenderNode->destroyHardwareResources();
        Caches& caches = Caches::getInstance();
        // Make sure to release all the textures we were owning as there won't
        // be another draw
        caches.textureCache.resetMarkInUse(this);
        caches.flush(Caches::kFlushMode_Layers);
    }
}
Пример #7
0
void Overlay::drawHealthBar(Player * player, GateModel * gate)
{
	//init glut overlay
	initdraw();
	
	int margin = 100;

	Camera * cam = player->getCamera();
	int x0 = cam->width - margin - 75;
	int y0 = margin;
	int x1 = cam->width - margin;
	int y1 = cam->height - margin;
	
	double xpbarHeight = y1 - y0;

	//xpbarbackground:
	glBegin(GL_QUADS);
	glColor3f((GLfloat)0, (GLfloat)1, (GLfloat)0);
	glVertex2f((GLfloat)x1, (GLfloat)y0);
	glVertex2f((GLfloat)x0, (GLfloat)y0);

	glColor3f((GLfloat)1, (GLfloat)0, (GLfloat)0);
	glVertex2f((GLfloat)x0, (GLfloat)y1);
	glVertex2f((GLfloat)x1, (GLfloat)y1);
	glEnd();

	//drawindicator:

	float indicatorpos = (float)(xpbarHeight * gate->getHealth()) / 100 ;

	int indicatorx0 = x0 - 10;
	int indicatory0 = cam->height - (int)indicatorpos - 5 - margin;
	int indicatorx1 = x1 + 10;
	int indicatory1 = cam->height - (int)indicatorpos + 5 - margin;

	glColor3f(1, 1, 1);
	glBegin(GL_QUADS);
	glVertex2f((GLfloat)indicatorx1, (GLfloat)indicatory0);
	glVertex2f((GLfloat)indicatorx0, (GLfloat)indicatory0);
	glVertex2f((GLfloat)indicatorx0, (GLfloat)indicatory1);
	glVertex2f((GLfloat)indicatorx1, (GLfloat)indicatory1);
	glEnd();

	//reset settings:
	stopDrawing();
}
Пример #8
0
void kpok::newGame()
{
  NewGameDlg* newGameDlg;

  // Get a "New Game" dialog.
  lastHandText = "";
  newGameDlg = new NewGameDlg(this);
  newGameDlg->hideReadingFromConfig();

  if (newGameDlg->exec()) {
    stopBlinking();
    stopDrawing();
    stopWave();

    // Delete the old values.
    for (unsigned int i = 0; i < m_numPlayers; i++)
      delete playerBox[i];
    delete[] playerBox;// necessary?

    int numPlayers = newGameDlg->getPlayers();

    // Most things will be done in initPoker.
    initPoker(numPlayers);

    // Set/show the name and money of all players.
    for (unsigned int i = 0; i < m_numPlayers; i++) {
      m_players[i].setName(newGameDlg->name(i));
      playerBox[i]->showName();
      m_players[i].setCash((newGameDlg->money() >= m_game.getMinBet())
			   ? newGameDlg->money() : START_MONEY);
      m_game.setDirty();
    }

    // Show the money for all players and the pot.
    paintCash();

    // Activate the Draw button.
    drawButton->setText(i18n("&Deal"));
    drawButton->setEnabled(true);
  }

  delete newGameDlg;
}
void CanvasContext::pauseSurface(ANativeWindow* window) {
    stopDrawing();
}