Ejemplo n.º 1
0
// inlined-only version
INLINE int32_t CompleteDrawContextInl(SWR_CONTEXT* pContext, uint32_t workerId, DRAW_CONTEXT* pDC)
{
    int32_t result = static_cast<int32_t>(InterlockedDecrement(&pDC->threadsDone));
    SWR_ASSERT(result >= 0);

    AR_FLUSH(pDC->drawId);

    if (result == 0)
    {
        ExecuteCallbacks(pContext, workerId, pDC);

        // Cleanup memory allocations
        pDC->pArena->Reset(true);
        if (!pDC->isCompute)
        {
            pDC->pTileMgr->initialize();
        }
        if (pDC->cleanupState)
        {
            pDC->pState->pArena->Reset(true);
        }

        _ReadWriteBarrier();

        pContext->dcRing.Dequeue();  // Remove from tail
    }

    return result;
}
Ejemplo n.º 2
0
void *FricXactor::Send(void *args)
{
  for(;;)
    {
      boost::shared_ptr<FricData> sendData = inChan.get();

      ExecuteCallbacks(SendCB, sendData.get());
      _sendPacket(*(sendData->ptype), *(sendData->port), *(sendData->addr), *(sendData->data));
    }

  return 0;
}
Ejemplo n.º 3
0
void *FricXactor::Receive(void *args)
{
  for(;;)
    {
      boost::shared_ptr<FricData> recvData(new FricData("FricRecieve"));

      _recvPacket(recvData->ptype, recvData->port, recvData->addr, recvData->data);
      
      outChan.put(recvData);
      ExecuteCallbacks(RecieveCB, recvData.get());
    }

  return 0;
}	  
JNIEXPORT void JNICALL Java_com_adobe_plugins_FastCanvasJNI_render
  (JNIEnv *je, jclass jc, jstring renderCommands)
{
    Canvas *theCanvas = Canvas::GetCanvas();
    if (theCanvas) {
        const char *rc = je->GetStringUTFChars(renderCommands, 0);
        int length = je->GetStringUTFLength(renderCommands);
		
        theCanvas->Render(rc, length);
        je->ReleaseStringUTFChars(renderCommands, rc);
		
		//send all callbacks, for now only capture callbacks
		ExecuteCallbacks(je);
    }
}
Ejemplo n.º 5
0
void InputManager::Update()
{
    SDL_PumpEvents(); // done implicitly by SDL_PollEvent
    const Uint8 *keys = SDL_GetKeyboardState( NULL );
    for( auto& kb : keyboardBinding_ )
    {
        for( auto& key : kb.second )
        {
            if( keys[ key->key_ ] )
                key->pressed_ = true;
            else
                key->pressed_ = false;
        }
    }
    ExecuteCallbacks();
}
Ejemplo n.º 6
0
/**
* Get next packet ready
* This function also keeps the connection alive as long as you keep calling it
*/
int CInsim::next_packet()
{
	unsigned char oldp_size, p_size;
	bool alive = true;

	while (alive)											   // Keep the connection alive!
	{
		alive = false;
		oldp_size = (unsigned char)*lbuf.buffer;

		if ((lbuf.bytes > 0) && (lbuf.bytes >= oldp_size)) {		// There's an old packet in the local buffer, skip it
			// Copy the leftovers from local buffer to global buffer
			memcpy(gbuf.buffer, lbuf.buffer+oldp_size, lbuf.bytes-oldp_size);
			gbuf.bytes = lbuf.bytes - oldp_size;

			// Copy from global buffer back to the beginning of local buffer
			memset(lbuf.buffer, 0, PACKET_BUFFER_SIZE);
			memcpy(lbuf.buffer, gbuf.buffer, gbuf.bytes);
			lbuf.bytes = gbuf.bytes;
		}

		p_size = (unsigned char)*lbuf.buffer;

		while ((lbuf.bytes < p_size) || (lbuf.bytes < 1))	   // Read until we have a full packet
		{
			// Clear them
			FD_ZERO(&readfd);
			FD_ZERO(&exceptfd);

			// Set them to watch our socket for data to read and exceptions that maybe thrown
			FD_SET(sock, &readfd);
			FD_SET(sock, &exceptfd);

			#ifdef CIS_WINDOWS
			int rc = select(0, &readfd, NULL, &exceptfd, &select_timeout);
			#elif defined CIS_LINUX
			int rc = pselect(sock + 1, &readfd, NULL, &exceptfd, &select_timeout, NULL);
			#endif

			if (rc == 0)					// Timeout
				continue;

			if (rc < 0)					 // An error occured
				return -1;

			if (FD_ISSET(sock, &exceptfd))	// An exception occured - we want to quit
				return -1;
			else
			{  // We got data!
				// Recieve any waiting bytes
				int retval = recv(sock, lbuf.buffer + lbuf.bytes, PACKET_BUFFER_SIZE - lbuf.bytes, 0);

				// Deal with the results
				if (retval == 0)				// Connection has been closed at the other end
					return -2;

				if (retval < 0)				 // An error ocurred
					return -1;

				p_size = *lbuf.buffer;
				lbuf.bytes += retval;
			}
		}

		memcpy(packet, lbuf.buffer, p_size);

		if ((peek_packet() == ISP_TINY) && (*(packet+3) == TINY_NONE)) {
			alive = true;

			struct IS_TINY keepalive;
			keepalive.Size = sizeof(struct IS_TINY);
			keepalive.Type = ISP_TINY;
			keepalive.ReqI = 0;
			keepalive.SubT = TINY_NONE;

			// Send it back
			if (send_packet(&keepalive) < 0)
				return -1;
		}

		ExecuteCallbacks(peek_packet());
	}

	return 0;
}