Replace member function void Fl_X::flush() by virtual void Fl_Window_Driver::flush()

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11646 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2016-04-18 11:58:46 +00:00
parent 6818216c30
commit 85b5f02a8b
12 changed files with 27 additions and 33 deletions

View File

@ -102,6 +102,7 @@ public:
// --- window management
virtual void take_focus();
virtual void flush(); // the default implementation may be enough
virtual void flush_double();
virtual void flush_overlay();
virtual void flush_single();

View File

@ -134,7 +134,6 @@ public:
static Fl_X* i(const Fl_Window* w) {return (Fl_X*)w->i;}
static int fake_X_wm(const Fl_Window*,int&,int&,int&,int&,int&);
static void make(Fl_Window*);
void flush();
static void set_high_resolution(bool);
CGRect* subRect() { return subRect_; } // getter
void subRect(CGRect *r) { subRect_ = r; } // setter

View File

@ -66,7 +66,6 @@ public:
int &bt,int &bx,int &by);
void make_fullscreen(int X, int Y, int W, int H);
void setwindow(Fl_Window* wi) {w=wi; wi->i=this;}
void flush() {w->flush();}
void set_minmax(LPMINMAXINFO minmax);
void mapraise();
int set_cursor(Fl_Cursor);

2
FL/x.H
View File

@ -127,8 +127,6 @@ public:
int set_cursor(const Fl_RGB_Image*, int, int);
static void make_xid(Fl_Window*,XVisualInfo* =fl_visual, Colormap=fl_colormap);
static Fl_X* set_xid(Fl_Window*, Window);
// kludges to get around protection:
void flush() {w->flush();}
static void x(Fl_Window* wi, int X) {wi->x(X);}
static void y(Fl_Window* wi, int Y) {wi->y(Y);}
static void activate_window(Window w);

View File

@ -684,7 +684,10 @@ void Fl::flush() {
if (i->wait_for_expose) {damage_ = 1; continue;}
Fl_Window* wi = i->w;
if (!wi->visible_r()) continue;
if (wi->damage()) {i->flush(); wi->clear_damage();}
if (wi->damage()) {
wi->driver()->flush();
wi->clear_damage();
}
// destroy damage regions for windows that don't use them:
if (i->region) {
fl_graphics_driver->XDestroyRegion(i->region);

View File

@ -153,7 +153,7 @@ void Fl_Widget_Surface::print_window_part(Fl_Window *win, int x, int y, int w, i
Fl_Window *save_front = Fl::first_window();
win->show();
Fl::check();
Fl_X::i(win)->flush(); // makes the window current necessary for fl_read_image
win->driver()->flush(); // makes the window current necessary for fl_read_image
uchar *image_data;
image_data = fl_read_image(NULL, x, y, w, h);
if (save_front != win) save_front->show();

View File

@ -223,6 +223,11 @@ void Fl_Window_Driver::redraw_overlay() {
Fl::damage(FL_DAMAGE_CHILD);
}
void Fl_Window_Driver::flush()
{
pWindow->flush();
}
//
// End of "$Id$".
//

View File

@ -101,7 +101,7 @@ static int main_screen_height; // height of menubar-containing screen used to co
// through_drawRect = YES means the drawRect: message was sent to the view,
// thus the graphics context was prepared by the system
static BOOL through_drawRect = NO;
// through_Fl_X_flush = YES means Fl_X::flush() was called
// through_Fl_X_flush = YES means Fl_Cocoa_Window_Driver::flush() was called
static BOOL through_Fl_X_flush = NO;
static int im_enabled = -1;
// OS version-dependent pasteboard type names
@ -1940,7 +1940,7 @@ static void handleUpdateEvent( Fl_Window *window )
i->region = 0;
}
window->clear_damage(FL_DAMAGE_ALL);
i->flush();
window->driver()->flush();
window->clear_damage();
}
@ -2856,17 +2856,18 @@ void Fl_X::GLcontext_makecurrent(NSOpenGLContext* ctxt)
/*
* Initialize the given port for redraw and call the window's flush() to actually draw the content
*/
void Fl_X::flush()
void Fl_Cocoa_Window_Driver::flush()
{
Fl_Window *w = pWindow;
if (w->as_gl_window()) {
w->flush();
Fl_Window_Driver::flush();
} else {
make_current_counts = 1;
if (!through_drawRect) [[xid contentView] lockFocus];
if (!through_drawRect) [[fl_xid(w) contentView] lockFocus];
through_Fl_X_flush = YES;
w->flush();
Fl_Window_Driver::flush();
through_Fl_X_flush = NO;
if (!through_drawRect) [[xid contentView] unlockFocus];
if (!through_drawRect) [[fl_xid(w) contentView] unlockFocus];
make_current_counts = 0;
Fl_Cocoa_Window_Driver::q_release_context();
}
@ -3226,15 +3227,16 @@ void Fl_Cocoa_Window_Driver::resize(int X,int Y,int W,int H) {
1) When a window is created or resized.
The system sends the drawRect: message to the window's view after having prepared the current
graphics context to draw to this view. Processing of drawRect: sets variable through_drawRect
to YES and calls handleUpdateEvent() that calls Fl_X::flush(). Fl_X::flush() sets through_Fl_X_flush
to YES and calls handleUpdateEvent() that calls Fl_Cocoa_Window_Driver::flush().
Fl_Cocoa_Window_Driver::flush() sets through_Fl_X_flush
to YES and calls Fl_Window::flush() that calls Fl_Window::make_current() that
uses the window's graphics context. The window's draw() function is then executed.
2) At each round of the FLTK event loop.
Fl::flush() is called, that calls Fl_X::flush() on each window that needs drawing. Variable
through_Fl_X_flush is set to YES. Fl_X::flush() locks the focus to the view and calls Fl_Window::flush()
that calls Fl_Window::make_current() which uses the window's graphics context.
Fl_Window::flush() then runs the window's draw() function.
Fl::flush() is called, that calls Fl_Cocoa_Window_Driver::flush() on each window that needs drawing.
Variable through_Fl_X_flush is set to YES. Fl_Cocoa_Window_Driver::flush() locks the focus to the
view and calls Fl_Window::flush() that calls Fl_Window::make_current() which uses the window's
graphics context. Fl_Window::flush() then runs the window's draw() function.
3) An FLTK application can call Fl_Window::make_current() at any time before it draws to a window.
This occurs for instance in the idle callback function of the mandelbrot test program. Variable

View File

@ -1116,7 +1116,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
// Very annoying!
fl_GetDC(hWnd); // Make sure we have a DC for this window...
fl_save_pen();
i->flush();
window->driver()->flush();
fl_restore_pen();
window->clear_damage();
} return 0;

View File

@ -77,6 +77,7 @@ public:
// --- window management
virtual void take_focus();
virtual void flush();
virtual void flush_double();
virtual void flush_overlay();
virtual void draw_begin();

View File

@ -108,15 +108,6 @@ void Fl_PicoAndroid_Window_Driver::flush_single()
scr->drawFrame();
}
#if !defined(FL_DOXYGEN) // FIXME - silence Doxygen warning
void Fl_X::flush()
{
w->flush();
}
#endif // !defined(FL_DOXYGEN) // FIXME - silence Doxygen warning
#if 0
void Fl_PicoAndroid_Window_Driver::flush()

View File

@ -167,11 +167,6 @@ void Fl::remove_fd(int)
{
}
void Fl_X::flush()
{
w->flush();
}
//
// End of "$Id: Fl_PicoSDL_Screen_Driver.cxx 11253 2016-03-01 00:54:21Z matt $".
//