]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_gecko.c
Gecko: load OffscreenGecko dynamically
[xonotic/darkplaces.git] / cl_gecko.c
index d9950a14b07d5767331ce4a876506822761ccfa8..3819aea2ee2255f1a7556d37e1b3e164ffe7b051 100644 (file)
-#ifdef SUPPORT_GECKO\r
+/* --- 8< --- 8< ---   OffscreenGecko headers   --- >8 --- >8 --- */\r
 \r
-// includes everything!\r
-#include <OffscreenGecko/browser.h>\r
+/* OffscreenGecko/defs.h */\r
 \r
-#ifdef _MSC_VER\r
-#      pragma comment( lib, "OffscreenGecko" )\r
+#define OSGK_CLASSTYPE_DEF     struct\r
+#define OSGK_CLASSTYPE_REF     struct\r
+\r
+#include <assert.h>\r
+#define OSGK_ASSERT(x) assert(x)\r
+\r
+typedef unsigned int OSGK_GeckoResult;\r
+\r
+#if defined(__cplusplus) || defined(__GNUC__)\r
+#  define OSGK_INLINE  inline\r
+#elif defined(_MSC_VER)\r
+#  define OSGK_INLINE  __inline\r
+#else\r
+#  define OSGK_INLINE\r
 #endif\r
 \r
+/* OffscreenGecko/baseobj.h */\r
+\r
+struct OSGK_BaseObject_s\r
+{\r
+  int reserved;\r
+};\r
+typedef struct OSGK_BaseObject_s OSGK_BaseObject;\r
+\r
+#define OSGK_DERIVEDTYPE(T)           \\r
+  typedef struct T ## _s {            \\r
+    OSGK_BaseObject baseobj;          \\r
+  } T\r
+\r
+static int (*osgk_addref) (OSGK_BaseObject* obj);\r
+static int (*osgk_release) (OSGK_BaseObject* obj);\r
+\r
+static OSGK_INLINE int osgk_addref_real (OSGK_BaseObject* obj)\r
+{\r
+  return osgk_addref (obj);\r
+}\r
+\r
+static OSGK_INLINE int osgk_release_real (OSGK_BaseObject* obj)\r
+{\r
+  return osgk_release (obj);\r
+}\r
+\r
+#define osgk_addref(obj)    osgk_addref_real (&((obj)->baseobj))\r
+#define osgk_release(obj)   osgk_release_real (&((obj)->baseobj))\r
+\r
+/* OffscreenGecko/embedding.h */\r
+\r
+OSGK_DERIVEDTYPE(OSGK_EmbeddingOptions);\r
+\r
+static OSGK_EmbeddingOptions* (*osgk_embedding_options_create) (void);\r
+static void (*osgk_embedding_options_add_search_path) (\r
+  OSGK_EmbeddingOptions* options, const char* path);\r
+/*static void (*osgk_embedding_options_add_components_path) (\r
+  OSGK_EmbeddingOptions* options, const char* path);*/\r
+static void (*osgk_embedding_options_set_profile_dir) (\r
+  OSGK_EmbeddingOptions* options, const char* profileDir,\r
+  const char* localProfileDir);\r
+\r
+OSGK_DERIVEDTYPE(OSGK_Embedding);\r
+\r
+#define OSGK_API_VERSION    1\r
+\r
+static OSGK_Embedding* (*osgk_embedding_create2) (\r
+  unsigned int apiVer, OSGK_EmbeddingOptions* options, \r
+  OSGK_GeckoResult* geckoResult);\r
+\r
+static OSGK_INLINE OSGK_Embedding* osgk_embedding_create (\r
+  OSGK_GeckoResult* geckoResult)\r
+{\r
+  return osgk_embedding_create2 (OSGK_API_VERSION, 0, geckoResult);\r
+}\r
+\r
+static OSGK_INLINE OSGK_Embedding* osgk_embedding_create_with_options (\r
+  OSGK_EmbeddingOptions* options, OSGK_GeckoResult* geckoResult)\r
+{\r
+  return osgk_embedding_create2 (OSGK_API_VERSION, options, geckoResult);\r
+}\r
+\r
+/*static OSGK_GeckoMem* (*osgk_embedding_get_gecko_mem) (\r
+  OSGK_Embedding* embedding);*/\r
+\r
+/*static OSGK_ComponentMgr* (*osgk_embedding_get_component_mgr) (\r
+  OSGK_Embedding* embedding);*/\r
+\r
+/*OSGK_CLASSTYPE_DEF nsIComponentManager;\r
+OSGK_CLASSTYPE_DEF nsIComponentRegistrar;\r
+OSGK_CLASSTYPE_DEF nsIServiceManager;*/\r
+\r
+/*static OSGK_CLASSTYPE_REF nsIComponentManager* \r
+(*osgk_embedding_get_gecko_component_manager) (OSGK_Embedding* embedding);*/\r
+/*static OSGK_CLASSTYPE_REF nsIComponentRegistrar* \r
+(*osgk_embedding_get_gecko_component_registrar) (OSGK_Embedding* embedding);*/\r
+/*static OSGK_CLASSTYPE_REF nsIServiceManager* \r
+(*osgk_embedding_get_gecko_service_manager) (OSGK_Embedding* embedding);*/\r
+\r
+enum\r
+{\r
+  jsgPrivileged = 1\r
+};\r
+/*static int (*osgk_embedding_register_js_global) (\r
+  OSGK_Embedding* embedding, const char* name, const char* contractID,\r
+  unsigned int flags, OSGK_String** previousContract,\r
+  OSGK_GeckoResult* geckoResult);*/\r
+\r
+/*static void (*osgk_embedding_clear_focus*) (OSGK_Embedding* embedding);*/\r
+/*void (*osgk_embedding_set_auto_focus) (OSGK_Embedding* embedding, int autoFocus);*/\r
+/*static int (*osgk_embedding_get_auto_focus) (OSGK_Embedding* embedding);*/\r
+\r
+/* OffscreenGecko/browser.h */\r
+OSGK_DERIVEDTYPE(OSGK_Browser);\r
+\r
+static OSGK_Browser* (*osgk_browser_create) (\r
+  OSGK_Embedding* embedding, int width, int height);\r
+static void (*osgk_browser_navigate) (OSGK_Browser* browser,\r
+  const char* uri);\r
+\r
+static int (*osgk_browser_query_dirty) (OSGK_Browser* browser);\r
+static const unsigned char* (*osgk_browser_lock_data) (\r
+  OSGK_Browser* browser, int* isDirty);\r
+static void (*osgk_browser_unlock_data) (OSGK_Browser* browser,\r
+  const unsigned char* data);\r
+\r
+typedef enum OSGK_MouseButton\r
+{\r
+  mbLeft, \r
+  mbRight, \r
+  mbMiddle\r
+} OSGK_MouseButton;\r
+\r
+typedef enum OSGK_MouseButtonEventType\r
+{\r
+  meDown,\r
+  meUp,\r
+  meDoubleClick\r
+} OSGK_MouseButtonEventType;\r
+\r
+static void (*osgk_browser_event_mouse_move) (\r
+  OSGK_Browser* browser, int x, int y);\r
+static void (*osgk_browser_event_mouse_button) (\r
+  OSGK_Browser* browser, OSGK_MouseButton button, \r
+  OSGK_MouseButtonEventType eventType);\r
+\r
+typedef enum OSGK_WheelAxis\r
+{\r
+  waVertical,\r
+  waHorizontal\r
+} OSGK_WheelAxis;\r
+\r
+typedef enum OSGK_WheelDirection\r
+{\r
+  wdPositive,\r
+  wdNegative,\r
+  wdPositivePage,\r
+  wdNegativePage\r
+} OSGK_WheelDirection;\r
+\r
+static void (*osgk_browser_event_mouse_wheel) (\r
+  OSGK_Browser* browser, OSGK_WheelAxis axis, \r
+  OSGK_WheelDirection direction);\r
+\r
+typedef enum OSGK_KeyboardEventType\r
+{\r
+  keDown,\r
+  keUp,\r
+  kePress\r
+} OSGK_KeyboardEventType;\r
+\r
+enum\r
+{\r
+  OSGKKey_First = 0x110000,\r
+\r
+  OSGKKey_Backspace = OSGKKey_First,\r
+  OSGKKey_Tab,\r
+  OSGKKey_Return,\r
+  OSGKKey_Shift,\r
+  OSGKKey_Control,\r
+  OSGKKey_Alt,\r
+  OSGKKey_CapsLock,\r
+  OSGKKey_Escape,\r
+  OSGKKey_Space,\r
+  OSGKKey_PageUp,\r
+  OSGKKey_PageDown,\r
+  OSGKKey_End,\r
+  OSGKKey_Home,\r
+  OSGKKey_Left,\r
+  OSGKKey_Up,\r
+  OSGKKey_Right,\r
+  OSGKKey_Down,\r
+  OSGKKey_Insert,\r
+  OSGKKey_Delete,\r
+  OSGKKey_F1,\r
+  OSGKKey_F2,\r
+  OSGKKey_F3,\r
+  OSGKKey_F4,\r
+  OSGKKey_F5,\r
+  OSGKKey_F6,\r
+  OSGKKey_F7,\r
+  OSGKKey_F8,\r
+  OSGKKey_F9,\r
+  OSGKKey_F10,\r
+  OSGKKey_F11,\r
+  OSGKKey_F12,\r
+  OSGKKey_NumLock,\r
+  OSGKKey_ScrollLock,\r
+  OSGKKey_Meta\r
+};\r
+\r
+static int (*osgk_browser_event_key) (\r
+  OSGK_Browser* browser, unsigned int key,\r
+  OSGK_KeyboardEventType eventType);\r
+\r
+typedef enum OSGK_AntiAliasType\r
+{\r
+  aaNone,\r
+  aaGray,\r
+  aaSubpixel\r
+} OSGK_AntiAliasType;\r
+\r
+/*static void (*osgk_browser_set_antialias) (\r
+  OSGK_Browser* browser, OSGK_AntiAliasType aaType);*/\r
+/*static OSGK_AntiAliasType (*osgk_browser_get_antialias) (OSGK_Browser* browser);*/\r
+\r
+/*static void (*osgk_browser_focus) (OSGK_Browser* browser);*/\r
+\r
+static void (*osgk_browser_resize) (OSGK_Browser* browser,\r
+  int width, int height);\r
+\r
+/* --- >8 --- >8 --- End OffscreenGecko headers --- 8< --- 8< --- */\r
+\r
 #include "quakedef.h"\r
 #include "cl_dyntexture.h"\r
 #include "cl_gecko.h"\r
 #include "timing.h"\r
 \r
-#define DEFAULT_SIZE     512\r
+#define DEFAULT_GECKO_SIZE       512\r
 \r
 static rtexturepool_t *cl_geckotexturepool;\r
 static OSGK_Embedding *cl_geckoembedding;\r
@@ -22,14 +246,16 @@ struct clgecko_s {
        char name[ MAX_QPATH + 32 ];\r
 \r
        OSGK_Browser *browser;\r
-       int w, h;\r
-       int texW, texH;\r
+       int width, height;\r
+       int texWidth, texHeight;\r
        \r
        rtexture_t *texture;\r
 };\r
 \r
 static clgecko_t cl_geckoinstances[ MAX_GECKO_INSTANCES ];\r
 \r
+static dllhandle_t osgk_dll = NULL;\r
+\r
 static clgecko_t * cl_gecko_findunusedinstance( void ) {\r
        int i;\r
        for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {\r
@@ -38,6 +264,9 @@ static clgecko_t * cl_gecko_findunusedinstance( void ) {
                        return instance;\r
                }\r
        }\r
+       if( developer.integer > 0 ) {\r
+               Con_Printf( "cl_gecko_findunusedinstance: out of geckos\n" );\r
+       }\r
        return NULL;\r
 }\r
 \r
@@ -58,6 +287,10 @@ clgecko_t * CL_Gecko_FindBrowser( const char *name ) {
                }\r
        }\r
 \r
+       if( developer.integer > 0 ) {\r
+               Con_Printf( "CL_Gecko_FindBrowser: No browser named '%s'!\n", name );\r
+       }\r
+\r
        return NULL;\r
 }\r
 \r
@@ -66,7 +299,7 @@ static void cl_gecko_updatecallback( rtexture_t *texture, clgecko_t *instance )
        if( instance->browser ) {\r
                // TODO: OSGK only supports BGRA right now\r
                TIMING_TIMESTATEMENT(data = osgk_browser_lock_data( instance->browser, NULL ));\r
-               R_UpdateTexture( texture, data, 0, 0, instance->w, instance->h);\r
+               R_UpdateTexture( texture, data, 0, 0, instance->width, instance->height );\r
                osgk_browser_unlock_data( instance->browser, data );\r
        }\r
 }\r
@@ -74,7 +307,7 @@ static void cl_gecko_updatecallback( rtexture_t *texture, clgecko_t *instance )
 static void cl_gecko_linktexture( clgecko_t *instance ) {\r
        // TODO: assert that instance->texture == NULL\r
        instance->texture = R_LoadTexture2D( cl_geckotexturepool, instance->name, \r
-               instance->texW, instance->texH, NULL, TEXTYPE_BGRA, TEXF_ALPHA | TEXF_PERSISTENT, NULL );\r
+               instance->texWidth, instance->texHeight, NULL, TEXTYPE_BGRA, TEXF_ALPHA | TEXF_PERSISTENT, NULL );\r
        R_MakeTextureDynamic( instance->texture, cl_gecko_updatecallback, instance );\r
        CL_LinkDynTexture( instance->name, instance->texture );\r
 }\r
@@ -87,32 +320,89 @@ static void cl_gecko_unlinktexture( clgecko_t *instance ) {
        }\r
 }\r
 \r
+void CL_Gecko_Resize( clgecko_t *instance, int width, int height ) {\r
+       int newWidth, newHeight;\r
+\r
+       // early out if bad parameters are passed (no resize to a texture size bigger than the original texture size)\r
+       if( !instance || !instance->browser) {\r
+               return;\r
+       }\r
+\r
+       newWidth = CeilPowerOf2( width );\r
+       newHeight = CeilPowerOf2( height );\r
+       if ((newWidth != instance->texWidth) || (newHeight != instance->texHeight))\r
+       {\r
+               cl_gecko_unlinktexture( instance );\r
+               instance->texWidth = newWidth;\r
+               instance->texHeight = newHeight;\r
+               cl_gecko_linktexture( instance );\r
+       }\r
+       else\r
+       {\r
+               /* The gecko area will only cover a part of the texture; to avoid\r
+               'old' pixels bleeding in at the border clear the texture. */\r
+               R_ClearTexture( instance->texture );\r
+       }\r
+\r
+       osgk_browser_resize( instance->browser, width, height);\r
+       instance->width = width;\r
+       instance->height = height;\r
+}\r
+\r
+void CL_Gecko_GetTextureExtent( clgecko_t *instance, float* pwidth, float* pheight )\r
+{\r
+       if( !instance || !instance->browser ) {\r
+               return;\r
+       }\r
+\r
+       *pwidth = (float)instance->width / instance->texWidth;\r
+       *pheight = (float)instance->height / instance->texHeight;\r
+}\r
+\r
+\r
 clgecko_t * CL_Gecko_CreateBrowser( const char *name ) {\r
+       clgecko_t *instance;\r
+\r
+       if (!osgk_dll) return NULL;\r
+\r
        // TODO: verify that we dont use a name twice\r
-       clgecko_t *instance = cl_gecko_findunusedinstance();\r
+       instance = cl_gecko_findunusedinstance();\r
        // TODO: assert != NULL\r
        \r
        if( cl_geckoembedding == NULL ) {\r
-               OSGK_EmbeddingOptions *options = osgk_embedding_options_create();\r
+               char profile_path [MAX_OSPATH];\r
+               OSGK_GeckoResult grc;\r
+               OSGK_EmbeddingOptions *options;\r
+\r
+               if( developer.integer > 0 ) {\r
+                       Con_Printf( "CL_Gecko_CreateBrowser: setting up gecko embedding\n" );\r
+               }\r
+\r
+               options = osgk_embedding_options_create();\r
                osgk_embedding_options_add_search_path( options, "./xulrunner/" );\r
-               cl_geckoembedding = osgk_embedding_create_with_options( options, NULL );\r
+               dpsnprintf (profile_path, sizeof (profile_path), "%s/xulrunner_profile/", fs_gamedir);\r
+               osgk_embedding_options_set_profile_dir( options, profile_path, 0 );\r
+               cl_geckoembedding = osgk_embedding_create_with_options( options, &grc );\r
                osgk_release( options );\r
                \r
                if( cl_geckoembedding == NULL ) {\r
-                       Con_Printf( "CL_Gecko_CreateBrowser: Couldn't retrieve gecko embedding object!\n" );\r
+                       Con_Printf( "CL_Gecko_CreateBrowser: Couldn't retrieve gecko embedding object (%.8x)!\n", grc );\r
                        return NULL;\r
+               } else if( developer.integer > 0 ) {\r
+                       Con_Printf( "CL_Gecko_CreateBrowser: Embedding set up correctly\n" );\r
                }\r
        }\r
 \r
        instance->active = true;\r
        strlcpy( instance->name, name, sizeof( instance->name ) );\r
-       instance->browser = osgk_browser_create( cl_geckoembedding, DEFAULT_SIZE, DEFAULT_SIZE );\r
+       instance->browser = osgk_browser_create( cl_geckoembedding, DEFAULT_GECKO_SIZE, DEFAULT_GECKO_SIZE );\r
+       if( instance->browser == NULL ) {\r
+               Con_Printf( "CL_Gecko_CreateBrowser: Browser object creation failed!\n" );\r
+       }\r
        // TODO: assert != NULL\r
 \r
-       instance->texW = DEFAULT_SIZE;\r
-       instance->texH = DEFAULT_SIZE;\r
-       instance->w = DEFAULT_SIZE;\r
-       instance->h = DEFAULT_SIZE;\r
+       instance->width = instance->texWidth = DEFAULT_GECKO_SIZE;\r
+       instance->height = instance->texHeight = DEFAULT_GECKO_SIZE;\r
        cl_gecko_linktexture( instance );\r
 \r
        return instance;\r
@@ -132,6 +422,7 @@ void CL_Gecko_DestroyBrowser( clgecko_t *instance ) {
 \r
 void CL_Gecko_Frame( void ) {\r
        int i;\r
+       // FIXME: track cl_numgeckoinstances to avoid scanning the entire array?\r
        for( i = 0 ; i < MAX_GECKO_INSTANCES ; i++ ) {\r
                clgecko_t *instance = &cl_geckoinstances[ i ];\r
                if( instance->active ) {\r
@@ -187,6 +478,11 @@ void CL_Gecko_Shutdown( void ) {
            osgk_release( cl_geckoembedding );\r
            cl_geckoembedding = NULL;\r
        }\r
+\r
+       if (osgk_dll != NULL)\r
+       {\r
+           Sys_UnloadLibrary (&osgk_dll);\r
+       }\r
 }\r
 \r
 static void cl_gecko_create_f( void ) {\r
@@ -279,18 +575,87 @@ static void cl_gecko_injecttext_f( void ) {
        }\r
 }\r
 \r
+static void gl_gecko_movecursor_f( void ) {\r
+       char name[MAX_QPATH];\r
+       float x, y;\r
+\r
+       if (Cmd_Argc() != 4)\r
+       {\r
+               Con_Print("usage: gecko_movecursor <name> <x> <y>\nmove the cursor to a certain position\n");\r
+               return;\r
+       }\r
+\r
+       // TODO: use snprintf instead\r
+       sprintf(name, CLGECKOPREFIX "%s", Cmd_Argv(1));\r
+       x = atof( Cmd_Argv( 2 ) );\r
+       y = atof( Cmd_Argv( 3 ) );\r
+\r
+       CL_Gecko_Event_CursorMove( CL_Gecko_FindBrowser( name ), x, y );\r
+}\r
+\r
+#undef osgk_addref\r
+#undef osgk_release\r
+\r
+static const dllfunction_t osgkFuncs[] =\r
+{\r
+       {"osgk_addref",                             (void **) &osgk_addref},\r
+       {"osgk_release",                            (void **) &osgk_release},\r
+       {"osgk_embedding_create2",                  (void **) &osgk_embedding_create2},\r
+       {"osgk_embedding_options_create",           (void **) &osgk_embedding_options_create},\r
+       {"osgk_embedding_options_add_search_path",  (void **) &osgk_embedding_options_add_search_path},\r
+       {"osgk_embedding_options_set_profile_dir",  (void **) &osgk_embedding_options_set_profile_dir},\r
+       {"osgk_browser_create",                     (void **) &osgk_browser_create},\r
+       {"osgk_browser_query_dirty",                (void **) &osgk_browser_query_dirty},\r
+       {"osgk_browser_navigate",                   (void **) &osgk_browser_navigate},\r
+       {"osgk_browser_lock_data",                  (void **) &osgk_browser_lock_data},\r
+       {"osgk_browser_unlock_data",                (void **) &osgk_browser_unlock_data},\r
+       {"osgk_browser_resize",                     (void **) &osgk_browser_resize},\r
+       {"osgk_browser_event_mouse_move",           (void **) &osgk_browser_event_mouse_move},\r
+       {"osgk_browser_event_mouse_button",         (void **) &osgk_browser_event_mouse_button},\r
+       {"osgk_browser_event_mouse_wheel",          (void **) &osgk_browser_event_mouse_wheel},\r
+       {"osgk_browser_event_key",                  (void **) &osgk_browser_event_key},\r
+       {NULL, NULL}\r
+};\r
+\r
 void CL_Gecko_Init( void )\r
 {\r
+       const char* dllnames [] =\r
+       {\r
+       #if defined(WIN64)\r
+               "OffscreenGecko64.dll",\r
+       #elif defined(WIN32)\r
+               "OffscreenGecko.dll",\r
+       #elif defined(MACOSX)\r
+               "OffscreenGecko.dylib",\r
+       #else\r
+               "OffscreenGecko.so",\r
+       #endif\r
+               NULL\r
+       };\r
+       \r
+       if (!osgk_dll)\r
+       {\r
+               if (! Sys_LoadLibrary (dllnames, &osgk_dll, osgkFuncs))\r
+               {\r
+                       Con_Printf ("Could not load OffscreenGecko, Gecko support unavailable\n");\r
+               }\r
+       }\r
+\r
        Cmd_AddCommand( "gecko_create", cl_gecko_create_f, "Create a gecko browser instance" );\r
        Cmd_AddCommand( "gecko_destroy", cl_gecko_destroy_f, "Destroy a gecko browser instance" );\r
        Cmd_AddCommand( "gecko_navigate", cl_gecko_navigate_f, "Navigate a gecko browser to a URI" );\r
        Cmd_AddCommand( "gecko_injecttext", cl_gecko_injecttext_f, "Injects text into a browser" );\r
+       Cmd_AddCommand( "gecko_movecursor", gl_gecko_movecursor_f, "Move the cursor to a certain position" );\r
 \r
        R_RegisterModule( "CL_Gecko", cl_gecko_start, cl_gecko_shutdown, cl_gecko_newmap );\r
 }\r
 \r
 void CL_Gecko_NavigateToURI( clgecko_t *instance, const char *URI ) {\r
-       if( instance && instance->active ) {\r
+       if( !instance || !instance->browser ) {\r
+               return;\r
+       }\r
+\r
+       if( instance->active ) {\r
                osgk_browser_navigate( instance->browser, URI );\r
        }\r
 }\r
@@ -303,8 +668,8 @@ void CL_Gecko_Event_CursorMove( clgecko_t *instance, float x, float y ) {
                return;\r
        }\r
 \r
-       mappedx = x * instance->w;\r
-       mappedy = y * instance->h;\r
+       mappedx = x * instance->width;\r
+       mappedy = y * instance->height;\r
        osgk_browser_event_mouse_move( instance->browser, mappedx, mappedy );\r
 }\r
 \r
@@ -412,47 +777,12 @@ qboolean CL_Gecko_Event_Key( clgecko_t *instance, int key, clgecko_buttoneventty
 \r
                osgk_browser_event_mouse_button( instance->browser, mappedbutton, mappedtype );\r
                return true;\r
+       } else if( K_MWHEELUP <= key && key <= K_MWHEELDOWN ) {\r
+               if( eventtype == CLG_BET_DOWN )\r
+                       osgk_browser_event_mouse_wheel( instance->browser, \r
+                               waVertical, (key == K_MWHEELUP) ? wdNegative : wdPositive );\r
+               return true;\r
        }\r
        // TODO: error?\r
        return false;\r
 }\r
-\r
-void CL_Gecko_Resize( clgecko_t *instance, int w, int h ) {\r
-       int newW, newH;\r
-\r
-       if( !instance || !instance->browser ) {\r
-               return;\r
-       }\r
-\r
-       newW = 1; while( newW < w ) newW *= 2;\r
-       newH = 1; while( newH < h ) newH *= 2;\r
-       if ((newW != instance->texW) || (newH != instance->texH))\r
-       {\r
-         cl_gecko_unlinktexture( instance );\r
-         instance->texW = newW;\r
-         instance->texH = newH;\r
-         cl_gecko_linktexture( instance );\r
-       }\r
-       else\r
-       {\r
-         /* The gecko area will only cover a part of the texture; to avoid\r
-            'old' pixels bleeding in at the border clear the texture. */\r
-         R_ClearTexture( instance->texture );\r
-       }\r
-\r
-       osgk_browser_resize( instance->browser, w, h);\r
-       instance->w = w;\r
-       instance->h = h;\r
-}\r
-\r
-void CL_Gecko_GetTextureExtent( clgecko_t *instance, float* u, float* v )\r
-{\r
-       if( !instance || !instance->browser ) {\r
-               return;\r
-       }\r
-\r
-       *u = (float)instance->w / instance->texW;\r
-       *v = (float)instance->h / instance->texH;\r
-}\r
-\r
-#endif\r