merge the formfield patch from ooo-build
[ooovba.git] / vcl / workben / outdevgrind.cxx
bloba0900e34a8dd2235bbbb2b325a1b77e5e1c871c9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outdevgrind.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 // bootstrap stuff
35 #include <rtl/bootstrap.hxx>
36 #include <comphelper/processfactory.hxx>
37 #include <comphelper/regpathhelper.hxx>
38 #include <cppuhelper/servicefactory.hxx>
39 #include <cppuhelper/bootstrap.hxx>
40 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/registry/XSimpleRegistry.hpp>
44 #include <ucbhelper/contentbroker.hxx>
45 #include <ucbhelper/configurationkeys.hxx>
47 #include <vcl/svapp.hxx>
48 #include <vcl/dialog.hxx>
49 #include <vcl/outdev.hxx>
50 #include <vcl/virdev.hxx>
51 #include <vcl/hatch.hxx>
52 #include <vcl/bitmap.hxx>
53 #include <vcl/wall.hxx>
54 #include <vcl/image.hxx>
55 #include <vcl/gdimtf.hxx>
56 #include <vcl/metaact.hxx>
57 #include <vcl/bitmapex.hxx>
58 #include <vcl/gradient.hxx>
59 #include <vcl/lineinfo.hxx>
60 #include <tools/string.hxx>
62 #include <osl/time.h>
64 #include <boost/function.hpp>
65 #include <boost/bind.hpp>
67 #include <stdio.h>
68 #include <unistd.h>
70 using namespace ::com::sun::star;
73 namespace
76 class GrindApp : public Application
78 public:
79 virtual void Main();
80 virtual USHORT Exception( USHORT nError );
83 class TestWindow : public Dialog
85 public:
86 TestWindow() : Dialog( (Window *) NULL )
88 SetText( rtl::OUString::createFromAscii( "OutDev grinding" ) );
89 SetSizePixel( Size( 1024, 1024 ) );
90 EnablePaint( true );
91 Show();
94 virtual ~TestWindow() {}
95 virtual void Paint( const Rectangle& rRect );
98 //----------------------------------------------------------------------------------
100 typedef boost::function1<void, OutputDevice*> functor_type;
101 typedef std::vector< std::pair<const char*,
102 functor_type> > functor_vector_type;
104 template< typename Functor > void add( functor_vector_type& res,
105 const char* pStr,
106 const Functor& func )
108 res.push_back( std::make_pair(pStr,functor_type(func)) );
111 void setupMethodStubs( functor_vector_type& res )
113 const Color aWhiteColor( COL_WHITE );
114 const Color aBlackColor( COL_BLACK );
116 const Point aPt1(10,10);
117 const Point aPt2(500,500);
118 const Point aPt3(0,0);
119 const Point aPt4(450,450);
121 const Rectangle aRect(aPt1,aPt2);
122 const Rectangle aRect2(aPt3,aPt4);
123 const Polygon aPoly(aRect);
124 const Polygon aPoly2(aRect2);
125 PolyPolygon aPolyPoly(aPoly);
126 aPolyPoly.Insert( aPoly2 );
127 Polygon aPoly3(aPoly2);
128 aPoly3.Rotate( aPoly3.GetBoundRect().Center(),
129 900 );
131 const String aString( ByteString("This is a test"),
132 RTL_TEXTENCODING_ASCII_US );
133 const LineInfo aLineInfo(LINE_SOLID,5);
135 // unfortunately, VDevs have inaccessible copy constructors
136 static VirtualDevice aVDev;
137 static VirtualDevice aVDevBW(1);
139 const Size aVDevSize;
140 aVDev.SetOutputSizePixel(aVDevSize);
141 aVDevBW.SetOutputSizePixel(aVDevSize);
143 const Bitmap aBitmap( aVDev.GetBitmap(aPt1,aVDevSize) );
144 const Bitmap aBitmapBW( aVDevBW.GetBitmap(aPt1,aVDevSize) );
145 const Bitmap aBitmapAlien( aVDevSize, 8 );
147 const BitmapEx aBitmapEx( aBitmap, aBitmapBW );
148 const BitmapEx aBitmapExBW( aBitmapBW, aBitmapBW );
149 const BitmapEx aBitmapExAlien( aBitmapAlien, aBitmapBW );
150 const BitmapEx aBitmapExAlpha( aBitmap, aBitmapAlien );
151 const BitmapEx aBitmapExAlphaAlien( aBitmapAlien, aBitmapAlien );
153 const Image aImage( aBitmapEx );
154 const Gradient aGradient(GRADIENT_ELLIPTICAL,aBlackColor,aWhiteColor);
155 const Hatch aHatch(HatchStyle_TRIPLE,aBlackColor,4,450);
156 const Wallpaper aWallpaper( aWhiteColor );
158 GDIMetaFile aMtf;
159 aMtf.AddAction( new MetaFillColorAction(Color(COL_RED),TRUE) );
160 aMtf.AddAction( new MetaRectAction(aRect) );
162 /* void DrawText( const Point& rStartPt, const XubString& rStr,
163 xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN,
164 MetricVector* pVector = NULL, String* pDisplayText = NULL );
166 add(res,
167 "DrawText",
168 boost::bind(
169 &OutputDevice::DrawText,
171 aPt1, aString, (USHORT)0, aString.Len(), (MetricVector*)0, (String*)0 ));
173 /* void DrawTextArray( const Point& rStartPt, const XubString& rStr,
174 const sal_Int32* pDXAry = NULL,
175 xub_StrLen nIndex = 0,
176 xub_StrLen nLen = STRING_LEN );
178 add(res,
179 "DrawTextArray",
180 boost::bind(
181 &OutputDevice::DrawTextArray,
183 aPt1, aString, (const sal_Int32*)0, (USHORT)0, aString.Len() ));
185 /* void DrawPixel( const Point& rPt, const Color& rColor ); */
186 add(res,
187 "DrawPixel",
188 boost::bind(
189 (void (OutputDevice::*)( const Point&, const Color& ))(
190 &OutputDevice::DrawPixel),
192 aPt1, aBlackColor ));
194 /* void DrawLine( const Point& rStartPt, const Point& rEndPt ); */
195 add(res,
196 "DrawLine",
197 boost::bind(
198 (void (OutputDevice::*)( const Point&, const Point& ))(
199 &OutputDevice::DrawLine),
201 aPt1, aPt2 ));
203 /* void DrawLine( const Point& rStartPt, const Point& rEndPt,
204 const LineInfo& rLineInfo );
206 add(res,
207 "DrawLine(LineInfo)",
208 boost::bind(
209 (void (OutputDevice::*)( const Point&, const Point&,const LineInfo& ))(
210 &OutputDevice::DrawLine),
212 aPt1, aPt2, aLineInfo ));
214 /* void DrawPolyLine( const Polygon& rPoly ); */
215 add(res,
216 "DrawPolyLine",
217 boost::bind(
218 (void (OutputDevice::*)( const Polygon& ))(
219 &OutputDevice::DrawPolyLine),
221 aPoly ));
223 /* void DrawPolyLine( const Polygon& rPoly,
224 const LineInfo& rLineInfo );
226 add(res,
227 "DrawPolyLine(LineInfo)",
228 boost::bind(
229 (void (OutputDevice::*)( const Polygon&, const LineInfo& ))(
230 &OutputDevice::DrawPolyLine),
232 aPoly, aLineInfo ));
234 /* void DrawPolygon( const Polygon& rPoly ); */
235 add(res,
236 "DrawPolygon",
237 boost::bind(
238 (void (OutputDevice::*)( const Polygon& ))
239 &OutputDevice::DrawPolygon,
241 aPoly ));
243 /* void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); */
244 add(res,
245 "DrawPolyPolygon",
246 boost::bind(
247 (void (OutputDevice::*)( const PolyPolygon& ))
248 &OutputDevice::DrawPolyPolygon,
250 aPolyPoly ));
252 /* void DrawRect( const Rectangle& rRect ); */
253 add(res,
254 "DrawRect",
255 boost::bind(
256 (void (OutputDevice::*)( const Rectangle& ))(
257 &OutputDevice::DrawRect),
259 aRect ));
261 /* void DrawRect( const Rectangle& rRect,
262 ULONG nHorzRount, ULONG nVertRound );
264 add(res,
265 "DrawRect(round corners)",
266 boost::bind(
267 (void (OutputDevice::*)( const Rectangle&, ULONG nHorzRount, ULONG nVertRound ))(
268 &OutputDevice::DrawRect),
270 aRect2,
271 4,4));
273 /* void DrawEllipse( const Rectangle& rRect ); */
274 add(res,
275 "DrawEllipse",
276 boost::bind(
277 &OutputDevice::DrawEllipse,
279 aRect ));
281 /* void DrawArc( const Rectangle& rRect,
282 const Point& rStartPt, const Point& rEndPt );
284 add(res,
285 "DrawArc",
286 boost::bind(
287 &OutputDevice::DrawArc,
289 aRect,aPt1,aPt2 ));
291 /* void DrawPie( const Rectangle& rRect,
292 const Point& rStartPt, const Point& rEndPt );
294 add(res,
295 "DrawPie",
296 boost::bind(
297 &OutputDevice::DrawPie,
299 aRect2,aPt3,aPt4 ));
301 /* void DrawChord( const Rectangle& rRect,
302 const Point& rStartPt, const Point& rEndPt );
304 add(res,
305 "DrawChord",
306 boost::bind(
307 &OutputDevice::DrawChord,
309 aRect2,aPt3,aPt4 ));
311 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
312 const Point& rSrcPt, const Size& rSrcSize );
314 add(res,
315 "DrawOutDev",
316 boost::bind(
317 (void (OutputDevice::*)( const Point&, const Size&,
318 const Point&, const Size& ))(
319 &OutputDevice::DrawOutDev),
321 aRect2.TopLeft(), aRect2.GetSize(),
322 aRect.TopLeft(), aRect.GetSize()));
324 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
325 const Point& rSrcPt, const Size& rSrcSize,
326 const OutputDevice& rOutDev );
328 add(res,
329 "DrawOutDev(foreign source)",
330 boost::bind(
331 (void (OutputDevice::*)( const Point&, const Size&,
332 const Point&, const Size&,
333 const OutputDevice& ))(
334 &OutputDevice::DrawOutDev),
336 aRect2.TopLeft(), aRect2.GetSize(),
337 aRect.TopLeft(), aRect.GetSize(),
338 boost::cref(aVDevBW) ));
340 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
341 const Point& rSrcPt, const Size& rSrcSize,
342 const OutputDevice& rOutDev );
344 add(res,
345 "DrawOutDev(foreign source, scaled)",
346 boost::bind(
347 (void (OutputDevice::*)( const Point&, const Size&,
348 const Point&, const Size&,
349 const OutputDevice& ))(
350 &OutputDevice::DrawOutDev),
352 aRect2.TopLeft(), aRect2.GetSize(),
353 aRect.TopLeft(), aRect.GetSize(),
354 boost::cref(aVDev) ));
356 /* void CopyArea( const Point& rDestPt,
357 const Point& rSrcPt, const Size& rSrcSize,
358 USHORT nFlags = 0 );
360 add(res,
361 "CopyArea",
362 boost::bind(
363 &OutputDevice::CopyArea,
365 aPt1,aPt3,aRect2.GetSize(),(USHORT)0 ));
367 /* void DrawBitmap( const Point& rDestPt,
368 const Bitmap& rBitmap );
370 add(res,
371 "DrawBitmap(alien source)",
372 boost::bind(
373 (void (OutputDevice::*)( const Point&,
374 const Bitmap& ))(
375 &OutputDevice::DrawBitmap),
377 aPt1,aBitmapAlien ));
379 /* void DrawBitmap( const Point& rDestPt,
380 const Bitmap& rBitmap );
382 add(res,
383 "DrawBitmap",
384 boost::bind(
385 (void (OutputDevice::*)( const Point&,
386 const Bitmap& ))(
387 &OutputDevice::DrawBitmap),
389 aPt1,aBitmap ));
391 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
392 const Bitmap& rBitmap );
394 add(res,
395 "DrawBitmap(scaled,alien source)",
396 boost::bind(
397 (void (OutputDevice::*)( const Point&,
398 const Size&,
399 const Bitmap& ))(
400 &OutputDevice::DrawBitmap),
402 aPt1,aRect.GetSize(),aBitmapAlien ));
404 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
405 const Bitmap& rBitmap );
407 add(res,
408 "DrawBitmap(scaled)",
409 boost::bind(
410 (void (OutputDevice::*)( const Point&,
411 const Size&,
412 const Bitmap& ))(
413 &OutputDevice::DrawBitmap),
415 aPt1,aRect.GetSize(),aBitmap ));
417 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
418 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
419 const Bitmap& rBitmap );
421 add(res,
422 "DrawBitmap(scaled subset,alien source)",
423 boost::bind(
424 (void (OutputDevice::*)( const Point&,
425 const Size&,
426 const Point&,
427 const Size&,
428 const Bitmap& ))(
429 &OutputDevice::DrawBitmap),
431 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien ));
433 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
434 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
435 const Bitmap& rBitmap );
437 add(res,
438 "DrawBitmap(scaled subset)",
439 boost::bind(
440 (void (OutputDevice::*)( const Point&,
441 const Size&,
442 const Point&,
443 const Size&,
444 const Bitmap& ))(
445 &OutputDevice::DrawBitmap),
447 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap ));
449 /* void DrawBitmapEx( const Point& rDestPt,
450 const BitmapEx& rBitmapEx );
452 add(res,
453 "DrawBitmapEx(alien source)",
454 boost::bind(
455 (void (OutputDevice::*)( const Point&,
456 const BitmapEx& ))(
457 &OutputDevice::DrawBitmapEx),
459 aPt1,aBitmapExAlien ));
461 /* void DrawBitmapEx( const Point& rDestPt,
462 const BitmapEx& rBitmapEx );
464 add(res,
465 "DrawBitmapEx",
466 boost::bind(
467 (void (OutputDevice::*)( const Point&,
468 const BitmapEx& ))(
469 &OutputDevice::DrawBitmapEx),
471 aPt1,aBitmapEx ));
473 /* void DrawBitmapEx( const Point& rDestPt,
474 const BitmapEx& rBitmapEx );
476 add(res,
477 "DrawBitmapEx(alpha)",
478 boost::bind(
479 (void (OutputDevice::*)( const Point&,
480 const BitmapEx& ))(
481 &OutputDevice::DrawBitmapEx),
483 aPt1,aBitmapExAlpha ));
485 /* void DrawBitmapEx( const Point& rDestPt,
486 const BitmapEx& rBitmapEx );
488 add(res,
489 "DrawBitmapEx(alpha, alien source)",
490 boost::bind(
491 (void (OutputDevice::*)( const Point&,
492 const BitmapEx& ))(
493 &OutputDevice::DrawBitmapEx),
495 aPt1,aBitmapExAlphaAlien ));
497 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
498 const BitmapEx& rBitmapEx );
500 add(res,
501 "DrawBitmapEx(scaled,alien source)",
502 boost::bind(
503 (void (OutputDevice::*)( const Point&,
504 const Size&,
505 const BitmapEx& ))(
506 &OutputDevice::DrawBitmapEx),
508 aPt1,aRect.GetSize(),aBitmapExAlien ));
510 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
511 const BitmapEx& rBitmapEx );
513 add(res,
514 "DrawBitmapEx(scaled)",
515 boost::bind(
516 (void (OutputDevice::*)( const Point&,
517 const Size&,
518 const BitmapEx& ))(
519 &OutputDevice::DrawBitmapEx),
521 aPt1,aRect.GetSize(),aBitmapEx ));
523 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
524 const BitmapEx& rBitmapEx );
526 add(res,
527 "DrawBitmapEx(scaled alpha)",
528 boost::bind(
529 (void (OutputDevice::*)( const Point&,
530 const Size&,
531 const BitmapEx& ))(
532 &OutputDevice::DrawBitmapEx),
534 aPt1,aRect.GetSize(),aBitmapExAlpha ));
536 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
537 const BitmapEx& rBitmapEx );
539 add(res,
540 "DrawBitmapEx(scaled alpha, alien source)",
541 boost::bind(
542 (void (OutputDevice::*)( const Point&,
543 const Size&,
544 const BitmapEx& ))(
545 &OutputDevice::DrawBitmapEx),
547 aPt1,aRect.GetSize(),aBitmapExAlphaAlien ));
549 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
550 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
551 const BitmapEx& rBitmapEx );
553 add(res,
554 "DrawBitmapEx(scaled subset,alien source)",
555 boost::bind(
556 (void (OutputDevice::*)( const Point&,
557 const Size&,
558 const Point&,
559 const Size&,
560 const BitmapEx& ))(
561 &OutputDevice::DrawBitmapEx),
563 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlien ));
565 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
566 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
567 const BitmapEx& rBitmapEx );
569 add(res,
570 "DrawBitmapEx(scaled subset)",
571 boost::bind(
572 (void (OutputDevice::*)( const Point&,
573 const Size&,
574 const Point&,
575 const Size&,
576 const BitmapEx& ))(
577 &OutputDevice::DrawBitmapEx),
579 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapEx ));
581 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
582 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
583 const BitmapEx& rBitmapEx );
585 add(res,
586 "DrawBitmapEx(scaled subset, alpha)",
587 boost::bind(
588 (void (OutputDevice::*)( const Point&,
589 const Size&,
590 const Point&,
591 const Size&,
592 const BitmapEx& ))(
593 &OutputDevice::DrawBitmapEx),
595 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlpha ));
597 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
598 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
599 const BitmapEx& rBitmapEx );
601 add(res,
602 "DrawBitmapEx(scaled subset, alpha alien source)",
603 boost::bind(
604 (void (OutputDevice::*)( const Point&,
605 const Size&,
606 const Point&,
607 const Size&,
608 const BitmapEx& ))(
609 &OutputDevice::DrawBitmapEx),
611 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlphaAlien ));
613 /* void DrawMask( const Point& rDestPt,
614 const Bitmap& rBitmap, const Color& rMaskColor );
616 add(res,
617 "DrawMask(alien source)",
618 boost::bind(
619 (void (OutputDevice::*)( const Point&,
620 const Bitmap&,
621 const Color& ))(
622 &OutputDevice::DrawMask),
624 aPt1,aBitmapAlien,aBlackColor ));
626 /* void DrawMask( const Point& rDestPt,
627 const Bitmap& rBitmap, const Color& rMaskColor );
629 add(res,
630 "DrawMask",
631 boost::bind(
632 (void (OutputDevice::*)( const Point&,
633 const Bitmap&,
634 const Color& ))(
635 &OutputDevice::DrawMask),
637 aPt1,aBitmap,aBlackColor ));
639 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
640 const Bitmap& rBitmap, const Color& rMaskColor );
642 add(res,
643 "DrawMask(scaled,alien source)",
644 boost::bind(
645 (void (OutputDevice::*)( const Point&,
646 const Size&,
647 const Bitmap&,
648 const Color& ))(
649 &OutputDevice::DrawMask),
651 aPt1,aRect.GetSize(),aBitmapAlien, aBlackColor ));
653 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
654 const Bitmap& rBitmap, const Color& rMaskColor );
656 add(res,
657 "DrawMask(scaled)",
658 boost::bind(
659 (void (OutputDevice::*)( const Point&,
660 const Size&,
661 const Bitmap&,
662 const Color& ))(
663 &OutputDevice::DrawMask),
665 aPt1,aRect.GetSize(),aBitmap,aBlackColor ));
667 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
668 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
669 const Bitmap& rBitmap, const Color& rMaskColor );
671 add(res,
672 "DrawMask(scaled subset,alien source)",
673 boost::bind(
674 (void (OutputDevice::*)( const Point&,
675 const Size&,
676 const Point&,
677 const Size&,
678 const Bitmap&,
679 const Color& ))(
680 &OutputDevice::DrawMask),
682 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien,aBlackColor ));
684 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
685 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
686 const Bitmap& rBitmap, const Color& rMaskColor );
688 add(res,
689 "DrawMask(scaled subset)",
690 boost::bind(
691 (void (OutputDevice::*)( const Point&,
692 const Size&,
693 const Point&,
694 const Size&,
695 const Bitmap&,
696 const Color& ))(
697 &OutputDevice::DrawMask),
699 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap,aBlackColor ));
701 /* void DrawImage( const Point& rPos,
702 const Image& rImage, USHORT nStyle = 0 );
704 add(res,
705 "DrawImage",
706 boost::bind(
707 (void (OutputDevice::*)( const Point&,
708 const Image&,
709 USHORT nStyle ))(
710 &OutputDevice::DrawImage),
712 aPt1,aImage,(USHORT)0 ));
714 /* void DrawImage( const Point& rPos, const Size& rSize,
715 const Image& rImage, USHORT nStyle = 0 );
717 add(res,
718 "DrawImage(scaled)",
719 boost::bind(
720 (void (OutputDevice::*)( const Point&,
721 const Size&,
722 const Image&,
723 USHORT nStyle ))(
724 &OutputDevice::DrawImage),
726 aPt1,aRect.GetSize(),aImage,(USHORT)0 ));
728 /* void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); */
729 add(res,
730 "DrawGradient",
731 boost::bind(
732 (void (OutputDevice::*)( const Rectangle&, const Gradient& ))(
733 &OutputDevice::DrawGradient),
735 aRect,aGradient ));
737 /* void DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); */
738 add(res,
739 "DrawGradient(polygon)",
740 boost::bind(
741 (void (OutputDevice::*)( const PolyPolygon&, const Gradient& ))(
742 &OutputDevice::DrawGradient),
744 aPoly3,aGradient ));
746 /* void DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); */
747 add(res,
748 "DrawHatch",
749 boost::bind(
750 &OutputDevice::DrawHatch,
752 aPoly3,aHatch ));
754 /* void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); */
755 add(res,
756 "DrawWallpaper",
757 boost::bind(
758 &OutputDevice::DrawWallpaper,
760 aRect2,aWallpaper ));
762 /* void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, USHORT nStyle ); */
763 add(res,
764 "DrawWaveLine",
765 boost::bind(
766 &OutputDevice::DrawWaveLine,
768 aPt1,aPt2,(USHORT)WAVE_NORMAL ));
770 /* void DrawGrid( const Rectangle& rRect, const Size& rDist, ULONG nFlags ); */
771 add(res,
772 "DrawGrid",
773 boost::bind(
774 &OutputDevice::DrawGrid,
776 aRect,Size(10,20),GRID_HORZLINES|GRID_VERTLINES ));
778 /* void DrawTransparent( const PolyPolygon& rPolyPoly,
779 USHORT nTransparencePercent );
781 add(res,
782 "DrawTransparent",
783 boost::bind(
784 (void (OutputDevice::*)( const PolyPolygon&, USHORT ))(
785 &OutputDevice::DrawTransparent),
787 aPoly3,(USHORT)50 ));
789 /* void DrawTransparent( const GDIMetaFile& rMtf,
790 const Point& rPos, const Size& rSize,
791 const Gradient& rTransparenceGradient );
793 add(res,
794 "DrawTransparent(metafile)",
795 boost::bind(
796 (void (OutputDevice::*)( const GDIMetaFile&,
797 const Point&,
798 const Size&,
799 const Gradient& ))(
800 &OutputDevice::DrawTransparent),
802 aMtf,aPt1,aRect.GetSize(),aGradient ));
804 /* void Erase(); */
805 add(res,
806 "Erase",
807 boost::bind(
808 &OutputDevice::Erase,
809 _1 ));
813 //----------------------------------------------------------------------------------
815 void grindFunc( OutputDevice& rTarget,
816 functor_vector_type::const_iterator iter,
817 sal_Int32 nTurns,
818 const char* pMsg )
820 const sal_uInt32 nStartTime( osl_getGlobalTimer() );
822 for( sal_Int32 i=0; i<nTurns; ++i )
823 iter->second(&rTarget);
825 if( rTarget.GetOutDevType() == OUTDEV_WINDOW )
826 static_cast<Window&>(rTarget).Sync();
828 fprintf( stdout,
829 "Duration: %d ms (%d repetitions)\tOperation: %s\tSetup: %s\n",
830 (int)(osl_getGlobalTimer() - nStartTime),
831 (int)(nTurns),
832 iter->first,
833 pMsg );
836 //----------------------------------------------------------------------------------
838 /** Call OutputDevice render methods repeatedly, and output elapsed
839 time to stdout
841 void outDevGrind( OutputDevice& rTarget, sal_Int32 nTurns=100 )
843 // TODO(F1): also profile pure complex clip setup times!
845 // State: fill/line color, draw mode, w/o clip, rect clip, complex clip
846 functor_vector_type aMethods;
847 setupMethodStubs( aMethods );
849 const Rectangle aClipRect(10,10,1000,1000);
850 const Polygon aPoly1( aClipRect );
851 Polygon aPoly2( aClipRect );
852 aPoly2.Rotate(aClipRect.Center(),450);
853 PolyPolygon aClipPoly(aPoly1);
854 aClipPoly.Insert(aPoly2);
856 functor_vector_type::const_iterator iter = aMethods.begin();
857 const functor_vector_type::const_iterator end = aMethods.end();
858 while( iter != end )
860 rTarget.SetLineColor( Color(COL_BLACK) );
861 rTarget.SetFillColor( Color(COL_GREEN) );
862 rTarget.SetRasterOp( ROP_OVERPAINT );
863 rTarget.SetClipRegion();
864 grindFunc( rTarget, iter, nTurns, "w/o clip, w/o xor" );
866 rTarget.SetLineColor( Color(COL_BLACK) );
867 rTarget.SetFillColor( Color(COL_GREEN) );
868 rTarget.SetRasterOp( ROP_OVERPAINT );
869 rTarget.SetClipRegion( aClipRect );
870 grindFunc( rTarget, iter, nTurns, "with rect clip, w/o xor" );
872 rTarget.SetLineColor( Color(COL_BLACK) );
873 rTarget.SetFillColor( Color(COL_GREEN) );
874 rTarget.SetRasterOp( ROP_OVERPAINT );
875 rTarget.SetClipRegion( aClipPoly );
876 grindFunc( rTarget, iter, nTurns, "with complex clip, w/o xor" );
878 rTarget.SetLineColor( Color(COL_BLACK) );
879 rTarget.SetFillColor( Color(COL_GREEN) );
880 rTarget.SetRasterOp( ROP_XOR );
881 rTarget.SetClipRegion();
882 grindFunc( rTarget, iter, nTurns, "w/o clip, with xor" );
884 rTarget.SetLineColor( Color(COL_BLACK) );
885 rTarget.SetFillColor( Color(COL_GREEN) );
886 rTarget.SetRasterOp( ROP_XOR );
887 rTarget.SetClipRegion( aClipRect );
888 grindFunc( rTarget, iter, nTurns, "with rect clip, with xor" );
890 rTarget.SetLineColor( Color(COL_BLACK) );
891 rTarget.SetFillColor( Color(COL_GREEN) );
892 rTarget.SetRasterOp( ROP_XOR );
893 rTarget.SetClipRegion( aClipPoly );
894 grindFunc( rTarget, iter, nTurns, "with complex clip, with xor" );
896 ++iter;
900 //----------------------------------------------------------------------------------
902 void TestWindow::Paint( const Rectangle& )
904 outDevGrind( *this );
905 fflush( stdout );
908 USHORT GrindApp::Exception( USHORT nError )
910 switch( nError & EXC_MAJORTYPE )
912 case EXC_RSCNOTLOADED:
913 Abort( String::CreateFromAscii(
914 "Error: could not load language resources.\nPlease check your installation.\n" ) );
915 break;
917 return 0;
920 void GrindApp::Main()
922 bool bHelp = false;
924 for( USHORT i = 0; i < GetCommandLineParamCount(); i++ )
926 ::rtl::OUString aParam = GetCommandLineParam( i );
928 if( aParam.equalsAscii( "--help" ) ||
929 aParam.equalsAscii( "-h" ) )
930 bHelp = true;
933 if( bHelp )
935 printf( "outdevgrind - Profile OutputDevice\n" );
936 return;
939 //-------------------------------------------------
940 // create the global service-manager
941 //-------------------------------------------------
942 uno::Reference< lang::XMultiServiceFactory > xFactory;
945 uno::Reference< uno::XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext();
946 xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(),
947 uno::UNO_QUERY );
948 if( xFactory.is() )
949 ::comphelper::setProcessServiceFactory( xFactory );
951 catch( uno::Exception& )
955 if( !xFactory.is() )
957 fprintf( stderr,
958 "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
959 exit( 1 );
962 // Create UCB.
963 uno::Sequence< uno::Any > aArgs( 2 );
964 aArgs[ 0 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY1_LOCAL );
965 aArgs[ 1 ] <<= rtl::OUString::createFromAscii( UCB_CONFIGURATION_KEY2_OFFICE );
966 ::ucbhelper::ContentBroker::initialize( xFactory, aArgs );
968 TestWindow pWindow;
969 pWindow.Execute();
971 // clean up UCB
972 ::ucbhelper::ContentBroker::deinitialize();
975 } // namespace
977 GrindApp aGrindApp;