bool EmulatedQemuCameraDevice::inWorkerThread()
{
    /* Wait till FPS timeout expires, or thread exit message is received. */
    WorkerThread::SelectRes res =
        getWorkerThread()->Select(-1, 1000000 / mEmulatedFPS);
    if (res == WorkerThread::EXIT_THREAD) {
        LOGV("%s: Worker thread has been terminated.", __FUNCTION__);
        return false;
    }

    /* Lets see if we need to generate a new frame. */
    if ((systemTime(SYSTEM_TIME_MONOTONIC) - mLastRedrawn) >= mRedrawAfter) {
        /*
         * Time to generate a new frame.
         */

#if EFCD_ROTATE_FRAME
        LOGV("%s: calld frame_type = rotateFrame():%d", __FUNCTION__, frame_type);
        const int frame_type = rotateFrame();
        switch (frame_type) {
            case 0:
                drawCheckerboard();
                break;
            case 1:
                drawStripes();
                break;
            case 2:
                drawSolid(mCurrentColor);
                break;
        }
#else
        /* Draw the checker board. */
        LOGV("%s: calld drawCheckerboard()", __FUNCTION__);
        drawCheckerboard();

#endif  // EFCD_ROTATE_FRAME

        mLastRedrawn = systemTime(SYSTEM_TIME_MONOTONIC);
    }

    /* Timestamp the current frame, and notify the camera HAL about new frame. */
    mCurFrameTimestamp = systemTime(SYSTEM_TIME_MONOTONIC);

    LOGV("%s: calld mCameraHAL->onNextFrameAvailable(mCurrentFrame:%p", __FUNCTION__,mCurrentFrame);
    mCameraHAL->onNextFrameAvailable(mCurrentFrame, mCurFrameTimestamp, this);

    return true;
}
Example #2
0
void redraw(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    /* Only need this if you care to look at the stencil buffer */
    if(dataChoice == STENCIL)
	glClear(GL_STENCIL_BUFFER_BIT);

    glPushMatrix();
    glScalef(.5, .5, .5);

    if(stage == 1)
       goto doneWithFrame;

    setupLight();

    setupNormalDrawingState();
    glPushMatrix();
    glTranslatef(0, 1, 4);
    glRotatef(135, 0, 1, 0);
    drawAirplane();
    glPopMatrix();

    if(stage == 2)
       goto doneWithFrame;

    setupBasePolygonState(3);	/* 2 decals */
    drawGround();

    if(stage == 3)
       goto doneWithFrame;

    setupDecalState(1);		/* decal # 1 = the runway asphalt */
    drawAsphalt();

    if(stage == 4)
       goto doneWithFrame;

    setupDecalState(2);		/* decal # 2 = yellow paint on the runway */
    drawStripes();

    if(stage == 5)
       goto doneWithFrame;

    setupDecalState(3);		/* decal # 3 = the plane's shadow */
    glDisable(GL_LIGHTING);
    glEnable(GL_BLEND);
    glPushMatrix();
    glColor4f(0, 0, 0, .5);
    glTranslatef(0, 0, 4);
    glRotatef(135, 0, 1, 0);
    glScalef(1, 0, 1);
    drawAirplane();
    glPopMatrix();
    glDisable(GL_BLEND);
    glEnable(GL_LIGHTING);

doneWithFrame:

    setupNormalDrawingState();

    glPopMatrix();

    switch(dataChoice) {
        case COLOR:
	    break; /* color already in back buffer */

	case STENCIL:
	    copyStencilToColor(GL_BACK);
	    break;

	case DEPTH:
	    copyDepthToColor(GL_BACK);
	    break;
    }

    glutSwapBuffers();
}