| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/render_widget_fullscreen_pepper.h" | 5 #include "chrome/renderer/render_widget_fullscreen_pepper.h" |
| 6 | 6 |
| 7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
| 8 #include "chrome/renderer/ggl/ggl.h" | 8 #include "chrome/renderer/ggl/ggl.h" |
| 9 #include "chrome/renderer/gpu_channel_host.h" | 9 #include "chrome/renderer/gpu_channel_host.h" |
| 10 #include "chrome/renderer/pepper_platform_context_3d_impl.h" | 10 #include "chrome/renderer/pepper_platform_context_3d_impl.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 new RenderWidgetFullscreenPepper(render_thread, plugin)); | 155 new RenderWidgetFullscreenPepper(render_thread, plugin)); |
| 156 widget->Init(opener_id); | 156 widget->Init(opener_id); |
| 157 return widget.release(); | 157 return widget.release(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( | 160 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( |
| 161 RenderThreadBase* render_thread, | 161 RenderThreadBase* render_thread, |
| 162 webkit::ppapi::PluginInstance* plugin) | 162 webkit::ppapi::PluginInstance* plugin) |
| 163 : RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect), | 163 : RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect), |
| 164 plugin_(plugin), | 164 plugin_(plugin), |
| 165 #if defined(OS_MACOSX) | |
| 166 plugin_handle_(NULL), | |
| 167 #endif | |
| 168 context_(NULL), | 165 context_(NULL), |
| 169 buffer_(0), | 166 buffer_(0), |
| 170 program_(0) { | 167 program_(0) { |
| 171 } | 168 } |
| 172 | 169 |
| 173 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { | 170 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { |
| 174 DestroyContext(); | 171 DestroyContext(); |
| 175 } | 172 } |
| 176 | 173 |
| 177 void RenderWidgetFullscreenPepper::Invalidate() { | 174 void RenderWidgetFullscreenPepper::Invalidate() { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return new PepperWidget(plugin_, this); | 257 return new PepperWidget(plugin_, this); |
| 261 } | 258 } |
| 262 | 259 |
| 263 void RenderWidgetFullscreenPepper::CreateContext() { | 260 void RenderWidgetFullscreenPepper::CreateContext() { |
| 264 DCHECK(!context_); | 261 DCHECK(!context_); |
| 265 RenderThread* render_thread = RenderThread::current(); | 262 RenderThread* render_thread = RenderThread::current(); |
| 266 DCHECK(render_thread); | 263 DCHECK(render_thread); |
| 267 GpuChannelHost* host = render_thread->EstablishGpuChannelSync(); | 264 GpuChannelHost* host = render_thread->EstablishGpuChannelSync(); |
| 268 if (!host) | 265 if (!host) |
| 269 return; | 266 return; |
| 270 gfx::NativeViewId view_id; | |
| 271 #if !defined(OS_MACOSX) | |
| 272 view_id = host_window(); | |
| 273 #else | |
| 274 Send(new ViewHostMsg_AllocateFakePluginWindowHandle( | |
| 275 routing_id(), true, true, &plugin_handle_)); | |
| 276 if (!plugin_handle_) | |
| 277 return; | |
| 278 view_id = static_cast<gfx::NativeViewId>(plugin_handle_); | |
| 279 #endif | |
| 280 const int32 attribs[] = { | 267 const int32 attribs[] = { |
| 281 ggl::GGL_ALPHA_SIZE, 8, | 268 ggl::GGL_ALPHA_SIZE, 8, |
| 282 ggl::GGL_DEPTH_SIZE, 0, | 269 ggl::GGL_DEPTH_SIZE, 0, |
| 283 ggl::GGL_STENCIL_SIZE, 0, | 270 ggl::GGL_STENCIL_SIZE, 0, |
| 284 ggl::GGL_SAMPLES, 0, | 271 ggl::GGL_SAMPLES, 0, |
| 285 ggl::GGL_SAMPLE_BUFFERS, 0, | 272 ggl::GGL_SAMPLE_BUFFERS, 0, |
| 286 ggl::GGL_NONE, | 273 ggl::GGL_NONE, |
| 287 }; | 274 }; |
| 288 context_ = ggl::CreateViewContext( | 275 context_ = ggl::CreateViewContext( |
| 289 host, | 276 host, |
| 290 view_id, | |
| 291 routing_id(), | 277 routing_id(), |
| 292 "GL_OES_packed_depth_stencil GL_OES_depth24", | 278 "GL_OES_packed_depth_stencil GL_OES_depth24", |
| 293 attribs); | 279 attribs); |
| 294 if (!context_ || !InitContext()) { | 280 if (!context_ || !InitContext()) { |
| 295 DestroyContext(); | 281 DestroyContext(); |
| 296 return; | 282 return; |
| 297 } | 283 } |
| 298 ggl::SetSwapBuffersCallback( | 284 ggl::SetSwapBuffersCallback( |
| 299 context_, | 285 context_, |
| 300 NewCallback(this, &RenderWidgetFullscreenPepper::DidFlushPaint)); | 286 NewCallback(this, &RenderWidgetFullscreenPepper::DidFlushPaint)); |
| 301 } | 287 } |
| 302 | 288 |
| 303 void RenderWidgetFullscreenPepper::DestroyContext() { | 289 void RenderWidgetFullscreenPepper::DestroyContext() { |
| 304 if (context_) { | 290 if (context_) { |
| 305 gpu::gles2::GLES2Implementation* gl = ggl::GetImplementation(context_); | 291 gpu::gles2::GLES2Implementation* gl = ggl::GetImplementation(context_); |
| 306 if (program_) { | 292 if (program_) { |
| 307 gl->DeleteProgram(program_); | 293 gl->DeleteProgram(program_); |
| 308 program_ = 0; | 294 program_ = 0; |
| 309 } | 295 } |
| 310 if (buffer_) { | 296 if (buffer_) { |
| 311 gl->DeleteBuffers(1, &buffer_); | 297 gl->DeleteBuffers(1, &buffer_); |
| 312 buffer_ = 0; | 298 buffer_ = 0; |
| 313 } | 299 } |
| 314 ggl::DestroyContext(context_); | 300 ggl::DestroyContext(context_); |
| 315 context_ = NULL; | 301 context_ = NULL; |
| 316 } | 302 } |
| 317 #if defined(OS_MACOSX) | |
| 318 if (plugin_handle_) { | |
| 319 Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(), | |
| 320 plugin_handle_)); | |
| 321 plugin_handle_ = NULL; | |
| 322 } | |
| 323 #endif | |
| 324 } | 303 } |
| 325 | 304 |
| 326 namespace { | 305 namespace { |
| 327 | 306 |
| 328 const char kVertexShader[] = | 307 const char kVertexShader[] = |
| 329 "attribute vec2 in_tex_coord;\n" | 308 "attribute vec2 in_tex_coord;\n" |
| 330 "varying vec2 tex_coord;\n" | 309 "varying vec2 tex_coord;\n" |
| 331 "void main() {\n" | 310 "void main() {\n" |
| 332 " gl_Position = vec4(in_tex_coord.x * 2. - 1.,\n" | 311 " gl_Position = vec4(in_tex_coord.x * 2. - 1.,\n" |
| 333 " in_tex_coord.y * 2. - 1.,\n" | 312 " in_tex_coord.y * 2. - 1.,\n" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return true; | 396 return true; |
| 418 } | 397 } |
| 419 | 398 |
| 420 bool RenderWidgetFullscreenPepper::CheckCompositing() { | 399 bool RenderWidgetFullscreenPepper::CheckCompositing() { |
| 421 bool compositing = webwidget_->isAcceleratedCompositingActive(); | 400 bool compositing = webwidget_->isAcceleratedCompositingActive(); |
| 422 if (compositing != is_accelerated_compositing_active_) { | 401 if (compositing != is_accelerated_compositing_active_) { |
| 423 didActivateAcceleratedCompositing(compositing); | 402 didActivateAcceleratedCompositing(compositing); |
| 424 } | 403 } |
| 425 return compositing; | 404 return compositing; |
| 426 } | 405 } |
| OLD | NEW |