- Timestamp:
- Jul 15, 2002, 12:02:30 PM (23 years ago)
- Location:
- trunk/src/gdi32
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/blit.cpp
r7791 r8871 1 /* $Id: blit.cpp,v 1.3 8 2002-01-29 14:36:31sandervl Exp $ */1 /* $Id: blit.cpp,v 1.39 2002-07-15 10:02:28 sandervl Exp $ */ 2 2 3 3 /* … … 32 32 int nWidthSrc, int nHeightSrc, DWORD dwRop) 33 33 { 34 BOOL rc; 35 36 dprintf(("GDI32: StretchBlt Dest: %x (%d, %d) size (%d, %d) ROP %x", 37 hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop)); 38 dprintf(("GDI32: StretchBlt Src : %x (%d, %d) size (%d, %d)\n", 39 hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc)); 40 41 SetLastError(ERROR_SUCCESS); 42 if(DIBSection::getSection() != NULL) 43 { 44 DIBSection *dsect = DIBSection::findHDC(hdcSrc); 45 if(dsect) 46 { 47 rc = dsect->BitBlt( hdcDest, 48 nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, 49 nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, 50 dwRop); 51 dprintf(("GDI32: StretchBlt returned %d", rc)); 52 return rc; 53 } 54 } 55 rc = O32_StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop); 56 if(DIBSection::getSection() != NULL) { 57 DIBSection *destdib = DIBSection::findHDC(hdcDest); 58 if(destdib) { 59 destdib->sync(hdcDest, nYOriginDest, nHeightDest); 60 } 61 } 62 if(rc == FALSE) { 63 dprintf(("!WARNING!: GDI32: StretchBlt returned FALSE; last error %x", rc, GetLastError())); 64 } 65 return rc; 34 BOOL rc; 35 36 dprintf(("GDI32: StretchBlt Dest: %x (%d, %d) size (%d, %d) ROP %x", 37 hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, dwRop)); 38 dprintf(("GDI32: StretchBlt Src : %x (%d, %d) size (%d, %d)\n", 39 hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc)); 40 41 SetLastError(ERROR_SUCCESS); 42 if(DIBSection::getSection() != NULL) 43 { 44 DIBSection *dsect = DIBSection::findHDC(hdcSrc); 45 if(dsect) 46 { 47 rc = dsect->BitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, 48 nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop); 49 dprintf(("GDI32: StretchBlt returned %d", rc)); 50 return rc; 51 } 52 } 53 rc = O32_StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop); 54 if(DIBSection::getSection() != NULL) { 55 DIBSection *destdib = DIBSection::findHDC(hdcDest); 56 if(destdib) { 57 destdib->sync(hdcDest, nYOriginDest, nHeightDest); 58 } 59 } 60 if(rc == FALSE) { 61 dprintf(("!WARNING!: GDI32: StretchBlt returned FALSE; last error %x", rc, GetLastError())); 62 } 63 return rc; 66 64 } 67 65 //****************************************************************************** … … 77 75 DWORD dwRop) 78 76 { 79 BOOL rc; 80 81 POINT point1, point2; 82 GetViewportOrgEx(hdcDest, &point1); 83 GetViewportOrgEx(hdcSrc, &point2); 84 dprintf(("BitBlt: Viewport origin dest (%d,%d) src (%d,%d)", point1.x, point1.y, point2.x, point2.y)); 85 86 SetLastError(ERROR_SUCCESS); 87 if(DIBSection::getSection() != NULL) 88 { 89 DIBSection *dsect = DIBSection::findHDC(hdcSrc); 90 if(dsect) 91 { 92 return dsect->BitBlt(hdcDest, 93 nXDest, 94 nYDest, 95 nWidth, 96 nHeight, 97 nXSrc, 98 nYSrc, 99 nWidth, 100 nHeight, 101 dwRop); 102 } 103 } 104 dprintf(("GDI32: BitBlt to hdc %X from hdc %x (%d,%d) to (%d,%d), (%d,%d) rop %X\n", 105 hdcDest, hdcSrc, nXSrc, nYSrc, nXDest, nYDest, nWidth, nHeight, dwRop)); 106 107 rc = O32_BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); 108 109 if(DIBSection::getSection() != NULL) { 110 DIBSection *destdib = DIBSection::findHDC(hdcDest); 111 if(destdib) { 112 destdib->sync(hdcDest, nYDest, nHeight); 113 } 114 } 115 return rc; 77 BOOL rc; 78 79 #ifdef DEBUG 80 POINT point1, point2; 81 GetViewportOrgEx(hdcDest, &point1); 82 GetViewportOrgEx(hdcSrc, &point2); 83 dprintf(("BitBlt: Viewport origin dest (%d,%d) src (%d,%d)", point1.x, point1.y, point2.x, point2.y)); 84 #endif 85 86 SetLastError(ERROR_SUCCESS); 87 if(DIBSection::getSection() != NULL) 88 { 89 DIBSection *dsect = DIBSection::findHDC(hdcSrc); 90 if(dsect) 91 { 92 return dsect->BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, nXSrc, nYSrc, nWidth, nHeight, dwRop); 93 } 94 } 95 dprintf(("GDI32: BitBlt to hdc %X from hdc %x (%d,%d) to (%d,%d), (%d,%d) rop %X\n", 96 hdcDest, hdcSrc, nXSrc, nYSrc, nXDest, nYDest, nWidth, nHeight, dwRop)); 97 98 rc = O32_BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop); 99 100 if(DIBSection::getSection() != NULL) { 101 DIBSection *destdib = DIBSection::findHDC(hdcDest); 102 if(destdib) { 103 destdib->sync(hdcDest, nYDest, nHeight); 104 } 105 } 106 return rc; 116 107 } 117 108 //****************************************************************************** … … 169 160 case 15: 170 161 case 16: //Default if BI_BITFIELDS not set is RGB 555 171 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0x7c00;172 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : 0x03e0;173 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : 0x001f;162 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : DEFAULT_16BPP_RED_MASK; 163 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK; 164 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK; 174 165 break; 175 166 176 167 case 24: 177 168 case 32: 178 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;179 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : 0xff00;180 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : 0xff;169 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : DEFAULT_24BPP_RED_MASK; 170 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK; 171 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK; 181 172 break; 182 173 default: … … 205 196 } 206 197 if(startscan != 0 || lines != info->bmiHeader.biHeight) { 207 dprintf(("WARNING: SetDIBitsToDevice startscan != 0 || lines != info->bmiHeader.biHeight"));198 dprintf(("WARNING: SetDIBitsToDevice startscan != 0 || lines != info->bmiHeader.biHeight")); 208 199 dprintf(("info bmp (%d,%d)", info->bmiHeader.biWidth, info->bmiHeader.biHeight)); 209 200 } … … 215 206 //Open32 always returns height of bitmap (regardless of how many scanlines were copied) 216 207 if(result != info->bmiHeader.biHeight) { 217 dprintf(("SetDIBitsToDevice failed with rc %x", result));208 dprintf(("SetDIBitsToDevice failed with rc %x", result)); 218 209 } 219 210 else … … 240 231 } 241 232 if(newbits) free(newbits); 233 242 234 ((BITMAPINFO *)info)->bmiHeader.biSizeImage = bmpsize; 243 235 return result; … … 413 405 BOOL WIN32API PatBlt(HDC hdc,int nXLeft,int nYLeft,int nWidth,int nHeight,DWORD dwRop) 414 406 { 415 BOOL rc;416 417 dprintf(("PatBlt %x (%d,%d)(%d,%d) %x", hdc, nXLeft,nYLeft,nWidth,nHeight, dwRop));418 //CB: Open32 bug: negative width/height not supported!419 if (nWidth < 0)420 {421 nXLeft += nWidth+1;422 nWidth = -nWidth;423 }424 if (nHeight < 0)425 {426 nYLeft += nHeight+1;427 nHeight = -nHeight;428 }429 rc = O32_PatBlt(hdc,nXLeft,nYLeft,nWidth,nHeight,dwRop);430 if(rc) {431 DIBSection *destdib = DIBSection::findHDC(hdc);432 if(destdib) {433 destdib->sync(hdc, nYLeft, nHeight);434 }435 }436 437 dprintf(("GDI32: PatBlt hdc %x (%d,%d) (%d,%d) returned %d\n",hdc, nXLeft,nYLeft,nWidth,nHeight,rc));438 return(rc);407 BOOL rc; 408 409 dprintf(("PatBlt %x (%d,%d)(%d,%d) %x", hdc, nXLeft,nYLeft,nWidth,nHeight, dwRop)); 410 //CB: Open32 bug: negative width/height not supported! 411 if (nWidth < 0) 412 { 413 nXLeft += nWidth+1; 414 nWidth = -nWidth; 415 } 416 if (nHeight < 0) 417 { 418 nYLeft += nHeight+1; 419 nHeight = -nHeight; 420 } 421 rc = O32_PatBlt(hdc,nXLeft,nYLeft,nWidth,nHeight,dwRop); 422 if(rc) { 423 DIBSection *destdib = DIBSection::findHDC(hdc); 424 if(destdib) { 425 destdib->sync(hdc, nYLeft, nHeight); 426 } 427 } 428 429 dprintf(("GDI32: PatBlt hdc %x (%d,%d) (%d,%d) returned %d\n",hdc, nXLeft,nYLeft,nWidth,nHeight,rc)); 430 return(rc); 439 431 } 440 432 //****************************************************************************** … … 451 443 int xMast, int yMask) 452 444 { 453 dprintf(("GDI32: PlgBlt, not implemented\n"));454 return(FALSE);445 dprintf(("GDI32: PlgBlt, not implemented\n")); 446 return(FALSE); 455 447 } 456 448 //****************************************************************************** … … 461 453 const BITMAPINFO *info, UINT wUsage, DWORD dwRop ) 462 454 { 463 INT rc;464 DWORD bitfields[3], compression = 0;465 WORD *newbits = NULL;455 INT rc; 456 DWORD bitfields[3], compression = 0; 457 WORD *newbits = NULL; 466 458 467 459 dprintf(("GDI32: StretchDIBits %x to (%d,%d) (%d,%d) from (%d,%d) (%d,%d), %x %x %x %x", hdc, xDst, yDst, widthDst, heightDst, xSrc, ySrc, widthSrc, heightSrc, bits, info, wUsage, dwRop)); … … 486 478 487 479 if(GetDIBColorTable(hdc, 0, info->bmiHeader.biClrUsed, pColors) == 0) { 488 dprintf(("ERROR: StretchDIBits: GetDIBColorTable failed!!"));480 dprintf(("ERROR: StretchDIBits: GetDIBColorTable failed!!")); 489 481 return FALSE; 490 482 } … … 500 492 //Open32 always returns height of bitmap (regardless of how many scanlines were copied) 501 493 if(rc != heightSrc && rc != infoLoc->bmiHeader.biHeight) { 502 dprintf(("StretchDIBits failed with rc %x", rc));494 dprintf(("StretchDIBits failed with rc %x", rc)); 503 495 } 504 else {505 rc = heightSrc;506 507 DIBSection *destdib = DIBSection::findHDC(hdc);508 if(destdib) {509 if(widthDst == widthSrc && heightDst == heightSrc &&510 destdib->GetBitCount() == infoLoc->bmiHeader.biBitCount &&511 destdib->GetBitCount() == 8)512 513 destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);514 }515 else destdib->sync(hdc, yDst, heightDst);516 }517 }518 519 return rc;496 else { 497 rc = heightSrc; 498 499 DIBSection *destdib = DIBSection::findHDC(hdc); 500 if(destdib) { 501 if(widthDst == widthSrc && heightDst == heightSrc && 502 destdib->GetBitCount() == infoLoc->bmiHeader.biBitCount && 503 destdib->GetBitCount() == 8) 504 { 505 destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits); 506 } 507 else destdib->sync(hdc, yDst, heightDst); 508 } 509 } 510 511 return rc; 520 512 } 521 513 … … 523 515 case 15: 524 516 case 16: //Default if BI_BITFIELDS not set is RGB 555 525 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0x7c00;526 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : 0x03e0;527 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : 0x001f;517 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : DEFAULT_16BPP_RED_MASK; 518 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK; 519 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK; 528 520 break; 529 521 case 24: 530 522 case 32: 531 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000;532 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : 0xff00;533 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : 0xff;523 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : DEFAULT_24BPP_RED_MASK; 524 bitfields[1] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK; 525 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK; 534 526 break; 535 527 default: … … 539 531 break; 540 532 } 541 if(bitfields[1] == 0x3E0)533 if(bitfields[1] == RGB555_GREEN_MASK) 542 534 {//RGB 555? 543 535 dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2])); … … 570 562 //Open32 always returns height of bitmap (regardless of how many scanlines were copied) 571 563 if(rc != heightSrc && rc != info->bmiHeader.biHeight) { 572 dprintf(("StretchDIBits failed with rc %x", rc));564 dprintf(("StretchDIBits failed with rc %x", rc)); 573 565 } 574 566 else 575 567 { 576 rc = heightSrc;577 578 DIBSection *destdib = DIBSection::findHDC(hdc);579 if(destdib) {580 if(widthDst == widthSrc && heightDst == heightSrc &&581 destdib->GetBitCount() == info->bmiHeader.biBitCount &&582 destdib->GetBitCount() == 8)583 584 destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits);585 }586 elsedestdib->sync(hdc, yDst, heightDst);587 }568 rc = heightSrc; 569 570 DIBSection *destdib = DIBSection::findHDC(hdc); 571 if(destdib) { 572 if(widthDst == widthSrc && heightDst == heightSrc && 573 destdib->GetBitCount() == info->bmiHeader.biBitCount && 574 destdib->GetBitCount() == 8) 575 { 576 destdib->sync(xDst, yDst, widthDst, heightDst, (PVOID)bits); 577 } 578 else destdib->sync(hdc, yDst, heightDst); 579 } 588 580 } 589 581 … … 636 628 dprintf(("GDI32: SetStretchBltMode 0x%08X, 0x%08X\n",arg1, arg2)); 637 629 638 if(DIBSection::getSection() != NULL)639 {640 DIBSection *dsect = DIBSection::findHDC(arg1);641 if(dsect)642 {643 dprintf((" - DC is DIBSection\n"));644 }645 }646 return O32_SetStretchBltMode(arg1, arg2);630 if(DIBSection::getSection() != NULL) 631 { 632 DIBSection *dsect = DIBSection::findHDC(arg1); 633 if(dsect) 634 { 635 dprintf((" - DC is DIBSection\n")); 636 } 637 } 638 return O32_SetStretchBltMode(arg1, arg2); 647 639 } 648 640 //****************************************************************************** -
trunk/src/gdi32/dbglocal.cpp
r6375 r8871 1 /* $Id: dbglocal.cpp,v 1. 7 2001-07-20 15:35:57sandervl Exp $ */1 /* $Id: dbglocal.cpp,v 1.8 2002-07-15 10:02:28 sandervl Exp $ */ 2 2 3 3 /* … … 12 12 #include <stdio.h> 13 13 #include <string.h> 14 #include <ctype.h> 14 15 #include "dbglocal.h" 15 16 … … 67 68 } 68 69 for(i=0;i<DBG_MAXFILES;i++) { 70 int len = strlen(DbgFileNames[i]); 69 71 dbgvar = strstr(envvar, DbgFileNames[i]); 70 if(dbgvar ) {72 if(dbgvar && !islower(dbgvar[len])) { 71 73 if(*(dbgvar-1) == '-') { 72 74 DbgEnabledGDI32[i] = 0; … … 88 90 } 89 91 for(i=0;i<DBG_MAXFILES;i++) { 92 int len = strlen(DbgFileNames[i]); 90 93 dbgvar = strstr(envvar2, DbgFileNames[i]); 91 if(dbgvar ) {94 if(dbgvar && !islower(dbgvar[len])) { 92 95 if(*(dbgvar-1) == '-') { 93 96 DbgEnabledLvl2GDI32[i] = 0; -
trunk/src/gdi32/dibitmap.cpp
r7713 r8871 1 /* $Id: dibitmap.cpp,v 1.3 0 2001-12-30 22:19:05sandervl Exp $ */1 /* $Id: dibitmap.cpp,v 1.31 2002-07-15 10:02:28 sandervl Exp $ */ 2 2 3 3 /* … … 20 20 #include "rgbcvt.h" 21 21 #include <stats.h> 22 #include "oslibgpi.h" 23 #include <objhandle.h> 22 24 23 25 #define DBG_LOCALLOG DBG_dibitmap … … 68 70 } 69 71 rc = CreateDIBitmap(hdc, lpbmih, fdwInit, newbits, lpbmi, fuUsage); 70 free( newbits );72 free( newbits ); 71 73 } 72 74 … … 93 95 case 15: 94 96 case 16: //Default if BI_BITFIELDS not set is RGB 555 95 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : 0x7c00;96 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : 0x03e0;97 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : 0x001f;97 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : DEFAULT_16BPP_RED_MASK; 98 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK; 99 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK; 98 100 break; 99 101 case 24: 100 102 case 32: 101 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : 0xff0000;102 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : 0xff00;103 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : 0xff;103 bitfields[0] = (lpbmih->biCompression == BI_BITFIELDS) ? *(DWORD *)lpbmi->bmiColors : DEFAULT_24BPP_RED_MASK; 104 bitfields[1] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK; 105 bitfields[2] = (lpbmih->biCompression == BI_BITFIELDS) ? *((DWORD *)lpbmi->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK; 104 106 break; 105 107 default: … … 109 111 break; 110 112 } 111 if(bitfields[1] == 0x3E0&& lpbInit && fdwInit == CBM_INIT)113 if(bitfields[1] == RGB555_GREEN_MASK && lpbInit && fdwInit == CBM_INIT) 112 114 {//RGB 555? 113 115 dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2])); … … 132 134 ((BITMAPINFOHEADER *)lpbmih)->biBitCount = biBitCount; 133 135 134 if(rc) STATS_CreateDIBitmap(rc, hdc, lpbmih, fdwInit, lpbInit, lpbmi, fuUsage); 136 if(rc) { 137 STATS_CreateDIBitmap(rc, hdc, lpbmih, fdwInit, lpbInit, lpbmi, fuUsage); 138 #ifdef NEW_GDIHANDLES 139 if(bitfields[1] == RGB565_GREEN_MASK) { 140 //mark bitmap as RGB565 141 dprintf(("RGB565 bitmap")); 142 ObjSetHandleFlag(rc, OBJHANDLE_FLAG_BMP_RGB565, TRUE); 143 } 144 #endif 145 } 135 146 136 147 return rc; … … 141 152 { 142 153 HBITMAP hBitmap; 154 #ifdef NEW_GDIHANDLES 155 pDCData pHps; 156 157 pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); 158 if(!pHps) 159 { 160 SetLastError(ERROR_INVALID_HANDLE); 161 return 0; 162 } 163 #endif 143 164 144 165 hBitmap = O32_CreateCompatibleBitmap(hdc, nWidth, nHeight); 145 166 dprintf(("GDI32: CreateCompatibleBitmap %x (%d,%d) returned %x", hdc, nWidth, nHeight, hBitmap)); 146 if(hBitmap) STATS_CreateCompatibleBitmap(hBitmap,hdc, nWidth, nHeight); 167 if(hBitmap) { 168 STATS_CreateCompatibleBitmap(hBitmap,hdc, nWidth, nHeight); 169 #ifdef NEW_GDIHANDLES 170 if(pHps->hwnd == 1) { //1 == HWND_DESKTOP 171 dprintf(("Screen compatible bitmap")); 172 ObjSetHandleFlag(hBitmap, OBJHANDLE_FLAG_BMP_SCREEN_COMPATIBLE, 1); 173 } 174 #endif 175 } 147 176 148 177 return hBitmap; … … 153 182 HBITMAP WIN32API CreateDiscardableBitmap(HDC hDC, int nWidth, int nHeight) 154 183 { 155 dprintf(("GDI32: CreateDisardableBitmap \n"));184 dprintf(("GDI32: CreateDisardableBitmap")); 156 185 return CreateCompatibleBitmap(hDC, nWidth, nHeight); 157 186 } … … 161 190 UINT cBitsPerPel, const void *lpvBits) 162 191 { 163 HBITMAP hBitmap;192 HBITMAP hBitmap; 164 193 165 194 hBitmap = O32_CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, lpvBits); … … 187 216 VOID **ppvBits, HANDLE hSection, DWORD dwOffset) 188 217 { 189 HBITMAP res = 0;190 BOOL fFlip = 0;191 int iHeight, iWidth;192 BOOL fCreateDC = FALSE;193 194 dprintf(("GDI32: CreateDIBSection %x %x %x %x %x %d", hdc, pbmi, iUsage, ppvBits, hSection, dwOffset));218 HBITMAP res = 0; 219 BOOL fFlip = 0; 220 int iHeight, iWidth; 221 BOOL fCreateDC = FALSE; 222 223 dprintf(("GDI32: CreateDIBSection %x %x %x %x %x %d", hdc, pbmi, iUsage, ppvBits, hSection, dwOffset)); 195 224 196 225 //SvL: 13-9-98: StarCraft uses bitmap with negative height … … 368 397 case 15: 369 398 case 16: //RGB 565 370 ((DWORD*)(lpbi->bmiColors))[0] = 0x7c00; 371 ((DWORD*)(lpbi->bmiColors))[1] = 0x03E0; 372 ((DWORD*)(lpbi->bmiColors))[2] = 0x001F; 373 break; 399 { 400 #ifdef NEW_GDIHANDLES 401 DWORD dwFlags; 402 403 dwFlags = ObjQueryHandleFlags(hBitmap); 404 if(dwFlags & (OBJHANDLE_FLAG_BMP_SCREEN_COMPATIBLE|OBJHANDLE_FLAG_BMP_RGB565)) { 405 ((DWORD*)(lpbi->bmiColors))[0] = RGB565_RED_MASK; 406 ((DWORD*)(lpbi->bmiColors))[1] = RGB565_GREEN_MASK; 407 ((DWORD*)(lpbi->bmiColors))[2] = RGB565_BLUE_MASK; 408 } 409 else { 410 ((DWORD*)(lpbi->bmiColors))[0] = RGB555_RED_MASK; 411 ((DWORD*)(lpbi->bmiColors))[1] = RGB555_GREEN_MASK; 412 ((DWORD*)(lpbi->bmiColors))[2] = RGB555_BLUE_MASK; 413 } 414 break; 415 #else 416 ((DWORD*)(lpbi->bmiColors))[0] = RGB555_RED_MASK; 417 ((DWORD*)(lpbi->bmiColors))[1] = RGB555_GREEN_MASK; 418 ((DWORD*)(lpbi->bmiColors))[2] = RGB555_BLUE_MASK; 419 #endif 420 } 374 421 case 24: 375 422 case 32: 376 ((DWORD*)(lpbi->bmiColors))[0] = 0xFF0000; 377 ((DWORD*)(lpbi->bmiColors))[1] = 0x00FF00; 378 ((DWORD*)(lpbi->bmiColors))[2] = 0x0000FF; 379 break; 380 } 381 } 382 if(nrlines && lpvBits && lpbi->bmiHeader.biBitCount == 16 && ((DWORD*)(lpbi->bmiColors))[1] == 0x3E0) 423 ((DWORD*)(lpbi->bmiColors))[0] = DEFAULT_24BPP_RED_MASK; 424 ((DWORD*)(lpbi->bmiColors))[1] = DEFAULT_24BPP_GREEN_MASK; 425 ((DWORD*)(lpbi->bmiColors))[2] = DEFAULT_24BPP_BLUE_MASK; 426 break; 427 } 428 if(lpbi->bmiHeader.biCompression == BI_RGB && lpbi->bmiHeader.biBitCount > 8) { 429 lpbi->bmiHeader.biCompression = BI_BITFIELDS; 430 dprintf(("BI_BITFIELDS: %x %x %x", ((DWORD*)(lpbi->bmiColors))[0], ((DWORD*)(lpbi->bmiColors))[1], ((DWORD*)(lpbi->bmiColors))[2])); 431 } 432 } 433 if(nrlines && lpvBits && lpbi->bmiHeader.biBitCount == 16 && ((DWORD*)(lpbi->bmiColors))[1] == RGB555_GREEN_MASK) 383 434 {//RGB 555? 384 435 dprintf(("RGB 565->555 conversion required")); … … 457 508 case 15: 458 509 case 16: //Default if BI_BITFIELDS not set is RGB 555 459 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : 0x7c00;460 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : 0x03e0;461 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : 0x001f;510 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : DEFAULT_16BPP_RED_MASK; 511 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : DEFAULT_16BPP_GREEN_MASK; 512 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : DEFAULT_16BPP_BLUE_MASK; 462 513 break; 463 514 464 515 case 24: 465 516 case 32: 466 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : 0xff0000;467 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : 0xff00;468 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : 0xff;517 bitfields[0] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)pBitmapInfo->bmiColors : DEFAULT_24BPP_RED_MASK; 518 bitfields[1] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 1) : DEFAULT_24BPP_GREEN_MASK; 519 bitfields[2] = (pBitmapInfo->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)pBitmapInfo->bmiColors + 2) : DEFAULT_24BPP_BLUE_MASK; 469 520 break; 470 521 default: … … 474 525 break; 475 526 } 476 if(pBits && bitfields[1] == 0x3E0)527 if(pBits && bitfields[1] == RGB555_GREEN_MASK) 477 528 {//RGB 555? 478 529 dprintf(("RGB 555->565 conversion required %x %x %x", bitfields[0], bitfields[1], bitfields[2])); -
trunk/src/gdi32/font.cpp
r8418 r8871 1 /* $Id: font.cpp,v 1.2 5 2002-05-15 11:43:18 sandervl Exp $ */1 /* $Id: font.cpp,v 1.26 2002-07-15 10:02:28 sandervl Exp $ */ 2 2 3 3 /* … … 97 97 }; 98 98 99 HFONT hFntDefaultGui = NULL; 100 99 101 /***************************************************************************** 100 102 * Name : static void iFontRename … … 142 144 lpstrFaceTemp, 143 145 LF_FACESIZE); 144 }145 146 //******************************************************************************147 HFONT hFntDefaultGui = NULL;148 //TODO: more??149 //******************************************************************************150 BOOL WIN32API IsSystemFont(HFONT hFont)151 {152 if(hFont == hFntDefaultGui) {153 return TRUE;154 }155 return FALSE;156 146 } 157 147 //****************************************************************************** -
trunk/src/gdi32/gdi32.DEF
r7682 r8871 1 ; $Id: gdi32.DEF,v 1.2 1 2001-12-26 11:33:10sandervl Exp $1 ; $Id: gdi32.DEF,v 1.22 2002-07-15 10:02:28 sandervl Exp $ 2 2 3 3 ;Created by BLAST for IBM's compiler … … 358 358 ; 359 359 _ObjAllocateHandle@12 @1201 NONAME 360 _ObjFreeHandle@4 @1202 NONAME 361 _ObjGetHandleData@8 @1203 NONAME 362 _ObjGetHandleType@4 @1204 NONAME 360 _ObjDeleteHandle@8 @1202 NONAME 361 _ObjQueryHandleData@8 @1203 NONAME 362 _ObjQueryHandleType@4 @1204 NONAME 363 _ObjSetHandleFlag@12 @1205 NONAME 364 _ObjSetHandleData@12 @1206 NONAME 365 _ObjQueryHandleFlags@4 @1207 NONAME 363 366 364 367 ; -
trunk/src/gdi32/gdi32.cpp
r8343 r8871 1 /* $Id: gdi32.cpp,v 1.8 1 2002-04-30 13:09:55sandervl Exp $ */1 /* $Id: gdi32.cpp,v 1.82 2002-07-15 10:02:29 sandervl Exp $ */ 2 2 3 3 /* … … 26 26 #include "font.h" 27 27 #include <stats.h> 28 #include <objhandle.h> 28 29 29 30 #define DBG_LOCALLOG DBG_gdi32 … … 60 61 { 61 62 case DEFAULT_GUI_FONT: 62 if(NULL==hFntDefaultGui) 63 hFntDefaultGui = CreateFontA( -9, 0, 0, 0, FW_MEDIUM, FALSE, 64 FALSE, FALSE, ANSI_CHARSET, 65 OUT_DEFAULT_PRECIS, 66 CLIP_DEFAULT_PRECIS, 67 DEFAULT_QUALITY, 68 FIXED_PITCH|FF_MODERN, "WarpSans"); 63 if(NULL==hFntDefaultGui) { 64 hFntDefaultGui = CreateFontA( -9, 0, 0, 0, FW_MEDIUM, FALSE, 65 FALSE, FALSE, ANSI_CHARSET, 66 OUT_DEFAULT_PRECIS, 67 CLIP_DEFAULT_PRECIS, 68 DEFAULT_QUALITY, 69 FIXED_PITCH|FF_MODERN, "WarpSans"); 70 //This object can't be deleted by applications 71 ObjSetHandleFlag(hFntDefaultGui, OBJHANDLE_FLAG_NODELETE, TRUE); 72 } 69 73 obj = hFntDefaultGui; 70 74 break; -
trunk/src/gdi32/objhandle.cpp
r8202 r8871 1 /* $Id: objhandle.cpp,v 1.2 1 2002-04-07 14:38:08sandervl Exp $ */1 /* $Id: objhandle.cpp,v 1.22 2002-07-15 10:02:29 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Handle Management Code for OS/2 4 4 * 5 5 * 6 * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl) 7 * 6 * Copyright 2000-2002 Sander van Leeuwen (sandervl@xs4all.nl) 8 7 * 9 8 * TODO: The table should be dynamically increased when necessary 10 9 * This is just a quick and dirty implementation 10 * 11 * System objects can't be deleted (TODO: any others?? (fonts?))!!!!) 11 12 * 12 13 * Project Odin Software License can be found in LICENSE.TXT … … 37 38 38 39 typedef struct { 39 ULONG dwUserData; 40 ObjectType type; 40 DWORD dwUserData; 41 DWORD dwGDI32Data; 42 DWORD dwFlags; 43 DWORD dwType; 41 44 } GdiObject; 42 45 … … 45 48 static VMutex objTableMutex; 46 49 47 #ifdef DEBUG 48 static DWORD GetObjectTypeNoDbg( HGDIOBJ hObj); 49 #else 50 #define GetObjectTypeNoDbg GetObjectType 51 #endif 52 53 //****************************************************************************** 54 //****************************************************************************** 55 BOOL WIN32API ObjAllocateHandle(HANDLE *hObject, DWORD dwUserData, ObjectType type) 50 //****************************************************************************** 51 //****************************************************************************** 52 BOOL WIN32API ObjAllocateHandle(HANDLE *hObject, DWORD dwUserData, DWORD dwType) 56 53 { 57 54 objTableMutex.enter(); … … 63 60 return FALSE; 64 61 } 65 if(objHandleTable[0]. type == 0) {62 if(objHandleTable[0].dwType == HNDL_NONE) { 66 63 //first handle can never be used 67 objHandleTable[0]. type = GDIOBJ_INVALID;64 objHandleTable[0].dwType = HNDL_INVALID; 68 65 objHandleTable[0].dwUserData = -1; 69 66 } 70 *hObject = lowestFreeIndex; 71 *hObject |= MAKE_HANDLE(type); 72 objHandleTable[lowestFreeIndex].dwUserData = dwUserData; 73 objHandleTable[lowestFreeIndex].type = type; 74 67 *hObject = lowestFreeIndex; 68 *hObject = MAKE_HANDLE(*hObject); 69 objHandleTable[lowestFreeIndex].dwUserData = dwUserData; 70 objHandleTable[lowestFreeIndex].dwType = dwType; 71 objHandleTable[lowestFreeIndex].dwGDI32Data = 0; 72 objHandleTable[lowestFreeIndex].dwFlags = 0; 75 73 lowestFreeIndex = -1; 76 74 … … 87 85 //****************************************************************************** 88 86 //****************************************************************************** 89 void WIN32API ObjFreeHandle(HANDLE hObject)87 BOOL WIN32API ObjDeleteHandle(HANDLE hObject, DWORD dwType) 90 88 { 91 89 hObject &= OBJHANDLE_MAGIC_MASK; 92 90 if(hObject < MAX_OBJECT_HANDLES) { 93 91 objTableMutex.enter(); 94 objHandleTable[hObject].dwUserData = 0; 95 objHandleTable[hObject].type = GDIOBJ_NONE; 96 if(lowestFreeIndex == -1 || hObject < lowestFreeIndex) 97 lowestFreeIndex = hObject; 98 92 if(!(objHandleTable[hObject].dwFlags & OBJHANDLE_FLAG_NODELETE)) 93 { 94 objHandleTable[hObject].dwUserData = 0; 95 objHandleTable[hObject].dwType = HNDL_NONE; 96 if(lowestFreeIndex == -1 || hObject < lowestFreeIndex) 97 lowestFreeIndex = hObject; 98 } 99 else { 100 dprintf(("ObjDeleteHandle: unable to delete system object %x", MAKE_HANDLE(hObject))); 101 } 99 102 objTableMutex.leave(); 100 } 101 } 102 //****************************************************************************** 103 //****************************************************************************** 104 DWORD WIN32API ObjGetHandleData(HANDLE hObject, ObjectType type) 105 { 106 hObject &= OBJHANDLE_MAGIC_MASK; 107 if(hObject < MAX_OBJECT_HANDLES && type == objHandleTable[hObject].type) { 108 return objHandleTable[hObject].dwUserData; 109 } 110 return HANDLE_OBJ_ERROR; 111 } 112 //****************************************************************************** 113 //****************************************************************************** 114 ObjectType WIN32API ObjGetHandleType(HANDLE hObject) 115 { 116 DWORD objtype; 117 118 switch(OBJHANDLE_MAGIC(hObject)) 119 { 120 case GDIOBJ_REGION: 121 hObject &= OBJHANDLE_MAGIC_MASK; 122 if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].type == GDIOBJ_REGION) { 123 return GDIOBJ_REGION; 124 } 125 break; 126 127 case USEROBJ_MENU: 128 hObject &= OBJHANDLE_MAGIC_MASK; 129 if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].type == USEROBJ_MENU) { 130 return USEROBJ_MENU; 131 } 132 break; 133 134 case GDIOBJ_NONE: 135 //could be a cutoff menu handle, check this 136 //TODO: dangerous assumption! (need to rewrite object handle management) 137 hObject &= OBJHANDLE_MAGIC_MASK; 138 if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].dwUserData != 0 && objHandleTable[hObject].type == USEROBJ_MENU) { 139 return USEROBJ_MENU; 140 } 141 break; 142 143 case GDIOBJ_BITMAP: 144 case GDIOBJ_BRUSH: 145 case GDIOBJ_PALETTE: 146 case GDIOBJ_FONT: 147 case USEROBJ_ACCEL: 148 default: 149 break; 150 } 151 return GDIOBJ_NONE; 103 return TRUE; 104 } 105 return FALSE; 106 } 107 //****************************************************************************** 108 //****************************************************************************** 109 DWORD WIN32API ObjQueryHandleData(HANDLE hObject, DWORD dwType) 110 { 111 DWORD dwUserData = HANDLE_INVALID_DATA; 112 113 objTableMutex.enter(); 114 hObject &= OBJHANDLE_MAGIC_MASK; 115 if(hObject < MAX_OBJECT_HANDLES && 116 ((dwType == HNDL_ANY && objHandleTable[hObject].dwType != HNDL_NONE) || 117 dwType == objHandleTable[hObject].dwType)) 118 { 119 dwUserData = objHandleTable[hObject].dwUserData; 120 } 121 objTableMutex.leave(); 122 return dwUserData; 123 } 124 //****************************************************************************** 125 //****************************************************************************** 126 BOOL WIN32API ObjSetHandleData(HANDLE hObject, DWORD dwType, DWORD dwUserData) 127 { 128 BOOL fSuccess = FALSE; 129 130 objTableMutex.enter(); 131 hObject &= OBJHANDLE_MAGIC_MASK; 132 if(hObject < MAX_OBJECT_HANDLES && 133 ((dwType == HNDL_ANY && objHandleTable[hObject].dwType != HNDL_NONE) || 134 dwType == objHandleTable[hObject].dwType)) 135 { 136 objHandleTable[hObject].dwUserData = dwUserData; 137 fSuccess = TRUE; 138 } 139 objTableMutex.leave(); 140 return fSuccess; 141 } 142 //****************************************************************************** 143 //****************************************************************************** 144 DWORD WIN32API ObjQueryHandleGDI32Data(HANDLE hObject, DWORD dwType) 145 { 146 DWORD dwGDI32Data = HANDLE_INVALID_DATA; 147 148 objTableMutex.enter(); 149 hObject &= OBJHANDLE_MAGIC_MASK; 150 if(hObject < MAX_OBJECT_HANDLES && 151 ((dwType == HNDL_ANY && objHandleTable[hObject].dwType != HNDL_NONE) || 152 dwType == objHandleTable[hObject].dwType)) 153 { 154 dwGDI32Data = objHandleTable[hObject].dwGDI32Data; 155 } 156 objTableMutex.leave(); 157 return dwGDI32Data; 158 } 159 //****************************************************************************** 160 //****************************************************************************** 161 BOOL WIN32API ObjSetHandleGDI32Data(HANDLE hObject, DWORD dwType, DWORD dwGDI32Data) 162 { 163 BOOL fSuccess = FALSE; 164 165 objTableMutex.enter(); 166 hObject &= OBJHANDLE_MAGIC_MASK; 167 if(hObject < MAX_OBJECT_HANDLES && 168 ((dwType == HNDL_ANY && objHandleTable[hObject].dwType != HNDL_NONE) || 169 dwType == objHandleTable[hObject].dwType)) 170 { 171 objHandleTable[hObject].dwGDI32Data = dwGDI32Data; 172 fSuccess = TRUE; 173 } 174 objTableMutex.leave(); 175 return fSuccess; 176 } 177 //****************************************************************************** 178 //****************************************************************************** 179 DWORD WIN32API ObjQueryHandleFlags(OBJHANDLE hObject) 180 { 181 DWORD dwFlags = HANDLE_INVALID_DATA; 182 183 objTableMutex.enter(); 184 hObject &= OBJHANDLE_MAGIC_MASK; 185 if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].dwType != HNDL_NONE) 186 { 187 dwFlags = objHandleTable[hObject].dwFlags; 188 } 189 objTableMutex.leave(); 190 return dwFlags; 191 } 192 //****************************************************************************** 193 //****************************************************************************** 194 BOOL WIN32API ObjSetHandleFlag(HANDLE hObject, DWORD dwFlag, BOOL fSet) 195 { 196 BOOL fSuccess = FALSE; 197 198 objTableMutex.enter(); 199 hObject &= OBJHANDLE_MAGIC_MASK; 200 if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].dwType != HNDL_NONE) { 201 if(fSet) { 202 objHandleTable[hObject].dwFlags |= dwFlag; 203 } 204 else objHandleTable[hObject].dwFlags &= ~dwFlag; 205 206 dprintf(("ObjSetHandleFlag %x -> %x", MAKE_HANDLE(hObject), dwFlag)); 207 208 fSuccess = TRUE; 209 } 210 objTableMutex.leave(); 211 return fSuccess; 212 } 213 //****************************************************************************** 214 //****************************************************************************** 215 DWORD WIN32API ObjQueryHandleType(HANDLE hObject) 216 { 217 DWORD objtype = 0; 218 219 objTableMutex.enter(); 220 hObject &= OBJHANDLE_MAGIC_MASK; 221 if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].dwType != HNDL_NONE) { 222 objtype = objHandleTable[hObject].dwType; 223 } 224 objTableMutex.leave(); 225 return objtype; 152 226 } 153 227 //****************************************************************************** … … 155 229 int WIN32API GetObjectA( HGDIOBJ hObject, int size, void *lpBuffer) 156 230 { 157 int rc; 158 159 dprintf(("GDI32: GetObject %X %X %X\n", hObject, size, lpBuffer)); 160 //TODO: must use 16 bits gdi object handles 161 if(HIWORD(hObject) == 0) { 162 hObject |= GDIOBJ_PREFIX; 163 } 164 if(lpBuffer == NULL) 165 { //return required size if buffer pointer == NULL 166 int objtype = GetObjectTypeNoDbg(hObject); 167 switch(objtype) 168 { 169 case OBJ_PEN: 170 return sizeof(LOGPEN); 171 172 case OBJ_EXTPEN: 173 return sizeof(EXTLOGPEN); 174 175 case OBJ_BRUSH: 176 return sizeof(LOGBRUSH); 177 178 case OBJ_PAL: 179 return sizeof(USHORT); 180 181 case OBJ_FONT: 182 return sizeof(LOGFONTA); 183 184 case OBJ_BITMAP: 185 return sizeof(BITMAP); //also default for dib sections??? (TODO: NEED TO CHECK THIS) 186 187 case OBJ_DC: 188 case OBJ_METADC: 189 case OBJ_REGION: 190 case OBJ_METAFILE: 191 case OBJ_MEMDC: 192 case OBJ_ENHMETADC: 193 case OBJ_ENHMETAFILE: 194 dprintf(("warning: GetObjectA not defined for object type %d", objtype)); 195 return 0; 196 } 197 } 198 if(DIBSection::getSection() != NULL) 199 { 231 int rc; 232 233 dprintf(("GDI32: GetObject %X %X %X\n", hObject, size, lpBuffer)); 234 235 if(lpBuffer == NULL) 236 { //return required size if buffer pointer == NULL 237 int objtype = GetObjectType(hObject); 238 switch(objtype) 239 { 240 case OBJ_PEN: 241 return sizeof(LOGPEN); 242 243 case OBJ_EXTPEN: 244 return sizeof(EXTLOGPEN); 245 246 case OBJ_BRUSH: 247 return sizeof(LOGBRUSH); 248 249 case OBJ_PAL: 250 return sizeof(USHORT); 251 252 case OBJ_FONT: 253 return sizeof(LOGFONTA); 254 255 case OBJ_BITMAP: 256 return sizeof(BITMAP); //also default for dib sections??? (TODO: NEED TO CHECK THIS) 257 258 case OBJ_DC: 259 case OBJ_METADC: 260 case OBJ_REGION: 261 case OBJ_METAFILE: 262 case OBJ_MEMDC: 263 case OBJ_ENHMETADC: 264 case OBJ_ENHMETAFILE: 265 dprintf(("warning: GetObjectA not defined for object type %d", objtype)); 266 return 0; 267 } 268 } 269 if(DIBSection::getSection() != NULL) 270 { 200 271 DIBSection *dsect = DIBSection::findObj(hObject); 201 272 if(dsect) 202 273 { 203 204 205 206 207 208 209 210 } 211 }212 213 return O32_GetObject(hObject, size, lpBuffer);274 rc = dsect->GetDIBSection(size, lpBuffer); 275 if(rc == 0) { 276 SetLastError(ERROR_INVALID_PARAMETER); 277 return 0; 278 } 279 SetLastError(ERROR_SUCCESS); 280 return rc; 281 } 282 } 283 284 return O32_GetObject(hObject, size, lpBuffer); 214 285 } 215 286 //****************************************************************************** … … 217 288 int WIN32API GetObjectW( HGDIOBJ hObject, int size, void *lpBuffer) 218 289 { 219 int ret, objtype; 220 221 dprintf(("GDI32: GetObjectW %X, %d %X", hObject, size, lpBuffer)); 222 223 //TODO: must use 16 bits gdi object handles 224 if(HIWORD(hObject) == 0) { 225 hObject |= GDIOBJ_PREFIX; 226 } 227 objtype = GetObjectTypeNoDbg(hObject); 228 229 switch(objtype) 230 { 231 case OBJ_FONT: 232 { 233 LOGFONTA logfonta; 290 int ret, objtype; 291 292 dprintf(("GDI32: GetObjectW %X, %d %X", hObject, size, lpBuffer)); 293 294 objtype = GetObjectType(hObject); 295 296 switch(objtype) 297 { 298 case OBJ_FONT: 299 { 300 LOGFONTA logfonta; 234 301 235 302 if(lpBuffer == NULL) { … … 252 319 } 253 320 return 0; 254 }255 default:256 return GetObjectA(hObject, size, lpBuffer);257 }321 } 322 default: 323 return GetObjectA(hObject, size, lpBuffer); 324 } 258 325 } 259 326 //****************************************************************************** … … 289 356 HGDIOBJ WIN32API SelectObject(HDC hdc, HGDIOBJ hObj) 290 357 { 291 HGDIOBJ rc;292 DWORD handleType;358 HGDIOBJ rc; 359 DWORD handleType; 293 360 294 361 //TODO: must use 16 bits gdi object handles … … 297 364 } 298 365 299 handleType = GetObjectType NoDbg(hObj);366 handleType = GetObjectType(hObj); 300 367 dprintf2(("GDI32: SelectObject %x %x type %s", hdc, hObj, DbgGetGDITypeName(handleType))); 301 if(handleType == GDIOBJ_REGION) {368 if(handleType == HNDL_REGION) { 302 369 //Return complexity here; not previously selected clip region 303 370 return (HGDIOBJ)SelectClipRgn(hdc, hObj); … … 321 388 } 322 389 rc = O32_SelectObject(hdc, hObj); 323 if(rc != 0 && GetObjectType NoDbg(rc) == OBJ_BITMAP && DIBSection::getSection != NULL)390 if(rc != 0 && GetObjectType(rc) == OBJ_BITMAP && DIBSection::getSection != NULL) 324 391 { 325 392 DIBSection *dsect = DIBSection::findObj(rc); … … 329 396 } 330 397 } 331 #ifdef USING_OPEN32332 if(handleType == OBJ_BITMAP)333 {334 //SvL: Open32 messes up the height of the hdc (for windows)335 pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);336 if(pHps && pHps->hwnd) {337 dprintf2(("change back origin"));338 selectClientArea(pHps);339 setPageXForm(pHps);340 }341 }342 #endif343 398 dprintf2(("GDI32: SelectObject %x %x returned %x", hdc, hObj, rc)); 344 399 … … 361 416 //****************************************************************************** 362 417 //****************************************************************************** 363 #ifdef DEBUG 364 static DWORD GetObjectTypeNoDbg( HGDIOBJ hObj) 418 DWORD WIN32API GetObjectType( HGDIOBJ hObj) 419 { 420 DWORD objtype = ObjQueryHandleType(hObj); 421 422 switch(objtype) { 423 case HNDL_PEN: 424 objtype = OBJ_PEN; 425 break; 426 case HNDL_BRUSH: 427 objtype = OBJ_BRUSH; 428 break; 429 case HNDL_DC: 430 objtype = OBJ_DC; 431 break; 432 case HNDL_METADC: 433 objtype = OBJ_METADC; 434 break; 435 case HNDL_PALETTE: 436 objtype = OBJ_PAL; 437 break; 438 case HNDL_FONT: 439 objtype = OBJ_FONT; 440 break; 441 case HNDL_BITMAP: 442 case HNDL_DIBSECTION: 443 objtype = OBJ_BITMAP; 444 break; 445 case HNDL_REGION: 446 objtype = OBJ_REGION; 447 break; 448 case HNDL_METAFILE: 449 objtype = OBJ_METAFILE; 450 break; 451 case HNDL_ENHMETAFILE: 452 objtype = OBJ_ENHMETAFILE; 453 break; 454 case HNDL_MEMDC: 455 objtype = OBJ_MEMDC; 456 break; 457 case HNDL_EXTPEN: 458 objtype = OBJ_EXTPEN; 459 break; 460 case HNDL_ENHMETADC: 461 objtype = OBJ_ENHMETADC; 462 break; 463 default: 464 objtype = 0; 465 break; 466 } 467 dprintf2(("GDI32: GetObjectType %x objtype %d (%s)", hObj, objtype, DbgGetGDITypeName(objtype))); 468 return objtype; 469 } 470 //****************************************************************************** 471 //TODO: System objects can't be deleted (TODO: any others?? (fonts?))!!!!) 472 //****************************************************************************** 473 BOOL WIN32API DeleteObject(HANDLE hObj) 365 474 { 366 475 DWORD objtype; 367 476 368 //TODO: must use 16 bits gdi object handles369 if(HIWORD(hObj) == 0) {370 hObj |= GDIOBJ_PREFIX;371 }372 if(ObjGetHandleType(hObj) == GDIOBJ_REGION) {373 dprintf2(("GDI32: GetObjectType %x REGION", hObj));374 SetLastError(ERROR_SUCCESS);375 return OBJ_REGION;376 }377 return O32_GetObjectType(hObj);378 }379 #endif380 //******************************************************************************381 //******************************************************************************382 DWORD WIN32API GetObjectType( HGDIOBJ hObj)383 {384 DWORD objtype;385 386 //TODO: must use 16 bits gdi object handles387 if(HIWORD(hObj) == 0) {388 hObj |= GDIOBJ_PREFIX;389 }390 if(ObjGetHandleType(hObj) == GDIOBJ_REGION) {391 dprintf2(("GDI32: GetObjectType %x REGION", hObj));392 SetLastError(ERROR_SUCCESS);393 return OBJ_REGION;394 }395 objtype = O32_GetObjectType(hObj);396 dprintf2(("GDI32: GetObjectType %x objtype %d", hObj, objtype));397 return objtype;398 }399 //******************************************************************************400 //TODO: System objects can't be deleted (TODO: any others?? (fonts?))!!!!)401 //******************************************************************************402 BOOL WIN32API DeleteObject(HANDLE hObj)403 {404 DWORD objtype;405 406 477 dprintf(("GDI32: DeleteObject %x", hObj)); 407 478 408 //TODO: must use 16 bits gdi object handles409 if(HIWORD(hObj) == 0)410 {411 hObj |= GDIOBJ_PREFIX;412 }413 414 //System objects can't be deleted (TODO: any others?? (fonts?))!!!!)415 objtype = GetObjectTypeNoDbg(hObj);416 switch (objtype)417 {418 case OBJ_PEN:419 if(IsSystemPen(hObj))420 {421 SetLastError(ERROR_SUCCESS);422 return TRUE;423 }424 else425 break;426 427 case OBJ_BRUSH:428 if(IsSystemBrush(hObj))429 {430 SetLastError(ERROR_SUCCESS);431 return TRUE;432 }433 else434 break;435 436 case OBJ_FONT:437 if(IsSystemFont(hObj))438 {439 SetLastError(ERROR_SUCCESS);440 return TRUE;441 }442 else443 break;444 445 // add more system-type objects as required ...446 }447 448 479 STATS_DeleteObject(hObj, objtype); 449 480 450 if(Obj GetHandleType(hObj) == GDIOBJ_REGION)451 { 452 OSLibDeleteRegion(Obj GetHandleData(hObj, GDIOBJ_REGION));453 Obj FreeHandle(hObj);481 if(ObjQueryHandleType(hObj) == HNDL_REGION) 482 { 483 OSLibDeleteRegion(ObjQueryHandleData(hObj, HNDL_REGION)); 484 ObjDeleteHandle(hObj, HNDL_REGION); 454 485 SetLastError(ERROR_SUCCESS); 455 486 return TRUE; -
trunk/src/gdi32/region.cpp
r7800 r8871 1 /* $Id: region.cpp,v 1.2 7 2002-02-05 11:45:46sandervl Exp $ */1 /* $Id: region.cpp,v 1.28 2002-07-15 10:02:29 sandervl Exp $ */ 2 2 3 3 /* … … 396 396 if(hrgn) 397 397 { 398 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);398 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 399 399 if(hrgn == HANDLE_OBJ_ERROR) { 400 400 dprintf(("WARNING: SelectClipRgn: invalid region!", hdc, hrgn1)); … … 488 488 if(hrgn) 489 489 { 490 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);490 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 491 491 if(hrgn == HANDLE_OBJ_ERROR) { 492 492 dprintf(("WARNING: ExtSelectRgn %x %x %d invalid region handle", hdc, hrgn1, mode)); … … 637 637 #endif 638 638 639 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);639 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 640 640 if(hrgn == HANDLE_OBJ_ERROR || !pHps) { 641 641 dprintf(("WARNING: GetClipRgn %x %x invalid handle", hdc, hrgn1)); … … 832 832 } 833 833 834 if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {834 if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) { 835 835 GpiDestroyRegion(hpsRegion, hrgn); 836 836 SetLastError(ERROR_OUTOFMEMORY_W); … … 856 856 } 857 857 858 if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {858 if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) { 859 859 GpiDestroyRegion(hpsRegion, hrgn); 860 860 SetLastError(ERROR_OUTOFMEMORY_W); … … 891 891 } 892 892 893 if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {893 if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) { 894 894 GpiDestroyRegion(hpsRegion, hrgn); 895 895 SetLastError(ERROR_OUTOFMEMORY_W); … … 1004 1004 } 1005 1005 1006 if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {1006 if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) { 1007 1007 GpiDestroyRegion(hpsRegion, hrgn); 1008 1008 SetLastError(ERROR_OUTOFMEMORY_W); … … 1027 1027 hrgn = GpiCreateEllipticRegion(hpsRegion, &rectl); 1028 1028 1029 if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {1029 if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) { 1030 1030 GpiDestroyRegion(hpsRegion, hrgn); 1031 1031 SetLastError(ERROR_OUTOFMEMORY_W); … … 1077 1077 hrgn = GpiCreatePolygonRegion(hpsRegion, 1, &polygon, POLYGON_BOUNDARY | flMode); 1078 1078 1079 if(ObjAllocateHandle(&hrgn, hrgn, GDIOBJ_REGION) == FALSE) {1079 if(ObjAllocateHandle(&hrgn, hrgn, HNDL_REGION) == FALSE) { 1080 1080 GpiDestroyRegion(hpsRegion, hrgn); 1081 1081 SetLastError(ERROR_OUTOFMEMORY_W); … … 1120 1120 } 1121 1121 1122 hrgnDest = Obj GetHandleData(hrgnDest, GDIOBJ_REGION);1123 hrgnSrc1 = Obj GetHandleData(hrgnSrc1, GDIOBJ_REGION);1124 hrgnSrc2 = Obj GetHandleData(hrgnSrc2, GDIOBJ_REGION);1122 hrgnDest = ObjQueryHandleData(hrgnDest, HNDL_REGION); 1123 hrgnSrc1 = ObjQueryHandleData(hrgnSrc1, HNDL_REGION); 1124 hrgnSrc2 = ObjQueryHandleData(hrgnSrc2, HNDL_REGION); 1125 1125 if(hrgnDest == HANDLE_OBJ_ERROR || hrgnSrc1 == HANDLE_OBJ_ERROR || (hrgnSrc2 == HANDLE_OBJ_ERROR && combineMode != RGN_COPY_W)) { 1126 1126 dprintf(("WARNING: CombineRgn %x %x %x %d invalid region", hrgn1, hrgn2, hrgn3, combineMode)); … … 1149 1149 #endif 1150 1150 1151 hrgn1 = Obj GetHandleData(hrgn1, GDIOBJ_REGION);1152 hrgn2 = Obj GetHandleData(hrgn2, GDIOBJ_REGION);1151 hrgn1 = ObjQueryHandleData(hrgn1, HNDL_REGION); 1152 hrgn2 = ObjQueryHandleData(hrgn2, HNDL_REGION); 1153 1153 if(hrgn1 == HANDLE_OBJ_ERROR || hrgn2 == HANDLE_OBJ_ERROR) { 1154 1154 dprintf(("WARNING: EqualRgn %x %x invalid region", hrgnt1, hrgnt2)); … … 1179 1179 #endif 1180 1180 1181 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1181 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1182 1182 if(hrgn == HANDLE_OBJ_ERROR) { 1183 1183 dprintf(("WARNING: SetRectRgn %x (%d,%d)(%d,%d) invalid region handle", hrgn1, left, top, right, bottom)); … … 1208 1208 return 0; 1209 1209 } 1210 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1210 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1211 1211 if(hrgn == HANDLE_OBJ_ERROR) { 1212 1212 dprintf(("WARNING: GetRegionData %x %d %x; invalid region handle", hrgn1, count, pData)); … … 1269 1269 #endif 1270 1270 1271 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1271 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1272 1272 if(hrgn == HANDLE_OBJ_ERROR) { 1273 1273 dprintf(("WARNING: GetRgnBox %x %x invalid region!", hrgn1, pRect)); … … 1305 1305 pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); 1306 1306 1307 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1307 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1308 1308 if(!pHps || hrgn == HANDLE_OBJ_ERROR) { 1309 1309 dprintf(("WARNING: InvertRgn %x %x invalid handle!", hdc, hrgn)); … … 1356 1356 #endif 1357 1357 1358 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1358 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1359 1359 if(hrgn == HANDLE_OBJ_ERROR) { 1360 1360 dprintf(("WARNING: OffsetRgn %x %d %d invalid handle!", hrgn, xOffset, yOffset)); … … 1405 1405 pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); 1406 1406 1407 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1407 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1408 1408 if(!pHps || hrgn == HANDLE_OBJ_ERROR) { 1409 1409 dprintf(("WARNING: FrameRgn %x %x %x (%d,%d) invalid handle!", hdc, hrgn, hBrush, width, height)); … … 1452 1452 pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); 1453 1453 1454 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1454 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1455 1455 if(!pHps || hrgn == HANDLE_OBJ_ERROR) { 1456 1456 dprintf(("WARNING: FillRgn %x %x %x invalid handle!", hdc, hrgn1, hBrush)); … … 1506 1506 #endif 1507 1507 1508 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1508 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1509 1509 if(hrgn == HANDLE_OBJ_ERROR) { 1510 1510 dprintf(("WARNING: PtInRgn %x (%d,%d) invalid region!", hrgn1, x, y)); … … 1544 1544 return FALSE; 1545 1545 } 1546 hrgn = Obj GetHandleData(hrgn, GDIOBJ_REGION);1546 hrgn = ObjQueryHandleData(hrgn, HNDL_REGION); 1547 1547 if(hrgn == HANDLE_OBJ_ERROR) { 1548 1548 dprintf(("WARNING: RectInRgn %x %x invalid region", hrgn1, pRect)); … … 1595 1595 1596 1596 hrgnwin = CreateRectRgn(1, 1, 2, 2); 1597 hrgn = Obj GetHandleData(hrgnwin, GDIOBJ_REGION);1597 hrgn = ObjQueryHandleData(hrgnwin, HNDL_REGION); 1598 1598 if(hrgn == HANDLE_OBJ_ERROR) { 1599 1599 dprintf(("WARNING: PathToRegion invalid region", hrgnwin)); -
trunk/src/gdi32/rgbcvt.h
r4034 r8871 1 //$Id: rgbcvt.h,v 1. 2 2000-08-18 18:14:58sandervl Exp $1 //$Id: rgbcvt.h,v 1.3 2002-07-15 10:02:30 sandervl Exp $ 2 2 #ifndef __RGBCVT_H__ 3 3 #define __RGBCVT_H__ 4 5 #define RGB555_RED_MASK 0x7c00 6 #define RGB555_GREEN_MASK 0x03e0 7 #define RGB555_BLUE_MASK 0x001f 8 9 #define RGB565_RED_MASK 0xF800 10 #define RGB565_GREEN_MASK 0x07e0 11 #define RGB565_BLUE_MASK 0x001f 12 13 //Default 16 bpp = RGB555 14 #define DEFAULT_16BPP_RED_MASK RGB555_RED_MASK 15 #define DEFAULT_16BPP_GREEN_MASK RGB555_GREEN_MASK 16 #define DEFAULT_16BPP_BLUE_MASK RGB555_BLUE_MASK 17 18 //Default 24/32 bpp = RGB888 19 #define DEFAULT_24BPP_RED_MASK 0xff0000 20 #define DEFAULT_24BPP_GREEN_MASK 0x00ff00 21 #define DEFAULT_24BPP_BLUE_MASK 0x0000ff 22 23 #define DEFAULT_32BPP_RED_MASK DEFAULT_24BPP_RED_MASK 24 #define DEFAULT_32BPP_GREEN_MASK DEFAULT_24BPP_GREEN_MASK 25 #define DEFAULT_32BPP_BLUE_MASK DEFAULT_24BPP_BLUE_MASK 26 4 27 5 28 void _Optlink RGB555to565(WORD *dest, WORD *src, ULONG num);
Note:
See TracChangeset
for help on using the changeset viewer.