diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-30 23:54:51 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-30 23:54:51 +0000 |
commit | 3962ea98fe59edad2b2c1dcb1b1893304526369b (patch) | |
tree | 65d1d131d62a1b5938cc37ed4dcf7eeab723d565 /webkit/plugins | |
parent | 2d02bea25a2ea6d67c3d1f4a06d3bbe697938163 (diff) | |
download | chromium_src-3962ea98fe59edad2b2c1dcb1b1893304526369b.zip chromium_src-3962ea98fe59edad2b2c1dcb1b1893304526369b.tar.gz chromium_src-3962ea98fe59edad2b2c1dcb1b1893304526369b.tar.bz2 |
Revert 98767 - Reimplement the Pepper fullscreen API to use webkitRequestFullScreen and friends.
This depends on https://bugs.webkit.org/show_bug.cgi?id=66746 and http://codereview.chromium.org/7461059/, neither of which have been landed. So this should be considered a preliminary review at this stage :)
BUG=
TEST=
Review URL: http://codereview.chromium.org/7714017
TBR=koz@chromium.org
Review URL: http://codereview.chromium.org/7740056
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98896 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 5 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 6 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 97 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.h | 14 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_webplugin_impl.cc | 8 |
6 files changed, 100 insertions, 32 deletions
diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index b42dbf1..c34643a 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -223,6 +223,11 @@ int32_t MockPluginDelegate::ShowContextMenu( return PP_ERROR_FAILED; } +FullscreenContainer* MockPluginDelegate::CreateFullscreenContainer( + PluginInstance* instance) { + return NULL; +} + gfx::Size MockPluginDelegate::GetScreenSize() { return gfx::Size(1024, 768); } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 5964c11..04382e0 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -100,6 +100,8 @@ class MockPluginDelegate : public PluginDelegate { PluginInstance* instance, webkit::ppapi::PPB_Flash_Menu_Impl* menu, const gfx::Point& position); + virtual FullscreenContainer* CreateFullscreenContainer( + PluginInstance* instance); virtual gfx::Size GetScreenSize(); virtual std::string GetDefaultEncoding(); virtual void ZoomLimitsChanged(double minimum_factor, diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index 5587502..f63276e 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -79,6 +79,7 @@ namespace webkit { namespace ppapi { class FileIO; +class FullscreenContainer; class PepperFilePath; class PluginInstance; class PluginModule; @@ -389,6 +390,11 @@ class PluginDelegate { webkit::ppapi::PPB_Flash_Menu_Impl* menu, const gfx::Point& position) = 0; + // Create a fullscreen container for a plugin instance. This effectively + // switches the plugin to fullscreen. + virtual FullscreenContainer* CreateFullscreenContainer( + PluginInstance* instance) = 0; + // Gets the size of the screen. The fullscreen window will be created at that // size. virtual gfx::Size GetScreenSize() = 0; diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 84d549a..f871ce2 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -52,6 +52,7 @@ #include "ui/gfx/skia_util.h" #include "webkit/plugins/ppapi/common.h" #include "webkit/plugins/ppapi/event_conversion.h" +#include "webkit/plugins/ppapi/fullscreen_container.h" #include "webkit/plugins/ppapi/message_channel.h" #include "webkit/plugins/ppapi/npapi_glue.h" #include "webkit/plugins/ppapi/plugin_delegate.h" @@ -232,7 +233,7 @@ PluginInstance::PluginInstance( plugin_print_interface_(NULL), plugin_graphics_3d_interface_(NULL), always_on_top_(false), - desired_fullscreen_state_(false), + fullscreen_container_(NULL), fullscreen_(false), message_channel_(NULL), sad_plugin_(NULL), @@ -276,6 +277,10 @@ void PluginInstance::Delete() { scoped_refptr<PluginInstance> ref(this); instance_interface_->DidDestroy(pp_instance()); + if (fullscreen_container_) { + fullscreen_container_->Destroy(); + fullscreen_container_ = NULL; + } container_ = NULL; } @@ -296,21 +301,32 @@ void PluginInstance::Paint(WebCanvas* canvas, } void PluginInstance::InvalidateRect(const gfx::Rect& rect) { - if (!container_ || position_.IsEmpty()) - return; // Nothing to do. - if (rect.IsEmpty()) - container_->invalidate(); - else - container_->invalidateRect(rect); + if (fullscreen_container_) { + if (rect.IsEmpty()) + fullscreen_container_->Invalidate(); + else + fullscreen_container_->InvalidateRect(rect); + } else { + if (!container_ || position_.IsEmpty()) + return; // Nothing to do. + if (rect.IsEmpty()) + container_->invalidate(); + else + container_->invalidateRect(rect); + } } void PluginInstance::ScrollRect(int dx, int dy, const gfx::Rect& rect) { - if (full_frame_) { - container_->scrollRect(dx, dy, rect); + if (fullscreen_container_) { + fullscreen_container_->ScrollRect(dx, dy, rect); } else { - // Can't do optimized scrolling since there could be other elements on top - // of us. - InvalidateRect(rect); + if (full_frame_) { + container_->scrollRect(dx, dy, rect); + } else { + // Can't do optimized scrolling since there could be other elements on top + // of us. + InvalidateRect(rect); + } } } @@ -324,7 +340,10 @@ unsigned PluginInstance::GetBackingTextureId() { } void PluginInstance::CommitBackingTexture() { - container_->commitBackingTexture(); + if (fullscreen_container_) + fullscreen_container_->Invalidate(); + else + container_->commitBackingTexture(); } void PluginInstance::InstanceCrashed() { @@ -486,7 +505,7 @@ PP_Var PluginInstance::GetInstanceObject() { void PluginInstance::ViewChanged(const gfx::Rect& position, const gfx::Rect& clip) { - fullscreen_ = desired_fullscreen_state_; + fullscreen_ = (fullscreen_container_ != NULL); position_ = position; if (clip.IsEmpty()) { @@ -747,7 +766,10 @@ bool PluginInstance::PluginHasFocus() const { } void PluginInstance::ReportGeometry() { - if (container_) + // 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_) container_->reportGeometry(); } @@ -866,7 +888,7 @@ void PluginInstance::PrintEnd() { } bool PluginInstance::IsFullscreenOrPending() { - return desired_fullscreen_state_; + return fullscreen_container_ != NULL; } void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { @@ -879,16 +901,22 @@ void PluginInstance::SetFullscreen(bool fullscreen, bool delay_report) { if (fullscreen == IsFullscreenOrPending()) return; - desired_fullscreen_state_ = fullscreen; - if (fullscreen) - container_->element().requestFullScreen(); - else - container_->element().document().cancelFullScreen(); - if (!delay_report) { - ReportGeometry(); + BindGraphics(pp_instance(), 0); + VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); + if (fullscreen) { + DCHECK(!fullscreen_container_); + fullscreen_container_ = delegate_->CreateFullscreenContainer(this); } else { - MessageLoop::current()->PostTask( + DCHECK(fullscreen_container_); + fullscreen_container_->Destroy(); + fullscreen_container_ = NULL; + fullscreen_ = false; + if (!delay_report) { + ReportGeometry(); + } else { + MessageLoop::current()->PostTask( FROM_HERE, NewRunnableMethod(this, &PluginInstance::ReportGeometry)); + } } } @@ -935,7 +963,10 @@ int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, } PluginDelegate::PlatformContext3D* PluginInstance::CreateContext3D() { - return delegate_->CreateContext3D(); + if (fullscreen_container_) + return fullscreen_container_->CreateContext3D(); + else + return delegate_->CreateContext3D(); } bool PluginInstance::PrintPDFOutput(PP_Resource print_output, @@ -1205,6 +1236,16 @@ PPB_Surface3D_Impl* PluginInstance::GetBoundSurface3D() const { } 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. + // + // 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_) + return; + if (container_) container_->setBackingTextureId(id); } @@ -1250,6 +1291,10 @@ PP_Bool PluginInstance::BindGraphics(PP_Instance instance, return PP_TRUE; } + // Refuse to bind if we're transitioning to fullscreen. + if (fullscreen_container_ && !fullscreen_) + return PP_FALSE; + EnterResourceNoLock<PPB_Graphics2D_API> enter_2d(device, false); PPB_Graphics2D_Impl* graphics_2d = enter_2d.succeeded() ? static_cast<PPB_Graphics2D_Impl*>(enter_2d.object()) : NULL; @@ -1437,6 +1482,8 @@ void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) { void PluginInstance::DoSetCursor(WebCursorInfo* cursor) { cursor_.reset(cursor); + if (fullscreen_container_) + fullscreen_container_->DidChangeCursor(*cursor); } } // namespace ppapi diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h index bd2e54f..fde1590 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.h +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.h @@ -64,6 +64,7 @@ class Resource; namespace webkit { namespace ppapi { +class FullscreenContainer; class MessageChannel; class ObjectVar; class PluginDelegate; @@ -241,6 +242,10 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // embedded in a page). bool IsFullPagePlugin() const; + FullscreenContainer* fullscreen_container() const { + return fullscreen_container_; + } + // FunctionGroupBase overrides. virtual ::ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() OVERRIDE; @@ -431,11 +436,10 @@ class PluginInstance : public base::RefCounted<PluginInstance>, // to use a more optimized painting path in some cases. bool always_on_top_; - // Since entering fullscreen mode is an asynchronous operation, we set this - // variable to the desired state at the time we issue the fullscreen change - // request. The plugin will receive a DidChangeView event when it goes - // fullscreen. - bool desired_fullscreen_state_; + // Plugin container for fullscreen mode. NULL if not in fullscreen mode. Note: + // there is a transition state where fullscreen_container_ is non-NULL but + // fullscreen_ is false (see above). + FullscreenContainer* fullscreen_container_; // True if we are in fullscreen mode. Note: it is false during the transition. bool fullscreen_; diff --git a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc index 2747b9d..cc6e66d 100644 --- a/webkit/plugins/ppapi/ppapi_webplugin_impl.cc +++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc @@ -118,7 +118,8 @@ bool WebPluginImpl::getFormValue(WebString* value) { } void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { - instance_->Paint(canvas, plugin_rect_, rect); + if (!instance_->IsFullscreenOrPending()) + instance_->Paint(canvas, plugin_rect_, rect); } void WebPluginImpl::updateGeometry( @@ -127,7 +128,8 @@ void WebPluginImpl::updateGeometry( const WebVector<WebRect>& cut_outs_rects, bool is_visible) { plugin_rect_ = window_rect; - instance_->ViewChanged(plugin_rect_, clip_rect); + if (!instance_->IsFullscreenOrPending()) + instance_->ViewChanged(plugin_rect_, clip_rect); } void WebPluginImpl::updateFocus(bool focused) { @@ -143,6 +145,8 @@ bool WebPluginImpl::acceptsInputEvents() { bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event, WebKit::WebCursorInfo& cursor_info) { + if (instance_->IsFullscreenOrPending()) + return false; return instance_->HandleInputEvent(event, &cursor_info); } |