Permalink
Browse files

Massive code cleanup

  • Loading branch information...
1 parent acc7ae8 commit 19b3023274e2b09af73be039ad68a9e2da3c4bf0 @alexp-sssup alexp-sssup committed Apr 3, 2009
Showing with 245 additions and 204 deletions.
  1. +0 −1 TODO
  2. +1 −4 frame.h
  3. +6 −25 main.cpp
  4. +21 −27 plugin/plugin.cpp
  5. +3 −1 plugin/plugin.h
  6. +152 −46 swf.cpp
  7. +29 −11 swf.h
  8. +32 −87 tags.cpp
  9. +1 −2 tags.h
View
1 TODO
@@ -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
View
@@ -31,12 +31,9 @@ class Frame
STRING Label;
public:
std::list<DisplayListTag*> displayList;
-
- Frame(const std::list<DisplayListTag*>& d):displayList(d),hack(0){ }
+ Frame(const std::list<DisplayListTag*>& d):displayList(d){ }
void Render(int baseLayer);
void setLabel(STRING l);
-
- int hack;
};
#endif
View
@@ -49,31 +49,12 @@ int main()
RenderThread rt(SDL,NULL);
InputThread it;
- while(1)
- {
- if(sys.clip.state.stop_FP && !sys.update_request)
- sem_wait(&sys.sem_run);
- 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;
- rt.draw(&sys.clip.frames[sys.clip.state.FP]);
- sys.clip.state.FP=sys.clip.state.next_FP;
-
- sem_post(&sys.clip.sem_frames);
- }
+ while(1)
+ {
+ sys.waitToRun();
+ rt.draw(&sys.getFrameAtFP());
+ sys.advanceFP();
+ }
cout << "the end" << endl;
View
@@ -27,50 +27,44 @@
SystemState sys;
pthread_t MovieTimer::t;
-RenderThread* MovieTimer::rt(NULL);
+sem_t MovieTimer::mutex;
+RenderThread* MovieTimer::rt=NULL;
MovieTimer::MovieTimer(RenderThread* r)
{
+ sem_init(&mutex,0,1);
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*)
{
while(1)
{
- if(sys.clip.state.stop_FP && !sys.update_request)
- sem_wait(&sys.sem_run);
- 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;
+ sys.waitToRun();
+ sem_wait(&mutex);
if(rt!=NULL)
- rt->draw(&sys.clip.frames[sys.clip.state.FP]);
+ rt->draw(&sys.getFrameAtFP());
else
throw "rt null";
- sys.clip.state.FP=sys.clip.state.next_FP;
-
- sem_post(&sys.clip.sem_frames);
+ sem_post(&mutex);
+ sys.advanceFP();
}
}
using namespace std;
char* NPP_GetMIMEDescription(void)
{
- return(MIME_TYPES_DESCRIPTION);
+ return (char*)(MIME_TYPES_DESCRIPTION);
}
/////////////////////////////////////
@@ -92,10 +86,10 @@ NPError NS_PluginGetValue(NPPVariable aVariable, void *aValue)
switch (aVariable)
{
case NPPVpluginNameString:
- *((char **)aValue) = PLUGIN_NAME;
+ *((char **)aValue) = (char*)PLUGIN_NAME;
break;
case NPPVpluginDescriptionString:
- *((char **)aValue) = PLUGIN_DESCRIPTION;
+ *((char **)aValue) = (char*)PLUGIN_DESCRIPTION;
break;
default:
err = NPERR_INVALID_PARAM;
@@ -242,7 +236,7 @@ NPError nsPluginInstance::SetWindow(NPWindow* aWindow)
abort();
}
rt=new RenderThread(NPAPI,p);
- mt.rt=rt;
+ mt.setRenderThread(rt);
// add xt event handler
Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
View
@@ -38,9 +38,11 @@ class MovieTimer
private:
static pthread_t t;
static void* timer_worker(void*);
+ static RenderThread* rt;
+ static sem_t mutex;
public:
MovieTimer(RenderThread* r);
- static RenderThread* rt;
+ void setRenderThread(RenderThread* r);
};
class nsPluginInstance : public nsPluginInstanceBase
Oops, something went wrong.

0 comments on commit 19b3023

Please sign in to comment.