- Timestamp:
- Jun 14, 2000, 8:30:18 PM (25 years ago)
- Location:
- trunk/src/gdi32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/dibsect.cpp
r3626 r3711 1 /* $Id: dibsect.cpp,v 1.3 3 2000-05-28 17:03:18sandervl Exp $ */1 /* $Id: dibsect.cpp,v 1.34 2000-06-14 18:30:15 sandervl Exp $ */ 2 2 3 3 /* … … 27 27 #include <win32wnd.h> 28 28 #include <cpuhlp.h> 29 #include <dcdata.h> 29 30 #include "oslibgpi.h" 30 31 #include "rgbcvt.h" … … 38 39 //****************************************************************************** 39 40 DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD hSection, DWORD dwOffset, DWORD handle, int fFlip) 40 : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBits Buffer(NULL)41 : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsDblBuffer(NULL) 41 42 { 42 43 bmpsize = pbmi->biWidth; … … 164 165 //double buffer for rgb 555 dib sections (for conversion) or flipped sections 165 166 if(dibinfo.dsBitfields[1] == 0x03e0 || (fFlip & FLIP_VERT)) { 166 DosAllocMem((PPVOID)&bmpBits Buffer, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);167 DosAllocMem((PPVOID)&bmpBitsDblBuffer, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT); 167 168 } 168 169 … … 205 206 DosFreeMem(bmpBits); 206 207 207 if(bmpBits Buffer)208 DosFreeMem(bmpBits Buffer);208 if(bmpBitsDblBuffer) 209 DosFreeMem(bmpBitsDblBuffer); 209 210 210 211 if(pOS2bmp) … … 341 342 //double buffer for rgb 555 dib sections (for conversion) or flipped sections 342 343 if(dibinfo.dsBitfields[1] == 0x03e0 || (fFlip & FLIP_VERT)) { 343 if(bmpBits Buffer) {344 DosFreeMem(bmpBits Buffer);344 if(bmpBitsDblBuffer) { 345 DosFreeMem(bmpBitsDblBuffer); 345 346 } 346 DosAllocMem((PPVOID)&bmpBits Buffer, dibinfo.dsBm.bmWidthBytes*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT);347 DosAllocMem((PPVOID)&bmpBitsDblBuffer, dibinfo.dsBm.bmWidthBytes*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT); 347 348 } 348 349 … … 394 395 BOOL fRestoryYInversion = FALSE, fFrameWindowDC = FALSE; 395 396 HWND hwndDest; 396 397 hwndDest = WindowFromDC(hdcDest); 398 //TODO: Test whether dc is for the client or frame window 399 // if(hwndDest && IsOS2FrameWindowHandle(hwndDest)) { 400 // fFrameWindowDC = TRUE; 401 // } 397 pDCData pHps; 398 399 pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc); 400 if(!pHps) 401 { 402 SetLastError(ERROR_INVALID_HANDLE_W); 403 return FALSE; 404 } 405 406 hwndDest = WindowFromDC(hdcDest); //could return desktop window, so check that 407 if(hwndDest && pHps->hwnd && !pHps->isClient) { 408 fFrameWindowDC = TRUE; 409 } 402 410 403 411 dprintf(("DIBSection::BitBlt %x %X (hps %x) %x to(%d,%d)(%d,%d) from (%d,%d)(%d,%d) rop %x flip %x", … … 478 486 //manually reverse bitmap data 479 487 char *src = bmpBits + (pOS2bmp->cy-1)*dibinfo.dsBm.bmWidthBytes; 480 char *dst = bmpBits Buffer;488 char *dst = bmpBitsDblBuffer; 481 489 for(int i=0;i<pOS2bmp->cy;i++) { 482 490 memcpy(dst, src, dibinfo.dsBm.bmWidthBytes); … … 484 492 src -= dibinfo.dsBm.bmWidthBytes; 485 493 } 486 bmpBits = bmpBitsBuffer; 487 } 494 bitmapBits = bmpBitsDblBuffer; 495 } 496 else bitmapBits = bmpBits; 488 497 489 498 //SvL: Optimize this.. (don't convert entire bitmap if only a part will be blitted to the dc) … … 491 500 dprintf(("DIBSection::BitBlt; convert rgb 555 to 565 (old y inv. = %d)", oldyinversion)); 492 501 493 if(bmpBits Buffer == NULL)502 if(bmpBitsDblBuffer == NULL) 494 503 DebugInt3(); 495 504 496 505 if(CPUFeatures & CPUID_MMX) { 497 RGB555to565MMX((WORD *)bmpBits Buffer, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));506 RGB555to565MMX((WORD *)bmpBitsDblBuffer, (WORD *)bitmapBits, pOS2bmp->cbImage/sizeof(WORD)); 498 507 } 499 else RGB555to565((WORD *)bmpBits Buffer, (WORD *)bmpBits, pOS2bmp->cbImage/sizeof(WORD));500 rc = GpiDrawBits(hps, bmpBits Buffer, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);501 } 502 else rc = GpiDrawBits(hps, b mpBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode);508 else RGB555to565((WORD *)bmpBitsDblBuffer, (WORD *)bitmapBits, pOS2bmp->cbImage/sizeof(WORD)); 509 rc = GpiDrawBits(hps, bmpBitsDblBuffer, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode); 510 } 511 else rc = GpiDrawBits(hps, bitmapBits, pOS2bmp, 4, &point[0], ROP_SRCCOPY, os2mode); 503 512 504 513 if(rc == GPI_OK) { … … 533 542 BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize); 534 543 memcpy(tmphdr, pOS2bmp, os2bmphdrsize); 535 destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes; 536 rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf, 544 545 if(fFlip & FLIP_VERT) { 546 destBuf = bmpBitsDblBuffer + nYdest*dibinfo.dsBm.bmWidthBytes; 547 548 rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf, 549 tmphdr); 550 //manually reverse bitmap data 551 char *src = destBuf; 552 char *dst = GetDIBObject() + (nYdest+nDestHeight-1)*dibinfo.dsBm.bmWidthBytes; 553 for(int i=0;i<nDestHeight;i++) { 554 memcpy(dst, src, dibinfo.dsBm.bmWidthBytes); 555 dst -= dibinfo.dsBm.bmWidthBytes; 556 src += dibinfo.dsBm.bmWidthBytes; 557 } 558 } 559 else { 560 destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes; 561 rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf, 537 562 tmphdr); 563 } 538 564 free(tmphdr); 539 565 if(rc != nDestHeight) { -
trunk/src/gdi32/dibsect.h
r3594 r3711 1 /* $Id: dibsect.h,v 1.1 8 2000-05-23 18:46:20sandervl Exp $ */1 /* $Id: dibsect.h,v 1.19 2000-06-14 18:30:18 sandervl Exp $ */ 2 2 3 3 /* … … 103 103 HWND hwndParent; 104 104 HDC hdc; 105 char *bmpBits, *bmpBits Buffer;105 char *bmpBits, *bmpBitsDblBuffer; 106 106 BOOL fFlip; 107 107 int bmpsize, os2bmphdrsize;
Note:
See TracChangeset
for help on using the changeset viewer.