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/win/main_win.cc | |
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/win/main_win.cc')
-rw-r--r-- | o3d/plugin/win/main_win.cc | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/o3d/plugin/win/main_win.cc b/o3d/plugin/win/main_win.cc index 48c1be1..d2727d7 100644 --- a/o3d/plugin/win/main_win.cc +++ b/o3d/plugin/win/main_win.cc @@ -512,7 +512,7 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { ::SetPixelV(hdc, 0, 0, RGB(0, 0, 0)); } - obj->client()->RenderClient(); + obj->renderer()->set_need_to_render(true); } else { // If there Client has no Renderer associated with it, paint the draw // area gray. @@ -552,24 +552,22 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { if (reentrance_count.get() > 1) { break; // Ignore this message; we're reentrant. } - // DoOnFrameCallback(obj); // TODO: Only logging for windows until we figure out the proper // mac way if (g_logger) g_logger->UpdateLogging(); - obj->client()->Tick(); - if (obj->client()->render_mode() == - o3d::Client::RENDERMODE_CONTINUOUS) { - // Must invalidate GetHWnd()'s drawing area, no matter which window is - // receiving this event. It turns out that we have to set the timer on - // the window we're using for drawing anyway, whichever that is, but - // it's possible that an extra event will slip through. - ::InvalidateRect(obj->GetHWnd(), NULL, TRUE); + // If rendering continuously, invalidate the window and force a paint if + // it is visible. The paint invalidates the renderer and Tick will later + // repaint the window. + if (obj->client()->render_mode() == o3d::Client::RENDERMODE_CONTINUOUS) { + InvalidateRect(obj->GetHWnd(), NULL, FALSE); + reentrance_count.decrement(); + UpdateWindow(obj->GetHWnd()); } - // Calling UpdateWindow to force a WM_PAINT here causes problems in - // Firefox 2 if rendering takes too long. WM_PAINT will be sent anyway - // when there are no other messages to process. + + obj->AsyncTick(); + break; } case WM_NCDESTROY: { @@ -815,9 +813,6 @@ NPError OSCALL NP_Shutdown(void) { } // extern "C" / namespace o3d namespace o3d { -void RenderOnDemandCallbackHandler::Run() { - ::InvalidateRect(obj_->GetHWnd(), NULL, TRUE); -} NPError NPP_New(NPMIMEType pluginType, NPP instance, @@ -912,8 +907,6 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window) { obj->CreateRenderer(default_display); obj->client()->Init(); - obj->client()->SetRenderOnDemandCallback( - new RenderOnDemandCallbackHandler(obj)); // we set the timer to 10ms or 100fps. At the time of this comment // the renderer does a vsync the max fps it will run will be the refresh |