From: Pierre Ossman Date: Mon, 27 Jan 2014 15:52:35 +0000 (+0100) Subject: Remove some premature optimisation X-Git-Tag: v1.3.90~48^2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=947b48de71e03df2df7010c5760766b93483c9e5;p=tigervnc.git Remove some premature optimisation Reduces header dependencies. --- 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 + #include #include -#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 #include #include @@ -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 #include +#include -#include "Viewport.h" - -#include #include 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 #include +#include // 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 #include @@ -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 -#include #include #include -#include - -#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 +#include 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);