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 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_vcl.hxx" 26 27 // bootstrap stuff 28 #include <rtl/bootstrap.hxx> 29 #include <comphelper/processfactory.hxx> 30 #include <comphelper/regpathhelper.hxx> 31 #include <cppuhelper/servicefactory.hxx> 32 #include <cppuhelper/bootstrap.hxx> 33 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 34 #include <com/sun/star/lang/XInitialization.hpp> 35 #include <com/sun/star/registry/XSimpleRegistry.hpp> 36 37 #include <ucbhelper/contentbroker.hxx> 38 #include <ucbhelper/configurationkeys.hxx> 39 40 #include <vcl/svapp.hxx> 41 #include <vcl/dialog.hxx> 42 #include <vcl/outdev.hxx> 43 #include <vcl/virdev.hxx> 44 #include <vcl/hatch.hxx> 45 #include <vcl/bitmap.hxx> 46 #include <vcl/wall.hxx> 47 #include <vcl/image.hxx> 48 #include <vcl/gdimtf.hxx> 49 #include <vcl/metaact.hxx> 50 #include <vcl/bitmapex.hxx> 51 #include <vcl/gradient.hxx> 52 #include <vcl/lineinfo.hxx> 53 #include <tools/string.hxx> 54 55 #include <osl/time.h> 56 57 #include <boost/function.hpp> 58 #include <boost/bind.hpp> 59 60 #include <stdio.h> 61 #include <unistd.h> 62 63 using namespace ::com::sun::star; 64 65 66 namespace 67 { 68 69 class GrindApp : public Application 70 { 71 public: 72 virtual void Main(); 73 virtual sal_uInt16 Exception( sal_uInt16 nError ); 74 }; 75 76 class TestWindow : public Dialog 77 { 78 public: 79 TestWindow() : Dialog( (Window *) NULL ) 80 { 81 SetText( rtl::OUString::createFromAscii( "OutDev grinding" ) ); 82 SetSizePixel( Size( 1024, 1024 ) ); 83 EnablePaint( true ); 84 Show(); 85 } 86 87 virtual ~TestWindow() {} 88 virtual void Paint( const Rectangle& rRect ); 89 }; 90 91 //---------------------------------------------------------------------------------- 92 93 typedef boost::function1<void, OutputDevice*> functor_type; 94 typedef std::vector< std::pair<const char*, 95 functor_type> > functor_vector_type; 96 97 template< typename Functor > void add( functor_vector_type& res, 98 const char* pStr, 99 const Functor& func ) 100 { 101 res.push_back( std::make_pair(pStr,functor_type(func)) ); 102 } 103 104 void setupMethodStubs( functor_vector_type& res ) 105 { 106 const Color aWhiteColor( COL_WHITE ); 107 const Color aBlackColor( COL_BLACK ); 108 109 const Point aPt1(10,10); 110 const Point aPt2(500,500); 111 const Point aPt3(0,0); 112 const Point aPt4(450,450); 113 114 const Rectangle aRect(aPt1,aPt2); 115 const Rectangle aRect2(aPt3,aPt4); 116 const Polygon aPoly(aRect); 117 const Polygon aPoly2(aRect2); 118 PolyPolygon aPolyPoly(aPoly); 119 aPolyPoly.Insert( aPoly2 ); 120 Polygon aPoly3(aPoly2); 121 aPoly3.Rotate( aPoly3.GetBoundRect().Center(), 122 900 ); 123 124 const String aString( ByteString("This is a test"), 125 RTL_TEXTENCODING_ASCII_US ); 126 const LineInfo aLineInfo(LINE_SOLID,5); 127 128 // unfortunately, VDevs have inaccessible copy constructors 129 static VirtualDevice aVDev; 130 static VirtualDevice aVDevBW(1); 131 132 const Size aVDevSize; 133 aVDev.SetOutputSizePixel(aVDevSize); 134 aVDevBW.SetOutputSizePixel(aVDevSize); 135 136 const Bitmap aBitmap( aVDev.GetBitmap(aPt1,aVDevSize) ); 137 const Bitmap aBitmapBW( aVDevBW.GetBitmap(aPt1,aVDevSize) ); 138 const Bitmap aBitmapAlien( aVDevSize, 8 ); 139 140 const BitmapEx aBitmapEx( aBitmap, aBitmapBW ); 141 const BitmapEx aBitmapExBW( aBitmapBW, aBitmapBW ); 142 const BitmapEx aBitmapExAlien( aBitmapAlien, aBitmapBW ); 143 const BitmapEx aBitmapExAlpha( aBitmap, aBitmapAlien ); 144 const BitmapEx aBitmapExAlphaAlien( aBitmapAlien, aBitmapAlien ); 145 146 const Image aImage( aBitmapEx ); 147 const Gradient aGradient(GRADIENT_ELLIPTICAL,aBlackColor,aWhiteColor); 148 const Hatch aHatch(HatchStyle_TRIPLE,aBlackColor,4,450); 149 const Wallpaper aWallpaper( aWhiteColor ); 150 151 GDIMetaFile aMtf; 152 aMtf.AddAction( new MetaFillColorAction(Color(COL_RED),sal_True) ); 153 aMtf.AddAction( new MetaRectAction(aRect) ); 154 155 /* void DrawText( const Point& rStartPt, const XubString& rStr, 156 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, 157 MetricVector* pVector = NULL, String* pDisplayText = NULL ); 158 */ 159 // add(res, 160 // "DrawText", 161 // boost::bind( 162 // &OutputDevice::DrawText, 163 // _1, 164 // aPt1, aString, (sal_uInt16)0, aString.Len(), (MetricVector*)0, (String*)0, (vcl::ITextLayout*)0 )); 165 166 /* void DrawTextArray( const Point& rStartPt, const XubString& rStr, 167 const sal_Int32* pDXAry = NULL, 168 xub_StrLen nIndex = 0, 169 xub_StrLen nLen = STRING_LEN ); 170 */ 171 add(res, 172 "DrawTextArray", 173 boost::bind( 174 &OutputDevice::DrawTextArray, 175 _1, 176 aPt1, aString, (const sal_Int32*)0, (sal_uInt16)0, aString.Len() )); 177 178 /* void DrawPixel( const Point& rPt, const Color& rColor ); */ 179 add(res, 180 "DrawPixel", 181 boost::bind( 182 (void (OutputDevice::*)( const Point&, const Color& ))( 183 &OutputDevice::DrawPixel), 184 _1, 185 aPt1, aBlackColor )); 186 187 /* void DrawLine( const Point& rStartPt, const Point& rEndPt ); */ 188 add(res, 189 "DrawLine", 190 boost::bind( 191 (void (OutputDevice::*)( const Point&, const Point& ))( 192 &OutputDevice::DrawLine), 193 _1, 194 aPt1, aPt2 )); 195 196 /* void DrawLine( const Point& rStartPt, const Point& rEndPt, 197 const LineInfo& rLineInfo ); 198 */ 199 add(res, 200 "DrawLine(LineInfo)", 201 boost::bind( 202 (void (OutputDevice::*)( const Point&, const Point&,const LineInfo& ))( 203 &OutputDevice::DrawLine), 204 _1, 205 aPt1, aPt2, aLineInfo )); 206 207 /* void DrawPolyLine( const Polygon& rPoly ); */ 208 add(res, 209 "DrawPolyLine", 210 boost::bind( 211 (void (OutputDevice::*)( const Polygon& ))( 212 &OutputDevice::DrawPolyLine), 213 _1, 214 aPoly )); 215 216 /* void DrawPolyLine( const Polygon& rPoly, 217 const LineInfo& rLineInfo ); 218 */ 219 add(res, 220 "DrawPolyLine(LineInfo)", 221 boost::bind( 222 (void (OutputDevice::*)( const Polygon&, const LineInfo& ))( 223 &OutputDevice::DrawPolyLine), 224 _1, 225 aPoly, aLineInfo )); 226 227 /* void DrawPolygon( const Polygon& rPoly ); */ 228 add(res, 229 "DrawPolygon", 230 boost::bind( 231 (void (OutputDevice::*)( const Polygon& )) 232 &OutputDevice::DrawPolygon, 233 _1, 234 aPoly )); 235 236 /* void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); */ 237 add(res, 238 "DrawPolyPolygon", 239 boost::bind( 240 (void (OutputDevice::*)( const PolyPolygon& )) 241 &OutputDevice::DrawPolyPolygon, 242 _1, 243 aPolyPoly )); 244 245 /* void DrawRect( const Rectangle& rRect ); */ 246 add(res, 247 "DrawRect", 248 boost::bind( 249 (void (OutputDevice::*)( const Rectangle& ))( 250 &OutputDevice::DrawRect), 251 _1, 252 aRect )); 253 254 /* void DrawRect( const Rectangle& rRect, 255 sal_uLong nHorzRount, sal_uLong nVertRound ); 256 */ 257 add(res, 258 "DrawRect(round corners)", 259 boost::bind( 260 (void (OutputDevice::*)( const Rectangle&, sal_uLong nHorzRount, sal_uLong nVertRound ))( 261 &OutputDevice::DrawRect), 262 _1, 263 aRect2, 264 4,4)); 265 266 /* void DrawEllipse( const Rectangle& rRect ); */ 267 add(res, 268 "DrawEllipse", 269 boost::bind( 270 &OutputDevice::DrawEllipse, 271 _1, 272 aRect )); 273 274 /* void DrawArc( const Rectangle& rRect, 275 const Point& rStartPt, const Point& rEndPt ); 276 */ 277 add(res, 278 "DrawArc", 279 boost::bind( 280 &OutputDevice::DrawArc, 281 _1, 282 aRect,aPt1,aPt2 )); 283 284 /* void DrawPie( const Rectangle& rRect, 285 const Point& rStartPt, const Point& rEndPt ); 286 */ 287 add(res, 288 "DrawPie", 289 boost::bind( 290 &OutputDevice::DrawPie, 291 _1, 292 aRect2,aPt3,aPt4 )); 293 294 /* void DrawChord( const Rectangle& rRect, 295 const Point& rStartPt, const Point& rEndPt ); 296 */ 297 add(res, 298 "DrawChord", 299 boost::bind( 300 &OutputDevice::DrawChord, 301 _1, 302 aRect2,aPt3,aPt4 )); 303 304 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize, 305 const Point& rSrcPt, const Size& rSrcSize ); 306 */ 307 add(res, 308 "DrawOutDev", 309 boost::bind( 310 (void (OutputDevice::*)( const Point&, const Size&, 311 const Point&, const Size& ))( 312 &OutputDevice::DrawOutDev), 313 _1, 314 aRect2.TopLeft(), aRect2.GetSize(), 315 aRect.TopLeft(), aRect.GetSize())); 316 317 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize, 318 const Point& rSrcPt, const Size& rSrcSize, 319 const OutputDevice& rOutDev ); 320 */ 321 add(res, 322 "DrawOutDev(foreign source)", 323 boost::bind( 324 (void (OutputDevice::*)( const Point&, const Size&, 325 const Point&, const Size&, 326 const OutputDevice& ))( 327 &OutputDevice::DrawOutDev), 328 _1, 329 aRect2.TopLeft(), aRect2.GetSize(), 330 aRect.TopLeft(), aRect.GetSize(), 331 boost::cref(aVDevBW) )); 332 333 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize, 334 const Point& rSrcPt, const Size& rSrcSize, 335 const OutputDevice& rOutDev ); 336 */ 337 add(res, 338 "DrawOutDev(foreign source, scaled)", 339 boost::bind( 340 (void (OutputDevice::*)( const Point&, const Size&, 341 const Point&, const Size&, 342 const OutputDevice& ))( 343 &OutputDevice::DrawOutDev), 344 _1, 345 aRect2.TopLeft(), aRect2.GetSize(), 346 aRect.TopLeft(), aRect.GetSize(), 347 boost::cref(aVDev) )); 348 349 /* void CopyArea( const Point& rDestPt, 350 const Point& rSrcPt, const Size& rSrcSize, 351 sal_uInt16 nFlags = 0 ); 352 */ 353 add(res, 354 "CopyArea", 355 boost::bind( 356 &OutputDevice::CopyArea, 357 _1, 358 aPt1,aPt3,aRect2.GetSize(),(sal_uInt16)0 )); 359 360 /* void DrawBitmap( const Point& rDestPt, 361 const Bitmap& rBitmap ); 362 */ 363 add(res, 364 "DrawBitmap(alien source)", 365 boost::bind( 366 (void (OutputDevice::*)( const Point&, 367 const Bitmap& ))( 368 &OutputDevice::DrawBitmap), 369 _1, 370 aPt1,aBitmapAlien )); 371 372 /* void DrawBitmap( const Point& rDestPt, 373 const Bitmap& rBitmap ); 374 */ 375 add(res, 376 "DrawBitmap", 377 boost::bind( 378 (void (OutputDevice::*)( const Point&, 379 const Bitmap& ))( 380 &OutputDevice::DrawBitmap), 381 _1, 382 aPt1,aBitmap )); 383 384 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize, 385 const Bitmap& rBitmap ); 386 */ 387 add(res, 388 "DrawBitmap(scaled,alien source)", 389 boost::bind( 390 (void (OutputDevice::*)( const Point&, 391 const Size&, 392 const Bitmap& ))( 393 &OutputDevice::DrawBitmap), 394 _1, 395 aPt1,aRect.GetSize(),aBitmapAlien )); 396 397 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize, 398 const Bitmap& rBitmap ); 399 */ 400 add(res, 401 "DrawBitmap(scaled)", 402 boost::bind( 403 (void (OutputDevice::*)( const Point&, 404 const Size&, 405 const Bitmap& ))( 406 &OutputDevice::DrawBitmap), 407 _1, 408 aPt1,aRect.GetSize(),aBitmap )); 409 410 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize, 411 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 412 const Bitmap& rBitmap ); 413 */ 414 add(res, 415 "DrawBitmap(scaled subset,alien source)", 416 boost::bind( 417 (void (OutputDevice::*)( const Point&, 418 const Size&, 419 const Point&, 420 const Size&, 421 const Bitmap& ))( 422 &OutputDevice::DrawBitmap), 423 _1, 424 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien )); 425 426 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize, 427 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 428 const Bitmap& rBitmap ); 429 */ 430 add(res, 431 "DrawBitmap(scaled subset)", 432 boost::bind( 433 (void (OutputDevice::*)( const Point&, 434 const Size&, 435 const Point&, 436 const Size&, 437 const Bitmap& ))( 438 &OutputDevice::DrawBitmap), 439 _1, 440 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap )); 441 442 /* void DrawBitmapEx( const Point& rDestPt, 443 const BitmapEx& rBitmapEx ); 444 */ 445 add(res, 446 "DrawBitmapEx(alien source)", 447 boost::bind( 448 (void (OutputDevice::*)( const Point&, 449 const BitmapEx& ))( 450 &OutputDevice::DrawBitmapEx), 451 _1, 452 aPt1,aBitmapExAlien )); 453 454 /* void DrawBitmapEx( const Point& rDestPt, 455 const BitmapEx& rBitmapEx ); 456 */ 457 add(res, 458 "DrawBitmapEx", 459 boost::bind( 460 (void (OutputDevice::*)( const Point&, 461 const BitmapEx& ))( 462 &OutputDevice::DrawBitmapEx), 463 _1, 464 aPt1,aBitmapEx )); 465 466 /* void DrawBitmapEx( const Point& rDestPt, 467 const BitmapEx& rBitmapEx ); 468 */ 469 add(res, 470 "DrawBitmapEx(alpha)", 471 boost::bind( 472 (void (OutputDevice::*)( const Point&, 473 const BitmapEx& ))( 474 &OutputDevice::DrawBitmapEx), 475 _1, 476 aPt1,aBitmapExAlpha )); 477 478 /* void DrawBitmapEx( const Point& rDestPt, 479 const BitmapEx& rBitmapEx ); 480 */ 481 add(res, 482 "DrawBitmapEx(alpha, alien source)", 483 boost::bind( 484 (void (OutputDevice::*)( const Point&, 485 const BitmapEx& ))( 486 &OutputDevice::DrawBitmapEx), 487 _1, 488 aPt1,aBitmapExAlphaAlien )); 489 490 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 491 const BitmapEx& rBitmapEx ); 492 */ 493 add(res, 494 "DrawBitmapEx(scaled,alien source)", 495 boost::bind( 496 (void (OutputDevice::*)( const Point&, 497 const Size&, 498 const BitmapEx& ))( 499 &OutputDevice::DrawBitmapEx), 500 _1, 501 aPt1,aRect.GetSize(),aBitmapExAlien )); 502 503 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 504 const BitmapEx& rBitmapEx ); 505 */ 506 add(res, 507 "DrawBitmapEx(scaled)", 508 boost::bind( 509 (void (OutputDevice::*)( const Point&, 510 const Size&, 511 const BitmapEx& ))( 512 &OutputDevice::DrawBitmapEx), 513 _1, 514 aPt1,aRect.GetSize(),aBitmapEx )); 515 516 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 517 const BitmapEx& rBitmapEx ); 518 */ 519 add(res, 520 "DrawBitmapEx(scaled alpha)", 521 boost::bind( 522 (void (OutputDevice::*)( const Point&, 523 const Size&, 524 const BitmapEx& ))( 525 &OutputDevice::DrawBitmapEx), 526 _1, 527 aPt1,aRect.GetSize(),aBitmapExAlpha )); 528 529 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 530 const BitmapEx& rBitmapEx ); 531 */ 532 add(res, 533 "DrawBitmapEx(scaled alpha, alien source)", 534 boost::bind( 535 (void (OutputDevice::*)( const Point&, 536 const Size&, 537 const BitmapEx& ))( 538 &OutputDevice::DrawBitmapEx), 539 _1, 540 aPt1,aRect.GetSize(),aBitmapExAlphaAlien )); 541 542 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 543 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 544 const BitmapEx& rBitmapEx ); 545 */ 546 add(res, 547 "DrawBitmapEx(scaled subset,alien source)", 548 boost::bind( 549 (void (OutputDevice::*)( const Point&, 550 const Size&, 551 const Point&, 552 const Size&, 553 const BitmapEx& ))( 554 &OutputDevice::DrawBitmapEx), 555 _1, 556 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlien )); 557 558 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 559 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 560 const BitmapEx& rBitmapEx ); 561 */ 562 add(res, 563 "DrawBitmapEx(scaled subset)", 564 boost::bind( 565 (void (OutputDevice::*)( const Point&, 566 const Size&, 567 const Point&, 568 const Size&, 569 const BitmapEx& ))( 570 &OutputDevice::DrawBitmapEx), 571 _1, 572 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapEx )); 573 574 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 575 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 576 const BitmapEx& rBitmapEx ); 577 */ 578 add(res, 579 "DrawBitmapEx(scaled subset, alpha)", 580 boost::bind( 581 (void (OutputDevice::*)( const Point&, 582 const Size&, 583 const Point&, 584 const Size&, 585 const BitmapEx& ))( 586 &OutputDevice::DrawBitmapEx), 587 _1, 588 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlpha )); 589 590 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize, 591 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 592 const BitmapEx& rBitmapEx ); 593 */ 594 add(res, 595 "DrawBitmapEx(scaled subset, alpha alien source)", 596 boost::bind( 597 (void (OutputDevice::*)( const Point&, 598 const Size&, 599 const Point&, 600 const Size&, 601 const BitmapEx& ))( 602 &OutputDevice::DrawBitmapEx), 603 _1, 604 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlphaAlien )); 605 606 /* void DrawMask( const Point& rDestPt, 607 const Bitmap& rBitmap, const Color& rMaskColor ); 608 */ 609 add(res, 610 "DrawMask(alien source)", 611 boost::bind( 612 (void (OutputDevice::*)( const Point&, 613 const Bitmap&, 614 const Color& ))( 615 &OutputDevice::DrawMask), 616 _1, 617 aPt1,aBitmapAlien,aBlackColor )); 618 619 /* void DrawMask( const Point& rDestPt, 620 const Bitmap& rBitmap, const Color& rMaskColor ); 621 */ 622 add(res, 623 "DrawMask", 624 boost::bind( 625 (void (OutputDevice::*)( const Point&, 626 const Bitmap&, 627 const Color& ))( 628 &OutputDevice::DrawMask), 629 _1, 630 aPt1,aBitmap,aBlackColor )); 631 632 /* void DrawMask( const Point& rDestPt, const Size& rDestSize, 633 const Bitmap& rBitmap, const Color& rMaskColor ); 634 */ 635 add(res, 636 "DrawMask(scaled,alien source)", 637 boost::bind( 638 (void (OutputDevice::*)( const Point&, 639 const Size&, 640 const Bitmap&, 641 const Color& ))( 642 &OutputDevice::DrawMask), 643 _1, 644 aPt1,aRect.GetSize(),aBitmapAlien, aBlackColor )); 645 646 /* void DrawMask( const Point& rDestPt, const Size& rDestSize, 647 const Bitmap& rBitmap, const Color& rMaskColor ); 648 */ 649 add(res, 650 "DrawMask(scaled)", 651 boost::bind( 652 (void (OutputDevice::*)( const Point&, 653 const Size&, 654 const Bitmap&, 655 const Color& ))( 656 &OutputDevice::DrawMask), 657 _1, 658 aPt1,aRect.GetSize(),aBitmap,aBlackColor )); 659 660 /* void DrawMask( const Point& rDestPt, const Size& rDestSize, 661 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 662 const Bitmap& rBitmap, const Color& rMaskColor ); 663 */ 664 add(res, 665 "DrawMask(scaled subset,alien source)", 666 boost::bind( 667 (void (OutputDevice::*)( const Point&, 668 const Size&, 669 const Point&, 670 const Size&, 671 const Bitmap&, 672 const Color& ))( 673 &OutputDevice::DrawMask), 674 _1, 675 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien,aBlackColor )); 676 677 /* void DrawMask( const Point& rDestPt, const Size& rDestSize, 678 const Point& rSrcPtPixel, const Size& rSrcSizePixel, 679 const Bitmap& rBitmap, const Color& rMaskColor ); 680 */ 681 add(res, 682 "DrawMask(scaled subset)", 683 boost::bind( 684 (void (OutputDevice::*)( const Point&, 685 const Size&, 686 const Point&, 687 const Size&, 688 const Bitmap&, 689 const Color& ))( 690 &OutputDevice::DrawMask), 691 _1, 692 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap,aBlackColor )); 693 694 /* void DrawImage( const Point& rPos, 695 const Image& rImage, sal_uInt16 nStyle = 0 ); 696 */ 697 add(res, 698 "DrawImage", 699 boost::bind( 700 (void (OutputDevice::*)( const Point&, 701 const Image&, 702 sal_uInt16 nStyle ))( 703 &OutputDevice::DrawImage), 704 _1, 705 aPt1,aImage,(sal_uInt16)0 )); 706 707 /* void DrawImage( const Point& rPos, const Size& rSize, 708 const Image& rImage, sal_uInt16 nStyle = 0 ); 709 */ 710 add(res, 711 "DrawImage(scaled)", 712 boost::bind( 713 (void (OutputDevice::*)( const Point&, 714 const Size&, 715 const Image&, 716 sal_uInt16 nStyle ))( 717 &OutputDevice::DrawImage), 718 _1, 719 aPt1,aRect.GetSize(),aImage,(sal_uInt16)0 )); 720 721 /* void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); */ 722 add(res, 723 "DrawGradient", 724 boost::bind( 725 (void (OutputDevice::*)( const Rectangle&, const Gradient& ))( 726 &OutputDevice::DrawGradient), 727 _1, 728 aRect,aGradient )); 729 730 /* void DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); */ 731 add(res, 732 "DrawGradient(polygon)", 733 boost::bind( 734 (void (OutputDevice::*)( const PolyPolygon&, const Gradient& ))( 735 &OutputDevice::DrawGradient), 736 _1, 737 aPoly3,aGradient )); 738 739 /* void DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); */ 740 add(res, 741 "DrawHatch", 742 boost::bind( 743 &OutputDevice::DrawHatch, 744 _1, 745 aPoly3,aHatch )); 746 747 /* void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); */ 748 add(res, 749 "DrawWallpaper", 750 boost::bind( 751 &OutputDevice::DrawWallpaper, 752 _1, 753 aRect2,aWallpaper )); 754 755 /* void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, sal_uInt16 nStyle ); */ 756 add(res, 757 "DrawWaveLine", 758 boost::bind( 759 &OutputDevice::DrawWaveLine, 760 _1, 761 aPt1,aPt2,(sal_uInt16)WAVE_NORMAL )); 762 763 /* void DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags ); */ 764 add(res, 765 "DrawGrid", 766 boost::bind( 767 &OutputDevice::DrawGrid, 768 _1, 769 aRect,Size(10,20),GRID_HORZLINES|GRID_VERTLINES )); 770 771 /* void DrawTransparent( const PolyPolygon& rPolyPoly, 772 sal_uInt16 nTransparencePercent ); 773 */ 774 add(res, 775 "DrawTransparent", 776 boost::bind( 777 (void (OutputDevice::*)( const PolyPolygon&, sal_uInt16 ))( 778 &OutputDevice::DrawTransparent), 779 _1, 780 aPoly3,(sal_uInt16)50 )); 781 782 /* void DrawTransparent( const GDIMetaFile& rMtf, 783 const Point& rPos, const Size& rSize, 784 const Gradient& rTransparenceGradient ); 785 */ 786 add(res, 787 "DrawTransparent(metafile)", 788 boost::bind( 789 (void (OutputDevice::*)( const GDIMetaFile&, 790 const Point&, 791 const Size&, 792 const Gradient& ))( 793 &OutputDevice::DrawTransparent), 794 _1, 795 aMtf,aPt1,aRect.GetSize(),aGradient )); 796 797 /* void Erase(); */ 798 add(res, 799 "Erase", 800 boost::bind( 801 &OutputDevice::Erase, 802 _1 )); 803 804 } 805 806 //---------------------------------------------------------------------------------- 807 808 void grindFunc( OutputDevice& rTarget, 809 functor_vector_type::const_iterator iter, 810 sal_Int32 nTurns, 811 const char* pMsg ) 812 { 813 const sal_uInt32 nStartTime( osl_getGlobalTimer() ); 814 815 for( sal_Int32 i=0; i<nTurns; ++i ) 816 iter->second(&rTarget); 817 818 if( rTarget.GetOutDevType() == OUTDEV_WINDOW ) 819 static_cast<Window&>(rTarget).Sync(); 820 821 fprintf( stdout, 822 "Duration: %d ms (%d repetitions)\tOperation: %s\tSetup: %s\n", 823 (int)(osl_getGlobalTimer() - nStartTime), 824 (int)(nTurns), 825 iter->first, 826 pMsg ); 827 } 828 829 //---------------------------------------------------------------------------------- 830 831 /** Call OutputDevice render methods repeatedly, and output elapsed 832 time to stdout 833 */ 834 void outDevGrind( OutputDevice& rTarget, sal_Int32 nTurns=100 ) 835 { 836 // TODO(F1): also profile pure complex clip setup times! 837 838 // State: fill/line color, draw mode, w/o clip, rect clip, complex clip 839 functor_vector_type aMethods; 840 setupMethodStubs( aMethods ); 841 842 const Rectangle aClipRect(10,10,1000,1000); 843 const Polygon aPoly1( aClipRect ); 844 Polygon aPoly2( aClipRect ); 845 aPoly2.Rotate(aClipRect.Center(),450); 846 PolyPolygon aClipPoly(aPoly1); 847 aClipPoly.Insert(aPoly2); 848 849 functor_vector_type::const_iterator iter = aMethods.begin(); 850 const functor_vector_type::const_iterator end = aMethods.end(); 851 while( iter != end ) 852 { 853 rTarget.SetLineColor( Color(COL_BLACK) ); 854 rTarget.SetFillColor( Color(COL_GREEN) ); 855 rTarget.SetRasterOp( ROP_OVERPAINT ); 856 rTarget.SetClipRegion(); 857 grindFunc( rTarget, iter, nTurns, "w/o clip, w/o xor" ); 858 859 rTarget.SetLineColor( Color(COL_BLACK) ); 860 rTarget.SetFillColor( Color(COL_GREEN) ); 861 rTarget.SetRasterOp( ROP_OVERPAINT ); 862 rTarget.SetClipRegion( aClipRect ); 863 grindFunc( rTarget, iter, nTurns, "with rect clip, w/o xor" ); 864 865 rTarget.SetLineColor( Color(COL_BLACK) ); 866 rTarget.SetFillColor( Color(COL_GREEN) ); 867 rTarget.SetRasterOp( ROP_OVERPAINT ); 868 rTarget.SetClipRegion( aClipPoly ); 869 grindFunc( rTarget, iter, nTurns, "with complex clip, w/o xor" ); 870 871 rTarget.SetLineColor( Color(COL_BLACK) ); 872 rTarget.SetFillColor( Color(COL_GREEN) ); 873 rTarget.SetRasterOp( ROP_XOR ); 874 rTarget.SetClipRegion(); 875 grindFunc( rTarget, iter, nTurns, "w/o clip, with xor" ); 876 877 rTarget.SetLineColor( Color(COL_BLACK) ); 878 rTarget.SetFillColor( Color(COL_GREEN) ); 879 rTarget.SetRasterOp( ROP_XOR ); 880 rTarget.SetClipRegion( aClipRect ); 881 grindFunc( rTarget, iter, nTurns, "with rect clip, with xor" ); 882 883 rTarget.SetLineColor( Color(COL_BLACK) ); 884 rTarget.SetFillColor( Color(COL_GREEN) ); 885 rTarget.SetRasterOp( ROP_XOR ); 886 rTarget.SetClipRegion( aClipPoly ); 887 grindFunc( rTarget, iter, nTurns, "with complex clip, with xor" ); 888 889 ++iter; 890 } 891 } 892 893 //---------------------------------------------------------------------------------- 894 895 void TestWindow::Paint( const Rectangle& ) 896 { 897 outDevGrind( *this ); 898 fflush( stdout ); 899 } 900 901 sal_uInt16 GrindApp::Exception( sal_uInt16 nError ) 902 { 903 switch( nError & EXC_MAJORTYPE ) 904 { 905 case EXC_RSCNOTLOADED: 906 Abort( String::CreateFromAscii( 907 "Error: could not load language resources.\nPlease check your installation.\n" ) ); 908 break; 909 } 910 return 0; 911 } 912 913 void GrindApp::Main() 914 { 915 bool bHelp = false; 916 917 for( sal_uInt16 i = 0; i < GetCommandLineParamCount(); i++ ) 918 { 919 ::rtl::OUString aParam = GetCommandLineParam( i ); 920 921 if( aParam.equalsAscii( "--help" ) || 922 aParam.equalsAscii( "-h" ) ) 923 bHelp = true; 924 } 925 926 if( bHelp ) 927 { 928 printf( "outdevgrind - Profile OutputDevice\n" ); 929 return; 930 } 931 932 //------------------------------------------------- 933 // create the global service-manager 934 //------------------------------------------------- 935 uno::Reference< lang::XMultiServiceFactory > xFactory; 936 try 937 { 938 uno::Reference< uno::XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext(); 939 xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(), 940 uno::UNO_QUERY ); 941 if( xFactory.is() ) 942 ::comphelper::setProcessServiceFactory( xFactory ); 943 } 944 catch( uno::Exception& ) 945 { 946 } 947 948 if( !xFactory.is() ) 949 { 950 fprintf( stderr, 951 "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" ); 952 exit( 1 ); 953 } 954 955 // Create UCB. 956 uno::Sequence< uno::Any > aArgs( 2 ); 957 aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL ); 958 aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE ); 959 ::ucbhelper::ContentBroker::initialize( xFactory, aArgs ); 960 961 TestWindow pWindow; 962 pWindow.Execute(); 963 964 // clean up UCB 965 ::ucbhelper::ContentBroker::deinitialize(); 966 } 967 968 } // namespace 969 970 GrindApp aGrindApp; 971