diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 22:28:39 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-14 22:28:39 +0000 |
commit | 79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b (patch) | |
tree | f29089b8f66f79b4ab1e0c7af8432a1ba372cdd9 /webkit | |
parent | 5b84fe3a0f6b9319e18f31db4d3c943616a91090 (diff) | |
download | chromium_src-79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b.zip chromium_src-79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b.tar.gz chromium_src-79c7bedcd3d2e7808fc4dd9745ac2bf5fbca460b.tar.bz2 |
Add fullscreen support to Pepper.
This needs http://codereview.chromium.org/3320019/show first for the Pepper interfaces to be there.
BUG=none
TEST=run a pepper test application, trigger fullscreen on and off.
Review URL: http://codereview.chromium.org/3352019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59440 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/pepper_fullscreen_container.h | 33 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_delegate.h | 6 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.cc | 77 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_instance.h | 10 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_plugin_module.cc | 3 | ||||
-rw-r--r-- | webkit/glue/plugins/pepper_webplugin_impl.cc | 8 |
6 files changed, 128 insertions, 9 deletions
diff --git a/webkit/glue/plugins/pepper_fullscreen_container.h b/webkit/glue/plugins/pepper_fullscreen_container.h new file mode 100644 index 0000000..5f67538 --- /dev/null +++ b/webkit/glue/plugins/pepper_fullscreen_container.h @@ -0,0 +1,33 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FULLSCREEN_CONTAINER_H_ +#define WEBKIT_GLUE_PLUGINS_PEPPER_FULLSCREEN_CONTAINER_H_ + +namespace WebKit { +struct WebRect; +} // namespace WebKit + +namespace pepper { + +// This class is like a lightweight WebPluginContainer for fullscreen pepper +// plugins, that only handles painting. +class FullscreenContainer { + public: + virtual ~FullscreenContainer() {} + + // Invalidates the full plugin region. + virtual void Invalidate() = 0; + + // Invalidates a partial region of the plugin. + virtual void InvalidateRect(const WebKit::WebRect&) = 0; + + // Destroys the fullscreen window. This also destroys the FullscreenContainer + // instance. + virtual void Destroy() = 0; +}; + +} // namespace pepper + +#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FULLSCREEN_CONTAINER_H_ diff --git a/webkit/glue/plugins/pepper_plugin_delegate.h b/webkit/glue/plugins/pepper_plugin_delegate.h index 162b4bb6..3393ba0 100644 --- a/webkit/glue/plugins/pepper_plugin_delegate.h +++ b/webkit/glue/plugins/pepper_plugin_delegate.h @@ -46,6 +46,7 @@ namespace pepper { class FileIO; class PluginInstance; +class FullscreenContainer; // Virtual interface that the browser implements to implement features for // Pepper plugins. @@ -167,6 +168,11 @@ class PluginDelegate { // of the file thread in this renderer. virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy() = 0; + + // Create a fullscreen container for a plugin instance. This effectively + // switches the plugin to fullscreen. + virtual FullscreenContainer* CreateFullscreenContainer( + PluginInstance* instance) = 0; }; } // namespace pepper diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index e6b1c18..1a1290e 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -23,6 +23,7 @@ #include "skia/ext/vector_platform_device.h" #include "skia/ext/platform_canvas.h" #include "third_party/ppapi/c/dev/ppb_find_dev.h" +#include "third_party/ppapi/c/dev/ppb_fullscreen_dev.h" #include "third_party/ppapi/c/dev/ppp_find_dev.h" #include "third_party/ppapi/c/dev/ppp_zoom_dev.h" #include "third_party/ppapi/c/pp_event.h" @@ -44,6 +45,7 @@ #include "webkit/glue/plugins/pepper_buffer.h" #include "webkit/glue/plugins/pepper_graphics_2d.h" #include "webkit/glue/plugins/pepper_event_conversion.h" +#include "webkit/glue/plugins/pepper_fullscreen_container.h" #include "webkit/glue/plugins/pepper_image_data.h" #include "webkit/glue/plugins/pepper_plugin_delegate.h" #include "webkit/glue/plugins/pepper_plugin_module.h" @@ -207,6 +209,25 @@ const PPB_Find_Dev ppb_find = { &SelectedFindResultChanged, }; +bool IsFullscreen(PP_Instance instance_id) { + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (!instance) + return false; + return instance->IsFullscreen(); +} + +bool SetFullscreen(PP_Instance instance_id, bool fullscreen) { + PluginInstance* instance = PluginInstance::FromPPInstance(instance_id); + if (!instance) + return false; + return instance->SetFullscreen(fullscreen); +} + +const PPB_Fullscreen_Dev ppb_fullscreen = { + &IsFullscreen, + &SetFullscreen, +}; + } // namespace PluginInstance::PluginInstance(PluginDelegate* delegate, @@ -225,7 +246,8 @@ PluginInstance::PluginInstance(PluginDelegate* delegate, pdf_output_done_(false), #endif // defined (OS_LINUX) plugin_print_interface_(NULL), - plugin_graphics_3d_interface_(NULL) { + plugin_graphics_3d_interface_(NULL), + fullscreen_container_(NULL) { memset(¤t_print_settings_, 0, sizeof(current_print_settings_)); DCHECK(delegate); module_->InstanceCreated(this); @@ -252,6 +274,11 @@ const PPB_Find_Dev* PluginInstance::GetFindInterface() { return &ppb_find; } +// static +const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() { + return &ppb_fullscreen; +} + PP_Instance PluginInstance::GetPPInstance() { return reinterpret_cast<intptr_t>(this); } @@ -264,12 +291,19 @@ 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); + } } PP_Var PluginInstance::GetWindowObject() { @@ -379,6 +413,10 @@ PP_Var PluginInstance::ExecuteScript(PP_Var script, PP_Var* exception) { void PluginInstance::Delete() { instance_interface_->Delete(GetPPInstance()); + if (fullscreen_container_) { + fullscreen_container_->Destroy(); + fullscreen_container_ = NULL; + } container_ = NULL; } @@ -640,6 +678,31 @@ void PluginInstance::Graphics3DContextLost() { plugin_graphics_3d_interface_->Graphics3DContextLost(GetPPInstance()); } +bool PluginInstance::IsFullscreen() { + return fullscreen_container_ != NULL; +} + +bool PluginInstance::SetFullscreen(bool fullscreen) { + bool is_fullscreen = (fullscreen_container_ != NULL); + if (fullscreen == is_fullscreen) + return true; + LOG(INFO) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); + if (fullscreen) { + fullscreen_container_ = delegate_->CreateFullscreenContainer(this); + } else { + fullscreen_container_->Destroy(); + fullscreen_container_ = NULL; + // TODO(piman): currently the fullscreen container resizes the plugin to the + // fullscreen size so we need to reset the size here. Eventually it will + // transparently scale and this won't be necessary. + if (container_) { + container_->reportGeometry(); + container_->invalidate(); + } + } + return true; +} + bool PluginInstance::PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas) { scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(print_output)); diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/glue/plugins/pepper_plugin_instance.h index 1260beb8..bf8f027 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.h +++ b/webkit/glue/plugins/pepper_plugin_instance.h @@ -24,6 +24,7 @@ struct PP_Var; struct PPB_Instance; struct PPB_Find_Dev; +struct PPB_Fullscreen_Dev; struct PPP_Find_Dev; struct PPP_Instance; struct PPP_Zoom_Dev; @@ -47,6 +48,7 @@ class ImageData; class PluginDelegate; class PluginModule; class URLLoader; +class FullscreenContainer; class PluginInstance : public base::RefCounted<PluginInstance> { public: @@ -63,6 +65,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // Returns a pointer to the interface implementing PPB_Find that is // exposed to the plugin. static const PPB_Find_Dev* GetFindInterface(); + static const PPB_Fullscreen_Dev* GetFullscreenInterface(); PluginDelegate* delegate() const { return delegate_; } PluginModule* module() const { return module_.get(); } @@ -128,6 +131,10 @@ class PluginInstance : public base::RefCounted<PluginInstance> { void Graphics3DContextLost(); + // Implementation of PPB_Fullscreen_Dev. + bool IsFullscreen(); + bool SetFullscreen(bool fullscreen); + private: bool LoadFindInterface(); bool LoadZoomInterface(); @@ -210,6 +217,9 @@ class PluginInstance : public base::RefCounted<PluginInstance> { // Containes the cursor if it's set by the plugin. scoped_ptr<WebKit::WebCursorInfo> cursor_; + // Plugin container for fullscreen mode. NULL if not in fullscreen mode. + FullscreenContainer* fullscreen_container_; + DISALLOW_COPY_AND_ASSIGN(PluginInstance); }; diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc index 2286285..1d1fb6b 100644 --- a/webkit/glue/plugins/pepper_plugin_module.cc +++ b/webkit/glue/plugins/pepper_plugin_module.cc @@ -21,6 +21,7 @@ #include "third_party/ppapi/c/dev/ppb_file_system_dev.h" #include "third_party/ppapi/c/dev/ppb_find_dev.h" #include "third_party/ppapi/c/dev/ppb_font_dev.h" +#include "third_party/ppapi/c/dev/ppb_fullscreen_dev.h" #include "third_party/ppapi/c/dev/ppb_graphics_3d_dev.h" #include "third_party/ppapi/c/dev/ppb_opengles_dev.h" #include "third_party/ppapi/c/dev/ppb_scrollbar_dev.h" @@ -231,6 +232,8 @@ const void* GetInterface(const char* name) { return Font::GetInterface(); if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0) return PluginInstance::GetFindInterface(); + if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0) + return PluginInstance::GetFullscreenInterface(); if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0) return UrlUtil::GetInterface(); if (strcmp(name, PPB_PRIVATE_INTERFACE) == 0) diff --git a/webkit/glue/plugins/pepper_webplugin_impl.cc b/webkit/glue/plugins/pepper_webplugin_impl.cc index 95b3012..d566280 100644 --- a/webkit/glue/plugins/pepper_webplugin_impl.cc +++ b/webkit/glue/plugins/pepper_webplugin_impl.cc @@ -81,7 +81,8 @@ NPObject* WebPluginImpl::scriptableObject() { } void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& rect) { - instance_->Paint(canvas, plugin_rect_, rect); + if (!instance_->IsFullscreen()) + instance_->Paint(canvas, plugin_rect_, rect); } void WebPluginImpl::updateGeometry( @@ -90,7 +91,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_->IsFullscreen()) + instance_->ViewChanged(plugin_rect_, clip_rect); } void WebPluginImpl::updateFocus(bool focused) { @@ -105,6 +107,8 @@ bool WebPluginImpl::acceptsInputEvents() { bool WebPluginImpl::handleInputEvent(const WebKit::WebInputEvent& event, WebKit::WebCursorInfo& cursor_info) { + if (instance_->IsFullscreen()) + return false; return instance_->HandleInputEvent(event, &cursor_info); } |