menukey.cxx
CConn.cxx
DesktopWindow.cxx
+ FLTKPixelBuffer.cxx
UserDialog.cxx
ServerDialog.cxx
OptionsDialog.cxx
+ PlatformPixelBuffer.cxx
Viewport.cxx
parameters.cxx
keysym2ucs.c
--- /dev/null
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#include <FL/fl_draw.H>
+
+#include <rfb/Exception.h>
+
+#include "FLTKPixelBuffer.h"
+
+FLTKPixelBuffer::FLTKPixelBuffer(int width, int height) :
+ PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true,
+ 255, 255, 255, 0, 8, 16),
+ width, height, NULL)
+{
+ data = new rdr::U8[width * height * format.bpp/8];
+ if (data == NULL)
+ throw rfb::Exception("Error: Not enough memory for framebuffer");
+}
+
+FLTKPixelBuffer::~FLTKPixelBuffer()
+{
+ delete [] data;
+}
+
+void FLTKPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
+{
+ int pixel_bytes, stride_bytes;
+ const uchar *buf_start;
+
+ pixel_bytes = format.bpp/8;
+ stride_bytes = pixel_bytes * getStride();
+ buf_start = data +
+ pixel_bytes * src_x +
+ stride_bytes * src_y;
+
+ fl_draw_image(buf_start, x, y, w, h, pixel_bytes, stride_bytes);
+}
--- /dev/null
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#ifndef __FLTKPIXELBUFFER_H__
+#define __FLTKPIXELBUFFER_H__
+
+#include "PlatformPixelBuffer.h"
+
+class FLTKPixelBuffer: public PlatformPixelBuffer {
+public:
+ FLTKPixelBuffer(int width, int height);
+ ~FLTKPixelBuffer();
+
+ virtual void draw(int src_x, int src_y, int x, int y, int w, int h);
+};
+
+
+#endif
-/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
using namespace rfb;
-static rfb::LogWriter vlog("PlatformPixelBuffer");
+static rfb::LogWriter vlog("OSXPixelBuffer");
-PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) :
- ManagedPixelBuffer(rfb::PixelFormat(32, 24, false, true,
- 255, 255, 255, 16, 8, 0),
- width, height),
+OSXPixelBuffer::OSXPixelBuffer(int width, int height) :
+ PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true,
+ 255, 255, 255, 16, 8, 0),
+ width, height, NULL),
bitmap(NULL)
{
CGColorSpaceRef lut;
+ data = new rdr::U8[width * height * format.bpp/8];
+ if (data == NULL)
+ throw rfb::Exception("Error: Not enough memory for framebuffer");
+
lut = CGColorSpaceCreateDeviceRGB();
assert(lut);
}
-PlatformPixelBuffer::~PlatformPixelBuffer()
+OSXPixelBuffer::~OSXPixelBuffer()
{
CFRelease((CGContextRef)bitmap);
+ delete [] data;
}
-void PlatformPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
+void OSXPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
{
CGRect rect;
CGContextRef gc;
-/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifndef __OSXPIXELBUFFER_H__
#define __OSXPIXELBUFFER_H__
-#include <rfb/PixelBuffer.h>
+#include "PlatformPixelBuffer.h"
-class PlatformPixelBuffer: public rfb::ManagedPixelBuffer {
+class OSXPixelBuffer: public PlatformPixelBuffer {
public:
- PlatformPixelBuffer(int width, int height);
- ~PlatformPixelBuffer();
+ OSXPixelBuffer(int width, int height);
+ ~OSXPixelBuffer();
- void draw(int src_x, int src_y, int x, int y, int w, int h);
+ virtual void draw(int src_x, int src_y, int x, int y, int w, int h);
protected:
// This is really a CGContextRef, but Apple headers conflict with FLTK
--- /dev/null
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#include "PlatformPixelBuffer.h"
+
+PlatformPixelBuffer::PlatformPixelBuffer(const rfb::PixelFormat& pf,
+ int width, int height,
+ rdr::U8* data) :
+ FullFramePixelBuffer(pf, width, height, data)
+{
+}
-/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <rfb/PixelBuffer.h>
-#include <FL/fl_draw.H>
-
-class PlatformPixelBuffer: public rfb::ManagedPixelBuffer {
+class PlatformPixelBuffer: public rfb::FullFramePixelBuffer {
public:
- PlatformPixelBuffer(int width, int height) :
- rfb::ManagedPixelBuffer(rfb::PixelFormat(32, 24, false, true,
- 255, 255, 255, 0, 8, 16),
- width, height)
- {};
-
- inline void draw(int src_x, int src_y, int x, int y, int w, int h);
-};
+ PlatformPixelBuffer(const rfb::PixelFormat& pf, int width, int height,
+ rdr::U8* data);
-inline void PlatformPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
-{
- int pixel_bytes, stride_bytes;
- const uchar *buf_start;
+ virtual void draw(int src_x, int src_y, int x, int y, int w, int h) = 0;
- pixel_bytes = getPF().bpp/8;
- stride_bytes = pixel_bytes * getStride();
- buf_start = data +
- pixel_bytes * src_x +
- stride_bytes * src_y;
-
- fl_draw_image(buf_start, x, y, w, h, pixel_bytes, stride_bytes);
-}
+protected:
+ int stride;
+};
#endif
#include "menukey.h"
#include "vncviewer.h"
+#include "PlatformPixelBuffer.h"
+#include "FLTKPixelBuffer.h"
+
#if defined(WIN32)
#include "Win32PixelBuffer.h"
#elif defined(__APPLE__)
#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>
Fl::add_clipboard_notify(handleClipboardChange, this);
#endif
- frameBuffer = new PlatformPixelBuffer(w, h);
+ frameBuffer = createFramebuffer(w, h);
assert(frameBuffer);
setServerPF(serverPF);
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,
}
+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;
private:
+ PlatformPixelBuffer* createFramebuffer(int w, int h);
+
static void handleUpdateTimeout(void *data);
static void handleClipboardChange(int source, void *data);
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ * Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
using namespace rfb;
-static rfb::LogWriter vlog("PlatformPixelBuffer");
+static rfb::LogWriter vlog("Win32PixelBuffer");
-PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) :
- FullFramePixelBuffer(rfb::PixelFormat(32, 24, false, true,
- 255, 255, 255, 16, 8, 0),
- width, height, NULL),
+Win32PixelBuffer::Win32PixelBuffer(int width, int height) :
+ PlatformPixelBuffer(rfb::PixelFormat(32, 24, false, true,
+ 255, 255, 255, 16, 8, 0),
+ width, height, NULL),
bitmap(NULL)
{
BITMAPINFOHEADER bih;
}
-PlatformPixelBuffer::~PlatformPixelBuffer()
+Win32PixelBuffer::~Win32PixelBuffer()
{
DeleteObject(bitmap);
}
-void PlatformPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
+void Win32PixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
{
HDC dc;
-/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <windows.h>
-#include <rfb/PixelBuffer.h>
+#include "PlatformPixelBuffer.h"
-class PlatformPixelBuffer: public rfb::FullFramePixelBuffer {
+class Win32PixelBuffer: public PlatformPixelBuffer {
public:
- PlatformPixelBuffer(int width, int height);
- ~PlatformPixelBuffer();
+ Win32PixelBuffer(int width, int height);
+ ~Win32PixelBuffer();
- void draw(int src_x, int src_y, int x, int y, int w, int h);
+ virtual void draw(int src_x, int src_y, int x, int y, int w, int h);
protected:
HBITMAP bitmap;
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- * Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ * Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
using namespace rfb;
-static rfb::LogWriter vlog("PlatformPixelBuffer");
+static rfb::LogWriter vlog("X11PixelBuffer");
static PixelFormat display_pf()
{
redShift, greenShift, blueShift);
}
-PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) :
- FullFramePixelBuffer(display_pf(), width, height, NULL),
+X11PixelBuffer::X11PixelBuffer(int width, int height) :
+ PlatformPixelBuffer(display_pf(), width, height, NULL),
shminfo(NULL), xim(NULL)
{
// Might not be open at this point
}
-PlatformPixelBuffer::~PlatformPixelBuffer()
+X11PixelBuffer::~X11PixelBuffer()
{
if (shminfo) {
vlog.debug("Freeing shared memory XImage");
}
-void PlatformPixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
+void X11PixelBuffer::draw(int src_x, int src_y, int x, int y, int w, int h)
{
if (shminfo)
XShmPutImage(fl_display, fl_window, fl_gc, xim, src_x, src_y, x, y, w, h, False);
}
-int PlatformPixelBuffer::getStride() const
+int X11PixelBuffer::getStride() const
{
return xim->bytes_per_line / (getPF().bpp/8);
}
return 0;
}
-int PlatformPixelBuffer::setupShm()
+int X11PixelBuffer::setupShm()
{
int major, minor;
Bool pixmaps;
-/* Copyright 2011 Pierre Ossman <ossman@cendio.se> for Cendio AB
+/* Copyright 2011-2014 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
-#include <rfb/PixelBuffer.h>
+#include "PlatformPixelBuffer.h"
-class PlatformPixelBuffer: public rfb::FullFramePixelBuffer {
+class X11PixelBuffer: public PlatformPixelBuffer {
public:
- PlatformPixelBuffer(int width, int height);
- ~PlatformPixelBuffer();
+ X11PixelBuffer(int width, int height);
+ ~X11PixelBuffer();
- void draw(int src_x, int src_y, int x, int y, int w, int h);
+ virtual void draw(int src_x, int src_y, int x, int y, int w, int h);
int getStride() const;