[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / renderer / render_widget_fullscreen_pepper.h
blobfac44c4f58c567d6a8dcc5dbbb405d1b43e21872
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 namespace webkit {
19 namespace ppapi {
21 class PluginInstance;
23 } // namespace ppapi
24 } // namespace webkit
26 namespace content {
27 class WebGraphicsContext3DCommandBufferImpl;
29 // A RenderWidget that hosts a fullscreen pepper plugin. This provides a
30 // FullscreenContainer that the plugin instance can callback into to e.g.
31 // invalidate rects.
32 class RenderWidgetFullscreenPepper :
33 public RenderWidgetFullscreen,
34 public webkit::ppapi::FullscreenContainer,
35 public PepperParentContextProvider,
36 public WebGraphicsContext3DSwapBuffersClient {
37 public:
38 static RenderWidgetFullscreenPepper* Create(
39 int32 opener_id,
40 webkit::ppapi::PluginInstance* plugin,
41 const GURL& active_url,
42 const WebKit::WebScreenInfo& screen_info);
44 // WebGraphicscontext3DSwapBuffersClient implementation
45 virtual void OnViewContextSwapBuffersPosted() OVERRIDE;
46 virtual void OnViewContextSwapBuffersComplete() OVERRIDE;
47 virtual void OnViewContextSwapBuffersAborted() OVERRIDE;
49 // pepper::FullscreenContainer API.
50 virtual void Invalidate() OVERRIDE;
51 virtual void InvalidateRect(const WebKit::WebRect& rect) OVERRIDE;
52 virtual void ScrollRect(int dx, int dy, const WebKit::WebRect& rect) OVERRIDE;
53 virtual void Destroy() OVERRIDE;
54 virtual void DidChangeCursor(const WebKit::WebCursorInfo& cursor) OVERRIDE;
55 virtual webkit::ppapi::PluginDelegate::PlatformContext3D*
56 CreateContext3D() OVERRIDE;
57 virtual void ReparentContext(
58 webkit::ppapi::PluginDelegate::PlatformContext3D*) OVERRIDE;
60 // IPC::Listener implementation. This overrides the implementation
61 // in RenderWidgetFullscreen.
62 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
64 WebGraphicsContext3DCommandBufferImpl* context() const { return context_; }
65 void SwapBuffers();
67 // Could be NULL when this widget is closing.
68 webkit::ppapi::PluginInstance* plugin() const { return plugin_; }
70 MouseLockDispatcher* mouse_lock_dispatcher() const {
71 return mouse_lock_dispatcher_.get();
74 protected:
75 RenderWidgetFullscreenPepper(webkit::ppapi::PluginInstance* plugin,
76 const GURL& active_url,
77 const WebKit::WebScreenInfo& screen_info);
78 virtual ~RenderWidgetFullscreenPepper();
80 // RenderWidget API.
81 virtual void WillInitiatePaint() OVERRIDE;
82 virtual void DidInitiatePaint() OVERRIDE;
83 virtual void DidFlushPaint() OVERRIDE;
84 virtual void Close() OVERRIDE;
85 virtual webkit::ppapi::PluginInstance* GetBitmapForOptimizedPluginPaint(
86 const gfx::Rect& paint_bounds,
87 TransportDIB** dib,
88 gfx::Rect* location,
89 gfx::Rect* clip,
90 float* scale_factor) OVERRIDE;
91 virtual void OnResize(const gfx::Size& new_size,
92 const gfx::Rect& resizer_rect,
93 bool is_fullscreen) OVERRIDE;
95 // RenderWidgetFullscreen API.
96 virtual WebKit::WebWidget* CreateWebWidget() OVERRIDE;
98 // RenderWidget overrides.
99 virtual bool SupportsAsynchronousSwapBuffers() OVERRIDE;
101 private:
102 // Creates the GL context for compositing.
103 void CreateContext();
105 // Initialize the GL states and resources for compositing.
106 bool InitContext();
108 // Checks (and returns) whether accelerated compositing should be on or off,
109 // and notify the browser.
110 bool CheckCompositing();
112 // Implementation of PepperParentContextProvider.
113 virtual WebGraphicsContext3DCommandBufferImpl*
114 GetParentContextForPlatformContext3D() OVERRIDE;
116 // URL that is responsible for this widget, passed to ggl::CreateViewContext.
117 GURL active_url_;
119 // The plugin instance this widget wraps.
120 webkit::ppapi::PluginInstance* plugin_;
122 // GL context for compositing.
123 WebGraphicsContext3DCommandBufferImpl* context_;
124 unsigned int buffer_;
125 unsigned int program_;
127 base::WeakPtrFactory<RenderWidgetFullscreenPepper> weak_ptr_factory_;
129 scoped_ptr<MouseLockDispatcher> mouse_lock_dispatcher_;
131 DISALLOW_COPY_AND_ASSIGN(RenderWidgetFullscreenPepper);
134 } // namespace content
136 #endif // CONTENT_RENDERER_RENDER_WIDGET_FULLSCREEN_PEPPER_H_