Browse Source

Remove some premature optimisation

Reduces header dependencies.
tags/v1.3.90
Pierre Ossman 10 years ago
parent
commit
947b48de71
6 changed files with 104 additions and 74 deletions
  1. 1
    0
      vncviewer/CConn.cxx
  2. 3
    1
      vncviewer/CConn.h
  3. 22
    0
      vncviewer/DesktopWindow.cxx
  4. 9
    19
      vncviewer/DesktopWindow.h
  5. 57
    0
      vncviewer/Viewport.cxx
  6. 12
    54
      vncviewer/Viewport.h

+ 1
- 0
vncviewer/CConn.cxx View File

@@ -44,6 +44,7 @@

#include "CConn.h"
#include "OptionsDialog.h"
#include "DesktopWindow.h"
#include "i18n.h"
#include "parameters.h"
#include "vncviewer.h"

+ 3
- 1
vncviewer/CConn.h View File

@@ -20,10 +20,12 @@
#ifndef __CCONN_H__
#define __CCONN_H__

#include <FL/Fl.H>

#include <rfb/CConnection.h>
#include <network/Socket.h>

#include "DesktopWindow.h"
class DesktopWindow;

class CConn : public rfb::CConnection,
public rdr::FdInStreamBlockCallback

+ 22
- 0
vncviewer/DesktopWindow.cxx View File

@@ -34,7 +34,9 @@
#include "parameters.h"
#include "vncviewer.h"
#include "CConn.h"
#include "Viewport.h"

#include <FL/Fl.H>
#include <FL/Fl_Scroll.H>
#include <FL/x.H>

@@ -220,6 +222,26 @@ void DesktopWindow::setColourMapEntries(int firstColour, int nColours,
viewport->setColourMapEntries(firstColour, nColours, rgbs);
}

void DesktopWindow::fillRect(const rfb::Rect& r, rfb::Pixel pix) {
viewport->fillRect(r, pix);
}

void DesktopWindow::imageRect(const rfb::Rect& r, void* pixels) {
viewport->imageRect(r, pixels);
}

void DesktopWindow::copyRect(const rfb::Rect& r, int srcX, int srcY) {
viewport->copyRect(r, srcX, srcY);
}

rdr::U8* DesktopWindow::getBufferRW(const rfb::Rect& r, int* stride) {
return viewport->getBufferRW(r, stride);
}

void DesktopWindow::damageRect(const rfb::Rect& r) {
viewport->damageRect(r);
}


// Copy the areas of the framebuffer that have been changed (damaged)
// to the displayed window.

+ 9
- 19
vncviewer/DesktopWindow.h View File

@@ -23,13 +23,13 @@
#include <map>

#include <rfb/Rect.h>
#include <rfb/Pixel.h>

#include "Viewport.h"

#include <FL/Fl.H>
#include <FL/Fl_Window.H>

class CConn;
class Viewport;

class Fl_Scroll;

class DesktopWindow : public Fl_Window {
@@ -52,22 +52,12 @@ public:

void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);

void fillRect(const rfb::Rect& r, rfb::Pixel pix) {
viewport->fillRect(r, pix);
}
void imageRect(const rfb::Rect& r, void* pixels) {
viewport->imageRect(r, pixels);
}
void copyRect(const rfb::Rect& r, int srcX, int srcY) {
viewport->copyRect(r, srcX, srcY);
}

rdr::U8* getBufferRW(const rfb::Rect& r, int* stride) {
return viewport->getBufferRW(r, stride);
}
void damageRect(const rfb::Rect& r) {
viewport->damageRect(r);
}
void fillRect(const rfb::Rect& r, rfb::Pixel pix);
void imageRect(const rfb::Rect& r, void* pixels);
void copyRect(const rfb::Rect& r, int srcX, int srcY);

rdr::U8* getBufferRW(const rfb::Rect& r, int* stride);
void damageRect(const rfb::Rect& r);

void resizeFramebuffer(int new_w, int new_h);


+ 57
- 0
vncviewer/Viewport.cxx View File

@@ -27,6 +27,7 @@

#include <rfb/CMsgWriter.h>
#include <rfb/LogWriter.h>
#include <rfb/PixelTransformer.h>

// FLTK can pull in the X11 headers on some systems
#ifndef XK_VoidSymbol
@@ -42,6 +43,7 @@
#include "Viewport.h"
#include "CConn.h"
#include "OptionsDialog.h"
#include "DesktopWindow.h"
#include "i18n.h"
#include "fltk_layout.h"
#include "parameters.h"
@@ -49,6 +51,19 @@
#include "menukey.h"
#include "vncviewer.h"

#if defined(WIN32)
#include "Win32PixelBuffer.h"
#elif defined(__APPLE__)
#include "OSXPixelBuffer.h"
#else
#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>

@@ -212,6 +227,48 @@ void Viewport::updateWindow()
damage.clear();
}

void Viewport::fillRect(const rfb::Rect& r, rfb::Pixel pix) {
if (pixelTrans) {
rfb::Pixel pix2;
if (colourMapChange)
commitColourMap();
pixelTrans->translatePixels(&pix, &pix2, 1);
pix = pix2;
}

frameBuffer->fillRect(r, pix);
damageRect(r);
}

void Viewport::imageRect(const rfb::Rect& r, void* pixels) {
if (pixelTrans) {
if (colourMapChange)
commitColourMap();
pixelTrans->translateRect(pixels, r.width(),
rfb::Rect(0, 0, r.width(), r.height()),
frameBuffer->data, frameBuffer->getStride(),
r.tl);
} else {
frameBuffer->imageRect(r, pixels);
}
damageRect(r);
}

void Viewport::copyRect(const rfb::Rect& r, int srcX, int srcY) {
frameBuffer->copyRect(r, rfb::Point(r.tl.x-srcX, r.tl.y-srcY));
damageRect(r);
}

rdr::U8* Viewport::getBufferRW(const rfb::Rect& r, int* stride) {
return frameBuffer->getBufferRW(r, stride);
}

void Viewport::damageRect(const rfb::Rect& r) {
damage.assign_union(rfb::Region(r));
if (!Fl::has_timeout(handleUpdateTimeout, this))
Fl::add_timeout(0.500, handleUpdateTimeout, this);
};

#ifdef HAVE_FLTK_CURSOR
static const char * dotcursor_xpm[] = {
"5 5 2 1",

+ 12
- 54
vncviewer/Viewport.h View File

@@ -22,29 +22,19 @@

#include <map>

#include <FL/Fl.H>
#include <FL/Fl_Widget.H>

#include <rfb/Region.h>
#include <rfb/PixelTransformer.h>

#if defined(WIN32)
#include "Win32PixelBuffer.h"
#elif defined(__APPLE__)
#include "OSXPixelBuffer.h"
#else
#include "X11PixelBuffer.h"
#endif

// We also have a generic version of the above, using pure FLTK:
//
// #include "PlatformPixelBuffer.h"
//
#include <rfb/Pixel.h>
#include <rfb/ColourMap.h>

class Fl_Menu_Button;
class Fl_RGB_Image;

namespace rfb { class PixelTransformer; }

class CConn;
class PlatformPixelBuffer;

class Viewport : public Fl_Widget {
public:
@@ -64,45 +54,13 @@ public:

void setColourMapEntries(int firstColour, int nColours, rdr::U16* rgbs);

void fillRect(const rfb::Rect& r, rfb::Pixel pix) {
if (pixelTrans) {
rfb::Pixel pix2;
if (colourMapChange)
commitColourMap();
pixelTrans->translatePixels(&pix, &pix2, 1);
pix = pix2;
}

frameBuffer->fillRect(r, pix);
damageRect(r);
}
void imageRect(const rfb::Rect& r, void* pixels) {
if (pixelTrans) {
if (colourMapChange)
commitColourMap();
pixelTrans->translateRect(pixels, r.width(),
rfb::Rect(0, 0, r.width(), r.height()),
frameBuffer->data, frameBuffer->getStride(),
r.tl);
} else {
frameBuffer->imageRect(r, pixels);
}
damageRect(r);
}
void copyRect(const rfb::Rect& r, int srcX, int srcY) {
frameBuffer->copyRect(r, rfb::Point(r.tl.x-srcX, r.tl.y-srcY));
damageRect(r);
}

rdr::U8* getBufferRW(const rfb::Rect& r, int* stride) {
return frameBuffer->getBufferRW(r, stride);
}

void damageRect(const rfb::Rect& r) {
damage.assign_union(rfb::Region(r));
if (!Fl::has_timeout(handleUpdateTimeout, this))
Fl::add_timeout(0.500, handleUpdateTimeout, this);
};
void fillRect(const rfb::Rect& r, rfb::Pixel pix);
void imageRect(const rfb::Rect& r, void* pixels);
void copyRect(const rfb::Rect& r, int srcX, int srcY);

rdr::U8* getBufferRW(const rfb::Rect& r, int* stride);

void damageRect(const rfb::Rect& r);

void setCursor(int width, int height, const rfb::Point& hotspot,
void* data, void* mask);

Loading…
Cancel
Save