~darkxst/ubuntu/raring/cogl/lp1163025

« back to all changes in this revision

Viewing changes to cogl/winsys/cogl-winsys-wgl.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-13 19:11:11 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120313191111-3hgk529qkh9m6uk2
Tags: 1.9.8-0ubuntu1
* New upstream release (LP: #941617)
* Updated symbols & library name for soname update
* debian/control.in: Bump minimum glib to 2.28
* debian/patches/02_disable_armv5t_specific_optimization.patch: Disabled

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
#include "cogl.h"
34
34
 
 
35
#include "cogl-util.h"
35
36
#include "cogl-winsys-private.h"
36
37
#include "cogl-context-private.h"
37
38
#include "cogl-framebuffer.h"
 
39
#include "cogl-onscreen-private.h"
38
40
#include "cogl-swap-chain-private.h"
39
41
#include "cogl-renderer-private.h"
40
42
#include "cogl-display-private.h"
87
89
 
88
90
  HDC client_dc;
89
91
 
90
 
  gboolean swap_throttled;
91
92
} CoglOnscreenWgl;
92
93
 
93
94
/* Define a set of arrays containing the functions required from GL
316
317
}
317
318
 
318
319
static int
319
 
choose_pixel_format (HDC dc, PIXELFORMATDESCRIPTOR *pfd)
 
320
choose_pixel_format (CoglFramebufferConfig *config,
 
321
                     HDC dc, PIXELFORMATDESCRIPTOR *pfd)
320
322
{
321
323
  int i, num_formats, best_pf = 0;
322
324
  PIXELFORMATDESCRIPTOR best_pfd;
323
325
 
324
326
  num_formats = DescribePixelFormat (dc, 0, sizeof (best_pfd), NULL);
325
327
 
 
328
  /* XXX: currently we don't support multisampling on windows... */
 
329
  if (config->samples_per_pixel)
 
330
    return best_pf;
 
331
 
326
332
  for (i = 1; i <= num_formats; i++)
327
333
    {
328
334
      memset (pfd, 0, sizeof (*pfd));
341
347
             already found */
342
348
          (best_pf == 0 || pixel_format_is_better (&best_pfd, pfd)))
343
349
        {
 
350
          if (config->swap_chain->has_alpha && pfd->cAlphaBits == 0)
 
351
            continue;
 
352
          if (config->need_stencil && pfd->cStencilBits == 0)
 
353
            continue;
 
354
 
344
355
          best_pf = i;
345
356
          best_pfd = *pfd;
346
357
        }
409
420
{
410
421
  CoglDisplayWgl *wgl_display = display->winsys;
411
422
 
412
 
  g_return_val_if_fail (wgl_display->wgl_context == NULL, FALSE);
 
423
  _COGL_RETURN_VAL_IF_FAIL (wgl_display->wgl_context == NULL, FALSE);
413
424
 
414
425
  /* Cogl assumes that there is always a GL context selected; in order
415
426
   * to make sure that a WGL context exists and is made current, we
445
456
 
446
457
      wgl_display->dummy_dc = GetDC (wgl_display->dummy_hwnd);
447
458
 
448
 
      pf = choose_pixel_format (wgl_display->dummy_dc, &pfd);
 
459
      pf = choose_pixel_format (&display->onscreen_template->config,
 
460
                                wgl_display->dummy_dc, &pfd);
449
461
 
450
462
      if (pf == 0 || !SetPixelFormat (wgl_display->dummy_dc, pf, &pfd))
451
463
        {
484
496
{
485
497
  CoglDisplayWgl *wgl_display = display->winsys;
486
498
 
487
 
  g_return_if_fail (wgl_display != NULL);
 
499
  _COGL_RETURN_IF_FAIL (wgl_display != NULL);
488
500
 
489
501
  if (wgl_display->wgl_context)
490
502
    {
512
524
{
513
525
  CoglDisplayWgl *wgl_display;
514
526
 
515
 
  g_return_val_if_fail (display->winsys == NULL, FALSE);
 
527
  _COGL_RETURN_VAL_IF_FAIL (display->winsys == NULL, FALSE);
516
528
 
517
529
  wgl_display = g_slice_new0 (CoglDisplayWgl);
518
530
  display->winsys = wgl_display;
573
585
  const char *wgl_extensions;
574
586
  int i;
575
587
 
576
 
  g_return_val_if_fail (wgl_display->wgl_context, FALSE);
 
588
  _COGL_RETURN_VAL_IF_FAIL (wgl_display->wgl_context, FALSE);
577
589
 
578
590
  if (!_cogl_context_update_features (context, error))
579
591
    return FALSE;
581
593
  memset (context->winsys_features, 0, sizeof (context->winsys_features));
582
594
 
583
595
  context->feature_flags |= COGL_FEATURE_ONSCREEN_MULTIPLE;
 
596
  COGL_FLAGS_SET (context->features,
 
597
                  COGL_FEATURE_ID_ONSCREEN_MULTIPLE, TRUE);
584
598
  COGL_FLAGS_SET (context->winsys_features,
585
599
                  COGL_WINSYS_FEATURE_MULTIPLE_ONSCREEN,
586
600
                  TRUE);
636
650
static void
637
651
_cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
638
652
{
 
653
  CoglFramebuffer *fb;
639
654
  CoglContext *context;
640
655
  CoglContextWgl *wgl_context;
641
656
  CoglDisplayWgl *wgl_display;
646
661
     NULL, but this isn't really going to work because before checking
647
662
     whether onscreen == NULL it reads the pointer to get the
648
663
     context */
649
 
  g_return_if_fail (onscreen != NULL);
 
664
  _COGL_RETURN_IF_FAIL (onscreen != NULL);
650
665
 
651
 
  context = COGL_FRAMEBUFFER (onscreen)->context;
 
666
  fb = COGL_FRAMEBUFFER (onscreen);
 
667
  context = fb->context;
652
668
  wgl_context = context->winsys;
653
669
  wgl_display = context->display->winsys;
654
670
  wgl_onscreen = onscreen->winsys;
665
681
   */
666
682
  if (wgl_renderer->pf_wglSwapInterval)
667
683
    {
668
 
      if (onscreen->swap_throttled)
 
684
      if (fb->config.swap_throttled)
669
685
        wgl_renderer->pf_wglSwapInterval (1);
670
686
      else
671
687
        wgl_renderer->pf_wglSwapInterval (0);
720
736
  int pf;
721
737
  HWND hwnd;
722
738
 
723
 
  g_return_val_if_fail (wgl_display->wgl_context, FALSE);
 
739
  _COGL_RETURN_VAL_IF_FAIL (wgl_display->wgl_context, FALSE);
724
740
 
725
741
  /* XXX: Note we ignore the user's original width/height when given a
726
742
   * foreign window. */
784
800
  wgl_onscreen->client_dc = GetDC (hwnd);
785
801
 
786
802
  /* Use the same pixel format as the dummy DC from the renderer */
787
 
  pf = GetPixelFormat (wgl_display->dummy_dc);
788
 
  DescribePixelFormat (wgl_display->dummy_dc, pf, sizeof (pfd), &pfd);
789
 
  if (!SetPixelFormat (wgl_onscreen->client_dc, pf, &pfd))
 
803
  pf = choose_pixel_format (&framebuffer->config,
 
804
                            wgl_onscreen->client_dc, &pfd);
 
805
 
 
806
  if (pf == 0 || !SetPixelFormat (wgl_onscreen->client_dc, pf, &pfd))
790
807
    {
791
808
      g_set_error (error, COGL_WINSYS_ERROR,
792
809
                   COGL_WINSYS_ERROR_CREATE_ONSCREEN,