]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_gecko.c
added prvm_offsets.h which centralizes field/global/function lookups for
[xonotic/darkplaces.git] / cl_gecko.c
index 72764efed822e3e256a99455b445e0a24934b14f..e66482d68730e060e31d3ca90098c4f062ca1c0f 100644 (file)
@@ -37,10 +37,10 @@ typedef struct OSGK_BaseObject_s OSGK_BaseObject;
 static int (*osgk_addref) (OSGK_BaseObject* obj);
 static int (*osgk_release) (OSGK_BaseObject* obj);
 
-static OSGK_INLINE int osgk_addref_real (OSGK_BaseObject* obj)
+/*static OSGK_INLINE int osgk_addref_real (OSGK_BaseObject* obj)
 {
   return osgk_addref (obj);
-}
+}*/
 
 static OSGK_INLINE int osgk_release_real (OSGK_BaseObject* obj)
 {
@@ -71,11 +71,11 @@ static OSGK_Embedding* (*osgk_embedding_create2) (
   unsigned int apiVer, OSGK_EmbeddingOptions* options, 
   OSGK_GeckoResult* geckoResult);
 
-static OSGK_INLINE OSGK_Embedding* osgk_embedding_create (
+/*static OSGK_INLINE OSGK_Embedding* osgk_embedding_create (
   OSGK_GeckoResult* geckoResult)
 {
   return osgk_embedding_create2 (OSGK_API_VERSION, 0, geckoResult);
-}
+}*/
 
 static OSGK_INLINE OSGK_Embedding* osgk_embedding_create_with_options (
   OSGK_EmbeddingOptions* options, OSGK_GeckoResult* geckoResult)
@@ -405,9 +405,7 @@ static clgecko_t * cl_gecko_findunusedinstance( void ) {
                        return instance;
                }
        }
-       if( developer.integer > 0 ) {
-               Con_Printf( "cl_gecko_findunusedinstance: out of geckos\n" );
-       }
+       Con_DPrintf( "cl_gecko_findunusedinstance: out of geckos\n" );
        return NULL;
 }
 
@@ -415,9 +413,7 @@ clgecko_t * CL_Gecko_FindBrowser( const char *name ) {
        int i;
 
        if( !name || !*name || strncmp( name, CLGECKOPREFIX, sizeof( CLGECKOPREFIX ) - 1 ) != 0 ) {
-               if( developer.integer > 0 ) {
-                       Con_Printf( "CL_Gecko_FindBrowser: Bad gecko texture name '%s'!\n", name );
-               }
+               Con_DPrintf( "CL_Gecko_FindBrowser: Bad gecko texture name '%s'!\n", name );
                return NULL;
        }
 
@@ -428,9 +424,7 @@ clgecko_t * CL_Gecko_FindBrowser( const char *name ) {
                }
        }
 
-       if( developer.integer > 0 ) {
-               Con_Printf( "CL_Gecko_FindBrowser: No browser named '%s'!\n", name );
-       }
+       Con_DPrintf( "CL_Gecko_FindBrowser: No browser named '%s'!\n", name );
 
        return NULL;
 }
@@ -441,7 +435,7 @@ static void cl_gecko_updatecallback( rtexture_t *texture, void* callbackData ) {
        if( instance->browser ) {
                // TODO: OSGK only supports BGRA right now
                TIMING_TIMESTATEMENT(data = osgk_browser_lock_data( instance->browser, NULL ));
-               R_UpdateTexture( texture, data, 0, 0, instance->width, instance->height );
+               R_UpdateTexture( texture, data, 0, 0, 0, instance->width, instance->height, 1 );
                osgk_browser_unlock_data( instance->browser, data );
        }
 }
@@ -449,7 +443,7 @@ static void cl_gecko_updatecallback( rtexture_t *texture, void* callbackData ) {
 static void cl_gecko_linktexture( clgecko_t *instance ) {
        // TODO: assert that instance->texture == NULL
        instance->texture = R_LoadTexture2D( cl_geckotexturepool, instance->name, 
-               instance->texWidth, instance->texHeight, NULL, TEXTYPE_BGRA, TEXF_ALWAYSPRECACHE | TEXF_ALPHA | TEXF_PERSISTENT, NULL );
+               instance->texWidth, instance->texHeight, NULL, TEXTYPE_BGRA, TEXF_ALPHA | TEXF_PERSISTENT, -1, NULL );
        R_MakeTextureDynamic( instance->texture, cl_gecko_updatecallback, instance );
        CL_LinkDynTexture( instance->name, instance->texture );
 }
@@ -531,14 +525,14 @@ static OSGK_ScriptResult dpGlobal_query (void* objTag, void* methTag,
   saveProg = prog;
   PRVM_SetProg(instance->ownerProg);
 
-  if (prog->funcoffsets.Gecko_Query)
+  if (PRVM_clientfunction(Gecko_Query))
   {
     OSGK_String* paramStr, *resultStr;
 
     if (!osgk_variant_get_string (strVal, &paramStr)) return srFailed;
         PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString (instance->name);
         PRVM_G_INT(OFS_PARM1) = PRVM_SetTempString (osgk_string_get (paramStr));
-    PRVM_ExecuteProgram(prog->funcoffsets.Gecko_Query,"Gecko_Query() required");
+    PRVM_ExecuteProgram(PRVM_clientfunction(Gecko_Query),"Gecko_Query() required");
     resultStr = osgk_string_create (PRVM_G_STRING (OFS_RETURN));
     *returnVal = osgk_variant_create_string (cl_geckoembedding, resultStr);
     osgk_release (resultStr);
@@ -551,7 +545,7 @@ static OSGK_ScriptResult dpGlobal_query (void* objTag, void* methTag,
   return result;
 }
 
-#if defined(WIN64)
+#if defined(_WIN64)
 # define XULRUNNER_DIR_SUFFIX  "win64"
 #elif defined(WIN32)
 # define XULRUNNER_DIR_SUFFIX  "win32"
@@ -570,9 +564,7 @@ static qboolean CL_Gecko_Embedding_Init (void)
 
        if( cl_geckoembedding != NULL ) return true;
 
-       if( developer.integer > 0 ) {
-               Con_Printf( "CL_Gecko_Embedding_Init: setting up gecko embedding\n" );
-       }
+       Con_DPrintf( "CL_Gecko_Embedding_Init: setting up gecko embedding\n" );
 
        options = osgk_embedding_options_create();
 #ifdef XULRUNNER_DIR_SUFFIX
@@ -589,9 +581,7 @@ static qboolean CL_Gecko_Embedding_Init (void)
                return false;
        } 
        
-       if( developer.integer > 0 ) {
-               Con_Printf( "CL_Gecko_Embedding_Init: Embedding set up correctly\n" );
-       }
+       Con_DPrintf( "CL_Gecko_Embedding_Init: Embedding set up correctly\n" );
 
        dpGlobalTemplate = osgk_sot_create( cl_geckoembedding, dpGlobal_create, NULL, NULL );
 
@@ -848,9 +838,7 @@ qboolean CL_Gecko_OpenLibrary (void)
 {
        const char* dllnames_gecko [] =
        {
-#if defined(WIN64)
-               "OffscreenGecko64.dll",
-#elif defined(WIN32)
+#if defined(WIN32)
                "OffscreenGecko.dll",
 #elif defined(MACOSX)
                "OffscreenGecko.dylib",
@@ -881,7 +869,7 @@ void CL_Gecko_Init( void )
        Cmd_AddCommand( "gecko_injecttext", cl_gecko_injecttext_f, "Injects text into a browser" );
        Cmd_AddCommand( "gecko_movecursor", gl_gecko_movecursor_f, "Move the cursor to a certain position" );
 
-       R_RegisterModule( "CL_Gecko", cl_gecko_start, cl_gecko_shutdown, cl_gecko_newmap );
+       R_RegisterModule( "CL_Gecko", cl_gecko_start, cl_gecko_shutdown, cl_gecko_newmap, NULL, NULL );
 }
 
 void CL_Gecko_NavigateToURI( clgecko_t *instance, const char *URI ) {