fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / vcl / workben / outdevgrind.cxx
blob261643dedfbcec8e9797633639ea5f05735a4ef6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 // bootstrap stuff
22 #include <rtl/bootstrap.hxx>
23 #include <comphelper/processfactory.hxx>
24 #include <cppuhelper/servicefactory.hxx>
25 #include <cppuhelper/bootstrap.hxx>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/registry/XSimpleRegistry.hpp>
30 #include <vcl/svapp.hxx>
31 #include <vcl/dialog.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/virdev.hxx>
34 #include <vcl/hatch.hxx>
35 #include <vcl/bitmap.hxx>
36 #include <vcl/wall.hxx>
37 #include <vcl/image.hxx>
38 #include <vcl/gdimtf.hxx>
39 #include <vcl/metaact.hxx>
40 #include <vcl/bitmapex.hxx>
41 #include <vcl/gradient.hxx>
42 #include <vcl/lineinfo.hxx>
43 #include <tools/string.hxx>
45 #include <osl/time.h>
47 #include <boost/function.hpp>
48 #include <boost/bind.hpp>
50 #include <stdio.h>
51 #include <unistd.h>
53 using namespace ::com::sun::star;
56 namespace
59 class GrindApp : public Application
61 public:
62 virtual int Main();
63 virtual sal_uInt16 Exception( sal_uInt16 nError );
66 class TestWindow : public Dialog
68 public:
69 TestWindow() : Dialog( (Window *) NULL )
71 SetText( OUString("OutDev grinding") );
72 SetSizePixel( Size( 1024, 1024 ) );
73 EnablePaint( true );
74 Show();
77 virtual ~TestWindow() {}
78 virtual void Paint( const Rectangle& rRect );
81 typedef boost::function1<void, OutputDevice*> functor_type;
82 typedef std::vector< std::pair<const char*,
83 functor_type> > functor_vector_type;
85 template< typename Functor > void add( functor_vector_type& res,
86 const char* pStr,
87 const Functor& func )
89 res.push_back( std::make_pair(pStr,functor_type(func)) );
92 void setupMethodStubs( functor_vector_type& res )
94 const Color aWhiteColor( COL_WHITE );
95 const Color aBlackColor( COL_BLACK );
97 const Point aPt1(10,10);
98 const Point aPt2(500,500);
99 const Point aPt3(0,0);
100 const Point aPt4(450,450);
102 const Rectangle aRect(aPt1,aPt2);
103 const Rectangle aRect2(aPt3,aPt4);
104 const Polygon aPoly(aRect);
105 const Polygon aPoly2(aRect2);
106 PolyPolygon aPolyPoly(aPoly);
107 aPolyPoly.Insert( aPoly2 );
108 Polygon aPoly3(aPoly2);
109 aPoly3.Rotate( aPoly3.GetBoundRect().Center(),
110 900 );
112 const String aString("This is a test");
113 const LineInfo aLineInfo(LINE_SOLID,5);
115 // unfortunately, VDevs have inaccessible copy constructors
116 static VirtualDevice aVDev;
117 static VirtualDevice aVDevBW(1);
119 const Size aVDevSize;
120 aVDev.SetOutputSizePixel(aVDevSize);
121 aVDevBW.SetOutputSizePixel(aVDevSize);
123 const Bitmap aBitmap( aVDev.GetBitmap(aPt1,aVDevSize) );
124 const Bitmap aBitmapBW( aVDevBW.GetBitmap(aPt1,aVDevSize) );
125 const Bitmap aBitmapAlien( aVDevSize, 8 );
127 const BitmapEx aBitmapEx( aBitmap, aBitmapBW );
128 const BitmapEx aBitmapExBW( aBitmapBW, aBitmapBW );
129 const BitmapEx aBitmapExAlien( aBitmapAlien, aBitmapBW );
130 const BitmapEx aBitmapExAlpha( aBitmap, aBitmapAlien );
131 const BitmapEx aBitmapExAlphaAlien( aBitmapAlien, aBitmapAlien );
133 const Image aImage( aBitmapEx );
134 const Gradient aGradient(GradientStyle_ELLIPTICAL,aBlackColor,aWhiteColor);
135 const Hatch aHatch(HatchStyle_TRIPLE,aBlackColor,4,450);
136 const Wallpaper aWallpaper( aWhiteColor );
138 GDIMetaFile aMtf;
139 aMtf.AddAction( new MetaFillColorAction(Color(COL_RED),sal_True) );
140 aMtf.AddAction( new MetaRectAction(aRect) );
142 /* void DrawTextArray( const Point& rStartPt, const XubString& rStr,
143 const sal_Int32* pDXAry = NULL,
144 xub_StrLen nIndex = 0,
145 xub_StrLen nLen = STRING_LEN );
147 add(res,
148 "DrawTextArray",
149 boost::bind(
150 &OutputDevice::DrawTextArray,
152 aPt1, aString, (const sal_Int32*)0, (sal_uInt16)0, aString.Len() ));
154 /* void DrawPixel( const Point& rPt, const Color& rColor ); */
155 add(res,
156 "DrawPixel",
157 boost::bind(
158 (void (OutputDevice::*)( const Point&, const Color& ))(
159 &OutputDevice::DrawPixel),
161 aPt1, aBlackColor ));
163 /* void DrawLine( const Point& rStartPt, const Point& rEndPt ); */
164 add(res,
165 "DrawLine",
166 boost::bind(
167 (void (OutputDevice::*)( const Point&, const Point& ))(
168 &OutputDevice::DrawLine),
170 aPt1, aPt2 ));
172 /* void DrawLine( const Point& rStartPt, const Point& rEndPt,
173 const LineInfo& rLineInfo );
175 add(res,
176 "DrawLine(LineInfo)",
177 boost::bind(
178 (void (OutputDevice::*)( const Point&, const Point&,const LineInfo& ))(
179 &OutputDevice::DrawLine),
181 aPt1, aPt2, aLineInfo ));
183 /* void DrawPolyLine( const Polygon& rPoly ); */
184 add(res,
185 "DrawPolyLine",
186 boost::bind(
187 (void (OutputDevice::*)( const Polygon& ))(
188 &OutputDevice::DrawPolyLine),
190 aPoly ));
192 /* void DrawPolyLine( const Polygon& rPoly,
193 const LineInfo& rLineInfo );
195 add(res,
196 "DrawPolyLine(LineInfo)",
197 boost::bind(
198 (void (OutputDevice::*)( const Polygon&, const LineInfo& ))(
199 &OutputDevice::DrawPolyLine),
201 aPoly, aLineInfo ));
203 /* void DrawPolygon( const Polygon& rPoly ); */
204 add(res,
205 "DrawPolygon",
206 boost::bind(
207 (void (OutputDevice::*)( const Polygon& ))
208 &OutputDevice::DrawPolygon,
210 aPoly ));
212 /* void DrawPolyPolygon( const PolyPolygon& rPolyPoly ); */
213 add(res,
214 "DrawPolyPolygon",
215 boost::bind(
216 (void (OutputDevice::*)( const PolyPolygon& ))
217 &OutputDevice::DrawPolyPolygon,
219 aPolyPoly ));
221 /* void DrawRect( const Rectangle& rRect ); */
222 add(res,
223 "DrawRect",
224 boost::bind(
225 (void (OutputDevice::*)( const Rectangle& ))(
226 &OutputDevice::DrawRect),
228 aRect ));
230 /* void DrawRect( const Rectangle& rRect,
231 sal_uLong nHorzRount, sal_uLong nVertRound );
233 add(res,
234 "DrawRect(round corners)",
235 boost::bind(
236 (void (OutputDevice::*)( const Rectangle&, sal_uLong nHorzRount, sal_uLong nVertRound ))(
237 &OutputDevice::DrawRect),
239 aRect2,
240 4,4));
242 /* void DrawEllipse( const Rectangle& rRect ); */
243 add(res,
244 "DrawEllipse",
245 boost::bind(
246 &OutputDevice::DrawEllipse,
248 aRect ));
250 /* void DrawArc( const Rectangle& rRect,
251 const Point& rStartPt, const Point& rEndPt );
253 add(res,
254 "DrawArc",
255 boost::bind(
256 &OutputDevice::DrawArc,
258 aRect,aPt1,aPt2 ));
260 /* void DrawPie( const Rectangle& rRect,
261 const Point& rStartPt, const Point& rEndPt );
263 add(res,
264 "DrawPie",
265 boost::bind(
266 &OutputDevice::DrawPie,
268 aRect2,aPt3,aPt4 ));
270 /* void DrawChord( const Rectangle& rRect,
271 const Point& rStartPt, const Point& rEndPt );
273 add(res,
274 "DrawChord",
275 boost::bind(
276 &OutputDevice::DrawChord,
278 aRect2,aPt3,aPt4 ));
280 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
281 const Point& rSrcPt, const Size& rSrcSize );
283 add(res,
284 "DrawOutDev",
285 boost::bind(
286 (void (OutputDevice::*)( const Point&, const Size&,
287 const Point&, const Size& ))(
288 &OutputDevice::DrawOutDev),
290 aRect2.TopLeft(), aRect2.GetSize(),
291 aRect.TopLeft(), aRect.GetSize()));
293 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
294 const Point& rSrcPt, const Size& rSrcSize,
295 const OutputDevice& rOutDev );
297 add(res,
298 "DrawOutDev(foreign source)",
299 boost::bind(
300 (void (OutputDevice::*)( const Point&, const Size&,
301 const Point&, const Size&,
302 const OutputDevice& ))(
303 &OutputDevice::DrawOutDev),
305 aRect2.TopLeft(), aRect2.GetSize(),
306 aRect.TopLeft(), aRect.GetSize(),
307 boost::cref(aVDevBW) ));
309 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
310 const Point& rSrcPt, const Size& rSrcSize,
311 const OutputDevice& rOutDev );
313 add(res,
314 "DrawOutDev(foreign source, scaled)",
315 boost::bind(
316 (void (OutputDevice::*)( const Point&, const Size&,
317 const Point&, const Size&,
318 const OutputDevice& ))(
319 &OutputDevice::DrawOutDev),
321 aRect2.TopLeft(), aRect2.GetSize(),
322 aRect.TopLeft(), aRect.GetSize(),
323 boost::cref(aVDev) ));
325 /* void CopyArea( const Point& rDestPt,
326 const Point& rSrcPt, const Size& rSrcSize,
327 sal_uInt16 nFlags = 0 );
329 add(res,
330 "CopyArea",
331 boost::bind(
332 &OutputDevice::CopyArea,
334 aPt1,aPt3,aRect2.GetSize(),(sal_uInt16)0 ));
336 /* void DrawBitmap( const Point& rDestPt,
337 const Bitmap& rBitmap );
339 add(res,
340 "DrawBitmap(alien source)",
341 boost::bind(
342 (void (OutputDevice::*)( const Point&,
343 const Bitmap& ))(
344 &OutputDevice::DrawBitmap),
346 aPt1,aBitmapAlien ));
348 /* void DrawBitmap( const Point& rDestPt,
349 const Bitmap& rBitmap );
351 add(res,
352 "DrawBitmap",
353 boost::bind(
354 (void (OutputDevice::*)( const Point&,
355 const Bitmap& ))(
356 &OutputDevice::DrawBitmap),
358 aPt1,aBitmap ));
360 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
361 const Bitmap& rBitmap );
363 add(res,
364 "DrawBitmap(scaled,alien source)",
365 boost::bind(
366 (void (OutputDevice::*)( const Point&,
367 const Size&,
368 const Bitmap& ))(
369 &OutputDevice::DrawBitmap),
371 aPt1,aRect.GetSize(),aBitmapAlien ));
373 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
374 const Bitmap& rBitmap );
376 add(res,
377 "DrawBitmap(scaled)",
378 boost::bind(
379 (void (OutputDevice::*)( const Point&,
380 const Size&,
381 const Bitmap& ))(
382 &OutputDevice::DrawBitmap),
384 aPt1,aRect.GetSize(),aBitmap ));
386 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
387 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
388 const Bitmap& rBitmap );
390 add(res,
391 "DrawBitmap(scaled subset,alien source)",
392 boost::bind(
393 (void (OutputDevice::*)( const Point&,
394 const Size&,
395 const Point&,
396 const Size&,
397 const Bitmap& ))(
398 &OutputDevice::DrawBitmap),
400 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien ));
402 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
403 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
404 const Bitmap& rBitmap );
406 add(res,
407 "DrawBitmap(scaled subset)",
408 boost::bind(
409 (void (OutputDevice::*)( const Point&,
410 const Size&,
411 const Point&,
412 const Size&,
413 const Bitmap& ))(
414 &OutputDevice::DrawBitmap),
416 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap ));
418 /* void DrawBitmapEx( const Point& rDestPt,
419 const BitmapEx& rBitmapEx );
421 add(res,
422 "DrawBitmapEx(alien source)",
423 boost::bind(
424 (void (OutputDevice::*)( const Point&,
425 const BitmapEx& ))(
426 &OutputDevice::DrawBitmapEx),
428 aPt1,aBitmapExAlien ));
430 /* void DrawBitmapEx( const Point& rDestPt,
431 const BitmapEx& rBitmapEx );
433 add(res,
434 "DrawBitmapEx",
435 boost::bind(
436 (void (OutputDevice::*)( const Point&,
437 const BitmapEx& ))(
438 &OutputDevice::DrawBitmapEx),
440 aPt1,aBitmapEx ));
442 /* void DrawBitmapEx( const Point& rDestPt,
443 const BitmapEx& rBitmapEx );
445 add(res,
446 "DrawBitmapEx(alpha)",
447 boost::bind(
448 (void (OutputDevice::*)( const Point&,
449 const BitmapEx& ))(
450 &OutputDevice::DrawBitmapEx),
452 aPt1,aBitmapExAlpha ));
454 /* void DrawBitmapEx( const Point& rDestPt,
455 const BitmapEx& rBitmapEx );
457 add(res,
458 "DrawBitmapEx(alpha, alien source)",
459 boost::bind(
460 (void (OutputDevice::*)( const Point&,
461 const BitmapEx& ))(
462 &OutputDevice::DrawBitmapEx),
464 aPt1,aBitmapExAlphaAlien ));
466 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
467 const BitmapEx& rBitmapEx );
469 add(res,
470 "DrawBitmapEx(scaled,alien source)",
471 boost::bind(
472 (void (OutputDevice::*)( const Point&,
473 const Size&,
474 const BitmapEx& ))(
475 &OutputDevice::DrawBitmapEx),
477 aPt1,aRect.GetSize(),aBitmapExAlien ));
479 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
480 const BitmapEx& rBitmapEx );
482 add(res,
483 "DrawBitmapEx(scaled)",
484 boost::bind(
485 (void (OutputDevice::*)( const Point&,
486 const Size&,
487 const BitmapEx& ))(
488 &OutputDevice::DrawBitmapEx),
490 aPt1,aRect.GetSize(),aBitmapEx ));
492 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
493 const BitmapEx& rBitmapEx );
495 add(res,
496 "DrawBitmapEx(scaled alpha)",
497 boost::bind(
498 (void (OutputDevice::*)( const Point&,
499 const Size&,
500 const BitmapEx& ))(
501 &OutputDevice::DrawBitmapEx),
503 aPt1,aRect.GetSize(),aBitmapExAlpha ));
505 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
506 const BitmapEx& rBitmapEx );
508 add(res,
509 "DrawBitmapEx(scaled alpha, alien source)",
510 boost::bind(
511 (void (OutputDevice::*)( const Point&,
512 const Size&,
513 const BitmapEx& ))(
514 &OutputDevice::DrawBitmapEx),
516 aPt1,aRect.GetSize(),aBitmapExAlphaAlien ));
518 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
519 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
520 const BitmapEx& rBitmapEx );
522 add(res,
523 "DrawBitmapEx(scaled subset,alien source)",
524 boost::bind(
525 (void (OutputDevice::*)( const Point&,
526 const Size&,
527 const Point&,
528 const Size&,
529 const BitmapEx& ))(
530 &OutputDevice::DrawBitmapEx),
532 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlien ));
534 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
535 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
536 const BitmapEx& rBitmapEx );
538 add(res,
539 "DrawBitmapEx(scaled subset)",
540 boost::bind(
541 (void (OutputDevice::*)( const Point&,
542 const Size&,
543 const Point&,
544 const Size&,
545 const BitmapEx& ))(
546 &OutputDevice::DrawBitmapEx),
548 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapEx ));
550 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
551 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
552 const BitmapEx& rBitmapEx );
554 add(res,
555 "DrawBitmapEx(scaled subset, alpha)",
556 boost::bind(
557 (void (OutputDevice::*)( const Point&,
558 const Size&,
559 const Point&,
560 const Size&,
561 const BitmapEx& ))(
562 &OutputDevice::DrawBitmapEx),
564 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlpha ));
566 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
567 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
568 const BitmapEx& rBitmapEx );
570 add(res,
571 "DrawBitmapEx(scaled subset, alpha alien source)",
572 boost::bind(
573 (void (OutputDevice::*)( const Point&,
574 const Size&,
575 const Point&,
576 const Size&,
577 const BitmapEx& ))(
578 &OutputDevice::DrawBitmapEx),
580 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlphaAlien ));
582 /* void DrawMask( const Point& rDestPt,
583 const Bitmap& rBitmap, const Color& rMaskColor );
585 add(res,
586 "DrawMask(alien source)",
587 boost::bind(
588 (void (OutputDevice::*)( const Point&,
589 const Bitmap&,
590 const Color& ))(
591 &OutputDevice::DrawMask),
593 aPt1,aBitmapAlien,aBlackColor ));
595 /* void DrawMask( const Point& rDestPt,
596 const Bitmap& rBitmap, const Color& rMaskColor );
598 add(res,
599 "DrawMask",
600 boost::bind(
601 (void (OutputDevice::*)( const Point&,
602 const Bitmap&,
603 const Color& ))(
604 &OutputDevice::DrawMask),
606 aPt1,aBitmap,aBlackColor ));
608 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
609 const Bitmap& rBitmap, const Color& rMaskColor );
611 add(res,
612 "DrawMask(scaled,alien source)",
613 boost::bind(
614 (void (OutputDevice::*)( const Point&,
615 const Size&,
616 const Bitmap&,
617 const Color& ))(
618 &OutputDevice::DrawMask),
620 aPt1,aRect.GetSize(),aBitmapAlien, aBlackColor ));
622 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
623 const Bitmap& rBitmap, const Color& rMaskColor );
625 add(res,
626 "DrawMask(scaled)",
627 boost::bind(
628 (void (OutputDevice::*)( const Point&,
629 const Size&,
630 const Bitmap&,
631 const Color& ))(
632 &OutputDevice::DrawMask),
634 aPt1,aRect.GetSize(),aBitmap,aBlackColor ));
636 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
637 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
638 const Bitmap& rBitmap, const Color& rMaskColor );
640 add(res,
641 "DrawMask(scaled subset,alien source)",
642 boost::bind(
643 (void (OutputDevice::*)( const Point&,
644 const Size&,
645 const Point&,
646 const Size&,
647 const Bitmap&,
648 const Color& ))(
649 &OutputDevice::DrawMask),
651 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien,aBlackColor ));
653 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
654 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
655 const Bitmap& rBitmap, const Color& rMaskColor );
657 add(res,
658 "DrawMask(scaled subset)",
659 boost::bind(
660 (void (OutputDevice::*)( const Point&,
661 const Size&,
662 const Point&,
663 const Size&,
664 const Bitmap&,
665 const Color& ))(
666 &OutputDevice::DrawMask),
668 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap,aBlackColor ));
670 /* void DrawImage( const Point& rPos,
671 const Image& rImage, sal_uInt16 nStyle = 0 );
673 add(res,
674 "DrawImage",
675 boost::bind(
676 (void (OutputDevice::*)( const Point&,
677 const Image&,
678 sal_uInt16 nStyle ))(
679 &OutputDevice::DrawImage),
681 aPt1,aImage,(sal_uInt16)0 ));
683 /* void DrawImage( const Point& rPos, const Size& rSize,
684 const Image& rImage, sal_uInt16 nStyle = 0 );
686 add(res,
687 "DrawImage(scaled)",
688 boost::bind(
689 (void (OutputDevice::*)( const Point&,
690 const Size&,
691 const Image&,
692 sal_uInt16 nStyle ))(
693 &OutputDevice::DrawImage),
695 aPt1,aRect.GetSize(),aImage,(sal_uInt16)0 ));
697 /* void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); */
698 add(res,
699 "DrawGradient",
700 boost::bind(
701 (void (OutputDevice::*)( const Rectangle&, const Gradient& ))(
702 &OutputDevice::DrawGradient),
704 aRect,aGradient ));
706 /* void DrawGradient( const PolyPolygon& rPolyPoly, const Gradient& rGradient ); */
707 add(res,
708 "DrawGradient(polygon)",
709 boost::bind(
710 (void (OutputDevice::*)( const PolyPolygon&, const Gradient& ))(
711 &OutputDevice::DrawGradient),
713 aPoly3,aGradient ));
715 /* void DrawHatch( const PolyPolygon& rPolyPoly, const Hatch& rHatch ); */
716 add(res,
717 "DrawHatch",
718 boost::bind(
719 &OutputDevice::DrawHatch,
721 aPoly3,aHatch ));
723 /* void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); */
724 add(res,
725 "DrawWallpaper",
726 boost::bind(
727 &OutputDevice::DrawWallpaper,
729 aRect2,aWallpaper ));
731 /* void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, sal_uInt16 nStyle ); */
732 add(res,
733 "DrawWaveLine",
734 boost::bind(
735 &OutputDevice::DrawWaveLine,
737 aPt1,aPt2,(sal_uInt16)WAVE_NORMAL ));
739 /* void DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags ); */
740 add(res,
741 "DrawGrid",
742 boost::bind(
743 &OutputDevice::DrawGrid,
745 aRect,Size(10,20),GRID_HORZLINES|GRID_VERTLINES ));
747 /* void DrawTransparent( const PolyPolygon& rPolyPoly,
748 sal_uInt16 nTransparencePercent );
750 add(res,
751 "DrawTransparent",
752 boost::bind(
753 (void (OutputDevice::*)( const PolyPolygon&, sal_uInt16 ))(
754 &OutputDevice::DrawTransparent),
756 aPoly3,(sal_uInt16)50 ));
758 /* void DrawTransparent( const GDIMetaFile& rMtf,
759 const Point& rPos, const Size& rSize,
760 const Gradient& rTransparenceGradient );
762 add(res,
763 "DrawTransparent(metafile)",
764 boost::bind(
765 (void (OutputDevice::*)( const GDIMetaFile&,
766 const Point&,
767 const Size&,
768 const Gradient& ))(
769 &OutputDevice::DrawTransparent),
771 aMtf,aPt1,aRect.GetSize(),aGradient ));
773 /* void Erase(); */
774 add(res,
775 "Erase",
776 boost::bind(
777 &OutputDevice::Erase,
778 _1 ));
783 void grindFunc( OutputDevice& rTarget,
784 functor_vector_type::const_iterator iter,
785 sal_Int32 nTurns,
786 const char* pMsg )
788 const sal_uInt32 nStartTime( osl_getGlobalTimer() );
790 for( sal_Int32 i=0; i<nTurns; ++i )
791 iter->second(&rTarget);
793 if( rTarget.GetOutDevType() == OUTDEV_WINDOW )
794 static_cast<Window&>(rTarget).Sync();
796 fprintf( stdout,
797 "Duration: %d ms (%d repetitions)\tOperation: %s\tSetup: %s\n",
798 (int)(osl_getGlobalTimer() - nStartTime),
799 (int)(nTurns),
800 iter->first,
801 pMsg );
805 /** Call OutputDevice render methods repeatedly, and output elapsed
806 time to stdout
808 void outDevGrind( OutputDevice& rTarget, sal_Int32 nTurns=100 )
810 // TODO(F1): also profile pure complex clip setup times!
812 // State: fill/line color, draw mode, w/o clip, rect clip, complex clip
813 functor_vector_type aMethods;
814 setupMethodStubs( aMethods );
816 const Rectangle aClipRect(10,10,1000,1000);
817 const Polygon aPoly1( aClipRect );
818 Polygon aPoly2( aClipRect );
819 aPoly2.Rotate(aClipRect.Center(),450);
820 PolyPolygon aClipPoly(aPoly1);
821 aClipPoly.Insert(aPoly2);
823 functor_vector_type::const_iterator iter = aMethods.begin();
824 const functor_vector_type::const_iterator end = aMethods.end();
825 while( iter != end )
827 rTarget.SetLineColor( Color(COL_BLACK) );
828 rTarget.SetFillColor( Color(COL_GREEN) );
829 rTarget.SetRasterOp( ROP_OVERPAINT );
830 rTarget.SetClipRegion();
831 grindFunc( rTarget, iter, nTurns, "w/o clip, w/o xor" );
833 rTarget.SetLineColor( Color(COL_BLACK) );
834 rTarget.SetFillColor( Color(COL_GREEN) );
835 rTarget.SetRasterOp( ROP_OVERPAINT );
836 rTarget.SetClipRegion( aClipRect );
837 grindFunc( rTarget, iter, nTurns, "with rect clip, w/o xor" );
839 rTarget.SetLineColor( Color(COL_BLACK) );
840 rTarget.SetFillColor( Color(COL_GREEN) );
841 rTarget.SetRasterOp( ROP_OVERPAINT );
842 rTarget.SetClipRegion( aClipPoly );
843 grindFunc( rTarget, iter, nTurns, "with complex clip, w/o xor" );
845 rTarget.SetLineColor( Color(COL_BLACK) );
846 rTarget.SetFillColor( Color(COL_GREEN) );
847 rTarget.SetRasterOp( ROP_XOR );
848 rTarget.SetClipRegion();
849 grindFunc( rTarget, iter, nTurns, "w/o clip, with xor" );
851 rTarget.SetLineColor( Color(COL_BLACK) );
852 rTarget.SetFillColor( Color(COL_GREEN) );
853 rTarget.SetRasterOp( ROP_XOR );
854 rTarget.SetClipRegion( aClipRect );
855 grindFunc( rTarget, iter, nTurns, "with rect clip, with xor" );
857 rTarget.SetLineColor( Color(COL_BLACK) );
858 rTarget.SetFillColor( Color(COL_GREEN) );
859 rTarget.SetRasterOp( ROP_XOR );
860 rTarget.SetClipRegion( aClipPoly );
861 grindFunc( rTarget, iter, nTurns, "with complex clip, with xor" );
863 ++iter;
868 void TestWindow::Paint( const Rectangle& )
870 outDevGrind( *this );
871 fflush( stdout );
874 sal_uInt16 GrindApp::Exception( sal_uInt16 nError )
876 switch( nError & EXC_MAJORTYPE )
878 case EXC_RSCNOTLOADED:
879 Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
880 break;
882 return 0;
885 int GrindApp::Main()
887 bool bHelp = false;
889 for( sal_uInt16 i = 0; i < GetCommandLineParamCount(); i++ )
891 OUString aParam = GetCommandLineParam( i );
893 if( aParam == "--help" || aParam == "-h" )
894 bHelp = true;
897 if( bHelp )
899 printf( "outdevgrind - Profile OutputDevice\n" );
900 return EXIT_SUCCESS;
903 // create the global service-manager
904 uno::Reference< lang::XMultiServiceFactory > xFactory;
907 uno::Reference< uno::XComponentContext > xCtx = ::cppu::defaultBootstrap_InitialComponentContext();
908 xFactory = uno::Reference< lang::XMultiServiceFactory >( xCtx->getServiceManager(),
909 uno::UNO_QUERY );
910 if( xFactory.is() )
911 ::comphelper::setProcessServiceFactory( xFactory );
913 catch( uno::Exception& )
917 if( !xFactory.is() )
919 fprintf( stderr,
920 "Could not bootstrap UNO, installation must be in disorder. Exiting.\n" );
921 exit( 1 );
924 TestWindow pWindow;
925 pWindow.Execute();
927 return EXIT_SUCCESS;
930 } // namespace
932 GrindApp aGrindApp;
934 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */