Changeset 2718 for trunk/src


Ignore:
Timestamp:
Feb 10, 2000, 1:36:11 AM (26 years ago)
Author:
sandervl
Message:

CreateDIBSection enhancement + CreateICA/W bugfix

Location:
trunk/src/gdi32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/dibitmap.cpp

    r2600 r2718  
    1 /* $Id: dibitmap.cpp,v 1.2 2000-02-02 23:45:06 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.3 2000-02-10 00:36:10 sandervl Exp $ */
    22
    33/*
     
    8585
    8686  dprintf(("GDI32: CreateDIBSection %x %x %x %x %d", hdc, iUsage, ppvBits, hSection, dwOffset));
    87   if(hSection)
    88   {
    89     dprintf(("GDI32: CreateDIBSection, hSection != NULL, not supported!"));
    90     return NULL;
    91   }
    9287
    9388  //SvL: 13-9-98: StarCraft uses bitmap with negative height
     
    111106  {
    112107    char PalSize;
    113     DIBSection *dsect = new DIBSection((BITMAPINFOHEADER_W *)&pbmi->bmiHeader, (char *)&pbmi->bmiColors, iUsage, (DWORD)res, fFlip);
     108    DIBSection *dsect;
     109
     110    dsect = new DIBSection((BITMAPINFOHEADER_W *)&pbmi->bmiHeader, (char *)&pbmi->bmiColors, iUsage, hSection, dwOffset, (DWORD)res, fFlip);
    114111
    115112    if(dsect != NULL)
  • trunk/src/gdi32/dibsect.cpp

    r2706 r2718  
    1 /* $Id: dibsect.cpp,v 1.16 2000-02-09 23:34:30 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.17 2000-02-10 00:36:10 sandervl Exp $ */
    22
    33/*
     
    88 *
    99 * Project Odin Software License can be found in LICENSE.TXT
     10 *
     11 * NOTE:
     12 * This is not a complete solution for CreateDIBSection, but enough for Quake 2!
    1013 *
    1114 */
     
    2124#include <vmutex.h>
    2225#include <winconst.h>
    23 
     26#include <win32wnd.h>
     27#include "oslibgpi.h"
     28
     29//Win32 apis used:
    2430HWND WIN32API WindowFromDC(HDC hdc);
    25 HWND Win32ToOS2Handle(HWND hwnd);
    26 
    27 BOOL    APIENTRY _GpiEnableYInversion (HPS hps, LONG lHeight);
    28 
    29 inline BOOL APIENTRY GpiEnableYInversion (HPS hps, LONG lHeight)
    30 {
    31  BOOL yyrc;
    32  USHORT sel = RestoreOS2FS();
    33 
    34     yyrc = _GpiEnableYInversion(hps, lHeight);
    35     SetFS(sel);
    36 
    37     return yyrc;
    38 }
     31BOOL   WINAPI UnmapViewOfFile(LPVOID addr);
     32LPVOID WINAPI MapViewOfFile(HANDLE mapping, DWORD access, DWORD offset_high,
     33                            DWORD offset_low, DWORD count);
    3934
    4035static VMutex dibMutex;
    4136
    42 //NOTE:
    43 //This is not a complete solution for CreateDIBSection, but enough for Quake 2!
    44 //******************************************************************************
    45 //******************************************************************************
    46 DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD handle, int fFlip)
     37//******************************************************************************
     38//******************************************************************************
     39DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip)
    4740                : bmpBits(NULL), pOS2bmp(NULL), next(NULL)
    4841{
     
    8275   }
    8376
    84    bmpBits    = (char *)malloc(bmpsize*pbmi->biHeight);
     77   this->hSection = hSection;
     78   if(hSection) {
     79        bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight);
     80        if(!bmpBits) {
     81                dprintf(("Dibsection: mapViewOfFile %x failed!", hSection));
     82                DebugInt3();
     83        }
     84   }
     85   if(!bmpBits) {
     86        DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);
     87   }
    8588   memset(bmpBits, 0, bmpsize*pbmi->biHeight);
    8689
    87    pOS2bmp    = (BITMAPINFO2 *)malloc(os2bmpsize);
     90   pOS2bmp = (BITMAPINFO2 *)malloc(os2bmpsize);
    8891
    8992   memset(pOS2bmp, /* set header + palette entries to zero */
     
    164167{
    165168   dprintf(("Delete DIBSection %x", handle));
     169
     170   if(hSection) {
     171        UnmapViewOfFile(bmpBits);
     172   }
     173   else
    166174   if(bmpBits)
    167         free(bmpBits);
     175        DosFreeMem(bmpBits);
     176
    168177   if(pOS2bmp)
    169178        free(pOS2bmp);
  • trunk/src/gdi32/dibsect.h

    r2600 r2718  
    1 /* $Id: dibsect.h,v 1.11 2000-02-02 23:45:06 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.12 2000-02-10 00:36:10 sandervl Exp $ */
    22
    33/*
     
    6363{
    6464public:
    65               DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD handle, int fFlip);
     65              DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip);
    6666             ~DIBSection();
    6767
     
    9696private:
    9797          DWORD handle, iUsage;
     98          DWORD hSection;
    9899          HWND  hwndParent;
    99100          HDC   hdc;
  • trunk/src/gdi32/gdi32.cpp

    r2600 r2718  
    1 /* $Id: gdi32.cpp,v 1.38 2000-02-02 23:45:06 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.39 2000-02-10 00:36:10 sandervl Exp $ */
    22
    33/*
     
    479479//******************************************************************************
    480480//******************************************************************************
    481 HDC WIN32API CreateICA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, const DEVMODEA * arg4)
    482 {
     481HDC WIN32API CreateICA(LPCSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszOutput,
     482                       const DEVMODEA *lpdvmInit)
     483{
     484 static char *szDisplay = "DISPLAY";
     485
    483486    dprintf(("GDI32: CreateICA"));
    484     return O32_CreateIC(arg1, arg2, arg3, arg4);
     487    //SvL: Open32 tests for "DISPLAY"
     488    if(lpszDriver && !strcmp(lpszDriver, "display")) {
     489        lpszDriver = szDisplay;
     490    }
     491    return O32_CreateIC(lpszDriver, lpszDevice, lpszOutput, lpdvmInit);
    485492}
    486493//******************************************************************************
     
    540547      devmode.dmReserved2        = arg4->dmReserved2;
    541548
    542       rc = O32_CreateIC(astring1,astring2,astring3,&devmode);
     549      rc = CreateICA(astring1,astring2,astring3,&devmode);
    543550    }
    544551    else
    545       rc = O32_CreateIC(astring1,astring2,astring3, NULL);
     552      rc = CreateICA(astring1,astring2,astring3, NULL);
    546553
    547554    FreeAsciiString(astring1);
  • trunk/src/gdi32/oslibgpi.h

    r2484 r2718  
    1 /* $Id: oslibgpi.h,v 1.3 2000-01-20 21:39:36 sandervl Exp $ */
     1/* $Id: oslibgpi.h,v 1.4 2000-02-10 00:36:11 sandervl Exp $ */
    22
    33/*
     
    2929
    3030  return yyrc;
     31}
     32
     33BOOL APIENTRYOS2 _GpiEnableYInversion(ULONG hps, LONG lHeight);
     34
     35inline BOOL GpiEnableYInversion(ULONG hps, LONG lHeight)
     36{
     37 BOOL yyrc;
     38 USHORT sel = RestoreOS2FS();
     39
     40    yyrc = _GpiEnableYInversion(hps, lHeight);
     41    SetFS(sel);
     42
     43    return yyrc;
    3144}
    3245
Note: See TracChangeset for help on using the changeset viewer.