David Rose 16 éve
szülő
commit
74d2ff3b54

+ 1 - 1
direct/src/plugin/p3dConcreteSequence.cxx

@@ -122,7 +122,7 @@ set_property(const string &property, P3D_object *value) {
   char *endptr;
   char *endptr;
   int index = strtoul(property.c_str(), &endptr, 10);
   int index = strtoul(property.c_str(), &endptr, 10);
   if (*endptr != '\0') {
   if (*endptr != '\0') {
-    return NULL;
+    return false;
   }
   }
 
 
   return set_element(index, value);
   return set_element(index, value);

+ 3 - 3
direct/src/plugin/p3dOsxSplashWindow.cxx

@@ -60,11 +60,10 @@ P3DOsxSplashWindow::
 void P3DOsxSplashWindow::
 void P3DOsxSplashWindow::
 set_image_filename(const string &image_filename,
 set_image_filename(const string &image_filename,
                    bool image_filename_temp) {
                    bool image_filename_temp) {
-  int num_channels, row_stride;
+  int num_channels;
   string data;
   string data;
   if (!read_image(image_filename, image_filename_temp, 
   if (!read_image(image_filename, image_filename_temp, 
-                  _image_height, _image_width, num_channels, row_stride,
-                  data)) {
+                  _image_height, _image_width, num_channels, data)) {
     return;
     return;
   }
   }
 
 
@@ -82,6 +81,7 @@ set_image_filename(const string &image_filename,
   }
   }
 
 
   // Now we need to copy from the RGB source image into the BGRA target image.
   // Now we need to copy from the RGB source image into the BGRA target image.
+  int row_stride = _image_width * num_channels;
   int new_row_stride = _image_width * 4;
   int new_row_stride = _image_width * 4;
   _image_data = new char[new_row_stride * _image_height];
   _image_data = new char[new_row_stride * _image_height];
   for (int yi = 0; yi < _image_height; ++yi) {
   for (int yi = 0; yi < _image_height; ++yi) {

+ 2 - 2
direct/src/plugin/p3dPackage.cxx

@@ -402,9 +402,9 @@ uncompress_archive() {
     return;
     return;
   }
   }
   
   
-  static const int decompress_buffer_size = 1024;
+  static const int decompress_buffer_size = 81920;
   char decompress_buffer[decompress_buffer_size];
   char decompress_buffer[decompress_buffer_size];
-  static const int write_buffer_size = 1024;
+  static const int write_buffer_size = 81920;
   char write_buffer[write_buffer_size];
   char write_buffer[write_buffer_size];
 
 
   z_stream z;
   z_stream z;

+ 5 - 11
direct/src/plugin/p3dSplashWindow.cxx

@@ -127,19 +127,17 @@ handle_event(P3D_event_data event) {
 //     Function: P3DSplashWindow::read_image
 //     Function: P3DSplashWindow::read_image
 //       Access: Protected
 //       Access: Protected
 //  Description: Reads the image filename and sets image parameters
 //  Description: Reads the image filename and sets image parameters
-//               height, width, num_channels, row_stride, and data.
-//               Returns true on success, false on failure.  If
-//               image_filename_temp is true, the file will be deleted
-//               after reading.
+//               height, width, num_channels, and data.  Returns true
+//               on success, false on failure.  If image_filename_temp
+//               is true, the file will be deleted after reading.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool P3DSplashWindow::
 bool P3DSplashWindow::
 read_image(const string &image_filename, bool image_filename_temp,
 read_image(const string &image_filename, bool image_filename_temp,
-           int &height, int &width, int &num_channels, int &row_stride,
+           int &height, int &width, int &num_channels, 
            string &data) {
            string &data) {
   height = 0;
   height = 0;
   width = 0;
   width = 0;
   num_channels = 0;
   num_channels = 0;
-  row_stride = 0;
   data.clear();
   data.clear();
 
 
   // We currently only support JPEG images.  Maybe that's all we'll
   // We currently only support JPEG images.  Maybe that's all we'll
@@ -198,11 +196,7 @@ read_image(const string &image_filename, bool image_filename_temp,
   height = cinfo.output_height;
   height = cinfo.output_height;
   num_channels = cinfo.output_components;
   num_channels = cinfo.output_components;
 
 
-  row_stride = width * num_channels;
-
-  // We'll pad row_stride out to word alignment, in case someone
-  // requires this.
-  row_stride = 4 * ((row_stride + 3) / 4);
+  int row_stride = width * num_channels;
 
 
   size_t buffer_size = height * row_stride;
   size_t buffer_size = height * row_stride;
   buffer = new JSAMPLE[buffer_size];
   buffer = new JSAMPLE[buffer_size];

+ 1 - 2
direct/src/plugin/p3dSplashWindow.h

@@ -53,8 +53,7 @@ public:
 
 
 protected:
 protected:
   bool read_image(const string &image_filename, bool image_filename_temp,
   bool read_image(const string &image_filename, bool image_filename_temp,
-                  int &height, int &width, int &num_channels, int &row_stride,
-                  string &data);
+                  int &height, int &width, int &num_channels, string &data);
 
 
 protected:
 protected:
   P3DInstance *_inst;
   P3DInstance *_inst;

+ 3 - 3
direct/src/plugin/p3dWinSplashWindow.cxx

@@ -467,14 +467,14 @@ update_image_filename(const string &image_filename, bool image_filename_temp) {
 
 
   // Go read the image.
   // Go read the image.
   string data;
   string data;
-  int num_channels, row_stride;
+  int num_channels;
   if (!read_image(image_filename, image_filename_temp, 
   if (!read_image(image_filename, image_filename_temp, 
-                  _bitmap_height, _bitmap_width, num_channels, row_stride,
-                  data)) {
+                  _bitmap_height, _bitmap_width, num_channels, data)) {
     return;
     return;
   }
   }
 
 
   // Massage the data into Windows' conventions.
   // Massage the data into Windows' conventions.
+  int row_stride = _bitmap_width * num_channels;
   int new_row_stride = (_bitmap_width * 3);
   int new_row_stride = (_bitmap_width * 3);
   // DWORD-pad the row.
   // DWORD-pad the row.
   new_row_stride = 4 * ((new_row_stride + 3) / 4);
   new_row_stride = 4 * ((new_row_stride + 3) / 4);

+ 18 - 12
direct/src/plugin/p3dX11SplashWindow.cxx

@@ -220,11 +220,11 @@ thread_run() {
       redraw(install_label);
       redraw(install_label);
       override = false;
       override = false;
       XFillRectangle(_display, _window, _graphics_context, 12, _height - 18,
       XFillRectangle(_display, _window, _graphics_context, 12, _height - 18,
-                                       install_progress * (_width - 24), 7);
+                     (unsigned int)(install_progress * (_width - 24)), 7);
       XFlush(_display);
       XFlush(_display);
     } else if (install_progress != prev_progress) {
     } else if (install_progress != prev_progress) {
       XFillRectangle(_display, _window, _graphics_context, 12, _height - 18,
       XFillRectangle(_display, _window, _graphics_context, 12, _height - 18,
-                                      install_progress * (_width - 24), 7);
+                     (unsigned int)(install_progress * (_width - 24)), 7);
     }
     }
     prev_label = install_label;
     prev_label = install_label;
     prev_progress = install_progress;
     prev_progress = install_progress;
@@ -250,10 +250,14 @@ redraw(string label) {
     // We have an image. Let's see how we can output it.
     // We have an image. Let's see how we can output it.
     if (_image_width <= _width && _image_height <= _height) {
     if (_image_width <= _width && _image_height <= _height) {
       // It fits within the window - just draw it.
       // It fits within the window - just draw it.
-      XPutImage(_display, _window, _graphics_context, _image, 0, 0, (_width - _image_width) * 0.5, (_height - _image_height) * 0.5, _image_width, _image_height);
+      XPutImage(_display, _window, _graphics_context, _image, 0, 0, 
+                (_width - _image_width) / 2, (_height - _image_height) / 2,
+                _image_width, _image_height);
     } else if (_resized_image != NULL) {
     } else if (_resized_image != NULL) {
       // We have a resized image already, draw that one.
       // We have a resized image already, draw that one.
-      XPutImage(_display, _window, _graphics_context, _resized_image, 0, 0, (_width - _resized_width) * 0.5, (_height - _resized_height) * 0.5, _resized_width, _resized_height);
+      XPutImage(_display, _window, _graphics_context, _resized_image, 0, 0, 
+                (_width - _resized_width) / 2, (_height - _resized_height) / 2,
+                _resized_width, _resized_height);
     } else {
     } else {
       // Yuck, the bad case - we need to scale it down.
       // Yuck, the bad case - we need to scale it down.
       double scale = min((double) _width  / (double) _image_width,
       double scale = min((double) _width  / (double) _image_width,
@@ -262,17 +266,20 @@ redraw(string label) {
       _resized_height = (int)(_image_height * scale);
       _resized_height = (int)(_image_height * scale);
       char *new_data = (char*) malloc(4 * _width * _height);
       char *new_data = (char*) malloc(4 * _width * _height);
       _resized_image = XCreateImage(_display, CopyFromParent, DefaultDepth(_display, _screen), 
       _resized_image = XCreateImage(_display, CopyFromParent, DefaultDepth(_display, _screen), 
-                                        ZPixmap, 0, (char *) new_data, _width, _height, 32, 0);
+                                    ZPixmap, 0, (char *) new_data, _width, _height, 32, 0);
       double x_ratio = ((double) _image_width) / ((double) _resized_width);
       double x_ratio = ((double) _image_width) / ((double) _resized_width);
       double y_ratio = ((double) _image_height) / ((double) _resized_height);
       double y_ratio = ((double) _image_height) / ((double) _resized_height);
       for (int x = 0; x < _width; ++x) {
       for (int x = 0; x < _width; ++x) {
         for (int y = 0; y < _height; ++y) {
         for (int y = 0; y < _height; ++y) {
-          XPutPixel(_resized_image, x, y, XGetPixel(_image,
-                         clamp(x * x_ratio, 0, _image_width),
-                         clamp(y * y_ratio, 0, _image_height)));
+          XPutPixel(_resized_image, x, y, 
+                    XGetPixel(_image,
+                              (int)clamp(x * x_ratio, 0, _image_width),
+                              (int)clamp(y * y_ratio, 0, _image_height)));
         }
         }
       }
       }
-      XPutImage(_display, _window, _graphics_context, _resized_image, 0, 0, (_width - _resized_width) * 0.5, (_height - _resized_height) * 0.5, _resized_width, _resized_height);
+      XPutImage(_display, _window, _graphics_context, _resized_image, 0, 0,
+                (_width - _resized_width) / 2, (_height - _resized_height) / 2,
+                _resized_width, _resized_height);
     }
     }
     XClearArea(_display, _window, 10, _height - 20, _width - 20, 10, false);
     XClearArea(_display, _window, 10, _height - 20, _width - 20, 10, false);
   }
   }
@@ -409,10 +416,9 @@ update_image_filename(const string &image_filename, bool image_filename_temp) {
 
 
   // Go read the image.
   // Go read the image.
   string data;
   string data;
-  int num_channels, row_stride;
+  int num_channels;
   if (!read_image(image_filename, image_filename_temp, 
   if (!read_image(image_filename, image_filename_temp, 
-                  _image_height, _image_width, num_channels, row_stride,
-                  data)) {
+                  _image_height, _image_width, num_channels, data)) {
     return;
     return;
   }
   }
 
 

+ 3 - 5
direct/src/plugin_npapi/nppanda3d_common.h

@@ -62,14 +62,12 @@ extern ofstream logfile;
 
 
 #include "load_plugin.h"
 #include "load_plugin.h"
 
 
-// Uncomment the following to enable use of the PluginThreadAsyncCall
-// function.  (It's commented out for now to assist development of the
-// case in which this is not available.)
-/*
+// If we are building with a version of Gecko that supports the
+// asynchronous callback function, we should use it--it's just so
+// handy.
 #if defined(NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) && NP_VERSION_MINOR >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL
 #if defined(NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL) && NP_VERSION_MINOR >= NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL
 #define HAS_PLUGIN_THREAD_ASYNC_CALL 1
 #define HAS_PLUGIN_THREAD_ASYNC_CALL 1
 #endif
 #endif
-*/
 
 
 // Appears in startup.cxx.
 // Appears in startup.cxx.
 extern NPNetscapeFuncs *browser;
 extern NPNetscapeFuncs *browser;

+ 24 - 19
direct/src/plugin_npapi/ppInstance.cxx

@@ -458,6 +458,25 @@ handle_request(P3D_request *request) {
   P3D_request_finish(request, handled);
   P3D_request_finish(request, handled);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: PPInstance::generic_browser_call
+//       Access: Public, Static
+//  Description: This method is called from strategically-chosen
+//               browser callback functions.  Its purpose is to
+//               provide another hook into the main thread callback,
+//               particularly if the PluginAsyncCall function isn't
+//               available.
+////////////////////////////////////////////////////////////////////
+void PPInstance::
+generic_browser_call() {
+#ifndef HAS_PLUGIN_THREAD_ASYNC_CALL
+  // If we can't ask Mozilla to call us back using
+  // NPN_PluginThreadAsyncCall(), then we'll do it explicitly now,
+  // since we know we're in the main thread here.
+  handle_request_loop();
+#endif
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: PPInstance::handle_event
 //     Function: PPInstance::handle_event
 //       Access: Public
 //       Access: Public
@@ -469,13 +488,6 @@ bool PPInstance::
 handle_event(void *event) {
 handle_event(void *event) {
   bool retval = false;
   bool retval = false;
 
 
-#ifndef HAS_PLUGIN_THREAD_ASYNC_CALL
-  // If we can't ask Mozilla to call us back using
-  // NPN_PluginThreadAsyncCall(), then we'll take advantage of the
-  // event loop to do it now.
-  handle_request_loop();
-#endif
-
   if (_p3d_inst == NULL) {
   if (_p3d_inst == NULL) {
     // Ignore events that come in before we've launched the instance.
     // Ignore events that come in before we've launched the instance.
     return retval;
     return retval;
@@ -653,16 +665,9 @@ request_ready(P3D_instance *instance) {
   }
   }
 
 
 #else
 #else
-  // On Mac, we ignore this asynchronous event, and rely on detecting
-  // it within HandleEvent().  TODO: enable a timer to ensure we get
-  // HandleEvent callbacks in a timely manner?  Or maybe we should
-  // enable a one-shot timer in response to this asynchronous event?
-  
-#ifndef __APPLE__
-  // On Unix, HandleEvent isn't called, so we will do what it does
-  // right here. Not sure if this is right.
-  handle_request_loop();
-#endif  // __APPLE__
+  // On Mac and Linux, we ignore this asynchronous event, and rely on
+  // detecting it within HandleEvent() and similar callbacks.
+
 #endif  // _WIN32
 #endif  // _WIN32
 
 
 #endif  // HAS_PLUGIN_THREAD_ASYNC_CALL
 #endif  // HAS_PLUGIN_THREAD_ASYNC_CALL
@@ -709,8 +714,8 @@ read_contents_file(const string &filename) {
     xpackage = xpackage->NextSiblingElement("package");
     xpackage = xpackage->NextSiblingElement("package");
   }
   }
 
 
-  // Couldn't find the core package description.
-  logfile << "No core package defined in contents file.\n" << flush;
+  // Couldn't find the coreapi package description.
+  logfile << "No coreapi package defined in contents file.\n" << flush;
   return false;
   return false;
 }
 }
 
 

+ 1 - 0
direct/src/plugin_npapi/ppInstance.h

@@ -51,6 +51,7 @@ public:
   void stream_as_file(NPStream *stream, const char *fname);
   void stream_as_file(NPStream *stream, const char *fname);
 
 
   void handle_request(P3D_request *request);
   void handle_request(P3D_request *request);
+  static void generic_browser_call();
 
 
   bool handle_event(void *event);
   bool handle_event(void *event);
 
 

+ 9 - 3
direct/src/plugin_npapi/startup.cxx

@@ -176,9 +176,7 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
 
 
   // To experiment with a "windowless" plugin, which really means we
   // To experiment with a "windowless" plugin, which really means we
   // create our own window without an intervening window, try this.
   // create our own window without an intervening window, try this.
-  // At the moment, there's a deadlock condition when we try it, but
-  // surely it can be solved.
-  //  browser->setvalue(instance, NPPVpluginWindowBool, (void *)false);
+  //browser->setvalue(instance, NPPVpluginWindowBool, (void *)false);
 
 
   // Now that we have stored the pointer, we can call begin(), which
   // Now that we have stored the pointer, we can call begin(), which
   // starts to initiate downloads.
   // starts to initiate downloads.
@@ -239,6 +237,7 @@ NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream,
           << ", " << stream->end 
           << ", " << stream->end 
           << ", notifyData = " << stream->notifyData
           << ", notifyData = " << stream->notifyData
           << "\n" << flush;
           << "\n" << flush;
+  PPInstance::generic_browser_call();
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
 
 
@@ -258,6 +257,7 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason) {
           << ", reason = " << reason
           << ", reason = " << reason
           << "\n" << flush;
           << "\n" << flush;
 
 
+  PPInstance::generic_browser_call();
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
 
 
@@ -286,6 +286,7 @@ NPP_WriteReady(NPP instance, NPStream *stream) {
 int32
 int32
 NPP_Write(NPP instance, NPStream *stream, int32 offset, 
 NPP_Write(NPP instance, NPStream *stream, int32 offset, 
           int32 len, void *buffer) {
           int32 len, void *buffer) {
+  PPInstance::generic_browser_call();
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
 
 
@@ -306,6 +307,7 @@ NPP_StreamAsFile(NPP instance, NPStream *stream, const char *fname) {
           << ", notifyData = " << stream->notifyData
           << ", notifyData = " << stream->notifyData
           << "\n" << flush;
           << "\n" << flush;
 
 
+  PPInstance::generic_browser_call();
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
 
 
@@ -330,6 +332,7 @@ NPP_Print(NPP instance, NPPrint *platformPrint) {
 int16
 int16
 NPP_HandleEvent(NPP instance, void *event) {
 NPP_HandleEvent(NPP instance, void *event) {
   //  logfile << "HandleEvent\n" << flush;
   //  logfile << "HandleEvent\n" << flush;
+  PPInstance::generic_browser_call();
 
 
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
@@ -350,6 +353,7 @@ NPP_URLNotify(NPP instance, const char *url,
           << ", reason = " << reason
           << ", reason = " << reason
           << "\n" << flush;
           << "\n" << flush;
 
 
+  PPInstance::generic_browser_call();
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
 
 
@@ -364,6 +368,7 @@ NPP_URLNotify(NPP instance, const char *url,
 NPError
 NPError
 NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
 NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
   logfile << "GetValue " << variable << "\n";
   logfile << "GetValue " << variable << "\n";
+  PPInstance::generic_browser_call();
   PPInstance *inst = (PPInstance *)(instance->pdata);
   PPInstance *inst = (PPInstance *)(instance->pdata);
   assert(inst != NULL);
   assert(inst != NULL);
 
 
@@ -387,6 +392,7 @@ NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
 NPError 
 NPError 
 NPP_SetValue(NPP instance, NPNVariable variable, void *value) {
 NPP_SetValue(NPP instance, NPNVariable variable, void *value) {
   logfile << "SetValue " << variable << "\n";
   logfile << "SetValue " << variable << "\n";
+  PPInstance::generic_browser_call();
   return NPERR_GENERIC_ERROR;
   return NPERR_GENERIC_ERROR;
 }
 }