hi, thanks for your answer,

i have whote a simple exe version to  test the problem,  it is still
happens..

just click mouse button continuous  and watch at the cpu occupancy,

with my system ;
before play a video  the test app cpu occupancy about %5 - 12%;
play a video    the test app cpu occupancy about %25 - 35%;
exit the video    the test app cpu occupancy about %25 - 35%;

my system : xp sp3
card : geforce4 MX440;
memory : 512M
cpu : amd Athlon32 2400+

///////////////////////////h/////////////////////////////////////
#ifndef D_WINDOW
#  define D_WINDOW

#include <FL/Fl_Box.H>
#include <FL/x.H>
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Double_Window.H>

class D_Window : public Fl_Box
{
public:
        int __w,__h;
        D_Window();
        void fl_draw_em(const char * c, int x , int y );
        void copy_offscreen_tr(HBITMAP bitmap);
        void copy_offscreen(HBITMAP bitmap);
        void draw();
        void DrawBG();
        void DrawBgOffScreen();
        void ReDrawBg();
        void DrawText();
        void DrawTextOffScreen();
        void ReDrawText();
        int handle(int event);

};
#endif


///////////////////////////cpp/////////////////////////////////////

#include "test.h"

Fl_Offscreen TextOffScreen = 0;
Fl_Offscreen BgOffScreen = 0;
HDC CDC = 0;
void D_Window::fl_draw_em(const char * c, int x , int y )
{
        Fl_Color tmp = fl_color();
        fl_color(1,1,1);
        fl_draw(c,x-1,y-1);
        fl_draw(c,x+1,y+1);
        fl_draw(c,x+1,y-1);
        fl_draw(c,x-1,y+1);
        fl_color(tmp);
        fl_draw(c,x,y);
}

void D_Window::copy_offscreen_tr(HBITMAP bitmap)
{
        if (!CDC)CDC = CreateCompatibleDC(fl_gc);
        SelectObject(CDC, bitmap);
        TransparentBlt(fl_gc,0,0,w(),h(),CDC,0,0,w(),h(),0);
}
void D_Window::copy_offscreen(HBITMAP bitmap)
{
        if (!CDC)CDC = CreateCompatibleDC(fl_gc);
        SelectObject(CDC, bitmap);
        BitBlt(fl_gc,0,0, w(), h(), CDC,0,0, SRCCOPY);
}
D_Window::D_Window():Fl_Box(0,0,1000,800)
{
}
void D_Window::draw()
{
        if (__w!=w()||__h!=h())
        {
                __w = w();
                __h = h();
                if(TextOffScreen)fl_delete_offscreen(TextOffScreen);
                TextOffScreen = 0;
                if(BgOffScreen)fl_delete_offscreen(BgOffScreen);
                BgOffScreen = 0;
                damage(FL_DAMAGE_ALL);
        }
        if (damage()=='5' || damage() == FL_DAMAGE_ALL)
        {
                DrawTextOffScreen();
        }
        if (damage()=='7' || damage() == FL_DAMAGE_ALL)
        {
                DrawBgOffScreen();
        }
        copy_offscreen(BgOffScreen);
        copy_offscreen_tr(TextOffScreen);
        clear_damage(FL_DAMAGE_ALL);
}

void D_Window::DrawBG()
{
        for(int i = 0 ; i < 25 ; i ++ )
        {
                for(int k = 0 ; k < 50 ; k ++ )
                {
                        fl_color((i*50+k)%256);
                        fl_rectf(i*40,k*16,40,16);
                }
        }
}
void D_Window::DrawBgOffScreen()
{
        if (!BgOffScreen)BgOffScreen = fl_create_offscreen(w(), h());
        fl_begin_offscreen(BgOffScreen);
        {
                DrawBG();
        }
        fl_end_offscreen();
}
void D_Window::ReDrawBg()
{
        damage('7');
}
void D_Window::DrawText()
{
        for(int i = 0 ; i < 25 ; i ++ )
        {
                for(int k = 0 ; k < 50 ; k ++ )
                {
                        fl_color(255-(i*50+k)%256);
                        fl_draw_em("FLTK",i*40+2,k*16+14);

                }
        }
}
void D_Window::DrawTextOffScreen()
{
        if (!TextOffScreen)TextOffScreen = fl_create_offscreen(w(), h());
        fl_begin_offscreen(TextOffScreen);
        {
                DrawText();
        }
        fl_end_offscreen();
}
void D_Window::ReDrawText()
{
        damage('5');
}
int D_Window::handle(int event)
{
        if (event == FL_MOVE)
        {
                ReDrawText();
                return 1;
        }
        if (event == FL_PUSH)
        {
                ReDrawBg();
                return 1;
        }
        return Fl_Box::handle(event);
};


int main(int argc, char** argv)
{
        Fl_Double_Window * mw = new Fl_Double_Window(0,0,1000,800);
        D_Window * test = new D_Window();
        mw->end();
        mw->show(argc,argv);
        return Fl::run();
}



_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to