aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer/Viewport.cxx
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2014-02-07 14:46:26 +0100
committerPierre Ossman <ossman@cendio.se>2014-07-07 14:50:28 +0200
commitac13abe4ce9f74522acd9697a08dc56de8e2949f (patch)
tree4eb0fdaa6cf22d0e06f63b9cb1a03063f5f21c27 /vncviewer/Viewport.cxx
parent668468b3d43d5ea1562ebc0be8de0c98c5601a60 (diff)
downloadtigervnc-ac13abe4ce9f74522acd9697a08dc56de8e2949f.tar.gz
tigervnc-ac13abe4ce9f74522acd9697a08dc56de8e2949f.zip
Create a proper interface base class for the viewport's framebuffer
This allows us to gracefully fall back to the FLTK code in case the platform specific code cannot be used.
Diffstat (limited to 'vncviewer/Viewport.cxx')
-rw-r--r--vncviewer/Viewport.cxx32
1 files changed, 25 insertions, 7 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index a7296e9a..a930cf89 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -51,6 +51,9 @@
#include "menukey.h"
#include "vncviewer.h"
+#include "PlatformPixelBuffer.h"
+#include "FLTKPixelBuffer.h"
+
#if defined(WIN32)
#include "Win32PixelBuffer.h"
#elif defined(__APPLE__)
@@ -59,11 +62,6 @@
#include "X11PixelBuffer.h"
#endif
-// We also have a generic version of the above, using pure FLTK:
-//
-// #include "PlatformPixelBuffer.h"
-//
-
#include <FL/fl_draw.H>
#include <FL/fl_ask.H>
@@ -100,7 +98,7 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& serverPF, CConn* cc_)
Fl::add_clipboard_notify(handleClipboardChange, this);
#endif
- frameBuffer = new PlatformPixelBuffer(w, h);
+ frameBuffer = createFramebuffer(w, h);
assert(frameBuffer);
setServerPF(serverPF);
@@ -358,7 +356,7 @@ void Viewport::resize(int x, int y, int w, int h)
vlog.debug("Resizing framebuffer from %dx%d to %dx%d",
frameBuffer->width(), frameBuffer->height(), w, h);
- newBuffer = new PlatformPixelBuffer(w, h);
+ newBuffer = createFramebuffer(w, h);
assert(newBuffer);
rect.setXYWH(0, 0,
@@ -500,6 +498,26 @@ int Viewport::handle(int event)
}
+PlatformPixelBuffer* Viewport::createFramebuffer(int w, int h)
+{
+ PlatformPixelBuffer *fb;
+
+ 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);
+ }
+
+ return fb;
+}
+
+
void Viewport::handleUpdateTimeout(void *data)
{
Viewport *self = (Viewport *)data;