Chromium Code Reviews| Index: webkit/plugins/ppapi/ppapi_plugin_instance.cc |
| =================================================================== |
| --- webkit/plugins/ppapi/ppapi_plugin_instance.cc (revision 99979) |
| +++ webkit/plugins/ppapi/ppapi_plugin_instance.cc (working copy) |
| @@ -23,6 +23,7 @@ |
| #include "ppapi/c/pp_resource.h" |
| #include "ppapi/c/pp_var.h" |
| #include "ppapi/c/ppb_core.h" |
| +#include "ppapi/c/ppb_fullscreen.h" |
| #include "ppapi/c/ppb_instance.h" |
| #include "ppapi/c/ppp_input_event.h" |
| #include "ppapi/c/ppp_instance.h" |
| @@ -235,6 +236,8 @@ |
| plugin_graphics_3d_interface_(NULL), |
| always_on_top_(false), |
| fullscreen_container_(NULL), |
| + fullscreen_dev_(false), |
| + desired_fullscreen_state_(false), |
| fullscreen_(false), |
| message_channel_(NULL), |
| sad_plugin_(NULL), |
| @@ -353,6 +356,7 @@ |
| // Free any associated graphics. |
| SetFullscreen(false, false); |
| + SetFullscreen_Dev(false, false); |
| bound_graphics_ = NULL; |
| InvalidateRect(gfx::Rect()); |
| @@ -521,7 +525,8 @@ |
| sent_did_change_view_ = true; |
| position_ = position; |
| clip_ = new_clip; |
| - fullscreen_ = (fullscreen_container_ != NULL); |
| + fullscreen_ = desired_fullscreen_state_; |
| + fullscreen_dev_ = (fullscreen_container_ != NULL); |
| PP_Rect pp_position, pp_clip; |
| RectToPPRect(position_, &pp_position); |
| @@ -774,7 +779,7 @@ |
| // If this call was delayed, we may have transitioned back to fullscreen in |
| // the mean time, so only report the geometry if we are actually in normal |
| // mode. |
| - if (container_ && !fullscreen_container_) |
| + if (container_ && !fullscreen_container_ && !fullscreen_dev_) |
| container_->reportGeometry(); |
| } |
| @@ -892,10 +897,14 @@ |
| #endif // defined(OS_MACOSX) |
| } |
| -bool PluginInstance::IsFullscreenOrPending() { |
| +bool PluginInstance::IsFullscreenOrPending_Dev() { |
| return fullscreen_container_ != NULL; |
| } |
| +bool PluginInstance::IsFullscreenOrPending() { |
| + return desired_fullscreen_state_; |
| +} |
| + |
| void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { |
| // Keep a reference on the stack. See NOTE above. |
| scoped_refptr<PluginInstance> ref(this); |
| @@ -906,8 +915,36 @@ |
| if (fullscreen == IsFullscreenOrPending()) |
| return; |
| + // Unbind current 2D or 3D graphics context. |
| BindGraphics(pp_instance(), 0); |
|
jeremya
2011/09/09 17:45:35
Is it necessary to unbind the graphics context her
polina
2011/09/26 21:57:00
That's what the interface documentation in the hea
|
| + |
| VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
| + desired_fullscreen_state_ = fullscreen; |
| + if (fullscreen) |
| + container_->element().requestFullScreen(); |
| + else |
| + container_->element().document().cancelFullScreen(); |
| + if (!delay_report) { |
| + ReportGeometry(); |
| + } else { |
| + MessageLoop::current()->PostTask( |
| + FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry)); |
| + } |
| +} |
| + |
| +void PluginInstance::SetFullscreen_Dev(bool fullscreen, bool delay_report) { |
| + // Keep a reference on the stack. See NOTE above. |
| + scoped_refptr<PluginInstance> ref(this); |
| + |
| + // We check whether we are trying to switch to the state we're already going |
| + // to (i.e. if we're already switching to fullscreen but the fullscreen |
| + // container isn't ready yet, don't do anything more). |
| + if (fullscreen == IsFullscreenOrPending_Dev()) |
| + return; |
| + |
| + // Unbind current 2D or 3D graphics context. |
| + BindGraphics(pp_instance(), 0); |
| + VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
| if (fullscreen) { |
| DCHECK(!fullscreen_container_); |
| fullscreen_container_ = delegate_->CreateFullscreenContainer(this); |
| @@ -915,7 +952,7 @@ |
| DCHECK(fullscreen_container_); |
| fullscreen_container_->Destroy(); |
| fullscreen_container_ = NULL; |
| - fullscreen_ = false; |
| + fullscreen_dev_ = false; |
| if (!delay_report) { |
| ReportGeometry(); |
| } else { |
| @@ -1241,14 +1278,16 @@ |
| } |
| void PluginInstance::setBackingTextureId(unsigned int id) { |
| - // If we have a full-screen container_ then the plugin is fullscreen, |
| - // and the parent context is not the one for the browser page, but for the |
| - // full-screen window, and so the parent texture ID doesn't correspond to |
| - // anything in the page's context. |
| + // If we have a fullscreen_container_ (under PPB_Fullscreen_Dev) |
| + // or desired_fullscreen_state is true (under PPB_Fullscreen), |
| + // then the plugin is fullscreen or transitioning to fullscreen |
| + // and the parent context is not the one for the browser page, |
| + // but for the fullscreen window, and so the parent texture ID |
| + // doesn't correspond to anything in the page's context. |
| // |
| // TODO(alokp): It would be better at some point to have the equivalent |
| // in the FullscreenContainer so that we don't need to poll |
| - if (fullscreen_container_) |
| + if (fullscreen_container_ || desired_fullscreen_state_) |
| return; |
| if (container_) |
| @@ -1296,8 +1335,10 @@ |
| return PP_TRUE; |
| } |
| - // Refuse to bind if we're transitioning to fullscreen. |
| - if (fullscreen_container_ && !fullscreen_) |
| + // Refuse to bind if we're transitioning to fullscreen with PPB_Fullscreen_Dev |
| + // or to/from fullscreen with PPB_Fullscreen. |
| + if ((fullscreen_container_ && !fullscreen_dev_) || |
| + desired_fullscreen_state_ != fullscreen_) |
| return PP_FALSE; |
| EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); |
| @@ -1416,18 +1457,32 @@ |
| return PP_FromBool(fullscreen_); |
| } |
| +PP_Bool PluginInstance::IsFullscreen_Dev(PP_Instance instance) { |
| + return PP_FromBool(fullscreen_dev_); |
| +} |
| + |
| PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, |
| PP_Bool fullscreen) { |
| SetFullscreen(PP_ToBool(fullscreen), true); |
| return PP_TRUE; |
| } |
| +PP_Bool PluginInstance::SetFullscreen_Dev(PP_Instance instance, |
| + PP_Bool fullscreen) { |
| + SetFullscreen_Dev(PP_ToBool(fullscreen), true); |
| + return PP_TRUE; |
| +} |
| + |
| PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { |
| gfx::Size screen_size = delegate()->GetScreenSize(); |
| *size = PP_MakeSize(screen_size.width(), screen_size.height()); |
| return PP_TRUE; |
| } |
| +PP_Bool PluginInstance::GetScreenSize_Dev(PP_Instance instance, PP_Size* size) { |
| + return GetScreenSize(instance, size); |
| +} |
| + |
| int32_t PluginInstance::RequestInputEvents(PP_Instance instance, |
| uint32_t event_classes) { |
| input_event_mask_ |= event_classes; |