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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( | 221 RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( |
222 RenderThreadBase* render_thread, | 222 RenderThreadBase* render_thread, |
223 webkit::ppapi::PluginInstance* plugin, | 223 webkit::ppapi::PluginInstance* plugin, |
224 const GURL& active_url) | 224 const GURL& active_url) |
225 : RenderWidgetFullscreen(render_thread), | 225 : RenderWidgetFullscreen(render_thread), |
226 active_url_(active_url), | 226 active_url_(active_url), |
227 plugin_(plugin), | 227 plugin_(plugin), |
228 context_(NULL), | 228 context_(NULL), |
229 buffer_(0), | 229 buffer_(0), |
230 program_(0) { | 230 program_(0), |
| 231 method_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
231 } | 232 } |
232 | 233 |
233 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { | 234 RenderWidgetFullscreenPepper::~RenderWidgetFullscreenPepper() { |
234 if (context_) | 235 if (context_) |
235 DestroyContext(context_, program_, buffer_); | 236 DestroyContext(context_, program_, buffer_); |
236 } | 237 } |
237 | 238 |
238 void RenderWidgetFullscreenPepper::Invalidate() { | 239 void RenderWidgetFullscreenPepper::Invalidate() { |
239 InvalidateRect(gfx::Rect(size_.width(), size_.height())); | 240 InvalidateRect(gfx::Rect(size_.width(), size_.height())); |
240 } | 241 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 attribs, | 357 attribs, |
357 active_url_); | 358 active_url_); |
358 if (!context_) | 359 if (!context_) |
359 return; | 360 return; |
360 | 361 |
361 if (!InitContext()) { | 362 if (!InitContext()) { |
362 DestroyContext(context_, program_, buffer_); | 363 DestroyContext(context_, program_, buffer_); |
363 context_ = NULL; | 364 context_ = NULL; |
364 return; | 365 return; |
365 } | 366 } |
366 context_->SetSwapBuffersCallback( | |
367 NewCallback(this, | |
368 &RenderWidgetFullscreenPepper:: | |
369 OnSwapBuffersCompleteByRendererGLContext)); | |
370 context_->SetContextLostCallback( | 367 context_->SetContextLostCallback( |
371 NewCallback(this, &RenderWidgetFullscreenPepper::OnLostContext)); | 368 NewCallback(this, &RenderWidgetFullscreenPepper::OnLostContext)); |
372 } | 369 } |
373 | 370 |
374 namespace { | 371 namespace { |
375 | 372 |
376 const char kVertexShader[] = | 373 const char kVertexShader[] = |
377 "attribute vec2 in_tex_coord;\n" | 374 "attribute vec2 in_tex_coord;\n" |
378 "varying vec2 tex_coord;\n" | 375 "varying vec2 tex_coord;\n" |
379 "void main() {\n" | 376 "void main() {\n" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 webwidget_ && webwidget_->isAcceleratedCompositingActive(); | 467 webwidget_ && webwidget_->isAcceleratedCompositingActive(); |
471 if (compositing != is_accelerated_compositing_active_) | 468 if (compositing != is_accelerated_compositing_active_) |
472 didActivateAcceleratedCompositing(compositing); | 469 didActivateAcceleratedCompositing(compositing); |
473 return compositing; | 470 return compositing; |
474 } | 471 } |
475 | 472 |
476 void RenderWidgetFullscreenPepper::SwapBuffers() { | 473 void RenderWidgetFullscreenPepper::SwapBuffers() { |
477 DCHECK(context_); | 474 DCHECK(context_); |
478 OnSwapBuffersPosted(); | 475 OnSwapBuffersPosted(); |
479 context_->SwapBuffers(); | 476 context_->SwapBuffers(); |
| 477 context_->Echo(method_factory_.NewRunnableMethod( |
| 478 &RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext)); |
480 } | 479 } |
481 | 480 |
482 void RenderWidgetFullscreenPepper::OnLostContext( | 481 void RenderWidgetFullscreenPepper::OnLostContext( |
483 RendererGLContext::ContextLostReason) { | 482 RendererGLContext::ContextLostReason) { |
484 if (!context_) | 483 if (!context_) |
485 return; | 484 return; |
486 // Destroy the context later, in case we got called from InitContext for | 485 // Destroy the context later, in case we got called from InitContext for |
487 // example. We still need to reset context_ now so that a new context gets | 486 // example. We still need to reset context_ now so that a new context gets |
488 // created when the plugin recreates its own. | 487 // created when the plugin recreates its own. |
489 MessageLoop::current()->PostTask( | 488 MessageLoop::current()->PostTask( |
490 FROM_HERE, | 489 FROM_HERE, |
491 NewRunnableFunction(DestroyContext, context_, program_, buffer_)); | 490 NewRunnableFunction(DestroyContext, context_, program_, buffer_)); |
492 context_ = NULL; | 491 context_ = NULL; |
493 program_ = 0; | 492 program_ = 0; |
494 buffer_ = 0; | 493 buffer_ = 0; |
495 OnSwapBuffersAborted(); | 494 OnSwapBuffersAborted(); |
496 CheckCompositing(); | 495 CheckCompositing(); |
497 } | 496 } |
498 | 497 |
499 void RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext() { | 498 void RenderWidgetFullscreenPepper::OnSwapBuffersCompleteByRendererGLContext() { |
500 OnSwapBuffersComplete(); | 499 OnSwapBuffersComplete(); |
501 } | 500 } |
OLD | NEW |