Skip to content

Commit

Permalink
Massive code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp-sssup committed Apr 3, 2009
1 parent acc7ae8 commit 19b3023
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 204 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,2 @@
remove add_to_list hack


trovare un vero schema per i due colori delle shapes. Lo stencil devo portare più informazioni... shaders forse trovare un vero schema per i due colori delle shapes. Lo stencil devo portare più informazioni... shaders forse
5 changes: 1 addition & 4 deletions frame.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ class Frame
STRING Label; STRING Label;
public: public:
std::list<DisplayListTag*> displayList; std::list<DisplayListTag*> displayList;

Frame(const std::list<DisplayListTag*>& d):displayList(d){ }
Frame(const std::list<DisplayListTag*>& d):displayList(d),hack(0){ }
void Render(int baseLayer); void Render(int baseLayer);
void setLabel(STRING l); void setLabel(STRING l);

int hack;
}; };


#endif #endif
31 changes: 6 additions & 25 deletions main.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,31 +49,12 @@ int main()
RenderThread rt(SDL,NULL); RenderThread rt(SDL,NULL);
InputThread it; InputThread it;


while(1) while(1)
{ {
if(sys.clip.state.stop_FP && !sys.update_request) sys.waitToRun();
sem_wait(&sys.sem_run); rt.draw(&sys.getFrameAtFP());
while(1) sys.advanceFP();
{ }
//thread_debug( "RENDER: frames mutex lock");
sem_wait(&sys.clip.sem_frames);

if(sys.clip.state.FP<sys.clip.frames.size())
break;

//thread_debug( "RENDER: frames mutex unlock");
sem_post(&sys.clip.sem_frames);
//thread_debug("RENDER: new frame wait");
sem_wait(&sys.new_frame);
}
//Aquired lock on frames list
sys.update_request=false;
sys.clip.state.next_FP=sys.clip.state.FP+1;
rt.draw(&sys.clip.frames[sys.clip.state.FP]);
sys.clip.state.FP=sys.clip.state.next_FP;

sem_post(&sys.clip.sem_frames);
}




cout << "the end" << endl; cout << "the end" << endl;
Expand Down
48 changes: 21 additions & 27 deletions plugin/plugin.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,50 +27,44 @@


SystemState sys; SystemState sys;
pthread_t MovieTimer::t; pthread_t MovieTimer::t;
RenderThread* MovieTimer::rt(NULL); sem_t MovieTimer::mutex;
RenderThread* MovieTimer::rt=NULL;


MovieTimer::MovieTimer(RenderThread* r) MovieTimer::MovieTimer(RenderThread* r)
{ {
sem_init(&mutex,0,1);
pthread_create(&t,0,timer_worker,NULL); pthread_create(&t,0,timer_worker,NULL);
} }


void MovieTimer::setRenderThread(RenderThread* r)
{
sem_wait(&mutex);

rt=r;

sem_post(&mutex);
}

void* MovieTimer::timer_worker(void*) void* MovieTimer::timer_worker(void*)
{ {
while(1) while(1)
{ {
if(sys.clip.state.stop_FP && !sys.update_request) sys.waitToRun();
sem_wait(&sys.sem_run); sem_wait(&mutex);
while(1)
{
//thread_debug( "RENDER: frames mutex lock");
sem_wait(&sys.clip.sem_frames);

if(sys.clip.state.FP<sys.clip.frames.size())
break;

//thread_debug( "RENDER: frames mutex unlock");
sem_post(&sys.clip.sem_frames);
//thread_debug("RENDER: new frame wait");
sem_wait(&sys.new_frame);
}
//Aquired lock on frames list
sys.update_request=false;
sys.clip.state.next_FP=sys.clip.state.FP+1;
if(rt!=NULL) if(rt!=NULL)
rt->draw(&sys.clip.frames[sys.clip.state.FP]); rt->draw(&sys.getFrameAtFP());
else else
throw "rt null"; throw "rt null";
sys.clip.state.FP=sys.clip.state.next_FP; sem_post(&mutex);

sys.advanceFP();
sem_post(&sys.clip.sem_frames);
} }
} }


using namespace std; using namespace std;


char* NPP_GetMIMEDescription(void) char* NPP_GetMIMEDescription(void)
{ {
return(MIME_TYPES_DESCRIPTION); return (char*)(MIME_TYPES_DESCRIPTION);
} }


///////////////////////////////////// /////////////////////////////////////
Expand All @@ -92,10 +86,10 @@ NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue)
switch (aVariable) switch (aVariable)
{ {
case NPPVpluginNameString: case NPPVpluginNameString:
*((char **)aValue) = PLUGIN_NAME; *((char **)aValue) = (char*)PLUGIN_NAME;
break; break;
case NPPVpluginDescriptionString: case NPPVpluginDescriptionString:
*((char **)aValue) = PLUGIN_DESCRIPTION; *((char **)aValue) = (char*)PLUGIN_DESCRIPTION;
break; break;
default: default:
err = NPERR_INVALID_PARAM; err = NPERR_INVALID_PARAM;
Expand Down Expand Up @@ -242,7 +236,7 @@ NPError nsPluginInstance::SetWindow(NPWindow* aWindow)
abort(); abort();
} }
rt=new RenderThread(NPAPI,p); rt=new RenderThread(NPAPI,p);
mt.rt=rt; mt.setRenderThread(rt);


// add xt event handler // add xt event handler
Widget xtwidget = XtWindowToWidget(mDisplay, mWindow); Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
Expand Down
4 changes: 3 additions & 1 deletion plugin/plugin.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ class MovieTimer
private: private:
static pthread_t t; static pthread_t t;
static void* timer_worker(void*); static void* timer_worker(void*);
static RenderThread* rt;
static sem_t mutex;
public: public:
MovieTimer(RenderThread* r); MovieTimer(RenderThread* r);
static RenderThread* rt; void setRenderThread(RenderThread* r);
}; };


class nsPluginInstance : public nsPluginInstanceBase class nsPluginInstance : public nsPluginInstanceBase
Expand Down
Loading

0 comments on commit 19b3023

Please sign in to comment.