Skip to content

Commit

Permalink
Advancing Albrecht's plan for the Fl_Window_Driver class.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11387 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Manolo Gouy authored and Manolo Gouy committed Mar 19, 2016
1 parent c2067d8 commit 5103053
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 100 deletions.
1 change: 0 additions & 1 deletion FL/Fl_Window_Driver.H
Expand Up @@ -60,7 +60,6 @@ public:

// --- window management
virtual void take_focus();
virtual void flush_single();
virtual void flush_double();
virtual void flush_overlay();
virtual void draw_begin();
Expand Down
5 changes: 4 additions & 1 deletion src/Fl_Window.cxx
Expand Up @@ -437,7 +437,10 @@ int Fl_Window::decorated_h()

void Fl_Window::flush()
{
driver()->flush_single();
if (!shown()) return;
make_current();
fl_clip_region(i->region); i->region = 0;
draw();
}


Expand Down
19 changes: 0 additions & 19 deletions src/Fl_Window_Driver.cxx
Expand Up @@ -18,11 +18,8 @@
//


#include <config.h>
#include "config_lib.h"
#include <FL/Fl_Window_Driver.H>
#include <FL/Fl.H>
#include <FL/Fl_Overlay_Window.H>
#include <FL/fl_draw.H>


Expand All @@ -44,25 +41,13 @@ void Fl_Window_Driver::take_focus()
}


void Fl_Window_Driver::flush_single()
{
Fl_X *i = Fl_X::i(pWindow);
if (!i) return;
fl_clip_region(i->region);
i->region = 0;
pWindow->draw();
}


void Fl_Window_Driver::flush_double()
{
flush_single();
}


void Fl_Window_Driver::flush_overlay()
{
flush_single();
}


Expand All @@ -81,10 +66,6 @@ void Fl_Window_Driver::draw_end()

void Fl_Window_Driver::destroy_double_buffer() {
Fl_X *i = Fl_X::i(pWindow);
/* This is a working, platform-independent implementation.
Some platforms may re-implement it for their own logic:
- on Xlib, it is reimplemented if the Xdbe extension is available.
*/
fl_delete_offscreen(i->other_xid);
i->other_xid = 0;
}
Expand Down
1 change: 0 additions & 1 deletion src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
Expand Up @@ -69,7 +69,6 @@ public:

// --- window management
virtual void take_focus();
virtual void flush_single();
virtual void flush_double();
virtual void flush_overlay();
virtual void draw_begin();
Expand Down
67 changes: 24 additions & 43 deletions src/drivers/Cocoa/Fl_Cocoa_Window_Driver.cxx
Expand Up @@ -55,61 +55,42 @@ void Fl_Cocoa_Window_Driver::take_focus()
}


void Fl_Cocoa_Window_Driver::flush_single()
{
if (!pWindow->shown()) return;
pWindow->make_current();
Fl_X *i = Fl_X::i(pWindow);
if (!i) return; // window not yet created
fl_clip_region(i->region); i->region = 0;
pWindow->draw();
}


void Fl_Cocoa_Window_Driver::flush_double()
{
if (!pWindow->shown()) return;
pWindow->make_current();
Fl_X *i = Fl_X::i(pWindow);
if (!i) return; // window not yet created
fl_clip_region(i->region); i->region = 0;
pWindow->draw();
void Fl_Cocoa_Window_Driver::flush_double() {
pWindow->Fl_Window::flush();
}


void Fl_Cocoa_Window_Driver::flush_overlay()
{
Fl_Overlay_Window *oWindow = pWindow->as_overlay_window();
if (!oWindow) return flush_single();

if (!pWindow->shown()) return;
pWindow->make_current(); // make sure fl_gc is non-zero
Fl_X *i = Fl_X::i(pWindow);
if (!i) return; // window not yet created

int erase_overlay = (pWindow->damage()&FL_DAMAGE_OVERLAY);
int erase_overlay = (pWindow->damage()&FL_DAMAGE_OVERLAY) | (oWindow->overlay_ == oWindow);
pWindow->clear_damage((uchar)(pWindow->damage()&~FL_DAMAGE_OVERLAY));

if (!i->other_xid) {
i->other_xid = fl_create_offscreen(pWindow->w(), pWindow->h());
pWindow->clear_damage(FL_DAMAGE_ALL);
if (!oWindow->shown()) return;
pWindow->make_current(); // make sure fl_gc is non-zero
Fl_X *myi = Fl_X::i(pWindow);
if (!myi) return; // window not yet created
if (!myi->other_xid) {
myi->other_xid = fl_create_offscreen(oWindow->w(), oWindow->h());
oWindow->clear_damage(FL_DAMAGE_ALL);
}
if (pWindow->damage() & ~FL_DAMAGE_EXPOSE) {
fl_clip_region(i->region); i->region = 0;
if ( i->other_xid ) {
fl_begin_offscreen( i->other_xid );
fl_clip_region( 0 );
pWindow->draw();
fl_end_offscreen();
} else {
pWindow->draw();
if (oWindow->damage() & ~FL_DAMAGE_EXPOSE) {
fl_clip_region(myi->region); myi->region = 0;
if ( myi->other_xid ) {
fl_begin_offscreen( myi->other_xid );
fl_clip_region( 0 );
oWindow->draw();
fl_end_offscreen();
} else {
oWindow->draw();
}
}
}
if (erase_overlay) fl_clip_region(0);
// on Irix (at least) it is faster to reduce the area copied to
// the current clip region:
int X,Y,W,H; fl_clip_box(0,0,oWindow->w(),oWindow->h(),X,Y,W,H);
if (myi->other_xid) fl_copy_offscreen(X, Y, W, H, myi->other_xid, X, Y);

int X,Y,W,H; fl_clip_box(0,0,pWindow->w(),pWindow->h(),X,Y,W,H);
if (i->other_xid) fl_copy_offscreen(X, Y, W, H, i->other_xid, X, Y);

if (oWindow->overlay_ == oWindow) oWindow->draw_overlay();
}

Expand Down
1 change: 0 additions & 1 deletion src/drivers/WinAPI/Fl_WinAPI_Window_Driver.H
Expand Up @@ -73,7 +73,6 @@ public:
virtual int decorated_h();

// --- window management
virtual void flush_single();
virtual void flush_double();
virtual void flush_overlay();
virtual void draw_begin();
Expand Down
13 changes: 0 additions & 13 deletions src/drivers/WinAPI/Fl_WinAPI_Window_Driver.cxx
Expand Up @@ -255,18 +255,6 @@ void Fl_WinAPI_Window_Driver::draw_begin()
}


void Fl_WinAPI_Window_Driver::flush_single()
{
if (!pWindow->shown()) return;
pWindow->make_current(); // make sure fl_gc is non-zero
Fl_X *i = Fl_X::i(pWindow);
if (!i) return;
fl_clip_region(i->region);
i->region = 0;
pWindow->draw();
}


void Fl_WinAPI_Window_Driver::flush_double()
{
if (!pWindow->shown()) return;
Expand Down Expand Up @@ -294,7 +282,6 @@ void Fl_WinAPI_Window_Driver::flush_double()
void Fl_WinAPI_Window_Driver::flush_overlay()
{
Fl_Overlay_Window *oWindow = pWindow->as_overlay_window();
if (!oWindow) return flush_single();

if (!pWindow->shown()) return;
pWindow->make_current(); // make sure fl_gc is non-zero
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/X11/Fl_X11_Window_Driver.H
Expand Up @@ -77,7 +77,6 @@ public:

// --- window management
virtual void take_focus();
virtual void flush_single();
virtual void flush_double();
virtual void flush_overlay();
virtual void draw_begin();
Expand All @@ -89,6 +88,7 @@ public:
virtual void free_icons();
virtual void capture_titlebar_and_borders(Fl_Shared_Image*& top, Fl_Shared_Image*& left, Fl_Shared_Image*& bottom, Fl_Shared_Image*& right);
virtual void wait_for_expose();
virtual void destroy_double_buffer();
};


Expand Down
28 changes: 8 additions & 20 deletions src/drivers/X11/Fl_X11_Window_Driver.cxx
Expand Up @@ -148,18 +148,6 @@ void Fl_X11_Window_Driver::draw_begin()
}


void Fl_X11_Window_Driver::flush_single()
{
if (!pWindow->shown()) return;
pWindow->make_current(); // make sure fl_gc is non-zero
Fl_X *i = Fl_X::i(pWindow);
if (!i) return;
fl_clip_region(i->region);
i->region = 0;
pWindow->draw();
}


void Fl_X11_Window_Driver::flush_double()
{
if (!pWindow->shown()) return;
Expand Down Expand Up @@ -215,7 +203,6 @@ void Fl_X11_Window_Driver::flush_double()
void Fl_X11_Window_Driver::flush_overlay()
{
Fl_Overlay_Window *oWindow = pWindow->as_overlay_window();
if (!oWindow) return flush_single();

if (!pWindow->shown()) return;
pWindow->make_current(); // make sure fl_gc is non-zero
Expand Down Expand Up @@ -289,15 +276,16 @@ void Fl_X11_Window_Driver::flush_overlay()
}



void Fl_X11_Window_Driver::destroy_double_buffer() {
#if USE_XDBE

//void Fl_X11_Dbe_Window_Driver::destroy_double_buffer() {
// Fl_X *i = Fl_X::i(pWindow);
// XdbeDeallocateBackBufferName(fl_display, i->other_xid);
// i->other_xid = 0;
//}
if (can_xdbe()) {
Fl_X *i = Fl_X::i(pWindow);
XdbeDeallocateBackBufferName(fl_display, i->other_xid);
i->other_xid = 0;
} else
#endif // USE_XDBE
Fl_Window_Driver::destroy_double_buffer();
}


void Fl_X11_Window_Driver::shape_bitmap_(Fl_Image* b) {
Expand Down

0 comments on commit 5103053

Please sign in to comment.