Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

movie.cc

Go to the documentation of this file.
00001 
00002 // Flash Plugin and Player
00003 // Copyright (C) 1998,1999 Olivier Debon
00004 // 
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 // 
00020 //  Author : Olivier Debon  <odebon@club-internet.fr>
00021 //  
00022 #include "movie.h"
00023 
00024 FlashMovie::FlashMovie() 
00025 {
00026         gd = NULL;
00027         sm = NULL;
00028         getSwf = NULL;
00029         getUrl = NULL;
00030         cursorOnOff = NULL;
00031         buttons_updated = 0;
00032         scheduledTime.tv_sec = -1;
00033         cur_focus = NULL;
00034         lost_over = NULL;
00035         msPerFrame = 0;
00036 
00037         /* mouse handling */
00038         mouse_active = 0;
00039         mouse_x = -1;
00040         mouse_y = -1;
00041         button_pressed = 0;
00042         refresh = 1;
00043 }
00044     
00045 FlashMovie::~FlashMovie() 
00046 {
00047         CInputScript *n;
00048 
00049         while (main != NULL) {
00050                 n = main->next;
00051                 delete main;
00052                 main = n;
00053         }
00054 
00055         if (gd) delete gd;
00056         if (sm) delete sm;
00057 }
00058 
00059 int
00060 FlashMovie::processMovie(GraphicDevice *gd, SoundMixer *sm)
00061 {
00062         CInputScript *script;
00063         int wakeUp = 0;
00064 
00065         if (sm && sm->playSounds()) {
00066                 wakeUp = 1;
00067         }
00068         for (script = this->main; script != NULL; script = script->next) {
00069                 if (script->program == NULL) continue;
00070                 if (script->program->nbFrames == 0) continue;
00071                 if (script->program->processMovie(gd,sm)) {
00072                         wakeUp = 1;
00073                 }
00074         }
00075         renderMovie();
00076         return wakeUp;
00077 }
00078 
00079 int
00080 FlashMovie::handleEvent(GraphicDevice *gd, SoundMixer *sm, FlashEvent *event)
00081 {
00082         int wakeUp = 0;
00083 
00084         if (sm && sm->playSounds()) {
00085                 wakeUp = 1;
00086         }
00087         if (this->main == 0) return 0;
00088         if (this->main->program == 0) return 0;
00089         if (this->main->program->handleEvent(gd, sm, event)) {
00090                 wakeUp = 1;
00091         }
00092         renderMovie();
00093         return wakeUp;
00094 }
00095 
00096 /* current focus bigger and translated if needed */
00097 void
00098 FlashMovie::renderFocus()
00099 {
00100         Rect rect,boundary;
00101         Matrix mat;
00102 
00103         if (mouse_active || !cur_focus) return;
00104 
00105         /* rect is the bbox in screen coordinates */
00106 
00107         // Compute the bounding box in screen coordinates
00108         cur_focus->character->getBoundingBox(&boundary,cur_focus);
00109         mat = (*gd->adjust) * cur_focus->renderMatrix;
00110         transformBoundingBox(&rect, &mat, &boundary, 1);
00111 
00112         gd->drawBox(rect.xmin, rect.ymin, rect.xmax, rect.ymax);
00113 }
00114 
00115 void 
00116 FlashMovie::renderMovie()
00117 {
00118         CInputScript *script,*prev,*next;
00119         Rect clipping;
00120         Matrix identity;
00121 
00122         clipping.reset();
00123 
00124         // First pass to update the clipping region
00125         for (script = this->main; script != NULL; script = script->next) {
00126                 if (script->level == -1) {
00127                         clipping.xmin = -32768;
00128                         clipping.ymin = -32768;
00129                         clipping.xmax =  32767;
00130                         clipping.ymax =  32767;
00131                         continue;
00132                 }
00133                 if (script->program == NULL) continue;
00134                 if (script->program->dl->bbox.xmin == LONG_MAX) continue;
00135                 transformBoundingBox(&clipping, &identity, &script->program->dl->bbox, 0);
00136                 script->program->render = 0;
00137         }
00138 
00139         if (clipping.xmin == LONG_MAX) return;
00140 
00141         // Update the clipping region
00142         gd->updateClippingRegion(&clipping);
00143         gd->clearCanvas();
00144 
00145         // Second pass to render the movie
00146         for (script = this->main; script != NULL; script = script->next) {
00147                 if (script->level == -1) continue;
00148                 if (script->program == NULL) continue;
00149                 script->program->dl->render(gd);
00150         }
00151         renderFocus();
00152 
00153         // Final pass to delete some movies
00154         script = this->main;
00155         prev = 0;
00156         while (script != NULL) {
00157                 if (script->level == -1) {
00158                         next = script->next;
00159                         if (prev == 0) {
00160                                 this->main = next;
00161                         } else {
00162                                 prev->next = next;
00163                         }
00164                         delete script;
00165                         script = next;
00166                 } else {
00167                         prev = script;
00168                         script = script->next;
00169                 }
00170         }
00171 }

Generated on Sat Nov 5 16:15:35 2005 for OPIE by  doxygen 1.4.2