Continue working on QNX GF and Photon support.
authorMike Gorchak <lestat@i.com.ua>
Wed, 10 Jun 2009 08:09:04 +0000
changeset 318544d5474c2c8a
parent 3184 68d3b48a6002
child 3186 51750b7a966f
Continue working on QNX GF and Photon support.
src/video/photon/SDL_photon.c
src/video/photon/SDL_photon_pixelfmt.c
src/video/qnxgf/SDL_gf_pixelfmt.c
src/video/qnxgf/SDL_qnxgf.c
     1.1 --- a/src/video/photon/SDL_photon.c	Wed Jun 10 05:56:36 2009 +0000
     1.2 +++ b/src/video/photon/SDL_photon.c	Wed Jun 10 08:09:04 2009 +0000
     1.3 @@ -61,7 +61,7 @@
     1.4  #endif /* SDL_VIDEO_OPENGL_ES */
     1.5  
     1.6  /* Low level device graphics driver names, which they are reporting */
     1.7 -Photon_DeviceCaps photon_devicename[] = {
     1.8 +static const Photon_DeviceCaps photon_devicename[] = {
     1.9      /* ATI Rage 128 graphics driver (devg-ati_rage128)      */
    1.10      {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
    1.11      ,
    1.12 @@ -384,19 +384,47 @@
    1.13          /* Query photon about graphics hardware caps and current video mode */
    1.14          status = PgGetGraphicsHWCaps(&hwcaps);
    1.15          if (status != 0) {
    1.16 -            SDL_SetError("Photon: Can't get graphics capabilities");
    1.17 -            SDL_free(didata->cursor);
    1.18 -            SDL_free(didata);
    1.19 -            return -1;
    1.20 -        }
    1.21 +            PhRect_t extent;
    1.22 +            PdOffscreenContext_t* curctx;
    1.23  
    1.24 -        /* Get current video mode details */
    1.25 -        status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
    1.26 -        if (status != 0) {
    1.27 -            SDL_SetError("Photon: Can't get current video mode information");
    1.28 -            SDL_free(didata->cursor);
    1.29 -            SDL_free(didata);
    1.30 -            return -1;
    1.31 +            /* If error happens, this also could mean, that photon is working */
    1.32 +            /* under custom (not listed by photon) video mode                 */
    1.33 +            status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
    1.34 +            if (status != 0) {
    1.35 +                SDL_SetError("Photon: Can't get graphics driver region");
    1.36 +                SDL_free(didata->cursor);
    1.37 +                SDL_free(didata);
    1.38 +                return -1;
    1.39 +            }
    1.40 +            modeinfo.width=extent.lr.x+1;
    1.41 +            modeinfo.height=extent.lr.y+1;
    1.42 +            /* Hardcode 60Hz, as the base refresh rate frequency */
    1.43 +            hwcaps.current_rrate=60;
    1.44 +            /* Clear current video driver name, no way to get it somehow */
    1.45 +            hwcaps.chip_name[0]=0x00;
    1.46 +
    1.47 +            /* Create offscreen context from video memory, which is currently */
    1.48 +            /* displayed on the screen                                        */
    1.49 +            curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
    1.50 +            if (curctx==NULL)
    1.51 +            {
    1.52 +                SDL_SetError("Photon: Can't get display area capabilities");
    1.53 +                SDL_free(didata->cursor);
    1.54 +                SDL_free(didata);
    1.55 +                return -1;
    1.56 +            }
    1.57 +            /* Retrieve current bpp */
    1.58 +            modeinfo.type=curctx->format;
    1.59 +            PhDCRelease(curctx);
    1.60 +        } else {
    1.61 +            /* Get current video mode details */
    1.62 +            status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
    1.63 +            if (status != 0) {
    1.64 +                SDL_SetError("Photon: Can't get current video mode information");
    1.65 +                SDL_free(didata->cursor);
    1.66 +                SDL_free(didata);
    1.67 +                return -1;
    1.68 +            }
    1.69          }
    1.70  
    1.71          /* Setup current desktop mode for SDL */
    1.72 @@ -527,6 +555,27 @@
    1.73                  mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
    1.74                  mode.driverdata = NULL;
    1.75                  SDL_AddDisplayMode(_this->current_display, &mode);
    1.76 +
    1.77 +                /* If mode is RGBA8888, add the same mode as RGBx888 */
    1.78 +                if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
    1.79 +                    mode.w = modeinfo.width;
    1.80 +                    mode.h = modeinfo.height;
    1.81 +                    mode.refresh_rate = modeinfo.refresh_rates[jt];
    1.82 +                    mode.format = SDL_PIXELFORMAT_RGB888;
    1.83 +                    mode.driverdata = NULL;
    1.84 +                    SDL_AddDisplayMode(_this->current_display, &mode);
    1.85 +                }
    1.86 +
    1.87 +                /* If mode is RGBA1555, add the same mode as RGBx555 */
    1.88 +                if (modeinfo.type == Pg_IMAGE_DIRECT_1555) {
    1.89 +                    mode.w = modeinfo.width;
    1.90 +                    mode.h = modeinfo.height;
    1.91 +                    mode.refresh_rate = modeinfo.refresh_rates[jt];
    1.92 +                    mode.format = SDL_PIXELFORMAT_RGB555;
    1.93 +                    mode.driverdata = NULL;
    1.94 +                    SDL_AddDisplayMode(_this->current_display, &mode);
    1.95 +                }
    1.96 +
    1.97                  jt++;
    1.98              } else {
    1.99                  break;
   1.100 @@ -1453,7 +1502,7 @@
   1.101      if (configs == 0) {
   1.102          int32_t it;
   1.103          int32_t jt;
   1.104 -        GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
   1.105 +        static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
   1.106  
   1.107          for (it = 0; it < 4; it++) {
   1.108              for (jt = 16; jt >= 0; jt--) {
     2.1 --- a/src/video/photon/SDL_photon_pixelfmt.c	Wed Jun 10 05:56:36 2009 +0000
     2.2 +++ b/src/video/photon/SDL_photon_pixelfmt.c	Wed Jun 10 08:09:04 2009 +0000
     2.3 @@ -72,6 +72,11 @@
     2.4              return 15;
     2.5          }
     2.6          break;
     2.7 +    case SDL_PIXELFORMAT_RGB555:
     2.8 +        {
     2.9 +            return 15;
    2.10 +        }
    2.11 +        break;
    2.12      case SDL_PIXELFORMAT_ABGR1555:
    2.13          {
    2.14              return 15;
    2.15 @@ -82,9 +87,14 @@
    2.16              return 16;
    2.17          }
    2.18          break;
    2.19 +    case SDL_PIXELFORMAT_RGB24:
    2.20 +        {
    2.21 +            return 24;
    2.22 +        }
    2.23 +        break;
    2.24      case SDL_PIXELFORMAT_RGB888:
    2.25          {
    2.26 -            return 24;
    2.27 +            return 32;
    2.28          }
    2.29          break;
    2.30      case SDL_PIXELFORMAT_BGRA8888:
    2.31 @@ -133,12 +143,12 @@
    2.32          break;
    2.33      case Pg_IMAGE_DIRECT_8888:
    2.34          {
    2.35 -            return SDL_PIXELFORMAT_BGRA8888;
    2.36 +            return SDL_PIXELFORMAT_ARGB8888;
    2.37          }
    2.38          break;
    2.39      case Pg_IMAGE_DIRECT_888:
    2.40          {
    2.41 -            return SDL_PIXELFORMAT_RGB888;
    2.42 +            return SDL_PIXELFORMAT_RGB24;
    2.43          }
    2.44          break;
    2.45      case Pg_IMAGE_DIRECT_565:
    2.46 @@ -170,12 +180,12 @@
    2.47              return Pg_IMAGE_PALETTE_BYTE;
    2.48          }
    2.49          break;
    2.50 -    case SDL_PIXELFORMAT_BGRA8888:
    2.51 +    case SDL_PIXELFORMAT_ARGB8888:
    2.52          {
    2.53              return Pg_IMAGE_DIRECT_8888;
    2.54          }
    2.55          break;
    2.56 -    case SDL_PIXELFORMAT_RGB888:
    2.57 +    case SDL_PIXELFORMAT_RGB24:
    2.58          {
    2.59              return Pg_IMAGE_DIRECT_888;
    2.60          }
    2.61 @@ -190,6 +200,11 @@
    2.62              return Pg_IMAGE_DIRECT_1555;
    2.63          }
    2.64          break;
    2.65 +    case SDL_PIXELFORMAT_RGB555:
    2.66 +        {
    2.67 +            return Pg_IMAGE_DIRECT_555;
    2.68 +        }
    2.69 +        break;
    2.70      }
    2.71  
    2.72      return 0;
     3.1 --- a/src/video/qnxgf/SDL_gf_pixelfmt.c	Wed Jun 10 05:56:36 2009 +0000
     3.2 +++ b/src/video/qnxgf/SDL_gf_pixelfmt.c	Wed Jun 10 08:09:04 2009 +0000
     3.3 @@ -41,8 +41,9 @@
     3.4              return GF_FORMAT_PACK_ARGB1555;
     3.5          }
     3.6          break;
     3.7 -    case SDL_PIXELFORMAT_ABGR1555:
     3.8 +    case SDL_PIXELFORMAT_RGB555:
     3.9          {
    3.10 +            /* RGB555 is the same as ARGB1555, but alpha is ignored */
    3.11              return GF_FORMAT_PACK_ARGB1555;
    3.12          }
    3.13          break;
    3.14 @@ -51,18 +52,33 @@
    3.15              return GF_FORMAT_PACK_RGB565;
    3.16          }
    3.17          break;
    3.18 -    case SDL_PIXELFORMAT_RGB888:
    3.19 +    case SDL_PIXELFORMAT_BGR565:
    3.20          {
    3.21 +            return GF_FORMAT_PKBE_RGB565;
    3.22 +        }
    3.23 +        break;
    3.24 +    case SDL_PIXELFORMAT_RGB24:
    3.25 +        {
    3.26 +            /* GF has wrong components order */
    3.27              return GF_FORMAT_BGR888;
    3.28          }
    3.29          break;
    3.30 -    case SDL_PIXELFORMAT_BGRA8888:
    3.31 +    case SDL_PIXELFORMAT_RGB888:
    3.32          {
    3.33 +            /* The same format as ARGB8888, but with alpha ignored */
    3.34 +            /* and GF has wrong components order                   */
    3.35              return GF_FORMAT_BGRA8888;
    3.36          }
    3.37          break;
    3.38      case SDL_PIXELFORMAT_ARGB8888:
    3.39          {
    3.40 +            /* GF has wrong components order */
    3.41 +            return GF_FORMAT_BGRA8888;
    3.42 +        }
    3.43 +        break;
    3.44 +    case SDL_PIXELFORMAT_BGRA8888:
    3.45 +        {
    3.46 +            /* GF has wrong components order */
    3.47              return GF_FORMAT_ARGB8888;
    3.48          }
    3.49          break;
    3.50 @@ -110,14 +126,9 @@
    3.51              return SDL_PIXELFORMAT_ARGB1555;
    3.52          }
    3.53          break;
    3.54 -    case GF_FORMAT_PKBE_ARGB1555:
    3.55 -        {
    3.56 -            return SDL_PIXELFORMAT_ABGR1555;
    3.57 -        }
    3.58 -        break;
    3.59      case GF_FORMAT_PKBE_RGB565:
    3.60          {
    3.61 -            return SDL_PIXELFORMAT_RGB565;
    3.62 +            return SDL_PIXELFORMAT_BGR565;
    3.63          }
    3.64          break;
    3.65      case GF_FORMAT_PKLE_RGB565:
    3.66 @@ -132,20 +143,22 @@
    3.67          break;
    3.68      case GF_FORMAT_BGR888:
    3.69          {
    3.70 -            return SDL_PIXELFORMAT_RGB888;
    3.71 +            /* GF has wrong components order */
    3.72 +            return SDL_PIXELFORMAT_RGB24;
    3.73          }
    3.74          break;
    3.75      case GF_FORMAT_BGRA8888:
    3.76          {
    3.77 -            return SDL_PIXELFORMAT_BGRA8888;
    3.78 +            /* GF has wrong components order */
    3.79 +            return SDL_PIXELFORMAT_ARGB8888;
    3.80          }
    3.81          break;
    3.82      case GF_FORMAT_ARGB8888:
    3.83          {
    3.84 -            return SDL_PIXELFORMAT_ARGB8888;
    3.85 +            /* GF has wrong components order */
    3.86 +            return SDL_PIXELFORMAT_BGRA8888;
    3.87          }
    3.88          break;
    3.89 -
    3.90      case GF_FORMAT_PLANAR_YUV_YV12:
    3.91          {
    3.92              return SDL_PIXELFORMAT_YV12;
     4.1 --- a/src/video/qnxgf/SDL_qnxgf.c	Wed Jun 10 05:56:36 2009 +0000
     4.2 +++ b/src/video/qnxgf/SDL_qnxgf.c	Wed Jun 10 08:09:04 2009 +0000
     4.3 @@ -47,7 +47,7 @@
     4.4  /* but some drivers are not. Later we can distinguish one driver from another */
     4.5  /* Feel free to add any new custom graphics mode                              */
     4.6  /******************************************************************************/
     4.7 -static SDL_DisplayMode generic_mode[] = {
     4.8 +static const SDL_DisplayMode generic_mode[] = {
     4.9      {0, 320, 200, 70, NULL},    /* 320x200 modes are 70Hz and 85Hz          */
    4.10      {0, 320, 200, 85, NULL},
    4.11      {0, 320, 240, 70, NULL},    /* 320x240 modes are 70Hz and 85Hz          */
    4.12 @@ -100,7 +100,7 @@
    4.13  };
    4.14  
    4.15  /* Low level device graphics driver names, which they are reporting */
    4.16 -GF_DeviceCaps gf_devicename[] = {
    4.17 +static const GF_DeviceCaps gf_devicename[] = {
    4.18      /* ATI Rage 128 graphics driver (devg-ati_rage128)      */
    4.19      {"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
    4.20       SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
    4.21 @@ -644,6 +644,25 @@
    4.22                      mode.driverdata = NULL;
    4.23                      SDL_AddDisplayMode(_this->current_display, &mode);
    4.24  
    4.25 +                    /* If mode is RGBA8888, add the same mode as RGBx888 */
    4.26 +                    if (modeinfo.primary_format==GF_FORMAT_BGRA8888) {
    4.27 +                        mode.w = generic_mode[jt].w;
    4.28 +                        mode.h = generic_mode[jt].h;
    4.29 +                        mode.refresh_rate = generic_mode[jt].refresh_rate;
    4.30 +                        mode.format = SDL_PIXELFORMAT_RGB888;
    4.31 +                        mode.driverdata = NULL;
    4.32 +                        SDL_AddDisplayMode(_this->current_display, &mode);
    4.33 +                    }
    4.34 +                    /* If mode is RGBA1555, add the same mode as RGBx555 */
    4.35 +                    if (modeinfo.primary_format==GF_FORMAT_PACK_ARGB1555) {
    4.36 +                        mode.w = generic_mode[jt].w;
    4.37 +                        mode.h = generic_mode[jt].h;
    4.38 +                        mode.refresh_rate = generic_mode[jt].refresh_rate;
    4.39 +                        mode.format = SDL_PIXELFORMAT_RGB555;
    4.40 +                        mode.driverdata = NULL;
    4.41 +                        SDL_AddDisplayMode(_this->current_display, &mode);
    4.42 +                    }
    4.43 +
    4.44                      jt++;
    4.45                  } while (1);
    4.46              } else {
    4.47 @@ -660,6 +679,26 @@
    4.48                                                          primary_format);
    4.49                          mode.driverdata = NULL;
    4.50                          SDL_AddDisplayMode(_this->current_display, &mode);
    4.51 +
    4.52 +                        /* If mode is RGBA8888, add the same mode as RGBx888 */
    4.53 +                        if (modeinfo.primary_format==GF_FORMAT_BGRA8888) {
    4.54 +                            mode.w = modeinfo.xres;
    4.55 +                            mode.h = modeinfo.yres;
    4.56 +                            mode.refresh_rate = modeinfo.refresh[jt];
    4.57 +                            mode.format = SDL_PIXELFORMAT_RGB888;
    4.58 +                            mode.driverdata = NULL;
    4.59 +                            SDL_AddDisplayMode(_this->current_display, &mode);
    4.60 +                        }
    4.61 +                        /* If mode is RGBA1555, add the same mode as RGBx555 */
    4.62 +                        if (modeinfo.primary_format==GF_FORMAT_PACK_ARGB1555) {
    4.63 +                            mode.w = modeinfo.xres;
    4.64 +                            mode.h = modeinfo.yres;
    4.65 +                            mode.refresh_rate = modeinfo.refresh[jt];
    4.66 +                            mode.format = SDL_PIXELFORMAT_RGB555;
    4.67 +                            mode.driverdata = NULL;
    4.68 +                            SDL_AddDisplayMode(_this->current_display, &mode);
    4.69 +                        }
    4.70 +
    4.71                          jt++;
    4.72                      } else {
    4.73                          break;
    4.74 @@ -823,7 +862,7 @@
    4.75      /* Mark main display layer is attached */
    4.76      didata->layer_attached = SDL_TRUE;
    4.77  
    4.78 -    /* Set layer source and destination viewport */
    4.79 +    /* Set layer source and destination viewports */
    4.80      gf_layer_set_src_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1);
    4.81      gf_layer_set_dst_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1);
    4.82  
    4.83 @@ -1464,7 +1503,7 @@
    4.84      if (configs == 0) {
    4.85          int32_t it;
    4.86          int32_t jt;
    4.87 -        GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
    4.88 +        static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
    4.89  
    4.90          for (it = 0; it < 4; it++) {
    4.91              for (jt = 16; jt >= 0; jt--) {
    4.92 @@ -1520,7 +1559,7 @@
    4.93                                      SDL_VIDEO_GF_OPENGLES_CONFS, &configs);
    4.94                  if (status != EGL_TRUE) {
    4.95                      SDL_SetError
    4.96 -                        ("Photon: Can't find closest configuration for OpenGL ES");
    4.97 +                        ("GF: Can't find closest configuration for OpenGL ES");
    4.98                      return NULL;
    4.99                  }
   4.100                  if (configs != 0) {
   4.101 @@ -1535,7 +1574,7 @@
   4.102          /* No available configs */
   4.103          if (configs == 0) {
   4.104              SDL_SetError
   4.105 -                ("Photon: Can't find any configuration for OpenGL ES");
   4.106 +                ("GF: Can't find any configuration for OpenGL ES");
   4.107              return NULL;
   4.108          }
   4.109      }