Commit 53036179 authored by Mike Gorchak's avatar Mike Gorchak

Continue working on 2D support for Photon/QNX.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404047
parent 345698f1
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#if defined(SDL_VIDEO_OPENGL_ES) #if defined(SDL_VIDEO_OPENGL_ES)
#include "../qnxgf/SDL_gf_pixelfmt.h" #include "../qnxgf/SDL_gf_pixelfmt.h"
/* If GF driver is not compiled in, include some of usefull functions */ /* If GF driver is not compiled in, include some of usefull functions */
#if !defined(SDL_VIDEO_DRIVER_QNXGF) #if !defined(SDL_VIDEO_DRIVER_QNXGF)
#include "../qnxgf/SDL_gf_pixelfmt.c" #include "../qnxgf/SDL_gf_pixelfmt.c"
#endif /* SDL_VIDEO_DRIVER_QNXGF */ #endif /* SDL_VIDEO_DRIVER_QNXGF */
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#if defined(SDL_VIDEO_OPENGL_ES) #if defined(SDL_VIDEO_OPENGL_ES)
#include "../qnxgf/SDL_gf_opengles.h" #include "../qnxgf/SDL_gf_opengles.h"
/* If GF driver is not compiled in, include some of usefull functions */ /* If GF driver is not compiled in, include some of usefull functions */
#if !defined(SDL_VIDEO_DRIVER_QNXGF) #if !defined(SDL_VIDEO_DRIVER_QNXGF)
#include "../qnxgf/SDL_gf_opengles.c" #include "../qnxgf/SDL_gf_opengles.c"
#endif /* SDL_VIDEO_DRIVER_QNXGF */ #endif /* SDL_VIDEO_DRIVER_QNXGF */
...@@ -137,7 +137,7 @@ static const Photon_DeviceCaps photon_devicename[] = { ...@@ -137,7 +137,7 @@ static const Photon_DeviceCaps photon_devicename[] = {
/* VIA UniChrome graphics driver (devg-unichrome.so) */ /* VIA UniChrome graphics driver (devg-unichrome.so) */
{"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
, ,
/* VESA unaccelerated gfx driver (devg-vesa.so) */ /* VESA unaccelerated gfx driver (devg-vesabios.so) */
{"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
, ,
/* VmWare graphics driver (devg-volari.so) */ /* VmWare graphics driver (devg-volari.so) */
...@@ -155,7 +155,7 @@ static SDL_bool photon_initialized = SDL_FALSE; ...@@ -155,7 +155,7 @@ static SDL_bool photon_initialized = SDL_FALSE;
static int static int
photon_available(void) photon_available(void)
{ {
int status; int32_t status;
/* Check if Photon was initialized before */ /* Check if Photon was initialized before */
if (photon_initialized == SDL_FALSE) { if (photon_initialized == SDL_FALSE) {
...@@ -194,7 +194,7 @@ photon_create(int devindex) ...@@ -194,7 +194,7 @@ photon_create(int devindex)
{ {
SDL_VideoDevice *device; SDL_VideoDevice *device;
SDL_VideoData *phdata; SDL_VideoData *phdata;
int status; int32_t status;
/* Check if photon could be initialized */ /* Check if photon could be initialized */
status = photon_available(); status = photon_available();
...@@ -883,6 +883,13 @@ photon_createwindow(_THIS, SDL_Window * window) ...@@ -883,6 +883,13 @@ photon_createwindow(_THIS, SDL_Window * window)
PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE,
Ph_WM_STATE_ISALTKEY); Ph_WM_STATE_ISALTKEY);
/* Special case, do not handle maximize events, if window can't be resized */
if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE)
{
PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
}
/* Set window dimension */ /* Set window dimension */
winsize.w = window->w; winsize.w = window->w;
winsize.h = window->h; winsize.h = window->h;
...@@ -1305,7 +1312,7 @@ photon_gl_loadlibrary(_THIS, const char *path) ...@@ -1305,7 +1312,7 @@ photon_gl_loadlibrary(_THIS, const char *path)
if (phdata->gfinitialized != SDL_TRUE) { if (phdata->gfinitialized != SDL_TRUE) {
SDL_SetError SDL_SetError
("Photon: GF initialization failed, no OpenGL ES support"); ("Photon: GF initialization failed, no OpenGL ES support");
return NULL; return -1;
} }
/* Check if OpenGL ES library is specified for GF driver */ /* Check if OpenGL ES library is specified for GF driver */
...@@ -1918,6 +1925,7 @@ photon_gl_swapwindow(_THIS, SDL_Window * window) ...@@ -1918,6 +1925,7 @@ photon_gl_swapwindow(_THIS, SDL_Window * window)
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata; (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
PhRect_t dst_rect; PhRect_t dst_rect;
PhRect_t src_rect; PhRect_t src_rect;
int32_t status;
if (phdata->gfinitialized != SDL_TRUE) { if (phdata->gfinitialized != SDL_TRUE) {
SDL_SetError SDL_SetError
...@@ -1951,6 +1959,17 @@ photon_gl_swapwindow(_THIS, SDL_Window * window) ...@@ -1951,6 +1959,17 @@ photon_gl_swapwindow(_THIS, SDL_Window * window)
src_rect.lr.x = window->w - 1; src_rect.lr.x = window->w - 1;
src_rect.lr.y = window->h - 1; src_rect.lr.y = window->h - 1;
/* Check if current device is not the same as target */
if (phdata->current_device_id != didata->device_id) {
/* Set target device as default for Pd and Pg functions */
status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
if (status != 0) {
SDL_SetError("Photon: Can't set default target device\n");
return;
}
phdata->current_device_id = didata->device_id;
}
/* Blit OpenGL ES pixmap surface directly to window region */ /* Blit OpenGL ES pixmap surface directly to window region */
PgFFlush(Ph_START_DRAW); PgFFlush(Ph_START_DRAW);
PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window));
...@@ -2324,12 +2343,8 @@ photon_pumpevents(_THIS) ...@@ -2324,12 +2343,8 @@ photon_pumpevents(_THIS)
if ((wdata != NULL) && (window != NULL)) { if ((wdata != NULL) && (window != NULL)) {
/* Check if window uses OpenGL ES */ /* Check if window uses OpenGL ES */
if (wdata->uses_gles == SDL_TRUE) { if (wdata->uses_gles == SDL_TRUE) {
PhRect_t dst_rect;
PhRect_t src_rect;
/* Cycle through each rectangle */ /* Cycle through each rectangle */
for (it = 0; it < event->num_rects; for (it = 0; it < event->num_rects; it++) {
it++) {
/* Blit OpenGL ES pixmap surface directly to window region */ /* Blit OpenGL ES pixmap surface directly to window region */
PgFFlush(Ph_START_DRAW); PgFFlush(Ph_START_DRAW);
PgSetRegionCx(PhDCGetCurrent(), PgSetRegionCx(PhDCGetCurrent(),
...@@ -2345,8 +2360,14 @@ photon_pumpevents(_THIS) ...@@ -2345,8 +2360,14 @@ photon_pumpevents(_THIS)
PgWaitHWIdle(); PgWaitHWIdle();
} }
} else { } else {
/* Normal window */ /* Cycle through each rectangle */
/* TODO: update the damaged rectangles */ for (it = 0; it < event->num_rects;
it++) {
/* Blit 2D pixmap surface directly to window region */
_photon_update_rectangles(window->renderer, &rects[it]);
}
PgFlush();
PgWaitHWIdle();
} }
} }
...@@ -2385,10 +2406,19 @@ photon_pumpevents(_THIS) ...@@ -2385,10 +2406,19 @@ photon_pumpevents(_THIS)
PgFFlush(Ph_DONE_DRAW); PgFFlush(Ph_DONE_DRAW);
PgWaitHWIdle(); PgWaitHWIdle();
} else { } else {
/* Normal window */ PhRect_t rect;
/* TODO: update the damaged rectangles */
/* We need to redraw entire window */ /* We need to redraw entire window */
rect.ul.x = 0;
rect.ul.y = 0;
rect.lr.x = window->w - 1;
rect.lr.y = window->h - 1;
/* Blit 2D pixmap surface directly to window region */
PgFFlush(Ph_START_DRAW);
_photon_update_rectangles(window->renderer, &rect);
PgFFlush(Ph_DONE_DRAW);
PgWaitHWIdle();
} }
} }
} }
...@@ -2693,9 +2723,16 @@ photon_pumpevents(_THIS) ...@@ -2693,9 +2723,16 @@ photon_pumpevents(_THIS)
case Ph_WM_MAX: case Ph_WM_MAX:
{ {
if (window != NULL) { if (window != NULL) {
SDL_SendWindowEvent(window->id, if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE)
SDL_WINDOWEVENT_MAXIMIZED, {
0, 0); SDL_SendWindowEvent(window->id,
SDL_WINDOWEVENT_MAXIMIZED,
0, 0);
}
else
{
/* otherwise ignor the resize events */
}
} }
} }
break; break;
......
This diff is collapsed.
...@@ -30,16 +30,27 @@ ...@@ -30,16 +30,27 @@
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#include <Ph.h> #include <Ph.h>
#include <photon/PhRender.h>
#define SDL_PHOTON_MAX_SURFACES 3 #define SDL_PHOTON_MAX_SURFACES 3
#define SDL_PHOTON_SURFTYPE_UNKNOWN 0x00000000
#define SDL_PHOTON_SURFTYPE_OFFSCREEN 0x00000001
#define SDL_PHOTON_SURFTYPE_PHIMAGE 0x00000002
typedef struct SDL_RenderData typedef struct SDL_RenderData
{ {
SDL_Window *window; /* SDL window type */ SDL_bool enable_vsync; /* VSYNC flip synchronization enable */
SDL_bool enable_vsync; /* VSYNC flip synchronization enable */ uint32_t surface_visible_idx; /* Index of visible surface */
uint32_t surface_visible_idx; /* Index of visible surface */ uint32_t surface_render_idx; /* Index of render surface */
uint32_t surface_render_idx; /* Index of render surface */ uint32_t surfaces_count; /* Amount of allocated surfaces */
uint32_t surfaces_count; /* Amount of allocated surfaces */ uint32_t surfaces_type; /* Type of allocated surfaces */
uint32_t window_width; /* Last active window width */
uint32_t window_height; /* Last active window height */
PhGC_t* gc; /* Graphics context */
PdOffscreenContext_t* osurfaces[SDL_PHOTON_MAX_SURFACES];
PhImage_t* psurfaces[SDL_PHOTON_MAX_SURFACES];
PmMemoryContext_t* pcontexts[SDL_PHOTON_MAX_SURFACES];
} SDL_RenderData; } SDL_RenderData;
typedef struct SDL_TextureData typedef struct SDL_TextureData
...@@ -48,6 +59,9 @@ typedef struct SDL_TextureData ...@@ -48,6 +59,9 @@ typedef struct SDL_TextureData
extern void photon_addrenderdriver(_THIS); extern void photon_addrenderdriver(_THIS);
/* Helper function, which redraws the backbuffer */
int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect);
#endif /* __SDL_PHOTON_RENDER_H__ */ #endif /* __SDL_PHOTON_RENDER_H__ */
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment