~ubuntu-branches/ubuntu/utopic/cairo-dock/utopic

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-opengl.c

Tags: upstream-2.3.0~1
ImportĀ upstreamĀ versionĀ 2.3.0~1

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <GL/glu.h>
31
31
 
32
32
#include "cairo-dock-log.h"
 
33
#include "cairo-dock-icon-facility.h"
33
34
#include "cairo-dock-dock-factory.h"
34
 
#include "cairo-dock-load.h"
35
 
#include "cairo-dock-internal-icons.h"
36
 
#include "cairo-dock-internal-system.h"
 
35
#include "cairo-dock-desklet-factory.h"  // cairo_dock_begin_draw_icon
 
36
#include "cairo-dock-image-buffer.h"
37
37
#include "cairo-dock-draw-opengl.h"
38
38
#include "cairo-dock-X-manager.h"
39
39
#include "cairo-dock-opengl.h"
124
124
        return pVisInfo;
125
125
}
126
126
 
127
 
gboolean cairo_dock_initialize_opengl_backend (gboolean bToggleIndirectRendering, gboolean bForceOpenGL)  // taken from a MacSlow's exemple.
 
127
gboolean cairo_dock_initialize_opengl_backend (gboolean bForceOpenGL)  // taken from a MacSlow's exemple.
128
128
{
129
129
        memset (&g_openglConfig, 0, sizeof (CairoDockGLConfig));
130
130
        g_bUseOpenGL = FALSE;
131
 
        g_openglConfig.bHasBeenForced = bForceOpenGL;
132
131
        gboolean bStencilBufferAvailable, bAlphaAvailable;
133
132
        Display *XDisplay = gdk_x11_get_default_xdisplay ();
134
133
        
258
257
        if (pVisInfo != NULL)
259
258
        {
260
259
                cd_message ("ok, got a visual");
 
260
                /// The function below sets a new colormap on the root window, and Qt doesn't like that !...
 
261
                /// link with https://bugzilla.redhat.com/show_bug.cgi?id=440340 ?
261
262
                g_openglConfig.pGlConfig = gdk_x11_gl_config_new_from_visualid (pVisInfo->visualid);
 
263
                /// as a workaround, we remove this colormap.
 
264
                Display *dpy = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
 
265
                XDeleteProperty ( dpy, DefaultRootWindow (dpy), XInternAtom (dpy, "RGB_DEFAULT_MAP", 0) ); // (XA_RGB_DEFAULT_MAP)
262
266
                XFree (pVisInfo);
263
267
        }
264
268
        g_return_val_if_fail (g_openglConfig.pGlConfig != NULL, FALSE);
265
269
        g_bUseOpenGL = TRUE;
266
270
        
267
271
        //\_________________ On regarde si le rendu doit etre indirect ou pas.
268
 
        g_openglConfig.bIndirectRendering = bToggleIndirectRendering;
269
272
        /**if (glXQueryVersion(XDisplay, &g_openglConfig.iGlxMajor, &g_openglConfig.iGlxMinor) == False)
270
273
        {
271
274
                cd_warning ("GLX not available !\nFear the worst !");
304
307
}
305
308
 
306
309
 
 
310
void cairo_dock_force_indirect_rendering (void)
 
311
{
 
312
        if (g_bUseOpenGL)
 
313
                g_openglConfig.bIndirectRendering = TRUE;
 
314
}
 
315
 
307
316
 
308
317
void cairo_dock_create_icon_fbo (void)  // it has been found that you get a speed boost if your textures is the same size and you use 1 FBO for them. => c'est le cas general dans le dock. Du coup on est gagnant a ne faire qu'un seul FBO pour toutes les icones.
309
318
{
315
324
        
316
325
        int iWidth = 0, iHeight = 0;
317
326
        int i;
318
 
        for (i = 0; i < CAIRO_DOCK_NB_TYPES; i += 2)
 
327
        for (i = 0; i < CAIRO_DOCK_NB_GROUPS; i += 2)
319
328
        {
320
 
                iWidth = MAX (iWidth, myIcons.tIconAuthorizedWidth[i]);
321
 
                iHeight = MAX (iHeight, myIcons.tIconAuthorizedHeight[i]);
 
329
                iWidth = MAX (iWidth, myIconsParam.tIconAuthorizedWidth[i]);
 
330
                iHeight = MAX (iHeight, myIconsParam.tIconAuthorizedHeight[i]);
322
331
        }
323
332
        if (iWidth == 0)
324
333
                iWidth = 48;
325
334
        if (iHeight == 0)
326
335
                iHeight = 48;
327
 
        iWidth *= (1 + myIcons.fAmplitude);
328
 
        iHeight *= (1 + myIcons.fAmplitude);
 
336
        iWidth *= (1 + myIconsParam.fAmplitude);
 
337
        iHeight *= (1 + myIconsParam.fAmplitude);
329
338
        g_openglConfig.iRedirectedTexture = cairo_dock_load_texture_from_raw_data (NULL, iWidth, iHeight);
330
339
}
331
340
 
395
404
                return ;
396
405
        int iWidth = 0, iHeight = 0;
397
406
        int i;
398
 
        for (i = 0; i < CAIRO_DOCK_NB_TYPES; i += 2)
 
407
        for (i = 0; i < CAIRO_DOCK_NB_GROUPS; i += 2)
399
408
        {
400
 
                iWidth = MAX (iWidth, myIcons.tIconAuthorizedWidth[i]);
401
 
                iHeight = MAX (iHeight, myIcons.tIconAuthorizedHeight[i]);
 
409
                iWidth = MAX (iWidth, myIconsParam.tIconAuthorizedWidth[i]);
 
410
                iHeight = MAX (iHeight, myIconsParam.tIconAuthorizedHeight[i]);
402
411
        }
403
412
        if (iWidth == 0)
404
413
                iWidth = 48;
405
414
        if (iHeight == 0)
406
415
                iHeight = 48;
407
 
        iWidth *= (1 + myIcons.fAmplitude);
408
 
        iHeight *= (1 + myIcons.fAmplitude);
 
416
        iWidth *= (1 + myIconsParam.fAmplitude);
 
417
        iHeight *= (1 + myIconsParam.fAmplitude);
409
418
        
410
419
        cd_debug ("%s (%dx%d)", __func__, iWidth, iHeight);
411
420
        if (g_openglConfig.iIconPbufferWidth != iWidth || g_openglConfig.iIconPbufferHeight != iHeight)
696
705
 
697
706
void cairo_dock_apply_desktop_background_opengl (CairoContainer *pContainer)
698
707
{
699
 
        if (! mySystem.bUseFakeTransparency || ! g_pFakeTransparencyDesktopBg || g_pFakeTransparencyDesktopBg->iTexture == 0)
 
708
        if (! myContainersParam.bUseFakeTransparency || ! g_pFakeTransparencyDesktopBg || g_pFakeTransparencyDesktopBg->iTexture == 0)
700
709
                return ;
701
710
        
702
711
        glPushMatrix ();
755
764
        static gboolean bChecked=FALSE;
756
765
        if (bChecked)
757
766
                return;
 
767
        //g_print ("*** Check for cairo-desklet\n");
758
768
        GdkGLContext* pGlContext = gtk_widget_get_gl_context (pWidget);
759
769
        GdkGLDrawable* pGlDrawable = gtk_widget_get_gl_drawable (pWidget);
760
770
        if (!gdk_gl_drawable_gl_begin (pGlDrawable, pGlContext))