Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / workben / outdevgrind.cxx
blob7407c51a5fe588e0054216c3e6f8441bcd6ef4cf
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 .
20 #include <sal/main.h>
21 #include <tools/extendapplicationenvironment.hxx>
23 #include <cppuhelper/bootstrap.hxx>
24 #include <comphelper/processfactory.hxx>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <vcl/svapp.hxx>
29 #include <vcl/window.hxx>
30 #include <vcl/dialog.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/virdev.hxx>
33 #include <vcl/hatch.hxx>
34 #include <vcl/bitmap.hxx>
35 #include <vcl/wall.hxx>
36 #include <vcl/image.hxx>
37 #include <vcl/gdimtf.hxx>
38 #include <vcl/metaact.hxx>
39 #include <vcl/bitmapex.hxx>
40 #include <vcl/gradient.hxx>
41 #include <vcl/lineinfo.hxx>
43 #include <rtl/bootstrap.hxx>
45 #include <osl/time.h>
47 #include <boost/function.hpp>
48 #include <boost/bind.hpp>
50 #include <stdio.h>
52 using namespace ::com::sun::star;
54 namespace
57 class GrindApp : public Application
59 public:
60 virtual int Main() SAL_OVERRIDE;
61 virtual sal_uInt16 Exception( sal_uInt16 nError ) SAL_OVERRIDE;
64 class TestWindow : public Dialog
66 public:
67 TestWindow() : Dialog( (vcl::Window *) NULL )
69 SetText( OUString("OutDev grinding") );
70 SetSizePixel( Size( 1024, 1024 ) );
71 EnablePaint( true );
72 Show();
75 virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
78 typedef boost::function1<void, OutputDevice*> functor_type;
79 typedef std::vector< std::pair<const char*,
80 functor_type> > functor_vector_type;
82 template< typename Functor > void add( functor_vector_type& res,
83 const char* pStr,
84 const Functor& func )
86 res.push_back( std::make_pair(pStr,functor_type(func)) );
89 void setupMethodStubs( functor_vector_type& res )
91 const Color aWhiteColor( COL_WHITE );
92 const Color aBlackColor( COL_BLACK );
94 const Point aPt1(10,10);
95 const Point aPt2(500,500);
96 const Point aPt3(0,0);
97 const Point aPt4(450,450);
99 const Rectangle aRect(aPt1,aPt2);
100 const Rectangle aRect2(aPt3,aPt4);
101 const Polygon aPoly(aRect);
102 const Polygon aPoly2(aRect2);
103 tools::PolyPolygon aPolyPoly(aPoly);
104 aPolyPoly.Insert( aPoly2 );
105 Polygon aPoly3(aPoly2);
106 aPoly3.Rotate( aPoly3.GetBoundRect().Center(),
107 900 );
109 const LineInfo aLineInfo(LINE_SOLID,5);
111 #ifdef FIXME_VDEV
112 const OUString aString("This is a test");
114 // unfortunately, VDevs have inaccessible copy constructors
115 static VirtualDevice aVDev;
116 static VirtualDevice aVDevBW(1);
118 const Size aVDevSize;
119 aVDev.SetOutputSizePixel(aVDevSize);
120 aVDevBW.SetOutputSizePixel(aVDevSize);
122 const Bitmap aBitmap( aVDev.GetBitmap(aPt1,aVDevSize) );
123 const Bitmap aBitmapBW( aVDevBW.GetBitmap(aPt1,aVDevSize) );
124 const Bitmap aBitmapAlien( aVDevSize, 8 );
125 #else
126 BitmapEx aIntro;
127 rtl::Bootstrap::set("BRAND_BASE_DIR", ".");
128 if (Application::LoadBrandBitmap ("intro", aIntro))
129 Application::Abort( "Failed to load intro image, run inside program/" );
131 const Bitmap aBitmap( aIntro.GetBitmap() );
132 Bitmap aBitmapBW( aBitmap );
133 aBitmapBW.Filter( BMP_FILTER_EMBOSS_GREY );
134 Bitmap aBitmapAlien( Size( 100, 100 ), 8 );
135 aBitmapAlien.Erase( COL_RED );
136 #endif
138 const BitmapEx aBitmapEx( aBitmap, aBitmapBW );
139 const BitmapEx aBitmapExBW( aBitmapBW, aBitmapBW );
140 const BitmapEx aBitmapExAlien( aBitmapAlien, aBitmapBW );
141 const BitmapEx aBitmapExAlpha( aBitmap, aBitmapAlien );
142 const BitmapEx aBitmapExAlphaAlien( aBitmapAlien, aBitmapAlien );
144 const Image aImage( aBitmapEx );
145 const Gradient aGradient(GradientStyle_ELLIPTICAL,aBlackColor,aWhiteColor);
146 const Hatch aHatch(HatchStyle_TRIPLE,aBlackColor,4,450);
147 const Wallpaper aWallpaper( aWhiteColor );
149 GDIMetaFile aMtf;
150 aMtf.AddAction( new MetaFillColorAction(Color(COL_RED),true) );
151 aMtf.AddAction( new MetaRectAction(aRect) );
153 #ifdef FIXME_NEEDS_LOVE
154 add(res,
155 "DrawTextArray",
156 boost::bind(
157 &OutputDevice::DrawTextArray,
159 aPt1, aString, (const sal_Int32*)0, (sal_uInt16)0, aString.getLength() ));
160 #endif
162 /* void DrawPixel( const Point& rPt, const Color& rColor ); */
163 add(res,
164 "DrawPixel",
165 boost::bind(
166 (void (OutputDevice::*)( const Point&, const Color& ))(
167 &OutputDevice::DrawPixel),
169 aPt1, aBlackColor ));
171 /* void DrawLine( const Point& rStartPt, const Point& rEndPt ); */
172 add(res,
173 "DrawLine",
174 boost::bind(
175 (void (OutputDevice::*)( const Point&, const Point& ))(
176 &OutputDevice::DrawLine),
178 aPt1, aPt2 ));
180 /* void DrawLine( const Point& rStartPt, const Point& rEndPt,
181 const LineInfo& rLineInfo );
183 add(res,
184 "DrawLine(LineInfo)",
185 boost::bind(
186 (void (OutputDevice::*)( const Point&, const Point&,const LineInfo& ))(
187 &OutputDevice::DrawLine),
189 aPt1, aPt2, aLineInfo ));
191 /* void DrawPolyLine( const Polygon& rPoly ); */
192 add(res,
193 "DrawPolyLine",
194 boost::bind(
195 (void (OutputDevice::*)( const Polygon& ))(
196 &OutputDevice::DrawPolyLine),
198 aPoly ));
200 /* void DrawPolyLine( const Polygon& rPoly,
201 const LineInfo& rLineInfo );
203 add(res,
204 "DrawPolyLine(LineInfo)",
205 boost::bind(
206 (void (OutputDevice::*)( const Polygon&, const LineInfo& ))(
207 &OutputDevice::DrawPolyLine),
209 aPoly, aLineInfo ));
211 /* void DrawPolygon( const Polygon& rPoly ); */
212 add(res,
213 "DrawPolygon",
214 boost::bind(
215 (void (OutputDevice::*)( const Polygon& ))
216 &OutputDevice::DrawPolygon,
218 aPoly ));
220 /* void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly ); */
221 add(res,
222 "DrawPolyPolygon",
223 boost::bind(
224 (void (OutputDevice::*)( const tools::PolyPolygon& ))
225 &OutputDevice::DrawPolyPolygon,
227 aPolyPoly ));
229 /* void DrawRect( const Rectangle& rRect ); */
230 add(res,
231 "DrawRect",
232 boost::bind(
233 (void (OutputDevice::*)( const Rectangle& ))(
234 &OutputDevice::DrawRect),
236 aRect ));
238 /* void DrawRect( const Rectangle& rRect,
239 sal_uLong nHorzRount, sal_uLong nVertRound );
241 add(res,
242 "DrawRect(round corners)",
243 boost::bind(
244 (void (OutputDevice::*)( const Rectangle&, sal_uLong nHorzRount, sal_uLong nVertRound ))(
245 &OutputDevice::DrawRect),
247 aRect2,
248 4,4));
250 /* void DrawEllipse( const Rectangle& rRect ); */
251 add(res,
252 "DrawEllipse",
253 boost::bind(
254 &OutputDevice::DrawEllipse,
256 aRect ));
258 /* void DrawArc( const Rectangle& rRect,
259 const Point& rStartPt, const Point& rEndPt );
261 add(res,
262 "DrawArc",
263 boost::bind(
264 &OutputDevice::DrawArc,
266 aRect,aPt1,aPt2 ));
268 /* void DrawPie( const Rectangle& rRect,
269 const Point& rStartPt, const Point& rEndPt );
271 add(res,
272 "DrawPie",
273 boost::bind(
274 &OutputDevice::DrawPie,
276 aRect2,aPt3,aPt4 ));
278 /* void DrawChord( const Rectangle& rRect,
279 const Point& rStartPt, const Point& rEndPt );
281 add(res,
282 "DrawChord",
283 boost::bind(
284 &OutputDevice::DrawChord,
286 aRect2,aPt3,aPt4 ));
288 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
289 const Point& rSrcPt, const Size& rSrcSize );
291 add(res,
292 "DrawOutDev",
293 boost::bind(
294 (void (OutputDevice::*)( const Point&, const Size&,
295 const Point&, const Size& ))(
296 &OutputDevice::DrawOutDev),
298 aRect2.TopLeft(), aRect2.GetSize(),
299 aRect.TopLeft(), aRect.GetSize()));
301 #ifdef FIXME_VDEV
302 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
303 const Point& rSrcPt, const Size& rSrcSize,
304 const OutputDevice& rOutDev );
306 add(res,
307 "DrawOutDev(foreign source)",
308 boost::bind(
309 (void (OutputDevice::*)( const Point&, const Size&,
310 const Point&, const Size&,
311 const OutputDevice& ))(
312 &OutputDevice::DrawOutDev),
314 aRect2.TopLeft(), aRect2.GetSize(),
315 aRect.TopLeft(), aRect.GetSize(),
316 boost::cref(aVDevBW) ));
318 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
319 const Point& rSrcPt, const Size& rSrcSize,
320 const OutputDevice& rOutDev );
322 add(res,
323 "DrawOutDev(foreign source, scaled)",
324 boost::bind(
325 (void (OutputDevice::*)( const Point&, const Size&,
326 const Point&, const Size&,
327 const OutputDevice& ))(
328 &OutputDevice::DrawOutDev),
330 aRect2.TopLeft(), aRect2.GetSize(),
331 aRect.TopLeft(), aRect.GetSize(),
332 boost::cref(aVDev) ));
333 #endif
335 /* void CopyArea( const Point& rDestPt,
336 const Point& rSrcPt, const Size& rSrcSize,
337 sal_uInt16 nFlags = 0 );
339 add(res,
340 "CopyArea",
341 boost::bind(
342 &OutputDevice::CopyArea,
344 aPt1, aPt3, aRect2.GetSize(), false ));
346 #ifdef NEEDS_QUALIY_PARAMTER
347 /* void DrawBitmap( const Point& rDestPt,
348 const Bitmap& rBitmap );
350 add(res,
351 "DrawBitmap(alien source)",
352 boost::bind(
353 (void (OutputDevice::*)( const Point&,
354 const Bitmap& ))(
355 &OutputDevice::DrawBitmap),
357 aPt1,aBitmapAlien ));
359 /* void DrawBitmap( const Point& rDestPt,
360 const Bitmap& rBitmap );
362 add(res,
363 "DrawBitmap",
364 boost::bind(
365 (void (OutputDevice::*)( const Point&,
366 const Bitmap& ))(
367 &OutputDevice::DrawBitmap),
369 aPt1,aBitmap ));
371 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
372 const Bitmap& rBitmap );
374 add(res,
375 "DrawBitmap(scaled,alien source)",
376 boost::bind(
377 (void (OutputDevice::*)( const Point&,
378 const Size&,
379 const Bitmap& ))(
380 &OutputDevice::DrawBitmap),
382 aPt1,aRect.GetSize(),aBitmapAlien ));
384 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
385 const Bitmap& rBitmap );
387 add(res,
388 "DrawBitmap(scaled)",
389 boost::bind(
390 (void (OutputDevice::*)( const Point&,
391 const Size&,
392 const Bitmap& ))(
393 &OutputDevice::DrawBitmap),
395 aPt1,aRect.GetSize(),aBitmap ));
397 #if 0
398 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
399 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
400 const Bitmap& rBitmap );
402 add(res,
403 "DrawBitmap(scaled subset,alien source)",
404 boost::bind(
405 (void (OutputDevice::*)( const Point&,
406 const Size&,
407 const Point&,
408 const Size&,
409 const Bitmap& ))(
410 &OutputDevice::DrawBitmap),
412 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien ));
413 #endif
415 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
416 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
417 const Bitmap& rBitmap );
419 add(res,
420 "DrawBitmap(scaled subset)",
421 boost::bind(
422 (void (OutputDevice::*)( const Point&,
423 const Size&,
424 const Point&,
425 const Size&,
426 const Bitmap& ))(
427 &OutputDevice::DrawBitmap),
429 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap ));
431 /* void DrawBitmapEx( const Point& rDestPt,
432 const BitmapEx& rBitmapEx );
434 add(res,
435 "DrawBitmapEx(alien source)",
436 boost::bind(
437 (void (OutputDevice::*)( const Point&,
438 const BitmapEx& ))(
439 &OutputDevice::DrawBitmapEx),
441 aPt1,aBitmapExAlien ));
443 /* void DrawBitmapEx( const Point& rDestPt,
444 const BitmapEx& rBitmapEx );
446 add(res,
447 "DrawBitmapEx",
448 boost::bind(
449 (void (OutputDevice::*)( const Point&,
450 const BitmapEx& ))(
451 &OutputDevice::DrawBitmapEx),
453 aPt1,aBitmapEx ));
455 /* void DrawBitmapEx( const Point& rDestPt,
456 const BitmapEx& rBitmapEx );
458 add(res,
459 "DrawBitmapEx(alpha)",
460 boost::bind(
461 (void (OutputDevice::*)( const Point&,
462 const BitmapEx& ))(
463 &OutputDevice::DrawBitmapEx),
465 aPt1,aBitmapExAlpha ));
467 /* void DrawBitmapEx( const Point& rDestPt,
468 const BitmapEx& rBitmapEx );
470 add(res,
471 "DrawBitmapEx(alpha, alien source)",
472 boost::bind(
473 (void (OutputDevice::*)( const Point&,
474 const BitmapEx& ))(
475 &OutputDevice::DrawBitmapEx),
477 aPt1,aBitmapExAlphaAlien ));
479 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
480 const BitmapEx& rBitmapEx );
482 add(res,
483 "DrawBitmapEx(scaled,alien source)",
484 boost::bind(
485 (void (OutputDevice::*)( const Point&,
486 const Size&,
487 const BitmapEx& ))(
488 &OutputDevice::DrawBitmapEx),
490 aPt1,aRect.GetSize(),aBitmapExAlien ));
492 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
493 const BitmapEx& rBitmapEx );
495 add(res,
496 "DrawBitmapEx(scaled)",
497 boost::bind(
498 (void (OutputDevice::*)( const Point&,
499 const Size&,
500 const BitmapEx& ))(
501 &OutputDevice::DrawBitmapEx),
503 aPt1,aRect.GetSize(),aBitmapEx ));
505 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
506 const BitmapEx& rBitmapEx );
508 add(res,
509 "DrawBitmapEx(scaled alpha)",
510 boost::bind(
511 (void (OutputDevice::*)( const Point&,
512 const Size&,
513 const BitmapEx& ))(
514 &OutputDevice::DrawBitmapEx),
516 aPt1,aRect.GetSize(),aBitmapExAlpha ));
518 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
519 const BitmapEx& rBitmapEx );
521 add(res,
522 "DrawBitmapEx(scaled alpha, alien source)",
523 boost::bind(
524 (void (OutputDevice::*)( const Point&,
525 const Size&,
526 const BitmapEx& ))(
527 &OutputDevice::DrawBitmapEx),
529 aPt1,aRect.GetSize(),aBitmapExAlphaAlien ));
531 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
532 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
533 const BitmapEx& rBitmapEx );
535 add(res,
536 "DrawBitmapEx(scaled subset,alien source)",
537 boost::bind(
538 (void (OutputDevice::*)( const Point&,
539 const Size&,
540 const Point&,
541 const Size&,
542 const BitmapEx& ))(
543 &OutputDevice::DrawBitmapEx),
545 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlien ));
547 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
548 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
549 const BitmapEx& rBitmapEx );
551 add(res,
552 "DrawBitmapEx(scaled subset)",
553 boost::bind(
554 (void (OutputDevice::*)( const Point&,
555 const Size&,
556 const Point&,
557 const Size&,
558 const BitmapEx& ))(
559 &OutputDevice::DrawBitmapEx),
561 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapEx ));
563 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
564 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
565 const BitmapEx& rBitmapEx );
567 add(res,
568 "DrawBitmapEx(scaled subset, alpha)",
569 boost::bind(
570 (void (OutputDevice::*)( const Point&,
571 const Size&,
572 const Point&,
573 const Size&,
574 const BitmapEx& ))(
575 &OutputDevice::DrawBitmapEx),
577 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlpha ));
579 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
580 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
581 const BitmapEx& rBitmapEx );
583 add(res,
584 "DrawBitmapEx(scaled subset, alpha alien source)",
585 boost::bind(
586 (void (OutputDevice::*)( const Point&,
587 const Size&,
588 const Point&,
589 const Size&,
590 const BitmapEx& ))(
591 &OutputDevice::DrawBitmapEx),
593 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapExAlphaAlien ));
595 /* void DrawMask( const Point& rDestPt,
596 const Bitmap& rBitmap, const Color& rMaskColor );
598 add(res,
599 "DrawMask(alien source)",
600 boost::bind(
601 (void (OutputDevice::*)( const Point&,
602 const Bitmap&,
603 const Color& ))(
604 &OutputDevice::DrawMask),
606 aPt1,aBitmapAlien,aBlackColor ));
608 /* void DrawMask( const Point& rDestPt,
609 const Bitmap& rBitmap, const Color& rMaskColor );
611 add(res,
612 "DrawMask",
613 boost::bind(
614 (void (OutputDevice::*)( const Point&,
615 const Bitmap&,
616 const Color& ))(
617 &OutputDevice::DrawMask),
619 aPt1,aBitmap,aBlackColor ));
621 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
622 const Bitmap& rBitmap, const Color& rMaskColor );
624 add(res,
625 "DrawMask(scaled,alien source)",
626 boost::bind(
627 (void (OutputDevice::*)( const Point&,
628 const Size&,
629 const Bitmap&,
630 const Color& ))(
631 &OutputDevice::DrawMask),
633 aPt1,aRect.GetSize(),aBitmapAlien, aBlackColor ));
635 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
636 const Bitmap& rBitmap, const Color& rMaskColor );
638 add(res,
639 "DrawMask(scaled)",
640 boost::bind(
641 (void (OutputDevice::*)( const Point&,
642 const Size&,
643 const Bitmap&,
644 const Color& ))(
645 &OutputDevice::DrawMask),
647 aPt1,aRect.GetSize(),aBitmap,aBlackColor ));
649 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
650 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
651 const Bitmap& rBitmap, const Color& rMaskColor );
653 add(res,
654 "DrawMask(scaled subset,alien source)",
655 boost::bind(
656 (void (OutputDevice::*)( const Point&,
657 const Size&,
658 const Point&,
659 const Size&,
660 const Bitmap&,
661 const Color& ))(
662 &OutputDevice::DrawMask),
664 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmapAlien,aBlackColor ));
666 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
667 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
668 const Bitmap& rBitmap, const Color& rMaskColor );
670 add(res,
671 "DrawMask(scaled subset)",
672 boost::bind(
673 (void (OutputDevice::*)( const Point&,
674 const Size&,
675 const Point&,
676 const Size&,
677 const Bitmap&,
678 const Color& ))(
679 &OutputDevice::DrawMask),
681 aPt1,aRect.GetSize(),aPt3,aRect2.GetSize(),aBitmap,aBlackColor ));
683 /* void DrawImage( const Point& rPos,
684 const Image& rImage, sal_uInt16 nStyle = 0 );
686 add(res,
687 "DrawImage",
688 boost::bind(
689 (void (OutputDevice::*)( const Point&,
690 const Image&,
691 sal_uInt16 nStyle ))(
692 &OutputDevice::DrawImage),
694 aPt1,aImage,(sal_uInt16)0 ));
696 /* void DrawImage( const Point& rPos, const Size& rSize,
697 const Image& rImage, sal_uInt16 nStyle = 0 );
699 add(res,
700 "DrawImage(scaled)",
701 boost::bind(
702 (void (OutputDevice::*)( const Point&,
703 const Size&,
704 const Image&,
705 sal_uInt16 nStyle ))(
706 &OutputDevice::DrawImage),
708 aPt1,aRect.GetSize(),aImage,(sal_uInt16)0 ));
710 #endif // NEEDS_QUALITY_PARAMATER
712 /* void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); */
713 add(res,
714 "DrawGradient",
715 boost::bind(
716 (void (OutputDevice::*)( const Rectangle&, const Gradient& ))(
717 &OutputDevice::DrawGradient),
719 aRect,aGradient ));
721 /* void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ); */
722 add(res,
723 "DrawGradient(polygon)",
724 boost::bind(
725 (void (OutputDevice::*)( const tools::PolyPolygon&, const Gradient& ))(
726 &OutputDevice::DrawGradient),
728 aPoly3,aGradient ));
730 /* void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch ); */
731 add(res,
732 "DrawHatch",
733 boost::bind(
734 &OutputDevice::DrawHatch,
736 aPoly3,aHatch ));
738 /* void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); */
739 add(res,
740 "DrawWallpaper",
741 boost::bind(
742 &OutputDevice::DrawWallpaper,
744 aRect2,aWallpaper ));
746 #ifdef FIXME_HAVE_WAVE_NORMAL
747 /* void DrawWaveLine( const Point& rStartPos, const Point& rEndPos, sal_uInt16 nStyle ); */
748 add(res,
749 "DrawWaveLine",
750 boost::bind(
751 &OutputDevice::DrawWaveLine,
753 aPt1,aPt2,(sal_uInt16)WAVE_NORMAL ));
754 #endif
756 /* void DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags ); */
757 add(res,
758 "DrawGrid",
759 boost::bind(
760 &OutputDevice::DrawGrid,
762 aRect,Size(10,20),DrawGridFlags::HorzLines|DrawGridFlags::VertLines ));
764 /* void DrawTransparent( const tools::PolyPolygon& rPolyPoly,
765 sal_uInt16 nTransparencePercent );
767 add(res,
768 "DrawTransparent",
769 boost::bind(
770 (void (OutputDevice::*)( const tools::PolyPolygon&, sal_uInt16 ))(
771 &OutputDevice::DrawTransparent),
773 aPoly3,(sal_uInt16)50 ));
775 /* void DrawTransparent( const GDIMetaFile& rMtf,
776 const Point& rPos, const Size& rSize,
777 const Gradient& rTransparenceGradient );
779 add(res,
780 "DrawTransparent(metafile)",
781 boost::bind(
782 (void (OutputDevice::*)( const GDIMetaFile&,
783 const Point&,
784 const Size&,
785 const Gradient& ))(
786 &OutputDevice::DrawTransparent),
788 aMtf,aPt1,aRect.GetSize(),aGradient ));
790 /* void Erase(); */
791 add(res,
792 "Erase",
793 boost::bind(
794 &OutputDevice::Erase,
795 _1 ));
799 void grindFunc( OutputDevice& rTarget,
800 functor_vector_type::const_iterator iter,
801 sal_Int32 nTurns,
802 const char* pMsg )
804 const sal_uInt32 nStartTime( osl_getGlobalTimer() );
806 for( sal_Int32 i=0; i<nTurns; ++i )
807 iter->second(&rTarget);
809 if( rTarget.GetOutDevType() == OUTDEV_WINDOW )
810 static_cast< vcl::Window & >( rTarget ).Sync();
812 fprintf( stdout,
813 "Duration: %d ms (%d repetitions)\tOperation: %s\tSetup: %s\n",
814 (int)(osl_getGlobalTimer() - nStartTime),
815 (int)(nTurns),
816 iter->first,
817 pMsg );
820 /** Call OutputDevice render methods repeatedly, and output elapsed
821 time to stdout
823 void outDevGrind(vcl::RenderContext& rTarget, sal_Int32 nTurns = 100)
825 // TODO(F1): also profile pure complex clip setup times!
827 // State: fill/line color, draw mode, w/o clip, rect clip, complex clip
828 functor_vector_type aMethods;
829 setupMethodStubs( aMethods );
831 const Rectangle aClipRect(10,10,1000,1000);
832 const Polygon aPoly1( aClipRect );
833 Polygon aPoly2( aClipRect );
834 aPoly2.Rotate(aClipRect.Center(),450);
835 tools::PolyPolygon aClipPoly(aPoly1);
836 aClipPoly.Insert(aPoly2);
838 functor_vector_type::const_iterator iter = aMethods.begin();
839 const functor_vector_type::const_iterator end = aMethods.end();
840 while( iter != end )
842 rTarget.SetLineColor( Color(COL_BLACK) );
843 rTarget.SetFillColor( Color(COL_GREEN) );
844 rTarget.SetRasterOp( ROP_OVERPAINT );
845 rTarget.SetClipRegion();
846 grindFunc( rTarget, iter, nTurns, "w/o clip, w/o xor" );
848 rTarget.SetLineColor( Color(COL_BLACK) );
849 rTarget.SetFillColor( Color(COL_GREEN) );
850 rTarget.SetRasterOp( ROP_OVERPAINT );
851 rTarget.SetClipRegion( vcl::Region( aClipRect ) );
852 grindFunc( rTarget, iter, nTurns, "with rect clip, w/o xor" );
854 rTarget.SetLineColor( Color(COL_BLACK) );
855 rTarget.SetFillColor( Color(COL_GREEN) );
856 rTarget.SetRasterOp( ROP_OVERPAINT );
857 rTarget.SetClipRegion( vcl::Region( aClipPoly ) );
858 grindFunc( rTarget, iter, nTurns, "with complex clip, w/o xor" );
860 rTarget.SetLineColor( Color(COL_BLACK) );
861 rTarget.SetFillColor( Color(COL_GREEN) );
862 rTarget.SetRasterOp( ROP_XOR );
863 rTarget.SetClipRegion();
864 grindFunc( rTarget, iter, nTurns, "w/o clip, with xor" );
866 rTarget.SetLineColor( Color(COL_BLACK) );
867 rTarget.SetFillColor( Color(COL_GREEN) );
868 rTarget.SetRasterOp( ROP_XOR );
869 rTarget.SetClipRegion( vcl::Region( aClipRect ) );
870 grindFunc( rTarget, iter, nTurns, "with rect clip, with xor" );
872 rTarget.SetLineColor( Color(COL_BLACK) );
873 rTarget.SetFillColor( Color(COL_GREEN) );
874 rTarget.SetRasterOp( ROP_XOR );
875 rTarget.SetClipRegion( vcl::Region( aClipPoly ) );
876 grindFunc( rTarget, iter, nTurns, "with complex clip, with xor" );
878 ++iter;
882 void TestWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
884 outDevGrind(rRenderContext);
885 fflush(stdout);
888 sal_uInt16 GrindApp::Exception( sal_uInt16 nError )
890 switch( nError & EXC_MAJORTYPE )
892 case EXC_RSCNOTLOADED:
893 Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
894 break;
896 return 0;
899 int GrindApp::Main()
901 ScopedVclPtrInstance<TestWindow> aWindow;
902 aWindow->Execute();
903 return 0;
906 } // namespace
909 SAL_IMPLEMENT_MAIN()
913 bool bHelp = false;
915 for( sal_uInt16 i = 0; i < Application::GetCommandLineParamCount(); i++ )
917 OUString aParam = Application::GetCommandLineParam( i );
919 if( aParam == "--help" || aParam == "-h" )
920 bHelp = true;
923 if( bHelp )
925 printf( "outdevgrind - Profile OutputDevice\n" );
926 return EXIT_SUCCESS;
929 tools::extendApplicationEnvironment();
931 uno::Reference< uno::XComponentContext > xContext = cppu::defaultBootstrap_InitialComponentContext();
932 uno::Reference< lang::XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), uno::UNO_QUERY );
934 if( !xServiceManager.is() )
935 Application::Abort( "Failed to bootstrap" );
937 comphelper::setProcessServiceFactory( xServiceManager );
939 InitVCL();
941 GrindApp aGrindApp;
942 aGrindApp.Main();
944 DeInitVCL();
946 catch (const css::uno::Exception& e)
948 SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
949 return EXIT_FAILURE;
951 catch (const std::exception& e)
953 SAL_WARN("vcl.app", "Fatal exception: " << e.what());
954 return EXIT_FAILURE;
957 return EXIT_SUCCESS;
960 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */