1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include <tools/debug.hxx>
#include <vcl/outdev.hxx>
#include <vcl/virdev.hxx>
#include <vcl/bmpacc.hxx>
#include <vcl/metaact.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
#include <vcl/graph.hxx>
#include <vcl/rendergraphicrasterizer.hxx>
#include <wall2.hxx>
#include <salgdi.hxx>
#include <window.h>
#include <svdata.hxx>
#include <outdev.h>
#include <com/sun/star/uno/Sequence.hxx>
#include <basegfx/vector/b2dvector.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <math.h>
// ========================================================================
DBG_NAMEEX( OutputDevice )
// ------------------------------------------------------------------------
void OutputDevice::DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags )
{
OSL_TRACE( "OutputDevice::DrawGrid()" );
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
Rectangle aDstRect( PixelToLogic( Point() ), GetOutputSize() );
aDstRect.Intersection( rRect );
if( aDstRect.IsEmpty() || ImplIsRecordLayout() )
return;
if( !mpGraphics && !ImplGetGraphics() )
return;
if( mbInitClipRegion )
ImplInitClipRegion();
if( mbOutputClipped )
return;
const long nDistX = Max( rDist.Width(), 1L );
const long nDistY = Max( rDist.Height(), 1L );
long nX = ( rRect.Left() >= aDstRect.Left() ) ? rRect.Left() : ( rRect.Left() + ( ( aDstRect.Left() - rRect.Left() ) / nDistX ) * nDistX );
long nY = ( rRect.Top() >= aDstRect.Top() ) ? rRect.Top() : ( rRect.Top() + ( ( aDstRect.Top() - rRect.Top() ) / nDistY ) * nDistY );
const long nRight = aDstRect.Right();
const long nBottom = aDstRect.Bottom();
const long nStartX = ImplLogicXToDevicePixel( nX );
const long nEndX = ImplLogicXToDevicePixel( nRight );
const long nStartY = ImplLogicYToDevicePixel( nY );
const long nEndY = ImplLogicYToDevicePixel( nBottom );
long nHorzCount = 0L;
long nVertCount = 0L;
::com::sun::star::uno::Sequence< sal_Int32 > aVertBuf;
::com::sun::star::uno::Sequence< sal_Int32 > aHorzBuf;
if( ( nFlags & GRID_DOTS ) || ( nFlags & GRID_HORZLINES ) )
{
aVertBuf.realloc( aDstRect.GetHeight() / nDistY + 2L );
aVertBuf[ nVertCount++ ] = nStartY;
while( ( nY += nDistY ) <= nBottom )
aVertBuf[ nVertCount++ ] = ImplLogicYToDevicePixel( nY );
}
if( ( nFlags & GRID_DOTS ) || ( nFlags & GRID_VERTLINES ) )
{
aHorzBuf.realloc( aDstRect.GetWidth() / nDistX + 2L );
aHorzBuf[ nHorzCount++ ] = nStartX;
while( ( nX += nDistX ) <= nRight )
aHorzBuf[ nHorzCount++ ] = ImplLogicXToDevicePixel( nX );
}
if( mbInitLineColor )
ImplInitLineColor();
if( mbInitFillColor )
ImplInitFillColor();
const sal_Bool bOldMap = mbMap;
EnableMapMode( sal_False );
if( nFlags & GRID_DOTS )
{
for( long i = 0L; i < nVertCount; i++ )
for( long j = 0L, Y = aVertBuf[ i ]; j < nHorzCount; j++ )
mpGraphics->DrawPixel( aHorzBuf[ j ], Y, this );
}
else
{
if( nFlags & GRID_HORZLINES )
{
for( long i = 0L; i < nVertCount; i++ )
{
nY = aVertBuf[ i ];
mpGraphics->DrawLine( nStartX, nY, nEndX, nY, this );
}
}
if( nFlags & GRID_VERTLINES )
{
for( long i = 0L; i < nHorzCount; i++ )
{
nX = aHorzBuf[ i ];
mpGraphics->DrawLine( nX, nStartY, nX, nEndY, this );
}
}
}
EnableMapMode( bOldMap );
if( mpAlphaVDev )
mpAlphaVDev->DrawGrid( rRect, rDist, nFlags );
}
// ------------------------------------------------------------------------
// Caution: This method is nearly the same as
// void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
// so when changes are made here do not forget to make change sthere, too
void OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency)
{
OSL_TRACE( "OutputDevice::DrawTransparent(B2D&,transparency)" );
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
// AW: Do NOT paint empty PolyPolygons
if(!rB2DPolyPoly.count())
return;
// we need a graphics
if( !mpGraphics )
if( !ImplGetGraphics() )
return;
if( mbInitClipRegion )
ImplInitClipRegion();
if( mbOutputClipped )
return;
if( mbInitLineColor )
ImplInitLineColor();
if( mbInitFillColor )
ImplInitFillColor();
if((mnAntialiasing & ANTIALIASING_ENABLE_B2DDRAW)
&& mpGraphics->supportsOperation(OutDevSupport_B2DDraw)
&& ROP_OVERPAINT == GetRasterOp() )
{
// b2dpolygon support not implemented yet on non-UNX platforms
const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
basegfx::B2DPolyPolygon aB2DPolyPolygon(rB2DPolyPoly);
// transform the polygon into device space and ensure it is closed
aB2DPolyPolygon.transform( aTransform );
aB2DPolyPolygon.setClosed( true );
bool bDrawnOk = true;
if( IsFillColor() )
bDrawnOk = mpGraphics->DrawPolyPolygon( aB2DPolyPolygon, fTransparency, this );
if( bDrawnOk && IsLineColor() )
{
const basegfx::B2DVector aHairlineWidth(1,1);
const int nPolyCount = aB2DPolyPolygon.count();
for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
{
const ::basegfx::B2DPolygon aOnePoly = aB2DPolyPolygon.getB2DPolygon( nPolyIdx );
mpGraphics->DrawPolyLine( aOnePoly, fTransparency, aHairlineWidth, ::basegfx::B2DLINEJOIN_NONE, this );
}
}
if( bDrawnOk )
{
if( mpMetaFile )
mpMetaFile->AddAction( new MetaTransparentAction( PolyPolygon( rB2DPolyPoly ), static_cast< sal_uInt16 >(fTransparency * 100.0)));
return;
}
}
// fallback to old polygon drawing if needed
const PolyPolygon aToolsPolyPolygon( rB2DPolyPoly );
DrawTransparent(PolyPolygon(rB2DPolyPoly), static_cast< sal_uInt16 >(fTransparency * 100.0));
}
// ------------------------------------------------------------------------
void OutputDevice::DrawTransparent( const PolyPolygon& rPolyPoly,
sal_uInt16 nTransparencePercent )
{
OSL_TRACE( "OutputDevice::DrawTransparent()" );
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
// short circuit for drawing an opaque polygon
if( (nTransparencePercent < 1) || ((mnDrawMode & DRAWMODE_NOTRANSPARENCY) != 0) )
{
DrawPolyPolygon( rPolyPoly );
return;
}
// short circut for drawing an invisible polygon
if( !mbFillColor || (nTransparencePercent >= 100) )
{
// short circuit if the polygon border is invisible too
if( !mbLineColor )
return;
// DrawTransparent() assumes that the border is NOT to be drawn transparently???
Push( PUSH_FILLCOLOR );
SetFillColor();
DrawPolyPolygon( rPolyPoly );
Pop();
return;
}
// handle metafile recording
if( mpMetaFile )
mpMetaFile->AddAction( new MetaTransparentAction( rPolyPoly, nTransparencePercent ) );
bool bDrawn = !IsDeviceOutputNecessary() || ImplIsRecordLayout();
if( bDrawn )
return;
// get the device graphics as drawing target
if( !mpGraphics )
if( !ImplGetGraphics() )
return;
// debug helper:
static const char* pDisableNative = getenv( "SAL_DISABLE_NATIVE_ALPHA");
// try hard to draw it directly, because the emulation layers are slower
if( !pDisableNative
&& mpGraphics->supportsOperation( OutDevSupport_B2DDraw )
#if defined UNX && ! defined QUARTZ
&& GetBitCount() > 8
#endif
#ifdef WIN32
// workaround bad dithering on remote displaying when using GDI+ with toolbar buttoin hilighting
&& !rPolyPoly.IsRect()
#endif
)
{
// prepare the graphics device
if( mbInitClipRegion )
ImplInitClipRegion();
if( mbOutputClipped )
return;
if( mbInitLineColor )
ImplInitLineColor();
if( mbInitFillColor )
ImplInitFillColor();
// get the polygon in device coordinates
basegfx::B2DPolyPolygon aB2DPolyPolygon( rPolyPoly.getB2DPolyPolygon() );
const ::basegfx::B2DHomMatrix aTransform = ImplGetDeviceTransformation();
aB2DPolyPolygon.transform( aTransform );
const double fTransparency = 0.01 * nTransparencePercent;
if( mbFillColor )
{
// draw the transparent polygon
// NOTE: filled polygons are assumed to be drawn as if they were always closed
bDrawn = mpGraphics->DrawPolyPolygon( aB2DPolyPolygon, fTransparency, this );
}
if( mbLineColor )
{
// disable the fill color for now
mpGraphics->SetFillColor();
// draw the border line
const basegfx::B2DVector aLineWidths( 1, 1 );
const int nPolyCount = aB2DPolyPolygon.count();
for( int nPolyIdx = 0; nPolyIdx < nPolyCount; ++nPolyIdx )
{
const ::basegfx::B2DPolygon& rPolygon = aB2DPolyPolygon.getB2DPolygon( nPolyIdx );
bDrawn = mpGraphics->DrawPolyLine( rPolygon, fTransparency, aLineWidths, ::basegfx::B2DLINEJOIN_NONE, this );
}
// prepare to restore the fill color
mbInitFillColor = mbFillColor;
}
}
if( bDrawn )
return;
if( 1 )
{
VirtualDevice* pOldAlphaVDev = mpAlphaVDev;
// #110958# Disable alpha VDev, we perform the necessary
// operation explicitly further below.
if( mpAlphaVDev )
mpAlphaVDev = NULL;
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = NULL;
if( OUTDEV_PRINTER == meOutDevType )
{
if(100 <= nTransparencePercent)
{
// #i112959# 100% transparent, draw nothing
return;
}
Rectangle aPolyRect( LogicToPixel( rPolyPoly ).GetBoundRect() );
const Size aDPISize( LogicToPixel( Size( 1, 1 ), MAP_INCH ) );
const long nBaseExtent = Max( FRound( aDPISize.Width() / 300. ), 1L );
long nMove;
const sal_uInt16 nTrans = ( nTransparencePercent < 13 ) ? 0 :
( nTransparencePercent < 38 ) ? 25 :
( nTransparencePercent < 63 ) ? 50 :
( nTransparencePercent < 88 ) ? 75 : 100;
switch( nTrans )
{
case( 25 ): nMove = nBaseExtent * 3; break;
case( 50 ): nMove = nBaseExtent * 4; break;
case( 75 ): nMove = nBaseExtent * 6; break;
// #i112959# very transparent (88 < nTransparencePercent <= 99)
case( 100 ): nMove = nBaseExtent * 8; break;
// #i112959# not transparent (nTransparencePercent < 13)
default: nMove = 0; break;
}
Push( PUSH_CLIPREGION | PUSH_LINECOLOR );
IntersectClipRegion( rPolyPoly );
SetLineColor( GetFillColor() );
const sal_Bool bOldMap = mbMap;
EnableMapMode( sal_False );
if(nMove)
{
Rectangle aRect( aPolyRect.TopLeft(), Size( aPolyRect.GetWidth(), nBaseExtent ) );
while( aRect.Top() <= aPolyRect.Bottom() )
{
DrawRect( aRect );
aRect.Move( 0, nMove );
}
aRect = Rectangle( aPolyRect.TopLeft(), Size( nBaseExtent, aPolyRect.GetHeight() ) );
while( aRect.Left() <= aPolyRect.Right() )
{
DrawRect( aRect );
aRect.Move( nMove, 0 );
}
}
else
{
// #i112959# if not transparent, draw full rectangle in clip region
DrawRect( aPolyRect );
}
EnableMapMode( bOldMap );
Pop();
}
else
{
PolyPolygon aPolyPoly( LogicToPixel( rPolyPoly ) );
Rectangle aPolyRect( aPolyPoly.GetBoundRect() );
Point aPoint;
Rectangle aDstRect( aPoint, GetOutputSizePixel() );
aDstRect.Intersection( aPolyRect );
if( OUTDEV_WINDOW == meOutDevType )
{
const Region aPaintRgn( ( (Window*) this )->GetPaintRegion() );
if( !aPaintRgn.IsNull() )
aDstRect.Intersection( LogicToPixel( aPaintRgn ).GetBoundRect() );
}
if( !aDstRect.IsEmpty() )
{
// #i66849# Added fast path for exactly rectangular
// polygons
// #i83087# Naturally, system alpha blending cannot
// work with separate alpha VDev
if( !mpAlphaVDev && !pDisableNative && aPolyPoly.IsRect() )
{
// setup Graphics only here (other cases delegate
// to basic OutDev methods)
if( 1 )
{
if ( mbInitClipRegion )
ImplInitClipRegion();
if ( mbInitLineColor )
ImplInitLineColor();
if ( mbInitFillColor )
ImplInitFillColor();
Rectangle aLogicPolyRect( rPolyPoly.GetBoundRect() );
Rectangle aPixelRect( ImplLogicToDevicePixel( aLogicPolyRect ) );
if( !mbOutputClipped )
{
bDrawn = mpGraphics->DrawAlphaRect(
aPixelRect.Left(), aPixelRect.Top(),
// #i98405# use methods with small g, else one pixel too much will be painted.
// This is because the source is a polygon which when painted would not paint
// the rightmost and lowest pixel line(s), so use one pixel less for the
// rectangle, too.
aPixelRect.getWidth(), aPixelRect.getHeight(),
sal::static_int_cast<sal_uInt8>(nTransparencePercent),
this );
}
else
bDrawn = true;
}
}
if( !bDrawn )
{
VirtualDevice aVDev( *this, 1 );
const Size aDstSz( aDstRect.GetSize() );
const sal_uInt8 cTrans = (sal_uInt8) MinMax( FRound( nTransparencePercent * 2.55 ), 0, 255 );
if( aDstRect.Left() || aDstRect.Top() )
aPolyPoly.Move( -aDstRect.Left(), -aDstRect.Top() );
if( aVDev.SetOutputSizePixel( aDstSz ) )
{
const sal_Bool bOldMap = mbMap;
EnableMapMode( sal_False );
aVDev.SetLineColor( COL_BLACK );
aVDev.SetFillColor( COL_BLACK );
aVDev.DrawPolyPolygon( aPolyPoly );
Bitmap aPaint( GetBitmap( aDstRect.TopLeft(), aDstSz ) );
Bitmap aPolyMask( aVDev.GetBitmap( Point(), aDstSz ) );
// #107766# check for non-empty bitmaps before accessing them
if( !!aPaint && !!aPolyMask )
{
BitmapWriteAccess* pW = aPaint.AcquireWriteAccess();
BitmapReadAccess* pR = aPolyMask.AcquireReadAccess();
if( pW && pR )
{
BitmapColor aPixCol;
const BitmapColor aFillCol( GetFillColor() );
const BitmapColor aWhite( pR->GetBestMatchingColor( Color( COL_WHITE ) ) );
const BitmapColor aBlack( pR->GetBestMatchingColor( Color( COL_BLACK ) ) );
const long nWidth = pW->Width(), nHeight = pW->Height();
const long nR = aFillCol.GetRed(), nG = aFillCol.GetGreen(), nB = aFillCol.GetBlue();
long nX, nY;
if( aPaint.GetBitCount() <= 8 )
{
const BitmapPalette& rPal = pW->GetPalette();
const sal_uInt16 nCount = rPal.GetEntryCount();
BitmapColor* pMap = (BitmapColor*) new sal_uInt8[ nCount * sizeof( BitmapColor ) ];
for( sal_uInt16 i = 0; i < nCount; i++ )
{
BitmapColor aCol( rPal[ i ] );
pMap[ i ] = BitmapColor( (sal_uInt8) rPal.GetBestIndex( aCol.Merge( aFillCol, cTrans ) ) );
}
if( pR->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL &&
pW->GetScanlineFormat() == BMP_FORMAT_8BIT_PAL )
{
const sal_uInt8 cBlack = aBlack.GetIndex();
for( nY = 0; nY < nHeight; nY++ )
{
Scanline pWScan = pW->GetScanline( nY );
Scanline pRScan = pR->GetScanline( nY );
sal_uInt8 cBit = 128;
for( nX = 0; nX < nWidth; nX++, cBit >>= 1, pWScan++ )
{
if( !cBit )
cBit = 128, pRScan++;
if( ( *pRScan & cBit ) == cBlack )
*pWScan = (sal_uInt8) pMap[ *pWScan ].GetIndex();
}
}
}
else
{
for( nY = 0; nY < nHeight; nY++ )
for( nX = 0; nX < nWidth; nX++ )
if( pR->GetPixel( nY, nX ) == aBlack )
pW->SetPixel( nY, nX, pMap[ pW->GetPixel( nY, nX ).GetIndex() ] );
}
delete[] (sal_uInt8*) pMap;
}
else
{
if( pR->GetScanlineFormat() == BMP_FORMAT_1BIT_MSB_PAL &&
pW->GetScanlineFormat() == BMP_FORMAT_24BIT_TC_BGR )
{
const sal_uInt8 cBlack = aBlack.GetIndex();
for( nY = 0; nY < nHeight; nY++ )
{
Scanline pWScan = pW->GetScanline( nY );
Scanline pRScan = pR->GetScanline( nY );
sal_uInt8 cBit = 128;
for( nX = 0; nX < nWidth; nX++, cBit >>= 1, pWScan += 3 )
{
if( !cBit )
cBit = 128, pRScan++;
if( ( *pRScan & cBit ) == cBlack )
{
pWScan[ 0 ] = COLOR_CHANNEL_MERGE( pWScan[ 0 ], nB, cTrans );
pWScan[ 1 ] = COLOR_CHANNEL_MERGE( pWScan[ 1 ], nG, cTrans );
pWScan[ 2 ] = COLOR_CHANNEL_MERGE( pWScan[ 2 ], nR, cTrans );
}
}
}
}
else
{
for( nY = 0; nY < nHeight; nY++ )
{
for( nX = 0; nX < nWidth; nX++ )
{
if( pR->GetPixel( nY, nX ) == aBlack )
{
aPixCol = pW->GetColor( nY, nX );
pW->SetPixel( nY, nX, aPixCol.Merge( aFillCol, cTrans ) );
}
}
}
}
}
}
aPolyMask.ReleaseAccess( pR );
aPaint.ReleaseAccess( pW );
DrawBitmap( aDstRect.TopLeft(), aPaint );
EnableMapMode( bOldMap );
if( mbLineColor )
{
Push( PUSH_FILLCOLOR );
SetFillColor();
DrawPolyPolygon( rPolyPoly );
Pop();
}
}
}
else
DrawPolyPolygon( rPolyPoly );
}
}
}
mpMetaFile = pOldMetaFile;
// #110958# Restore disabled alpha VDev
mpAlphaVDev = pOldAlphaVDev;
// #110958# Apply alpha value also to VDev alpha channel
if( mpAlphaVDev )
{
const Color aFillCol( mpAlphaVDev->GetFillColor() );
mpAlphaVDev->SetFillColor( Color(sal::static_int_cast<sal_uInt8>(255*nTransparencePercent/100),
sal::static_int_cast<sal_uInt8>(255*nTransparencePercent/100),
sal::static_int_cast<sal_uInt8>(255*nTransparencePercent/100)) );
mpAlphaVDev->DrawTransparent( rPolyPoly, nTransparencePercent );
mpAlphaVDev->SetFillColor( aFillCol );
}
}
}
// -----------------------------------------------------------------------
void OutputDevice::DrawTransparent( const GDIMetaFile& rMtf, const Point& rPos,
const Size& rSize, const Gradient& rTransparenceGradient )
{
OSL_TRACE( "OutputDevice::DrawTransparent()" );
DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
const Color aBlack( COL_BLACK );
if( mpMetaFile )
mpMetaFile->AddAction( new MetaFloatTransparentAction( rMtf, rPos, rSize, rTransparenceGradient ) );
if( ( rTransparenceGradient.GetStartColor() == aBlack && rTransparenceGradient.GetEndColor() == aBlack ) ||
( mnDrawMode & ( DRAWMODE_NOTRANSPARENCY ) ) )
{
( (GDIMetaFile&) rMtf ).WindStart();
( (GDIMetaFile&) rMtf ).Play( this, rPos, rSize );
( (GDIMetaFile&) rMtf ).WindStart();
}
else
{
GDIMetaFile* pOldMetaFile = mpMetaFile;
Rectangle aOutRect( LogicToPixel( rPos ), LogicToPixel( rSize ) );
Point aPoint;
Rectangle aDstRect( aPoint, GetOutputSizePixel() );
mpMetaFile = NULL;
aDstRect.Intersection( aOutRect );
if( OUTDEV_WINDOW == meOutDevType )
{
const Region aPaintRgn( ( (Window*) this )->GetPaintRegion() );
if( !aPaintRgn.IsNull() )
aDstRect.Intersection( LogicToPixel( aPaintRgn.GetBoundRect() ) );
}
if( !aDstRect.IsEmpty() )
{
VirtualDevice* pVDev = new VirtualDevice;
((OutputDevice*)pVDev)->mnDPIX = mnDPIX;
((OutputDevice*)pVDev)->mnDPIY = mnDPIY;
if( pVDev->SetOutputSizePixel( aDstRect.GetSize() ) )
{
if(GetAntialiasing())
{
// #i102109#
// For MetaFile replay (see task) it may now be neccessary to take
// into account that the content is AntiAlialised and needs to be masked
// like that. Instead of masking, i will use a copy-modify-paste cycle
// here (as i already use in the VclPrimiziveRenderer with successs)
pVDev->SetAntialiasing(GetAntialiasing());
// create MapMode for buffer (offset needed) and set
MapMode aMap(GetMapMode());
const Point aOutPos(PixelToLogic(aDstRect.TopLeft()));
aMap.SetOrigin(Point(-aOutPos.X(), -aOutPos.Y()));
pVDev->SetMapMode(aMap);
// copy MapMode state and disable for target
const bool bOrigMapModeEnabled(IsMapModeEnabled());
EnableMapMode(false);
// copy MapMode state and disable for buffer
const bool bBufferMapModeEnabled(pVDev->IsMapModeEnabled());
pVDev->EnableMapMode(false);
// copy content from original to buffer
pVDev->DrawOutDev(
aPoint, pVDev->GetOutputSizePixel(), // dest
aDstRect.TopLeft(), pVDev->GetOutputSizePixel(), // source
*this);
// draw MetaFile to buffer
pVDev->EnableMapMode(bBufferMapModeEnabled);
((GDIMetaFile&)rMtf).WindStart();
((GDIMetaFile&)rMtf).Play(pVDev, rPos, rSize);
((GDIMetaFile&)rMtf).WindStart();
// get content bitmap from buffer
pVDev->EnableMapMode(false);
const Bitmap aPaint(pVDev->GetBitmap(aPoint, pVDev->GetOutputSizePixel()));
// create alpha mask from gradient and get as Bitmap
pVDev->EnableMapMode(bBufferMapModeEnabled);
pVDev->SetDrawMode(DRAWMODE_GRAYGRADIENT);
pVDev->DrawGradient(Rectangle(rPos, rSize), rTransparenceGradient);
pVDev->SetDrawMode(DRAWMODE_DEFAULT);
pVDev->EnableMapMode(false);
const AlphaMask aAlpha(pVDev->GetBitmap(aPoint, pVDev->GetOutputSizePixel()));
delete pVDev;
// draw masked content to target and restore MapMode
DrawBitmapEx(aDstRect.TopLeft(), BitmapEx(aPaint, aAlpha));
EnableMapMode(bOrigMapModeEnabled);
}
else
{
Bitmap aPaint, aMask;
AlphaMask aAlpha;
MapMode aMap( GetMapMode() );
Point aOutPos( PixelToLogic( aDstRect.TopLeft() ) );
const sal_Bool bOldMap = mbMap;
aMap.SetOrigin( Point( -aOutPos.X(), -aOutPos.Y() ) );
pVDev->SetMapMode( aMap );
const sal_Bool bVDevOldMap = pVDev->IsMapModeEnabled();
// create paint bitmap
( (GDIMetaFile&) rMtf ).WindStart();
( (GDIMetaFile&) rMtf ).Play( pVDev, rPos, rSize );
( (GDIMetaFile&) rMtf ).WindStart();
pVDev->EnableMapMode( sal_False );
aPaint = pVDev->GetBitmap( Point(), pVDev->GetOutputSizePixel() );
pVDev->EnableMapMode( bVDevOldMap ); // #i35331#: MUST NOT use EnableMapMode( sal_True ) here!
// create mask bitmap
pVDev->SetLineColor( COL_BLACK );
pVDev->SetFillColor( COL_BLACK );
pVDev->DrawRect( Rectangle( pVDev->PixelToLogic( Point() ), pVDev->GetOutputSize() ) );
pVDev->SetDrawMode( DRAWMODE_WHITELINE | DRAWMODE_WHITEFILL | DRAWMODE_WHITETEXT |
DRAWMODE_WHITEBITMAP | DRAWMODE_WHITEGRADIENT );
( (GDIMetaFile&) rMtf ).WindStart();
( (GDIMetaFile&) rMtf ).Play( pVDev, rPos, rSize );
( (GDIMetaFile&) rMtf ).WindStart();
pVDev->EnableMapMode( sal_False );
aMask = pVDev->GetBitmap( Point(), pVDev->GetOutputSizePixel() );
pVDev->EnableMapMode( bVDevOldMap ); // #i35331#: MUST NOT use EnableMapMode( sal_True ) here!
// create alpha mask from gradient
pVDev->SetDrawMode( DRAWMODE_GRAYGRADIENT );
pVDev->DrawGradient( Rectangle( rPos, rSize ), rTransparenceGradient );
pVDev->SetDrawMode( DRAWMODE_DEFAULT );
pVDev->EnableMapMode( sal_False );
pVDev->DrawMask( Point(), pVDev->GetOutputSizePixel(), aMask, Color( COL_WHITE ) );
aAlpha = pVDev->GetBitmap( Point(), pVDev->GetOutputSizePixel() );
delete pVDev;
EnableMapMode( sal_False );
DrawBitmapEx( aDstRect.TopLeft(), BitmapEx( aPaint, aAlpha ) );
EnableMapMode( bOldMap );
}
}
else
delete pVDev;
}
mpMetaFile = pOldMetaFile;
}
}
// -----------------------------------------------------------------------
void OutputDevice::ImplDrawColorWallpaper( long nX, long nY,
long nWidth, long nHeight,
const Wallpaper& rWallpaper )
{
// Wallpaper ohne Umrandung zeichnen
Color aOldLineColor = GetLineColor();
Color aOldFillColor = GetFillColor();
SetLineColor();
SetFillColor( rWallpaper.GetColor() );
sal_Bool bMap = mbMap;
EnableMapMode( sal_False );
DrawRect( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ) );
SetLineColor( aOldLineColor );
SetFillColor( aOldFillColor );
EnableMapMode( bMap );
}
// -----------------------------------------------------------------------
void OutputDevice::ImplDrawBitmapWallpaper( long nX, long nY,
long nWidth, long nHeight,
const Wallpaper& rWallpaper )
{
BitmapEx aBmpEx;
const BitmapEx* pCached = rWallpaper.ImplGetImpWallpaper()->ImplGetCachedBitmap();
Point aPos;
Size aSize;
GDIMetaFile* pOldMetaFile = mpMetaFile;
const WallpaperStyle eStyle = rWallpaper.GetStyle();
const sal_Bool bOldMap = mbMap;
sal_Bool bDrawn = sal_False;
sal_Bool bDrawGradientBackground = sal_False;
sal_Bool bDrawColorBackground = sal_False;
if( pCached )
aBmpEx = *pCached;
else
aBmpEx = rWallpaper.GetBitmap();
const long nBmpWidth = aBmpEx.GetSizePixel().Width();
const long nBmpHeight = aBmpEx.GetSizePixel().Height();
const sal_Bool bTransparent = aBmpEx.IsTransparent();
// draw background
if( bTransparent )
{
if( rWallpaper.IsGradient() )
bDrawGradientBackground = sal_True;
else
{
if( !pCached && !rWallpaper.GetColor().GetTransparency() )
{
VirtualDevice aVDev( *this );
aVDev.SetBackground( rWallpaper.GetColor() );
aVDev.SetOutputSizePixel( Size( nBmpWidth, nBmpHeight ) );
aVDev.DrawBitmapEx( Point(), aBmpEx );
aBmpEx = aVDev.GetBitmap( Point(), aVDev.GetOutputSizePixel() );
}
bDrawColorBackground = sal_True;
}
}
else if( eStyle != WALLPAPER_TILE && eStyle != WALLPAPER_SCALE )
{
if( rWallpaper.IsGradient() )
bDrawGradientBackground = sal_True;
else
bDrawColorBackground = sal_True;
}
// background of bitmap?
if( bDrawGradientBackground )
ImplDrawGradientWallpaper( nX, nY, nWidth, nHeight, rWallpaper );
else if( bDrawColorBackground && bTransparent )
{
ImplDrawColorWallpaper( nX, nY, nWidth, nHeight, rWallpaper );
bDrawColorBackground = sal_False;
}
// calc pos and size
if( rWallpaper.IsRect() )
{
const Rectangle aBound( LogicToPixel( rWallpaper.GetRect() ) );
aPos = aBound.TopLeft();
aSize = aBound.GetSize();
}
else
{
aPos = Point( nX, nY );
aSize = Size( nWidth, nHeight );
}
mpMetaFile = NULL;
EnableMapMode( sal_False );
Push( PUSH_CLIPREGION );
IntersectClipRegion( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ) );
switch( eStyle )
{
case( WALLPAPER_SCALE ):
{
if( !pCached || ( pCached->GetSizePixel() != aSize ) )
{
if( pCached )
rWallpaper.ImplGetImpWallpaper()->ImplReleaseCachedBitmap();
aBmpEx = rWallpaper.GetBitmap();
aBmpEx.Scale( aSize );
aBmpEx = BitmapEx( aBmpEx.GetBitmap().CreateDisplayBitmap( this ), aBmpEx.GetMask() );
}
}
break;
case( WALLPAPER_TOPLEFT ):
break;
case( WALLPAPER_TOP ):
aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1;
break;
case( WALLPAPER_TOPRIGHT ):
aPos.X() += ( aSize.Width() - nBmpWidth );
break;
case( WALLPAPER_LEFT ):
aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1;
break;
case( WALLPAPER_CENTER ):
{
aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1;
aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1;
}
break;
case( WALLPAPER_RIGHT ):
{
aPos.X() += ( aSize.Width() - nBmpWidth );
aPos.Y() += ( aSize.Height() - nBmpHeight ) >> 1;
}
break;
case( WALLPAPER_BOTTOMLEFT ):
aPos.Y() += ( aSize.Height() - nBmpHeight );
break;
case( WALLPAPER_BOTTOM ):
{
aPos.X() += ( aSize.Width() - nBmpWidth ) >> 1;
aPos.Y() += ( aSize.Height() - nBmpHeight );
}
break;
case( WALLPAPER_BOTTOMRIGHT ):
{
aPos.X() += ( aSize.Width() - nBmpWidth );
aPos.Y() += ( aSize.Height() - nBmpHeight );
}
break;
default:
{
const long nRight = nX + nWidth - 1L;
const long nBottom = nY + nHeight - 1L;
long nFirstX;
long nFirstY;
if( eStyle == WALLPAPER_TILE )
{
nFirstX = aPos.X();
nFirstY = aPos.Y();
}
else
{
nFirstX = aPos.X() + ( ( aSize.Width() - nBmpWidth ) >> 1 );
nFirstY = aPos.Y() + ( ( aSize.Height() - nBmpHeight ) >> 1 );
}
const long nOffX = ( nFirstX - nX ) % nBmpWidth;
const long nOffY = ( nFirstY - nY ) % nBmpHeight;
long nStartX = nX + nOffX;
long nStartY = nY + nOffY;
if( nOffX > 0L )
nStartX -= nBmpWidth;
if( nOffY > 0L )
nStartY -= nBmpHeight;
for( long nBmpY = nStartY; nBmpY <= nBottom; nBmpY += nBmpHeight )
for( long nBmpX = nStartX; nBmpX <= nRight; nBmpX += nBmpWidth )
DrawBitmapEx( Point( nBmpX, nBmpY ), aBmpEx );
bDrawn = sal_True;
}
break;
}
if( !bDrawn )
{
// optimized for non-transparent bitmaps
if( bDrawColorBackground )
{
const Size aBmpSize( aBmpEx.GetSizePixel() );
const Point aTmpPoint;
const Rectangle aOutRect( aTmpPoint, GetOutputSizePixel() );
const Rectangle aColRect( Point( nX, nY ), Size( nWidth, nHeight ) );
Rectangle aWorkRect;
aWorkRect = Rectangle( 0, 0, aOutRect.Right(), aPos.Y() - 1L );
aWorkRect.Justify();
aWorkRect.Intersection( aColRect );
if( !aWorkRect.IsEmpty() )
{
ImplDrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(),
aWorkRect.GetWidth(), aWorkRect.GetHeight(),
rWallpaper );
}
aWorkRect = Rectangle( 0, aPos.Y(), aPos.X() - 1L, aPos.Y() + aBmpSize.Height() - 1L );
aWorkRect.Justify();
aWorkRect.Intersection( aColRect );
if( !aWorkRect.IsEmpty() )
{
ImplDrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(),
aWorkRect.GetWidth(), aWorkRect.GetHeight(),
rWallpaper );
}
aWorkRect = Rectangle( aPos.X() + aBmpSize.Width(), aPos.Y(), aOutRect.Right(), aPos.Y() + aBmpSize.Height() - 1L );
aWorkRect.Justify();
aWorkRect.Intersection( aColRect );
if( !aWorkRect.IsEmpty() )
{
ImplDrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(),
aWorkRect.GetWidth(), aWorkRect.GetHeight(),
rWallpaper );
}
aWorkRect = Rectangle( 0, aPos.Y() + aBmpSize.Height(), aOutRect.Right(), aOutRect.Bottom() );
aWorkRect.Justify();
aWorkRect.Intersection( aColRect );
if( !aWorkRect.IsEmpty() )
{
ImplDrawColorWallpaper( aWorkRect.Left(), aWorkRect.Top(),
aWorkRect.GetWidth(), aWorkRect.GetHeight(),
rWallpaper );
}
}
DrawBitmapEx( aPos, aBmpEx );
}
rWallpaper.ImplGetImpWallpaper()->ImplSetCachedBitmap( aBmpEx );
Pop();
EnableMapMode( bOldMap );
mpMetaFile = pOldMetaFile;
}
// -----------------------------------------------------------------------
void OutputDevice::ImplDrawGradientWallpaper( long nX, long nY,
long nWidth, long nHeight,
const Wallpaper& rWallpaper )
{
Rectangle aBound;
GDIMetaFile* pOldMetaFile = mpMetaFile;
const sal_Bool bOldMap = mbMap;
sal_Bool bNeedGradient = sal_True;
/*
if ( rWallpaper.IsRect() )
aBound = LogicToPixel( rWallpaper.GetRect() );
else
*/
aBound = Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) );
mpMetaFile = NULL;
EnableMapMode( sal_False );
Push( PUSH_CLIPREGION );
IntersectClipRegion( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ) );
if( OUTDEV_WINDOW == meOutDevType && rWallpaper.GetStyle() == WALLPAPER_APPLICATIONGRADIENT )
{
Window *pWin = dynamic_cast< Window* >( this );
if( pWin )
{
// limit gradient to useful size, so that it still can be noticed
// in maximized windows
long gradientWidth = pWin->GetDesktopRectPixel().GetSize().Width();
if( gradientWidth > 1024 )
gradientWidth = 1024;
if( mnOutOffX+nWidth > gradientWidth )
ImplDrawColorWallpaper( nX, nY, nWidth, nHeight, rWallpaper.GetGradient().GetEndColor() );
if( mnOutOffX > gradientWidth )
bNeedGradient = sal_False;
else
aBound = Rectangle( Point( -mnOutOffX, nY ), Size( gradientWidth, nHeight ) );
}
}
if( bNeedGradient )
DrawGradient( aBound, rWallpaper.GetGradient() );
Pop();
EnableMapMode( bOldMap );
mpMetaFile = pOldMetaFile;
}
// -----------------------------------------------------------------------
void OutputDevice::ImplDrawWallpaper( long nX, long nY,
long nWidth, long nHeight,
const Wallpaper& rWallpaper )
{
if( rWallpaper.IsBitmap() )
ImplDrawBitmapWallpaper( nX, nY, nWidth, nHeight, rWallpaper );
else if( rWallpaper.IsGradient() )
ImplDrawGradientWallpaper( nX, nY, nWidth, nHeight, rWallpaper );
else
ImplDrawColorWallpaper( nX, nY, nWidth, nHeight, rWallpaper );
}
// -----------------------------------------------------------------------
void OutputDevice::DrawWallpaper( const Rectangle& rRect,
const Wallpaper& rWallpaper )
{
if ( mpMetaFile )
mpMetaFile->AddAction( new MetaWallpaperAction( rRect, rWallpaper ) );
if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
return;
if ( rWallpaper.GetStyle() != WALLPAPER_NULL )
{
Rectangle aRect = LogicToPixel( rRect );
aRect.Justify();
if ( !aRect.IsEmpty() )
{
ImplDrawWallpaper( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(),
rWallpaper );
}
}
if( mpAlphaVDev )
mpAlphaVDev->DrawWallpaper( rRect, rWallpaper );
}
// -----------------------------------------------------------------------
void OutputDevice::Erase()
{
if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
return;
sal_Bool bNativeOK = sal_False;
if( meOutDevType == OUTDEV_WINDOW )
{
Window* pWindow = static_cast<Window*>(this);
ControlPart aCtrlPart = pWindow->ImplGetWindowImpl()->mnNativeBackground;
if( aCtrlPart != 0 && ! pWindow->IsControlBackground() )
{
ImplControlValue aControlValue;
Point aGcc3WorkaroundTemporary;
Rectangle aCtrlRegion( aGcc3WorkaroundTemporary, GetOutputSizePixel() );
ControlState nState = 0;
if( pWindow->IsEnabled() ) nState |= CTRL_STATE_ENABLED;
bNativeOK = pWindow->DrawNativeControl( CTRL_WINDOW_BACKGROUND, aCtrlPart, aCtrlRegion,
nState, aControlValue, rtl::OUString() );
}
}
if ( mbBackground && ! bNativeOK )
{
RasterOp eRasterOp = GetRasterOp();
if ( eRasterOp != ROP_OVERPAINT )
SetRasterOp( ROP_OVERPAINT );
ImplDrawWallpaper( 0, 0, mnOutWidth, mnOutHeight, maBackground );
if ( eRasterOp != ROP_OVERPAINT )
SetRasterOp( eRasterOp );
}
if( mpAlphaVDev )
mpAlphaVDev->Erase();
}
// -----------------------------------------------------------------------
bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize,
const GfxLink& rGfxLink, GDIMetaFile* pSubst )
{
OSL_TRACE( "OutputDevice::DrawEPS()" );
bool bDrawn(true);
if ( mpMetaFile )
{
GDIMetaFile aSubst;
if( pSubst )
aSubst = *pSubst;
mpMetaFile->AddAction( new MetaEPSAction( rPoint, rSize, rGfxLink, aSubst ) );
}
if ( !IsDeviceOutputNecessary() || ImplIsRecordLayout() )
return bDrawn;
if( mbOutputClipped )
return bDrawn;
Rectangle aRect( ImplLogicToDevicePixel( Rectangle( rPoint, rSize ) ) );
if( !aRect.IsEmpty() )
{
// draw the real EPS graphics
if( rGfxLink.GetData() && rGfxLink.GetDataSize() )
{
if( !mpGraphics && !ImplGetGraphics() )
return bDrawn;
if( mbInitClipRegion )
ImplInitClipRegion();
aRect.Justify();
bDrawn = mpGraphics->DrawEPS( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(),
(sal_uInt8*) rGfxLink.GetData(), rGfxLink.GetDataSize(), this );
}
// else draw the substitution graphics
if( !bDrawn && pSubst )
{
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = NULL;
Graphic( *pSubst ).Draw( this, rPoint, rSize );
mpMetaFile = pOldMetaFile;
}
}
if( mpAlphaVDev )
mpAlphaVDev->DrawEPS( rPoint, rSize, rGfxLink, pSubst );
return bDrawn;
}
// ------------------------------------------------------------------
void OutputDevice::DrawRenderGraphic( const Point& rPoint, const Size& rSize,
const ::vcl::RenderGraphic& rRenderGraphic )
{
OSL_TRACE( "OutputDevice::DrawRenderGraphic()" );
if( mpMetaFile )
mpMetaFile->AddAction( new MetaRenderGraphicAction( rPoint, rSize, rRenderGraphic ) );
if( !rRenderGraphic.IsEmpty() )
{
::vcl::RenderGraphicRasterizer aRasterizer( rRenderGraphic );
BitmapEx aBmpEx;
const Size aSizePixel( LogicToPixel( rSize ) );
GDIMetaFile* pOldMetaFile = mpMetaFile;
mpMetaFile = NULL;
DrawBitmapEx( rPoint, rSize, aRasterizer.Rasterize( aSizePixel ) );
mpMetaFile = pOldMetaFile;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|