]> git.tdb.fi Git - libs/gui.git/commitdiff
Drop the DrawContext class
authorMikko Rasa <tdb@tdb.fi>
Sun, 12 Oct 2014 14:18:57 +0000 (17:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 12 Oct 2014 14:18:57 +0000 (17:18 +0300)
I've never actually used it, and 2D graphics are all but dead.  I don't
have any real interest of implementing it on other platforms either.

source/graphics/drawcontext.h [deleted file]
source/graphics/windows/drawcontext.cpp [deleted file]
source/graphics/x11/drawcontext.cpp [deleted file]

diff --git a/source/graphics/drawcontext.h b/source/graphics/drawcontext.h
deleted file mode 100644 (file)
index 957e153..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef MSP_GRAPHICS_DRAWCONTEXT_H_
-#define MSP_GRAPHICS_DRAWCONTEXT_H_
-
-namespace Msp {
-namespace Graphics {
-
-class Display;
-class Window;
-
-class DrawContext
-{
-private:
-       struct Private;
-
-       Display &display;
-       Window &window;
-       Private *priv;
-
-public:
-       DrawContext(Window &);
-       ~DrawContext();
-
-       Window &get_window() const { return window; }
-       unsigned get_depth() const;
-       unsigned char *get_data();
-       void update();
-};
-
-} // namespace Graphics
-} // namespace Msp
-
-#endif
diff --git a/source/graphics/windows/drawcontext.cpp b/source/graphics/windows/drawcontext.cpp
deleted file mode 100644 (file)
index b887615..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <stdexcept>
-#include "drawcontext.h"
-#include "window.h"
-
-using namespace std;
-
-namespace Msp {
-namespace Graphics {
-
-DrawContext::DrawContext(Window &w):
-       display(w.get_display()),
-       window(w)
-{
-       throw runtime_error("no DrawContext support on windows");
-}
-
-DrawContext::~DrawContext()
-{ }
-
-unsigned DrawContext::get_depth() const
-{
-       return 0;
-}
-
-unsigned char *DrawContext::get_data()
-{
-       return 0;
-}
-
-void DrawContext::update()
-{ }
-
-} // namespace Graphics
-} // namespace Msp
diff --git a/source/graphics/x11/drawcontext.cpp b/source/graphics/x11/drawcontext.cpp
deleted file mode 100644 (file)
index e40390f..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <stdexcept>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <X11/Xutil.h>
-#include "display_private.h"
-#include "drawcontext.h"
-#include "window_private.h"
-
-using namespace std;
-
-namespace Msp {
-namespace Graphics {
-
-struct DrawContext::Private
-{
-       XImage *image;
-       bool use_shm;
-       XShmSegmentInfo shminfo;
-};
-
-DrawContext::DrawContext(Window &w):
-       display(w.get_display()),
-       window(w),
-       priv(new Private)
-{
-       DisplayHandle dpy = display.get_private().display;
-
-       priv->use_shm = XShmQueryExtension(dpy);
-
-       XWindowAttributes wa;
-       XGetWindowAttributes(dpy, window.get_private().window, &wa);
-
-       if(priv->use_shm)
-       {
-               priv->image = XShmCreateImage(dpy, wa.visual, wa.depth, ZPixmap, 0, &priv->shminfo, wa.width, wa.height);
-               if(!priv->image)
-                       throw runtime_error("XShmCreateImage");
-
-               priv->shminfo.shmid = shmget(IPC_PRIVATE, priv->image->bytes_per_line*priv->image->height, IPC_CREAT|0666);
-               priv->shminfo.shmaddr=priv->image->data = reinterpret_cast<char *>(shmat(priv->shminfo.shmid, 0, 0));
-               priv->shminfo.readOnly = false;
-
-               XShmAttach(dpy, &priv->shminfo);
-
-               XSync(dpy, false);
-               display.check_error();
-       }
-       else
-       {
-               priv->image = XCreateImage(dpy, wa.visual, wa.depth, ZPixmap, 0, 0, wa.width, wa.height, 8, 0);
-               if(!priv->image)
-                       throw runtime_error("XCreateImage");
-               priv->image->data = new char[priv->image->bytes_per_line*priv->image->height];
-       }
-}
-
-DrawContext::~DrawContext()
-{
-       if(priv->use_shm)
-       {
-               XShmDetach(display.get_private().display, &priv->shminfo);
-               shmdt(priv->shminfo.shmaddr);
-               shmctl(priv->shminfo.shmid, IPC_RMID, 0);
-       }
-
-       XDestroyImage(priv->image);
-
-       delete priv;
-}
-
-unsigned DrawContext::get_depth() const
-{
-       return priv->image->bits_per_pixel;
-}
-
-unsigned char *DrawContext::get_data()
-{
-       return reinterpret_cast<unsigned char *>(priv->image->data);
-}
-
-void DrawContext::update()
-{
-       DisplayHandle dpy = display.get_private().display;
-       WindowHandle wnd = window.get_private().window;
-
-       GC gc = XCreateGC(dpy, wnd, 0, 0);
-
-       if(priv->use_shm)
-               XShmPutImage(dpy, wnd, gc, priv->image, 0, 0, 0, 0, priv->image->width, priv->image->height, false);
-       else
-               XPutImage(dpy, wnd, gc, priv->image, 0, 0, 0, 0, priv->image->width, priv->image->height);
-
-       XFreeGC(dpy, gc);
-}
-
-} // namespace Graphics
-} // namespace Msp