diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 19:34:15 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 19:34:15 +0000 |
commit | 090e45fd4f5f4f56157dd140bba65a20bf5c777a (patch) | |
tree | 4dc313ff82bc765a930ab864e41174a3c1e8f378 /o3d/plugin/mac | |
parent | bd63475e7bbf9927b645a4645d27d6987b4d4d78 (diff) | |
download | chromium_src-090e45fd4f5f4f56157dd140bba65a20bf5c777a.zip chromium_src-090e45fd4f5f4f56157dd140bba65a20bf5c777a.tar.gz chromium_src-090e45fd4f5f4f56157dd140bba65a20bf5c777a.tar.bz2 |
Fixed bug in Core Graphics backend where it was falling through to the
AGL initialization code path in some situations, causing full-screen
mode (at least) to break. Also fixed bug causing plugin to become
reentrant during event dispatching.
BUG=none
TEST=none
TBR=maf
Review URL: http://codereview.chromium.org/2339002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin/mac')
-rw-r--r-- | o3d/plugin/mac/main_mac.mm | 65 | ||||
-rw-r--r-- | o3d/plugin/mac/plugin_mac.mm | 6 |
2 files changed, 39 insertions, 32 deletions
diff --git a/o3d/plugin/mac/main_mac.mm b/o3d/plugin/mac/main_mac.mm index 328c84b..3e05180 100644 --- a/o3d/plugin/mac/main_mac.mm +++ b/o3d/plugin/mac/main_mac.mm @@ -1043,39 +1043,40 @@ NPError NPP_SetWindow(NPP instance, NPWindow* window) { if (obj->mac_cgl_context_) { CGLSetCurrentContext(obj->mac_cgl_context_); } - } else if (obj->drawing_model_ == NPDrawingModelCoreGraphics && - obj->mac_cgl_pbuffer_ == NULL) { - // We initialize things with a CGL context rendering to a 1x1 - // pbuffer. Later we use the O3D RenderSurface APIs to set up the - // framebuffer object which is used for rendering. - CGLContextObj share_context = obj->GetFullscreenShareContext(); - CGLPixelFormatObj pixel_format = obj->GetFullscreenCGLPixelFormatObj(); - DCHECK(share_context); - CGLError result; - CGLContextObj context; - result = CGLCreateContext(pixel_format, share_context, &context); - if (result != kCGLNoError) { - DLOG(ERROR) << "Error " << result << " creating context."; - return NPERR_GENERIC_ERROR; - } - CGLPBufferObj pbuffer; - if ((result = CGLCreatePBuffer(1, 1, - GL_TEXTURE_2D, GL_RGBA, - 0, &pbuffer)) != kCGLNoError) { - CGLDestroyContext(context); - DLOG(ERROR) << "Error " << result << " creating pbuffer."; - return NPERR_GENERIC_ERROR; - } - if ((result = CGLSetPBuffer(context, pbuffer, 0, 0, 0)) != kCGLNoError) { - CGLDestroyContext(context); - CGLDestroyPBuffer(pbuffer); - DLOG(ERROR) << "Error " << result << " attaching pbuffer to context."; - return NPERR_GENERIC_ERROR; + } else if (obj->drawing_model_ == NPDrawingModelCoreGraphics) { + if (obj->mac_cgl_pbuffer_ == NULL) { + // We initialize things with a CGL context rendering to a 1x1 + // pbuffer. Later we use the O3D RenderSurface APIs to set up the + // framebuffer object which is used for rendering. + CGLContextObj share_context = obj->GetFullscreenShareContext(); + CGLPixelFormatObj pixel_format = obj->GetFullscreenCGLPixelFormatObj(); + DCHECK(share_context); + CGLError result; + CGLContextObj context; + result = CGLCreateContext(pixel_format, share_context, &context); + if (result != kCGLNoError) { + DLOG(ERROR) << "Error " << result << " creating context."; + return NPERR_GENERIC_ERROR; + } + CGLPBufferObj pbuffer; + if ((result = CGLCreatePBuffer(1, 1, + GL_TEXTURE_2D, GL_RGBA, + 0, &pbuffer)) != kCGLNoError) { + CGLDestroyContext(context); + DLOG(ERROR) << "Error " << result << " creating pbuffer."; + return NPERR_GENERIC_ERROR; + } + if ((result = CGLSetPBuffer(context, pbuffer, 0, 0, 0)) != kCGLNoError) { + CGLDestroyContext(context); + CGLDestroyPBuffer(pbuffer); + DLOG(ERROR) << "Error " << result << " attaching pbuffer to context."; + return NPERR_GENERIC_ERROR; + } + // Must make the context current for renderer creation to succeed + CGLSetCurrentContext(context); + obj->mac_cgl_context_ = context; + obj->mac_cgl_pbuffer_ = pbuffer; } - // Must make the context current for renderer creation to succeed - CGLSetCurrentContext(context); - obj->mac_cgl_context_ = context; - obj->mac_cgl_pbuffer_ = pbuffer; } else if (!had_a_window && obj->mac_agl_context_ == NULL) { // setup AGL context AGLPixelFormat myAGLPixelFormat = NULL; diff --git a/o3d/plugin/mac/plugin_mac.mm b/o3d/plugin/mac/plugin_mac.mm index 071890b..488a7b6 100644 --- a/o3d/plugin/mac/plugin_mac.mm +++ b/o3d/plugin/mac/plugin_mac.mm @@ -237,6 +237,12 @@ void RenderTimer::TimerCallback(CFRunLoopTimerRef timer, void* info) { NPP instance = instances_[i]; PluginObject* obj = static_cast<PluginObject*>(instance->pdata); + // RenderClient() may cause events to be processed, leading to + // reentrant calling of this code. Detect and avoid this case. + if (obj->client()->IsRendering()) { + continue; + } + bool in_fullscreen = obj->GetFullscreenMacWindow(); if (obj->drawing_model_ == NPDrawingModelCoreAnimation && |