diff options
author | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 20:19:04 +0000 |
---|---|---|
committer | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-13 20:19:04 +0000 |
commit | cd7b299fd6053afcd625ce36f0e51f94c83b182c (patch) | |
tree | c8db33db4106077f2b9c16bc6b5e6822568e411f /o3d/plugin/mac | |
parent | 3d2da9c08491d46c0b3f8dcdccbb6d1c84bfbc40 (diff) | |
download | chromium_src-cd7b299fd6053afcd625ce36f0e51f94c83b182c.zip chromium_src-cd7b299fd6053afcd625ce36f0e51f94c83b182c.tar.gz chromium_src-cd7b299fd6053afcd625ce36f0e51f94c83b182c.tar.bz2 |
Plugin no longer makes synchronous NPAPI calls from a Windows message handler. This fixes deadlocks and slowdown in Chrome. The approach is strange. It asynchronously opens the url data:, and then invokes Tick from the finish callback. This is the simplest approach I could think of that hide widespread browser support. NPN_PluginThreadAsyncCall would be ideal but it is supported by all browsers we currently support.
Review URL: http://codereview.chromium.org/149415
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin/mac')
-rw-r--r-- | o3d/plugin/mac/main_mac.mm | 20 | ||||
-rw-r--r-- | o3d/plugin/mac/plugin_mac.mm | 25 |
2 files changed, 13 insertions, 32 deletions
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm index 3427505..1ef1d1c 100644 --- a/o3d/plugin/mac/main_mac.mm +++ b/o3d/plugin/mac/main_mac.mm @@ -70,25 +70,11 @@ namespace { // destroy it explicitly. scoped_ptr<base::AtExitManager> g_at_exit_manager; -// if defined, in AGL mode we do double buffered drawing -// #define USE_AGL_DOUBLE_BUFFER - #define CFTIMER // #define DEFERRED_DRAW_ON_NULLEVENTS -// currently drawing with the timer doesn't play well with USE_AGL_DOUBLE_BUFFER -#ifdef CFTIMER -#undef USE_AGL_DOUBLE_BUFFER -#endif - void DrawPlugin(PluginObject* obj) { obj->client()->RenderClient(); -#ifdef USE_AGL_DOUBLE_BUFFER - // In AGL mode, we have to call aglSwapBuffers to guarantee that our - // pixels make it to the screen. - if (obj->mac_agl_context_ != NULL) - aglSwapBuffers(obj->mac_agl_context_); -#endif } unsigned char GetMacEventKeyChar(const EventRecord *the_event) { @@ -809,10 +795,6 @@ bool HandleMacEvent(EventRecord* the_event, NPP instance) { return handled; } -void RenderOnDemandCallbackHandler::Run() { - obj_->SetWantsRedraw(true); -} - NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved) { HANDLE_CRASHES; @@ -1124,8 +1106,6 @@ NPError NPP_SetWindow(NPP instance, NPWindow* window) { } obj->client()->Init(); - obj->client()->SetRenderOnDemandCallback( - new RenderOnDemandCallbackHandler(obj)); if (obj->renderer()) { obj->renderer()->SetClientOriginOffset(gl_x_origin, gl_y_origin); diff --git a/o3d/plugin/mac/plugin_mac.mm b/o3d/plugin/mac/plugin_mac.mm index 459f116..5df3b88 100644 --- a/o3d/plugin/mac/plugin_mac.mm +++ b/o3d/plugin/mac/plugin_mac.mm @@ -234,19 +234,20 @@ void RenderTimer::TimerCallback(CFRunLoopTimerRef timer, void* info) { bool plugin_visible = in_fullscreen || (obj->last_buffer_rect_[2] > 1 && obj->last_buffer_rect_[3] > 1); - if (plugin_visible && obj->WantsRedraw()) { - obj->SetWantsRedraw(false); // for on-demand drawing - - // Force a sync to the VBL (once per timer callback) - // to avoid tearing - GLint sync = (i == 0); - if (obj->mac_cgl_context_) { - CGLSetParameter(obj->mac_cgl_context_, kCGLCPSwapInterval, &sync); - } else if (obj->mac_agl_context_) { - aglSetInteger(obj->mac_agl_context_, AGL_SWAP_INTERVAL, &sync); - } + if (plugin_visible && obj->renderer()) { + if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS || + obj->renderer()->need_to_render()) { + // Force a sync to the VBL (once per timer callback) + // to avoid tearing + GLint sync = (i == 0); + if (obj->mac_cgl_context_) { + CGLSetParameter(obj->mac_cgl_context_, kCGLCPSwapInterval, &sync); + } else if (obj->mac_agl_context_) { + aglSetInteger(obj->mac_agl_context_, AGL_SWAP_INTERVAL, &sync); + } - obj->client()->RenderClient(); + obj->client()->RenderClient(); + } } } } |