From 8c14cbc98c1bb94c1f5a264694b8cf439b4f7729 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 5 Feb 2013 20:47:00 +0000 Subject: [PATCH] Allow selecting the kinds of DC to test in the graphics benchmark too. Still run all the tests by default but allow specifying --dc or --gc as well as --paint, --client or --memory to test just the specified kinds of DCs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/benchmarks/graphics.cpp | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/tests/benchmarks/graphics.cpp b/tests/benchmarks/graphics.cpp index 06a4725..5ee2628 100644 --- a/tests/benchmarks/graphics.cpp +++ b/tests/benchmarks/graphics.cpp @@ -32,6 +32,13 @@ struct GraphicsBenchmarkOptions testBitmaps = testLines = testRectangles = false; + + usePaint = + useClient = + useMemory = false; + + useDC = + useGC = false; } long mapMode, @@ -43,6 +50,13 @@ struct GraphicsBenchmarkOptions bool testBitmaps, testLines, testRectangles; + + bool usePaint, + useClient, + useMemory; + + bool useDC, + useGC; } opts; class GraphicsBenchmarkFrame : public wxFrame @@ -63,18 +77,21 @@ public: private: void OnPaint(wxPaintEvent& WXUNUSED(event)) { + if ( opts.usePaint ) { wxPaintDC dc(this); wxGCDC gcdc(dc); BenchmarkDCAndGC("paint", dc, gcdc); } + if ( opts.useClient ) { wxClientDC dc(this); wxGCDC gcdc(dc); BenchmarkDCAndGC("client", dc, gcdc); } + if ( opts.useMemory ) { wxBitmap bmp(opts.width, opts.height); wxMemoryDC dc(bmp); @@ -87,8 +104,10 @@ private: void BenchmarkDCAndGC(const char* dckind, wxDC& dc, wxGCDC& gcdc) { - BenchmarkAll(wxString::Format("%6s DC", dckind), dc); - BenchmarkAll(wxString::Format("%6s GC", dckind), gcdc); + if ( opts.useDC ) + BenchmarkAll(wxString::Format("%6s DC", dckind), dc); + if ( opts.useGC ) + BenchmarkAll(wxString::Format("%6s GC", dckind), gcdc); } void BenchmarkAll(const wxString& msg, wxDC& dc) @@ -204,6 +223,11 @@ public: { wxCMD_LINE_SWITCH, "", "bitmaps" }, { wxCMD_LINE_SWITCH, "", "lines" }, { wxCMD_LINE_SWITCH, "", "rectangles" }, + { wxCMD_LINE_SWITCH, "", "paint" }, + { wxCMD_LINE_SWITCH, "", "client" }, + { wxCMD_LINE_SWITCH, "", "memory" }, + { wxCMD_LINE_SWITCH, "", "dc" }, + { wxCMD_LINE_SWITCH, "", "gc" }, { wxCMD_LINE_OPTION, "m", "map-mode", "", wxCMD_LINE_VAL_NUMBER }, { wxCMD_LINE_OPTION, "p", "pen-width", "", wxCMD_LINE_VAL_NUMBER }, { wxCMD_LINE_OPTION, "w", "width", "", wxCMD_LINE_VAL_NUMBER }, @@ -240,6 +264,24 @@ public: opts.testRectangles = true; } + opts.usePaint = parser.Found("paint"); + opts.useClient = parser.Found("client"); + opts.useMemory = parser.Found("memory"); + if ( !(opts.usePaint || opts.useClient || opts.useMemory) ) + { + opts.usePaint = + opts.useClient = + opts.useMemory = true; + } + + opts.useDC = parser.Found("dc"); + opts.useGC = parser.Found("gc"); + if ( !(opts.useDC || opts.useGC) ) + { + opts.useDC = + opts.useGC = true; + } + return true; } -- 2.7.4