From 7ddb522ec2040eb0fb6472b104a19c727350ef7e Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 6 Dec 2015 13:16:48 +0100 Subject: [PATCH] Extend benchmarks of drawing bitmaps on wxMemoryDC Extended tests to determine speed of drawing RGB/ARGB bitmaps on target bitmaps with different colour depths (RGB/0RGB/ARGB/system default). See #16766. --- tests/benchmarks/graphics.cpp | 59 ++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/tests/benchmarks/graphics.cpp b/tests/benchmarks/graphics.cpp index 16fb7399ea..fd4a471808 100644 --- a/tests/benchmarks/graphics.cpp +++ b/tests/benchmarks/graphics.cpp @@ -137,7 +137,9 @@ public: Connect(wxEVT_SIZE, wxSizeEventHandler(GraphicsBenchmarkFrame::OnSize)); - m_bitmap.Create(64, 64, 32); + m_bitmapARGB.Create(64, 64, 32); + m_bitmapARGB.UseAlpha(true); + m_bitmapRGB.Create(64, 64, 24); Show(); } @@ -228,10 +230,33 @@ private: if ( opts.useMemory ) { - wxBitmap bmp(opts.width, opts.height); - wxMemoryDC dc(bmp); - wxGCDC gcdc(dc); - BenchmarkDCAndGC("memory", dc, gcdc); + { + wxBitmap bmp(opts.width, opts.height); + wxMemoryDC dc(bmp); + wxGCDC gcdc(dc); + BenchmarkDCAndGC("default memory", dc, gcdc); + } + { + wxBitmap bmp(opts.width, opts.height, 24); + wxMemoryDC dc(bmp); + wxGCDC gcdc(dc); + BenchmarkDCAndGC("RGB memory", dc, gcdc); + } + { + wxBitmap bmp(opts.width, opts.height, 32); + bmp.UseAlpha(false); + wxMemoryDC dc(bmp); + wxGCDC gcdc(dc); + BenchmarkDCAndGC("0RGB memory", dc, gcdc); + } + { + wxBitmap bmp(opts.width, opts.height, 32); + bmp.UseAlpha(true); + wxMemoryDC dc(bmp); + wxGCDC gcdc(dc); + BenchmarkDCAndGC("ARGB memory", dc, gcdc); + } + } wxTheApp->ExitMainLoop(); @@ -337,13 +362,30 @@ private: int x = rand() % opts.width, y = rand() % opts.height; - dc.DrawBitmap(m_bitmap, x, y, true); + dc.DrawBitmap(m_bitmapARGB, x, y, true); } const long t = sw.Time(); - wxPrintf("%ld bitmaps done in %ldms = %gus/bitmap\n", + wxPrintf("%ld ARGB bitmaps done in %ldms = %gus/bitmap\n", opts.numIters, t, (1000. * t)/opts.numIters); + + wxPrintf("Benchmarking %s: ", msg); + fflush(stdout); + + sw.Start(); + for ( int n = 0; n < opts.numIters; n++ ) + { + int x = rand() % opts.width, + y = rand() % opts.height; + + dc.DrawBitmap(m_bitmapRGB, x, y, true); + } + const long t2 = sw.Time(); + + wxPrintf("%ld RGB bitmaps done in %ldms = %gus/bitmap\n", + opts.numIters, t2, (1000. * t2)/opts.numIters); + } void BenchmarkImages(const wxString& msg, wxDC& dc) @@ -422,7 +464,8 @@ private: } - wxBitmap m_bitmap; + wxBitmap m_bitmapARGB; + wxBitmap m_bitmapRGB; #if wxUSE_GLCANVAS wxGLCanvas* m_glCanvas; wxGLContext* m_glContext;