1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_
6 #define CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
11 #include "content/renderer/mouse_lock_dispatcher.h"
12 #include "content/renderer/pepper/pepper_parent_context_provider.h"
13 #include "content/renderer/render_widget_fullscreen.h"
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h"
16 #include "webkit/plugins/ppapi/fullscreen_container.h"
18 class WebGraphicsContext3DCommandBufferImpl
;
28 // A RenderWidget that hosts a fullscreen pepper plugin. This provides a
29 // FullscreenContainer that the plugin instance can callback into to e.g.
31 class RenderWidgetFullscreenPepper
:
32 public RenderWidgetFullscreen
,
33 public webkit::ppapi::FullscreenContainer
,
34 public content::PepperParentContextProvider
,
35 public WebGraphicsContext3DSwapBuffersClient
{
37 static RenderWidgetFullscreenPepper
* Create(
39 webkit::ppapi::PluginInstance
* plugin
,
40 const GURL
& active_url
,
41 const WebKit::WebScreenInfo
& screen_info
);
43 // WebGraphicscontext3DSwapBuffersClient implementation
44 virtual void OnViewContextSwapBuffersPosted() OVERRIDE
;
45 virtual void OnViewContextSwapBuffersComplete() OVERRIDE
;
46 virtual void OnViewContextSwapBuffersAborted() OVERRIDE
;
48 // pepper::FullscreenContainer API.
49 virtual void Invalidate() OVERRIDE
;
50 virtual void InvalidateRect(const WebKit::WebRect
& rect
) OVERRIDE
;
51 virtual void ScrollRect(int dx
, int dy
, const WebKit::WebRect
& rect
) OVERRIDE
;
52 virtual void Destroy() OVERRIDE
;
53 virtual void DidChangeCursor(const WebKit::WebCursorInfo
& cursor
) OVERRIDE
;
54 virtual webkit::ppapi::PluginDelegate::PlatformContext3D
*
55 CreateContext3D() OVERRIDE
;
56 virtual MouseLockDispatcher
* GetMouseLockDispatcher() OVERRIDE
;
58 // IPC::Listener implementation. This overrides the implementation
59 // in RenderWidgetFullscreen.
60 virtual bool OnMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
62 WebGraphicsContext3DCommandBufferImpl
* context() const { return context_
; }
65 // Could be NULL when this widget is closing.
66 webkit::ppapi::PluginInstance
* plugin() const { return plugin_
; }
69 RenderWidgetFullscreenPepper(webkit::ppapi::PluginInstance
* plugin
,
70 const GURL
& active_url
,
71 const WebKit::WebScreenInfo
& screen_info
);
72 virtual ~RenderWidgetFullscreenPepper();
75 virtual void WillInitiatePaint() OVERRIDE
;
76 virtual void DidInitiatePaint() OVERRIDE
;
77 virtual void DidFlushPaint() OVERRIDE
;
78 virtual void Close() OVERRIDE
;
79 virtual webkit::ppapi::PluginInstance
* GetBitmapForOptimizedPluginPaint(
80 const gfx::Rect
& paint_bounds
,
84 float* scale_factor
) OVERRIDE
;
85 virtual void OnResize(const gfx::Size
& new_size
,
86 const gfx::Rect
& resizer_rect
,
87 bool is_fullscreen
) OVERRIDE
;
89 // RenderWidgetFullscreen API.
90 virtual WebKit::WebWidget
* CreateWebWidget() OVERRIDE
;
92 // RenderWidget overrides.
93 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE
;
96 // Creates the GL context for compositing.
99 // Initialize the GL states and resources for compositing.
102 // Checks (and returns) whether accelerated compositing should be on or off,
103 // and notify the browser.
104 bool CheckCompositing();
106 // Implementation of PepperParentContextProvider.
107 virtual WebGraphicsContext3DCommandBufferImpl
*
108 GetParentContextForPlatformContext3D() OVERRIDE
;
110 // URL that is responsible for this widget, passed to ggl::CreateViewContext.
113 // The plugin instance this widget wraps.
114 webkit::ppapi::PluginInstance
* plugin_
;
116 // GL context for compositing.
117 WebGraphicsContext3DCommandBufferImpl
* context_
;
118 unsigned int buffer_
;
119 unsigned int program_
;
121 base::WeakPtrFactory
<RenderWidgetFullscreenPepper
> weak_ptr_factory_
;
123 scoped_ptr
<MouseLockDispatcher
> mouse_lock_dispatcher_
;
125 DISALLOW_COPY_AND_ASSIGN(RenderWidgetFullscreenPepper
);
128 #endif // CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_