Esempio n. 1
0
static void
vboxApplyPatch(const char* psFuncName, void *pDst, const void *pSrc, unsigned long size)
{
    void *alPatch;
    int rv;

    /* Get aligned start address we're going to patch*/
    alPatch = (void*) ((uintptr_t)pDst & ~(uintptr_t)(PAGESIZE-1));

#ifndef VBOX_NO_MESA_PATCH_REPORTS
    crDebug("MProtecting: %p, %li", alPatch, pDst-alPatch+size);
#endif

    /* Get write access to mesa functions */
    rv = RTMemProtect(alPatch, pDst-alPatch+size, RTMEM_PROT_READ|RTMEM_PROT_WRITE|RTMEM_PROT_EXEC);
    if (RT_FAILURE(rv))
    {
        crError("mprotect failed with %x (%s)", rv, psFuncName);
    }

#ifndef VBOX_NO_MESA_PATCH_REPORTS
    crDebug("Writing %li bytes to %p from %p", size, pDst, pSrc);
#endif

    crMemcpy(pDst, pSrc, size);

    /*@todo Restore the protection, probably have to check what was it before us...*/
    rv = RTMemProtect(alPatch, pDst-alPatch+size, RTMEM_PROT_READ|RTMEM_PROT_EXEC);
    if (RT_FAILURE(rv))
    {
        crError("mprotect2 failed with %x (%s)", rv, psFuncName);
    }
}
Esempio n. 2
0
/*
 *  Updates geometry info for given spu window.
 *  Returns GL_TRUE if it changed since last call, GL_FALSE otherwise.
 *  bForceUpdate - forces dispatching of geometry info even if it's unchanged
 */
GLboolean stubUpdateWindowGeometry(WindowInfo *pWindow, GLboolean bForceUpdate)
{
    int winX, winY;
    unsigned int winW, winH;
    GLboolean res = GL_FALSE;

    CRASSERT(pWindow);

    stubGetWindowGeometry(pWindow, &winX, &winY, &winW, &winH);

    /* @todo remove "if (winW && winH)"?*/
    if (winW && winH) {
        if (stub.trackWindowSize) {
            if (bForceUpdate || winW != pWindow->width || winH != pWindow->height) {
                crDebug("Dispatched WindowSize (%i)", pWindow->spuWindow);
                stub.spuDispatch.WindowSize(pWindow->spuWindow, winW, winH);
                pWindow->width = winW;
                pWindow->height = winH;
                res = GL_TRUE;
            }
        }
        if (stub.trackWindowPos) {
            if (bForceUpdate || winX != pWindow->x || winY != pWindow->y) {
                crDebug("Dispatched WindowPosition (%i)", pWindow->spuWindow);
                stub.spuDispatch.WindowPosition(pWindow->spuWindow, winX, winY);
                pWindow->x = winX;
                pWindow->y = winY;
                res = GL_TRUE;
            }
        }
    }

    return res;
}
Esempio n. 3
0
static void
vncspuNetLoggerInit(void)
{
#ifdef NETLOGGER
	if (vnc_spu.netlogger_url) {
		char *c;

		crDebug("VNC SPU: NetLogger URL: %s", vnc_spu.netlogger_url);
#if 0
		if (vnc_spu.netlogger_url) {
			/* XXX add unlink() wrapper to Cr util package */
			unlink(vnc_spu.netlogger_url);
		}
#endif
		NL_logger_module("vncspu", /* module name */
										 vnc_spu.netlogger_url,
										 NL_LVL_DEBUG, /* logging level */
										 NL_TYPE_APP, /* target type */
										 "" /* terminator */
										 );
		NL_info("vncspu", "spu.program.begin", "");

		vnc_spu.hostname = crAlloc(101);
		crGetHostname(vnc_spu.hostname, 100);
		/* truncate at first dot */
		if ((c = crStrchr(vnc_spu.hostname, '.')))
			*c = 0;
	}
	else {
		crDebug("VNC SPU: NetLogger disabled");
	}
#endif
}
Esempio n. 4
0
File: net.c Progetto: L3oV1nc3/VMGL
/**
 * Establish a connection with a server.
 * \param server  the server to connect to, in the form
 *                "protocol://servername:port" where the port specifier
 *                is optional and if the protocol is missing it is assumed
 *                to be "tcpip".
 * \param default_port  the port to connect to, if port not specified in the
 *                      server URL string.
 * \param mtu  desired maximum transmission unit size (in bytes)
 */
CRConnection *
crNetConnectToServer( const char *server, unsigned short default_port, int mtu)
{
	char hostname[4096], protocol[4096];
	unsigned short port;
	CRConnection *conn;

	crDebug( "In crNetConnectToServer( \"%s\", port=%d, mtu=%d )",
					 server, default_port, mtu );

	CRASSERT( cr_net.initialized );

	if (mtu < CR_MINIMUM_MTU)
	{
		crError( "You tried to connect to server \"%s\" with an mtu of %d, "
						 "but the minimum MTU is %d", server, mtu, CR_MINIMUM_MTU );
	}

	/* Tear the URL apart into relevant portions. */
	if ( !crParseURL( server, protocol, hostname, &port, default_port ) ) {
		 crError( "Malformed URL: \"%s\"", server );
	}

	crDebug( "Connecting to %s on port %d, with protocol %s",
					 hostname, port, protocol );

	conn = (CRConnection *) crCalloc( sizeof(*conn) );
	if (!conn)
		return NULL;

	/* init the non-zero fields */
	conn->type               = CR_NO_CONNECTION; /* we don't know yet */
	conn->recv_credits       = CR_INITIAL_RECV_CREDITS;
	conn->hostname           = crStrdup( hostname );
	conn->port               = port;
	conn->mtu                = mtu;
	conn->buffer_size        = mtu;
	conn->endianness         = crDetermineEndianness();

#ifdef CHROMIUM_THREADSAFE
	crInitMutex(&conn->messageList.lock);
	crInitCondition(&conn->messageList.nonEmpty);
#endif

	/* now, just dispatch to the appropriate protocol's initialization functions. */
	InitConnection(conn, protocol, mtu);

	if (!crNetConnect( conn ))
	{
		crDebug("crNetConnectToServer() failed, freeing the connection");
		crFree( conn );
		return NULL;
	}

	crDebug( "Done connecting to %s (swapping=%d)", server, conn->swap );
#ifndef NDEBUG
	crNetDumpConnectionInfo(conn);
#endif
	return conn;
}
Esempio n. 5
0
static void
RENDER_APIENTRY renderspuWindowDestroy( GLint win )
{
    WindowInfo *window;
    GET_CONTEXT(pOldCtx);

    CRASSERT(win >= 0);
    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
    if (window) {
        crDebug("Render SPU: Destroy window (%d)", win);
        renderspu_SystemDestroyWindow( window );
        /* remove window info from hash table, and free it */
        crHashtableDelete(render_spu.windowTable, win, crFree);

        /* check if this window is bound to some ctx. Note: window pointer is already freed here */
        crHashtableWalk(render_spu.contextTable, renderspuCheckCurrentCtxWindowCB, window);

        /* restore current context */
        {
            GET_CONTEXT(pNewCtx);
            if (pNewCtx!=pOldCtx)
            {
                renderspuMakeCurrent(pOldCtx&&pOldCtx->currentWindow ? pOldCtx->currentWindow->id:0, 0,
                                     pOldCtx ? pOldCtx->id:0);
            }
        }
    }
    else {
        crDebug("Render SPU: Attempt to destroy invalid window (%d)", win);
    }
}
Esempio n. 6
0
static int renderspuAtiQuirk_Apply()
{
    char aBuf[4096];
    DWORD cbResult = 0;
    LPCSTR pszVal;
    int rc;

    crDebug("renderspuAtiQuirk_Apply..");

    rc = renderspuAtiQuirk_GetICDDriverList(aBuf, sizeof (aBuf), &cbResult);
    if (RT_FAILURE(rc))
    {
        crDebug("renderspuAtiQuirk_GetICDDriverList failed, rc(%d)", rc);
        return rc;
    }

    for (pszVal = renderspuRegMultiSzCurVal(aBuf);
            pszVal;
            pszVal = renderspuRegMultiSzNextVal(pszVal))
    {
        renderspuAtiQuirk_ApplyForModule(pszVal);
    }

    return VINF_SUCCESS;
}
Esempio n. 7
0
static int renderspuAtiQuirk_ApplyForModule(LPCSTR pszAtiDll)
{
    int rc;
    HMODULE hAtiDll;

    crDebug("renderspuAtiQuirk_ApplyForModule (%s)", pszAtiDll);

    hAtiDll = GetModuleHandleA(pszAtiDll);
    if (!hAtiDll)
    {
        crDebug("GetModuleHandle failed, %d", GetLastError());
        return VERR_NOT_FOUND;
    }

    rc = renderspuIatPatcherPatchFunction(hAtiDll, "user32.dll", "GetForegroundWindow", (void*)renderspuAtiQuirk_GetForegroundWindow);
    if (RT_FAILURE(rc))
    {
        crDebug("renderspuIatPatcherPatchFunction failed, %d", rc);
        return rc;
    }

    crDebug("renderspuAtiQuirk_ApplyForModule SUCCEEDED!");
    crInfo("ATI Fullscreen qwirk SUCCEEDED!");

    return VINF_SUCCESS;
}
Esempio n. 8
0
DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID)
{
    crDebug("crVBoxServerMapScreen(%i) [%i,%i:%u,%u %x]", sIndex, x, y, w, h, winID);

    if (sIndex<0 || sIndex>=cr_server.screenCount)
        return VERR_INVALID_PARAMETER;

    if (MAPPED(SCREEN(sIndex)) && SCREEN(sIndex).winID!=winID)
    {
        crDebug("Mapped screen[%i] is being remapped.", sIndex);
        crVBoxServerUnmapScreen(sIndex);
    }

    SCREEN(sIndex).winID = winID;
    SCREEN(sIndex).x = x;
    SCREEN(sIndex).y = y;
    SCREEN(sIndex).w = w;
    SCREEN(sIndex).h = h;

    renderspuSetWindowId(SCREEN(sIndex).winID);
    crHashtableWalk(cr_server.muralTable, crVBoxServerReparentMuralCB, &sIndex);
    renderspuSetWindowId(SCREEN(0).winID);

    crHashtableWalk(cr_server.muralTable, crVBoxServerCheckMuralCB, NULL);

#ifndef WINDOWS
    /*Restore FB content for clients, which have current window on a screen being remapped*/
    {
        GLint i;

        for (i = 0; i < cr_server.numClients; i++)
        {
            cr_server.curClient = cr_server.clients[i];
            if (cr_server.curClient->currentCtx
                && (cr_server.curClient->currentCtx->buffer.pFrontImg || cr_server.curClient->currentCtx->buffer.pBackImg)
                && cr_server.curClient->currentMural
                && cr_server.curClient->currentMural->screenId == sIndex
                && cr_server.curClient->currentCtx->buffer.storedHeight == h
                && cr_server.curClient->currentCtx->buffer.storedWidth == w)
            {
                int clientWindow = cr_server.curClient->currentWindow;
                int clientContext = cr_server.curClient->currentContextNumber;

                if (clientWindow && clientWindow != cr_server.currentWindow)
                {
                    crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
                }

                crStateApplyFBImage(cr_server.curClient->currentCtx);
            }
        }
        cr_server.curClient = NULL;
    }
#endif

    return VINF_SUCCESS;
}
Esempio n. 9
0
static void replicatespuDebugOpcodes( CRPackBuffer *pack )
{
	unsigned char *tmp;
	for (tmp = pack->opcode_start; tmp > pack->opcode_current; tmp--)
	{
		crDebug( "  %d (0x%p, 0x%p)", *tmp, tmp, pack->opcode_current );
	}
	crDebug( "\n" );
}
Esempio n. 10
0
static void
GetCursorPosition( const WindowInfo *window, int pos[2] )
{
	RECT rect;
	POINT point;
	GLint size[2], x, y;
	unsigned int NativeHeight, NativeWidth, ChromiumHeight, ChromiumWidth;
	float WidthRatio, HeightRatio;
	static int DebugFlag = 0;
	
	// apparently the "window" parameter passed to this 
	// function contains the native window information
	HWND NATIVEhwnd = WindowFromDC( window->drawable );	

	// get the native window's height and width
	stubGetWindowGeometry(window, &x, &y, &NativeWidth, &NativeHeight);

	// get the spu window's height and width
	stub.spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, window->spuWindow, GL_INT, 2, size);
	ChromiumWidth = size[0];
	ChromiumHeight = size[1];

	// get the ratio of the size of the native window to the cr window
	WidthRatio = (float)ChromiumWidth / (float)NativeWidth;
	HeightRatio = (float)ChromiumHeight / (float)NativeHeight;
	
	// output some debug information at the beginning
	if(DebugFlag)
	{
		DebugFlag = 0;
		crDebug("Native Window Handle = %d", NATIVEhwnd);
		crDebug("Native Width = %i", NativeWidth);
		crDebug("Native Height = %i", NativeHeight);
		crDebug("Chromium Width = %i", ChromiumWidth);
		crDebug("Chromium Height = %i", ChromiumHeight);
	}
		
	if (NATIVEhwnd) 
	{ 
		GetClientRect( NATIVEhwnd, &rect );
		GetCursorPos (&point);
		
		// make sure these coordinates are relative to the native window,
		// not the whole desktop
		ScreenToClient(NATIVEhwnd, &point);

		// calculate the new position of the virtual cursor
		pos[0] = (int)(point.x * WidthRatio);
		pos[1] = (int)((NativeHeight - point.y) * HeightRatio);
	}
	else 
	{
		pos[0] = 0;
		pos[1] = 0;
	}
}
Esempio n. 11
0
File: glx.c Progetto: alown/chromium
static int QueryVisBits(Display *dpy, XVisualInfo *vis)
{
	int visBits = 0;
	int foo, bar, return_val, value;
	unsigned int i;

	/* We can only query the OpenGL capabilities if we actually
	 * have a native OpenGL underneath us.  Without it, we can't
	 * get at all the actual OpenGL characteristics.
	 */
	if (!stub.haveNativeOpenGL) return 0;

	if (!stub.wsInterface.glXQueryExtension(dpy, &foo, &bar)) return 0;

	/* If we don't have the GLX_USE_GL attribute, we've failed. */
	return_val = stub.wsInterface.glXGetConfig(dpy, vis, GLX_USE_GL, &value);
	if (return_val) {
		crDebug("native glXGetConfig returned %d (%s) at %s line %d",
			return_val, glx_error_string(return_val), __FILE__, __LINE__);
		return 0;
	}
	if (value == 0) {
		crDebug("visual ID 0x%x doesn't support OpenGL at %s line %d",
			(int) vis->visual->visualid, __FILE__, __LINE__);
		return 0;
	}

	for (i = 0; i < sizeof(attrib_map)/sizeof(attrib_map[0]); i++) {
		return_val = stub.wsInterface.glXGetConfig(dpy, vis, attrib_map[i].gl_attrib, &value);
		if (return_val) {
			crDebug("native glXGetConfig(%s) returned %d (%s) at %s line %d",
				attrib_map[i].attrib_name, return_val, glx_error_string(return_val), __FILE__, __LINE__);
			return 0;
		}

		switch(attrib_map[i].test) {
			case TEST_TRUE:
				if (value)
					visBits |= attrib_map[i].match_vis_bits;
				break;

			case TEST_GREATER_0:
				if (value > 0)
					visBits |= attrib_map[i].match_vis_bits;
				break;

			default:
				crWarning("illegal attribute map test for %s at %s line %d", 
					attrib_map[i].attrib_name, __FILE__, __LINE__);
				return 0;
		}
	}

	return visBits;
}
Esempio n. 12
0
BOOL APIENTRY DrvValidateVersion(DWORD version)
{
    CR_DDI_PROLOGUE();
    if (stubInit()) {
        crDebug("DrvValidateVersion %x -> TRUE\n", version);
        return TRUE;
    }

    crDebug("DrvValidateVersion %x -> FALSE, going to use system default opengl32.dll\n", version);
    return FALSE;
}
Esempio n. 13
0
static GLboolean
getWindowGeometry(GLint *x, GLint *y, GLint *w, GLint *h)
{
	GLboolean retVal = GL_FALSE;
	ErrorFunc prev = XSetErrorHandler(handler);

	if (!windowtracker_spu.dpy) {
		windowtracker_spu.dpy = XOpenDisplay(windowtracker_spu.display);
	}
	if (windowtracker_spu.dpy) {
		Display *dpy = windowtracker_spu.dpy;
		if (!windowtracker_spu.win
				&& windowtracker_spu.window_title
				&& windowtracker_spu.window_title[0]) {
			crDebug("Window Tracker SPU: Looking for window %s",
							windowtracker_spu.window_title);
			windowtracker_spu.win = findWindowByTitle(dpy,
																								DefaultScreen(dpy),
																								DefaultRootWindow(dpy),
																								windowtracker_spu.window_title);
			if (windowtracker_spu.win) {
				crDebug("Window Tracker SPU: found window ID %u (0x%x)",
								(unsigned int) windowtracker_spu.win,
								(unsigned int) windowtracker_spu.win);
			}
		}
		if (windowtracker_spu.win) {
			Window root, child;
			unsigned int width, height, border, depth;
			if (XGetGeometry(windowtracker_spu.dpy, windowtracker_spu.win, &root,
											 x, y, &width, &height, &border, &depth)) {
				int rx, ry;
				if (XTranslateCoordinates(dpy,
																	windowtracker_spu.win,  /* from */
																	DefaultRootWindow(dpy), /* to */
																	*x, *y, &rx, &ry, &child)) {
					*x = rx;
					*y = ry;
				}
				*w = width;
				*h = height;
				retVal = GL_TRUE;
			}
		}
	}

	XSetErrorHandler(prev);

	if (ErrorCaught) {
		crError("Window Tracker SPU: invalid window handle.  Exiting.");
	}

	return retVal;
}
Esempio n. 14
0
void __attribute__ ((constructor)) vbox_install_into_mesa(void)
{
    {
#ifdef _X_ATTRIBUTE_PRINTF
        void (*pxf86Msg)(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
#else
        void (*pxf86Msg)(MessageType type, const char *format, ...) _printf_attribute(2,3);
#endif

        pxf86Msg = dlsym(RTLD_DEFAULT, "xf86Msg");
        if (pxf86Msg)
        {
            pxf86Msg(X_INFO, "Next line is added to allow vboxvideo_drv.so to appear as whitelisted driver\n");
            pxf86Msg(X_INFO, "The file referenced, is *NOT* loaded\n");
            pxf86Msg(X_INFO, "Loading %s/ati_drv.so\n", DRI_XORG_DRV_DIR);

            /* we're failing to proxy software dri driver calls for certain xservers, so just make sure we're unloaded for now */
            __driDriverExtensions[0] = NULL;
            return;
        }
    }

    if (!stubInit())
    {
        crDebug("vboxdriInitScreen: stubInit failed");
        return;
    }

    /* Load swrast_dri.so to proxy dri related calls there. */
    if (!vbox_load_sw_dri())
    {
        crDebug("vboxdriInitScreen: vbox_load_sw_dri failed...going to fail badly");
        return;
    }

    /* Handle gl api.
     * In the end application call would look like this:
     * app call glFoo->(mesa asm dispatch stub)->cr_glFoo(vbox asm dispatch stub)->SPU Foo function(packspuFoo or alike)
     * Note, we don't need to install extension functions via _glapi_add_dispatch, because we'd override glXGetProcAddress.
     */
    /* Mesa's dispatch table is different across library versions, have to modify mesa's table using offset info functions*/
    vboxPatchMesaGLAPITable();

    /* Handle glx api.
     * In the end application call would look like this:
     * app call glxFoo->(mesa asm dispatch stub patched with vbox_glXFoo:jmp glxim[Foo's index])->VBOXGLXTAG(glxFoo)
     */
    /* Fill structure used by our assembly stubs */
    vboxFillGLXAPITable(&glxim);
    /* Now patch functions exported by libGL.so */
    vboxPatchMesaExports();
}
Esempio n. 15
0
void
renderspu_SystemMakeCurrent(WindowInfo *window, GLint nativeWindow,
                            ContextInfo *context)
{
    Boolean result;
/*    DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->BltInfo.Base.id));*/

    CRASSERT(render_spu.ws.aglSetCurrentContext);
    //crDebug( "renderspu_SystemMakeCurrent( %x, %i, %x )", window, nativeWindow, context );

    nativeWindow = 0;

    if(window && context)
    {
        CRASSERT(window->window);
        CRASSERT(context->context);

        if(window->visual != context->visual)
        {
            crDebug("Render SPU (renderspu_SystemMakeCurrent): MakeCurrent visual mismatch (0x%x != 0x%x); remaking window.",
                    (uint)window->visual->visAttribs, (uint)context->visual->visAttribs);
            /*
             * XXX have to revisit this issue!!!
             *
             * But for now we destroy the current window
             * and re-create it with the context's visual abilities
             */
            renderspu_SystemDestroyWindow(window);
            renderspu_SystemCreateWindow(context->visual, window->visible,
                                         window);
        }

        /* This is the normal case: rendering to the render SPU's own window */
        result = renderspuWindowAttachContext(window, window->window,
                                              context);
        /* XXX this is a total hack to work around an NVIDIA driver bug */
        if(render_spu.self.GetFloatv && context->haveWindowPosARB)
        {
            GLfloat f[4];
            render_spu.self.GetFloatv(GL_CURRENT_RASTER_POSITION, f);
            if (!window->everCurrent || f[1] < 0.0)
            {
                crDebug("Render SPU (renderspu_SystemMakeCurrent): Resetting raster pos");
                render_spu.self.WindowPos2iARB(0, 0);
            }
        }
        /* Reapply the visible regions */
        renderspu_SystemWindowApplyVisibleRegion(window);
    }
    else
        renderspuWindowAttachContext (0, 0, 0);
}
Esempio n. 16
0
/* Either show or hide the render SPU's window. */
void renderspu_SystemShowWindow( WindowInfo *window, GLboolean showIt )
{
    if (showIt)
    {
        crDebug("SHOW renderspu_SystemShowWindow: %x", window->hWnd);
        ShowWindow( window->hWnd, SW_SHOWNORMAL );
    }
    else
    {
        crDebug("HIDE renderspu_SystemShowWindow: %x", window->hWnd);
        ShowWindow( window->hWnd, SW_HIDE );
    }
}
Esempio n. 17
0
void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierExecCR( GLuint name )
{
	CRServerBarrier *barrier;
#if DEBUG_BARRIERS
	char debug_buf[4096];
#endif

	if (cr_server.ignore_papi)
	{
		cr_server.head_spu->dispatch_table.BarrierExecCR( name );
		return;
	}

	barrier = (CRServerBarrier *) crHashtableSearch( cr_server.barriers, name );
	if ( barrier == NULL )
	{
		crError( "crServerDispatchBarrierExec: No such barrier: %d", name );
	}

#if DEBUG_BARRIERS
	sprintf( debug_buf, "BarrierExec( %d )", name );
	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
	sprintf( debug_buf, "num_waiting = %d", barrier->num_waiting );
	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
#endif

	barrier->waiting[barrier->num_waiting++] = cr_server.run_queue;

	cr_server.run_queue->blocked = 1;

	if ( barrier->num_waiting == barrier->count )
	{
		GLuint i;

		if (cr_server.debug_barriers)
			crDebug("crserver: BarrierExec(client=%p, id=%d, num_waiting=%d/%d) - release",
							cr_server.curClient, name, barrier->num_waiting,
							barrier->count);

		for ( i = 0; i < barrier->count; i++ )
		{
			barrier->waiting[i]->blocked = 0;
		}
		barrier->num_waiting = 0;
	}
	else if (cr_server.debug_barriers)
		crDebug("crserver: BarrierExec(client=%p, id=%d, num_waiting=%d/%d) - block",
						cr_server.curClient, name, barrier->num_waiting,
						barrier->count);

}
Esempio n. 18
0
void
PrintRegion(const char *s, const RegionPtr r)
{
	const BoxPtr rects = REGION_RECTS(r);
	GLint n = REGION_NUM_RECTS(r), i;
	crDebug("Region %s (data at %p rects at %p)",
					s, (void*) r->data, (void*) rects);
	if (n == 0)
		crDebug("  EMPTY");
	for (i = 0; i < n; i++) {
		crDebug("  Rect %d: %d, %d .. %d, %d", i, rects[i].x1, rects[i].y1,
						rects[i].x2, rects[i].y2);
	}
}
Esempio n. 19
0
static int
PrintQueue(void)
{
	RunQueue *q = cr_server.run_queue;
	int count = 0;
	crDebug("Queue entries:");
	while (q) {
		count++;
		crDebug("Entry: %p  client: %p", q, q->client);
		q = q->next;
		if (q == cr_server.run_queue)
			return count;
	}
	return count;
}
Esempio n. 20
0
/* returns the amt of pending data which was handled */ 
static int
crSDPUserbufRecv(CRConnection *conn, CRMessage *msg)
{
	unsigned long buf[2];
	int len;
  
	switch (msg->header.type)
	{
	case CR_MESSAGE_GATHER:
		/* grab the offset and the length */
		len = 2*sizeof(unsigned long);
		if (__sdp_read_exact(conn->sdp_socket, buf, len) <= 0)
		{
			__sdp_dead_connection( conn );
		}
		msg->gather.offset = buf[0];
		msg->gather.len = buf[1];
    
		/* read the rest into the userbuf */
		if (buf[0]+buf[1] > (unsigned long) conn->userbuf_len)
		{
			crDebug("userbuf for Gather Message is too small!");
			return len;
		}
		
		if (__sdp_read_exact(conn->sdp_socket, conn->userbuf+buf[0], buf[1]) <= 0)
		{
			__sdp_dead_connection( conn );
		}
		return len+buf[1];
    
	default:
		return 0;
	}
}
Esempio n. 21
0
HGLRC APIENTRY DrvCreateContext(HDC hdc)
{
    char dpyName[MAX_DPY_NAME];
    ContextInfo *context;

    CR_DDI_PROLOGUE();

    crDebug( "DrvCreateContext(0x%x) called.", hdc);

    stubInit();

    CRASSERT(stub.contextTable);

    sprintf(dpyName, "%d", hdc);
#ifndef VBOX_CROGL_USE_VBITS_SUPERSET
    if (stub.haveNativeOpenGL)
        desiredVisual |= ComputeVisBits( hdc );
#endif

    context = stubNewContext(dpyName, desiredVisual, UNDECIDED, 0
#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                             , NULL
#endif
                            );
    if (!context)
        return 0;

    return (HGLRC) context->id;
}
Esempio n. 22
0
bool DLM_APIENTRY
crDLMLoadState(CRDLM *dlm, PSSMHANDLE pSSM, SPUDispatchTable *dispatchTable)
{
    uint32_t cLists = 0;
    uint32_t i;
    int32_t  rc;
    bool     fSuccess = true;

    /* Get number of Display Lists assigned to current DLM context. */
    rc = SSMR3GetU32(pSSM, &cLists);
    if (RT_SUCCESS(rc))
    {
        crDebug("Restoring Display Lists: %u lists to restore.", cLists);

        for (i = 0; i < cLists; i++)
        {
            fSuccess = crDLMLoadList(dlm, pSSM, dispatchTable);
            if (!fSuccess)
                break;
        }
    }
    else
        crError("Restoring Display Lists: can't get number of lists.");

    return fSuccess;
}
Esempio n. 23
0
void
crSDPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
           unsigned int mtu )
{
	(void) mtu;
  
	cr_sdp.recv_list = rfl;
	cr_sdp.close_list = cfl;
	if ( cr_sdp.initialized )
	{
		return;
	}
  
	cr_sdp.initialized = 1;
	crDebug("Initializing SDP");
  
	cr_sdp.num_conns = 0;
	cr_sdp.conns     = NULL;
	
	cr_sdp.server_sock    = -1;
  
#ifdef CHROMIUM_THREADSAFE
	crInitMutex(&cr_sdp.mutex);
	crInitMutex(&cr_sdp.recvmutex);
#endif
	cr_sdp.bufpool = crBufferPoolInit(16);
}
void STATE_APIENTRY crStatePolygonStipple (PCRStateTracker pState, const GLubyte *p) 
{
    CRContext *g = GetCurrentContext(pState);
    CRPolygonState *poly = &(g->polygon);
        CRStateBits *sb = GetCurrentBits(pState);
    CRPolygonBits *pb = &(sb->polygon);

    if (g->current.inBeginEnd) 
    {
        crStateError(pState, __LINE__, __FILE__, GL_INVALID_OPERATION,
                "glPolygonStipple called in begin/end");
        return;
    }

    FLUSH();

    if (!p && !crStateIsBufferBound(pState, GL_PIXEL_UNPACK_BUFFER_ARB))
    {
        crDebug("Void pointer passed to PolygonStipple");
        return;
    }

    /** @todo track mask if buffer is bound?*/
    if (!crStateIsBufferBound(pState, GL_PIXEL_UNPACK_BUFFER_ARB))
    {
        crMemcpy((char*)poly->stipple, (char*)p, 128);
    }

    DIRTY(pb->dirty, g->neg_bitid);
    DIRTY(pb->stipple, g->neg_bitid);
}
Esempio n. 25
0
static void *
crSDPAlloc( CRConnection *conn )
{
  CRSDPBuffer *buf;
  
#ifdef CHROMIUM_THREADSAFE
  crLockMutex(&cr_sdp.mutex);
#endif
  
	buf = (CRSDPBuffer *) crBufferPoolPop( cr_sdp.bufpool, conn->buffer_size );
  
	if ( buf == NULL )
	{
		crDebug( "Buffer pool %p was empty, so I allocated %d bytes.\n\tI did so from the buffer: %p", 
             cr_sdp.bufpool,
             (unsigned int)sizeof(CRSDPBuffer) + conn->buffer_size, &cr_sdp.bufpool );
		buf = (CRSDPBuffer *) 
			crAlloc( sizeof(CRSDPBuffer) + conn->buffer_size );
		buf->magic = CR_SDP_BUFFER_MAGIC;
		buf->kind  = CRSDPMemory;
		buf->pad   = 0;
		buf->allocated = conn->buffer_size;
	}
	else {
		CRASSERT(buf->magic == CR_SDP_BUFFER_MAGIC);
	}

#ifdef CHROMIUM_THREADSAFE
	crUnlockMutex(&cr_sdp.mutex);
#endif
  
	return (void *)( buf + 1 );
}
Esempio n. 26
0
static void RENDER_APIENTRY
renderspuWindowShow( GLint win, GLint flag )
{
    WindowInfo *window;
    CRASSERT(win >= 0);
    window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
    if (window) {
        GLboolean visible;
        if (window->nativeWindow) {
            /* We're rendering back to the native app window instead of the
             * new window which we (the Render SPU) created earlier.
             * So, we never want to show the Render SPU's window.
             */
            flag = 0;
        }
        
        visible = !!flag;
        
        if (window->visible != visible)
        {
            renderspu_SystemShowWindow( window, visible );
            window->visible = visible;
        }
    }
    else {
        crDebug("Render SPU: Attempt to hide/show invalid window (%d)", win);
    }
}
Esempio n. 27
0
void crVBoxServerRemoveClient(uint32_t u32ClientID)
{
    CRClient *pClient=NULL;
    int32_t i;

    crDebug("crServer: RemoveClient u32ClientID=%d", u32ClientID);

    for (i = 0; i < cr_server.numClients; i++)
    {
        if (cr_server.clients[i] && cr_server.clients[i]->conn
            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
        {
            pClient = cr_server.clients[i];
            break;
        }
    }
    //if (!pClient) return VERR_INVALID_PARAMETER;
    if (!pClient)
    {
        crWarning("Invalid client id %u passed to crVBoxServerRemoveClient", u32ClientID);
        return;
    }

    /* Disconnect the client */
    pClient->conn->Disconnect(pClient->conn);

    /* Let server clear client from the queue */
    crServerDeleteClient(pClient);
}
Esempio n. 28
0
Display* stubGetWindowDisplay(WindowInfo *pWindow)
{
#if defined(CR_NEWWINTRACK)
    if ((NIL_RTTHREAD!=stub.hSyncThread) && (RTThreadNativeSelf()==RTThreadGetNative(stub.hSyncThread)))
    {
        if (pWindow && pWindow->dpy && !pWindow->syncDpy)
        {
            crDebug("going to XOpenDisplay(%s)", pWindow->dpyName);
            pWindow->syncDpy = XOpenDisplay(pWindow->dpyName);
            if (!pWindow->syncDpy)
            {
                crWarning("Failed to open display %s", pWindow->dpyName);
            }
            return pWindow->syncDpy;
        }
        else
        {
            return pWindow ? pWindow->syncDpy:NULL;
        }
    }
    else
#endif
    {
        return pWindow ? pWindow->dpy:NULL;
    }
}
Esempio n. 29
0
static SPUFunctions *
zpixSPUInit(int id, SPU * child, SPU * self,
						unsigned int context_id, unsigned int num_contexts)
{
	int i = 0;
	(void) self;
	(void) context_id;
	(void) num_contexts;

	self->privatePtr = (void *) &zpix_spu;

	crMemZero(&zpix_spu, sizeof(zpix_spu));

	zpix_spu.id = id;
	zpix_spu.has_child = 0;
	zpix_spu.server = NULL;
	if (child)
	{
		crSPUInitDispatchTable(&(zpix_spu.child));
		crSPUCopyDispatchTable(&(zpix_spu.child), &(child->dispatch_table));
		zpix_spu.has_child = 1;
	}
	crSPUInitDispatchTable(&(zpix_spu.super));
	crSPUCopyDispatchTable(&(zpix_spu.super),
												 &(self->superSPU->dispatch_table));
	zpixspuGatherConfiguration(&zpix_spu);

	/* non-zero instance initialization values */
	crDebug("Zpix SPU - verbose = %d", zpix_spu.verbose);
	zpix_spu.rXold = -1;
	zpix_spu.rYold = -1;

	/* set up shadow buffers */
	for (i = 0; i < FBNUM; i++)
	{
		zpix_spu.b.fbWidth[i] = -1;
		zpix_spu.b.fbHeight[i] = -1;
		zpix_spu.b.fbLen[i] = 0;
		zpix_spu.b.fBuf[i] = NULL;
		zpix_spu.b.dBuf[i] = NULL;
		zpix_spu.zBuf[i] = NULL;
	}

	/* allocate some initial server shadows */

	/*XXX this is just a convenience since storage amount is trivial */
#define DEFAULT_NUMBER_SERVER_SHADOWS 8

	zpix_spu.n_sb = DEFAULT_NUMBER_SERVER_SHADOWS - 1;
	zpix_spu.sb = (SBUFS *) crAlloc((zpix_spu.n_sb + 1) * sizeof(SBUFS));

	/* set highest valid index */

	for (i = 0; i < zpix_spu.n_sb; i++)
	{
		zpix_spu.sb[i] = zpix_spu.b;
	}

	return &zpix_functions;
}
Esempio n. 30
0
static void
*crFileAlloc( CRConnection *conn )
{
	CRFileBuffer *buf;

#ifdef CHROMIUM_THREADSAFE
	crLockMutex(&cr_file.mutex);
#endif

	buf  = (CRFileBuffer *) crBufferPoolPop( cr_file.bufpool, conn->buffer_size );

	if ( buf == NULL )
	{
		crDebug( "Buffer pool was empty, so I allocated %d bytes", 
			(int)(sizeof(CRFileBuffer) + conn->buffer_size) );
		buf = (CRFileBuffer *) 
			crAlloc( sizeof(CRFileBuffer) + conn->buffer_size );
		buf->magic = CR_FILE_BUFFER_MAGIC;
		buf->kind  = CRFileMemory;
		buf->pad   = 0;
		buf->allocated = conn->buffer_size;
	}

#ifdef CHROMIUM_THREADSAFE
	crUnlockMutex(&cr_file.mutex);
#endif

	return (void *)( buf + 1 );
}