diff options
-rw-r--r-- | client/Makefile.am | 18 | ||||
-rw-r--r-- | client/common.h | 2 | ||||
-rw-r--r-- | client/red_window.h | 6 | ||||
-rw-r--r-- | client/screen.cpp | 2 | ||||
-rw-r--r-- | client/screen.h | 6 | ||||
-rw-r--r-- | client/windows/red_window.cpp | 8 | ||||
-rw-r--r-- | client/x11/Makefile.am | 20 | ||||
-rw-r--r-- | client/x11/pixels_source_p.h | 26 | ||||
-rw-r--r-- | client/x11/platform.cpp | 18 | ||||
-rw-r--r-- | client/x11/red_drawable.cpp | 15 | ||||
-rw-r--r-- | client/x11/red_window.cpp | 35 | ||||
-rw-r--r-- | client/x11/red_window_p.h | 9 | ||||
-rw-r--r-- | client/x11/x_platform.h | 6 | ||||
-rw-r--r-- | configure.ac | 21 |
14 files changed, 137 insertions, 55 deletions
diff --git a/client/Makefile.am b/client/Makefile.am index 86d7c3e3..f700ed65 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -15,6 +15,17 @@ generated_marshallers.cpp: $(top_srcdir)/spice.proto generated_marshallers.h: $(top_srcdir)/spice.proto $(PYTHON) $(top_srcdir)/spice_codegen.py --generate-marshallers $(STRUCTS) --client -H $(top_srcdir)/spice.proto generated_marshallers.h +if SUPPORT_GL +GL_SRCS = \ + gl_canvas.cpp \ + glc.cpp \ + red_gl_canvas.cpp \ + red_gl_canvas.h \ + red_pixmap_gl.h +else +GL_SRCS = +endif + RED_COMMON_SRCS = \ application.cpp \ application.h \ @@ -46,10 +57,6 @@ RED_COMMON_SRCS = \ debug.h \ display_channel.cpp \ display_channel.h \ - red_gl_canvas.cpp \ - red_gl_canvas.h \ - gl_canvas.cpp \ - glc.cpp \ glz_decoded_image.h \ glz_decoder_config.h \ glz_decoder.cpp \ @@ -86,7 +93,6 @@ RED_COMMON_SRCS = \ red_peer.cpp \ red_peer.h \ red_pixmap_sw.h \ - red_pixmap_gl.h \ red_pixmap.h \ red_types.h \ red_window.h \ @@ -109,6 +115,6 @@ RED_COMMON_SRCS = \ MAINTAINERCLEANFILES = $(spice_built_sources) -EXTRA_DIST = $(RED_COMMON_SRCS) $(spice_built_sources) +EXTRA_DIST = $(RED_COMMON_SRCS) $(spice_built_sources) $(GL_SRCS) BUILT_SOURCES = $(spice_built_sources) diff --git a/client/common.h b/client/common.h index 83f0e85a..c0ce4424 100644 --- a/client/common.h +++ b/client/common.h @@ -45,8 +45,10 @@ #else #include <unistd.h> #include <X11/X.h> +#ifdef USE_OGL #include <GL/glx.h> #endif +#endif #ifdef __GNUC__ #if __SIZEOF_POINTER__ == 8 diff --git a/client/red_window.h b/client/red_window.h index a5eeb535..97f3b791 100644 --- a/client/red_window.h +++ b/client/red_window.h @@ -79,12 +79,12 @@ public: void set_render_pbuff(RedPbuffer pbuff); void set_render_fbo(GLuint fbo); void set_gl_context(RedGlContext context); -#endif - - int get_screen_num(); void set_type_gl(); void unset_type_gl(); +#endif + + int get_screen_num(); static void init(); static void cleanup(); diff --git a/client/screen.cpp b/client/screen.cpp index bc876467..75205719 100644 --- a/client/screen.cpp +++ b/client/screen.cpp @@ -915,6 +915,7 @@ void RedScreen::interrupt_update() _update_interrupt_trigger->trigger(); } +#ifdef USE_OGL void RedScreen::set_type_gl() { _window.set_type_gl(); @@ -924,4 +925,5 @@ void RedScreen::unset_type_gl() { _window.unset_type_gl(); } +#endif // USE_OGL diff --git a/client/screen.h b/client/screen.h index 8b737a2b..8d9a81c3 100644 --- a/client/screen.h +++ b/client/screen.h @@ -21,7 +21,9 @@ #include "common.h" #include "region.h" #include "red_key.h" +#ifdef USE_OGL #include "GL/gl.h" +#endif // USE_OGL #include "red_window.h" #include "platform.h" @@ -94,12 +96,12 @@ public: #ifdef USE_OGL void untouch_context(); bool need_recreate_context_gl(); + void set_type_gl(); + void unset_type_gl(); #endif void set_update_interrupt_trigger(EventSources::Trigger *trigger); bool update_by_interrupt(); void interrupt_update(); - void set_type_gl(); - void unset_type_gl(); void update(); diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp index 1be94ffe..4ca98fb8 100644 --- a/client/windows/red_window.cpp +++ b/client/windows/red_window.cpp @@ -825,14 +825,6 @@ void RedWindow::untouch_context() #endif -void RedWindow::set_type_gl() -{ -} - -void RedWindow::unset_type_gl() -{ -} - void RedWindow::on_focus_in() { _focused = true; diff --git a/client/x11/Makefile.am b/client/x11/Makefile.am index cbc9c529..3d90e9f0 100644 --- a/client/x11/Makefile.am +++ b/client/x11/Makefile.am @@ -9,7 +9,6 @@ INCLUDES = \ -DSW_CANVAS_CACHE \ -DSW_CANVAS_NO_CHUNKS \ -DUSE_GLZ \ - -DUSE_OGL \ -D__STDC_LIMIT_MACROS \ -I. \ -I.. \ @@ -60,10 +59,6 @@ RED_COMMON_SRCS = \ $(CLIENT_DIR)/debug.h \ $(CLIENT_DIR)/display_channel.cpp \ $(CLIENT_DIR)/display_channel.h \ - $(CLIENT_DIR)/red_gl_canvas.cpp \ - $(CLIENT_DIR)/red_gl_canvas.h \ - $(CLIENT_DIR)/gl_canvas.cpp \ - $(CLIENT_DIR)/glc.cpp \ $(CLIENT_DIR)/glz_decoded_image.h \ $(CLIENT_DIR)/glz_decoder_config.h \ $(CLIENT_DIR)/glz_decoder.cpp \ @@ -100,7 +95,6 @@ RED_COMMON_SRCS = \ $(CLIENT_DIR)/red_peer.cpp \ $(CLIENT_DIR)/red_peer.h \ $(CLIENT_DIR)/red_pixmap_sw.h \ - $(CLIENT_DIR)/red_pixmap_gl.h \ $(CLIENT_DIR)/red_pixmap.h \ $(CLIENT_DIR)/red_types.h \ $(CLIENT_DIR)/red_window.h \ @@ -129,6 +123,18 @@ RED_COMMON_SRCS = \ $(CLIENT_DIR)/gui/gui.cpp \ $(NULL) +if SUPPORT_GL +RED_OGL_SRCS = \ + $(CLIENT_DIR)/gl_canvas.cpp \ + $(CLIENT_DIR)/glc.cpp \ + $(CLIENT_DIR)/red_gl_canvas.cpp \ + $(CLIENT_DIR)/red_gl_canvas.h \ + $(CLIENT_DIR)/red_pixmap_gl.h \ + red_pixmap_gl.cpp +else +RED_OGL_SRCS = +endif + bin_PROGRAMS = spicec spicec_SOURCES = \ @@ -149,7 +155,6 @@ spicec_SOURCES = \ red_drawable.cpp \ red_pixmap.cpp \ red_pixmap_sw.cpp \ - red_pixmap_gl.cpp \ red_window.cpp \ red_window_p.h \ res.cpp \ @@ -159,6 +164,7 @@ spicec_SOURCES = \ x_icon.h \ x_platform.h \ $(RED_COMMON_SRCS) \ + $(RED_OGL_SRCS) \ $(NULL) spicec_LDFLAGS = \ diff --git a/client/x11/pixels_source_p.h b/client/x11/pixels_source_p.h index a3e4cfbc..b1b5261c 100644 --- a/client/x11/pixels_source_p.h +++ b/client/x11/pixels_source_p.h @@ -19,43 +19,54 @@ #define _H_PIXELE_SOURSR_P #include <X11/X.h> +#ifdef USE_OGL #include <GL/glu.h> +#endif // USE_OGL +#include <X11/Xdefs.h> +#include <X11/Xutil.h> // required by Xshm.h, but not included by it #include <X11/extensions/XShm.h> #include "red_window.h" +#ifdef USE_OGL #include "red_pixmap_gl.h" +#endif // USE_OGL #include "pixman_utils.h" enum { PIXELS_SOURCE_TYPE_INVALID, PIXELS_SOURCE_TYPE_X_DRAWABLE, PIXELS_SOURCE_TYPE_PIXMAP, +#ifdef USE_OGL PIXELS_SOURCE_TYPE_GL_TEXTURE, PIXELS_SOURCE_TYPE_GL_DRAWABLE, +#endif // USE_OGL }; struct PixelsSource_p { int type; union { struct { + XImage* x_image; + XShmSegmentInfo *shminfo; + pixman_image_t* pixman_image; + RedDrawable::Format format; + } pixmap; + + struct { Drawable drawable; int screen; GC gc; int width, height; +#ifdef USE_OGL RenderType rendertype; union { GLXPbuffer pbuff; GLuint fbo; }; RedGlContext context; +#endif // USE_OGL } x_drawable; - struct { - XImage* x_image; - XShmSegmentInfo *shminfo; - pixman_image_t* pixman_image; - RedDrawable::Format format; - } pixmap; - +#ifdef USE_OGL struct { RenderType rendertype; Win win; @@ -69,6 +80,7 @@ struct PixelsSource_p { }; RedGlContext context; } gl; +#endif // USE_OGL }; }; diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp index fecfb138..92264546 100644 --- a/client/x11/platform.cpp +++ b/client/x11/platform.cpp @@ -69,7 +69,9 @@ static Display* x_display = NULL; static bool x_shm_avail = false; static XVisualInfo **vinfo = NULL; static RedDrawable::Format *screen_format = NULL; +#ifdef USE_OGL static GLXFBConfig **fb_config = NULL; +#endif // USE_OGL static XIM x_input_method = NULL; static XIC x_input_context = NULL; @@ -324,10 +326,12 @@ RedDrawable::Format XPlatform::get_screen_format(int screen) return screen_format[screen]; } +#ifdef USE_OGL GLXFBConfig** XPlatform::get_fbconfig() { return fb_config; } +#endif // USE_OGL XIC XPlatform::get_input_context() { @@ -2136,6 +2140,7 @@ static void cleanup(void) delete vinfo; vinfo = NULL; } +#ifdef USE_OGL if (fb_config) { for (i = 0; i < ScreenCount(x_display); ++i) { if (fb_config[i]) { @@ -2145,6 +2150,7 @@ static void cleanup(void) delete fb_config; fb_config = NULL; } +#endif // USE_OGL } static void quit_handler(int sig) @@ -2291,7 +2297,9 @@ static XVisualInfo* get_x_vis_info(int screen) void Platform::init() { +#ifdef USE_OGL int err, ev; +#endif // USE_OGL int threads_enable; int major, minor; Bool pixmaps; @@ -2314,10 +2322,11 @@ void Platform::init() vinfo = new XVisualInfo *[ScreenCount(x_display)]; memset(vinfo, 0, sizeof(XVisualInfo *) * ScreenCount(x_display)); - fb_config = new GLXFBConfig *[ScreenCount(x_display)]; - memset(fb_config, 0, sizeof(GLXFBConfig *) * ScreenCount(x_display)); screen_format = new RedDrawable::Format[ScreenCount(x_display)]; memset(screen_format, 0, sizeof(RedDrawable::Format) * ScreenCount(x_display)); +#ifdef USE_OGL + fb_config = new GLXFBConfig *[ScreenCount(x_display)]; + memset(fb_config, 0, sizeof(GLXFBConfig *) * ScreenCount(x_display)); if (threads_enable && glXQueryExtension(x_display, &err, &ev)) { int num_configs; @@ -2349,11 +2358,14 @@ void Platform::init() vinfo[i] = get_x_vis_info(i); } } - } else { + } else +#else // !USE_OGL + { for (int i = 0; i < ScreenCount(x_display); ++i) { vinfo[i] = get_x_vis_info(i); } } +#endif // USE_OGL for (int i = 0; i < ScreenCount(x_display); ++i) { if (vinfo[i] == NULL) { diff --git a/client/x11/red_drawable.cpp b/client/x11/red_drawable.cpp index 32754da9..327028b9 100644 --- a/client/x11/red_drawable.cpp +++ b/client/x11/red_drawable.cpp @@ -21,6 +21,8 @@ #include "debug.h" #include "x_platform.h" #include "utils.h" + +#ifdef USE_OGL #include "gl_utils.h" #include <GL/gl.h> #include <GL/glu.h> @@ -131,6 +133,7 @@ static inline void copy_to_gldrawable_from_pixmap(const RedDrawable_p* dest, glXMakeCurrent(XPlatform::get_display(), pbuffer, context); } } +#endif // USE_OGL static inline void copy_to_drawable_from_drawable(const RedDrawable_p* dest, const SpiceRect& area, @@ -269,6 +272,7 @@ static inline void copy_to_x_drawable(const RedDrawable_p* dest, } } +#ifdef USE_OGL static inline void copy_to_gl_drawable(const RedDrawable_p* dest, const SpiceRect& area, const SpicePoint& offset, @@ -286,6 +290,7 @@ static inline void copy_to_gl_drawable(const RedDrawable_p* dest, THROW("invalid source type %d", source->type); } } +#endif // USE_OGL static inline void copy_to_pixmap_from_drawable(const RedDrawable_p* dest, const SpiceRect& area, @@ -316,6 +321,7 @@ static inline void copy_to_pixmap_from_pixmap(const RedDrawable_p* dest, area.bottom - area.top); } +#ifdef USE_OGL static inline void copy_to_pixmap_from_gltexture(const RedDrawable_p* dest, const SpiceRect& area, const SpicePoint& offset, @@ -359,6 +365,7 @@ static inline void copy_to_pixmap_from_gltexture(const RedDrawable_p* dest, glXMakeCurrent(XPlatform::get_display(), win, context); } } +#endif // USE_OGL static inline void copy_to_pixmap(const RedDrawable_p* dest, const SpiceRect& area, @@ -367,9 +374,11 @@ static inline void copy_to_pixmap(const RedDrawable_p* dest, int src_x, int src_y) { switch (source->type) { +#ifdef USE_OGL case PIXELS_SOURCE_TYPE_GL_TEXTURE: copy_to_pixmap_from_gltexture(dest, area, offset, source, src_x, src_y); break; +#endif // USE_OGL case PIXELS_SOURCE_TYPE_X_DRAWABLE: copy_to_pixmap_from_drawable(dest, area, offset, source, src_x, src_y); break; @@ -386,10 +395,12 @@ void RedDrawable::copy_pixels(const PixelsSource& src, int src_x, int src_y, con PixelsSource_p* source = (PixelsSource_p*)src.get_opaque(); RedDrawable_p* dest = (RedDrawable_p*)get_opaque(); switch (dest->source.type) { +#ifdef USE_OGL case PIXELS_SOURCE_TYPE_GL_DRAWABLE: copy_to_gl_drawable(dest, area, _origin, source, src_x + src._origin.x, src_y + src._origin.y); break; +#endif // USE_OGL case PIXELS_SOURCE_TYPE_X_DRAWABLE: copy_to_x_drawable(dest, area, _origin, source, src_x + src._origin.x, src_y + src._origin.y); @@ -639,6 +650,7 @@ static inline void fill_drawable(RedDrawable_p* dest, const SpiceRect& area, rgb area.right - area.left, area.bottom - area.top); } +#ifdef USE_OGL static inline void fill_gl_drawable(RedDrawable_p* dest, const SpiceRect& area, rgb32_t color, const SpicePoint& offset) { @@ -672,6 +684,7 @@ static inline void fill_gl_drawable(RedDrawable_p* dest, const SpiceRect& area, glColor3f(1, 1, 1); } +#endif // USE_OGL static inline void fill_pixmap(RedDrawable_p* dest, const SpiceRect& area, rgb32_t color, const SpicePoint& offset) @@ -689,9 +702,11 @@ void RedDrawable::fill_rect(const SpiceRect& area, rgb32_t color) { RedDrawable_p* dest = (RedDrawable_p*)get_opaque(); switch (dest->source.type) { +#ifdef USE_OGL case PIXELS_SOURCE_TYPE_GL_DRAWABLE: fill_gl_drawable(dest, area, color, _origin); break; +#endif // USE_OGL case PIXELS_SOURCE_TYPE_X_DRAWABLE: fill_drawable(dest, area, color, _origin); break; diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp index 7e69b428..5a0886ac 100644 --- a/client/x11/red_window.cpp +++ b/client/x11/red_window.cpp @@ -22,23 +22,26 @@ #include <X11/Xatom.h> #include <X11/XKBlib.h> +#ifdef USE_OGL #include <GL/gl.h> #include <GL/glu.h> #include <GL/glx.h> #include <GL/glext.h> +#endif // USE_OGL #include <stdio.h> #include "red_window.h" #include "utils.h" -#include "gl_utils.h" #include "debug.h" #include "platform.h" #include "x_platform.h" #include "pixels_source_p.h" #include <spice/protocol.h> #include "region.h" +#ifdef USE_OGL +#include "gl_utils.h" #include "red_pixmap_gl.h" -#include "red_pixmap_gl.h" +#endif // USE_OGL #include "x_icon.h" @@ -1008,6 +1011,7 @@ void RedWindow_p::wait_for_unmap() } } +#ifdef USE_OGL void RedWindow_p::set_glx(int width, int height) { if (_glcont_copy) { @@ -1025,6 +1029,7 @@ void RedWindow_p::set_glx(int width, int height) GLC_ERROR_TEST_FINISH; } } +#endif // USE_OGL void RedWindow_p::set_minmax(PixelsSource_p& pix_source, int width, int height) { @@ -1053,7 +1058,9 @@ Cursor RedWindow_p::create_invisible_cursor(Window window) RedWindow_p::RedWindow_p() : _win (None) +#ifdef USE_OGL , _glcont_copy (NULL) +#endif // USE_OGL , _icon (NULL) , _focused (false) , _ignore_foucs (false) @@ -1083,10 +1090,12 @@ void RedWindow_p::destroy(RedWindow& red_window, PixelsSource_p& pix_source) XFreeCursor(x_display, _invisible_cursor); _invisible_cursor = None; XDeleteContext(x_display, window, user_data_context); +#ifdef USE_OGL if (_glcont_copy) { glXDestroyContext(x_display, _glcont_copy); _glcont_copy = NULL; } +#endif // USE_OGL XDestroyWindow(x_display, window); XFreeColormap(x_display, _colormap); XFreeGC(x_display, pix_source.x_drawable.gc); @@ -1895,6 +1904,7 @@ bool RedWindow::get_mouse_anchor_point(SpicePoint& pt) return true; } +#ifdef USE_OGL RedGlContext RedWindow::create_context_gl() { if (XPlatform::get_fbconfig()[_screen]) { @@ -1926,16 +1936,6 @@ void RedWindow::untouch_context() glXMakeCurrent(x_display, 0, 0); } -int RedWindow::get_screen_num() -{ - return _screen; -} - -RedDrawable::Format RedWindow::get_format() -{ - return XPlatform::get_screen_format(_screen); -} - void RedWindow::set_type_gl() { PixelsSource_p *pix_source = (PixelsSource_p*)get_opaque(); @@ -1972,6 +1972,17 @@ void RedWindow::set_render_fbo(GLuint fbo) pix_source->x_drawable.rendertype = RENDER_TYPE_FBO; pix_source->x_drawable.fbo = fbo; } +#endif // USE_OGL + +int RedWindow::get_screen_num() +{ + return _screen; +} + +RedDrawable::Format RedWindow::get_format() +{ + return XPlatform::get_screen_format(_screen); +} void RedWindow::on_focus_in() { diff --git a/client/x11/red_window_p.h b/client/x11/red_window_p.h index b843c423..29121d9c 100644 --- a/client/x11/red_window_p.h +++ b/client/x11/red_window_p.h @@ -18,12 +18,17 @@ #ifndef _H_RED_WINDOW_P #define _H_RED_WINDOW_P +#ifdef USE_OGL #include <GL/glx.h> +#endif // USE_OGL +#include <X11/Xdefs.h> #include <X11/Xlib.h> typedef Window Win; +#ifdef USE_OGL typedef GLXContext RedGlContext; typedef GLXPbuffer RedPbuffer; +#endif // USE_OGL class RedWindow; class Icon; @@ -49,7 +54,9 @@ public: static void win_proc(XEvent& event); static Cursor create_invisible_cursor(Window window); +#ifdef USE_OGL void set_glx(int width, int height); +#endif // USE_OGL static void handle_key_press_event(RedWindow& red_window, XKeyEvent* event); protected: @@ -59,7 +66,9 @@ protected: bool _visibale; bool _expect_parent; SpicePoint _show_pos; +#ifdef USE_OGL GLXContext _glcont_copy; +#endif // USE_OGL Icon* _icon; bool _focused; bool _ignore_foucs; diff --git a/client/x11/x_platform.h b/client/x11/x_platform.h index 57c2f26f..c535652a 100644 --- a/client/x11/x_platform.h +++ b/client/x11/x_platform.h @@ -19,6 +19,8 @@ #define _H_XPLATFORM #include "red_drawable.h" +#include <X11/Xdefs.h> +#include <X11/Xutil.h> #include <X11/extensions/XShm.h> class XPlatform { @@ -26,8 +28,10 @@ public: static Display* get_display(); static XVisualInfo** get_vinfo(); static RedDrawable::Format get_screen_format(int screen); - static GLXFBConfig** get_fbconfig(); static XIC get_input_context(); +#ifdef USE_OGL + static GLXFBConfig** get_fbconfig(); +#endif // USE_OGL typedef void (*win_proc_t)(XEvent& event); static void set_win_proc(Window win, win_proc_t proc); diff --git a/configure.ac b/configure.ac index 3114a1ad..ef5f7f78 100644 --- a/configure.ac +++ b/configure.ac @@ -96,6 +96,12 @@ AC_ARG_ENABLE(tunnel, [ --enable-tunnel Enable network redirection], [ have_tunnel=yes]) AM_CONDITIONAL(SUPPORT_TUNNEL, test "x$have_tunnel" = "xyes") + +have_opengl=no +AC_ARG_ENABLE(opengl, +[ --enable-opengl Enable opengl requirement / support (not recommended)], +[ have_opengl=yes]) +AM_CONDITIONAL(SUPPORT_GL, test "x$have_opengl" = "xyes") dnl ========================================================================= dnl Check deps @@ -163,13 +169,14 @@ SPICE_REQUIRES+=" openssl" # AC_SUBST(GL_LIBS) # SPICE_REQUIRES+=" gl glu" -have_gl=yes -AC_CHECK_LIB(GL, glBlendFunc, GL_LIBS="$GL_LIBS -lGL", have_gl=no) -AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lGLU", have_gl=no) -GL_CFLAGS="-DGL_GLEXT_PROTOTYPES" +if test "x$have_opengl" = "xyes"; then + AC_CHECK_LIB(GL, glBlendFunc, GL_LIBS="$GL_LIBS -lGL", have_opengl=no) + AC_CHECK_LIB(GLU, gluSphere, GL_LIBS="$GL_LIBS -lGLU", have_opengl=no) + GL_CFLAGS="-DGL_GLEXT_PROTOTYPES -DUSE_OGL" -if test "x$have_gl" = "xno"; then - AC_MSG_ERROR([GL libraries not available]) + if test "x$have_opengl" = "xno"; then + AC_MSG_ERROR([GL libraries not available]) + fi fi AC_SUBST(GL_CFLAGS) @@ -361,5 +368,7 @@ echo " Red target: ${red_target} + OpenGL: ${have_opengl} + Now type 'make' to build $PACKAGE " |