aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fbperf.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2017-01-02 17:00:41 +0100
committerPierre Ossman <ossman@cendio.se>2017-02-10 17:02:13 +0100
commit403ac27d2377df4fed8bf5039125f6d89aaa6955 (patch)
tree00e740d165f0aedff234e50b2303581efe6805d5 /tests/fbperf.cxx
parent13548819fa30b58f8d007a367d48934c7f064914 (diff)
downloadtigervnc-403ac27d2377df4fed8bf5039125f6d89aaa6955.tar.gz
tigervnc-403ac27d2377df4fed8bf5039125f6d89aaa6955.zip
Abstract platform rendering to "surfaces"
This will allow us to render more things than just the framebuffer.
Diffstat (limited to 'tests/fbperf.cxx')
-rw-r--r--tests/fbperf.cxx94
1 files changed, 74 insertions, 20 deletions
diff --git a/tests/fbperf.cxx b/tests/fbperf.cxx
index 5c37b0f7..8c71d966 100644
--- a/tests/fbperf.cxx
+++ b/tests/fbperf.cxx
@@ -27,15 +27,6 @@
#include <rfb/util.h>
#include "../vncviewer/PlatformPixelBuffer.h"
-#include "../vncviewer/FLTKPixelBuffer.h"
-
-#if defined(WIN32)
-#include "../vncviewer/Win32PixelBuffer.h"
-#elif defined(__APPLE__)
-#include "../vncviewer/OSXPixelBuffer.h"
-#else
-#include "../vncviewer/X11PixelBuffer.h"
-#endif
#include "util.h"
@@ -70,6 +61,19 @@ protected:
virtual void changefb();
};
+class OverlayTestWindow: public PartialTestWindow {
+public:
+ OverlayTestWindow();
+
+ virtual void start(int width, int height);
+ virtual void stop();
+
+ virtual void draw();
+
+protected:
+ Surface* overlay;
+};
+
TestWindow::TestWindow() :
Fl_Window(0, 0, "Framebuffer Performance Test"),
fb(NULL)
@@ -93,17 +97,7 @@ void TestWindow::start(int width, int height)
frames = 0;
time = 0;
- try {
-#if defined(WIN32)
- fb = new Win32PixelBuffer(w(), h());
-#elif defined(__APPLE__)
- fb = new OSXPixelBuffer(w(), h());
-#else
- fb = new X11PixelBuffer(w(), h());
-#endif
- } catch (rdr::Exception& e) {
- fb = new FLTKPixelBuffer(w(), h());
- }
+ fb = new PlatformPixelBuffer(w(), h());
pixel = 0;
fb->fillRect(fb->getRect(), &pixel);
@@ -207,6 +201,60 @@ void PartialTestWindow::changefb()
fb->fillRect(r, &pixel);
}
+OverlayTestWindow::OverlayTestWindow() :
+ overlay(NULL)
+{
+}
+
+void OverlayTestWindow::start(int width, int height)
+{
+ PartialTestWindow::start(width, height);
+
+ overlay = new Surface(400, 200);
+ overlay->clear(0xff, 0x80, 0x00, 0xcc);
+}
+
+void OverlayTestWindow::stop()
+{
+ PartialTestWindow::stop();
+
+ delete overlay;
+ overlay = NULL;
+}
+
+void OverlayTestWindow::draw()
+{
+ int ox, oy, ow, oh;
+ int X, Y, W, H;
+
+ // Check what actually needs updating
+ fl_clip_box(0, 0, w(), h(), X, Y, W, H);
+ if ((W == 0) || (H == 0))
+ return;
+
+ PartialTestWindow::draw();
+
+ // We might get a redraw before we are fully ready
+ if (!overlay)
+ return;
+
+ // Simplify the clip region to a simple rectangle in order to
+ // properly draw all the layers even if they only partially overlap
+ fl_push_no_clip();
+ fl_push_clip(X, Y, W, H);
+
+ ox = (w() - overlay->width()) / 2;
+ oy = h() / 4 - overlay->height() / 2;
+ ow = overlay->width();
+ oh = overlay->height();
+ fl_clip_box(ox, oy, ow, oh, X, Y, W, H);
+ if ((W != 0) && (H != 0))
+ overlay->draw(X - ox, Y - oy, X, Y, W, H);
+
+ fl_pop_clip();
+ fl_pop_clip();
+}
+
static void dosubtest(TestWindow* win, int width, int height,
unsigned long long* pixels,
unsigned long long* frames,
@@ -311,5 +359,11 @@ int main(int argc, char** argv)
delete win;
fprintf(stderr, "\n");
+ fprintf(stderr, "Partial window update with overlay:\n\n");
+ win = new OverlayTestWindow();
+ dotest(win);
+ delete win;
+ fprintf(stderr, "\n");
+
return 0;
}