19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Lesser General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2.1 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Lesser General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Lesser General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free Software 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <Ph.h> 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <photon/Pg.h> 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_endian.h" 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_video.h" 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_pixels_c.h" 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_ph_video.h" 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_ph_image_c.h" 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_ph_modes_c.h" 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_ph_gl.h" 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetupImage(_THIS, SDL_Surface *screen) 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgColor_t* palette=NULL; 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int type=0; 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int bpp; 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bpp=screen->format->BitsPerPixel; 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Determine image type */ 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(bpp) 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 8:{ 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_PALETTE_BYTE; 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 15:{ 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_555; 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 16:{ 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_565; 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 24:{ 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_888; 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 32:{ 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_8888; 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default:{ 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupImage(): unsupported bpp=%d !\n", bpp); 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* palette emulation code */ 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((bpp==8) && (desktoppal==SDLPH_PAL_EMULATE)) 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* creating image palette */ 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall palette=SDL_malloc(_Pg_MAX_PALETTE*sizeof(PgColor_t)); 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (palette==NULL) 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupImage(): can't allocate memory for palette !\n"); 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgGetPalette(palette); 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* using shared memory for speed (set last param to 1) */ 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, palette, _Pg_MAX_PALETTE, 1)) == NULL) 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=8 !\n"); 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(palette); 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* using shared memory for speed (set last param to 1) */ 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((SDL_Image = PhCreateImage(NULL, screen->w, screen->h, type, NULL, 0, 1)) == NULL) 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupImage(): PhCreateImage() failed for bpp=%d !\n", bpp); 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels = SDL_Image->image; 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pitch = SDL_Image->bpl; 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = ph_NormalUpdate; 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetupOCImage(_THIS, SDL_Surface *screen) 1129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int type = 0; 1149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int bpp; 1159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.flags = screen->flags; 1179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall bpp=screen->format->BitsPerPixel; 1199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Determine image type */ 1219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(bpp) 1229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 8: { 1249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_PALETTE_BYTE; 1259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 15:{ 1289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_555; 1299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 16:{ 1329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_565; 1339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 24:{ 1369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_888; 1379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 32:{ 1409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall type = Pg_IMAGE_DIRECT_8888; 1419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default:{ 1449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupOCImage(): unsupported bpp=%d !\n", bpp); 1459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 1469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 1489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Currently offscreen contexts with the same bit depth as display bpp only can be created */ 1519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.offscreen_context = PdCreateOffscreenContext(0, screen->w, screen->h, Pg_OSC_MEM_PAGE_ALIGN); 1529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.offscreen_context == NULL) 1549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupOCImage(): PdCreateOffscreenContext() function failed !\n"); 1569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 1579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pitch = OCImage.offscreen_context->pitch; 1609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.dc_ptr = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context); 1629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.dc_ptr == NULL) 1649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupOCImage(): PdGetOffscreenContextPtr function failed !\n"); 1669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(OCImage.offscreen_context); 1679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 1689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.FrameData0 = OCImage.dc_ptr; 1719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.CurrentFrameData = OCImage.FrameData0; 1729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.current = 0; 1739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCSetCurrent(OCImage.offscreen_context); 1759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels = OCImage.CurrentFrameData; 1779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = ph_OCUpdate; 1799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 1819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetupFullScreenImage(_THIS, SDL_Surface* screen) 1849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 1859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.flags = screen->flags; 1869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Begin direct and fullscreen mode */ 1889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!ph_EnterFullScreen(this, screen, PH_ENTER_DIRECTMODE)) 1899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 1919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* store palette for fullscreen */ 1949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->format->BitsPerPixel==8) && (desktopbpp!=8)) 1959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 1969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgGetPalette(savedpal); 1979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgGetPalette(syspalph); 1989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 1999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.offscreen_context = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY | Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); 2019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.offscreen_context == NULL) 2029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext() function failed !\n"); 2049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 2059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) 2089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.offscreen_backcontext = PdDupOffscreenContext(OCImage.offscreen_context, Pg_OSC_MEM_PAGE_ALIGN | Pg_OSC_CRTC_SAFE); 2109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.offscreen_backcontext == NULL) 2119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupFullScreenImage(): PdCreateOffscreenContext(back) function failed !\n"); 2139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 2149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.FrameData0 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_context); 2189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.FrameData0 == NULL) 2199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupFullScreenImage(): PdGetOffscreenContextPtr() function failed !\n"); 2219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_DestroyImage(this, screen); 2229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 2239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) 2269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.FrameData1 = (unsigned char *)PdGetOffscreenContextPtr(OCImage.offscreen_backcontext); 2289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.FrameData1 == NULL) 2299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_SetupFullScreenImage(back): PdGetOffscreenContextPtr() function failed !\n"); 2319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_DestroyImage(this, screen); 2329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 2339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* wait for the hardware */ 2379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 2389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 2399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) 2419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.current = 0; 2439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCSetCurrent(OCImage.offscreen_context); 2449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pitch = OCImage.offscreen_context->pitch; 2459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels = OCImage.FrameData0; 2469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* emulate 640x400 videomode */ 2489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (videomode_emulatemode==1) 2499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 2519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i=0; i<40; i++) 2539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); 2559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i=440; i<480; i++) 2579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); 2599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels+=screen->pitch*40; 2619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSwapDisplay(OCImage.offscreen_backcontext, 0); 2639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 2659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.current = 0; 2679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCSetCurrent(OCImage.offscreen_context); 2689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pitch = OCImage.offscreen_context->pitch; 2699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels = OCImage.FrameData0; 2709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* emulate 640x400 videomode */ 2729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (videomode_emulatemode==1) 2739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 2759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i=0; i<40; i++) 2779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); 2799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i=440; i<480; i++) 2819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 2829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(screen->pixels+screen->pitch*i, 0x00, screen->pitch); 2839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels+=screen->pitch*40; 2859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 2879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = ph_OCDCUpdate; 2899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* wait for the hardware */ 2919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 2929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 2939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 2959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 2969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 2989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 2999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetupOpenGLImage(_THIS, SDL_Surface* screen) 3009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->UpdateRects = ph_OpenGLUpdate; 3029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels=NULL; 3039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pitch=NULL; 3049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if (_NTO_VERSION >= 630) 3069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) 3079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (!ph_EnterFullScreen(this, screen, PH_IGNORE_DIRECTMODE)) 3099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->flags &= ~SDL_FULLSCREEN; 3119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 3129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif /* 6.3.0 */ 3159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (ph_SetupOpenGLContext(this, screen->w, screen->h, screen->format->BitsPerPixel, screen->flags)!=0) 3179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->flags &= ~SDL_OPENGL; 3199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 3209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 3239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 3249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_VIDEO_OPENGL */ 3269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_DestroyImage(_THIS, SDL_Surface* screen) 3289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 3299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 3319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->flags & SDL_OPENGL)==SDL_OPENGL) 3329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (oglctx) 3349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if (_NTO_VERSION < 630) 3369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCSetCurrent(NULL); 3379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(oglctx); 3389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #else 3399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall qnxgl_context_destroy(oglctx); 3409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall qnxgl_buffers_destroy(oglbuffers); 3419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall qnxgl_finish(); 3429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif /* 6.3.0 */ 3439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall oglctx=NULL; 3449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall oglbuffers=NULL; 3459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall oglflags=0; 3469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall oglbpp=0; 3479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #if (_NTO_VERSION >= 630) 3509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (currently_fullscreen) 3519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_LeaveFullScreen(this); 3539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall #endif /* 6.3.0 */ 3559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 3579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_VIDEO_OPENGL */ 3599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (currently_fullscreen) 3619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* if we right now in 8bpp fullscreen we must release palette */ 3639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->format->BitsPerPixel==8) && (desktopbpp!=8)) 3649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetPalette(syspalph, 0, -1, 0, 0, 0); 3669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetPalette(savedpal, 0, 0, _Pg_MAX_PALETTE, Pg_PALSET_GLOBAL | Pg_PALSET_FORCE_EXPOSE, 0); 3679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 3689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_LeaveFullScreen(this); 3709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.offscreen_context != NULL) 3739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(OCImage.offscreen_context); 3759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.offscreen_context = NULL; 3769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.FrameData0 = NULL; 3779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (OCImage.offscreen_backcontext != NULL) 3799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(OCImage.offscreen_backcontext); 3819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.offscreen_backcontext = NULL; 3829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.FrameData1 = NULL; 3839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OCImage.CurrentFrameData = NULL; 3859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_Image) 3879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* if palette allocated, free it */ 3899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (SDL_Image->palette) 3909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 3919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_Image->palette); 3929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgShmemDestroy(SDL_Image->image); 3949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(SDL_Image); 3959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 3969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 3979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Must be zeroed everytime */ 3989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_Image = NULL; 3999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (screen) 4019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall screen->pixels = NULL; 4039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_UpdateHWInfo(_THIS) 4079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgVideoModeInfo_t vmode; 4099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgHWCaps_t hwcaps; 4109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Update video ram amount */ 4129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgGetGraphicsHWCaps(&hwcaps) < 0) 4139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_UpdateHWInfo(): GetGraphicsHWCaps() function failed !\n"); 4159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 4169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.video_mem=hwcaps.currently_available_video_ram/1024; 4189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* obtain current mode capabilities */ 4209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgGetVideoModeInfo(hwcaps.current_video_mode, &vmode) < 0) 4219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_UpdateHWInfo(): GetVideoModeInfo() function failed !\n"); 4239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 4249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((vmode.mode_capabilities1 & PgVM_MODE_CAP1_OFFSCREEN) == PgVM_MODE_CAP1_OFFSCREEN) 4279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* this is a special test for drivers which tries to lie about offscreen capability */ 4299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (hwcaps.currently_available_video_ram!=0) 4309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.hw_available = 1; 4329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.hw_available = 0; 4369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.hw_available = 0; 4419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_RECTANGLE) == PgVM_MODE_CAP2_RECTANGLE) 4449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_fill = 1; 4469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_fill = 0; 4509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_BITBLT) == PgVM_MODE_CAP2_BITBLT) 4539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw = 1; 4559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw = 0; 4599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND) == PgVM_MODE_CAP2_ALPHA_BLEND) 4629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw_A = 1; 4649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw_A = 0; 4689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((vmode.mode_capabilities2 & PgVM_MODE_CAP2_CHROMA) == PgVM_MODE_CAP2_CHROMA) 4719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw_CC = 1; 4739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.blit_hw_CC = 0; 4779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 4809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 4819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetupUpdateFunction(_THIS, SDL_Surface* screen, Uint32 flags) 4839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 4849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int setupresult=-1; 4859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_DestroyImage(this, screen); 4879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 4889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 4899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((flags & SDL_OPENGL)==SDL_OPENGL) 4909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall setupresult=ph_SetupOpenGLImage(this, screen); 4929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 4939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 4949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 4969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((flags & SDL_FULLSCREEN)==SDL_FULLSCREEN) 4979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 4989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall setupresult=ph_SetupFullScreenImage(this, screen); 4999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 5019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((flags & SDL_HWSURFACE)==SDL_HWSURFACE) 5039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall setupresult=ph_SetupOCImage(this, screen); 5059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 5079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall setupresult=ph_SetupImage(this, screen); 5099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 5129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 5149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (setupresult!=-1) 5159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_UpdateHWInfo(this); 5179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return setupresult; 5209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_AllocHWSurface(_THIS, SDL_Surface* surface) 5239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgHWCaps_t hwcaps; 5259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata!=NULL) 5279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_AllocHWSurface(): hwdata already exists!\n"); 5299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 5309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata=SDL_malloc(sizeof(struct private_hwdata)); 5329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_memset(surface->hwdata, 0x00, sizeof(struct private_hwdata)); 5339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->offscreenctx=PdCreateOffscreenContext(0, surface->w, surface->h, Pg_OSC_MEM_PAGE_ALIGN); 5349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata->offscreenctx == NULL) 5359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_AllocHWSurface(): PdCreateOffscreenContext() function failed !\n"); 5379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 5389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pixels=PdGetOffscreenContextPtr(surface->hwdata->offscreenctx); 5409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->pixels==NULL) 5419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(surface->hwdata->offscreenctx); 5439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_AllocHWSurface(): PdGetOffscreenContextPtr() function failed !\n"); 5449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 5459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->pitch=surface->hwdata->offscreenctx->pitch; 5479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->flags|=SDL_HWSURFACE; 5489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->flags|=SDL_PREALLOC; 5499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if 0 /* FIXME */ 5519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* create simple offscreen lock */ 5529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->crlockparam.flags=0; 5539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PdCreateOffscreenLock(surface->hwdata->offscreenctx, &surface->hwdata->crlockparam)!=EOK) 5549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(surface->hwdata->offscreenctx); 5569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_AllocHWSurface(): Can't create offscreen lock !\n"); 5579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 5589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* 0 */ 5609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Update video ram amount */ 5629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgGetGraphicsHWCaps(&hwcaps) < 0) 5639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PdDestroyOffscreenLock(surface->hwdata->offscreenctx); 5659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(surface->hwdata->offscreenctx); 5669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_AllocHWSurface(): GetGraphicsHWCaps() function failed !\n"); 5679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 5689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.video_mem=hwcaps.currently_available_video_ram/1024; 5709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 5729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 5739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_FreeHWSurface(_THIS, SDL_Surface* surface) 5759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 5769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgHWCaps_t hwcaps; 5779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata==NULL) 5799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_FreeHWSurface(): no hwdata!\n"); 5819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 5829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata->offscreenctx == NULL) 5849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_FreeHWSurface(): no offscreen context to delete!\n"); 5869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 5879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if 0 /* FIXME */ 5909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* unlock the offscreen context if it has been locked before destroy it */ 5919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PdIsOffscreenLocked(surface->hwdata->offscreenctx)==Pg_OSC_LOCKED) 5929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 5939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PdUnlockOffscreen(surface->hwdata->offscreenctx); 5949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 5959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PdDestroyOffscreenLock(surface->hwdata->offscreenctx); 5979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* 0 */ 5989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 5999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhDCRelease(surface->hwdata->offscreenctx); 6009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_free(surface->hwdata); 6029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata=NULL; 6039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Update video ram amount */ 6059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgGetGraphicsHWCaps(&hwcaps) < 0) 6069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_FreeHWSurface(): GetGraphicsHWCaps() function failed !\n"); 6089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 6099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->info.video_mem=hwcaps.currently_available_video_ram/1024; 6119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 6139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst) 6169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->hwdata==NULL) && (src != this->screen)) 6189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_CheckHWBlit(): Source surface haven't hardware specific data.\n"); 6209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags&=~SDL_HWACCEL; 6219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 6229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_HWSURFACE) != SDL_HWSURFACE) 6249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_CheckHWBlit(): Source surface isn't a hardware surface.\n"); 6269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags&=~SDL_HWACCEL; 6279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 6289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) 6319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (this->info.blit_hw_CC!=1) 6339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags&=~SDL_HWACCEL; 6359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->map->hw_blit=NULL; 6369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 6379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) 6419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (this->info.blit_hw_A!=1) 6439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags&=~SDL_HWACCEL; 6459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->map->hw_blit=NULL; 6469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 6479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->flags|=SDL_HWACCEL; 6519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src->map->hw_blit = ph_HWAccelBlit; 6529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 1; 6549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 6559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse HallPgColor_t ph_ExpandColor(_THIS, SDL_Surface* surface, Uint32 color) 6579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 6589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 truecolor; 6599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Photon API accepts true colors only during hw filling operations */ 6619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch(surface->format->BitsPerPixel) 6629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 8: 6649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((surface->format->palette) && (color<=surface->format->palette->ncolors)) 6669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall truecolor=PgRGB(surface->format->palette->colors[color].r, 6689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->format->palette->colors[color].g, 6699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->format->palette->colors[color].b); 6709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 6729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_ExpandColor(): Color out of range for the 8bpp mode !\n"); 6749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0xFFFFFFFFUL; 6759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 15: 6799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall truecolor = ((color & 0x00007C00UL) << 9) | /* R */ 6819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x000003E0UL) << 6) | /* G */ 6829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x0000001FUL) << 3) | /* B */ 6839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x00007000UL) << 4) | /* R compensation */ 6849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x00000380UL) << 1) | /* G compensation */ 6859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x0000001CUL) >> 2); /* B compensation */ 6869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 16: 6899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 6909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall truecolor = ((color & 0x0000F800UL) << 8) | /* R */ 6919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x000007E0UL) << 5) | /* G */ 6929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x0000001FUL) << 3) | /* B */ 6939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x0000E000UL) << 3) | /* R compensation */ 6949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x00000600UL) >> 1) | /* G compensation */ 6959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ((color & 0x0000001CUL) >> 2); /* B compensation */ 6969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 6979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 6989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 6999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 24: 7009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall truecolor=color & 0x00FFFFFFUL; 7029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 7049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case 32: 7059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall truecolor=color; 7079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 7099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 7109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_ExpandColor(): Unsupported depth for the hardware operations !\n"); 7129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0xFFFFFFFFUL; 7139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return truecolor; 7179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_FillHWRect(_THIS, SDL_Surface* surface, SDL_Rect* rect, Uint32 color) 7209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgColor_t oldcolor; 7229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint32 truecolor; 7239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int ydisp=0; 7249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (this->info.blit_fill!=1) 7269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 7289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall truecolor=ph_ExpandColor(this, surface, color); 7319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (truecolor==0xFFFFFFFFUL) 7329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 7349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall oldcolor=PgSetFillColor(truecolor); 7379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* 640x400 videomode emulation */ 7399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (videomode_emulatemode==1) 7409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ydisp+=40; 7429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgDrawIRect(rect->x, rect->y+ydisp, rect->w+rect->x-1, rect->h+rect->y+ydisp-1, Pg_DRAW_FILL); 7459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetFillColor(oldcolor); 7469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 7479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 7489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 7509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_FlipHWSurface(_THIS, SDL_Surface* screen) 7539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhArea_t farea; 7559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) 7579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* flush all drawing ops before blitting */ 7599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 7609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 7619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall farea.pos.x=0; 7639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall farea.pos.y=0; 7649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall farea.size.w=screen->w; 7659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall farea.size.h=screen->h; 7669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* emulate 640x400 videomode */ 7689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (videomode_emulatemode==1) 7699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall farea.pos.y+=40; 7719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgContextBlitArea(OCImage.offscreen_context, &farea, OCImage.offscreen_backcontext, &farea); 7749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* flush the blitting */ 7769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 7779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 7789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 7809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 7819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_LockHWSurface(_THIS, SDL_Surface* surface) 7839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 7849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if 0 /* FIXME */ 7869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int lockresult; 7879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata == NULL) 7899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 7919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 7929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->lockparam.flags=0; 7949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->lockparam.time_out=NULL; 7959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall lockresult=PdLockOffscreen(surface->hwdata->offscreenctx, &surface->hwdata->lockparam); 7969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 7979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall switch (lockresult) 7989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 7999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case EOK: 8009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall break; 8019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case Pg_OSC_LOCK_DEADLOCK: 8029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_LockHWSurface(): Deadlock detected !\n"); 8039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 8049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall case Pg_OSC_LOCK_INVALID: 8059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_LockHWSurface(): Lock invalid !\n"); 8069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 8079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall default: 8089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_LockHWSurface(): Can't lock the surface !\n"); 8099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 8109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* 0 */ 8129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 8149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_UnlockHWSurface(_THIS, SDL_Surface* surface) 8179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if 0 /* FIXME */ 8209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int unlockresult; 8219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((surface == NULL) || (surface->hwdata == NULL)) 8239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 8259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PdIsOffscreenLocked(surface->hwdata->offscreenctx)==Pg_OSC_LOCKED) 8289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall unlockresult=PdUnlockOffscreen(surface->hwdata->offscreenctx); 8309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* 0 */ 8329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 8349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 8359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_HWAccelBlit(SDL_Surface* src, SDL_Rect* srcrect, SDL_Surface* dst, SDL_Rect* dstrect) 8379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 8389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_VideoDevice* this=current_video; 8399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhArea_t srcarea; 8409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhArea_t dstarea; 8419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int ydisp=0; 8429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* 640x400 videomode emulation */ 8449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (videomode_emulatemode==1) 8459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ydisp+=40; 8479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srcarea.pos.x=srcrect->x; 8509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srcarea.pos.y=srcrect->y; 8519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srcarea.size.w=srcrect->w; 8529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srcarea.size.h=srcrect->h; 8539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dstarea.pos.x=dstrect->x; 8559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dstarea.pos.y=dstrect->y; 8569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dstarea.size.w=dstrect->w; 8579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dstarea.size.h=dstrect->h; 8589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (((src == this->screen) || (src->hwdata!=NULL)) && ((dst == this->screen) || (dst->hwdata!=NULL))) 8609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) 8629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_SetHWColorKey(this, src, src->format->colorkey); 8649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgChromaOn(); 8659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) 8689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_SetHWAlpha(this, src, src->format->alpha); 8709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgAlphaOn(); 8719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 8739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (dst == this->screen) 8749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (src == this->screen) 8769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* blitting from main screen to main screen */ 8789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dstarea.pos.y+=ydisp; 8799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srcarea.pos.y+=ydisp; 8809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgContextBlitArea(OCImage.offscreen_context, &srcarea, OCImage.offscreen_context, &dstarea); 8819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 8839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* blitting from offscreen to main screen */ 8859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dstarea.pos.y+=ydisp; 8869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, OCImage.offscreen_context, &dstarea); 8879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 8909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (src == this->screen) 8929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* blitting from main screen to offscreen */ 8949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall srcarea.pos.y+=ydisp; 8959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgContextBlitArea(OCImage.offscreen_context, &srcarea, dst->hwdata->offscreenctx, &dstarea); 8969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 8979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 8989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 8999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* blitting offscreen to offscreen */ 9009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgContextBlitArea(src->hwdata->offscreenctx, &srcarea, dst->hwdata->offscreenctx, &dstarea); 9019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) 9059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgAlphaOff(); 9079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) 9109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgChromaOff(); 9129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall else 9159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_HWAccelBlit(): Source or target surface is not a hardware surface !\n"); 9179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 9189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 9219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 9229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 9249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 9259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) 9279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 9289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (this->info.blit_hw_CC!=1) 9299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 9319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata!=NULL) 9349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall surface->hwdata->colorkey=ph_ExpandColor(this, surface, key); 9369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (surface->hwdata->colorkey==0xFFFFFFFFUL) 9379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 9399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetChroma(surface->hwdata->colorkey, Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); 9429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 9449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 9459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallint ph_SetHWAlpha(_THIS, SDL_Surface* surface, Uint8 alpha) 9479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 9489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (this->info.blit_hw_A!=1) 9499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return -1; 9519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetAlphaBlend(NULL, alpha); 9549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return 0; 9569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 9579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 9599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_OpenGLUpdate(_THIS, int numrects, SDL_Rect* rects) 9609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 9619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall this->GL_SwapBuffers(this); 9629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 9649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 9659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* SDL_VIDEO_OPENGL */ 9669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) 9689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 9699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhPoint_t ph_pos; 9709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhRect_t ph_rect; 9719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 9729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i=0; i<numrects; ++i) 9749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rects[i].w==0) /* Clipped? dunno why but this occurs sometime. */ 9769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 9789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rects[i].h==0) /* Clipped? dunno why but this occurs sometime. */ 9819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 9839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_pos.x = rects[i].x; 9869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_pos.y = rects[i].y; 9879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_rect.ul.x = rects[i].x; 9889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_rect.ul.y = rects[i].y; 9899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_rect.lr.x = rects[i].x + rects[i].w; 9909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall ph_rect.lr.y = rects[i].y + rects[i].h; 9919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgDrawPhImageRectmx(&ph_pos, SDL_Image, &ph_rect, 0) < 0) 9939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 9949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_NormalUpdate(): PgDrawPhImageRectmx failed!\n"); 9959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall return; 9969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 9989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 9999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgFlush() < 0) 10009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_NormalUpdate(): PgFlush() function failed!\n"); 10029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects) 10069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 10079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int i; 10089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhPoint_t zero = {0, 0}; 10109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhArea_t src_rect; 10119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PhArea_t dest_rect; 10129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetTranslation(&zero, 0); 10149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetRegion(PtWidgetRid(window)); 10159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgSetClipping(0, NULL); 10169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgFlush(); 10189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 10199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall for (i=0; i<numrects; ++i) 10219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rects[i].w == 0) /* Clipped? */ 10239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 10259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (rects[i].h == 0) /* Clipped? */ 10289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall continue; 10309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src_rect.pos.x=rects[i].x; 10339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src_rect.pos.y=rects[i].y; 10349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dest_rect.pos.x=rects[i].x; 10359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dest_rect.pos.y=rects[i].y; 10369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src_rect.size.w=rects[i].w; 10389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall src_rect.size.h=rects[i].h; 10399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dest_rect.size.w=rects[i].w; 10409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall dest_rect.size.h=rects[i].h; 10419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgContextBlitArea(OCImage.offscreen_context, &src_rect, NULL, &dest_rect); 10439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgFlush() < 0) 10469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_OCUpdate(): PgFlush failed.\n"); 10489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 10509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallvoid ph_OCDCUpdate(_THIS, int numrects, SDL_Rect *rects) 10529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall{ 10539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall PgWaitHWIdle(); 10549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 10559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall if (PgFlush() < 0) 10569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall { 10579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_SetError("ph_OCDCUpdate(): PgFlush failed.\n"); 10589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall } 10599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall} 1060