salgdi2.cxx (9f62ea84) | salgdi2.cxx (5f27b83c) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 45 unchanged lines hidden (view full) --- 54 bRet = bAllowForTest; 55 default: break; 56 } 57 return bRet; 58} 59 60// ======================================================================= 61 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 45 unchanged lines hidden (view full) --- 54 bRet = bAllowForTest; 55 default: break; 56 } 57 return bRet; 58} 59 60// ======================================================================= 61 |
62void WinSalGraphics::copyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics ) | 62void WinSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics ) |
63{ 64 HDC hSrcDC; 65 DWORD nRop; 66 67 if ( pSrcGraphics ) | 63{ 64 HDC hSrcDC; 65 DWORD nRop; 66 67 if ( pSrcGraphics ) |
68 hSrcDC = static_cast<WinSalGraphics*>(pSrcGraphics)->mhDC; | 68 hSrcDC = static_cast<WinSalGraphics*>(pSrcGraphics)->getHDC(); |
69 else | 69 else |
70 hSrcDC = mhDC; | 70 hSrcDC = getHDC(); |
71 72 if ( mbXORMode ) 73 nRop = SRCINVERT; 74 else 75 nRop = SRCCOPY; 76 | 71 72 if ( mbXORMode ) 73 nRop = SRCINVERT; 74 else 75 nRop = SRCCOPY; 76 |
77 if ( (pPosAry->mnSrcWidth == pPosAry->mnDestWidth) && 78 (pPosAry->mnSrcHeight == pPosAry->mnDestHeight) ) | 77 if ( (rPosAry.mnSrcWidth == rPosAry.mnDestWidth) && 78 (rPosAry.mnSrcHeight == rPosAry.mnDestHeight) ) |
79 { | 79 { |
80 BitBlt( mhDC, 81 (int)pPosAry->mnDestX, (int)pPosAry->mnDestY, 82 (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight, | 80 BitBlt( getHDC(), 81 (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, 82 (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, |
83 hSrcDC, | 83 hSrcDC, |
84 (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY, | 84 (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, |
85 nRop ); 86 } 87 else 88 { | 85 nRop ); 86 } 87 else 88 { |
89 int nOldStretchMode = SetStretchBltMode( mhDC, STRETCH_DELETESCANS ); 90 StretchBlt( mhDC, 91 (int)pPosAry->mnDestX, (int)pPosAry->mnDestY, 92 (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight, | 89 int nOldStretchMode = SetStretchBltMode( getHDC(), STRETCH_DELETESCANS ); 90 StretchBlt( getHDC(), 91 (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, 92 (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, |
93 hSrcDC, | 93 hSrcDC, |
94 (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY, 95 (int)pPosAry->mnSrcWidth, (int)pPosAry->mnSrcHeight, | 94 (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, 95 (int)rPosAry.mnSrcWidth, (int)rPosAry.mnSrcHeight, |
96 nRop ); | 96 nRop ); |
97 SetStretchBltMode( mhDC, nOldStretchMode ); | 97 SetStretchBltMode( getHDC(), nOldStretchMode ); |
98 } 99} 100 101// ----------------------------------------------------------------------- 102 103void ImplCalcOutSideRgn( const RECT& rSrcRect, 104 int nLeft, int nTop, int nRight, int nBottom, 105 HRGN& rhInvalidateRgn ) --- 174 unchanged lines hidden (view full) --- 280 int nOffX = (int)(nDestX-nSrcX); 281 int nOffY = (int)(nDestY-nSrcY); 282 OffsetRgn( hInvalidateRgn, nOffX-aPt.x, nOffY-aPt.y ); 283 284 // by excluding hInvalidateRgn from the system's clip region 285 // we will prevent bitblt from copying useless data 286 // epsecially now shadows from overlapping windows will appear (#i36344) 287 hOldClipRgn = CreateRectRgn( 0, 0, 0, 0 ); | 98 } 99} 100 101// ----------------------------------------------------------------------- 102 103void ImplCalcOutSideRgn( const RECT& rSrcRect, 104 int nLeft, int nTop, int nRight, int nBottom, 105 HRGN& rhInvalidateRgn ) --- 174 unchanged lines hidden (view full) --- 280 int nOffX = (int)(nDestX-nSrcX); 281 int nOffY = (int)(nDestY-nSrcY); 282 OffsetRgn( hInvalidateRgn, nOffX-aPt.x, nOffY-aPt.y ); 283 284 // by excluding hInvalidateRgn from the system's clip region 285 // we will prevent bitblt from copying useless data 286 // epsecially now shadows from overlapping windows will appear (#i36344) 287 hOldClipRgn = CreateRectRgn( 0, 0, 0, 0 ); |
288 nOldClipRgnType = GetClipRgn( mhDC, hOldClipRgn ); | 288 nOldClipRgnType = GetClipRgn( getHDC(), hOldClipRgn ); |
289 290 bRestoreClipRgn = TRUE; // indicate changed clipregion and force invalidate | 289 290 bRestoreClipRgn = TRUE; // indicate changed clipregion and force invalidate |
291 ExtSelectClipRgn( mhDC, hInvalidateRgn, RGN_DIFF ); | 291 ExtSelectClipRgn( getHDC(), hInvalidateRgn, RGN_DIFF ); |
292 } 293 } 294 } 295 } 296 | 292 } 293 } 294 } 295 } 296 |
297 BitBlt( mhDC, | 297 BitBlt( getHDC(), |
298 (int)nDestX, (int)nDestY, 299 (int)nSrcWidth, (int)nSrcHeight, | 298 (int)nDestX, (int)nDestY, 299 (int)nSrcWidth, (int)nSrcHeight, |
300 mhDC, | 300 getHDC(), |
301 (int)nSrcX, (int)nSrcY, 302 SRCCOPY ); 303 304 if( bRestoreClipRgn ) 305 { 306 // restore old clip region 307 if( nOldClipRgnType != ERROR ) | 301 (int)nSrcX, (int)nSrcY, 302 SRCCOPY ); 303 304 if( bRestoreClipRgn ) 305 { 306 // restore old clip region 307 if( nOldClipRgnType != ERROR ) |
308 SelectClipRgn( mhDC, hOldClipRgn); | 308 SelectClipRgn( getHDC(), hOldClipRgn); |
309 DeleteRegion( hOldClipRgn ); 310 311 // invalidate regions that were not copied 312 bool bInvalidate = true; 313 314 // Combine Invalidate Region with existing ClipRegion 315 HRGN hTempRgn = CreateRectRgn( 0, 0, 0, 0 ); | 309 DeleteRegion( hOldClipRgn ); 310 311 // invalidate regions that were not copied 312 bool bInvalidate = true; 313 314 // Combine Invalidate Region with existing ClipRegion 315 HRGN hTempRgn = CreateRectRgn( 0, 0, 0, 0 ); |
316 if ( GetClipRgn( mhDC, hTempRgn ) == 1 ) | 316 if ( GetClipRgn( getHDC(), hTempRgn ) == 1 ) |
317 { 318 int nRgnType = CombineRgn( hInvalidateRgn, hTempRgn, hInvalidateRgn, RGN_AND ); 319 if ( (nRgnType == ERROR) || (nRgnType == NULLREGION) ) 320 bInvalidate = false; 321 } 322 DeleteRegion( hTempRgn ); 323 324 if ( bInvalidate ) --- 12 unchanged lines hidden (view full) --- 337 DeleteRegion( hInvalidateRgn ); 338 } 339 340} 341 342// ----------------------------------------------------------------------- 343 344void ImplDrawBitmap( HDC hDC, | 317 { 318 int nRgnType = CombineRgn( hInvalidateRgn, hTempRgn, hInvalidateRgn, RGN_AND ); 319 if ( (nRgnType == ERROR) || (nRgnType == NULLREGION) ) 320 bInvalidate = false; 321 } 322 DeleteRegion( hTempRgn ); 323 324 if ( bInvalidate ) --- 12 unchanged lines hidden (view full) --- 337 DeleteRegion( hInvalidateRgn ); 338 } 339 340} 341 342// ----------------------------------------------------------------------- 343 344void ImplDrawBitmap( HDC hDC, |
345 const SalTwoRect* pPosAry, const WinSalBitmap& rSalBitmap, | 345 const SalTwoRect& rPosAry, const WinSalBitmap& rSalBitmap, |
346 sal_Bool bPrinter, int nDrawMode ) 347{ 348 if( hDC ) 349 { 350 HGLOBAL hDrawDIB; 351 HBITMAP hDrawDDB = rSalBitmap.ImplGethDDB(); 352 WinSalBitmap* pTmpSalBmp = NULL; 353 sal_Bool bPrintDDB = ( bPrinter && hDrawDDB ); --- 11 unchanged lines hidden (view full) --- 365 { 366 PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( hDrawDIB ); 367 PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) pBI; 368 PBYTE pBits = (PBYTE) pBI + *(DWORD*) pBI + 369 rSalBitmap.ImplGetDIBColorCount( hDrawDIB ) * sizeof( RGBQUAD ); 370 const int nOldStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS ); 371 372 StretchDIBits( hDC, | 346 sal_Bool bPrinter, int nDrawMode ) 347{ 348 if( hDC ) 349 { 350 HGLOBAL hDrawDIB; 351 HBITMAP hDrawDDB = rSalBitmap.ImplGethDDB(); 352 WinSalBitmap* pTmpSalBmp = NULL; 353 sal_Bool bPrintDDB = ( bPrinter && hDrawDDB ); --- 11 unchanged lines hidden (view full) --- 365 { 366 PBITMAPINFO pBI = (PBITMAPINFO) GlobalLock( hDrawDIB ); 367 PBITMAPINFOHEADER pBIH = (PBITMAPINFOHEADER) pBI; 368 PBYTE pBits = (PBYTE) pBI + *(DWORD*) pBI + 369 rSalBitmap.ImplGetDIBColorCount( hDrawDIB ) * sizeof( RGBQUAD ); 370 const int nOldStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS ); 371 372 StretchDIBits( hDC, |
373 (int)pPosAry->mnDestX, (int)pPosAry->mnDestY, 374 (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight, 375 (int)pPosAry->mnSrcX, (int)(pBIH->biHeight - pPosAry->mnSrcHeight - pPosAry->mnSrcY), 376 (int)pPosAry->mnSrcWidth, (int)pPosAry->mnSrcHeight, | 373 (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, 374 (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, 375 (int)rPosAry.mnSrcX, (int)(pBIH->biHeight - rPosAry.mnSrcHeight - rPosAry.mnSrcY), 376 (int)rPosAry.mnSrcWidth, (int)rPosAry.mnSrcHeight, |
377 pBits, pBI, DIB_RGB_COLORS, nDrawMode ); 378 379 GlobalUnlock( hDrawDIB ); 380 SetStretchBltMode( hDC, nOldStretchMode ); 381 } 382 else if( hDrawDDB && !bPrintDDB ) 383 { 384 HDC hBmpDC = ImplGetCachedDC( CACHED_HDC_DRAW, hDrawDDB ); 385 COLORREF nOldBkColor = RGB(0xFF,0xFF,0xFF); 386 COLORREF nOldTextColor = RGB(0,0,0); 387 sal_Bool bMono = ( rSalBitmap.GetBitCount() == 1 ); 388 389 if( bMono ) 390 { 391 nOldBkColor = SetBkColor( hDC, RGB( 0xFF, 0xFF, 0xFF ) ); 392 nOldTextColor = ::SetTextColor( hDC, RGB( 0x00, 0x00, 0x00 ) ); 393 } 394 | 377 pBits, pBI, DIB_RGB_COLORS, nDrawMode ); 378 379 GlobalUnlock( hDrawDIB ); 380 SetStretchBltMode( hDC, nOldStretchMode ); 381 } 382 else if( hDrawDDB && !bPrintDDB ) 383 { 384 HDC hBmpDC = ImplGetCachedDC( CACHED_HDC_DRAW, hDrawDDB ); 385 COLORREF nOldBkColor = RGB(0xFF,0xFF,0xFF); 386 COLORREF nOldTextColor = RGB(0,0,0); 387 sal_Bool bMono = ( rSalBitmap.GetBitCount() == 1 ); 388 389 if( bMono ) 390 { 391 nOldBkColor = SetBkColor( hDC, RGB( 0xFF, 0xFF, 0xFF ) ); 392 nOldTextColor = ::SetTextColor( hDC, RGB( 0x00, 0x00, 0x00 ) ); 393 } 394 |
395 if ( (pPosAry->mnSrcWidth == pPosAry->mnDestWidth) && 396 (pPosAry->mnSrcHeight == pPosAry->mnDestHeight) ) | 395 if ( (rPosAry.mnSrcWidth == rPosAry.mnDestWidth) && 396 (rPosAry.mnSrcHeight == rPosAry.mnDestHeight) ) |
397 { 398 BitBlt( hDC, | 397 { 398 BitBlt( hDC, |
399 (int)pPosAry->mnDestX, (int)pPosAry->mnDestY, 400 (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight, | 399 (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, 400 (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, |
401 hBmpDC, | 401 hBmpDC, |
402 (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY, | 402 (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, |
403 nDrawMode ); 404 } 405 else 406 { 407 const int nOldStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS ); 408 409 StretchBlt( hDC, | 403 nDrawMode ); 404 } 405 else 406 { 407 const int nOldStretchMode = SetStretchBltMode( hDC, STRETCH_DELETESCANS ); 408 409 StretchBlt( hDC, |
410 (int)pPosAry->mnDestX, (int)pPosAry->mnDestY, 411 (int)pPosAry->mnDestWidth, (int)pPosAry->mnDestHeight, | 410 (int)rPosAry.mnDestX, (int)rPosAry.mnDestY, 411 (int)rPosAry.mnDestWidth, (int)rPosAry.mnDestHeight, |
412 hBmpDC, | 412 hBmpDC, |
413 (int)pPosAry->mnSrcX, (int)pPosAry->mnSrcY, 414 (int)pPosAry->mnSrcWidth, (int)pPosAry->mnSrcHeight, | 413 (int)rPosAry.mnSrcX, (int)rPosAry.mnSrcY, 414 (int)rPosAry.mnSrcWidth, (int)rPosAry.mnSrcHeight, |
415 nDrawMode ); 416 417 SetStretchBltMode( hDC, nOldStretchMode ); 418 } 419 420 if( bMono ) 421 { 422 SetBkColor( hDC, nOldBkColor ); --- 5 unchanged lines hidden (view full) --- 428 429 if( bPrintDDB ) 430 delete pTmpSalBmp; 431 } 432} 433 434// ----------------------------------------------------------------------- 435 | 415 nDrawMode ); 416 417 SetStretchBltMode( hDC, nOldStretchMode ); 418 } 419 420 if( bMono ) 421 { 422 SetBkColor( hDC, nOldBkColor ); --- 5 unchanged lines hidden (view full) --- 428 429 if( bPrintDDB ) 430 delete pTmpSalBmp; 431 } 432} 433 434// ----------------------------------------------------------------------- 435 |
436void WinSalGraphics::drawBitmap( const SalTwoRect* pPosAry, 437 const SalBitmap& rSalBitmap ) | 436void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) |
438{ | 437{ |
439 ImplDrawBitmap( mhDC, pPosAry, static_cast<const WinSalBitmap&>(rSalBitmap), 440 mbPrinter, 441 mbXORMode ? SRCINVERT : SRCCOPY ); | 438 bool bTryDirectPaint(!mbPrinter && !mbXORMode); 439 440 if(bTryDirectPaint) 441 { 442 // only paint direct when no scaling and no MapMode, else the 443 // more expensive conversions may be done for short-time Bitmap/BitmapEx 444 // used for buffering only 445 if(rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight) 446 { 447 bTryDirectPaint = false; 448 } 449 } 450 451 // try to draw using GdiPlus directly 452 if(bTryDirectPaint && tryDrawBitmapGdiPlus(rPosAry, rSalBitmap)) 453 { 454 return; 455 } 456 457 // fall back old stuff 458 ImplDrawBitmap(getHDC(), rPosAry, static_cast<const WinSalBitmap&>(rSalBitmap), 459 mbPrinter, 460 mbXORMode ? SRCINVERT : SRCCOPY ); |
442} 443 444// ----------------------------------------------------------------------- 445 | 461} 462 463// ----------------------------------------------------------------------- 464 |
446void WinSalGraphics::drawBitmap( const SalTwoRect* pPosAry, | 465void WinSalGraphics::drawBitmap( const SalTwoRect& rPosAry, |
447 const SalBitmap& rSSalBitmap, 448 SalColor nTransparentColor ) 449{ 450 DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 451 452 const WinSalBitmap& rSalBitmap = static_cast<const WinSalBitmap&>(rSSalBitmap); 453 454 WinSalBitmap* pMask = new WinSalBitmap; --- 32 unchanged lines hidden (view full) --- 487 488 delete pTmpSalBmp; 489 } 490 491 ImplReleaseCachedDC( CACHED_HDC_1 ); 492 493 // hMaskBitmap is destroyed by new SalBitmap 'pMask' ( bDIB==FALSE, bCopy == FALSE ) 494 if( pMask->Create( hMaskBitmap, FALSE, FALSE ) ) | 466 const SalBitmap& rSSalBitmap, 467 SalColor nTransparentColor ) 468{ 469 DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 470 471 const WinSalBitmap& rSalBitmap = static_cast<const WinSalBitmap&>(rSSalBitmap); 472 473 WinSalBitmap* pMask = new WinSalBitmap; --- 32 unchanged lines hidden (view full) --- 506 507 delete pTmpSalBmp; 508 } 509 510 ImplReleaseCachedDC( CACHED_HDC_1 ); 511 512 // hMaskBitmap is destroyed by new SalBitmap 'pMask' ( bDIB==FALSE, bCopy == FALSE ) 513 if( pMask->Create( hMaskBitmap, FALSE, FALSE ) ) |
495 drawBitmap( pPosAry, rSalBitmap, *pMask ); | 514 drawBitmap( rPosAry, rSalBitmap, *pMask ); |
496 497 delete pMask; 498} 499 500// ----------------------------------------------------------------------- 501 | 515 516 delete pMask; 517} 518 519// ----------------------------------------------------------------------- 520 |
502void WinSalGraphics::drawBitmap( const SalTwoRect* pPosAry, | 521void WinSalGraphics::drawBitmap( const SalTwoRect& rPosAry, |
503 const SalBitmap& rSSalBitmap, 504 const SalBitmap& rSTransparentBitmap ) 505{ 506 DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); | 522 const SalBitmap& rSSalBitmap, 523 const SalBitmap& rSTransparentBitmap ) 524{ 525 DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); |
526 bool bTryDirectPaint(!mbPrinter && !mbXORMode); |
|
507 | 527 |
528 if(bTryDirectPaint) 529 { 530 // only paint direct when no scaling and no MapMode, else the 531 // more expensive conversions may be done for short-time Bitmap/BitmapEx 532 // used for buffering only 533 if(rPosAry.mnSrcWidth == rPosAry.mnDestWidth && rPosAry.mnSrcHeight == rPosAry.mnDestHeight) 534 { 535 bTryDirectPaint = false; 536 } 537 } 538 539 // try to draw using GdiPlus directly 540 if(bTryDirectPaint && drawAlphaBitmap(rPosAry, rSSalBitmap, rSTransparentBitmap)) 541 { 542 return; 543 } 544 |
|
508 const WinSalBitmap& rSalBitmap = static_cast<const WinSalBitmap&>(rSSalBitmap); 509 const WinSalBitmap& rTransparentBitmap = static_cast<const WinSalBitmap&>(rSTransparentBitmap); 510 | 545 const WinSalBitmap& rSalBitmap = static_cast<const WinSalBitmap&>(rSSalBitmap); 546 const WinSalBitmap& rTransparentBitmap = static_cast<const WinSalBitmap&>(rSTransparentBitmap); 547 |
511 SalTwoRect aPosAry = *pPosAry; | 548 SalTwoRect aPosAry = rPosAry; |
512 int nDstX = (int)aPosAry.mnDestX; 513 int nDstY = (int)aPosAry.mnDestY; 514 int nDstWidth = (int)aPosAry.mnDestWidth; 515 int nDstHeight = (int)aPosAry.mnDestHeight; | 549 int nDstX = (int)aPosAry.mnDestX; 550 int nDstY = (int)aPosAry.mnDestY; 551 int nDstWidth = (int)aPosAry.mnDestWidth; 552 int nDstHeight = (int)aPosAry.mnDestHeight; |
516 HDC hDC = mhDC; | 553 HDC hDC = getHDC(); |
517 HBITMAP hMemBitmap = 0; 518 HBITMAP hMaskBitmap = 0; 519 520 if( ( nDstWidth > CACHED_HDC_DEFEXT ) || ( nDstHeight > CACHED_HDC_DEFEXT ) ) 521 { 522 hMemBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight ); 523 hMaskBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight ); 524 } --- 7 unchanged lines hidden (view full) --- 532 // bei Paletten-Displays hat WIN/WNT offenbar ein kleines Problem, 533 // die Farben der Maske richtig auf die Palette abzubilden, 534 // wenn wir die DIB direkt ausgeben => DDB-Ausgabe 535 if( ( GetBitCount() <= 8 ) && rTransparentBitmap.ImplGethDIB() && rTransparentBitmap.GetBitCount() == 1 ) 536 { 537 WinSalBitmap aTmp; 538 539 if( aTmp.Create( rTransparentBitmap, this ) ) | 554 HBITMAP hMemBitmap = 0; 555 HBITMAP hMaskBitmap = 0; 556 557 if( ( nDstWidth > CACHED_HDC_DEFEXT ) || ( nDstHeight > CACHED_HDC_DEFEXT ) ) 558 { 559 hMemBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight ); 560 hMaskBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight ); 561 } --- 7 unchanged lines hidden (view full) --- 569 // bei Paletten-Displays hat WIN/WNT offenbar ein kleines Problem, 570 // die Farben der Maske richtig auf die Palette abzubilden, 571 // wenn wir die DIB direkt ausgeben => DDB-Ausgabe 572 if( ( GetBitCount() <= 8 ) && rTransparentBitmap.ImplGethDIB() && rTransparentBitmap.GetBitCount() == 1 ) 573 { 574 WinSalBitmap aTmp; 575 576 if( aTmp.Create( rTransparentBitmap, this ) ) |
540 ImplDrawBitmap( hMaskDC, &aPosAry, aTmp, FALSE, SRCCOPY ); | 577 ImplDrawBitmap( hMaskDC, aPosAry, aTmp, FALSE, SRCCOPY ); |
541 } 542 else | 578 } 579 else |
543 ImplDrawBitmap( hMaskDC, &aPosAry, rTransparentBitmap, FALSE, SRCCOPY ); | 580 ImplDrawBitmap( hMaskDC, aPosAry, rTransparentBitmap, FALSE, SRCCOPY ); |
544 545 // now MemDC contains background, MaskDC the transparency mask 546 547 // #105055# Respect XOR mode 548 if( mbXORMode ) 549 { | 581 582 // now MemDC contains background, MaskDC the transparency mask 583 584 // #105055# Respect XOR mode 585 if( mbXORMode ) 586 { |
550 ImplDrawBitmap( hMaskDC, &aPosAry, rSalBitmap, FALSE, SRCERASE ); | 587 ImplDrawBitmap( hMaskDC, aPosAry, rSalBitmap, FALSE, SRCERASE ); |
551 // now MaskDC contains the bitmap area with black background 552 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hMaskDC, 0, 0, SRCINVERT ); 553 // now MemDC contains background XORed bitmap area ontop 554 } 555 else 556 { 557 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hMaskDC, 0, 0, SRCAND ); 558 // now MemDC contains background with masked-out bitmap area | 588 // now MaskDC contains the bitmap area with black background 589 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hMaskDC, 0, 0, SRCINVERT ); 590 // now MemDC contains background XORed bitmap area ontop 591 } 592 else 593 { 594 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hMaskDC, 0, 0, SRCAND ); 595 // now MemDC contains background with masked-out bitmap area |
559 ImplDrawBitmap( hMaskDC, &aPosAry, rSalBitmap, FALSE, SRCERASE ); | 596 ImplDrawBitmap( hMaskDC, aPosAry, rSalBitmap, FALSE, SRCERASE ); |
560 // now MaskDC contains the bitmap area with black background 561 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hMaskDC, 0, 0, SRCPAINT ); 562 // now MemDC contains background and bitmap merged together 563 } 564 // copy to output DC 565 BitBlt( hDC, nDstX, nDstY, nDstWidth, nDstHeight, hMemDC, 0, 0, SRCCOPY ); 566 567 ImplReleaseCachedDC( CACHED_HDC_1 ); --- 4 unchanged lines hidden (view full) --- 572 { 573 DeleteObject( hMemBitmap ); 574 DeleteObject( hMaskBitmap ); 575 } 576} 577 578// ----------------------------------------------------------------------- 579 | 597 // now MaskDC contains the bitmap area with black background 598 BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hMaskDC, 0, 0, SRCPAINT ); 599 // now MemDC contains background and bitmap merged together 600 } 601 // copy to output DC 602 BitBlt( hDC, nDstX, nDstY, nDstWidth, nDstHeight, hMemDC, 0, 0, SRCCOPY ); 603 604 ImplReleaseCachedDC( CACHED_HDC_1 ); --- 4 unchanged lines hidden (view full) --- 609 { 610 DeleteObject( hMemBitmap ); 611 DeleteObject( hMaskBitmap ); 612 } 613} 614 615// ----------------------------------------------------------------------- 616 |
580bool WinSalGraphics::drawAlphaBitmap( const SalTwoRect& rTR, 581 const SalBitmap& rSrcBitmap, 582 const SalBitmap& rAlphaBmp ) 583{ 584 (void)rTR; (void)rSrcBitmap; (void)rAlphaBmp; 585 586 // TODO(P3): implement alpha bmp blits. Catch: Windows only 587 // handles 32bpp, premultiplied bitmaps 588 return false; 589} 590 591// ----------------------------------------------------------------------- 592 | |
593bool WinSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, 594 long nHeight, sal_uInt8 nTransparency ) 595{ 596 if( mbPen || !mbBrush || mbXORMode ) 597 return false; // can only perform solid fills without XOR. 598 599 HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, 0 ); 600 SetPixel( hMemDC, (int)0, (int)0, mnBrushColor ); 601 602 BLENDFUNCTION aFunc = { 603 AC_SRC_OVER, 604 0, 605 255 - 255L*nTransparency/100, 606 0 607 }; 608 609 // hMemDC contains a 1x1 bitmap of the right color - stretch-blit 610 // that to dest hdc | 617bool WinSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, 618 long nHeight, sal_uInt8 nTransparency ) 619{ 620 if( mbPen || !mbBrush || mbXORMode ) 621 return false; // can only perform solid fills without XOR. 622 623 HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, 0 ); 624 SetPixel( hMemDC, (int)0, (int)0, mnBrushColor ); 625 626 BLENDFUNCTION aFunc = { 627 AC_SRC_OVER, 628 0, 629 255 - 255L*nTransparency/100, 630 0 631 }; 632 633 // hMemDC contains a 1x1 bitmap of the right color - stretch-blit 634 // that to dest hdc |
611 bool bRet = AlphaBlend( mhDC, nX, nY, nWidth, nHeight, | 635 bool bRet = AlphaBlend( getHDC(), nX, nY, nWidth, nHeight, |
612 hMemDC, 0,0,1,1, 613 aFunc ) == TRUE; 614 615 ImplReleaseCachedDC( CACHED_HDC_1 ); 616 617 return bRet; 618} 619 620// ----------------------------------------------------------------------- 621 | 636 hMemDC, 0,0,1,1, 637 aFunc ) == TRUE; 638 639 ImplReleaseCachedDC( CACHED_HDC_1 ); 640 641 return bRet; 642} 643 644// ----------------------------------------------------------------------- 645 |
622void WinSalGraphics::drawMask( const SalTwoRect* pPosAry, | 646void WinSalGraphics::drawMask( const SalTwoRect& rPosAry, |
623 const SalBitmap& rSSalBitmap, 624 SalColor nMaskColor ) 625{ 626 DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 627 628 const WinSalBitmap& rSalBitmap = static_cast<const WinSalBitmap&>(rSSalBitmap); 629 | 647 const SalBitmap& rSSalBitmap, 648 SalColor nMaskColor ) 649{ 650 DBG_ASSERT( !mbPrinter, "No transparency print possible!" ); 651 652 const WinSalBitmap& rSalBitmap = static_cast<const WinSalBitmap&>(rSSalBitmap); 653 |
630 SalTwoRect aPosAry = *pPosAry; | 654 SalTwoRect aPosAry = rPosAry; |
631 const BYTE cRed = SALCOLOR_RED( nMaskColor ); 632 const BYTE cGreen = SALCOLOR_GREEN( nMaskColor ); 633 const BYTE cBlue = SALCOLOR_BLUE( nMaskColor ); | 655 const BYTE cRed = SALCOLOR_RED( nMaskColor ); 656 const BYTE cGreen = SALCOLOR_GREEN( nMaskColor ); 657 const BYTE cBlue = SALCOLOR_BLUE( nMaskColor ); |
634 HDC hDC = mhDC; | 658 HDC hDC = getHDC(); |
635 HBRUSH hMaskBrush = CreateSolidBrush( RGB( cRed, cGreen, cBlue ) ); 636 HBRUSH hOldBrush = SelectBrush( hDC, hMaskBrush ); 637 638 // bei Paletten-Displays hat WIN/WNT offenbar ein kleines Problem, 639 // die Farben der Maske richtig auf die Palette abzubilden, 640 // wenn wir die DIB direkt ausgeben => DDB-Ausgabe 641 if( ( GetBitCount() <= 8 ) && rSalBitmap.ImplGethDIB() && rSalBitmap.GetBitCount() == 1 ) 642 { 643 WinSalBitmap aTmp; 644 645 if( aTmp.Create( rSalBitmap, this ) ) | 659 HBRUSH hMaskBrush = CreateSolidBrush( RGB( cRed, cGreen, cBlue ) ); 660 HBRUSH hOldBrush = SelectBrush( hDC, hMaskBrush ); 661 662 // bei Paletten-Displays hat WIN/WNT offenbar ein kleines Problem, 663 // die Farben der Maske richtig auf die Palette abzubilden, 664 // wenn wir die DIB direkt ausgeben => DDB-Ausgabe 665 if( ( GetBitCount() <= 8 ) && rSalBitmap.ImplGethDIB() && rSalBitmap.GetBitCount() == 1 ) 666 { 667 WinSalBitmap aTmp; 668 669 if( aTmp.Create( rSalBitmap, this ) ) |
646 ImplDrawBitmap( hDC, &aPosAry, aTmp, FALSE, 0x00B8074AUL ); | 670 ImplDrawBitmap( hDC, aPosAry, aTmp, FALSE, 0x00B8074AUL ); |
647 } 648 else | 671 } 672 else |
649 ImplDrawBitmap( hDC, &aPosAry, rSalBitmap, FALSE, 0x00B8074AUL ); | 673 ImplDrawBitmap( hDC, aPosAry, rSalBitmap, FALSE, 0x00B8074AUL ); |
650 651 SelectBrush( hDC, hOldBrush ); 652 DeleteBrush( hMaskBrush ); 653} 654 655// ----------------------------------------------------------------------- 656 657SalBitmap* WinSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY ) 658{ 659 DBG_ASSERT( !mbPrinter, "No ::GetBitmap() from printer possible!" ); 660 661 WinSalBitmap* pSalBitmap = NULL; 662 663 nDX = labs( nDX ); 664 nDY = labs( nDY ); 665 | 674 675 SelectBrush( hDC, hOldBrush ); 676 DeleteBrush( hMaskBrush ); 677} 678 679// ----------------------------------------------------------------------- 680 681SalBitmap* WinSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY ) 682{ 683 DBG_ASSERT( !mbPrinter, "No ::GetBitmap() from printer possible!" ); 684 685 WinSalBitmap* pSalBitmap = NULL; 686 687 nDX = labs( nDX ); 688 nDY = labs( nDY ); 689 |
666 HDC hDC = mhDC; | 690 HDC hDC = getHDC(); |
667 HBITMAP hBmpBitmap = CreateCompatibleBitmap( hDC, nDX, nDY ); 668 HDC hBmpDC = ImplGetCachedDC( CACHED_HDC_1, hBmpBitmap ); 669 sal_Bool bRet; 670 DWORD err = 0; 671 672 bRet = BitBlt( hBmpDC, 0, 0, (int) nDX, (int) nDY, hDC, (int) nX, (int) nY, SRCCOPY ) ? TRUE : FALSE; 673 ImplReleaseCachedDC( CACHED_HDC_1 ); 674 --- 16 unchanged lines hidden (view full) --- 691 692 return pSalBitmap; 693} 694 695// ----------------------------------------------------------------------- 696 697SalColor WinSalGraphics::getPixel( long nX, long nY ) 698{ | 691 HBITMAP hBmpBitmap = CreateCompatibleBitmap( hDC, nDX, nDY ); 692 HDC hBmpDC = ImplGetCachedDC( CACHED_HDC_1, hBmpBitmap ); 693 sal_Bool bRet; 694 DWORD err = 0; 695 696 bRet = BitBlt( hBmpDC, 0, 0, (int) nDX, (int) nDY, hDC, (int) nX, (int) nY, SRCCOPY ) ? TRUE : FALSE; 697 ImplReleaseCachedDC( CACHED_HDC_1 ); 698 --- 16 unchanged lines hidden (view full) --- 715 716 return pSalBitmap; 717} 718 719// ----------------------------------------------------------------------- 720 721SalColor WinSalGraphics::getPixel( long nX, long nY ) 722{ |
699 COLORREF aWinCol = ::GetPixel( mhDC, (int) nX, (int) nY ); | 723 COLORREF aWinCol = ::GetPixel( getHDC(), (int) nX, (int) nY ); |
700 701 if ( CLR_INVALID == aWinCol ) 702 return MAKE_SALCOLOR( 0, 0, 0 ); 703 else 704 return MAKE_SALCOLOR( GetRValue( aWinCol ), 705 GetGValue( aWinCol ), 706 GetBValue( aWinCol ) ); 707} 708 709// ----------------------------------------------------------------------- 710 711void WinSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) 712{ 713 if ( nFlags & SAL_INVERT_TRACKFRAME ) 714 { 715 HPEN hDotPen = CreatePen( PS_DOT, 0, 0 ); | 724 725 if ( CLR_INVALID == aWinCol ) 726 return MAKE_SALCOLOR( 0, 0, 0 ); 727 else 728 return MAKE_SALCOLOR( GetRValue( aWinCol ), 729 GetGValue( aWinCol ), 730 GetBValue( aWinCol ) ); 731} 732 733// ----------------------------------------------------------------------- 734 735void WinSalGraphics::invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) 736{ 737 if ( nFlags & SAL_INVERT_TRACKFRAME ) 738 { 739 HPEN hDotPen = CreatePen( PS_DOT, 0, 0 ); |
716 HPEN hOldPen = SelectPen( mhDC, hDotPen ); 717 HBRUSH hOldBrush = SelectBrush( mhDC, GetStockBrush( NULL_BRUSH ) ); 718 int nOldROP = SetROP2( mhDC, R2_NOT ); | 740 HPEN hOldPen = SelectPen( getHDC(), hDotPen ); 741 HBRUSH hOldBrush = SelectBrush( getHDC(), GetStockBrush( NULL_BRUSH ) ); 742 int nOldROP = SetROP2( getHDC(), R2_NOT ); |
719 | 743 |
720 WIN_Rectangle( mhDC, (int)nX, (int)nY, (int)(nX+nWidth), (int)(nY+nHeight) ); | 744 WIN_Rectangle( getHDC(), (int)nX, (int)nY, (int)(nX+nWidth), (int)(nY+nHeight) ); |
721 | 745 |
722 SetROP2( mhDC, nOldROP ); 723 SelectPen( mhDC, hOldPen ); 724 SelectBrush( mhDC, hOldBrush ); | 746 SetROP2( getHDC(), nOldROP ); 747 SelectPen( getHDC(), hOldPen ); 748 SelectBrush( getHDC(), hOldBrush ); |
725 DeletePen( hDotPen ); 726 } 727 else if ( nFlags & SAL_INVERT_50 ) 728 { 729 SalData* pSalData = GetSalData(); 730 if ( !pSalData->mh50Brush ) 731 { 732 if ( !pSalData->mh50Bmp ) 733 pSalData->mh50Bmp = ImplLoadSalBitmap( SAL_RESID_BITMAP_50 ); 734 pSalData->mh50Brush = CreatePatternBrush( pSalData->mh50Bmp ); 735 } 736 | 749 DeletePen( hDotPen ); 750 } 751 else if ( nFlags & SAL_INVERT_50 ) 752 { 753 SalData* pSalData = GetSalData(); 754 if ( !pSalData->mh50Brush ) 755 { 756 if ( !pSalData->mh50Bmp ) 757 pSalData->mh50Bmp = ImplLoadSalBitmap( SAL_RESID_BITMAP_50 ); 758 pSalData->mh50Brush = CreatePatternBrush( pSalData->mh50Bmp ); 759 } 760 |
737 COLORREF nOldTextColor = ::SetTextColor( mhDC, 0 ); 738 HBRUSH hOldBrush = SelectBrush( mhDC, pSalData->mh50Brush ); 739 PatBlt( mhDC, nX, nY, nWidth, nHeight, PATINVERT ); 740 ::SetTextColor( mhDC, nOldTextColor ); 741 SelectBrush( mhDC, hOldBrush ); | 761 COLORREF nOldTextColor = ::SetTextColor( getHDC(), 0 ); 762 HBRUSH hOldBrush = SelectBrush( getHDC(), pSalData->mh50Brush ); 763 PatBlt( getHDC(), nX, nY, nWidth, nHeight, PATINVERT ); 764 ::SetTextColor( getHDC(), nOldTextColor ); 765 SelectBrush( getHDC(), hOldBrush ); |
742 } 743 else 744 { 745 RECT aRect; 746 aRect.left = (int)nX; 747 aRect.top = (int)nY; 748 aRect.right = (int)nX+nWidth; 749 aRect.bottom = (int)nY+nHeight; | 766 } 767 else 768 { 769 RECT aRect; 770 aRect.left = (int)nX; 771 aRect.top = (int)nY; 772 aRect.right = (int)nX+nWidth; 773 aRect.bottom = (int)nY+nHeight; |
750 ::InvertRect( mhDC, &aRect ); | 774 ::InvertRect( getHDC(), &aRect ); |
751 } 752} 753 754// ----------------------------------------------------------------------- 755 756void WinSalGraphics::invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) 757{ 758 HPEN hPen; 759 HPEN hOldPen; 760 HBRUSH hBrush; 761 HBRUSH hOldBrush = 0; 762 COLORREF nOldTextColor RGB(0,0,0); | 775 } 776} 777 778// ----------------------------------------------------------------------- 779 780void WinSalGraphics::invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nSalFlags ) 781{ 782 HPEN hPen; 783 HPEN hOldPen; 784 HBRUSH hBrush; 785 HBRUSH hOldBrush = 0; 786 COLORREF nOldTextColor RGB(0,0,0); |
763 int nOldROP = SetROP2( mhDC, R2_NOT ); | 787 int nOldROP = SetROP2( getHDC(), R2_NOT ); |
764 765 if ( nSalFlags & SAL_INVERT_TRACKFRAME ) 766 hPen = CreatePen( PS_DOT, 0, 0 ); 767 else 768 { 769 770 if ( nSalFlags & SAL_INVERT_50 ) 771 { --- 6 unchanged lines hidden (view full) --- 778 } 779 780 hBrush = pSalData->mh50Brush; 781 } 782 else 783 hBrush = GetStockBrush( BLACK_BRUSH ); 784 785 hPen = GetStockPen( NULL_PEN ); | 788 789 if ( nSalFlags & SAL_INVERT_TRACKFRAME ) 790 hPen = CreatePen( PS_DOT, 0, 0 ); 791 else 792 { 793 794 if ( nSalFlags & SAL_INVERT_50 ) 795 { --- 6 unchanged lines hidden (view full) --- 802 } 803 804 hBrush = pSalData->mh50Brush; 805 } 806 else 807 hBrush = GetStockBrush( BLACK_BRUSH ); 808 809 hPen = GetStockPen( NULL_PEN ); |
786 nOldTextColor = ::SetTextColor( mhDC, 0 ); 787 hOldBrush = SelectBrush( mhDC, hBrush ); | 810 nOldTextColor = ::SetTextColor( getHDC(), 0 ); 811 hOldBrush = SelectBrush( getHDC(), hBrush ); |
788 } | 812 } |
789 hOldPen = SelectPen( mhDC, hPen ); | 813 hOldPen = SelectPen( getHDC(), hPen ); |
790 791 POINT* pWinPtAry; 792 // Unter NT koennen wir das Array direkt weiterreichen 793 DBG_ASSERT( sizeof( POINT ) == sizeof( SalPoint ), 794 "WinSalGraphics::DrawPolyLine(): POINT != SalPoint" ); 795 796 pWinPtAry = (POINT*)pPtAry; 797 // Wegen Windows 95 und der Beschraenkung auf eine maximale Anzahl 798 // von Punkten 799 if ( nSalFlags & SAL_INVERT_TRACKFRAME ) 800 { | 814 815 POINT* pWinPtAry; 816 // Unter NT koennen wir das Array direkt weiterreichen 817 DBG_ASSERT( sizeof( POINT ) == sizeof( SalPoint ), 818 "WinSalGraphics::DrawPolyLine(): POINT != SalPoint" ); 819 820 pWinPtAry = (POINT*)pPtAry; 821 // Wegen Windows 95 und der Beschraenkung auf eine maximale Anzahl 822 // von Punkten 823 if ( nSalFlags & SAL_INVERT_TRACKFRAME ) 824 { |
801 if ( !Polyline( mhDC, pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) 802 Polyline( mhDC, pWinPtAry, MAX_64KSALPOINTS ); | 825 if ( !Polyline( getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) 826 Polyline( getHDC(), pWinPtAry, MAX_64KSALPOINTS ); |
803 } 804 else 805 { | 827 } 828 else 829 { |
806 if ( !WIN_Polygon( mhDC, pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) 807 WIN_Polygon( mhDC, pWinPtAry, MAX_64KSALPOINTS ); | 830 if ( !WIN_Polygon( getHDC(), pWinPtAry, (int)nPoints ) && (nPoints > MAX_64KSALPOINTS) ) 831 WIN_Polygon( getHDC(), pWinPtAry, MAX_64KSALPOINTS ); |
808 } 809 | 832 } 833 |
810 SetROP2( mhDC, nOldROP ); 811 SelectPen( mhDC, hOldPen ); | 834 SetROP2( getHDC(), nOldROP ); 835 SelectPen( getHDC(), hOldPen ); |
812 813 if ( nSalFlags & SAL_INVERT_TRACKFRAME ) 814 DeletePen( hPen ); 815 else 816 { | 836 837 if ( nSalFlags & SAL_INVERT_TRACKFRAME ) 838 DeletePen( hPen ); 839 else 840 { |
817 ::SetTextColor( mhDC, nOldTextColor ); 818 SelectBrush( mhDC, hOldBrush ); | 841 ::SetTextColor( getHDC(), nOldTextColor ); 842 SelectBrush( getHDC(), hOldBrush ); |
819 } 820} | 843 } 844} |