lok: impress: show only supported transitions in the side pane
[LibreOffice.git] / vcl / workben / outdevgrind.cxx
blob8283a5e59da2e845ff6dd34e3f244564971c3fab
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 <sal/log.hxx>
22 #include <tools/diagnose_ex.h>
23 #include <tools/extendapplicationenvironment.hxx>
25 #include <cppuhelper/bootstrap.hxx>
26 #include <comphelper/processfactory.hxx>
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <vcl/svapp.hxx>
31 #include <vcl/window.hxx>
32 #include <vcl/dialog.hxx>
33 #include <vcl/outdev.hxx>
34 #include <vcl/virdev.hxx>
35 #include <vcl/hatch.hxx>
36 #include <vcl/bitmap.hxx>
37 #include <vcl/BitmapEmbossGreyFilter.hxx>
38 #include <vcl/wall.hxx>
39 #include <vcl/image.hxx>
40 #include <vcl/gdimtf.hxx>
41 #include <vcl/metaact.hxx>
42 #include <vcl/bitmapex.hxx>
43 #include <vcl/gradient.hxx>
44 #include <vcl/lineinfo.hxx>
46 #include <rtl/bootstrap.hxx>
48 #include <osl/time.h>
50 #include <functional>
52 #include <stdio.h>
54 using namespace ::com::sun::star;
56 namespace
59 class GrindApp : public Application
61 public:
62 virtual int Main() override;
63 virtual void Exception( ExceptionCategory nCategory ) override;
66 class TestWindow : public Dialog
68 public:
69 TestWindow() : Dialog( nullptr )
71 SetText( "OutDev grinding" );
72 SetSizePixel( Size( 1024, 1024 ) );
73 EnablePaint( true );
74 Show();
77 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
80 typedef std::function<void (OutputDevice*)> functor_type;
81 typedef std::vector< std::pair<const char*,
82 functor_type> > functor_vector_type;
84 template< typename Functor > void add( functor_vector_type& res,
85 const char* pStr,
86 const Functor& func )
88 res.emplace_back(pStr,functor_type(func) );
91 void setupMethodStubs( functor_vector_type& res )
93 const Color aWhiteColor( COL_WHITE );
94 const Color aBlackColor( COL_BLACK );
96 const Point aPt1(10,10);
97 const Point aPt2(500,500);
98 const Point aPt3(0,0);
99 const Point aPt4(450,450);
101 const tools::Rectangle aRect(aPt1,aPt2);
102 const tools::Rectangle aRect2(aPt3,aPt4);
103 const tools::Polygon aPoly(aRect);
104 const tools::Polygon aPoly2(aRect2);
105 tools::PolyPolygon aPolyPoly(aPoly);
106 aPolyPoly.Insert( aPoly2 );
107 tools::Polygon aPoly3(aPoly2);
108 aPoly3.Rotate( aPoly3.GetBoundRect().Center(), 900 );
109 const LineInfo aLineInfo(LineStyle::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 );
134 BitmapEx aTmpBmpEx(aBitmapBW);
135 BitmapFilter::Filter(aTmpBmpEx, BitmapEmbossGreyFilter(0, 0));
136 aBitmapBW = aTmpBmpEx.GetBitmap();
138 Bitmap aBitmapAlien( Size( 100, 100 ), 8 );
139 aBitmapAlien.Erase( COL_RED );
140 #endif
142 const BitmapEx aBitmapEx( aBitmap, aBitmapBW );
143 (void)aBitmapEx;
144 const BitmapEx aBitmapExBW( aBitmapBW, aBitmapBW );
145 (void)aBitmapExBW;
146 const BitmapEx aBitmapExAlien( aBitmapAlien, aBitmapBW );
147 (void)aBitmapExAlien;
148 const BitmapEx aBitmapExAlpha( aBitmap, aBitmapAlien );
149 (void)aBitmapExAlpha;
150 const BitmapEx aBitmapExAlphaAlien( aBitmapAlien, aBitmapAlien );
151 (void)aBitmapExAlphaAlien;
153 #ifdef NEEDS_QUALITY_PARAMETER
154 const Image aImage( aBitmapEx );
155 #endif
156 const Gradient aGradient(GradientStyle::Elliptical,aBlackColor,aWhiteColor);
157 const Hatch aHatch(HatchStyle::Triple,aBlackColor,4,450);
158 const Wallpaper aWallpaper( aWhiteColor );
160 GDIMetaFile aMtf;
161 aMtf.AddAction( new MetaFillColorAction(COL_RED,true) );
162 aMtf.AddAction( new MetaRectAction(aRect) );
164 #ifdef FIXME_NEEDS_LOVE
165 add(res,
166 "DrawTextArray",
167 [&] (OutputDevice * pDev) {
168 return pDev->DrawTextArray(aPt1, aString, (const sal_Int32*)0, (sal_uInt16)0, aString.getLength());
170 #endif
172 /* void DrawPixel( const Point& rPt, const Color& rColor ); */
173 add(res,
174 "DrawPixel",
175 [aPt1, aBlackColor](OutputDevice *pOutDev) { return pOutDev->DrawPixel(aPt1, aBlackColor); });
177 /* void DrawLine( const Point& rStartPt, const Point& rEndPt ); */
178 add(res,
179 "DrawLine",
180 [aPt1, aPt2] (OutputDevice *pOutDev) { return pOutDev->DrawLine(aPt1, aPt2); });
182 /* void DrawLine( const Point& rStartPt, const Point& rEndPt,
183 const LineInfo& rLineInfo );
185 add(res,
186 "DrawLine(LineInfo)",
187 [aPt1, aPt2, aLineInfo] (OutputDevice *pOutDev) { return pOutDev->DrawLine(aPt1, aPt2, aLineInfo); });
189 /* void DrawPolyLine( const Polygon& rPoly ); */
190 add(res,
191 "DrawPolyLine",
192 [aPoly] (OutputDevice *pOutDev) {return pOutDev->DrawPolyLine(aPoly); });
194 /* void DrawPolyLine( const Polygon& rPoly,
195 const LineInfo& rLineInfo );
197 add(res,
198 "DrawPolyLine(LineInfo)",
199 [aPoly, aLineInfo] (OutputDevice *pOutDev) { return pOutDev->DrawPolyLine(aPoly, aLineInfo); });
201 /* void DrawPolygon( const Polygon& rPoly ); */
202 add(res,
203 "DrawPolygon",
204 [aPoly] (OutputDevice *pOutDev) { return pOutDev->DrawPolygon(aPoly); });
206 /* void DrawPolyPolygon( const tools::PolyPolygon& rPolyPoly ); */
207 add(res,
208 "DrawPolyPolygon",
209 [aPolyPoly] (OutputDevice *pOutDev) { return pOutDev->DrawPolyPolygon(aPolyPoly); });
211 /* void DrawRect( const Rectangle& rRect ); */
212 add(res,
213 "DrawRect",
214 [aRect] (OutputDevice *pOutDev) { return pOutDev->DrawRect(aRect); });
216 /* void DrawRect( const Rectangle& rRect,
217 sal_uLong nHorzRount, sal_uLong nVertRound );
219 add(res,
220 "DrawRect(round corners)",
221 [aRect2] (OutputDevice *pOutDev) { return pOutDev->DrawRect(aRect2,4,4); });
223 /* void DrawEllipse( const Rectangle& rRect ); */
224 add(res,
225 "DrawEllipse",
226 [aRect] (OutputDevice *pOutDev) { return pOutDev->DrawEllipse(aRect); });
228 /* void DrawArc( const Rectangle& rRect,
229 const Point& rStartPt, const Point& rEndPt );
231 add(res,
232 "DrawArc",
233 [aRect,aPt1,aPt2] (OutputDevice *pOutDev) { return pOutDev->DrawArc(aRect,aPt1,aPt2); });
235 /* void DrawPie( const Rectangle& rRect,
236 const Point& rStartPt, const Point& rEndPt );
238 add(res,
239 "DrawPie",
240 [aRect2,aPt3,aPt4] (OutputDevice *pOutDev) { return pOutDev->DrawPie(aRect2,aPt3,aPt4); });
242 /* void DrawChord( const Rectangle& rRect,
243 const Point& rStartPt, const Point& rEndPt );
245 add(res,
246 "DrawChord",
247 [aRect2,aPt3,aPt4] (OutputDevice *pOutDev) { return pOutDev->DrawChord(aRect2,aPt3,aPt4); });
249 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
250 const Point& rSrcPt, const Size& rSrcSize );
252 add(res,
253 "DrawOutDev",
254 [aRect,aRect2] (OutputDevice *pOutDev) { return pOutDev->DrawOutDev(aRect2.TopLeft(), aRect2.GetSize(),
255 aRect.TopLeft(), aRect.GetSize()); });
257 #ifdef FIXME_VDEV
258 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
259 const Point& rSrcPt, const Size& rSrcSize,
260 const OutputDevice& rOutDev );
262 add(res,
263 "DrawOutDev(foreign source)",
264 [&] (OutputDevice * pDev) {
265 return pDev->DrawOutDev(aRect2.TopLeft(), aRect2.GetSize(),
266 aRect.TopLeft(), aRect.GetSize(), aVDevBW);
269 /* void DrawOutDev( const Point& rDestPt, const Size& rDestSize,
270 const Point& rSrcPt, const Size& rSrcSize,
271 const OutputDevice& rOutDev );
273 add(res,
274 "DrawOutDev(foreign source, scaled)",
275 [&] (OutputDevice * pDev) {
276 return pDev->DrawOutDev(aRect2.TopLeft(), aRect2.GetSize(),
277 aRect.TopLeft(), aRect.GetSize(), aVDev);
279 #endif
281 /* void CopyArea( const Point& rDestPt,
282 const Point& rSrcPt, const Size& rSrcSize,
283 sal_uInt16 nFlags = 0 );
285 add(res,
286 "CopyArea",
287 [&] (OutputDevice * pDev) { return pDev->CopyArea(aPt1, aPt3, aRect2.GetSize()); } );
289 #ifdef NEEDS_QUALITY_PARAMETER
290 /* void DrawBitmap( const Point& rDestPt,
291 const Bitmap& rBitmap );
293 add(res,
294 "DrawBitmap(alien source)",
295 [&] (OutputDevice * pDev) { return pDev->DrawBitmap(aPt1, aBitmapAlien); });
297 /* void DrawBitmap( const Point& rDestPt,
298 const Bitmap& rBitmap );
300 add(res,
301 "DrawBitmap",
302 [&] (OutputDevice * pDev) { return pDev->DrawBitmap(aPt1, aBitmap); });
304 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
305 const Bitmap& rBitmap );
307 add(res,
308 "DrawBitmap(scaled,alien source)",
309 [&] (OutputDevice * pDev) {
310 return pDev->DrawBitmap(aPt1, aRect.GetSize(), aBitmapAlien);
313 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
314 const Bitmap& rBitmap );
316 add(res,
317 "DrawBitmap(scaled)",
318 [&] (OutputDevice * pDev) {
319 return pDev->DrawBitmap(aPt1, aRect.GetSize(), aBitmap);
322 #if 0
323 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
324 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
325 const Bitmap& rBitmap );
327 add(res,
328 "DrawBitmap(scaled subset,alien source)",
329 [&] (OutputDevice * pDev) {
330 return pDev->DrawBitmap(aPt1, aRect.GetSize(), aPt3,
331 aRect2.GetSize(), aBitmapAlien);
333 #endif
335 /* void DrawBitmap( const Point& rDestPt, const Size& rDestSize,
336 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
337 const Bitmap& rBitmap );
339 add(res,
340 "DrawBitmap(scaled subset)",
341 [&] (OutputDevice * pDev) {
342 return pDev->DrawBitmap(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(), aBitmap);
345 /* void DrawBitmapEx( const Point& rDestPt,
346 const BitmapEx& rBitmapEx );
348 add(res,
349 "DrawBitmapEx(alien source)",
350 [&] (OutputDevice * pDev) { return pDev->DrawBitmapEx(aPt1, aBitmapExAlien); });
352 /* void DrawBitmapEx( const Point& rDestPt,
353 const BitmapEx& rBitmapEx );
355 add(res,
356 "DrawBitmapEx",
357 [&] (OutputDevice * pDev) { return pDev->DrawBitmapEx(aPt1, aBitmapEx); });
359 /* void DrawBitmapEx( const Point& rDestPt,
360 const BitmapEx& rBitmapEx );
362 add(res,
363 "DrawBitmapEx(alpha)",
364 [&] (OutputDevice * pDev) { return pDev->DrawBitmapEx(aPt1, aBitmapExAlpha); });
366 /* void DrawBitmapEx( const Point& rDestPt,
367 const BitmapEx& rBitmapEx );
369 add(res,
370 "DrawBitmapEx(alpha, alien source)",
371 [&] (OutputDevice * pDev) { return pDev->DrawBitmapEx(aPt1, aBitmapExAlphaAlien); });
373 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
374 const BitmapEx& rBitmapEx );
376 add(res,
377 "DrawBitmapEx(scaled,alien source)",
378 [&] (OutputDevice * pDev) {
379 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aBitmapExAlien);
382 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
383 const BitmapEx& rBitmapEx );
385 add(res,
386 "DrawBitmapEx(scaled)",
387 [&] (OutputDevice * pDev) {
388 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aBitmapEx);
391 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
392 const BitmapEx& rBitmapEx );
394 add(res,
395 "DrawBitmapEx(scaled alpha)",
396 [&] (OutputDevice * pDev) {
397 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aBitmapExAlpha);
400 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
401 const BitmapEx& rBitmapEx );
403 add(res,
404 "DrawBitmapEx(scaled alpha, alien source)",
405 [&] (OutputDevice * pDev) {
406 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aBitmapExAlphaAlien);
409 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
410 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
411 const BitmapEx& rBitmapEx );
413 add(res,
414 "DrawBitmapEx(scaled subset,alien source)",
415 [&] (OutputDevice * pDev) {
416 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(), aBitmapExAlien);
419 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
420 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
421 const BitmapEx& rBitmapEx );
423 add(res,
424 "DrawBitmapEx(scaled subset)",
425 [&] (OutputDevice * pDev) {
426 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(), aBitmapEx);
429 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
430 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
431 const BitmapEx& rBitmapEx );
433 add(res,
434 "DrawBitmapEx(scaled subset, alpha)",
435 [&] (OutputDevice * pDev) {
436 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(), aBitmapExAlpha);
439 /* void DrawBitmapEx( const Point& rDestPt, const Size& rDestSize,
440 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
441 const BitmapEx& rBitmapEx );
443 add(res,
444 "DrawBitmapEx(scaled subset, alpha alien source)",
445 [&] (OutputDevice * pDev) {
446 return pDev->DrawBitmapEx(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(), aBitmapExAlphaAlien);
449 /* void DrawMask( const Point& rDestPt,
450 const Bitmap& rBitmap, const Color& rMaskColor );
452 add(res,
453 "DrawMask(alien source)",
454 [&] (OutputDevice * pDev) {
455 return pDev->DrawMask(aPt1, aBitmapAlien, aBlackColor);
458 /* void DrawMask( const Point& rDestPt,
459 const Bitmap& rBitmap, const Color& rMaskColor );
461 add(res,
462 "DrawMask",
463 [&] (OutputDevice * pDev) {
464 return pDev->DrawMask(aPt1, aBitmap, aBlackColor);
467 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
468 const Bitmap& rBitmap, const Color& rMaskColor );
470 add(res,
471 "DrawMask(scaled,alien source)",
472 [&] (OutputDevice * pDev) {
473 return pDev->DrawMask(aPt1, aRect.GetSize(), aBitmapAlien, aBlackColor);
476 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
477 const Bitmap& rBitmap, const Color& rMaskColor );
479 add(res,
480 "DrawMask(scaled)",
481 [&] (OutputDevice * pDev) {
482 return pDev->DrawMask(aPt1, aRect.GetSize(), aBitmap, aBlackColor);
485 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
486 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
487 const Bitmap& rBitmap, const Color& rMaskColor );
489 add(res,
490 "DrawMask(scaled subset,alien source)",
491 [&] (OutputDevice * pDev) {
492 return pDev->DrawMask(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(),
493 aBitmapAlien, aBlackColor);
496 /* void DrawMask( const Point& rDestPt, const Size& rDestSize,
497 const Point& rSrcPtPixel, const Size& rSrcSizePixel,
498 const Bitmap& rBitmap, const Color& rMaskColor );
500 add(res,
501 "DrawMask(scaled subset)",
502 [&] (OutputDevice * pDev) {
503 return pDev->DrawMask(aPt1, aRect.GetSize(), aPt3, aRect2.GetSize(), aBitmap, aBlackColor);
506 /* void DrawImage( const Point& rPos,
507 const Image& rImage, sal_uInt16 nStyle = 0 );
509 add(res,
510 "DrawImage",
511 [&] (OutputDevice * pDev) {
512 return pDev->DrawImage(aPt1, aImage, static_cast<sal_uInt16>(0));
515 /* void DrawImage( const Point& rPos, const Size& rSize,
516 const Image& rImage, sal_uInt16 nStyle = 0 );
518 add(res,
519 "DrawImage(scaled)",
520 [&] (OutputDevice * pDev) {
521 return pDev->DrawImage(aPt1, aRect.GetSize(), aImage, static_cast<sal_uInt16>(0)));
524 #endif // NEEDS_QUALITY_PARAMETER
526 /* void DrawGradient( const Rectangle& rRect, const Gradient& rGradient ); */
527 add(res,
528 "DrawGradient",
529 [&] (OutputDevice * pDev) {
530 return pDev->DrawGradient(aRect, aGradient);
533 /* void DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient ); */
534 add(res,
535 "DrawGradient(polygon)",
536 [&] (OutputDevice * pDev) {
537 return pDev->DrawGradient(aPoly3, aGradient);
540 /* void DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& rHatch ); */
541 add(res,
542 "DrawHatch",
543 [&] (OutputDevice * pDev) {
544 return pDev->DrawHatch(aPoly3, aHatch);
547 /* void DrawWallpaper( const Rectangle& rRect, const Wallpaper& rWallpaper ); */
548 add(res,
549 "DrawWallpaper",
550 [&] (OutputDevice * pDev) {
551 return pDev->DrawWallpaper(aRect2, aWallpaper);
554 /* void DrawGrid( const Rectangle& rRect, const Size& rDist, sal_uLong nFlags ); */
555 add(res,
556 "DrawGrid",
557 [&] (OutputDevice * pDev) {
558 return pDev->DrawGrid(aRect, Size(10,20), DrawGridFlags::HorzLines|DrawGridFlags::VertLines);
561 /* void DrawTransparent( const tools::PolyPolygon& rPolyPoly,
562 sal_uInt16 nTransparencePercent );
564 add(res,
565 "DrawTransparent",
566 [&] (OutputDevice * pDev) {
567 return pDev->DrawTransparent(aPoly3, sal_uInt16(50));
570 /* void DrawTransparent( const GDIMetaFile& rMtf,
571 const Point& rPos, const Size& rSize,
572 const Gradient& rTransparenceGradient );
574 add(res,
575 "DrawTransparent(metafile)",
576 [&] (OutputDevice * pDev) {
577 return pDev->DrawTransparent(aMtf, aPt1, aRect.GetSize(), aGradient);
580 /* void Erase(); */
581 add(res,
582 "Erase",
583 [] (OutputDevice * pDev) { return pDev->Erase(); } );
587 void grindFunc( OutputDevice& rTarget,
588 functor_vector_type::const_iterator const & iter,
589 sal_Int32 nTurns,
590 const char* pMsg )
592 const sal_uInt32 nStartTime( osl_getGlobalTimer() );
594 for( sal_Int32 i=0; i<nTurns; ++i )
595 iter->second(&rTarget);
597 if( rTarget.GetOutDevType() == OUTDEV_WINDOW )
598 static_cast< vcl::Window & >( rTarget ).Flush();
600 fprintf( stdout,
601 "Duration: %d ms (%d repetitions)\tOperation: %s\tSetup: %s\n",
602 static_cast<int>(osl_getGlobalTimer() - nStartTime),
603 static_cast<int>(nTurns),
604 iter->first,
605 pMsg );
608 /** Call OutputDevice render methods repeatedly, and output elapsed
609 time to stdout
611 void outDevGrind(vcl::RenderContext& rTarget)
613 sal_Int32 nTurns = 100;
614 // TODO(F1): also profile pure complex clip setup times!
616 // State: fill/line color, draw mode, w/o clip, rect clip, complex clip
617 functor_vector_type aMethods;
618 setupMethodStubs( aMethods );
620 const tools::Rectangle aClipRect(10,10,1000,1000);
621 const tools::Polygon aPoly1( aClipRect );
622 tools::Polygon aPoly2( aClipRect );
623 aPoly2.Rotate(aClipRect.Center(),450);
624 tools::PolyPolygon aClipPoly(aPoly1);
625 aClipPoly.Insert(aPoly2);
627 functor_vector_type::const_iterator iter = aMethods.begin();
628 const functor_vector_type::const_iterator end = aMethods.end();
629 while( iter != end )
631 rTarget.SetLineColor( COL_BLACK );
632 rTarget.SetFillColor( COL_GREEN );
633 rTarget.SetRasterOp( RasterOp::OverPaint );
634 rTarget.SetClipRegion();
635 grindFunc( rTarget, iter, nTurns, "w/o clip, w/o xor" );
637 rTarget.SetLineColor( COL_BLACK );
638 rTarget.SetFillColor( COL_GREEN );
639 rTarget.SetRasterOp( RasterOp::OverPaint );
640 rTarget.SetClipRegion( vcl::Region( aClipRect ) );
641 grindFunc( rTarget, iter, nTurns, "with rect clip, w/o xor" );
643 rTarget.SetLineColor( COL_BLACK );
644 rTarget.SetFillColor( COL_GREEN );
645 rTarget.SetRasterOp( RasterOp::OverPaint );
646 rTarget.SetClipRegion( vcl::Region( aClipPoly ) );
647 grindFunc( rTarget, iter, nTurns, "with complex clip, w/o xor" );
649 rTarget.SetLineColor( COL_BLACK );
650 rTarget.SetFillColor( COL_GREEN );
651 rTarget.SetRasterOp( RasterOp::Xor );
652 rTarget.SetClipRegion();
653 grindFunc( rTarget, iter, nTurns, "w/o clip, with xor" );
655 rTarget.SetLineColor( COL_BLACK );
656 rTarget.SetFillColor( COL_GREEN );
657 rTarget.SetRasterOp( RasterOp::Xor );
658 rTarget.SetClipRegion( vcl::Region( aClipRect ) );
659 grindFunc( rTarget, iter, nTurns, "with rect clip, with xor" );
661 rTarget.SetLineColor( COL_BLACK );
662 rTarget.SetFillColor( COL_GREEN );
663 rTarget.SetRasterOp( RasterOp::Xor );
664 rTarget.SetClipRegion( vcl::Region( aClipPoly ) );
665 grindFunc( rTarget, iter, nTurns, "with complex clip, with xor" );
667 ++iter;
671 void TestWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
673 outDevGrind(rRenderContext);
674 fflush(stdout);
677 void GrindApp::Exception( ExceptionCategory nCategory )
679 switch( nCategory )
681 case ExceptionCategory::ResourceNotLoaded:
682 Abort( "Error: could not load language resources.\nPlease check your installation.\n" );
683 break;
684 default: break;
688 int GrindApp::Main()
690 ScopedVclPtrInstance<TestWindow> aWindow;
691 aWindow->Execute();
692 return 0;
695 } // namespace
698 SAL_IMPLEMENT_MAIN()
702 bool bHelp = false;
704 for( sal_uInt16 i = 0; i < Application::GetCommandLineParamCount(); i++ )
706 OUString aParam = Application::GetCommandLineParam( i );
708 if( aParam == "--help" || aParam == "-h" )
709 bHelp = true;
712 if( bHelp )
714 printf( "outdevgrind - Profile OutputDevice\n" );
715 return EXIT_SUCCESS;
718 tools::extendApplicationEnvironment();
720 uno::Reference< uno::XComponentContext > xContext = cppu::defaultBootstrap_InitialComponentContext();
721 uno::Reference< lang::XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), uno::UNO_QUERY );
723 if( !xServiceManager.is() )
724 Application::Abort( "Failed to bootstrap" );
726 comphelper::setProcessServiceFactory( xServiceManager );
728 InitVCL();
730 GrindApp aGrindApp;
731 aGrindApp.Main();
733 DeInitVCL();
735 catch (const css::uno::Exception&)
737 TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
738 return EXIT_FAILURE;
740 catch (const std::exception& e)
742 SAL_WARN("vcl.app", "Fatal: " << e.what());
743 return EXIT_FAILURE;
746 return EXIT_SUCCESS;
749 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */