diff options
author | Pierre Ossman <ossman@cendio.se> | 2014-01-27 16:52:35 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2014-07-07 13:27:08 +0200 |
commit | 947b48de71e03df2df7010c5760766b93483c9e5 (patch) | |
tree | 1fa5b92d8d5bb3518f631458de79fc719ec0ab98 /vncviewer | |
parent | 0dff4b8b45574191200950a14e5bdd35f0435099 (diff) | |
download | tigervnc-947b48de71e03df2df7010c5760766b93483c9e5.tar.gz tigervnc-947b48de71e03df2df7010c5760766b93483c9e5.zip |
Remove some premature optimisation
Reduces header dependencies.
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/CConn.cxx | 1 | ||||
-rw-r--r-- | vncviewer/CConn.h | 4 | ||||
-rw-r--r-- | vncviewer/DesktopWindow.cxx | 22 | ||||
-rw-r--r-- | vncviewer/DesktopWindow.h | 28 | ||||
-rw-r--r-- | vncviewer/Viewport.cxx | 57 | ||||
-rw-r--r-- | vncviewer/Viewport.h | 66 |
6 files changed, 104 insertions, 74 deletions
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx index cf963f0f..c5cd4a45 100644 --- a/vncviewer/CConn.cxx +++ b/vncviewer/CConn.cxx @@ -44,6 +44,7 @@ #include "CConn.h" #include "OptionsDialog.h" +#include "DesktopWindow.h" #include "i18n.h" #include "parameters.h" #include "vncviewer.h" diff --git a/vncviewer/CConn.h b/vncviewer/CConn.h index 33dcf4ab..286a09ed 100644 --- a/vncviewer/CConn.h +++ b/vncviewer/CConn.h @@ -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 diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index 40d08ae2..2a2f8734 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -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. diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h index fefdd35b..06f25f55 100644 --- a/vncviewer/DesktopWindow.h +++ b/vncviewer/DesktopWindow.h @@ -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); diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index d784a421..0ac76024 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -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", diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h index 59839dcb..e83a14ba 100644 --- a/vncviewer/Viewport.h +++ b/vncviewer/Viewport.h @@ -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); |