diff options
| -rw-r--r-- | FL/Fl_Device.H | 2 | ||||
| -rw-r--r-- | src/Fl_Device.cxx | 9 | ||||
| -rw-r--r-- | src/Fl_Screen_Driver.cxx | 3 | ||||
| -rw-r--r-- | src/Fl_Widget_Surface.cxx | 3 | ||||
| -rw-r--r-- | src/Fl_cocoa.mm | 13 |
5 files changed, 15 insertions, 15 deletions
diff --git a/FL/Fl_Device.H b/FL/Fl_Device.H index de1c47485..540ec8354 100644 --- a/FL/Fl_Device.H +++ b/FL/Fl_Device.H @@ -126,6 +126,8 @@ public: virtual Fl_RGB_Image* rectangle_capture(Fl_Widget *widget, int x, int y, int w, int h) = 0; /** Returns the window's GL context */ virtual GLContext context(Fl_Widget *widget) = 0; + /** Returns the OpenGL plugin */ + static Fl_Device_Plugin *opengl_plugin(); }; #endif // Fl_Device_H diff --git a/src/Fl_Device.cxx b/src/Fl_Device.cxx index d43517b25..1166c7582 100644 --- a/src/Fl_Device.cxx +++ b/src/Fl_Device.cxx @@ -122,6 +122,15 @@ Fl_Surface_Device *Fl_Surface_Device::pop_current() return surface_; } +Fl_Device_Plugin *Fl_Device_Plugin::opengl_plugin() { + static Fl_Device_Plugin *pi = NULL; + if (!pi) { + Fl_Plugin_Manager pm("fltk:device"); + pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org"); + } + return pi; +} + // // End of "$Id$". // diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index cb89ec2b8..1d812a047 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -192,8 +192,7 @@ Fl_RGB_Image *Fl_Screen_Driver::traverse_to_gl_subwindows(Fl_Group *g, int x, in Fl_RGB_Image *full_img) { if ( g->as_gl_window() ) { - Fl_Plugin_Manager pm("fltk:device"); - Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org"); + Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin(); if (!pi) return full_img; full_img = pi->rectangle_capture(g, x, y, w, h); } diff --git a/src/Fl_Widget_Surface.cxx b/src/Fl_Widget_Surface.cxx index cdeb3cf17..5c6c45432 100644 --- a/src/Fl_Widget_Surface.cxx +++ b/src/Fl_Widget_Surface.cxx @@ -68,8 +68,7 @@ void Fl_Widget_Surface::draw(Fl_Widget* widget, int delta_x, int delta_y) // we do some trickery to recognize OpenGL windows and draw them via a plugin int drawn_by_plugin = 0; if (widget->as_gl_window()) { - Fl_Plugin_Manager pm("fltk:device"); - Fl_Device_Plugin *pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org"); + Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin(); if (pi) { drawn_by_plugin = pi->print(widget); } diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index b6453c4b2..8d077a46f 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -147,15 +147,6 @@ static TISCreateASCIICapableInputSourceList_type TISCreateASCIICapableInputSourc typedef void (*KeyScript_type)(short); static KeyScript_type KeyScript; -static Fl_Device_Plugin *opengl_plugin_device() { - static Fl_Device_Plugin *pi = NULL; - if (!pi) { - Fl_Plugin_Manager pm("fltk:device"); - pi = (Fl_Device_Plugin*)pm.plugin("opengl.device.fltk.org"); - } - return pi; -} - /* fltk-utf8 placekeepers */ void fl_set_status(int x, int y, int w, int h) { @@ -2212,7 +2203,7 @@ static CGContextRef prepare_bitmap_for_layer(int w, int h ) { Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(window); [self did_view_resolution_change]; if (d->wait_for_expose_value) { // 1st drawing of layer-backed GL window - Fl_Device_Plugin *pi = opengl_plugin_device(); + Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin(); if (pi) { [pi->context(window) update]; // layer-backed GL windows may be empty without this } @@ -4253,7 +4244,7 @@ static NSBitmapImageRep* GL_rect_to_nsbitmap(Fl_Window *win, int x, int y, int w // captures a rectangle from a GL window and returns it as an allocated NSBitmapImageRep // the capture has high res on retina { - Fl_Device_Plugin *pi = opengl_plugin_device(); + Fl_Device_Plugin *pi = Fl_Device_Plugin::opengl_plugin(); if (!pi) return nil; Fl_RGB_Image *img = pi->rectangle_capture(win, x, y, w, h); NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:img->w() pixelsHigh:img->h() bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:NSDeviceRGBColorSpace bytesPerRow:4*img->w() bitsPerPixel:32]; |
