OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/render_widget_fullscreen_pepper.h" | 5 #include "content/renderer/render_widget_fullscreen_pepper.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
9 #include "content/renderer/gpu/gpu_channel_host.h" | 9 #include "content/renderer/gpu/gpu_channel_host.h" |
10 #include "content/renderer/pepper_platform_context_3d_impl.h" | 10 #include "content/renderer/pepper_platform_context_3d_impl.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 using WebKit::WebWidget; | 31 using WebKit::WebWidget; |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // WebWidget that simply wraps the pepper plugin. | 35 // WebWidget that simply wraps the pepper plugin. |
36 class PepperWidget : public WebWidget { | 36 class PepperWidget : public WebWidget { |
37 public: | 37 public: |
38 PepperWidget(webkit::ppapi::PluginInstance* plugin, | 38 PepperWidget(webkit::ppapi::PluginInstance* plugin, |
39 RenderWidgetFullscreenPepper* widget) | 39 RenderWidgetFullscreenPepper* widget) |
40 : plugin_(plugin), | 40 : plugin_(plugin), |
41 widget_(widget), | 41 widget_(widget) { |
42 cursor_(WebCursorInfo::TypePointer) { | |
43 } | 42 } |
44 | 43 |
45 virtual ~PepperWidget() {} | 44 virtual ~PepperWidget() {} |
46 | 45 |
47 // WebWidget API | 46 // WebWidget API |
48 virtual void close() { | 47 virtual void close() { |
49 delete this; | 48 delete this; |
50 } | 49 } |
51 | 50 |
52 virtual WebSize size() { | 51 virtual WebSize size() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 gl->BindTexture(GL_TEXTURE_2D, texture); | 89 gl->BindTexture(GL_TEXTURE_2D, texture); |
91 gl->DrawArrays(GL_TRIANGLES, 0, 3); | 90 gl->DrawArrays(GL_TRIANGLES, 0, 3); |
92 widget_->SwapBuffers(); | 91 widget_->SwapBuffers(); |
93 } | 92 } |
94 | 93 |
95 virtual void themeChanged() { | 94 virtual void themeChanged() { |
96 NOTIMPLEMENTED(); | 95 NOTIMPLEMENTED(); |
97 } | 96 } |
98 | 97 |
99 virtual bool handleInputEvent(const WebInputEvent& event) { | 98 virtual bool handleInputEvent(const WebInputEvent& event) { |
100 bool result = plugin_->HandleInputEvent(event, &cursor_); | 99 // This cursor info is ignored, we always set the cursor directly from |
| 100 // RenderWidgetFullscreenPepper::DidChangeCursor. |
| 101 WebCursorInfo cursor; |
| 102 bool result = plugin_->HandleInputEvent(event, &cursor); |
101 | 103 |
102 // For normal web pages, WebViewImpl does input event translations and | 104 // For normal web pages, WebViewImpl does input event translations and |
103 // generates context menu events. Since we don't have a WebView, we need to | 105 // generates context menu events. Since we don't have a WebView, we need to |
104 // do the necessary translation ourselves. | 106 // do the necessary translation ourselves. |
105 if (WebInputEvent::isMouseEventType(event.type)) { | 107 if (WebInputEvent::isMouseEventType(event.type)) { |
106 const WebMouseEvent& mouse_event = | 108 const WebMouseEvent& mouse_event = |
107 reinterpret_cast<const WebMouseEvent&>(event); | 109 reinterpret_cast<const WebMouseEvent&>(event); |
108 bool send_context_menu_event = false; | 110 bool send_context_menu_event = false; |
109 // On Mac/Linux, we handle it on mouse down. | 111 // On Mac/Linux, we handle it on mouse down. |
110 // On Windows, we handle it on mouse up. | 112 // On Windows, we handle it on mouse up. |
111 #if defined(OS_WIN) | 113 #if defined(OS_WIN) |
112 send_context_menu_event = | 114 send_context_menu_event = |
113 mouse_event.type == WebInputEvent::MouseUp && | 115 mouse_event.type == WebInputEvent::MouseUp && |
114 mouse_event.button == WebMouseEvent::ButtonRight; | 116 mouse_event.button == WebMouseEvent::ButtonRight; |
115 #elif defined(OS_MACOSX) | 117 #elif defined(OS_MACOSX) |
116 send_context_menu_event = | 118 send_context_menu_event = |
117 mouse_event.type == WebInputEvent::MouseDown && | 119 mouse_event.type == WebInputEvent::MouseDown && |
118 (mouse_event.button == WebMouseEvent::ButtonRight || | 120 (mouse_event.button == WebMouseEvent::ButtonRight || |
119 (mouse_event.button == WebMouseEvent::ButtonLeft && | 121 (mouse_event.button == WebMouseEvent::ButtonLeft && |
120 mouse_event.modifiers & WebMouseEvent::ControlKey)); | 122 mouse_event.modifiers & WebMouseEvent::ControlKey)); |
121 #else | 123 #else |
122 send_context_menu_event = | 124 send_context_menu_event = |
123 mouse_event.type == WebInputEvent::MouseDown && | 125 mouse_event.type == WebInputEvent::MouseDown && |
124 mouse_event.button == WebMouseEvent::ButtonRight; | 126 mouse_event.button == WebMouseEvent::ButtonRight; |
125 #endif | 127 #endif |
126 if (send_context_menu_event) { | 128 if (send_context_menu_event) { |
127 WebMouseEvent context_menu_event(mouse_event); | 129 WebMouseEvent context_menu_event(mouse_event); |
128 context_menu_event.type = WebInputEvent::ContextMenu; | 130 context_menu_event.type = WebInputEvent::ContextMenu; |
129 plugin_->HandleInputEvent(context_menu_event, &cursor_); | 131 plugin_->HandleInputEvent(context_menu_event, &cursor); |
130 } | 132 } |
131 } | 133 } |
132 return result; | 134 return result; |
133 } | 135 } |
134 | 136 |
135 virtual void mouseCaptureLost() { | 137 virtual void mouseCaptureLost() { |
136 NOTIMPLEMENTED(); | 138 NOTIMPLEMENTED(); |
137 } | 139 } |
138 | 140 |
139 virtual void setFocus(bool focus) { | 141 virtual void setFocus(bool focus) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 183 } |
182 | 184 |
183 virtual bool isAcceleratedCompositingActive() const { | 185 virtual bool isAcceleratedCompositingActive() const { |
184 return widget_->context() && (plugin_->GetBackingTextureId() != 0); | 186 return widget_->context() && (plugin_->GetBackingTextureId() != 0); |
185 } | 187 } |
186 | 188 |
187 private: | 189 private: |
188 scoped_refptr<webkit::ppapi::PluginInstance> plugin_; | 190 scoped_refptr<webkit::ppapi::PluginInstance> plugin_; |
189 RenderWidgetFullscreenPepper* widget_; | 191 RenderWidgetFullscreenPepper* widget_; |
190 WebSize size_; | 192 WebSize size_; |
191 WebCursorInfo cursor_; | |
192 | 193 |
193 DISALLOW_COPY_AND_ASSIGN(PepperWidget); | 194 DISALLOW_COPY_AND_ASSIGN(PepperWidget); |
194 }; | 195 }; |
195 | 196 |
196 void DestroyContext(RendererGLContext* context, GLuint program, GLuint buffer) { | 197 void DestroyContext(RendererGLContext* context, GLuint program, GLuint buffer) { |
197 DCHECK(context); | 198 DCHECK(context); |
198 gpu::gles2::GLES2Implementation* gl = context->GetImplementation(); | 199 gpu::gles2::GLES2Implementation* gl = context->GetImplementation(); |
199 if (program) | 200 if (program) |
200 gl->DeleteProgram(program); | 201 gl->DeleteProgram(program); |
201 if (buffer) | 202 if (buffer) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 256 } |
256 } | 257 } |
257 | 258 |
258 void RenderWidgetFullscreenPepper::Destroy() { | 259 void RenderWidgetFullscreenPepper::Destroy() { |
259 // This function is called by the plugin instance as it's going away, so reset | 260 // This function is called by the plugin instance as it's going away, so reset |
260 // plugin_ to NULL to avoid calling into a dangling pointer e.g. on Close(). | 261 // plugin_ to NULL to avoid calling into a dangling pointer e.g. on Close(). |
261 plugin_ = NULL; | 262 plugin_ = NULL; |
262 Send(new ViewHostMsg_Close(routing_id_)); | 263 Send(new ViewHostMsg_Close(routing_id_)); |
263 } | 264 } |
264 | 265 |
| 266 void RenderWidgetFullscreenPepper::DidChangeCursor( |
| 267 const WebKit::WebCursorInfo& cursor) { |
| 268 didChangeCursor(cursor); |
| 269 } |
| 270 |
265 webkit::ppapi::PluginDelegate::PlatformContext3D* | 271 webkit::ppapi::PluginDelegate::PlatformContext3D* |
266 RenderWidgetFullscreenPepper::CreateContext3D() { | 272 RenderWidgetFullscreenPepper::CreateContext3D() { |
267 if (!context_) { | 273 if (!context_) { |
268 CreateContext(); | 274 CreateContext(); |
269 } | 275 } |
270 if (!context_) | 276 if (!context_) |
271 return NULL; | 277 return NULL; |
272 return new PlatformContext3DImpl(context_); | 278 return new PlatformContext3DImpl(context_); |
273 } | 279 } |
274 | 280 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 NewRunnableFunction(DestroyContext, context_, program_, buffer_)); | 493 NewRunnableFunction(DestroyContext, context_, program_, buffer_)); |
488 context_ = NULL; | 494 context_ = NULL; |
489 program_ = 0; | 495 program_ = 0; |
490 buffer_ = 0; | 496 buffer_ = 0; |
491 OnSwapBuffersAborted(); | 497 OnSwapBuffersAborted(); |
492 } | 498 } |
493 | 499 |
494 void RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext() { | 500 void RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext() { |
495 OnSwapBuffersComplete(); | 501 OnSwapBuffersComplete(); |
496 } | 502 } |
OLD | NEW |