OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/common/gpu/client/gpu_channel_host.h" |
9 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
10 #include "content/renderer/gpu/gpu_channel_host.h" | |
11 #include "content/renderer/pepper_platform_context_3d_impl.h" | 11 #include "content/renderer/pepper_platform_context_3d_impl.h" |
12 #include "content/renderer/render_thread_impl.h" | 12 #include "content/renderer/render_thread_impl.h" |
13 #include "gpu/command_buffer/client/gles2_implementation.h" | 13 #include "gpu/command_buffer/client/gles2_implementation.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidget.h" |
17 #include "ui/gfx/gl/gpu_preference.h" | 17 #include "ui/gfx/gl/gpu_preference.h" |
18 #include "webkit/plugins/ppapi/plugin_delegate.h" | 18 #include "webkit/plugins/ppapi/plugin_delegate.h" |
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
20 | 20 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return; | 79 return; |
80 | 80 |
81 WebRect plugin_rect(0, 0, size_.width, size_.height); | 81 WebRect plugin_rect(0, 0, size_.width, size_.height); |
82 widget_->plugin()->Paint(canvas, plugin_rect, rect); | 82 widget_->plugin()->Paint(canvas, plugin_rect, rect); |
83 } | 83 } |
84 | 84 |
85 virtual void composite(bool finish) { | 85 virtual void composite(bool finish) { |
86 if (!widget_->plugin()) | 86 if (!widget_->plugin()) |
87 return; | 87 return; |
88 | 88 |
89 RendererGLContext* context = widget_->context(); | 89 ContentGLContext* context = widget_->context(); |
90 DCHECK(context); | 90 DCHECK(context); |
91 gpu::gles2::GLES2Implementation* gl = context->GetImplementation(); | 91 gpu::gles2::GLES2Implementation* gl = context->GetImplementation(); |
92 unsigned int texture = widget_->plugin()->GetBackingTextureId(); | 92 unsigned int texture = widget_->plugin()->GetBackingTextureId(); |
93 gl->BindTexture(GL_TEXTURE_2D, texture); | 93 gl->BindTexture(GL_TEXTURE_2D, texture); |
94 gl->DrawArrays(GL_TRIANGLES, 0, 3); | 94 gl->DrawArrays(GL_TRIANGLES, 0, 3); |
95 widget_->SwapBuffers(); | 95 widget_->SwapBuffers(); |
96 } | 96 } |
97 | 97 |
98 virtual void themeChanged() { | 98 virtual void themeChanged() { |
99 NOTIMPLEMENTED(); | 99 NOTIMPLEMENTED(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 (widget_->plugin()->GetBackingTextureId() != 0); | 194 (widget_->plugin()->GetBackingTextureId() != 0); |
195 } | 195 } |
196 | 196 |
197 private: | 197 private: |
198 RenderWidgetFullscreenPepper* widget_; | 198 RenderWidgetFullscreenPepper* widget_; |
199 WebSize size_; | 199 WebSize size_; |
200 | 200 |
201 DISALLOW_COPY_AND_ASSIGN(PepperWidget); | 201 DISALLOW_COPY_AND_ASSIGN(PepperWidget); |
202 }; | 202 }; |
203 | 203 |
204 void DestroyContext(RendererGLContext* context, GLuint program, GLuint buffer) { | 204 void DestroyContext(ContentGLContext* context, GLuint program, GLuint buffer) { |
205 DCHECK(context); | 205 DCHECK(context); |
206 gpu::gles2::GLES2Implementation* gl = context->GetImplementation(); | 206 gpu::gles2::GLES2Implementation* gl = context->GetImplementation(); |
207 if (program) | 207 if (program) |
208 gl->DeleteProgram(program); | 208 gl->DeleteProgram(program); |
209 if (buffer) | 209 if (buffer) |
210 gl->DeleteBuffers(1, &buffer); | 210 gl->DeleteBuffers(1, &buffer); |
211 delete context; | 211 delete context; |
212 } | 212 } |
213 | 213 |
214 } // anonymous namespace | 214 } // anonymous namespace |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 337 } |
338 | 338 |
339 void RenderWidgetFullscreenPepper::CreateContext() { | 339 void RenderWidgetFullscreenPepper::CreateContext() { |
340 DCHECK(!context_); | 340 DCHECK(!context_); |
341 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 341 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
342 GpuChannelHost* host = render_thread->EstablishGpuChannelSync( | 342 GpuChannelHost* host = render_thread->EstablishGpuChannelSync( |
343 content::CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); | 343 content::CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT); |
344 if (!host) | 344 if (!host) |
345 return; | 345 return; |
346 const int32 attribs[] = { | 346 const int32 attribs[] = { |
347 RendererGLContext::ALPHA_SIZE, 8, | 347 ContentGLContext::ALPHA_SIZE, 8, |
348 RendererGLContext::DEPTH_SIZE, 0, | 348 ContentGLContext::DEPTH_SIZE, 0, |
349 RendererGLContext::STENCIL_SIZE, 0, | 349 ContentGLContext::STENCIL_SIZE, 0, |
350 RendererGLContext::SAMPLES, 0, | 350 ContentGLContext::SAMPLES, 0, |
351 RendererGLContext::SAMPLE_BUFFERS, 0, | 351 ContentGLContext::SAMPLE_BUFFERS, 0, |
352 RendererGLContext::SHARE_RESOURCES, 0, | 352 ContentGLContext::SHARE_RESOURCES, 0, |
353 RendererGLContext::BIND_GENERATES_RESOURCES, 1, | 353 ContentGLContext::BIND_GENERATES_RESOURCES, 1, |
354 RendererGLContext::NONE, | 354 ContentGLContext::NONE, |
355 }; | 355 }; |
356 context_ = RendererGLContext::CreateViewContext( | 356 context_ = ContentGLContext::CreateViewContext( |
357 host, | 357 host, |
358 surface_id(), | 358 surface_id(), |
359 NULL, | 359 NULL, |
360 "GL_OES_packed_depth_stencil GL_OES_depth24", | 360 "GL_OES_packed_depth_stencil GL_OES_depth24", |
361 attribs, | 361 attribs, |
362 active_url_, | 362 active_url_, |
363 gfx::PreferIntegratedGpu); | 363 gfx::PreferIntegratedGpu); |
364 if (!context_) | 364 if (!context_) |
365 return; | 365 return; |
366 | 366 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 didDeactivateCompositor(); | 480 didDeactivateCompositor(); |
481 } | 481 } |
482 return compositing; | 482 return compositing; |
483 } | 483 } |
484 | 484 |
485 void RenderWidgetFullscreenPepper::SwapBuffers() { | 485 void RenderWidgetFullscreenPepper::SwapBuffers() { |
486 DCHECK(context_); | 486 DCHECK(context_); |
487 OnSwapBuffersPosted(); | 487 OnSwapBuffersPosted(); |
488 context_->SwapBuffers(); | 488 context_->SwapBuffers(); |
489 context_->Echo(base::Bind( | 489 context_->Echo(base::Bind( |
490 &RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext, | 490 &RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByContentGLContext, |
491 weak_ptr_factory_.GetWeakPtr())); | 491 weak_ptr_factory_.GetWeakPtr())); |
492 | 492 |
493 // The compositor isn't actually active in this path, but pretend it is for | 493 // The compositor isn't actually active in this path, but pretend it is for |
494 // scheduling purposes. | 494 // scheduling purposes. |
495 didCommitAndDrawCompositorFrame(); | 495 didCommitAndDrawCompositorFrame(); |
496 } | 496 } |
497 | 497 |
498 void RenderWidgetFullscreenPepper::OnLostContext( | 498 void RenderWidgetFullscreenPepper::OnLostContext( |
499 RendererGLContext::ContextLostReason) { | 499 ContentGLContext::ContextLostReason) { |
500 if (!context_) | 500 if (!context_) |
501 return; | 501 return; |
502 // Destroy the context later, in case we got called from InitContext for | 502 // Destroy the context later, in case we got called from InitContext for |
503 // example. We still need to reset context_ now so that a new context gets | 503 // example. We still need to reset context_ now so that a new context gets |
504 // created when the plugin recreates its own. | 504 // created when the plugin recreates its own. |
505 MessageLoop::current()->PostTask( | 505 MessageLoop::current()->PostTask( |
506 FROM_HERE, | 506 FROM_HERE, |
507 base::Bind(&DestroyContext, context_, program_, buffer_)); | 507 base::Bind(&DestroyContext, context_, program_, buffer_)); |
508 context_ = NULL; | 508 context_ = NULL; |
509 program_ = 0; | 509 program_ = 0; |
510 buffer_ = 0; | 510 buffer_ = 0; |
511 OnSwapBuffersAborted(); | 511 OnSwapBuffersAborted(); |
512 CheckCompositing(); | 512 CheckCompositing(); |
513 } | 513 } |
514 | 514 |
515 void RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext() { | 515 void RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByContentGLContext() { |
516 OnSwapBuffersComplete(); | 516 OnSwapBuffersComplete(); |
517 } | 517 } |
518 | 518 |
519 RendererGLContext* | 519 ContentGLContext* |
520 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { | 520 RenderWidgetFullscreenPepper::GetParentContextForPlatformContext3D() { |
521 if (!context_) { | 521 if (!context_) { |
522 CreateContext(); | 522 CreateContext(); |
523 } | 523 } |
524 if (!context_) | 524 if (!context_) |
525 return NULL; | 525 return NULL; |
526 return context_; | 526 return context_; |
527 } | 527 } |
OLD | NEW |